Exemplo n.º 1
0
 public function testCreateResultPostPlugin()
 {
     $query = new SelectQuery();
     $response = new Response('', array('HTTP 1.0 200 OK'));
     $result = $this->client->createResult($query, $response);
     $expectedEvent = new PostCreateResultEvent($query, $response, $result);
     $expectedEvent->setDispatcher($this->client->getEventDispatcher());
     $expectedEvent->setName(Events::POST_CREATE_RESULT);
     $observer = $this->getMock('Solarium\\Core\\Plugin\\Plugin', array('postCreateResult'));
     $observer->expects($this->once())->method('postCreateResult')->with($this->equalTo($expectedEvent));
     $this->client->registerPlugin('testplugin', $observer);
     $this->client->getEventDispatcher()->addListener(Events::POST_CREATE_RESULT, array($observer, 'postCreateResult'));
     $this->client->createResult($query, $response);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public function testPluginIntegration()
 {
     $client = new Client();
     $client->registerPlugin('testplugin', $this->plugin);
     $this->plugin->setMaxQueryStringLength(1);
     // this forces POST for even the smallest queries
     $query = $client->createSelect();
     $request = $client->createRequest($query);
     // default method is GET, the plugin should have changed this to POST
     $this->assertEquals(Request::METHOD_POST, $request->getMethod());
 }