File tree 2 files changed +16
-8
lines changed
2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -183,14 +183,14 @@ instead of
183
183
184
184
To be able to use the fully set up service container for your console tests
185
185
you can extend your test from
186
- :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Test\\ WebTestCase `::
186
+ :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Test\\ KernelTestCase `::
187
187
188
188
use Symfony\Component\Console\Tester\CommandTester;
189
189
use Symfony\Bundle\FrameworkBundle\Console\Application;
190
- use Symfony\Bundle\FrameworkBundle\Test\WebTestCase ;
190
+ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase ;
191
191
use Acme\DemoBundle\Command\GreetCommand;
192
192
193
- class ListCommandTest extends WebTestCase
193
+ class ListCommandTest extends KernelTestCase
194
194
{
195
195
public function testExecute()
196
196
{
@@ -214,3 +214,12 @@ you can extend your test from
214
214
// ...
215
215
}
216
216
}
217
+
218
+ .. versionadded :: 2.5
219
+ :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Test\\ KernelTestCase ` was
220
+ extracted from :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Test\\ WebTestCase `
221
+ in Symfony 2.5, where WebTestCase was made to inherit from KernelTestCase.
222
+ The difference being that WebTestCase makes available an instance of
223
+ :class: `Symfony\\ Bundle\\ FrameworkBundle\\ Client ` via `createClient() `,
224
+ while KernelTestCase makes available an instance of
225
+ :class: `Symfony\\ Component\\ HttpKernel\\ KernelInterface ` via `createKernel() `.
Original file line number Diff line number Diff line change @@ -17,15 +17,15 @@ Functional Testing
17
17
------------------
18
18
19
19
If you need to actually execute a query, you will need to boot the kernel
20
- to get a valid connection. In this case, you'll extend the ``WebTestCase ``,
20
+ to get a valid connection. In this case, you'll extend the ``KernelTestCase ``,
21
21
which makes all of this quite easy::
22
22
23
23
// src/Acme/StoreBundle/Tests/Entity/ProductRepositoryFunctionalTest.php
24
24
namespace Acme\StoreBundle\Tests\Entity;
25
25
26
- use Symfony\Bundle\FrameworkBundle\Test\WebTestCase ;
26
+ use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase ;
27
27
28
- class ProductRepositoryFunctionalTest extends WebTestCase
28
+ class ProductRepositoryFunctionalTest extends KernelTestCase
29
29
{
30
30
/**
31
31
* @var \Doctrine\ORM\EntityManager
@@ -37,8 +37,7 @@ which makes all of this quite easy::
37
37
*/
38
38
public function setUp()
39
39
{
40
- static::$kernel = static::createKernel();
41
- static::$kernel->boot();
40
+ self::bootKernel();
42
41
$this->em = static::$kernel->getContainer()
43
42
->get('doctrine')
44
43
->getManager()
You can’t perform that action at this time.
0 commit comments