@@ 73-111 (lines=39) @@ | ||
70 | } |
|
71 | ||
72 | // T F T |
|
73 | function it_creates_two_different_class_definitions_for_the_same_class_with_different_interfaces_and_same_patches( |
|
74 | ClassMirror $mirror, |
|
75 | ClassCreator $creator, |
|
76 | NameGenerator $namer, |
|
77 | ClassPatchInterface $alt1, |
|
78 | ClassPatchInterface $alt2, |
|
79 | \ReflectionClass $class, |
|
80 | \ReflectionClass $interface1, |
|
81 | \ReflectionClass $interface2, |
|
82 | ClassNode $node1, |
|
83 | ClassNode $node2 |
|
84 | ) { |
|
85 | $mirror->reflect($class, array($interface1))->willReturn($node1); |
|
86 | $mirror->reflect($class, array($interface2))->willReturn($node2); |
|
87 | $alt1->supports($node1)->willReturn(true); |
|
88 | $alt1->supports($node2)->willReturn(true); |
|
89 | $alt2->supports($node1)->willReturn(false); |
|
90 | $alt2->supports($node2)->willReturn(false); |
|
91 | $alt1->getPriority()->willReturn(1); |
|
92 | $alt2->getPriority()->willReturn(2); |
|
93 | $namer->name($class, array($interface1))->willReturn('SplStack'); |
|
94 | $namer->name($class, array($interface2))->willReturn('SplStack'); |
|
95 | $class->getName()->willReturn('stdClass'); |
|
96 | $interface1->getName()->willReturn('ArrayAccess'); |
|
97 | $interface2->getName()->willReturn('Iterator'); |
|
98 | ||
99 | $alt1->apply($node1)->shouldBeCalled(); |
|
100 | $alt1->apply($node2)->shouldBeCalled(); |
|
101 | $alt2->apply($node1)->shouldNotBeCalled(); |
|
102 | $alt2->apply($node2)->shouldNotBeCalled(); |
|
103 | $creator->create('SplStack', $node1)->shouldBeCalledTimes(1); |
|
104 | $creator->create('SplStack', $node2)->shouldBeCalledTimes(1); |
|
105 | ||
106 | $this->registerClassPatch($alt1); |
|
107 | $this->registerClassPatch($alt2); |
|
108 | ||
109 | $this->double($class, array($interface1)); |
|
110 | $this->double($class, array($interface2)); |
|
111 | } |
|
112 | ||
113 | // F F T |
|
114 | function it_creates_two_different_class_definitions_for_different_classes_with_different_interfaces_and_same_patches( |
|
@@ 114-154 (lines=41) @@ | ||
111 | } |
|
112 | ||
113 | // F F T |
|
114 | function it_creates_two_different_class_definitions_for_different_classes_with_different_interfaces_and_same_patches( |
|
115 | ClassMirror $mirror, |
|
116 | ClassCreator $creator, |
|
117 | NameGenerator $namer, |
|
118 | ClassPatchInterface $alt1, |
|
119 | ClassPatchInterface $alt2, |
|
120 | \ReflectionClass $class1, |
|
121 | \ReflectionClass $class2, |
|
122 | \ReflectionClass $interface1, |
|
123 | \ReflectionClass $interface2, |
|
124 | ClassNode $node1, |
|
125 | ClassNode $node2 |
|
126 | ) { |
|
127 | $mirror->reflect($class1, array($interface1))->willReturn($node1); |
|
128 | $mirror->reflect($class2, array($interface2))->willReturn($node2); |
|
129 | $alt1->supports($node1)->willReturn(true); |
|
130 | $alt1->supports($node2)->willReturn(true); |
|
131 | $alt2->supports($node1)->willReturn(false); |
|
132 | $alt2->supports($node2)->willReturn(false); |
|
133 | $alt1->getPriority()->willReturn(1); |
|
134 | $alt2->getPriority()->willReturn(2); |
|
135 | $namer->name($class1, array($interface1))->willReturn('SplStack'); |
|
136 | $namer->name($class2, array($interface2))->willReturn('spec\Prophecy\Doubler\aClass'); |
|
137 | $class1->getName()->willReturn('stdClass'); |
|
138 | $class2->getName()->willReturn('aClass'); |
|
139 | $interface1->getName()->willReturn('ArrayAccess'); |
|
140 | $interface2->getName()->willReturn('Iterator'); |
|
141 | ||
142 | $alt1->apply($node1)->shouldBeCalled(); |
|
143 | $alt1->apply($node2)->shouldBeCalled(); |
|
144 | $alt2->apply($node1)->shouldNotBeCalled(); |
|
145 | $alt2->apply($node2)->shouldNotBeCalled(); |
|
146 | $creator->create('SplStack', $node1)->shouldBeCalledTimes(1); |
|
147 | $creator->create('spec\Prophecy\Doubler\aClass', $node2)->shouldBeCalledTimes(1); |
|
148 | ||
149 | $this->registerClassPatch($alt1); |
|
150 | $this->registerClassPatch($alt2); |
|
151 | ||
152 | $this->double($class1, array($interface1)); |
|
153 | $this->double($class2, array($interface2)); |
|
154 | } |
|
155 | ||
156 | // T T - |
|
157 | function it_creates_only_one_class_definition_for_the_same_class_with_same_interfaces_and_without_patches( |