execute() public method

Executes the query through the internal filters and executor
public execute ( $sql, $executor ) : result
return result set of some sort
Example #1
0
 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!');
 }