public function testNodeDelete()
 {
     $this->deleteEvent->getStructures()->willReturn([$this->structure]);
     $this->handler->invalidateStructure($this->structure->reveal())->shouldBeCalled();
     $this->subscriber->onContentNodePreDelete($this->deleteEvent->reveal());
     $this->subscriber->onContentNodePostDelete($this->deleteEvent->reveal());
 }
示例#2
0
 public function testDisableCache()
 {
     // disable cache
     $this->structure->getCacheLifeTime()->willReturn(0);
     $this->response->setPublic()->shouldNotBeCalled();
     $this->response->setMaxAge($this->maxAge)->shouldNotBeCalled();
     $this->response->setSharedMaxAge($this->sharedMaxAge)->shouldNotBeCalled();
     $this->handler->updateResponse($this->response->reveal(), $this->structure->reveal());
 }
示例#3
0
 public function testInvalidate()
 {
     $this->structure->hasTag('sulu.rlp')->willReturn(true);
     $this->structure->getPropertyValueByTagName('sulu.rlp')->willReturn('/path/to');
     $this->structure->getLanguageCode()->willReturn($this->languageCode);
     $this->structure->getWebspaceKey()->willReturn($this->webspaceKey);
     $urls = ['/path/to/1', '/path/to/2'];
     $this->webspaceManager->findUrlsByResourceLocator('/path/to', $this->env, $this->languageCode, $this->webspaceKey)->willReturn($urls);
     $this->proxyClient->purge($urls[0])->shouldBeCalled();
     $this->proxyClient->purge($urls[1])->shouldBeCalled();
     $this->proxyClient->flush()->shouldBeCalled();
     $this->webspaceManager->findUrlsByResourceLocator(Argument::any())->shouldNotBeCalled();
     $this->handler->invalidateStructure($this->structure->reveal());
     $this->handler->flush();
 }
 /**
  * @dataProvider provideLifecycle
  */
 public function testLifecycle($options, $shouldInvalidate)
 {
     if ($options['has_structure']) {
         $this->request->attributes->set('structure', $this->structure->reveal());
     }
     if ($options['preview']) {
         $this->request->query->set('preview', true);
     }
     $this->filterResponseEvent->getResponse()->willReturn($this->response);
     $this->filterResponseEvent->getRequest()->willReturn($this->request);
     $this->filterResponseEvent->isMasterRequest()->willReturn($options['is_master_request']);
     $invalidateProphecy = $this->handler->updateResponse($this->response, Argument::any());
     if ($shouldInvalidate) {
         $invalidateProphecy->shouldBeCalled();
     } else {
         $invalidateProphecy->shouldNotBeCalled();
     }
     $this->subscriber->onResponse($this->filterResponseEvent->reveal());
 }
示例#5
0
 public function testUpdateResponse()
 {
     $this->handler1->updateResponse($this->response->reveal(), $this->structure->reveal())->shouldBeCalled();
     $this->handler2->updateResponse($this->response->reveal(), $this->structure->reveal())->shouldBeCalled();
     $this->handler->updateResponse($this->response->reveal(), $this->structure->reveal());
 }
示例#6
0
 public function testTerminate()
 {
     $this->handler->flush()->shouldBeCalled();
     $this->subscriber->onTerminate($this->postResponseEvent->reveal());
 }