コード例 #1
0
 public function testRenderFragmentWithoutUser()
 {
     $windowState = $this->createWindowState();
     $this->environment->expects($this->never())->method($this->anything());
     $this->stateManager->expects($this->once())->method('deleteWindowsState')->willThrowException(new AccessDeniedException());
     $this->assertEquals('', $this->extension->renderFragment($this->environment, $windowState));
     $this->assertFalse($windowState->isRenderedSuccessfully());
 }
コード例 #2
0
 public function testRenderFragmentWithEmptyCleanUrl()
 {
     $windowState = $this->createWindowState();
     $this->environment->expects($this->never())->method($this->anything());
     $this->entityManager->expects($this->never())->method($this->anything());
     $this->assertEquals('', $this->extension->renderFragment($this->environment, $windowState));
     $this->assertFalse($windowState->isRenderedSuccessfully());
 }
コード例 #3
0
 /**
  * @dataProvider renderDataProvider
  * @param string $widgetUrl
  * @param string $widgetType
  * @param string $expectedWidgetUrl
  */
 public function testRender($widgetUrl, $widgetType, $expectedWidgetUrl)
 {
     $user = $this->getMock('stdClass');
     $token = $this->getMockBuilder('stdClass')->setMethods(array('getUser'))->getMock();
     $token->expects($this->once())->method('getUser')->will($this->returnValue($user));
     $this->securityContext->expects($this->once())->method('getToken')->will($this->returnValue($token));
     $normalStateData = array('cleanUrl' => $widgetUrl, 'type' => $widgetType);
     $normalState = $this->getStateMock(1, $normalStateData);
     $badState = $this->getStateMock(2, null);
     $states = array($normalState, $badState);
     $repository = $this->getMock('Doctrine\\Common\\Persistence\\ObjectRepository');
     $repository->expects($this->once())->method('findBy')->with(array('user' => $user))->will($this->returnValue($states));
     $this->em->expects($this->once())->method('getRepository')->with('OroWindowsBundle:WindowsState')->will($this->returnValue($repository));
     $this->em->expects($this->once())->method('remove')->with($badState);
     $this->em->expects($this->once())->method('flush');
     $output = 'RENDERED';
     $expectedStates = array('cleanUrl' => $expectedWidgetUrl, 'type' => $widgetType);
     $this->environment->expects($this->once())->method('render')->with("OroWindowsBundle::states.html.twig", array("states" => array(1 => $expectedStates)))->will($this->returnValue($output));
     $this->assertEquals($output, $this->extension->render($this->environment));
 }