11<?php
22
33use Illuminate \Foundation \AliasLoader ;
4+ use Illuminate \Support \Str ;
45
56class FieldProviderTest extends Orchestra \Testbench \TestCase
67{
@@ -33,39 +34,39 @@ public function testExtend()
3334 public function testLaravelAuth ()
3435 {
3536 $ userId = 23452345 ;
36-
37+
3738 \Illuminate \Support \Facades \Auth::shouldReceive ('id ' )->once ()->andReturn ($ userId );
38-
39+
3940 $ currentUserId = $ this ->app ['understand.fieldProvider ' ]->getUserId ();
40-
41+
4142 $ this ->assertSame ($ userId , $ currentUserId );
4243 }
43-
44+
4445 public function testSentinelGetUser ()
4546 {
4647 $ loader = AliasLoader::getInstance ();
4748 $ loader ->alias ('Sentinel ' , '\Illuminate\Support\Facades\Auth ' );
48-
49+
4950 $ user = new stdClass ();
5051 $ user ->id = 423523 ;
51-
52+
5253 \Illuminate \Support \Facades \Auth::shouldReceive ('getUser ' )->once ()->andReturn ($ user );
53-
54+
5455 $ currentUserId = $ this ->app ['understand.fieldProvider ' ]->getUserId ();
5556
5657 $ this ->assertSame ($ user ->id , $ currentUserId );
5758 }
58-
59+
5960 public function testSentryGetUser ()
6061 {
6162 $ loader = AliasLoader::getInstance ();
6263 $ loader ->alias ('Sentry ' , '\Illuminate\Support\Facades\Auth ' );
63-
64+
6465 $ user = new stdClass ();
6566 $ user ->id = 545 ;
66-
67+
6768 \Illuminate \Support \Facades \Auth::shouldReceive ('getUser ' )->once ()->andReturn ($ user );
68-
69+
6970 $ currentUserId = $ this ->app ['understand.fieldProvider ' ]->getUserId ();
7071
7172 $ this ->assertSame ($ user ->id , $ currentUserId );
@@ -117,6 +118,8 @@ public function testEnableQueryBindings()
117118
118119 public function testGetServerIp ()
119120 {
121+ \Illuminate \Support \Facades \Route::get ('/ ' , function () {});
122+
120123 $ this ->call ('GET ' , '/ ' , [], [], [], ['SERVER_ADDR ' => '127.0 0.1 ' ]);
121124
122125 $ ip = $ this ->app ['understand.fieldProvider ' ]->getServerIp ();
@@ -126,6 +129,8 @@ public function testGetServerIp()
126129
127130 public function testQueryString ()
128131 {
132+ \Illuminate \Support \Facades \Route::get ('/test ' , function () {});
133+
129134 $ this ->call ('GET ' , '/test?query=123&password=1234 ' );
130135
131136 $ queryString = $ this ->app ['understand.fieldProvider ' ]->getQueryStringArray ();
@@ -136,6 +141,8 @@ public function testQueryString()
136141
137142 public function testPostRequestParameters ()
138143 {
144+ \Illuminate \Support \Facades \Route::post ('/ ' , function () {});
145+
139146 $ this ->call ('POST ' , '/ ' , ['test ' => 'a ' , 'password ' => 'b ' ]);
140147
141148 $ postData = $ this ->app ['understand.fieldProvider ' ]->getPostDataArray ();
@@ -146,6 +153,13 @@ public function testPostRequestParameters()
146153
147154 public function testJsonRequest ()
148155 {
156+ if ( ! method_exists ($ this , 'json ' ))
157+ {
158+ return $ this ->markTestSkipped ('The test base class does not support json requests ' );
159+ }
160+
161+ \Illuminate \Support \Facades \Route::post ('/ ' , function () {});
162+
149163 $ this ->json ('POST ' , '/ ' , ['test ' => 'b ' , 'password ' => 'test ' ]);
150164
151165 $ jsonData = $ this ->app ['understand.fieldProvider ' ]->getPostDataArray ();
@@ -156,6 +170,8 @@ public function testJsonRequest()
156170
157171 public function testQueryStringDisabled ()
158172 {
173+ \Illuminate \Support \Facades \Route::get ('/test ' , function () {});
174+
159175 $ this ->app ['config ' ]->set ('understand-laravel.query_string_enabled ' , false );
160176
161177 $ this ->call ('GET ' , '/test?query=123&password=1234 ' );
@@ -167,6 +183,8 @@ public function testQueryStringDisabled()
167183
168184 public function testPostRequestParametersDisabled ()
169185 {
186+ \Illuminate \Support \Facades \Route::post ('/ ' , function () {});
187+
170188 $ this ->app ['config ' ]->set ('understand-laravel.post_data_enabled ' , false );
171189
172190 $ this ->call ('POST ' , '/ ' , ['test ' => 'a ' , 'password ' => 'b ' ]);
0 commit comments