8000 add test · symfony/symfony@d5feef6 · GitHub
[go: up one dir, main page]

Skip to content

Commit d5feef6

Browse files
committed
add test
1 parent fdb2c43 commit d5feef6

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
namespace Symfony\Contracts\Tests\Fixtures;
4+
5+
use Symfony\Contracts\Service\ServiceSubscriberTrait;
6+
7+
/**
8+
* @author Kevin Bond <kevinbond@gmail.com>
9+
*/
10+
class TestServiceSubscriberUnion
11+
{
12+
use ServiceSubscriberTrait;
13+
14+
private function method1(): Service1
15+
{
16+
return $this->container->get(__METHOD__);
17+
}
18+
19+
private function method2(): Service1|Service2
20+
{
21+
return $this->container->get(__METHOD__);
22+
}
23+
24+
private function method3(): Service1|Service2|null
25+
{
26+
return $this->container->get(__METHOD__);
27+
}
28+
}

src/Symfony/Contracts/Tests/Service/ServiceSubscriberTraitTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Contracts\Service\ServiceLocatorTrait;
1717
use Symfony\Contracts\Service\ServiceSubscriberInterface;
1818
use Symfony\Contracts\Service\ServiceSubscriberTrait;
19+
use Symfony\Contracts\Tests\Fixtures\TestServiceSubscriberUnion;
1920

2021
class ServiceSubscriberTraitTest extends TestCase
2122
{
@@ -34,6 +35,16 @@ public function testSetContainerIsCalledOnParent()
3435

3536
$this->assertSame($container, (new TestService())->setContainer($container));
3637
}
38+
39+
/**
40+
* @requires PHP 8
41+
*/
42+
public function testMethodsWithUnionReturnTypesAreIgnored()
43+
{
44+
$expected = [TestServiceSubscriberUnion::class.'::method1' => '?Symfony\Contracts\Tests\Fixtures\Service1'];
45+
46+
$this->assertEquals($expected, TestServiceSubscriberUnion::getSubscribedServices());
47+
}
3748
}
3849

3950
class ParentTestService

0 commit comments

Comments
 (0)
0