diff options
author | diosmosis <diosmosis@users.noreply.github.com> | 2018-08-03 04:01:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-03 04:01:37 +0300 |
commit | f8ea46b3252ee14da53b32a9118e2af494c29eac (patch) | |
tree | ef57f1b96a0eba2477fd3939ddfdb1401dbfbcff /tests/PHPUnit | |
parent | cb1d83db863938ace3ebdafd072dfd32e434fded (diff) |
Reconstruct partial stack traces for fatal errors. (#13238)
* Reconstruct partial stack traces for fatal errors.
* tweak to fatal error breadcrumb
* Add docs + fix test.
* Add fatal error test and improve fatal error stack trace a bit.
* fix test on travis
Diffstat (limited to 'tests/PHPUnit')
-rw-r--r-- | tests/PHPUnit/Integration/ErrorHandlerTest.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/tests/PHPUnit/Integration/ErrorHandlerTest.php b/tests/PHPUnit/Integration/ErrorHandlerTest.php new file mode 100644 index 0000000000..eaf290c574 --- /dev/null +++ b/tests/PHPUnit/Integration/ErrorHandlerTest.php @@ -0,0 +1,39 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +namespace Piwik\Tests\Integration; + + +use Piwik\Http; +use Piwik\Tests\Framework\Fixture; +use Piwik\Tests\Framework\TestCase\IntegrationTestCase; + +class ErrorHandlerTest extends IntegrationTestCase +{ + public function test_fatalErrorStackTracesReturned() + { + $url = Fixture::getRootUrl() . '/tests/resources/trigger-fatal.php?format=json'; + $response = Http::sendHttpRequest($url, 2); + + $response = json_decode($response, $isAssoc = true); + $response['message'] = $this->cleanMessage($response['message']); + + $this->assertEquals('error', $response['result']); + + $expectedFormat = <<<FORMAT +Allowed memory size of %s bytes exhausted (tried to allocate %s bytes) on {includePath}/tests/resources/trigger-fatal.php(22)#0 {includePath}/tests/resources/trigger-fatal.php(35): MyClass->triggerError()#1 {includePath}/tests/resources/trigger-fatal.php(51): MyDerivedClass::staticMethod()#2 {includePath}/tests/resources/trigger-fatal.php(57): myFunction() +FORMAT; + + $this->assertStringMatchesFormat($expectedFormat, $response['message']); + } + + private function cleanMessage($message) + { + return str_replace(PIWIK_INCLUDE_PATH, '{includePath}', $message); + } +}
\ No newline at end of file |