/** * This method is used to optimize the matching process. * * @param ClassNameIndex $classNameIndex * @return ClassNameIndex */ public function reduceTargetClassNames(ClassNameIndex $classNameIndex) { if ($this->pointcut === null) { $this->pointcut = $this->proxyClassBuilder->findPointcut($this->aspectClassName, $this->pointcutMethodName); } if ($this->pointcut === false) { return $classNameIndex; } return $this->pointcut->reduceTargetClassNames($classNameIndex); }
/** * @test */ public function reduceTargetClassNamesAsksThePointcutsFilterCompositeToReduce() { $pointcutExpression = 'ThePointcutExpression'; $aspectClassName = 'TheAspect'; $className = 'TheClass'; $targetClassNameIndex = new Aop\Builder\ClassNameIndex(); $mockPointcutFilterComposite = $this->getMockBuilder(Pointcut\PointcutFilterComposite::class)->disableOriginalConstructor()->getMock(); $mockPointcutFilterComposite->expects($this->once())->method('reduceTargetClassNames')->with($targetClassNameIndex)->will($this->returnValue('someResult')); $pointcut = new Pointcut\Pointcut($pointcutExpression, $mockPointcutFilterComposite, $aspectClassName, $className); $this->assertEquals('someResult', $pointcut->reduceTargetClassNames($targetClassNameIndex)); }