Skip to content

Commit e0186d5

Browse files
committed
fix client setup for symfony 5
1 parent 0a6c431 commit e0186d5

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/Functional/BaseTestCase.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
1515
use Symfony\Bundle\FrameworkBundle\Client;
16+
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1617
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
1718
use Symfony\Cmf\Component\Testing\Functional\DbManager\PhpcrDecorator;
1819
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -52,7 +53,10 @@ protected function getKernelConfiguration(): array
5253
return [];
5354
}
5455

55-
public function getFrameworkBundleClient(): Client
56+
/**
57+
* @return Client|KernelBrowser
58+
*/
59+
public function getFrameworkBundleClient()
5660
{
5761
if (null === $this->client) {
5862
// property does not exist in all symfony versions

tests/Functional/BaseTestCaseTest.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,35 @@
1212
namespace Symfony\Cmf\Component\Testing\Tests\Functional;
1313

1414
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
15+
use PHPUnit\Framework\MockObject\MockObject;
1516
use PHPUnit\Framework\TestCase;
1617
use Symfony\Bundle\FrameworkBundle\Client;
18+
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
1719
use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR;
1820
use Symfony\Cmf\Component\Testing\Tests\Fixtures\TestTestCase;
1921
use Symfony\Component\DependencyInjection\ContainerInterface;
2022
use Symfony\Component\HttpKernel\KernelInterface;
2123

2224
class BaseTestCaseTest extends TestCase
2325
{
26+
/**
27+
* @var ContainerInterface|MockObject
28+
*/
2429
private $container;
2530

31+
/**
32+
* @var KernelInterface|MockObject
33+
*/
2634
private $kernel;
2735

2836
/**
2937
* @var TestTestCase
3038
*/
3139
private $testCase;
3240

41+
/**
42+
* @var KernelBrowser|Client|MockObject
43+
*/
3344
private $client;
3445

3546
protected function setUp(): void
@@ -51,7 +62,12 @@ protected function setUp(): void
5162
$this->testCase = new TestTestCase();
5263
$this->testCase->setKernel($this->kernel);
5364

54-
$this->client = $this->createMock(Client::class);
65+
if (class_exists(KernelBrowser::class)) {
66+
$this->client = $this->createMock(KernelBrowser::class);
67+
} else {
68+
$this->client = $this->createMock(Client::class);
69+
}
70+
5571
$this->client->expects($this->any())
5672
->method('getContainer')
5773
->willReturn($this->container);
@@ -79,7 +95,11 @@ public function provideTestDb()
7995

8096
public function testItCanProvideAFrameworkBundleClient()
8197
{
82-
$this->assertInstanceOf(Client::class, $this->testCase->getFrameworkBundleClient());
98+
if (class_exists(KernelBrowser::class)) {
99+
$this->assertInstanceOf(KernelBrowser::class, $this->testCase->getFrameworkBundleClient());
100+
} else {
101+
$this->assertInstanceOf(Client::class, $this->testCase->getFrameworkBundleClient());
102+
}
83103
}
84104

85105
/**

0 commit comments

Comments
 (0)