public function testPluginIntegration() { $client = new Client(); $client->registerPlugin('testplugin', $this->plugin); $input = array('key' => 'xid', 'type' => 'param', 'name' => 'xid', 'value' => 123); $this->plugin->addCustomization($input); $originalRequest = new Request(); $expectedRequest = new Request(); $expectedRequest->addParam('xid', 123); // this should be the effect of the customization $observer = $this->getMock('Solarium\\Core\\Client\\Adapter\\Http', array('execute')); $observer->expects($this->once())->method('execute')->with($this->equalTo($expectedRequest))->will($this->returnValue(new Response('', array('HTTP 1.0 200 OK')))); $client->setAdapter($observer); $client->executeRequest($originalRequest); }
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); }