/**
  * @depends testConstructorAndGetters
  *
  * @param PreCreateRequest $event
  */
 public function testSetAndGetQuery($event)
 {
     $request = new Request();
     $request->addParam('testparam', 'test value');
     $event->setRequest($request);
     $this->assertEquals($request, $event->getRequest());
 }
 public function onPreCreateRequest(PreCreateRequestEvent $event)
 {
     $query = $event->getQuery();
     if (null === $query->getOption('cache_lifetime')) {
         $this->currentRequestCacheProfile = null;
         return;
     }
     $this->currentRequestCacheProfile = new CacheProfile($query->getOption('cache_key'), $query->getOption('cache_lifetime'));
 }
 public function testCreateRequestWithOverridingPlugin()
 {
     $expectedRequest = new Request();
     $expectedRequest->setHandler('something-unique-345978');
     $query = new SelectQuery();
     $expectedEvent = new PreCreateRequestEvent($query);
     $expectedEvent->setDispatcher($this->client->getEventDispatcher());
     $expectedEvent->setName(Events::PRE_CREATE_REQUEST);
     $test = $this;
     $this->client->getEventDispatcher()->addListener(Events::PRE_CREATE_REQUEST, function (PreCreateRequestEvent $event) use($test, $expectedRequest, $expectedEvent) {
         $test->assertEquals($expectedEvent, $event);
         $event->setRequest($expectedRequest);
     });
     $returnedRequest = $this->client->createRequest($query);
     $this->assertEquals($expectedRequest, $returnedRequest);
 }
Beispiel #4
0
 /**
  * Event hook to capture querytype
  *
  * @param  PreCreateRequestEvent $event
  * @return void
  */
 public function preCreateRequest(PreCreateRequestEvent $event)
 {
     $this->queryType = $event->getQuery()->getType();
 }