12
12
namespace Symfony \Cmf \Component \Testing \Tests \Functional ;
13
13
14
14
use Doctrine \Bundle \PHPCRBundle \Initializer \InitializerManager ;
15
+ use Doctrine \Bundle \PHPCRBundle \ManagerRegistry ;
15
16
use Doctrine \Bundle \PHPCRBundle \ManagerRegistryInterface ;
16
17
use Doctrine \Bundle \PHPCRBundle \Test \RepositoryManager ;
17
18
use PHPUnit \Framework \MockObject \MockObject ;
21
22
use Symfony \Cmf \Component \Testing \Functional \BaseTestCase ;
22
23
use Symfony \Cmf \Component \Testing \Functional \DbManager \PHPCR ;
23
24
use Symfony \Cmf \Component \Testing \Tests \Fixtures \TestTestCase ;
25
+ use Symfony \Component \DependencyInjection \Container ;
24
26
use Symfony \Component \DependencyInjection \ContainerInterface ;
27
+ use Symfony \Component \HttpKernel \Kernel ;
25
28
use Symfony \Component \HttpKernel \KernelInterface ;
26
29
27
30
class BaseTestCaseTest extends TestCase
@@ -48,13 +51,18 @@ class BaseTestCaseTest extends TestCase
48
51
49
52
protected function setUp (): void
50
53
{
51
- $ this ->container = $ this ->createMock (ContainerInterface::class);
54
+ $ managerRegistry = interface_exists (ManagerRegistryInterface::class)
55
+ ? $ this ->createMock (ManagerRegistryInterface::class)
56
+ : $ this ->createMock (ManagerRegistry::class)
57
+ ;
58
+ $ this ->container = Kernel::MAJOR_VERSION >= 7 ? $ this ->createMock (Container::class) : $ this ->createMock (ContainerInterface::class);
52
59
$ this ->container
53
60
->method ('get ' )
54
- ->willReturnCallback (function ($ name ) {
61
+ ->willReturnCallback (function ($ name ) use ( $ managerRegistry ) {
55
62
$ dic = [
56
63
'test.client ' => $ this ->client ,
57
- 'doctrine_phpcr ' => $ this ->createMock (ManagerRegistryInterface::class),
64
+ 'test.service_container ' => $ this ->container ,
65
+ 'doctrine_phpcr ' => $ managerRegistry ,
58
66
'doctrine_phpcr.initializer_manager ' => $ this ->createMock (InitializerManager::class),
59
67
];
60
68
@@ -85,15 +93,6 @@ protected function setUp(): void
85
93
->willReturn ($ this ->container );
86
94
}
87
95
88
- public function testGetContainer ()
89
- {
90
- $ class = new \ReflectionClass (BaseTestCase::class);
91
- $ method = $ class ->getMethod ('getContainer ' );
92
- $ method ->setAccessible (true );
93
-
94
- $ this ->assertEquals ($ this ->container , $ method ->invoke (null ));
95
- }
96
-
97
96
public function testGetKernel ()
98
97
{
99
98
$ class = new \ReflectionClass (BaseTestCase::class);
@@ -128,8 +127,6 @@ public function provideTestDb()
128
127
129
128
/**
130
129
* @dataProvider provideTestDb
131
- *
132
- * @depends testGetContainer
133
130
*/
134
131
public function testDb ($ dbName , $ expected )
135
132
{
0 commit comments