Skip to content

Commit 0056540

Browse files
authored
Merge pull request #28 from understand/bugfix/context-exception-support
add support for 5.7 context->exception, test improvements
2 parents 0709989 + 5fce50f commit 0056540

File tree

8 files changed

+23
-10
lines changed

8 files changed

+23
-10
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
language: php
22

33
php:
4-
- 5.6
54
- 7.0
65
- 7.1
6+
- 7.2
77
- hhvm
88

99
before_script:

composer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
"illuminate/support": "~5.0"
1616
},
1717
"require-dev": {
18-
"phpunit/phpunit": "~5.7",
18+
"phpunit/phpunit": "~6.0",
1919
"mockery/mockery": "^0.9.4",
20-
"orchestra/testbench": "^3.4"
20+
"orchestra/testbench": "^3.5"
2121
},
2222
"autoload": {
2323
"psr-0": {

phpunit.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
convertWarningsToExceptions="true"
99
processIsolation="false"
1010
stopOnFailure="false"
11-
syntaxCheck="false"
1211
>
1312
<testsuites>
1413
<testsuite name="Package Test Suite">

src/Understand/UnderstandLaravel5/UnderstandLaravel5ServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ protected function handleEvent($level, $message, $context)
303303
$this->app['understand.eventLogger']->logEvent($level, $message, $context);
304304
}
305305
// `\Log::notice`, `\Log::warning`, `\Log::error`, `\Log::critical`, `\Log::alert`, `\Log::emergency` and `\Exception`, `\Throwable`
306-
else if ($this->detectLaravelVersion(['5.6']) && isset($context['exception']) && ($context['exception'] instanceof Exception || $context['exception'] instanceof Throwable))
306+
else if ($this->detectLaravelVersion(['5.6', '5.7']) && isset($context['exception']) && ($context['exception'] instanceof Exception || $context['exception'] instanceof Throwable))
307307
{
308308
$exception = $context['exception'];
309309
unset($context['exception']);

tests/EventListenerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ public function testErrorHandlerExceptionLogging()
9393
$called++;
9494
$decoded = json_decode($data, true);
9595

96+
$this->assertEquals('EventListenerTest', $decoded['stack'][0]['class']);
97+
9698
$laravelLogTag = in_array('exception_log', $decoded['tags'], true);
9799
};
98100

@@ -103,7 +105,7 @@ public function testErrorHandlerExceptionLogging()
103105

104106
$this->app->singleton('Illuminate\Contracts\Debug\ExceptionHandler', 'Illuminate\Foundation\Exceptions\Handler');
105107

106-
$exception = new \RuntimeException();
108+
$exception = new \RuntimeException('Test');
107109
$this->app['Illuminate\Foundation\Exceptions\Handler']->report($exception);
108110

109111
$this->assertSame($called, 1);

tests/ExceptionEncoderTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
class ExceptionEncoderTest extends PHPUnit_Framework_TestCase
3+
use PHPUnit\Framework\TestCase;
4+
5+
class ExceptionEncoderTest extends TestCase
46
{
57
public function testExceptionObjectResult()
68
{
@@ -98,7 +100,14 @@ protected function assertIncompleteClassStackTrace($exception, $index)
98100
$encoder = new Understand\UnderstandLaravel5\ExceptionEncoder();
99101
$stackTraceArray = $encoder->stackTraceToArray($exception->getTrace());
100102

101-
$this->assertSame('object(__PHP_Incomplete_Class)', $stackTraceArray[$index]['args'][0]);
103+
if (starts_with(phpversion(), '7.2'))
104+
{
105+
$this->assertSame('__PHP_Incomplete_Class', $stackTraceArray[$index]['args'][0]);
106+
}
107+
else
108+
{
109+
$this->assertSame('object(__PHP_Incomplete_Class)', $stackTraceArray[$index]['args'][0]);
110+
}
102111
}
103112

104113
public function testStackTraceLimit()

tests/TestFileReaderTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

33
use Understand\UnderstandLaravel5\ExceptionEncoder;
4+
use PHPUnit\Framework\TestCase;
45

5-
class TestFileReaderTest extends PHPUnit_Framework_TestCase
6+
class TestFileReaderTest extends TestCase
67
{
78
public function testCodeReader()
89
{

tests/TokenProviderTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22

3-
class TokenProviderTest extends PHPUnit_Framework_TestCase
3+
use PHPUnit\Framework\TestCase;
4+
5+
class TokenProviderTest extends TestCase
46
{
57
public function testRandomToken()
68
{

0 commit comments

Comments
 (0)