public function logQuery(PreExecute $event) { $this->requests[spl_object_hash($event->getQuery())] = ['query' => $event->getQuery(), 'start' => microtime(TRUE)]; $query = $event->getQuery(); if ($query instanceof SelectQuery) { $query->getDebug(); $query->setOptions(['omitheader' => FALSE, 'debug' => TRUE]); } }
/** * @depends testConstructorAndGetters * * @param PreExecute $event */ public function testSetAndGetQuery($event) { $client = new Client(); $query = $client->createSelect(); $query->setQuery('test123'); $response = new Response('', array('HTTP 1.0 200 OK')); $result = new Result($client, $query, $response); $event->setResult($result); $this->assertEquals($result, $event->getResult()); }
public function testExecuteWithOverridingPlugin() { $query = new PingQuery(); $response = new Response('', array('HTTP 1.0 200 OK')); $expectedResult = new Result($this->client, $query, $response); $expectedEvent = new PreExecuteEvent($query); $expectedEvent->setDispatcher($this->client->getEventDispatcher()); $expectedEvent->setName(Events::PRE_EXECUTE); $test = $this; $this->client->getEventDispatcher()->addListener(Events::PRE_EXECUTE, function (PreExecuteEvent $event) use($test, $expectedResult, $expectedEvent) { $test->assertEquals($expectedEvent, $event); $event->setResult($expectedResult); }); $returnedResult = $this->client->execute($query); $this->assertEquals($expectedResult, $returnedResult); }