Skip to content

Commit e2a44b2

Browse files
committed
Merge branch 'master' into 5.5
2 parents 003ebc1 + 54bbf6f commit e2a44b2

File tree

9 files changed

+94
-78
lines changed

9 files changed

+94
-78
lines changed

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ language: php
33
php:
44
- 7.0
55
- 7.1
6+
- 7.2
67

78
install:
89
- composer update

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
},
2222
"require-dev": {
2323
"phpunit/phpunit": "^6.0",
24-
"mockery/mockery": "^0.9",
24+
"mockery/mockery": "^1.0",
2525
"guzzlehttp/guzzle": "^6.0",
2626
"orchestra/testbench": "3.5.*",
2727
"illuminated/testing-tools": "5.5.*"

composer.lock

+42-41
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Exceptions/ExceptionHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function onShutdown()
6464

6565
$this->logger->info('%separator%');
6666

67-
$handlers = $this->logger->getHandlers();
67+
$handlers = (array) $this->logger->getHandlers();
6868
foreach ($handlers as $handler) {
6969
$handler->close();
7070
}

tests/ConsoleLogger/Exceptions/ExceptionHandlerTest.php

+20-18
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,23 @@ class ExceptionHandlerTest extends TestCase
1414
/** @test */
1515
public function it_logs_an_error_for_all_occurred_application_notices_warnings_errors_and_exceptions()
1616
{
17-
$logger = Mockery::mock(LoggerInterface::class);
18-
$logger->shouldReceive('error')->with('Test exception', Mockery::subset([
19-
'code' => 111,
20-
'message' => 'Test exception',
21-
'file' => __FILE__,
22-
]))->once();
17+
$logger = spy(LoggerInterface::class);
2318

2419
$handler = app(ExceptionHandler::class);
2520
$handler->setLogger($logger);
2621
$handler->report(new Exception('Test exception', 111));
22+
23+
$logger->shouldHaveReceived()->error('Test exception', Mockery::subset([
24+
'code' => 111,
25+
'message' => 'Test exception',
26+
'file' => __FILE__,
27+
]));
2728
}
2829

2930
/** @test */
3031
public function it_supports_custom_runtime_exception_which_has_ability_to_set_optional_context()
3132
{
32-
$logger = Mockery::mock(LoggerInterface::class);
33-
$logger->shouldReceive('error')->with('Test exception with context', Mockery::subset([
34-
'code' => 111,
35-
'message' => 'Test exception with context',
36-
'file' => __FILE__,
37-
'context' => [
38-
'foo' => 'bar',
39-
'baz' => 123,
40-
'faz' => true,
41-
'daz' => null,
42-
],
43-
]))->once();
33+
$logger = spy(LoggerInterface::class);
4434

4535
$handler = app(ExceptionHandler::class);
4636
$handler->setLogger($logger);
@@ -50,5 +40,17 @@ public function it_supports_custom_runtime_exception_which_has_ability_to_set_op
5040
'faz' => true,
5141
'daz' => null,
5242
], 111));
43+
44+
$logger->shouldHaveReceived()->error('Test exception with context', Mockery::subset([
45+
'code' => 111,
46+
'message' => 'Test exception with context',
47+
'file' => __FILE__,
48+
'context' => [
49+
'foo' => 'bar',
50+
'baz' => 123,
51+
'faz' => true,
52+
'daz' => null,
53+
],
54+
]));
5355
}
5456
}

tests/ConsoleLogger/Loggable/Notifications/EmailChannel/EmailChannelTest.php

+1
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ private function normalizeMailerHandlerDump($dump)
161161
$dump = preg_replace('/".*[email protected]"/', '"normalized"', $dump);
162162
$dump = preg_replace('/\+"date": ".*?\.\d*"/', '+date: "normalized"', $dump);
163163
$dump = preg_replace('/date: .*?\.\d*/', 'date: "normalized"', $dump);
164+
$dump = preg_replace('/-dateTime: DateTimeImmutable @\d*/', '-dateTime: DateTimeImmutable @normalized', $dump);
164165
$dump = preg_replace('/-cacheKey: ".*?"/', '-cacheKey: "normalized"', $dump);
165166
$dump = preg_replace('/-_timestamp: .*?\n/', '', $dump);
166167
$dump = preg_replace('/#initialized: .*?\n/', '', $dump);

tests/ConsoleLogger/LoggableTraitOnMysqlTest.php

+12-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use GenericCommand;
66
use Illuminated\Console\Exceptions\ExceptionHandler;
77
use Mockery;
8-
use Monolog\Handler\RotatingFileHandler;
8+
use Monolog\Handler\AbstractProcessingHandler;
99
use Psr\Log\LoggerInterface;
1010

1111
class LoggableTraitOnMysqlTest extends TestCase
@@ -55,20 +55,22 @@ public function it_writes_to_log_file_mysql_specific_information_after_header()
5555
* @runInSeparateProcess
5656
* @preserveGlobalState disabled
5757
*/
58-
public function it_writes_to_log_file_information_footer_each_iteration()
58+
public function it_writes_to_log_file_information_footer_each_iteration_and_close_all_handlers_on_shutdown()
5959
{
60-
$logger = Mockery::mock(LoggerInterface::class);
61-
$logger->shouldReceive('info')->with('/Execution time\: .*? sec\./')->once();
62-
$logger->shouldReceive('info')->with('/Memory peak usage\: .*?\./')->once();
63-
$logger->shouldReceive('info')->with('%separator%')->once();
64-
$logger->shouldReceive('getHandlers')->withNoArgs()->once()->andReturn([
65-
new RotatingFileHandler('foo'),
66-
new RotatingFileHandler('bar'),
67-
new RotatingFileHandler('baz'),
60+
$logger = spy(LoggerInterface::class);
61+
$logger->expects()->getHandlers()->andReturn([
62+
$processingHandler1 = spy(AbstractProcessingHandler::class),
63+
$processingHandler2 = spy(AbstractProcessingHandler::class),
6864
]);
6965

7066
$handler = app(ExceptionHandler::class);
7167
$handler->initialize($logger);
7268
$handler->onShutdown();
69+
70+
$logger->shouldHaveReceived()->info(Mockery::pattern('/Execution time\: .*? sec\./'));
71+
$logger->shouldHaveReceived()->info(Mockery::pattern('/Memory peak usage\: .*?\./'));
72+
$logger->shouldHaveReceived()->info('%separator%');
73+
$processingHandler1->shouldHaveReceived()->close();
74+
$processingHandler2->shouldHaveReceived()->close();
7375
}
7476
}

0 commit comments

Comments
 (0)