onResult() public method

Attach an results filter, gets called with the query, result and the time taken, returns result
public onResult ( $callback )
Esempio n. 1
0
 public function testFilteringResults()
 {
     $connection = \Mockery::mock('\\Pheasant\\Database\\Mysqli\\Connection');
     $result = \Mockery::mock('\\Pheasant\\Database\\Mysqli\\ResultSet');
     $filter = new FilterChain();
     $results = array();
     $filter->onResult(function ($sql, $result, $time) use(&$results) {
         $results[] = func_get_args();
     });
     $connection->shouldReceive('execute')->with('SELECT 1')->andReturn($result)->once();
     $filter->execute('SELECT 1', function ($sql) use($connection) {
         return $connection->execute($sql);
     });
     $this->assertEquals(count($results), 1);
     $this->assertEquals('SELECT 1', $results[0][0]);
     $this->assertSame($result, $results[0][1]);
     $this->assertFalse(is_null($results[0][2]));
 }