1313
1414namespace Liip \Acme \Tests \Test ;
1515
16- use Doctrine \Common \Annotations \Annotation \IgnoreAnnotation ;
17- use Liip \Acme \Tests \App \Entity \User ;
1816use Liip \Acme \Tests \AppConfig \AppConfigKernel ;
1917use Liip \Acme \Tests \Traits \LiipAcmeFixturesTrait ;
2018use Liip \FunctionalTestBundle \Annotations \QueryCount ;
3129 * @runTestsInSeparateProcesses
3230 *
3331 * @preserveGlobalState disabled
34- *
35- * Avoid conflict with PHPUnit annotation when reading QueryCount
36- * annotation:
37- *
38- * @IgnoreAnnotation("expectedException")
3932 */
4033class WebTestCaseConfigTest extends WebTestCase
4134{
@@ -44,6 +37,13 @@ class WebTestCaseConfigTest extends WebTestCase
4437 /** @var \Symfony\Bundle\FrameworkBundle\Client client */
4538 private $ client ;
4639
40+ protected function tearDown (): void
41+ {
42+ parent ::tearDown ();
43+
44+ restore_exception_handler ();
45+ }
46+
4747 protected static function getKernelClass (): string
4848 {
4949 return AppConfigKernel::class;
@@ -54,8 +54,6 @@ protected static function getKernelClass(): string
5454 */
5555 public function testIndexClientWithCredentials (): void
5656 {
57- $ this ->skipTestIfSymfonyHasVersion7 ();
58-
5957 $ this ->client = static ::makeClientWithCredentials ('foobar ' , '12341234 ' );
6058
6159 $ path = '/admin ' ;
@@ -87,8 +85,6 @@ public function testIndexClientWithCredentials(): void
8785 */
8886 public function testIndexAuthenticatedClient (): void
8987 {
90- $ this ->skipTestIfSymfonyHasVersion7 ();
91-
9288 $ this ->client = static ::makeAuthenticatedClient ();
9389
9490 $ path = '/admin ' ;
@@ -120,8 +116,6 @@ public function testIndexAuthenticatedClient(): void
120116 */
121117 public function testIndexAuthenticationLoginAs (): void
122118 {
123- $ this ->skipTestIfSymfonyHasVersion7 ();
124-
125119 $ user = $ this ->loadTestFixtures ();
126120
127121 $ loginAs = $ this ->loginAs ($ user , 'secured_area ' );
@@ -160,8 +154,6 @@ public function testIndexAuthenticationLoginAs(): void
160154 */
161155 public function testIndexAuthenticationLoginClient (): void
162156 {
163- $ this ->skipTestIfSymfonyHasVersion7 ();
164-
165157 $ user = $ this ->loadTestFixtures ();
166158
167159 $ this ->client = static ::makeClient ();
@@ -190,57 +182,6 @@ public function testIndexAuthenticationLoginClient(): void
190182 );
191183 }
192184
193- /**
194- * Log in as the user defined in the Data Fixtures and except an
195- * AllowedQueriesExceededException exception.
196- *
197- * There will be 2 queries:
198- * - the user 1 is loaded from the database when logging in
199- * - the user 2 is loaded by the controller
200- *
201- * In the configuration the limit is 1, an Exception will be thrown.
202- */
203- public function testAllowedQueriesExceededException (): void
204- {
205- $ this ->skipTestIfSymfonyHasVersion7 ();
206-
207- $ user = $ this ->loadTestFixtures ();
208-
209- $ this ->assertInstanceOf (
210- User::class,
211- $ user
212- );
213-
214- $ this ->client = static ::makeClient ();
215-
216- $ this ->loginClient ($ this ->client , $ user , 'secured_area ' );
217-
218- $ path = '/user/2 ' ;
219-
220- $ this ->expectException (\Liip \FunctionalTestBundle \Exception \AllowedQueriesExceededException::class);
221-
222- $ crawler = $ this ->client ->request ('GET ' , $ path );
223-
224- // The following code is called if no exception has been thrown, it should help to understand why
225- $ this ->assertStatusCode (200 , $ this ->client );
226- $ this ->assertSame (
227- 'LiipFunctionalTestBundle ' ,
228- $ crawler ->filter ('h1 ' )->text ()
229- );
230- $ this ->assertSame (
231- 'Logged in as foo bar. ' ,
232- $ crawler ->filter ('p#user ' )->text ()
233- );
234- $ this ->assertSame (
235- 'Name: alice bob ' ,
236- $ crawler ->filter ('div#content p:nth-child(1) ' )->text ()
237- );
238- $ this ->assertSame (
239- 'Email: alice@example.com ' ,
240- $ crawler ->filter ('div#content p:nth-child(2) ' )->text ()
241- );
242- }
243-
244185 /**
245186 * Expect an exception due to the QueryCount annotation.
246187 *
0 commit comments