2525 */
2626class WebTestCaseTest extends WebTestCase
2727{
28- /** @var \Symfony\Bundle\FrameworkBundle\Client client */
29- private $ client = null ;
30-
3128 public function setUp (): void
3229 {
3330 static ::$ class = AppKernel::class;
34- $ this -> client = static :: makeClient ();
31+ static :: $ client = $ this -> makeClient ();
3532 }
3633
3734 public static function getKernelClass ()
@@ -54,7 +51,7 @@ public function testMakeClient(): void
5451 {
5552 $ this ->assertInstanceOf (
5653 'Symfony\Bundle\FrameworkBundle\Client ' ,
57- static :: makeClient ()
54+ $ this -> makeClient ()
5855 );
5956 }
6057
@@ -81,7 +78,7 @@ public function testIndex(): void
8178 $ path = '/ ' ;
8279
8380 /** @var \Symfony\Component\DomCrawler\Crawler $crawler */
84- $ crawler = $ this -> client ->request ('GET ' , $ path );
81+ $ crawler = static :: $ client ->request ('GET ' , $ path );
8582
8683 $ this ->assertSame (1 ,
8784 $ crawler ->filter ('html > body ' )->count ());
@@ -110,9 +107,9 @@ public function testIndexAssertStatusCode(): void
110107
111108 $ path = '/ ' ;
112109
113- $ this -> client ->request ('GET ' , $ path );
110+ static :: $ client ->request ('GET ' , $ path );
114111
115- $ this ->assertStatusCode (200 , $ this -> client );
112+ $ this ->assertStatusCode (200 , static :: $ client );
116113 }
117114
118115 /**
@@ -124,10 +121,10 @@ public function testAssertStatusCodeFail(): void
124121
125122 $ path = '/ ' ;
126123
127- $ this -> client ->request ('GET ' , $ path );
124+ static :: $ client ->request ('GET ' , $ path );
128125
129126 try {
130- $ this ->assertStatusCode (-1 , $ this -> client );
127+ $ this ->assertStatusCode (-1 , static :: $ client );
131128 } catch (AssertionFailedError $ e ) {
132129 $ this ->assertStringStartsWith (
133130 'HTTP/1.1 200 OK ' ,
@@ -154,10 +151,10 @@ public function testAssertStatusCodeException(): void
154151
155152 $ path = '/user/2 ' ;
156153
157- $ this -> client ->request ('GET ' , $ path );
154+ static :: $ client ->request ('GET ' , $ path );
158155
159156 try {
160- $ this ->assertStatusCode (-1 , $ this -> client );
157+ $ this ->assertStatusCode (-1 , static :: $ client );
161158 } catch (AssertionFailedError $ e ) {
162159 $ string = <<<'EOF'
163160No user found
@@ -180,9 +177,9 @@ public function testIndexIsSuccesful(): void
180177
181178 $ path = '/ ' ;
182179
183- $ this -> client ->request ('GET ' , $ path );
180+ static :: $ client ->request ('GET ' , $ path );
184181
185- $ this ->isSuccessful ($ this -> client ->getResponse ());
182+ $ this ->isSuccessful (static :: $ client ->getResponse ());
186183 }
187184
188185 /**
@@ -240,11 +237,11 @@ public function test404Error(): void
240237
241238 $ path = '/missing_page ' ;
242239
243- $ this -> client ->request ('GET ' , $ path );
240+ static :: $ client ->request ('GET ' , $ path );
244241
245- $ this ->assertStatusCode (404 , $ this -> client );
242+ $ this ->assertStatusCode (404 , static :: $ client );
246243
247- $ this ->isSuccessful ($ this -> client ->getResponse (), false );
244+ $ this ->isSuccessful (static :: $ client ->getResponse (), false );
248245 }
249246
250247 /**
@@ -704,23 +701,23 @@ public function testForm(): void
704701
705702 $ path = '/form ' ;
706703
707- $ crawler = $ this -> client ->request ('GET ' , $ path );
704+ $ crawler = static :: $ client ->request ('GET ' , $ path );
708705
709- $ this ->assertStatusCode (200 , $ this -> client );
706+ $ this ->assertStatusCode (200 , static :: $ client );
710707
711708 $ form = $ crawler ->selectButton ('Submit ' )->form ();
712- $ crawler = $ this -> client ->submit ($ form );
709+ $ crawler = static :: $ client ->submit ($ form );
713710
714- $ this ->assertStatusCode (200 , $ this -> client );
711+ $ this ->assertStatusCode (200 , static :: $ client );
715712
716- $ this ->assertValidationErrors (['children[name].data ' ], $ this -> client ->getContainer ());
713+ $ this ->assertValidationErrors (['children[name].data ' ], static :: $ client ->getContainer ());
717714
718715 // Try again with the fields filled out.
719716 $ form = $ crawler ->selectButton ('Submit ' )->form ();
720717 $ form ->setValues (['form[name] ' => 'foo bar ' ]);
721- $ crawler = $ this -> client ->submit ($ form );
718+ $ crawler = static :: $ client ->submit ($ form );
722719
723- $ this ->assertStatusCode (200 , $ this -> client );
720+ $ this ->assertStatusCode (200 , static :: $ client );
724721
725722 $ this ->assertContains (
726723 'Name submitted. ' ,
@@ -739,23 +736,23 @@ public function testFormWithEmbed(): void
739736
740737 $ path = '/form-with-embed ' ;
741738
742- $ crawler = $ this -> client ->request ('GET ' , $ path );
739+ $ crawler = static :: $ client ->request ('GET ' , $ path );
743740
744- $ this ->assertStatusCode (200 , $ this -> client );
741+ $ this ->assertStatusCode (200 , static :: $ client );
745742
746743 $ form = $ crawler ->selectButton ('Submit ' )->form ();
747- $ crawler = $ this -> client ->submit ($ form );
744+ $ crawler = static :: $ client ->submit ($ form );
748745
749- $ this ->assertStatusCode (200 , $ this -> client );
746+ $ this ->assertStatusCode (200 , static :: $ client );
750747
751- $ this ->assertValidationErrors (['children[name].data ' ], $ this -> client ->getContainer ());
748+ $ this ->assertValidationErrors (['children[name].data ' ], static :: $ client ->getContainer ());
752749
753750 // Try again with the fields filled out.
754751 $ form = $ crawler ->selectButton ('Submit ' )->form ();
755752 $ form ->setValues (['form[name] ' => 'foo bar ' ]);
756- $ crawler = $ this -> client ->submit ($ form );
753+ $ crawler = static :: $ client ->submit ($ form );
757754
758- $ this ->assertStatusCode (200 , $ this -> client );
755+ $ this ->assertStatusCode (200 , static :: $ client );
759756
760757 $ this ->assertContains (
761758 'Name submitted. ' ,
@@ -774,16 +771,16 @@ public function testFormWithException(): void
774771
775772 $ path = '/form ' ;
776773
777- $ crawler = $ this -> client ->request ('GET ' , $ path );
774+ $ crawler = static :: $ client ->request ('GET ' , $ path );
778775
779- $ this ->assertStatusCode (200 , $ this -> client );
776+ $ this ->assertStatusCode (200 , static :: $ client );
780777
781778 $ form = $ crawler ->selectButton ('Submit ' )->form ();
782- $ this -> client ->submit ($ form );
779+ static :: $ client ->submit ($ form );
783780
784- $ this ->assertStatusCode (200 , $ this -> client );
781+ $ this ->assertStatusCode (200 , static :: $ client );
785782
786- $ this ->assertValidationErrors (['' ], $ this -> client ->getContainer ());
783+ $ this ->assertValidationErrors (['' ], static :: $ client ->getContainer ());
787784 }
788785
789786 /**
@@ -796,14 +793,14 @@ public function testFormWithExceptionAssertStatusCode(): void
796793
797794 $ path = '/form ' ;
798795
799- $ crawler = $ this -> client ->request ('GET ' , $ path );
796+ $ crawler = static :: $ client ->request ('GET ' , $ path );
800797
801798 $ form = $ crawler ->selectButton ('Submit ' )->form ();
802799
803- $ this -> client ->submit ($ form );
800+ static :: $ client ->submit ($ form );
804801
805802 try {
806- $ this ->assertStatusCode (-1 , $ this -> client );
803+ $ this ->assertStatusCode (-1 , static :: $ client );
807804 } catch (AssertionFailedError $ e ) {
808805 $ string = <<<'EOF'
809806Unexpected validation errors:
@@ -826,14 +823,14 @@ public function testJsonIsSuccesful(): void
826823 {
827824 $ this ->loadFixtures ([]);
828825
829- $ this -> client = static :: makeClient ();
826+ static :: $ client = $ this -> makeClient ();
830827
831828 $ path = '/json ' ;
832829
833- $ this -> client ->request ('GET ' , $ path );
830+ static :: $ client ->request ('GET ' , $ path );
834831
835832 $ this ->isSuccessful (
836- $ this -> client ->getResponse (),
833+ static :: $ client ->getResponse (),
837834 true ,
838835 'application/json '
839836 );
@@ -843,6 +840,6 @@ public function tearDown(): void
843840 {
844841 parent ::tearDown ();
845842
846- $ this -> client = null ;
843+ static :: $ client = null ;
847844 }
848845}
0 commit comments