PhpSpec\Wrapper\Collaborator::beADoubleOf PHP Method

beADoubleOf() public method

public beADoubleOf ( string $classOrInterface )
$classOrInterface string
    public function beADoubleOf($classOrInterface)
    {
        if (interface_exists($classOrInterface)) {
            $this->prophecy->willImplement($classOrInterface);
        } else {
            $this->prophecy->willExtend($classOrInterface);
        }
    }

Usage Example

 /**
  * @param CollaboratorManager $collaborators
  * @param \ReflectionMethod $beforeMethod
  */
 private function createMissingCollabolators(CollaboratorManager $collaborators, \ReflectionMethod $beforeMethod)
 {
     foreach ($beforeMethod->getParameters() as $parameter) {
         if (!$collaborators->has($parameter->getName())) {
             $collaborator = new Collaborator($this->prophet->prophesize());
             if (null !== ($class = $parameter->getClass())) {
                 $collaborator->beADoubleOf($class->getName());
             }
             $collaborators->set($parameter->getName(), $collaborator);
         }
     }
 }