Example #1
0
 public function testAddAndGetQueries()
 {
     $client = new Client();
     $client->clearEndpoints();
     $client->createEndpoint('local1');
     $endpoint2 = $client->createEndpoint('local2');
     $this->plugin->initPlugin($client, array());
     $query1 = $client->createSelect()->setQuery('test1');
     $query2 = $client->createSelect()->setQuery('test2');
     $this->plugin->addQuery(1, $query1);
     $this->plugin->addQuery(2, $query2, $endpoint2);
     $this->assertEquals(array(1 => array('query' => $query1, 'endpoint' => 'local1'), 2 => array('query' => $query2, 'endpoint' => 'local2')), $this->plugin->getQueries());
 }
 public function testExecuteRequestWithOverridingPlugin()
 {
     $request = new Request();
     $response = new Response('', array('HTTP 1.0 200 OK'));
     $endpoint = $this->client->createEndpoint('s1');
     $expectedEvent = new PreExecuteRequestEvent($request, $endpoint);
     $expectedEvent->setDispatcher($this->client->getEventDispatcher());
     $expectedEvent->setName(Events::PRE_EXECUTE_REQUEST);
     $test = $this;
     $this->client->getEventDispatcher()->addListener(Events::PRE_EXECUTE_REQUEST, function (PreExecuteRequestEvent $event) use($test, $response, $expectedEvent) {
         $test->assertEquals($expectedEvent, $event);
         $event->setResponse($response);
     });
     $returnedResponse = $this->client->executeRequest($request, $endpoint);
     $this->assertEquals($response, $returnedResponse);
 }