Skip to content

Commit c54bf9b

Browse files
Fixes test for intersection type
1 parent 7eb2e0e commit c54bf9b

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

tests/PHP81/Php81LanguageFeaturesTest.php

+14-4
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,14 @@ public function testMockingClassWithNewInInitializer()
8080
/** @test */
8181
public function it_can_mock_a_class_with_an_intersection_argument_type_hint()
8282
{
83-
$mock = Mockery::mock(ArgumentIntersectionTypeHint::class);
83+
$mock = Mockery::spy(ArgumentIntersectionTypeHint::class);
8484
$object = new IntersectionTypeHelperClass();
8585
$mock->allows()->foo($object);
8686

8787
$mock->foo($object);
88+
89+
$this->expectException(\TypeError::class);
90+
$mock->foo(Mockery::mock(IntersectionTypeHelper1Interface::class));
8891
}
8992

9093
/** @test */
@@ -184,16 +187,23 @@ public function exits(): never
184187
exit(123);
185188
}
186189
}
187-
class IntersectionTypeHelperClass
190+
class IntersectionTypeHelperClass implements IntersectionTypeHelper1Interface, IntersectionTypeHelper2Interface
191+
{
192+
function foo(): int { return 123; }
193+
function bar(): int { return 123; }
194+
}
195+
interface IntersectionTypeHelper2Interface
188196
{
197+
function foo(): int;
189198
}
190-
interface IntersectionTypeHelperInterface
199+
interface IntersectionTypeHelper1Interface
191200
{
201+
function bar(): int;
192202
}
193203

194204
class ArgumentIntersectionTypeHint
195205
{
196-
public function foo(IntersectionTypeHelperClass&IntersectionTypeHelperInterface $foo)
206+
public function foo(IntersectionTypeHelper1Interface&IntersectionTypeHelper2Interface $foo)
197207
{
198208
}
199209
}

0 commit comments

Comments
 (0)