Pressroom template verwijderd, website naar root van repo

This commit is contained in:
2020-03-22 15:30:52 +01:00
parent 2cb6a77425
commit f3d1c41e91
7620 changed files with 0 additions and 186900 deletions

View File

@@ -0,0 +1,54 @@
<?php
namespace spec\Prophecy\Doubler\ClassPatch;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ArgumentNode;
use Prophecy\Doubler\Generator\Node\ClassNode;
use Prophecy\Doubler\Generator\Node\MethodNode;
class DisableConstructorPatchSpec extends ObjectBehavior
{
function it_is_a_patch()
{
$this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
}
function its_priority_is_100()
{
$this->getPriority()->shouldReturn(100);
}
function it_supports_anything(ClassNode $node)
{
$this->supports($node)->shouldReturn(true);
}
function it_makes_all_constructor_arguments_optional(
ClassNode $class,
MethodNode $method,
ArgumentNode $arg1,
ArgumentNode $arg2
) {
$class->hasMethod('__construct')->willReturn(true);
$class->getMethod('__construct')->willReturn($method);
$method->getArguments()->willReturn(array($arg1, $arg2));
$arg1->setDefault(null)->shouldBeCalled();
$arg2->setDefault(null)->shouldBeCalled();
$method->setCode(Argument::type('string'))->shouldBeCalled();
$this->apply($class);
}
function it_creates_new_constructor_if_object_has_none(ClassNode $class)
{
$class->hasMethod('__construct')->willReturn(false);
$class->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode'))
->shouldBeCalled();
$this->apply($class);
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace spec\Prophecy\Doubler\ClassPatch;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ClassNode;
use Prophecy\Doubler\Generator\Node\MethodNode;
class HhvmExceptionPatchSpec extends ObjectBehavior
{
function it_is_a_patch()
{
$this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
}
function its_priority_is_minus_50()
{
$this->getPriority()->shouldReturn(-50);
}
function it_uses_parent_code_for_setTraceOptions(ClassNode $node, MethodNode $method, MethodNode $getterMethod)
{
$node->hasMethod('setTraceOptions')->willReturn(true);
$node->getMethod('setTraceOptions')->willReturn($method);
$node->hasMethod('getTraceOptions')->willReturn(true);
$node->getMethod('getTraceOptions')->willReturn($getterMethod);
$method->useParentCode()->shouldBeCalled();
$getterMethod->useParentCode()->shouldBeCalled();
$this->apply($node);
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace spec\Prophecy\Doubler\ClassPatch;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ClassNode;
use Prophecy\Doubler\Generator\Node\MethodNode;
class KeywordPatchSpec extends ObjectBehavior
{
function it_is_a_patch()
{
$this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
}
function its_priority_is_49()
{
$this->getPriority()->shouldReturn(49);
}
function it_will_remove_echo_and_eval_methods(
ClassNode $node,
MethodNode $method1,
MethodNode $method2,
MethodNode $method3
) {
$node->removeMethod('eval')->shouldBeCalled();
$node->removeMethod('echo')->shouldBeCalled();
$method1->getName()->willReturn('echo');
$method2->getName()->willReturn('eval');
$method3->getName()->willReturn('notKeyword');
$node->getMethods()->willReturn(array(
'echo' => $method1,
'eval' => $method2,
'notKeyword' => $method3,
));
$this->apply($node);
}
}

View File

@@ -0,0 +1,140 @@
<?php
namespace spec\Prophecy\Doubler\ClassPatch;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ClassNode;
use Prophecy\Doubler\Generator\Node\MethodNode;
class MagicCallPatchSpec extends ObjectBehavior
{
function it_is_a_patch()
{
$this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
}
function it_supports_anything(ClassNode $node)
{
$this->supports($node)->shouldReturn(true);
}
function it_discovers_api_using_phpdoc(ClassNode $node)
{
$node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApi');
$node->getInterfaces()->willReturn(array());
$node->addMethod(new MethodNode('undefinedMethod'))->shouldBeCalled();
$this->apply($node);
}
function it_ignores_existing_methods(ClassNode $node)
{
$node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiExtended');
$node->getInterfaces()->willReturn(array());
$node->addMethod(new MethodNode('undefinedMethod'))->shouldBeCalled();
$node->addMethod(new MethodNode('definedMethod'))->shouldNotBeCalled();
$this->apply($node);
}
function it_ignores_empty_methods_from_phpdoc(ClassNode $node)
{
$node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiInvalidMethodDefinition');
$node->getInterfaces()->willReturn(array());
$node->addMethod(new MethodNode(''))->shouldNotBeCalled();
$this->apply($node);
}
function it_discovers_api_using_phpdoc_from_implemented_interfaces(ClassNode $node)
{
$node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiImplemented');
$node->getInterfaces()->willReturn(array());
$node->addMethod(new MethodNode('implementedMethod'))->shouldBeCalled();
$this->apply($node);
}
function it_discovers_api_using_phpdoc_from_own_interfaces(ClassNode $node)
{
$node->getParentClass()->willReturn('stdClass');
$node->getInterfaces()->willReturn(array('spec\Prophecy\Doubler\ClassPatch\MagicalApiImplemented'));
$node->addMethod(new MethodNode('implementedMethod'))->shouldBeCalled();
$this->apply($node);
}
function it_discovers_api_using_phpdoc_from_extended_parent_interfaces(ClassNode $node)
{
$node->getParentClass()->willReturn('spec\Prophecy\Doubler\ClassPatch\MagicalApiImplementedExtended');
$node->getInterfaces()->willReturn(array());
$node->addMethod(new MethodNode('implementedMethod'))->shouldBeCalled();
$this->apply($node);
}
function it_has_50_priority()
{
$this->getPriority()->shouldReturn(50);
}
}
/**
* @method void undefinedMethod()
*/
class MagicalApi
{
/**
* @return void
*/
public function definedMethod()
{
}
}
/**
* @method void invalidMethodDefinition
* @method void
* @method
*/
class MagicalApiInvalidMethodDefinition
{
}
/**
* @method void undefinedMethod()
* @method void definedMethod()
*/
class MagicalApiExtended extends MagicalApi
{
}
/**
*/
class MagicalApiImplemented implements MagicalApiInterface
{
}
/**
*/
class MagicalApiImplementedExtended extends MagicalApiImplemented
{
}
/**
* @method void implementedMethod()
*/
interface MagicalApiInterface
{
}

View File

@@ -0,0 +1,79 @@
<?php
namespace spec\Prophecy\Doubler\ClassPatch;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ClassNode;
use Prophecy\Doubler\Generator\Node\MethodNode;
class ProphecySubjectPatchSpec extends ObjectBehavior
{
function it_is_a_patch()
{
$this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
}
function it_has_priority_of_0()
{
$this->getPriority()->shouldReturn(0);
}
function it_supports_any_class(ClassNode $node)
{
$this->supports($node)->shouldReturn(true);
}
function it_forces_class_to_implement_ProphecySubjectInterface(ClassNode $node)
{
$node->addInterface('Prophecy\Prophecy\ProphecySubjectInterface')->shouldBeCalled();
$node->addProperty('objectProphecy', 'private')->willReturn(null);
$node->getMethods()->willReturn(array());
$node->hasMethod(Argument::any())->willReturn(false);
$node->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode'))->willReturn(null);
$node->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode'))->willReturn(null);
$this->apply($node);
}
function it_forces_all_class_methods_except_constructor_to_proxy_calls_into_prophecy_makeCall(
ClassNode $node,
MethodNode $constructor,
MethodNode $method1,
MethodNode $method2,
MethodNode $method3
) {
$node->addInterface('Prophecy\Prophecy\ProphecySubjectInterface')->willReturn(null);
$node->addProperty('objectProphecy', 'private')->willReturn(null);
$node->hasMethod(Argument::any())->willReturn(false);
$node->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode'))->willReturn(null);
$node->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode'))->willReturn(null);
$constructor->getName()->willReturn('__construct');
$method1->getName()->willReturn('method1');
$method2->getName()->willReturn('method2');
$method3->getName()->willReturn('method3');
$method1->getReturnType()->willReturn('int');
$method2->getReturnType()->willReturn('int');
$method3->getReturnType()->willReturn('void');
$node->getMethods()->willReturn(array(
'method1' => $method1,
'method2' => $method2,
'method3' => $method3,
));
$constructor->setCode(Argument::any())->shouldNotBeCalled();
$method1->setCode('return $this->getProphecy()->makeProphecyMethodCall(__FUNCTION__, func_get_args());')
->shouldBeCalled();
$method2->setCode('return $this->getProphecy()->makeProphecyMethodCall(__FUNCTION__, func_get_args());')
->shouldBeCalled();
$method3->setCode('$this->getProphecy()->makeProphecyMethodCall(__FUNCTION__, func_get_args());')
->shouldBeCalled();
$this->apply($node);
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace spec\Prophecy\Doubler\ClassPatch;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ArgumentNode;
use Prophecy\Doubler\Generator\Node\ClassNode;
use Prophecy\Doubler\Generator\Node\MethodNode;
class ReflectionClassNewInstancePatchSpec extends ObjectBehavior
{
function it_is_a_patch()
{
$this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
}
function its_priority_is_50()
{
$this->getPriority()->shouldReturn(50);
}
function it_supports_ReflectionClass_only(ClassNode $reflectionClassNode, ClassNode $anotherClassNode)
{
$reflectionClassNode->getParentClass()->willReturn('ReflectionClass');
$anotherClassNode->getParentClass()->willReturn('stdClass');
$this->supports($reflectionClassNode)->shouldReturn(true);
$this->supports($anotherClassNode)->shouldReturn(false);
}
function it_makes_all_newInstance_arguments_optional(
ClassNode $class,
MethodNode $method,
ArgumentNode $arg1
) {
$class->getMethod('newInstance')->willReturn($method);
$method->getArguments()->willReturn(array($arg1));
$arg1->setDefault(null)->shouldBeCalled();
$this->apply($class);
}
}

View File

@@ -0,0 +1,85 @@
<?php
namespace spec\Prophecy\Doubler\ClassPatch;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ClassNode;
use Prophecy\Doubler\Generator\Node\MethodNode;
class SplFileInfoPatchSpec extends ObjectBehavior
{
function it_is_a_patch()
{
$this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
}
function its_priority_is_50()
{
$this->getPriority()->shouldReturn(50);
}
function it_does_not_support_nodes_without_parent_class(ClassNode $node)
{
$node->getParentClass()->willReturn('stdClass');
$this->supports($node)->shouldReturn(false);
}
function it_supports_nodes_with_SplFileInfo_as_parent_class(ClassNode $node)
{
$node->getParentClass()->willReturn('SplFileInfo');
$this->supports($node)->shouldReturn(true);
}
function it_supports_nodes_with_derivative_of_SplFileInfo_as_parent_class(ClassNode $node)
{
$node->getParentClass()->willReturn('SplFileInfo');
$this->supports($node)->shouldReturn(true);
}
function it_adds_a_method_to_node_if_not_exists(ClassNode $node)
{
$node->hasMethod('__construct')->willReturn(false);
$node->addMethod(Argument::any())->shouldBeCalled();
$node->getParentClass()->shouldBeCalled();
$this->apply($node);
}
function it_updates_existing_method_if_found(ClassNode $node, MethodNode $method)
{
$node->hasMethod('__construct')->willReturn(true);
$node->getMethod('__construct')->willReturn($method);
$node->getParentClass()->shouldBeCalled();
$method->useParentCode()->shouldBeCalled();
$this->apply($node);
}
function it_should_not_supply_a_file_for_a_directory_iterator(ClassNode $node, MethodNode $method)
{
$node->hasMethod('__construct')->willReturn(true);
$node->getMethod('__construct')->willReturn($method);
$node->getParentClass()->willReturn('DirectoryIterator');
$method->setCode(Argument::that(function($value) {
return strpos($value, '.php') === false;
}))->shouldBeCalled();
$this->apply($node);
}
function it_should_supply_a_file_for_a_spl_file_object(ClassNode $node, MethodNode $method)
{
$node->hasMethod('__construct')->willReturn(true);
$node->getMethod('__construct')->willReturn($method);
$node->getParentClass()->willReturn('SplFileObject');
$method->setCode(Argument::that(function($value) {
return strpos($value, '.php') !== false;
}))->shouldBeCalled();
$this->apply($node);
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace spec\Prophecy\Doubler\ClassPatch;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Prophecy\Doubler\Generator\Node\ClassNode;
class TraversablePatchSpec extends ObjectBehavior
{
function it_is_a_patch()
{
$this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
}
function it_supports_class_that_implements_only_Traversable(ClassNode $node)
{
$node->getInterfaces()->willReturn(array('Traversable'));
$this->supports($node)->shouldReturn(true);
}
function it_does_not_support_class_that_implements_Iterator(ClassNode $node)
{
$node->getInterfaces()->willReturn(array('Traversable', 'Iterator'));
$this->supports($node)->shouldReturn(false);
}
function it_does_not_support_class_that_implements_IteratorAggregate(ClassNode $node)
{
$node->getInterfaces()->willReturn(array('Traversable', 'IteratorAggregate'));
$this->supports($node)->shouldReturn(false);
}
function it_has_100_priority()
{
$this->getPriority()->shouldReturn(100);
}
function it_forces_node_to_implement_IteratorAggregate(ClassNode $node)
{
$node->addInterface('Iterator')->shouldBeCalled();
$node->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode'))->willReturn(null);
$this->apply($node);
}
}