diff --git a/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php b/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php index 3ab4a66680e0..ad6ffe402047 100644 --- a/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php +++ b/src/Illuminate/Foundation/Exceptions/Renderer/Listener.php @@ -44,7 +44,7 @@ public function registerListeners(Dispatcher $events) /** * Returns the queries that have been executed. * - * @return array + * @return array */ public function queries() { diff --git a/tests/Foundation/Exceptions/Renderer/ListenerTest.php b/tests/Foundation/Exceptions/Renderer/ListenerTest.php new file mode 100644 index 000000000000..fd44ba609cc5 --- /dev/null +++ b/tests/Foundation/Exceptions/Renderer/ListenerTest.php @@ -0,0 +1,47 @@ +shouldReceive('getName')->andReturn('testing'); + $connection->shouldReceive('prepareBindings')->with(['foo'])->andReturn(['foo']); + + $event = new QueryExecuted('select * from users where id = ?', ['foo'], 5.2, $connection); + + $listener = new Listener(); + + $listener->onQueryExecuted($event); + + $queries = $listener->queries(); + + $this->assertIsArray($queries); + $this->assertCount(1, $queries); + + $query = $queries[0]; + + $this->assertArrayHasKey('connectionName', $query); + $this->assertArrayHasKey('time', $query); + $this->assertArrayHasKey('sql', $query); + $this->assertArrayHasKey('bindings', $query); + + $this->assertEquals('testing', $query['connectionName']); + $this->assertEquals(5.2, $query['time']); + $this->assertEquals('select * from users where id = ?', $query['sql']); + $this->assertEquals(['foo'], $query['bindings']); + } +}