function ClassCodeGeneratorSpec::it_generates_proper_php_code_for_specific_ClassNode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/spec/Prophecy/Doubler/Generator/ClassCodeGeneratorSpec.php \spec\Prophecy\Doubler\Generator\ClassCodeGeneratorSpec::it_generates_proper_php_code_for_specific_ClassNode()
Parameters
\Prophecy\Doubler\Generator\Node\ClassNode $class:
\Prophecy\Doubler\Generator\Node\MethodNode $method1:
\Prophecy\Doubler\Generator\Node\MethodNode $method2:
\Prophecy\Doubler\Generator\Node\MethodNode $method3:
\Prophecy\Doubler\Generator\Node\ArgumentNode $argument11:
\Prophecy\Doubler\Generator\Node\ArgumentNode $argument12:
\Prophecy\Doubler\Generator\Node\ArgumentNode $argument21:
\Prophecy\Doubler\Generator\Node\ArgumentNode $argument31:
File
- vendor/
phpspec/ prophecy/ spec/ Prophecy/ Doubler/ Generator/ ClassCodeGeneratorSpec.php, line 19
Class
Namespace
spec\Prophecy\Doubler\GeneratorCode
function it_generates_proper_php_code_for_specific_ClassNode($class, $method1, $method2, $method3, $argument11, $argument12, $argument21, $argument31) {
$class
->getParentClass()
->willReturn('RuntimeException');
$class
->getInterfaces()
->willReturn(array(
'Prophecy\\Doubler\\Generator\\MirroredInterface',
'ArrayAccess',
'ArrayIterator',
));
$class
->getProperties()
->willReturn(array(
'name' => 'public',
'email' => 'private',
));
$class
->getMethods()
->willReturn(array(
$method1,
$method2,
$method3,
));
$method1
->getName()
->willReturn('getName');
$method1
->getVisibility()
->willReturn('public');
$method1
->returnsReference()
->willReturn(false);
$method1
->isStatic()
->willReturn(true);
$method1
->getArguments()
->willReturn(array(
$argument11,
$argument12,
));
$method1
->hasReturnType()
->willReturn(true);
$method1
->getReturnType()
->willReturn('string');
$method1
->getCode()
->willReturn('return $this->name;');
$method2
->getName()
->willReturn('getEmail');
$method2
->getVisibility()
->willReturn('protected');
$method2
->returnsReference()
->willReturn(false);
$method2
->isStatic()
->willReturn(false);
$method2
->getArguments()
->willReturn(array(
$argument21,
));
$method2
->hasReturnType()
->willReturn(false);
$method2
->getCode()
->willReturn('return $this->email;');
$method3
->getName()
->willReturn('getRefValue');
$method3
->getVisibility()
->willReturn('public');
$method3
->returnsReference()
->willReturn(true);
$method3
->isStatic()
->willReturn(false);
$method3
->getArguments()
->willReturn(array(
$argument31,
));
$method3
->hasReturnType()
->willReturn(false);
$method3
->getCode()
->willReturn('return $this->refValue;');
$argument11
->getName()
->willReturn('fullname');
$argument11
->getTypeHint()
->willReturn('array');
$argument11
->isOptional()
->willReturn(true);
$argument11
->getDefault()
->willReturn(null);
$argument11
->isPassedByReference()
->willReturn(false);
$argument12
->getName()
->willReturn('class');
$argument12
->getTypeHint()
->willReturn('ReflectionClass');
$argument12
->isOptional()
->willReturn(false);
$argument12
->isPassedByReference()
->willReturn(false);
$argument21
->getName()
->willReturn('default');
$argument21
->getTypeHint()
->willReturn(null);
$argument21
->isOptional()
->willReturn(true);
$argument21
->getDefault()
->willReturn('ever.zet@gmail.com');
$argument21
->isPassedByReference()
->willReturn(false);
$argument31
->getName()
->willReturn('refValue');
$argument31
->getTypeHint()
->willReturn(null);
$argument31
->isOptional()
->willReturn(false);
$argument31
->getDefault()
->willReturn();
$argument31
->isPassedByReference()
->willReturn(false);
$code = $this
->generate('CustomClass', $class);
$expected = <<<'PHP'
namespace {
class CustomClass extends \RuntimeException implements \Prophecy\Doubler\Generator\MirroredInterface, \ArrayAccess, \ArrayIterator {
public $name;
private $email;
public static function getName(array $fullname = NULL, \ReflectionClass $class): string {
return $this->name;
}
protected function getEmail( $default = 'ever.zet@gmail.com') {
return $this->email;
}
public function &getRefValue( $refValue) {
return $this->refValue;
}
}
}
PHP;
$expected = strtr($expected, array(
"\r\n" => "\n",
"\r" => "\n",
));
$code
->shouldBe($expected);
}