Permalink
Browse files

Add a failing test for intercepting magic call returned value

  • Loading branch information...
1 parent 0bf4c5e commit d3d48a2c73bc2790cdd1e9baa6f0b669431b3adf @MarcelloDuarte MarcelloDuarte 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);
+ }
+ }
+}

0 comments on commit d3d48a2

Please sign in to comment.