File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99 - name : Checkout repository
1010 uses : actions/checkout@v3
1111
12+ - name : Setup PHP
13+ uses : shivammathur/setup-php@v2
14+ with :
15+ php-version : ' 8.2'
16+ tools : composer
17+ coverage : none
18+
1219 - name : Cache Composer dependencies
1320 uses : actions/cache@v3
1421 with :
1522 path : /tmp/composer-cache
1623 key : ${{ runner.os }}-${{ hashFiles('composer.lock') }}
1724
1825 - name : Installing dependencies
19- uses : php-actions/composer@v6
20- with :
21- php_version : 8.2
26+ env :
27+ COMPOSER_CACHE_DIR : /tmp/composer-cache
28+ run : composer install --no-interaction --no-progress --prefer-dist
2229
2330 - name : Running unit test
24- uses : php-actions/phpunit@v3
25- with :
26- version : 9.6
27- php_version : 8.2
28- configuration : phpunit.xml
31+ run : vendor/bin/phpunit --configuration phpunit.xml
Original file line number Diff line number Diff line change @@ -149,7 +149,6 @@ public function user()
149149 // pull the user data on that cookie which serves as a remember cookie on
150150 // the application. Once we have a user we can return it to the caller.
151151 $ recaller = $ this ->getRecaller ();
152-
153152 if (is_null ($ user ) && ! is_null ($ recaller ))
154153 {
155154 $ user = $ this ->getUserByRecaller ($ recaller );
@@ -210,15 +209,14 @@ protected function getRecaller()
210209 /**
211210 * Get the user ID from the recaller cookie.
212211 *
213- * @return string
212+ * @return int
214213 */
215- protected function getRecallerId ()
216- {
217- if ($ this ->validRecaller ($ recaller = $ this ->getRecaller ()))
218- {
219- return head (explode ('| ' , $ recaller ));
220- }
221- }
214+ protected function getRecallerId ()
215+ {
216+ if ($ this ->validRecaller ($ recaller = $ this ->getRecaller ())) {
217+ return (int ) head (explode ('| ' , $ recaller ));
218+ }
219+ }
222220
223221 /**
224222 * Determine if the recaller cookie is in a valid format.
Original file line number Diff line number Diff line change @@ -374,4 +374,25 @@ public function testUserUsesRememberCookieIfItExists()
374374 $ this ->assertEquals ($ user ->reveal (), $ guard ->user ());
375375 $ this ->assertTrue ($ guard ->viaRemember ());
376376 }
377+
378+ public function testGetIdWhenRememberCookieExistsWillReturnIntegerIdFromCookieValue ()
379+ {
380+ $ request = Request::create ('/ ' , 'GET ' , [], [
381+ 'remember_82e5d2c56bdd0811318f0cf078b78bfc ' => '123|recaller '
382+ ]);
383+
384+ $ this ->session ->get ('login_82e5d2c56bdd0811318f0cf078b78bfc ' , Argument::any ())->will (function ($ args ) {
385+ return $ args [1 ];
386+ });
387+
388+ $ guard = new Guard (
389+ $ this ->userProvider ->reveal (),
390+ $ this ->session ->reveal (),
391+ $ request
392+ );
393+
394+ $ this ->assertNotNull ($ guard ->id ());
395+ $ this ->assertIsInt ($ guard ->id ());
396+ $ this ->assertSame (123 , $ guard ->id ());
397+ }
377398}
You can’t perform that action at this time.
0 commit comments