public function testGetManager() { /** @var \PHPUnit_Framework_MockObject_MockObject|WindowsStateManager $manager */ $manager = $this->getMockBuilder('Oro\\Bundle\\WindowsBundle\\Manager\\WindowsStateManager')->disableOriginalConstructor()->getMock(); $this->registry->addManager($manager); $this->defaultManager->expects($this->never())->method($this->anything()); $manager->expects($this->exactly(2))->method('isApplicable')->willReturn(true); $this->assertTrue($this->registry->getManager()->isApplicable()); }
/** * Renders fragment by window state. * * @param \Twig_Environment $environment * @param AbstractWindowsState $windowState * * @return string */ public function renderFragment(\Twig_Environment $environment, AbstractWindowsState $windowState) { $result = ''; $scheduleDelete = false; $windowState->setRenderedSuccessfully(false); try { $uri = $this->windowsStateRequestManager->getUri($windowState->getData()); /** @var HttpKernelExtension $httpKernelExtension */ $httpKernelExtension = $environment->getExtension('http_kernel'); $result = $httpKernelExtension->renderFragment($uri); $windowState->setRenderedSuccessfully(true); return $result; } catch (NotFoundHttpException $e) { $scheduleDelete = true; } catch (\InvalidArgumentException $e) { $scheduleDelete = true; } if ($scheduleDelete) { try { $this->windowsStateManagerRegistry->getManager()->deleteWindowsState($windowState->getId()); } catch (AccessDeniedException $e) { return $result; } } return $result; }