/** * Prepares $this->nodeTypeManager with a fresh instance with all mocks and makes the given fixture data available as NodeTypes configuration * * @param array $nodeTypesFixtureData */ protected function prepareNodeTypeManager(array $nodeTypesFixtureData) { $this->nodeTypeManager = new NodeTypeManager(); $this->mockConfigurationManager = $this->getMockBuilder(ConfigurationManager::class)->disableOriginalConstructor()->getMock(); $mockCache = $this->getMockBuilder(StringFrontend::class)->disableOriginalConstructor()->getMock(); $mockCache->expects($this->any())->method('get')->willReturn(null); $this->inject($this->nodeTypeManager, 'fullConfigurationCache', $mockCache); $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->with('NodeTypes')->will($this->returnValue($nodeTypesFixtureData)); $this->inject($this->nodeTypeManager, 'configurationManager', $this->mockConfigurationManager); }
/** * @test */ public function getViewConfigurationUsedFilterConfigurationWithHigherWeight() { $matchingConfigurationOne = ['requestFilter' => 'isPackage("Neos.Flow")', 'options' => 'a value']; $matchingConfigurationTwo = ['requestFilter' => 'isPackage("Neos.Flow") && isFormat("html")', 'options' => 'a value with higher weight']; $notMatchingConfiguration = ['requestFilter' => 'isPackage("Vendor.Package")', 'options' => 'another value']; $viewConfigurations = [$notMatchingConfiguration, $matchingConfigurationOne, $matchingConfigurationTwo]; $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->with('Views')->will($this->returnValue($viewConfigurations)); $calculatedConfiguration = $this->viewConfigurationManager->getViewConfiguration($this->mockActionRequest); $this->assertEquals($calculatedConfiguration, $matchingConfigurationTwo); }
public function setUp() { $this->policyService = new PolicyService(); $this->mockConfigurationManager = $this->getMockBuilder(ConfigurationManager::class)->disableOriginalConstructor()->getMock(); $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->with(ConfigurationManager::CONFIGURATION_TYPE_POLICY)->will($this->returnCallback(function () { return $this->mockPolicyConfiguration; })); $this->inject($this->policyService, 'configurationManager', $this->mockConfigurationManager); $this->mockObjectManager = $this->getMockBuilder(ObjectManager::class)->disableOriginalConstructor()->getMock(); $this->inject($this->policyService, 'objectManager', $this->mockObjectManager); $this->mockPrivilege = $this->getAccessibleMock(AbstractPrivilege::class, ['matchesSubject'], [], '', false); }
/** * @test */ public function flushConfigurationCachesByChangedFilesFlushesConfigurationCache() { $this->registerCache('Flow_Object_Classes'); $this->registerCache('Flow_Object_Configuration'); $this->mockConfigurationManager->expects($this->once())->method('flushConfigurationCache'); $this->cacheManager->flushSystemCachesByChangedFiles('Flow_ConfigurationFiles', []); }