Skip to content

Commit 198b35a

Browse files
committed
Added info about integration tests
1 parent bd28a64 commit 198b35a

File tree

1 file changed

+8
-38
lines changed

1 file changed

+8
-38
lines changed

testing.rst

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -91,24 +91,11 @@ You can run tests using the ``./vendor/bin/phpunit`` command:
9191
Integration Tests
9292
-----------------
9393

94-
TODO: KernelTestCase
94+
An integration test will test a larger part of your application compared to a unit
95+
test. Integration tests will use the Kernel to fetch a service from the dependency
96+
injection container.
9597

96-
Accessing the Container
97-
~~~~~~~~~~~~~~~~~~~~~~~
98-
99-
You can get the same container used in the application, which only includes
100-
the public services::
101-
102-
public function testSomething()
103-
{
104-
$kernel = self::bootKernel();
105-
$container = $kernel->getContainer();
106-
$someService = $container->get('the-service-ID');
107-
108-
// ...
109-
}
110-
111-
Symfony tests also have access to a special container that includes both the
98+
Symfony tests have access to a special container that includes both the
11299
public services and the non-removed :ref:`private services <container-public>`
113100
services::
114101

@@ -118,29 +105,12 @@ services::
118105
self::bootKernel();
119106

120107
$container = self::$container;
121-
// $someService = $container->get('the-service-ID');
108+
$someService = $container->get('the-service-ID');
122109

123-
// ...
110+
$result = $someService->something();
111+
$this->assertTrue($result);
124112
}
125113

126-
.. TODO is this really different from self::$container and how to access
127-
this in KernelTestCase?
128-
129-
Finally, for the most rare edge-cases, Symfony includes a special container
130-
which provides access to all services, public and private. This special
131-
container is a service that can be get via the normal container::
132-
133-
public function testSomething()
134-
{
135-
$client = self::createClient();
136-
$normalContainer = $client->getContainer();
137-
$specialContainer = $normalContainer->get('test.service_container');
138-
139-
// $somePrivateService = $specialContainer->get('the-service-ID');
140-
141-
// ...
142-
}
143-
144114
Mocking Services
145115
~~~~~~~~~~~~~~~~
146116

@@ -149,7 +119,7 @@ TODO
149119
.. _functional-tests:
150120

151121
Application Tests
152-
----------------
122+
-----------------
153123

154124
Application tests check the integration of the different layers of an
155125
application (from the routing to the views). They are no different from unit

0 commit comments

Comments
 (0)