/**
  * Setup the most commonly used mocks and a real FrontendRoutePartHandler. The mock objects created by this function
  * will not be sufficient for most tests, but they are the lowest common denominator.
  *
  * @return void
  */
 protected function setUp()
 {
     $this->routePartHandler = new FrontendNodeRoutePartHandler();
     $this->routePartHandler->setName('node');
     // The mockContextFactory is configured to return the last mock context which has been built with buildMockContext():
     $mockContextFactory = $this->getMock('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactory', array('create'));
     $mockContextFactory->mockContext = null;
     $mockContextFactory->expects($this->any())->method('create')->will($this->returnCallback(function ($contextProperties) use($mockContextFactory) {
         if (isset($contextProperties['currentSite'])) {
             $mockContextFactory->mockContext->mockSite = $contextProperties['currentSite'];
         }
         if (isset($contextProperties['currentDomain'])) {
             $mockContextFactory->mockContext->mockDomain = $contextProperties['currentDomain'];
         }
         if (isset($contextProperties['dimensions'])) {
             $mockContextFactory->mockContext->mockDimensions = $contextProperties['dimensions'];
         }
         if (isset($contextProperties['targetDimensions'])) {
             $mockContextFactory->mockContext->mockTargetDimensions = $contextProperties['targetDimensions'];
         }
         return $mockContextFactory->mockContext;
     }));
     $this->mockContextFactory = $mockContextFactory;
     $this->inject($this->routePartHandler, 'contextFactory', $this->mockContextFactory);
     $this->mockSystemLogger = $this->getMock('TYPO3\\Flow\\Log\\SystemLoggerInterface');
     $this->inject($this->routePartHandler, 'systemLogger', $this->mockSystemLogger);
     $this->mockDomainRepository = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Repository\\DomainRepository')->disableOriginalConstructor()->getMock();
     $this->inject($this->routePartHandler, 'domainRepository', $this->mockDomainRepository);
     $this->mockSiteRepository = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Repository\\SiteRepository')->disableOriginalConstructor()->getMock();
     $this->mockSiteRepository->expects($this->any())->method('findFirstOnline')->will($this->returnValue(null));
     $this->inject($this->routePartHandler, 'siteRepository', $this->mockSiteRepository);
     $this->contentDimensionPresetSource = new ConfigurationContentDimensionPresetSource();
     $this->contentDimensionPresetSource->setConfiguration(array());
     $this->inject($this->routePartHandler, 'contentDimensionPresetSource', $this->contentDimensionPresetSource);
 }
 public function setUp()
 {
     $this->publishingService = new PublishingService();
     $this->mockWorkspaceRepository = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Repository\\WorkspaceRepository')->disableOriginalConstructor()->setMethods(array('findOneByName'))->getMock();
     $this->inject($this->publishingService, 'workspaceRepository', $this->mockWorkspaceRepository);
     $this->mockNodeDataRepository = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Repository\\NodeDataRepository')->disableOriginalConstructor()->setMethods(array('findByWorkspace'))->getMock();
     $this->inject($this->publishingService, 'nodeDataRepository', $this->mockNodeDataRepository);
     $this->mockNodeFactory = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Factory\\NodeFactory')->disableOriginalConstructor()->getMock();
     $this->inject($this->publishingService, 'nodeFactory', $this->mockNodeFactory);
     $this->mockContextFactory = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Service\\ContextFactoryInterface')->disableOriginalConstructor()->getMock();
     $this->inject($this->publishingService, 'contextFactory', $this->mockContextFactory);
     $this->mockDomainRepository = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Repository\\DomainRepository')->disableOriginalConstructor()->getMock();
     $this->inject($this->publishingService, 'domainRepository', $this->mockDomainRepository);
     $this->mockSiteRepository = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Repository\\SiteRepository')->disableOriginalConstructor()->getMock();
     $this->mockSite = $this->getMockBuilder('TYPO3\\Neos\\Domain\\Model\\Site')->disableOriginalConstructor()->getMock();
     $this->mockSiteRepository->expects($this->any())->method('findFirstOnline')->will($this->returnValue($this->mockSite));
     $this->inject($this->publishingService, 'siteRepository', $this->mockSiteRepository);
     $this->mockBaseWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock();
     $this->mockBaseWorkspace->expects($this->any())->method('getName')->will($this->returnValue('live'));
     $this->mockBaseWorkspace->expects($this->any())->method('getBaseWorkspace')->will($this->returnValue(null));
     $this->mockWorkspace = $this->getMockBuilder('TYPO3\\TYPO3CR\\Domain\\Model\\Workspace')->disableOriginalConstructor()->getMock();
     $this->mockWorkspace->expects($this->any())->method('getName')->will($this->returnValue('workspace-name'));
     $this->mockWorkspace->expects($this->any())->method('getBaseWorkspace')->will($this->returnValue($this->mockBaseWorkspace));
 }