Skip to content

Commit efd4a1f

Browse files
greg0iredbu
authored andcommitted
Avoid name collision with parent method (#193)
Since symfony/symfony@4f91020 , that ships with 4.3.0, there is a collision between a private static method in a trait use in an ancestor class of BaseTestCase and the method in BaseTestCase. See https://github.com/symfony/symfony/blob/950306adaad8b23725c4efeaf6c570d89e17f164/src/Symfony/Bundle/FrameworkBundle/Test/WebTestAssertionsTrait.php#L189 Closes #192
1 parent 7157df3 commit efd4a1f

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

phpunit.xml.dist

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@
1212
</testsuite>
1313
</testsuites>
1414

15+
<listeners>
16+
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
17+
</listeners>
18+
1519
</phpunit>

src/Functional/BaseTestCase.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,26 @@ protected function getKernelConfiguration()
5454
return [];
5555
}
5656

57+
public function __call($name, $arguments)
58+
{
59+
if ('getClient' === $name) {
60+
@trigger_error(sprintf(
61+
'"%s::getClient()" is deprecated in favor of getFrameworkBundleClient() since symfony-cmf/testing 2.1 and will no longer be callable in 3.0',
62+
__CLASS__
63+
), E_USER_DEPRECATED);
64+
65+
return $this->getFrameworkBundleClient();
66+
}
67+
68+
return parent::$name(...$arguments);
69+
}
70+
5771
/**
5872
* Gets the Client.
5973
*
6074
* @return Client
6175
*/
62-
public function getClient()
76+
public function getFrameworkBundleClient()
6377
{
6478
if (null === $this->client) {
6579
$this->client = $this->createClient($this->getKernelConfiguration());

tests/Functional/BaseTestCaseTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,20 @@ public function provideTestDb()
7676
];
7777
}
7878

79+
/**
80+
* @group legacy
81+
* @expectedDeprecation "Symfony\Cmf\Component\Testing\Functional\BaseTestCase::getClient()" is deprecated in favor of getFrameworkBundleClient() since symfony-cmf/testing 2.1 and will no longer be callable in 3.0
82+
*/
83+
public function testItTriggersADeprecationErrorWhenCallingGetClient()
84+
{
85+
$this->assertInstanceOf(Client::class, $this->testCase->getClient());
86+
}
87+
88+
public function testItCanProvideAFrameworkBundleClient()
89+
{
90+
$this->assertInstanceOf(Client::class, $this->testCase->getFrameworkBundleClient());
91+
}
92+
7993
/**
8094
* @dataProvider provideTestDb
8195
* @depends testGetContainer

0 commit comments

Comments
 (0)