コード例 #1
0
 /**
  * @test
  * @author Robert Lemke <*****@*****.**>
  */
 public function buildAspectContainerDetectsAllSupportedKindsOfAdviceAndPointcutsAndIntroductions()
 {
     $mockReflectionService = $this->getMock('F3\\FLOW3\\Reflection\\ReflectionService', array('loadFromCache', 'saveToCache'), array(), '', FALSE, TRUE);
     $mockReflectionService->initialize(array('F3\\FLOW3\\Tests\\AOP\\Fixture\\AspectClassWithAllAdviceTypes'));
     $mockPointcutExpressionParser = $this->getMock('F3\\FLOW3\\AOP\\Pointcut\\PointcutExpressionParser', array('parse'), array(), '', FALSE);
     $mockPointcutExpressionParser->expects($this->any())->method('parse')->will($this->returnCallBack(array($this, 'pointcutFilterCompositeCallBack')));
     $this->mockObjectFactory->expects($this->any())->method('create')->will($this->returnCallBack(array($this, 'objectFactoryCallBack')));
     $framework = $this->getMock($this->buildAccessibleProxy('F3\\FLOW3\\AOP\\Framework'), array('dummy'), array($this->mockObjectManager, $this->mockObjectFactory), '', TRUE, TRUE);
     $framework->injectReflectionService($mockReflectionService);
     $framework->injectPointcutExpressionParser($mockPointcutExpressionParser);
     $container = $framework->_call('buildAspectContainer', 'F3\\FLOW3\\Tests\\AOP\\Fixture\\AspectClassWithAllAdviceTypes');
     $this->assertType('F3\\FLOW3\\AOP\\AspectContainer', $container);
     $this->assertSame('F3\\FLOW3\\Tests\\AOP\\Fixture\\AspectClassWithAllAdviceTypes', $container->getClassName());
     $advisors = $container->getAdvisors();
     $this->assertType('F3\\FLOW3\\AOP\\Advice\\AroundAdvice', $advisors[0]->getAdvice());
     $this->assertSame('fooAround', $advisors[0]->getPointcut()->getPointcutExpression());
     $this->assertType('F3\\FLOW3\\AOP\\Advice\\BeforeAdvice', $advisors[1]->getAdvice());
     $this->assertSame('fooBefore', $advisors[1]->getPointcut()->getPointcutExpression());
     $this->assertType('F3\\FLOW3\\AOP\\Advice\\AfterReturningAdvice', $advisors[2]->getAdvice());
     $this->assertSame('fooAfterReturning', $advisors[2]->getPointcut()->getPointcutExpression());
     $this->assertType('F3\\FLOW3\\AOP\\Advice\\AfterThrowingAdvice', $advisors[3]->getAdvice());
     $this->assertSame('fooAfterThrowing', $advisors[3]->getPointcut()->getPointcutExpression());
     $this->assertType('F3\\FLOW3\\AOP\\Advice\\AfterAdvice', $advisors[4]->getAdvice());
     $this->assertSame('fooAfter', $advisors[4]->getPointcut()->getPointcutExpression());
     $pointcuts = $container->getPointcuts();
     $this->assertTrue(count($pointcuts) === 1);
     $this->assertType('F3\\FLOW3\\AOP\\Pointcut\\Pointcut', $pointcuts[0]);
     $this->assertSame('fooPointcut', $pointcuts[0]->getPointcutExpression());
     $introductions = $container->getIntroductions();
     $this->assertTrue(count($introductions) === 1);
     $this->assertType('F3\\FLOW3\\AOP\\Introduction', $introductions[0]);
     $this->assertSame('F3\\FLOW3\\Tests\\AOP\\Fixture\\AspectClassWithAllAdviceTypes', $introductions[0]->getDeclaringAspectClassName());
     $this->assertSame('F3\\FLOW3\\Tests\\AOP\\Fixture\\InterfaceForIntroduction', $introductions[0]->getInterfaceName());
     $this->assertSame('ThePointcutExpression', $introductions[0]->getPointcut()->getPointcutExpression());
 }
コード例 #2
0
 /**
  * @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'));
 }