/** * @Given /^I have the following policies:$/ */ public function iHaveTheFollowingPolicies($string) { self::$testingPolicyPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Policy.yaml'; file_put_contents(self::$testingPolicyPathAndFilename, $string->getRaw()); $configurationManager = $this->objectManager->get('TYPO3\\Flow\\Configuration\\ConfigurationManager'); $configurations = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($configurationManager, 'configurations', TRUE); unset($configurations[\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_POLICY]); \TYPO3\Flow\Reflection\ObjectAccess::setProperty($configurationManager, 'configurations', $configurations, TRUE); $policyService = $this->objectManager->get('TYPO3\\Flow\\Security\\Policy\\PolicyService'); \TYPO3\Flow\Reflection\ObjectAccess::setProperty($policyService, 'initialized', FALSE, TRUE); }
/** * WARNING: If using this step definition, IT MUST RUN AS ABSOLUTELY FIRST STEP IN A SCENARIO! * * @Given /^I have the following policies:$/ */ public function iHaveTheFollowingPolicies($string) { if ($this->subProcess !== null) { // This check ensures that this statement is ran *before* a subprocess is opened; as the Policy.yaml // which is set here influences the Proxy Building Process. throw new \Exception('Step "I have the following policies:" must run as FIRST step in a scenario, because otherwise the proxy-classes are already built in the wrong manner!'); } self::$testingPolicyPathAndFilename = $this->environment->getPathToTemporaryDirectory() . 'Policy.yaml'; file_put_contents(self::$testingPolicyPathAndFilename, $string->getRaw()); $configurationManager = $this->objectManager->get(\TYPO3\Flow\Configuration\ConfigurationManager::class); $configurations = \TYPO3\Flow\Reflection\ObjectAccess::getProperty($configurationManager, 'configurations', true); unset($configurations[\TYPO3\Flow\Configuration\ConfigurationManager::CONFIGURATION_PROCESSING_TYPE_POLICY]); \TYPO3\Flow\Reflection\ObjectAccess::setProperty($configurationManager, 'configurations', $configurations, true); $policyService = $this->objectManager->get(\TYPO3\Flow\Security\Policy\PolicyService::class); \TYPO3\Flow\Reflection\ObjectAccess::setProperty($policyService, 'initialized', false, true); }