Mercurial > hg > isophonics-drupal-site
comparison vendor/phpspec/prophecy/spec/Prophecy/Doubler/ClassPatch/SplFileInfoPatchSpec.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4c8ae668cc8c |
---|---|
1 <?php | |
2 | |
3 namespace spec\Prophecy\Doubler\ClassPatch; | |
4 | |
5 use PhpSpec\ObjectBehavior; | |
6 use Prophecy\Argument; | |
7 use Prophecy\Doubler\Generator\Node\ClassNode; | |
8 use Prophecy\Doubler\Generator\Node\MethodNode; | |
9 | |
10 class SplFileInfoPatchSpec extends ObjectBehavior | |
11 { | |
12 function it_is_a_patch() | |
13 { | |
14 $this->shouldBeAnInstanceOf('Prophecy\Doubler\ClassPatch\ClassPatchInterface'); | |
15 } | |
16 | |
17 function its_priority_is_50() | |
18 { | |
19 $this->getPriority()->shouldReturn(50); | |
20 } | |
21 | |
22 function it_does_not_support_nodes_without_parent_class(ClassNode $node) | |
23 { | |
24 $node->getParentClass()->willReturn('stdClass'); | |
25 $this->supports($node)->shouldReturn(false); | |
26 } | |
27 | |
28 function it_supports_nodes_with_SplFileInfo_as_parent_class(ClassNode $node) | |
29 { | |
30 $node->getParentClass()->willReturn('SplFileInfo'); | |
31 $this->supports($node)->shouldReturn(true); | |
32 } | |
33 | |
34 function it_supports_nodes_with_derivative_of_SplFileInfo_as_parent_class(ClassNode $node) | |
35 { | |
36 $node->getParentClass()->willReturn('SplFileInfo'); | |
37 $this->supports($node)->shouldReturn(true); | |
38 } | |
39 | |
40 function it_adds_a_method_to_node_if_not_exists(ClassNode $node) | |
41 { | |
42 $node->hasMethod('__construct')->willReturn(false); | |
43 $node->addMethod(Argument::any())->shouldBeCalled(); | |
44 $node->getParentClass()->shouldBeCalled(); | |
45 | |
46 $this->apply($node); | |
47 } | |
48 | |
49 function it_updates_existing_method_if_found(ClassNode $node, MethodNode $method) | |
50 { | |
51 $node->hasMethod('__construct')->willReturn(true); | |
52 $node->getMethod('__construct')->willReturn($method); | |
53 $node->getParentClass()->shouldBeCalled(); | |
54 | |
55 $method->useParentCode()->shouldBeCalled(); | |
56 | |
57 $this->apply($node); | |
58 } | |
59 | |
60 function it_should_not_supply_a_file_for_a_directory_iterator(ClassNode $node, MethodNode $method) | |
61 { | |
62 $node->hasMethod('__construct')->willReturn(true); | |
63 $node->getMethod('__construct')->willReturn($method); | |
64 $node->getParentClass()->willReturn('DirectoryIterator'); | |
65 | |
66 $method->setCode(Argument::that(function($value) { | |
67 return strpos($value, '.php') === false; | |
68 }))->shouldBeCalled(); | |
69 | |
70 $this->apply($node); | |
71 } | |
72 | |
73 function it_should_supply_a_file_for_a_spl_file_object(ClassNode $node, MethodNode $method) | |
74 { | |
75 $node->hasMethod('__construct')->willReturn(true); | |
76 $node->getMethod('__construct')->willReturn($method); | |
77 $node->getParentClass()->willReturn('SplFileObject'); | |
78 | |
79 $method->setCode(Argument::that(function($value) { | |
80 return strpos($value, '.php') !== false; | |
81 }))->shouldBeCalled(); | |
82 | |
83 $this->apply($node); | |
84 } | |
85 } |