Exemplo n.º 1
0
 /**
  * @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());
 }
Exemplo n.º 2
0
 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'));
 }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 /**
  * Event hook to capture querytype
  *
  * @param  PreCreateRequestEvent $event
  * @return void
  */
 public function preCreateRequest(PreCreateRequestEvent $event)
 {
     $this->queryType = $event->getQuery()->getType();
 }