Skip to content

Commit 793711d

Browse files
committed
[symfony#3311][WCM] Use KernelTestCase instead of WebTestCase for testing Command with a container
1 parent 9d4a138 commit 793711d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

cookbook/console/console_command.rst

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ instead of
183183

184184
To be able to use the fully set up service container for your console tests
185185
you can extend your test from
186-
:class:`Symfony\\Bundle\\FrameworkBundle\\Test\\WebTestCase`::
186+
:class:`Symfony\\Bundle\\FrameworkBundle\\Test\\KernelTestCase`::
187187

188188
use Symfony\Component\Console\Tester\CommandTester;
189189
use Symfony\Bundle\FrameworkBundle\Console\Application;
190-
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
190+
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
191191
use Acme\DemoBundle\Command\GreetCommand;
192192

193-
class ListCommandTest extends WebTestCase
193+
class ListCommandTest extends KernelTestCase
194194
{
195195
public function testExecute()
196196
{
@@ -214,3 +214,12 @@ you can extend your test from
214214
// ...
215215
}
216216
}
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()`.

0 commit comments

Comments
 (0)