16
16
use Hautelook \AliceBundle \Functional \ConfigurableKernel ;
17
17
use Hautelook \AliceBundle \Functional \WithoutDoctrineKernel ;
18
18
use Nelmio \Alice \Bridge \Symfony \NelmioAliceBundle ;
19
- use PHPUnit \ Framework \ TestCase ;
20
- use Symfony \Component \HttpKernel \KernelInterface ;
19
+ use Symfony \ Bundle \ FrameworkBundle \ Test \ KernelTestCase ;
20
+ use Symfony \Component \HttpKernel \Kernel ;
21
21
22
22
/**
23
23
* @covers \Hautelook\AliceBundle\HautelookAliceBundle
24
24
* @covers \Hautelook\AliceBundle\DependencyInjection\Configuration
25
25
* @covers \Hautelook\AliceBundle\DependencyInjection\HautelookAliceExtension
26
26
*/
27
- class HautelookAliceBundleTest extends TestCase
27
+ class HautelookAliceBundleTest extends KernelTestCase
28
28
{
29
- /**
30
- * @var KernelInterface|null
31
- */
32
- protected $ kernel ;
33
-
34
29
/**
35
30
* {@inheritdoc}
36
31
*/
37
- public function tearDown (): void
32
+ protected function tearDown (): void
38
33
{
39
- if (null !== $ this ->kernel ) {
40
- $ this ->kernel ->shutdown ();
34
+ if (Kernel::VERSION_ID < 41000 ) {
35
+ if (null !== self ::$ kernel ) {
36
+ self ::$ kernel ->shutdown ();
37
+ }
38
+ } else {
39
+ parent ::tearDown ();
40
+ static ::$ class = null ;
41
41
}
42
42
}
43
43
@@ -46,88 +46,102 @@ public function testCannotBootIfFidryAliceDataFixturesBundleIsNotRegistered()
46
46
$ this ->expectException (\LogicException::class);
47
47
$ this ->expectExceptionMessage ('To register "Hautelook\AliceBundle\HautelookAliceBundle", you also need: "Doctrine\Bundle\DoctrineBundle\DoctrineBundle", "Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle". ' );
48
48
49
- $ this -> kernel = new ConfigurableKernel ('ConfigurableKernel0 ' , true );
50
- $ this -> kernel ->boot ();
49
+ self :: $ kernel = new ConfigurableKernel ('ConfigurableKernel0 ' , true );
50
+ self :: $ kernel ->boot ();
51
51
}
52
52
53
53
public function testWillReplaceFixtureLoadCommandWithErrorInformationCommandIfDoctrineBundleIsNotRegistered ()
54
54
{
55
55
$ this ->expectException (\LogicException::class);
56
56
$ this ->expectExceptionMessage ('To register "Hautelook\AliceBundle\HautelookAliceBundle", you also need: "Doctrine\Bundle\DoctrineBundle\DoctrineBundle". ' );
57
57
58
- $ this -> kernel = new WithoutDoctrineKernel ('ConfigurableKernel1 ' , true );
59
- $ this -> kernel ->addBundle (new FidryAliceDataFixturesBundle ());
60
- $ this -> kernel ->addBundle (new NelmioAliceBundle ());
61
- $ this -> kernel ->boot ();
58
+ self :: $ kernel = new WithoutDoctrineKernel ('ConfigurableKernel1 ' , true );
59
+ self :: $ kernel ->addBundle (new FidryAliceDataFixturesBundle ());
60
+ self :: $ kernel ->addBundle (new NelmioAliceBundle ());
61
+ self :: $ kernel ->boot ();
62
62
}
63
63
64
64
public function testServiceRegistration ()
65
65
{
66
- $ this ->kernel = new AppKernel ('public ' , true );
67
- $ this ->kernel ->boot ();
66
+ if (Kernel::VERSION_ID < 41000 ) {
67
+ self ::$ kernel = new AppKernel ('public ' , true );
68
+ self ::$ kernel ->boot ();
69
+ $ container = self ::$ kernel ->getContainer ();
70
+ } else {
71
+ parent ::bootKernel (['environment ' => 'public ' , 'debug ' => true ]);
72
+ $ container = self ::$ container ;
73
+ }
68
74
69
75
// Resolvers
70
76
$ this ->assertInstanceOf (
71
77
\Hautelook \AliceBundle \Resolver \Bundle \SimpleBundleResolver::class,
72
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.resolver.bundle.simple_resolver ' )
78
+ $ container ->get ('hautelook_alice.resolver.bundle.simple_resolver ' )
73
79
);
74
80
75
81
$ this ->assertInstanceOf (
76
82
\Hautelook \AliceBundle \Resolver \Bundle \NoBundleResolver::class,
77
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.resolver.bundle.no_bundle_resolver ' )
83
+ $ container ->get ('hautelook_alice.resolver.bundle.no_bundle_resolver ' )
78
84
);
79
85
80
86
$ this ->assertInstanceOf (
81
87
\Hautelook \AliceBundle \BundleResolverInterface::class,
82
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.resolver.bundle ' )
88
+ $ container ->get ('hautelook_alice.resolver.bundle ' )
83
89
);
84
90
85
91
// Locators
86
92
$ this ->assertInstanceOf (
87
93
\Hautelook \AliceBundle \Locator \EnvironmentlessFilesLocator::class,
88
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.locator.environmentless ' )
94
+ $ container ->get ('hautelook_alice.locator.environmentless ' )
89
95
);
90
96
91
97
$ this ->assertInstanceOf (
92
98
\Hautelook \AliceBundle \Locator \EnvDirectoryLocator::class,
93
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.locator.env_directory ' )
99
+ $ container ->get ('hautelook_alice.locator.env_directory ' )
94
100
);
95
101
96
102
$ this ->assertInstanceOf (
97
103
\Hautelook \AliceBundle \FixtureLocatorInterface::class,
98
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.locator ' )
104
+ $ container ->get ('hautelook_alice.locator ' )
99
105
);
100
106
101
107
// Loader
102
108
$ this ->assertInstanceOf (
103
109
\Fidry \AliceDataFixtures \Loader \FileResolverLoader::class,
104
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.data_fixtures.loader.file_resolver_loader ' )
110
+ $ container ->get ('hautelook_alice.data_fixtures.loader.file_resolver_loader ' )
105
111
);
106
112
107
113
$ this ->assertInstanceOf (
108
114
\Fidry \AliceDataFixtures \LoaderInterface::class,
109
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.data_fixtures.purge_loader ' )
115
+ $ container ->get ('hautelook_alice.data_fixtures.purge_loader ' )
110
116
);
111
117
112
118
$ this ->assertInstanceOf (
113
119
\Fidry \AliceDataFixtures \LoaderInterface::class,
114
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.data_fixtures.append_loader ' )
120
+ $ container ->get ('hautelook_alice.data_fixtures.append_loader ' )
115
121
);
116
122
117
123
$ this ->assertInstanceOf (
118
124
\Hautelook \AliceBundle \Loader \DoctrineOrmLoader::class,
119
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.loader.doctrine_orm_loader ' )
125
+ $ container ->get ('hautelook_alice.loader.doctrine_orm_loader ' )
120
126
);
121
127
122
128
$ this ->assertInstanceOf (
123
129
\Hautelook \AliceBundle \LoaderInterface::class,
124
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.loader ' )
130
+ $ container ->get ('hautelook_alice.loader ' )
125
131
);
126
132
127
133
// Commands
128
134
$ this ->assertInstanceOf (
129
135
\Hautelook \AliceBundle \Console \Command \Doctrine \DoctrineOrmLoadDataFixturesCommand::class,
130
- $ this -> kernel -> getContainer () ->get ('hautelook_alice.console.command.doctrine.doctrine_orm_load_data_fixtures_command ' )
136
+ $ container ->get ('hautelook_alice.console.command.doctrine.doctrine_orm_load_data_fixtures_command ' )
131
137
);
132
138
}
139
+
140
+ /**
141
+ * {@inheritdoc}
142
+ */
143
+ protected static function getKernelClass ()
144
+ {
145
+ return AppKernel::class;
146
+ }
133
147
}
0 commit comments