/**
  * Test if you try to create from a viewer type, that does not exists
  *
  * @expectedException \Enhavo\Bundle\AppBundle\Exception\ViewerNotFoundException
  */
 function testCreateViewerWithTypeThatDoesNotExist()
 {
     $viewerList = $this->getViewerList();
     $container = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock();
     $requestStack = $this->getRequestStackMock();
     $factory = new ViewerFactory($container, $requestStack, $viewerList);
     $factory->create('notExistingType');
 }
Example #2
0
 function testCreate()
 {
     $viewerMock = $this->getMockBuilder('Enhavo\\Bundle\\AppBundle\\Viewer\\ViewerInterface')->getMock();
     $typeCollectorMock = $this->getMockBuilder('Enhavo\\Bundle\\AppBundle\\Type\\TypeCollector')->disableOriginalConstructor()->getMock();
     $typeCollectorMock->method('getType')->willReturn($viewerMock);
     $containerMock = $this->getMockBuilder('Symfony\\Component\\DependencyInjection\\ContainerInterface')->getMock();
     $factory = new ViewerFactory($containerMock, $typeCollectorMock);
     $configurationMock = $this->getMockBuilder('Enhavo\\Bundle\\AppBundle\\Controller\\RequestConfigurationInterface')->getMock();
     $configurationMock->method('getViewerOptions')->willReturn([]);
     $metadataMock = $this->getMockBuilder('Sylius\\Component\\Resource\\Metadata\\MetadataInterface')->getMock();
     $formMock = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
     $resourceMock = new EntityMock();
     $viewer = $factory->create($configurationMock, $metadataMock, $resourceMock, $formMock, 'type');
     $this->assertInstanceOf('Enhavo\\Bundle\\AppBundle\\Viewer\\ViewerInterface', $viewer);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function tableAction(Request $request)
 {
     $configuration = $this->requestConfigurationFactory->create($this->metadata, $request);
     if (!$this->authorizationChecker->isGranted($configuration, $this->metadata)) {
         throw new AccessDeniedHttpException();
     }
     $this->isGrantedOr403($configuration, ResourceActions::INDEX);
     $resources = $this->resourcesCollectionProvider->get($configuration, $this->repository);
     $viewer = $this->viewerFactory->create($configuration, $this->metadata, $resources, null, 'table');
     return $this->viewHandler->handle($configuration, $viewer->createView());
 }