コード例 #1
0
ファイル: MockedMethodTest.php プロジェクト: belanur/mokka
 /**
  * @expectedException \Mokka\VerificationException
  */
 public function testCallThrowsExceptionIfArgumentDoesNotMatchExpectedValue()
 {
     $arguments = new ArgumentCollection();
     $arguments->addArgument(new Argument('foo'));
     $method = new MockedMethod('foo', $arguments, new Any());
     $method->call(new ArgumentCollection(array('bar')));
     $method->verify();
 }
コード例 #2
0
 public function testHasArgumentAtPosition()
 {
     $this->assertFalse($this->_collection->hasArgumentAtPosition(0));
     $this->_collection->addArgument(new Argument('foo'));
     $this->assertTrue($this->_collection->hasArgumentAtPosition(0));
 }
コード例 #3
0
ファイル: Mock.php プロジェクト: belanur/mokka
 /**
  * @param string $methodName
  * @param array $args
  * @return NULL
  */
 private function _call($methodName, array $args)
 {
     $arguments = new ArgumentCollection();
     foreach ($args as $arg) {
         if ($arg instanceof AnythingArgument) {
             $arguments->addArgument($arg);
             continue;
         }
         $arguments->addArgument(new Argument($arg));
     }
     if ($this->_listeningForVerification || $this->_listeningForStub) {
         $this->_lastMethod = $methodName;
         $this->_lastArgs = $arguments;
         if ($this->_listeningForVerification) {
             $this->__mokka_addMockedMethod(new MockedMethod($methodName, $arguments, $this->_invokationRule));
         }
         return $this;
     }
     if ($this->__mokka_getMethods()->hasMethod($methodName, $arguments)) {
         $this->__mokka_getMethods()->getMethod($methodName, $arguments)->call($arguments);
     }
     if ($this->__mokka_getStubs()->hasMethod($methodName, $arguments)) {
         return $this->__mokka_getStubs()->getMethod($methodName, $arguments)->call($arguments);
     }
     return null;
 }