public function testUpdateResponsePage() { $this->page->getCacheLifeTime()->willReturn('300'); $this->page->getUuid()->willReturn('1234'); $this->handler->updateResponse($this->response->reveal(), $this->page->reveal()); $this->assertEquals('300', $this->parameterBag->get(DebugHandler::HEADER_STRUCTURE_TTL)); }
protected function compare(HandlerInterface $handler1, HandlerInterface $handler2) { $p1 = $handler1->getPriority(); $p2 = $handler2->getPriority(); if ($p1 === $p2) { return 0; } return $p1 < $p2 ? -1 : 1; }
public function testUpdateResponse() { $this->response->setPublic()->shouldBeCalled(); $this->response->setMaxAge($this->maxAge)->shouldBeCalled(); $this->response->setSharedMaxAge($this->sharedMaxAge)->shouldBeCalled(); $this->structure->getCacheLifeTime()->willReturn(10); $this->response->getAge()->willReturn(50); $this->handler->updateResponse($this->response->reveal(), $this->structure->reveal()); }
public function testUpdateResponse() { $expectedTags = ['structure-1', 'structure-2', 'structure-3', 'structure-4']; $this->structure->getUuid()->willReturn('1'); $this->structure->getProperties(true)->willReturn([$this->property1->reveal(), $this->property2->reveal()]); $this->property1->getContentTypeName()->willReturn('type1'); $this->property2->getContentTypeName()->willReturn('type2'); $this->contentTypeManager->get('type1')->willReturn($this->contentType1); $this->contentTypeManager->get('type2')->willReturn($this->contentType2); $this->contentType1->getReferencedUuids(Argument::any())->willReturn(['2']); $this->contentType2->getReferencedUuids(Argument::any())->willReturn(['3', '4']); $this->parameterBag->set('X-Cache-Tags', implode(',', $expectedTags))->shouldBeCalled(); $this->handler->updateResponse($this->response->reveal(), $this->structure->reveal()); }
public function handle(array $record) : bool { if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) { // The same logic as in FingersCrossedHandler if (!$this->handler instanceof HandlerInterface) { $this->handler = call_user_func($this->handler, $record, $this); if (!$this->handler instanceof HandlerInterface) { throw new \RuntimeException("The factory callable should return a HandlerInterface"); } } if ($this->processors) { $record = $this->processRecord($record); } $this->handler->handle($record); } return false === $this->bubble; }
/** * @param HandlerInterface $handler */ public function addHandler(HandlerInterface $handler) { $this->handlers[$handler->getCommandName()] = $handler; }
public function isHandling(array $record) { return $this->handler->isHandling($record); }
public function save(array $options = []) : bool { return $this->handler->save($this->getData(), $options); }
/** * Run the handler. * * @return ?? */ public function runHandler() { return $this->handler->run($this->parse()); }