Pheasant\Tests\FilterChainTest::testCatchingErrors PHP Метод

testCatchingErrors() публичный Метод

public testCatchingErrors ( )
    public function testCatchingErrors()
    {
        $connection = \Mockery::mock('\\Pheasant\\Database\\Mysqli\\Connection');
        $filter = new FilterChain();
        $exceptions = array();
        $filter->onError(function ($e) use(&$exceptions) {
            $exceptions[] = $e;
        });
        $connection->shouldReceive('execute')->andThrow(new \Exception('Eeeeek!'));
        try {
            $filter->execute('SELECT 1', function ($sql) use($connection) {
                $connection->execute($sql);
            });
            $this->fail('Exception expected');
        } catch (\Exception $e) {
            $this->assertEquals($e->getMessage(), 'Eeeeek!');
        }
        $this->assertEquals(count($exceptions), 1);
        $this->assertEquals($exceptions[0]->getMessage(), 'Eeeeek!');
    }