Permalink
Browse files

Merge branch 'develop' into junit

  • Loading branch information...
2 parents 5e37e8f + 54e2c1f commit b4fbfe0b149d3426733f4953a7bb029b36cd415f Amjad Mohamed committed Sep 2, 2012
@@ -2,8 +2,11 @@
namespace Spec\PHPSpec\Specification\Interceptor;
+require_once __DIR__ . DIRECTORY_SEPARATOR . '_files/Calculator.php';
+
use PHPSpec\Specification\Interceptor\Object as ObjectInterceptor,
- PHPSpec\Matcher\MatcherFactory;
+ PHPSpec\Matcher\MatcherFactory,
+ spec\PHPSpec\Specification\Interceptor\Calculator;
class DescribeObject extends \PHPSpec\Context
{
@@ -18,4 +21,9 @@ public function itCanAccessNonPublicProperties()
->should->be(42);
}
+ public function itWIllInterceptTheResultOfInterceptedMagicCall()
+ {
+ $calculator = $this->spec(new Calculator);
+ $calculator->add(40, 2)->should->equal(42);
+ }
}
@@ -0,0 +1,13 @@
+<?php
+
+namespace spec\PHPSpec\Specification\Interceptor;
+
+class Calculator
+{
+ public function __call($method, $args)
+ {
+ if ($method === 'add') {
+ return array_sum($args);
+ }
+ }
+}
@@ -348,9 +348,9 @@ protected function interceptedHasAMagicCall()
protected function invokeInterceptedMagicCall($method, $args)
{
$intercepted = new \ReflectionMethod($this->_actualValue, '__call');
- return $intercepted->invokeArgs(
+ return InterceptorFactory::create($intercepted->invokeArgs(
$this->_actualValue, array($method, $args)
- );
+ ));
}
/**

0 comments on commit b4fbfe0

Please sign in to comment.