@@ -91,24 +91,11 @@ You can run tests using the ``./vendor/bin/phpunit`` command:
91
91
Integration Tests
92
92
-----------------
93
93
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.
95
97
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
112
99
public services and the non-removed :ref: `private services <container-public >`
113
100
services::
114
101
@@ -118,29 +105,12 @@ services::
118
105
self::bootKernel();
119
106
120
107
$container = self::$container;
121
- // $someService = $container->get('the-service-ID');
108
+ $someService = $container->get('the-service-ID');
122
109
123
- // ...
110
+ $result = $someService->something();
111
+ $this->assertTrue($result);
124
112
}
125
113
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
-
144
114
Mocking Services
145
115
~~~~~~~~~~~~~~~~
146
116
149
119
.. _functional-tests :
150
120
151
121
Application Tests
152
- ----------------
122
+ -----------------
153
123
154
124
Application tests check the integration of the different layers of an
155
125
application (from the routing to the views). They are no different from unit
0 commit comments