Repository navigation
Move the test namespace from Tests\ to CodeIgniter\Shield\Tests
#1399
paulbalandan
started this conversation in
Ideas
Replies: 1 comment 1 reply
|
Good catch! You've identified the issue and come up with a good solution. This looks like a solid approach to me! |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Shield's tests live under the
Tests\namespace. Some framework classes are marked@internal, and PHPStan only allows use of an internal class from inside its root namespace. The root for the framework isCodeIgniter, so tests underTests\are flagged for legitimate test hooks.Impact today
service('superglobals')is the only way to set cookies and server values in tests on framework 4.4 and later. The framework snapshots superglobals, so writing$_COOKIEdirectly does not work. The 8 calls toSuperglobals::setCookie(),setServer()andunsetServer()inSessionAuthenticatorTest,ActionsTest,LoginTestandMagicLinkTestare reported asmethod.internalClassand sit inphpstan-baseline.php.single_service()does not help, because PHPStan flags the namespace of the caller and not the way the object was obtained.Verification
I moved one test class to
CodeIgniter\Shield\Tests\…, removed@internalfrom the two abstract support classes (DatabaseTestCaseandTestCase) and re-ran PHPStan. TheSuperglobalserrors disappeared for that file.Proposal
Tests\…toCodeIgniter\Shield\Tests\….Tests\Support\, as the framework does, and drop@internalfromDatabaseTestCaseandTestCase.Tests\\entry inautoload-devand theAbstractFilterTestCasereference inpyrameter.php.This mirrors how the framework names its own tests and removes the 8 baseline entries without an ignore rule.
All reactions