Source of file DebugErrorReporterTest.php
Size: 2,502 Bytes - Last Modified: 2021-12-24T06:35:34+00:00
/var/www/docs.ssmods.com/process/src/tests/Camspiers/LoggerBridge/DebugErrorReporterTest.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 | <?php namespace Camspiers\LoggerBridge; use Camspiers\LoggerBridge\ErrorReporter\DebugErrorReporter; use Config; class DebugErrorReporterTest extends \PHPUnit_Framework_TestCase { public function testReportErrorNotLive() { Config::inst()->update('SS_Backtrace', 'ignore_function_args', array()); $envMock = $this->getMock(__NAMESPACE__.'\EnvReporter\EnvReporter'); $envMock->expects($this->once()) ->method('isLive') ->will($this->returnValue(false)); $debugErrorReporter = new DebugErrorReporter($envMock); ob_start(); $debugErrorReporter->reportError( new \ErrorException( 'Error message', E_USER_ERROR, 0, 'example-file.php', 10 ) ); $contents = ob_get_contents(); ob_end_clean(); $this->assertContains( '[User Error]', $contents ); $this->assertContains( 'Error message', $contents ); $this->assertContains( 'Line 10 in example-file.php', $contents ); } public function testReportErrorLive() { Config::inst()->update('Director', 'alternate_base_url', 'http://localhost'); define('BASE_URL', 'http://localhost/'); define('FRAMEWORK_DIR', 'framework'); $_SERVER['REQUEST_METHOD'] = 'GET'; $_SERVER['REQUEST_URI'] = '/'; Config::inst()->update('SS_Backtrace', 'ignore_function_args', array()); $envMock = $this->getMock(__NAMESPACE__.'\EnvReporter\EnvReporter'); $envMock->expects($this->once()) ->method('isLive') ->will($this->returnValue(true)); $debugErrorReporter = new DebugErrorReporter($envMock); ob_start(); $debugErrorReporter->reportError( new \ErrorException( 'Error message', E_USER_ERROR, 0, 'example-file.php', 10 ) ); $contents = ob_get_contents(); ob_end_clean(); $this->assertEquals( <<<HTML <!DOCTYPE html><html><head><title>GET /</title><link rel="stylesheet" type="text/css" href="http://localhost/framework/css/debug.css" /></head><body><div class="info"><h1>Website Error</h1></div></body></html> HTML , $contents ); } } |