/tests/LogShutdownTest.php
PHP | 29 lines | 24 code | 2 blank | 3 comment | 0 complexity | ec4e2b6a6b8cc7b780b30bef5c9ae035 MD5 | raw file
- <?php
- require_once dirname(__FILE__).'/../../padrino/src/PadrinoTestCase.php';
-
- class LogShutdownTest extends PadrinoTestCase{
- public function testExceptionEvent(){
- $dir = dirname(__FILE__).'/_temp_';
- PurFile::delete($dir);
- ob_start();
- passthru('php '.dirname(__FILE__).'/LogShutdownTest/log.php 2>/dev/null');
- $stdout = ob_get_contents();
- ob_end_clean();
- // Check script execution
- $stdout = preg_replace('/\/.*?log\.php/','log.php',trim($stdout));
- // Note: xdebug add a stack strace, so only assert the first line
- preg_match('/.*/',$stdout,$matches);
- $this->assertSame('Fatal error: Maximum execution time of 1 second exceeded in log.php on line 23',$matches[0]);
- // Validate log content
- $expect = PurFile::read(dirname(__FILE__).'/LogShutdownTest/expect.log');
- $expect = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} GMT)/','{date}',$expect);
- $assert = PurFile::read($dir.'/error.log');
- $assert = preg_replace('/(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} GMT)/','{date}',$assert);
- $this->assertSame(
- $expect,
- $assert
- );
- PurFile::delete($dir);
- }
- }