Beispiel #1
0
 public function testBeforeCallReturnValueDoesNotOverrideDefaultReturnValue()
 {
     $interceptor = new ReturnBeforeCallInterceptor();
     InterceptorCache::registerInterceptor($interceptor, function ($x) {
         return true;
     });
     $proxy = $this->builder->build(new ReflectionClass('Tmont\\Phroxy\\Tests\\ClassToBeProxied'));
     self::assertEquals('bar', $proxy->bar());
 }
Beispiel #2
0
 /**
  * Registers an interceptor for any resolved type that matches the filter
  * expression
  * 
  * This method is merely a wrapper for {@link InterceptorCache::registerInterceptor()}.
  *
  * @uses    InterceptorCache::registerInterceptor()
  * @param   Interceptor $interceptor Interceptor implementation to register
  * @param   Closure     $matcher     Predicate that takes a ReflectionMethod as an argument and returns a boolean
  * @returns Container
  */
 public function registerInterceptor(Interceptor $interceptor, Closure $matcher)
 {
     InterceptorCache::registerInterceptor($interceptor, $matcher);
     return $this;
 }
Beispiel #3
0
 public function testAddInterceptorToCache()
 {
     $interceptor = $this->getMock('Tmont\\Phroxy\\Interceptor');
     $this->container->registerInterceptor($interceptor, function ($x) {
         return true;
     });
     self::assertEquals(1, count(InterceptorCache::getInterceptors(new ReflectionMethod($interceptor, 'onBeforeMethodCall'))));
 }