You are here

function ClassCodeGeneratorSpec::it_overrides_properly_methods_with_args_passed_by_reference in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/spec/Prophecy/Doubler/Generator/ClassCodeGeneratorSpec.php \spec\Prophecy\Doubler\Generator\ClassCodeGeneratorSpec::it_overrides_properly_methods_with_args_passed_by_reference()

Parameters

\Prophecy\Doubler\Generator\Node\ClassNode $class:

\Prophecy\Doubler\Generator\Node\MethodNode $method:

\Prophecy\Doubler\Generator\Node\ArgumentNode $argument:

File

vendor/phpspec/prophecy/spec/Prophecy/Doubler/Generator/ClassCodeGeneratorSpec.php, line 107

Class

ClassCodeGeneratorSpec

Namespace

spec\Prophecy\Doubler\Generator

Code

function it_overrides_properly_methods_with_args_passed_by_reference($class, $method, $argument) {
  $class
    ->getParentClass()
    ->willReturn('RuntimeException');
  $class
    ->getInterfaces()
    ->willReturn(array(
    'Prophecy\\Doubler\\Generator\\MirroredInterface',
  ));
  $class
    ->getProperties()
    ->willReturn(array());
  $class
    ->getMethods()
    ->willReturn(array(
    $method,
  ));
  $method
    ->getName()
    ->willReturn('getName');
  $method
    ->getVisibility()
    ->willReturn('public');
  $method
    ->isStatic()
    ->willReturn(false);
  $method
    ->getArguments()
    ->willReturn(array(
    $argument,
  ));
  $method
    ->hasReturnType()
    ->willReturn(false);
  $method
    ->returnsReference()
    ->willReturn(false);
  $method
    ->getCode()
    ->willReturn('return $this->name;');
  $argument
    ->getName()
    ->willReturn('fullname');
  $argument
    ->getTypeHint()
    ->willReturn('array');
  $argument
    ->isOptional()
    ->willReturn(true);
  $argument
    ->getDefault()
    ->willReturn(null);
  $argument
    ->isPassedByReference()
    ->willReturn(true);
  $code = $this
    ->generate('CustomClass', $class);
  $expected = <<<'PHP'
namespace  {
class CustomClass extends \RuntimeException implements \Prophecy\Doubler\Generator\MirroredInterface {

public  function getName(array &$fullname = NULL) {
return $this->name;
}

}
}
PHP;
  $expected = strtr($expected, array(
    "\r\n" => "\n",
    "\r" => "\n",
  ));
  $code
    ->shouldBe($expected);
}