/** * @test * @author Robert Lemke <*****@*****.**> * @expectedException \F3\FLOW3\Object\Exception */ public function autoWiringThrowsExceptionForUnmatchedDependenciesOfRequiredSetterInjectedDependencies() { $this->mockObjectManager->expects($this->once())->method('getObject')->with('stdClass')->will($this->throwException(new \F3\FLOW3\Object\Exception())); $objectName = 'F3\\FLOW3\\Tests\\Object\\Fixture\\ClassWithUnmatchedRequiredSetterDependency'; $setterParameters = array(array('position' => 0, 'byReference' => FALSE, 'array' => FALSE, 'optional' => FALSE, 'allowsNull' => FALSE, 'class' => 'stdClass')); $this->mockReflectionService->expects($this->at(1))->method('getMethodParameters')->with($objectName, 'injectRequiredSetterArgument')->will($this->returnValue($setterParameters)); $objectConfiguration = new \F3\FLOW3\Object\Configuration\Configuration($objectName); $this->objectBuilder->createObject($objectName, $objectConfiguration); }
/** * @test * @expectedException \F3\FLOW3\AOP\Exception\InvalidPointcutExpressionException * @author Robert Lemke <*****@*****.**> */ public function parseDesignatorFilterThrowsAnExceptionIfACustomFilterDoesNotImplementThePointcutFilterInterface() { $mockFilter = new \ArrayObject(); $mockPointcutFilterComposite = $this->getMock('F3\\FLOW3\\AOP\\Pointcut\\PointcutFilterComposite', array(), array(), '', FALSE); $this->mockObjectManager->expects($this->once())->method('getObject')->with('F3\\Foo\\Custom\\Filter')->will($this->returnValue($mockFilter)); $parser = $this->getMock($this->buildAccessibleProxy('F3\\FLOW3\\AOP\\Pointcut\\PointcutExpressionParser'), array('dummy'), array(), '', FALSE); $parser->injectObjectManager($this->mockObjectManager); $parser->_call('parseDesignatorFilter', '&&', 'F3\\Foo\\Custom\\Filter', $mockPointcutFilterComposite); }
/** * @test * @author Bastian Waidelich <*****@*****.**> */ public function registeredRoutePartHandlerIsInvokedWhenCallingResolve() { $this->route->setUriPattern('{key1}/{key2}'); $this->route->setRoutePartsConfiguration(array('key1' => array('handler' => 'F3\\FLOW3\\MVC\\Fixture\\Web\\Routing\\MockRoutePartHandler'))); $this->routeValues = array('key2' => 'value2'); $mockRoutePartHandler = new \F3\FLOW3\MVC\Fixture\Web\Routing\MockRoutePartHandler(); $this->mockObjectManager->expects($this->once())->method('getObject')->with('F3\\FLOW3\\MVC\\Fixture\\Web\\Routing\\MockRoutePartHandler')->will($this->returnValue($mockRoutePartHandler)); $this->route->resolves($this->routeValues); $this->assertEquals('_resolve_invoked_/value2', $this->route->getMatchingUri()); }
/** * @test * @author Robert Lemke <*****@*****.**> */ public function createRegistersShutdownObjectsAtTheComponentManager() { $className = 'SomeClass' . uniqid(); eval('class ' . $className . ' {}'); $object = new $className(); $objectName = 'F3\\Virtual\\BasicClass'; $objectConfiguration = new \F3\FLOW3\Object\Configuration\Configuration($objectName); $objectConfiguration->setScope('prototype'); $this->mockObjectManager->expects($this->once())->method('isObjectRegistered')->with($objectName)->will($this->returnValue(TRUE)); $this->mockObjectManager->expects($this->once())->method('getObjectConfiguration')->with($objectName)->will($this->returnValue($objectConfiguration)); $this->mockObjectManager->expects($this->once())->method('registerShutdownObject')->with($object, 'shutdownObject'); $this->mockObjectBuilder->expects($this->once())->method('createObject')->will($this->returnValue($object)); $this->objectFactory->create($objectName); }
/** * @test * @author Robert Lemke <*****@*****.**> */ public function setNewValidatorConjunctionCanHandleShortValidatorNames() { $mockValidator1 = $this->getMock('F3\\FLOW3\\Validation\\Validator\\ValidatorInterface'); $mockValidator2 = $this->getMock('F3\\FLOW3\\Validation\\Validator\\ValidatorInterface'); $mockValidatorChain = $this->getMock('F3\\FLOW3\\Validation\\Validator\\ConjunctionValidator', array(), array(), '', FALSE); $mockValidatorChain->expects($this->at(0))->method('addValidator')->with($mockValidator1); $mockValidatorChain->expects($this->at(1))->method('addValidator')->with($mockValidator2); $this->mockObjectFactory->expects($this->once())->method('create')->with('F3\\FLOW3\\Validation\\Validator\\ConjunctionValidator')->will($this->returnValue($mockValidatorChain)); $this->mockObjectManager->expects($this->any())->method('isObjectRegistered')->will($this->returnValue(FALSE)); $this->mockObjectManager->expects($this->exactly(2))->method('getObject')->will($this->onConsecutiveCalls($mockValidator1, $mockValidator2)); $argument = $this->getMock($this->buildAccessibleProxy('F3\\FLOW3\\MVC\\Controller\\Argument'), array('dummy'), array(), '', FALSE); $argument->_set('objectManager', $this->mockObjectManager); $argument->_set('objectFactory', $this->mockObjectFactory); $argument->setNewValidatorConjunction(array('Validator1', 'Validator2')); }