예제 #1
0
 function testExactValue()
 {
     $this->assert(Argument::exact('foo')->accepts(new ExactArgument('foo')));
     $this->assert(Argument::exact(new \DateTime('2011-12-13'))->accepts(new ExactArgument(new \DateTime('2011-12-13'))));
     $this->assert->not(Argument::exact('foo')->accepts(new ExactArgument('bar')));
     $this->assert->not(Argument::exact('foo')->accepts(new IntegerArgument()));
 }
예제 #2
0
파일: Stubs.php 프로젝트: rtens/mockster
 /**
  * @param $method
  * @param $arguments
  * @return array|Argument[]
  */
 private function normalize($method, $arguments)
 {
     $normalized = [];
     $reflection = new \ReflectionMethod($this->class, $method);
     foreach ($reflection->getParameters() as $i => $parameter) {
         if (array_key_exists($i, $arguments)) {
             $argument = $arguments[$i];
             if ($argument instanceof Argument) {
                 $normalized[] = $argument;
             } else {
                 $normalized[] = Argument::exact($argument);
             }
         } else {
             if ($parameter->isDefaultValueAvailable()) {
                 $normalized[] = Argument::exact($parameter->getDefaultValue());
             }
         }
     }
     return $normalized;
 }