Example #1
0
 /**
  * Initializes the getMetric() method of the given function or method node.
  *
  * @param PHP_PMD_Node_Function|PHP_PMD_Node_Method $mock   Mock instance.
  * @param string                                    $metric Metric acronym.
  * @param mixed                                     $value  Expected value.
  *
  * @return PHP_PMD_Node_Function|PHP_PMD_Node_Method
  */
 protected function initFunctionOrMethod($mock, $metric, $value)
 {
     if ($metric === null) {
         return $mock;
     }
     $mock->expects($this->atLeastOnce())->method('getMetric')->with($this->equalTo($metric))->will($this->returnValue($value));
     return $mock;
 }
Example #2
0
 /**
  * testMagicCallThrowsExceptionWhenNoMatchingMethodExists
  *
  * @return void
  * @covers PHP_PMD_Node_AbstractCallable::__call
  * @group phpmd
  * @group phpmd::node
  * @group unittest
  * @expectedException BadMethodCallException
  */
 public function testMagicCallThrowsExceptionWhenNoMatchingMethodExists()
 {
     $node = new PHP_PMD_Node_Function(new PHP_Depend_Code_Function(null));
     $node->getFooBar();
 }
Example #3
0
 /**
  * Initializes the getParameterCount() method of the given callable.
  *
  * @param PHP_PMD_Node_Function|PHP_PMD_Node_Method $mock Mocked callable.
  * @param integer $parameterCount Number of parameters.
  *
  * @return PHP_PMD_Node_Function|PHP_PMD_Node_Method
  */
 private function _initFunctionOrMethod($mock, $parameterCount)
 {
     $mock->expects($this->once())->method('getParameterCount')->will($this->returnValue($parameterCount));
     return $mock;
 }