public function logResult(PostExecute $event) { $this->requests[spl_object_hash($event->getQuery())] += ['result' => $event->getResult(), 'end' => microtime(TRUE)]; $result = $event->getResult(); $data = $event->getResult()->getData(); $this->totalTime += isset($data['responseHeader']['QTime']) ? $data['responseHeader']['QTime'] : 0; if ($result instanceof SelectResult && $result->getDebug()->getTiming() !== NULL) { $this->totalTime -= $result->getDebug()->getTiming()->getPhase('process')->getTiming('debug'); } }
public function testConstructorAndGetters() { $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 = new PostExecute($query, $result); $this->assertEquals($query, $event->getQuery()); $this->assertEquals($result, $event->getResult()); }
public function testExecutePostPlugin() { $query = new PingQuery(); $response = new Response('', array('HTTP 1.0 200 OK')); $result = new Result($this->client, $query, $response); $expectedEvent = new PostExecuteEvent($query, $result); $expectedEvent->setName(Events::POST_EXECUTE); $mock = $this->getMock('Solarium\\Core\\Client\\Client', array('createRequest', 'executeRequest', 'createResult')); $mock->expects($this->once())->method('createRequest')->will($this->returnValue('dummyrequest')); $mock->expects($this->once())->method('executeRequest')->will($this->returnValue('dummyresponse')); $mock->expects($this->once())->method('createResult')->will($this->returnValue($result)); $observer = $this->getMock('Solarium\\Core\\Plugin\\Plugin', array('postExecute')); $observer->expects($this->once())->method('postExecute')->with($this->equalTo($expectedEvent)); $mock->getEventDispatcher()->addListener(Events::POST_EXECUTE, array($observer, 'postExecute')); $expectedEvent->setDispatcher($mock->getEventDispatcher()); $mock->execute($query); }