/** * Intercept all calls on the subject, and use the call details to create * a new expectation. The actual return value is then returned after being * recorded. * * @param string $method * @param array $args * @return mixed */ public function __call($method, array $args) { $return = call_user_func_array(array($this->_subject, $method), $args); $expectation = $this->_mock->shouldReceive($method)->andReturn($return); if ($this->_strict) { $exactArgs = array(); foreach ($args as $arg) { $exactArgs[] = ehough_mockery_Mockery::mustBe($arg); } $expectation->once()->ordered(); call_user_func_array(array($expectation, 'with'), $exactArgs); } else { call_user_func_array(array($expectation, 'with'), $args); } return $return; }
/** * @expectedException ehough_mockery_mockery_Exception */ public function testMustBeConstraintThrowsExceptionWhenConstraintUnmatchedWithObject() { $a = new stdClass(); $a->foo = 1; $b = new stdClass(); $b->foo = 2; $this->mock->shouldReceive('foo')->with(ehough_mockery_Mockery::mustBe($a))->once(); $this->mock->foo($b); $this->container->mockery_verify(); }