/**
  * Sets up this test case
  *
  */
 protected function setUp()
 {
     $this->mockObjectManager = $this->createMock(ObjectManagerInterface::class);
     $this->mockObjectManager->expects($this->any())->method('isRegistered')->will($this->returnCallback(array($this, 'objectManagerIsRegisteredCallback')));
     $this->parser = $this->getAccessibleMock(Parser::class, array('dummy'));
     $this->parser->_set('objectManager', $this->mockObjectManager);
 }
 /**
  * Set the routes configuration for the Neos setup and configures the routing component
  * to skip initialisation, which would overwrite the specific settings again.
  *
  * @param ComponentContext $componentContext
  * @return void
  */
 public function handle(ComponentContext $componentContext)
 {
     $configurationSource = $this->objectManager->get(\Neos\Flow\Configuration\Source\YamlSource::class);
     $routesConfiguration = $configurationSource->load($this->packageManager->getPackage('Neos.Setup')->getConfigurationPath() . ConfigurationManager::CONFIGURATION_TYPE_ROUTES);
     $this->router->setRoutesConfiguration($routesConfiguration);
     $componentContext->setParameter(\Neos\Flow\Mvc\Routing\RoutingComponent::class, 'skipRouterInitialization', true);
 }
 /**
  * Adds all validators that extend the AssetValidatorInterface.
  *
  * @return void
  */
 protected function initializeObject()
 {
     $assetValidatorImplementationClassNames = $this->reflectionService->getAllImplementationClassNamesForInterface(AssetValidatorInterface::class);
     foreach ($assetValidatorImplementationClassNames as $assetValidatorImplementationClassName) {
         $this->addValidator($this->objectManager->get($assetValidatorImplementationClassName));
     }
 }
 /**
  * @param array $chainConfiguration
  * @return ComponentChain
  * @throws Exception
  */
 public function create(array $chainConfiguration)
 {
     if (empty($chainConfiguration)) {
         return null;
     }
     $arraySorter = new PositionalArraySorter($chainConfiguration);
     $sortedChainConfiguration = $arraySorter->toArray();
     $chainComponents = [];
     foreach ($sortedChainConfiguration as $componentName => $configuration) {
         $componentOptions = isset($configuration['componentOptions']) ? $configuration['componentOptions'] : [];
         if (isset($configuration['chain'])) {
             $component = $this->create($configuration['chain']);
         } else {
             if (!isset($configuration['component'])) {
                 throw new Exception(sprintf('Component chain could not be created because no component class name is configured for component "%s"', $componentName), 1401718283);
             }
             $component = $this->objectManager->get($configuration['component'], $componentOptions);
             if (!$component instanceof ComponentInterface) {
                 throw new Exception(sprintf('Component chain could not be created because the class "%s" does not implement the ComponentInterface, in component "%s" does not implement', $configuration['component'], $componentName), 1401718283);
             }
         }
         $chainComponents[] = $component;
     }
     return new ComponentChain(['components' => $chainComponents]);
 }
 /**
  * @return void
  */
 public function initializeObject()
 {
     // flush routing caches if in Development context & routing settings changed
     if ($this->objectManager->getContext()->isDevelopment() && $this->routeCache->get('routingSettings') !== $this->routingSettings) {
         $this->flushCaches();
         $this->routeCache->set('routingSettings', $this->routingSettings);
     }
 }
 /**
  * This object is created very early and is part of the blacklisted "Neos\Flow\Aop" namespace so we can't rely on AOP for the property injection.
  *
  * @param ObjectManagerInterface $objectManager
  * @return void
  */
 public function injectObjectManager(ObjectManagerInterface $objectManager)
 {
     if ($this->objectManager === null) {
         $this->objectManager = $objectManager;
         /** @var CacheManager $cacheManager */
         $cacheManager = $this->objectManager->get(CacheManager::class);
         $this->runtimeExpressionsCache = $cacheManager->getCache('Flow_Aop_RuntimeExpressions');
         $this->runtimeExpressions = $this->runtimeExpressionsCache->requireOnce('Flow_Aop_RuntimeExpressions');
     }
 }
 /**
  * Prepare test objects
  */
 protected function setUp()
 {
     $this->nodeFactory = $this->getMockBuilder(NodeFactory::class)->setMethods(array('filterNodeByContext'))->getMock();
     $this->nodeFactory->expects(self::any())->method('filterNodeByContext')->willReturnArgument(0);
     $this->reflectionServiceMock = $this->createMock(ReflectionService::class);
     $this->reflectionServiceMock->expects(self::any())->method('getAllImplementationClassNamesForInterface')->with(NodeInterface::class)->willReturn(array(Node::class));
     $this->objectManagerMock = $this->createMock(ObjectManagerInterface::class);
     $this->objectManagerMock->expects(self::any())->method('get')->with(ReflectionService::class)->willReturn($this->reflectionServiceMock);
     $this->objectManagerMock->expects(self::any())->method('getClassNameByObjectName')->with(NodeInterface::class)->willReturn(Node::class);
     $this->inject($this->nodeFactory, 'objectManager', $this->objectManagerMock);
 }
 /**
  * Resolves the class name of an authentication provider. If a valid provider class name is given, it is just returned.
  *
  * @param string $providerName The (short) name of the provider
  * @return string The object name of the authentication provider
  * @throws NoAuthenticationProviderFoundException
  */
 public function resolveProviderClass($providerName)
 {
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($providerName);
     if ($resolvedObjectName !== false) {
         return $resolvedObjectName;
     }
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('Neos\\Flow\\Security\\Authentication\\Provider\\' . $providerName);
     if ($resolvedObjectName !== false) {
         return $resolvedObjectName;
     }
     throw new NoAuthenticationProviderFoundException('An authentication provider with the name "' . $providerName . '" could not be resolved.', 1217154134);
 }
 /**
  * Resolves the class name of a request pattern. If a valid request pattern class name is given, it is just returned.
  *
  * @param string $name The (short) name of the pattern
  * @return string The class name of the request pattern, NULL if no class was found.
  * @throws Exception\NoRequestPatternFoundException
  */
 public function resolveRequestPatternClass($name)
 {
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($name);
     if ($resolvedObjectName !== false) {
         return $resolvedObjectName;
     }
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('Neos\\Flow\\Security\\RequestPattern\\' . $name);
     if ($resolvedObjectName !== false) {
         return $resolvedObjectName;
     }
     throw new Exception\NoRequestPatternFoundException('A request pattern with the name: "' . $name . '" could not be resolved.', 1217154134);
 }
 /**
  * Resolves the class name of a security interceptor. If a valid interceptor class name is given, it is just returned.
  *
  * @param string $name The (short) name of the interceptor
  * @return string The class name of the security interceptor, NULL if no class was found.
  * @throws NoInterceptorFoundException
  */
 public function resolveInterceptorClass($name)
 {
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName($name);
     if ($resolvedObjectName !== false) {
         return $resolvedObjectName;
     }
     $resolvedObjectName = $this->objectManager->getCaseSensitiveObjectName('Neos\\Flow\\Security\\Authorization\\Interceptor\\' . $name);
     if ($resolvedObjectName !== false) {
         return $resolvedObjectName;
     }
     throw new NoInterceptorFoundException('A security interceptor with the name: "' . $name . '" could not be resolved.', 1217154134);
 }
 /**
  * @test
  */
 public function ifCommandCantBeResolvedTheHelpScreenIsShown()
 {
     // The following call is only made to satisfy PHPUnit. For some weird reason PHPUnit complains that the
     // mocked method ("getObjectNameByClassName") does not exist _if the mock object is not used_.
     $this->mockObjectManager->getObjectNameByClassName('Acme\\Test\\Command\\DefaultCommandController');
     $this->mockCommandManager->getCommandByIdentifier('acme.test:default:list');
     $mockCommandManager = $this->createMock(Cli\CommandManager::class);
     $mockCommandManager->expects($this->any())->method('getCommandByIdentifier')->with('test:default:list')->will($this->throwException(new NoSuchCommandException()));
     $this->requestBuilder->injectCommandManager($mockCommandManager);
     $request = $this->requestBuilder->build('test:default:list');
     $this->assertSame(HelpCommandController::class, $request->getControllerObjectName());
 }
 /**
  * Merge the default plugin arguments of the Plugin with the arguments in the request
  * and generate a controllerObjectName
  *
  * @param object $request
  * @param array $arguments
  * @return string $controllerObjectName
  */
 public function getControllerObjectName($request, array $arguments)
 {
     $controllerName = $arguments['controllerName'] !== null ? $arguments['controllerName'] : $request->getControllerName();
     $subPackageKey = $arguments['subPackageKey'] !== null ? $arguments['subPackageKey'] : $request->getControllerSubpackageKey();
     $packageKey = $arguments['packageKey'] !== null ? $arguments['packageKey'] : $request->getControllerPackageKey();
     $possibleObjectName = '@package\\@subpackage\\Controller\\@controllerController';
     $possibleObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleObjectName);
     $possibleObjectName = str_replace('@subpackage', $subPackageKey, $possibleObjectName);
     $possibleObjectName = str_replace('@controller', $controllerName, $possibleObjectName);
     $possibleObjectName = str_replace('\\\\', '\\', $possibleObjectName);
     $controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($possibleObjectName);
     return $controllerObjectName !== false ? $controllerObjectName : '';
 }
 /**
  * Execute the job
  *
  * A job should finish itself after successful execution using the queue methods.
  *
  * @param QueueInterface $queue
  * @param Message $message
  * @return boolean TRUE If the execution was successful
  * @throws \Exception
  */
 public function execute(QueueInterface $queue, Message $message)
 {
     $service = $this->objectManager->get($this->className);
     $this->deferMethodCallAspect->setProcessingJob(true);
     try {
         $methodName = $this->methodName;
         call_user_func_array([$service, $methodName], $this->arguments);
         return true;
     } catch (\Exception $exception) {
         $this->deferMethodCallAspect->setProcessingJob(false);
         throw $exception;
     }
 }
 /**
  * @return void
  */
 public function setUp()
 {
     parent::setup();
     vfsStream::setup('Foo');
     $this->httpRequest = Http\Request::create(new Http\Uri('http://localhost'));
     $this->httpResponse = new Http\Response();
     $mockRequestHandler = $this->createMock(Http\RequestHandler::class);
     $mockRequestHandler->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->httpRequest));
     $mockRequestHandler->expects($this->any())->method('getHttpResponse')->will($this->returnValue($this->httpResponse));
     $this->mockBootstrap = $this->createMock(Bootstrap::class);
     $this->mockBootstrap->expects($this->any())->method('getActiveRequestHandler')->will($this->returnValue($mockRequestHandler));
     $this->mockSecurityContext = $this->createMock(Context::class);
     $this->mockObjectManager = $this->createMock(ObjectManagerInterface::class);
     $this->mockObjectManager->expects($this->any())->method('get')->with(Context::class)->will($this->returnValue($this->mockSecurityContext));
 }
 /**
  * Get available data source implementations
  *
  * @param ObjectManagerInterface $objectManager
  * @return array Data source class names indexed by identifier
  * @Flow\CompileStatic
  * @throws NeosException
  */
 public static function getDataSources($objectManager)
 {
     $reflectionService = $objectManager->get(ReflectionService::class);
     $dataSources = array();
     $dataSourceClassNames = $reflectionService->getAllImplementationClassNamesForInterface(DataSourceInterface::class);
     /** @var $dataSourceClassName DataSourceInterface */
     foreach ($dataSourceClassNames as $dataSourceClassName) {
         $identifier = $dataSourceClassName::getIdentifier();
         if (isset($dataSources[$identifier])) {
             throw new NeosException(sprintf('Data source with identifier "%s" is already defined in class %s.', $identifier, $dataSourceClassName), 1414088185);
         }
         $dataSources[$identifier] = $dataSourceClassName;
     }
     return $dataSources;
 }
 /**
  * Returns the static value of the given operand, this might be also a global object
  *
  * @param mixed $expression The expression string representing the operand
  * @return mixed The calculated value
  */
 public function getValueForOperand($expression)
 {
     if (is_array($expression)) {
         $result = [];
         foreach ($expression as $expressionEntry) {
             $result[] = $this->getValueForOperand($expressionEntry);
         }
         return $result;
     } elseif (is_numeric($expression)) {
         return $expression;
     } elseif ($expression === true) {
         return true;
     } elseif ($expression === false) {
         return false;
     } elseif ($expression === null) {
         return null;
     } elseif (strpos($expression, 'context.') === 0) {
         $objectAccess = explode('.', $expression, 3);
         $globalObjectsRegisteredClassName = $this->globalObjects[$objectAccess[1]];
         $globalObject = $this->objectManager->get($globalObjectsRegisteredClassName);
         $this->securityContext->withoutAuthorizationChecks(function () use($globalObject, $objectAccess, &$globalObjectValue) {
             $globalObjectValue = $this->getObjectValueByPath($globalObject, $objectAccess[2]);
         });
         return $globalObjectValue;
     } else {
         return trim($expression, '"\'');
     }
 }
 /**
  * Sets up this test case
  */
 public function setUp()
 {
     $this->dispatcher = $this->getMockBuilder(Dispatcher::class)->disableOriginalConstructor()->setMethods(['resolveController'])->getMock();
     $this->mockActionRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('isMainRequest')->will($this->returnValue(false));
     $this->mockParentRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getParentRequest')->will($this->returnValue($this->mockParentRequest));
     $this->mockMainRequest = $this->getMockBuilder(ActionRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getMainRequest')->will($this->returnValue($this->mockMainRequest));
     $this->mockHttpRequest = $this->getMockBuilder(HttpRequest::class)->disableOriginalConstructor()->getMock();
     $this->mockActionRequest->expects($this->any())->method('getHttpRequest')->will($this->returnValue($this->mockHttpRequest));
     $this->mockHttpResponse = $this->getMockBuilder(HttpResponse::class)->disableOriginalConstructor()->getMock();
     $this->mockController = $this->getMockBuilder(ControllerInterface::class)->setMethods(['processRequest'])->getMock();
     $this->dispatcher->expects($this->any())->method('resolveController')->will($this->returnValue($this->mockController));
     $this->mockSecurityContext = $this->getMockBuilder(Context::class)->disableOriginalConstructor()->getMock();
     $this->mockFirewall = $this->getMockBuilder(FirewallInterface::class)->getMock();
     $this->mockSecurityLogger = $this->getMockBuilder(SecurityLoggerInterface::class)->getMock();
     $this->mockObjectManager = $this->getMockBuilder(ObjectManagerInterface::class)->getMock();
     $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnCallback(function ($className) {
         if ($className === Context::class) {
             return $this->mockSecurityContext;
         } elseif ($className === FirewallInterface::class) {
             return $this->mockFirewall;
         } elseif ($className === SecurityLoggerInterface::class) {
             return $this->mockSecurityLogger;
         }
         return null;
     }));
     $this->inject($this->dispatcher, 'objectManager', $this->mockObjectManager);
 }
 /**
  * Handle an Exception thrown while rendering TypoScript according to
  * settings specified in Neos.Fusion.rendering.exceptionHandler
  *
  * @param array $typoScriptPath
  * @param \Exception $exception
  * @param boolean $useInnerExceptionHandler
  * @return string
  * @throws InvalidConfigurationException
  */
 public function handleRenderingException($typoScriptPath, \Exception $exception, $useInnerExceptionHandler = false)
 {
     $typoScriptConfiguration = $this->getConfigurationForPath($typoScriptPath);
     if (isset($typoScriptConfiguration['__meta']['exceptionHandler'])) {
         $exceptionHandlerClass = $typoScriptConfiguration['__meta']['exceptionHandler'];
         $invalidExceptionHandlerMessage = 'The class "%s" is not valid for property "@exceptionHandler".';
     } else {
         if ($useInnerExceptionHandler === true) {
             $exceptionHandlerClass = $this->settings['rendering']['innerExceptionHandler'];
         } else {
             $exceptionHandlerClass = $this->settings['rendering']['exceptionHandler'];
         }
         $invalidExceptionHandlerMessage = 'The class "%s" is not valid for setting "Neos.Fusion.rendering.exceptionHandler".';
     }
     $exceptionHandler = null;
     if ($this->objectManager->isRegistered($exceptionHandlerClass)) {
         $exceptionHandler = $this->objectManager->get($exceptionHandlerClass);
     }
     if ($exceptionHandler === null || !$exceptionHandler instanceof AbstractRenderingExceptionHandler) {
         $message = sprintf($invalidExceptionHandlerMessage . "\n" . 'Please specify a fully qualified classname to a subclass of %2$s\\AbstractRenderingExceptionHandler.' . "\n" . 'You might implement an own handler or use one of the following:' . "\n" . '%2$s\\AbsorbingHandler' . "\n" . '%2$s\\HtmlMessageHandler' . "\n" . '%2$s\\PlainTextHandler' . "\n" . '%2$s\\ThrowingHandler' . "\n" . '%2$s\\XmlCommentHandler', $exceptionHandlerClass, 'Neos\\Fusion\\Core\\ExceptionHandlers');
         throw new InvalidConfigurationException($message, 1368788926);
     }
     $exceptionHandler->setRuntime($this);
     if (array_key_exists('__objectType', $typoScriptConfiguration)) {
         $typoScriptPath .= sprintf('<%s>', $typoScriptConfiguration['__objectType']);
     }
     $output = $exceptionHandler->handleRenderingException($typoScriptPath, $exception);
     return $output;
 }
 /**
  * Emits a signal when an Advice is invoked
  *
  * The advice is not proxyable, so the signal is dispatched manually here.
  *
  * @param object $aspectObject
  * @param string $methodName
  * @param JoinPointInterface $joinPoint
  * @return void
  * @Flow\Signal
  */
 protected function emitAdviceInvoked($aspectObject, $methodName, $joinPoint)
 {
     if ($this->dispatcher === null) {
         $this->dispatcher = $this->objectManager->get(Dispatcher::class);
     }
     $this->dispatcher->dispatch(self::class, 'adviceInvoked', [$aspectObject, $methodName, $joinPoint]);
 }
 /**
  * @test
  */
 public function validatePasswordWillUseStrategyIdentifierFromHashedPassword()
 {
     $mockStrategy = $this->createMock(PasswordHashingStrategyInterface::class);
     $this->mockObjectManager->expects($this->any())->method('get')->will($this->returnValue($mockStrategy));
     $mockStrategy->expects($this->atLeastOnce())->method('validatePassword')->with('myTestPassword', '---hashed-password---')->will($this->returnValue(true));
     $result = $this->hashService->validatePassword('myTestPassword', 'TestStrategy=>---hashed-password---');
     $this->assertEquals(true, $result);
 }
 /**
  * @test
  */
 public function resolveValidatorObjectNameCanResolveShortNamesOfBuiltInValidators()
 {
     $this->mockObjectManager->expects($this->at(0))->method('get')->with(ReflectionService::class)->will($this->returnValue($this->mockReflectionService));
     $this->mockObjectManager->expects($this->at(1))->method('isRegistered')->with('Foo')->will($this->returnValue(false));
     $this->mockObjectManager->expects($this->at(2))->method('isRegistered')->with('Neos\\Flow\\Validation\\Validator\\FooValidator')->will($this->returnValue(true));
     $this->mockReflectionService->expects($this->any())->method('getAllImplementationClassNamesForInterface')->with(ValidatorInterface::class)->will($this->returnValue(['Neos\\Flow\\Validation\\Validator\\FooValidator']));
     $this->assertSame('Neos\\Flow\\Validation\\Validator\\FooValidator', $this->validatorResolver->_call('resolveValidatorObjectName', 'Foo'));
 }
 /**
  * Starts the shutdown sequence
  *
  * @param string $runlevel one of the Bootstrap::RUNLEVEL_* constants
  * @return void
  */
 protected function shutdown($runlevel)
 {
     $this->bootstrap->shutdown($runlevel);
     if ($runlevel === Bootstrap::RUNLEVEL_COMPILETIME) {
         $this->objectManager->get(LockManager::class)->unlockSite();
     }
     exit($this->response->getExitCode());
 }
 /**
  * Adds a setting filter to the pointcut filter composite
  *
  * @param string $operator The operator
  * @param string $configurationPath The path to the settings option, that should be used
  * @param PointcutFilterComposite $pointcutFilterComposite An instance of the pointcut filter composite. The result (ie. the custom filter) will be added to this composite object.
  * @return void
  */
 protected function parseDesignatorSetting($operator, $configurationPath, PointcutFilterComposite $pointcutFilterComposite)
 {
     $filter = new PointcutSettingFilter($configurationPath);
     /** @var ConfigurationManager $configurationManager */
     $configurationManager = $this->objectManager->get(ConfigurationManager::class);
     $filter->injectConfigurationManager($configurationManager);
     $pointcutFilterComposite->addFilter($operator, $filter);
 }
 /**
  * Matches a \Neos\Flow\Mvc\RequestInterface against the configured CSRF pattern rules and
  * searches for invalid csrf tokens. If this returns TRUE, the request is invalid!
  *
  * @param RequestInterface $request The request that should be matched
  * @return boolean TRUE if the pattern matched, FALSE otherwise
  * @throws AuthenticationRequiredException
  */
 public function matchRequest(RequestInterface $request)
 {
     if (!$request instanceof ActionRequest || $request->getHttpRequest()->isMethodSafe()) {
         $this->systemLogger->log('CSRF: No token required, safe request', LOG_DEBUG);
         return false;
     }
     if ($this->authenticationManager->isAuthenticated() === false) {
         $this->systemLogger->log('CSRF: No token required, not authenticated', LOG_DEBUG);
         return false;
     }
     if ($this->securityContext->areAuthorizationChecksDisabled() === true) {
         $this->systemLogger->log('CSRF: No token required, authorization checks are disabled', LOG_DEBUG);
         return false;
     }
     $controllerClassName = $this->objectManager->getClassNameByObjectName($request->getControllerObjectName());
     $actionMethodName = $request->getControllerActionName() . 'Action';
     if (!$this->hasPolicyEntryForMethod($controllerClassName, $actionMethodName)) {
         $this->systemLogger->log(sprintf('CSRF: No token required, method %s::%s() is not restricted by a policy.', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return false;
     }
     if ($this->reflectionService->isMethodTaggedWith($controllerClassName, $actionMethodName, 'skipcsrfprotection')) {
         $this->systemLogger->log(sprintf('CSRF: No token required, method %s::%s() is tagged with a "skipcsrfprotection" annotation', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return false;
     }
     $httpRequest = $request->getHttpRequest();
     if ($httpRequest->hasHeader('X-Flow-Csrftoken')) {
         $csrfToken = $httpRequest->getHeader('X-Flow-Csrftoken');
     } else {
         $internalArguments = $request->getMainRequest()->getInternalArguments();
         $csrfToken = isset($internalArguments['__csrfToken']) ? $internalArguments['__csrfToken'] : null;
     }
     if (empty($csrfToken)) {
         $this->systemLogger->log(sprintf('CSRF: token was empty but a valid token is required for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return true;
     }
     if (!$this->securityContext->hasCsrfProtectionTokens()) {
         throw new AuthenticationRequiredException(sprintf('CSRF: No CSRF tokens in security context, possible session timeout. A valid token is required for %s::%s()', $controllerClassName, $actionMethodName), 1317309673);
     }
     if ($this->securityContext->isCsrfProtectionTokenValid($csrfToken) === false) {
         $this->systemLogger->log(sprintf('CSRF: token was invalid but a valid token is required for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
         return true;
     }
     $this->systemLogger->log(sprintf('CSRF: Successfully verified token for %s::%s()', $controllerClassName, $actionMethodName), LOG_DEBUG);
     return false;
 }
 /**
  * @test
  */
 public function convertFromReturnsNullIfResourcePropertyIsNotConverted()
 {
     $this->mockObjectManager->expects($this->any())->method('getClassNameByObjectName')->will($this->returnCallback(function ($objectType) {
         return $objectType;
     }));
     $configuration = new PropertyMappingConfiguration();
     $configuration->setTypeConverterOption(ImageInterfaceConverter::class, PersistentObjectConverter::CONFIGURATION_CREATION_ALLOWED, true);
     $this->assertNull($this->converter->convertFrom(array(), Image::class, array(), $configuration));
 }
 /**
  * Emits a signal when a Request has been dispatched
  *
  * The action request is not proxyable, so the signal is dispatched manually here.
  * The safeguard allows unit tests without the dispatcher dependency.
  *
  * @param ActionRequest $request
  * @return void
  * @Flow\Signal
  */
 protected function emitRequestDispatched($request)
 {
     if ($this->objectManager !== null) {
         $dispatcher = $this->objectManager->get(SignalSlotDispatcher::class);
         if ($dispatcher !== null) {
             $dispatcher->dispatch(ActionRequest::class, 'requestDispatched', [$request]);
         }
     }
 }
 /**
  * Returns the object name of the controller defined by the package, subpackage key and
  * controller name
  *
  * @param string $packageKey the package key of the controller
  * @param string $subPackageKey the subpackage key of the controller
  * @param string $controllerName the controller name excluding the "Controller" suffix
  * @return string The controller's Object Name or NULL if the controller does not exist
  */
 protected function getControllerObjectName($packageKey, $subPackageKey, $controllerName)
 {
     $possibleObjectName = '@package\\@subpackage\\Controller\\@controllerController';
     $possibleObjectName = str_replace('@package', str_replace('.', '\\', $packageKey), $possibleObjectName);
     $possibleObjectName = str_replace('@subpackage', $subPackageKey, $possibleObjectName);
     $possibleObjectName = str_replace('@controller', $controllerName, $possibleObjectName);
     $possibleObjectName = str_replace('\\\\', '\\', $possibleObjectName);
     $controllerObjectName = $this->objectManager->getCaseSensitiveObjectName($possibleObjectName);
     return $controllerObjectName !== false ? $controllerObjectName : null;
 }
 /**
  * @test
  */
 public function parseSetsDefaultValueOfRoutePartsRecursively()
 {
     $this->route->setUriPattern('{foo.bar}');
     $this->route->setRoutePartsConfiguration(['foo.bar' => ['handler' => 'SomeRoutePartHandler']]);
     $this->route->setDefaults(['foo' => ['bar' => 'SomeDefaultValue']]);
     $mockRoutePartHandler = $this->createMock(Routing\DynamicRoutePartInterface::class);
     $mockRoutePartHandler->expects($this->once())->method('setDefaultValue')->with('SomeDefaultValue');
     $this->mockObjectManager->expects($this->once())->method('get')->with('SomeRoutePartHandler')->will($this->returnValue($mockRoutePartHandler));
     $this->route->parse();
 }
 /**
  * @param PropertyMappingConfiguration $propertyMappingConfiguration
  * @param string $dataType
  * @return boolean
  */
 protected function setTypeConverterForType(PropertyMappingConfiguration $propertyMappingConfiguration, $dataType)
 {
     if (!isset($this->typesConfiguration[$dataType]) || !isset($this->typesConfiguration[$dataType]['typeConverter'])) {
         return false;
     }
     $typeConverter = $this->objectManager->get($this->typesConfiguration[$dataType]['typeConverter']);
     $propertyMappingConfiguration->setTypeConverter($typeConverter);
     $this->setTypeConverterOptionsForType($propertyMappingConfiguration, $this->typesConfiguration[$dataType]['typeConverter'], $dataType);
     return true;
 }
Exemple #30
0
 /**
  * @When /^I import the last exported site$/
  */
 public function iImportTheLastExportedSite()
 {
     // Persist any pending entity insertions (caused by lazy creation of live Workspace)
     // This is a workaround which should be solved by properly isolating all read-only steps
     $this->getSubContext('flow')->persistAll();
     $this->resetNodeInstances();
     /** @var SiteImportService $siteImportService */
     $siteImportService = $this->objectManager->get(SiteImportService::class);
     $siteImportService->importFromFile($this->lastExportedSiteXmlPathAndFilename);
 }