annotate vendor/phpspec/prophecy/spec/Prophecy/Doubler/ClassPatch/TraversablePatchSpec.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace spec\Prophecy\Doubler\ClassPatch;
Chris@0 4
Chris@0 5 use PhpSpec\ObjectBehavior;
Chris@0 6 use Prophecy\Argument;
Chris@0 7 use Prophecy\Doubler\Generator\Node\ClassNode;
Chris@0 8
Chris@0 9 class TraversablePatchSpec extends ObjectBehavior
Chris@0 10 {
Chris@0 11 function it_is_a_patch()
Chris@0 12 {
Chris@0 13 $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface');
Chris@0 14 }
Chris@0 15
Chris@0 16 function it_supports_class_that_implements_only_Traversable(ClassNode $node)
Chris@0 17 {
Chris@0 18 $node->getInterfaces()->willReturn(array('Traversable'));
Chris@0 19
Chris@0 20 $this->supports($node)->shouldReturn(true);
Chris@0 21 }
Chris@0 22
Chris@0 23 function it_does_not_support_class_that_implements_Iterator(ClassNode $node)
Chris@0 24 {
Chris@0 25 $node->getInterfaces()->willReturn(array('Traversable', 'Iterator'));
Chris@0 26
Chris@0 27 $this->supports($node)->shouldReturn(false);
Chris@0 28 }
Chris@0 29
Chris@0 30 function it_does_not_support_class_that_implements_IteratorAggregate(ClassNode $node)
Chris@0 31 {
Chris@0 32 $node->getInterfaces()->willReturn(array('Traversable', 'IteratorAggregate'));
Chris@0 33
Chris@0 34 $this->supports($node)->shouldReturn(false);
Chris@0 35 }
Chris@0 36
Chris@0 37 function it_has_100_priority()
Chris@0 38 {
Chris@0 39 $this->getPriority()->shouldReturn(100);
Chris@0 40 }
Chris@0 41
Chris@0 42 function it_forces_node_to_implement_IteratorAggregate(ClassNode $node)
Chris@0 43 {
Chris@0 44 $node->addInterface('Iterator')->shouldBeCalled();
Chris@0 45
Chris@0 46 $node->addMethod(Argument::type('Prophecy\Doubler\Generator\Node\MethodNode'))->willReturn(null);
Chris@0 47
Chris@0 48 $this->apply($node);
Chris@0 49 }
Chris@0 50 }