public function testHandle()
{
$record = ['level' => Logger::DEBUG, 'extra' => ['contao' => new ContaoContext('foobar')], 'context' => [], 'datetime' => new \DateTime(), 'message' => 'foobar'];
/** @var Statement|\PHPUnit_Framework_MockObject_MockObject $connection */
$statement = $this->getMock('Doctrine\\DBAL\\Statement', ['execute'], [], '', false);
$statement->expects($this->once())->method('execute');
/** @var Connection|\PHPUnit_Framework_MockObject_MockObject $connection */
$connection = $this->getMock('Doctrine\\DBAL\\Connection', ['prepare'], [], '', false);
$connection->expects($this->any())->method('prepare')->willReturn($statement);
$container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerBuilder')->setMethods(['has', 'get'])->getMock();
$container->expects($this->any())->method('has')->willReturn(true);
$container->expects($this->any())->method('get')->willReturnCallback(function ($key) use($connection) {
switch ($key) {
case 'contao.framework':
return $this->mockContaoFramework();
case 'doctrine.dbal.default_connection':
return $connection;
}
});
$handler = new ContaoTableHandler();
$handler->setContainer($container);
$this->assertFalse($handler->handle($record));
}