/** * Records the call as expectation and returns the mehtod options object. * * @param string method the method name * @param var[] args an array of arguments * @return var */ public function handleInvocation($method, $args) { $expectation = new Expectation($method); $expectation->setArguments($args); if ($this->expectationMap->containsKey($method)) { $methodExpectations = $this->expectationMap[$method]; } else { $methodExpectations = new ExpectationList(); $this->expectationMap[$method] = $methodExpectations; } $methodExpectations->add($expectation); return new MethodOptions($expectation, $method); }
public function handleInvocation_should_throw_exception_when_expectation_defines_one() { $expected = new \lang\XPException('foo'); $myExpectation = new Expectation('foo'); $myExpectation->setException($expected); $expectationsList = new ExpectationList(); $expectationsList->add($myExpectation); $this->expectationMap->put('foo', $expectationsList); try { $this->sut->handleInvocation('foo', null); $this->fail('Exception not thrown.', null, $expect); } catch (\lang\XPException $e) { $this->assertEquals($expected, $e); } }