Skip to content

Commit

Permalink
refactor: Restructure test fixtures (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan authored Nov 17, 2023
1 parent dd65314 commit 0acb40e
Show file tree
Hide file tree
Showing 25 changed files with 21 additions and 23 deletions.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@
}
},
"autoload-dev": {
"psr-4": {
"CodeIgniter\\PHPStan\\Tests\\": "tests/"
}
"classmap": [
"tests/"
]
},
"config": {
"allow-plugins": {
Expand Down
4 changes: 1 addition & 3 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ parameters:
analyseAndScan:
- src/ComposerJsonRewriter.php
- src/ComposerScripts.php
- tests/Fixtures
- tests/*/data/*
tmpDir: build/phpstan
bootstrapFiles:
- vendor/codeigniter4/framework/system/Test/bootstrap.php
scanDirectories:
- vendor/codeigniter4/framework/system/Helpers
codeigniter:
additionalModelNamespaces:
- CodeIgniter\PHPStan\Tests\Fixtures\Type
Expand Down
2 changes: 1 addition & 1 deletion tests/Rules/Classes/CacheHandlerInstantiationRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ protected function getRule(): Rule

public function testRule(): void
{
$this->analyse([__DIR__ . '/../../Fixtures/Rules/Classes/cache-handler.php'], [
$this->analyse([__DIR__ . '/data/cache-handler.php'], [
[
'Calling new FileHandler() directly is incomplete to get the cache instance.',
19,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ protected function getRule(): Rule

public function testRule(): void
{
$this->analyse([__DIR__ . '/../../Fixtures/Rules/Classes/framework-exception.php'], [
$this->analyse([__DIR__ . '/data/framework-exception.php'], [
[
'Instantiating FrameworkException using new is not allowed. Use one of its named constructors instead.',
17,
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ protected function getRule(): Rule
public function testRule(): void
{
$this->analyse([
__DIR__ . '/../../Fixtures/Type/config.php',
__DIR__ . '/../../Fixtures/Type/model.php',
__DIR__ . '/../../Type/data/config.php',
__DIR__ . '/../../Type/data/model.php',
], [
[
'Parameter #1 $name of function config expects a valid class string, \'bar\' given.',
Expand Down Expand Up @@ -107,6 +107,6 @@ public function testRule(): void
public function testAllowNonModelClassesOnModelCall(): void
{
$this->checkArgumentTypeOfModel = false;
$this->analyse([__DIR__ . '/../../Fixtures/Rules/Functions/bug-8.php'], []);
$this->analyse([__DIR__ . '/data/bug-8.php'], []);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ protected function getRule(): Rule
public function testRule(): void
{
$this->analyse([
__DIR__ . '/../../Fixtures/Type/config.php',
__DIR__ . '/../../Fixtures/Type/factories-in-tests.php',
__DIR__ . '/../../Fixtures/Type/model.php',
__DIR__ . '/../../Type/data/config.php',
__DIR__ . '/../../Type/data/factories-in-tests.php',
__DIR__ . '/../../Type/data/model.php',
], [
[
'Call to function config with CodeIgniter\Shield\Config\AuthJWT::class is discouraged.',
Expand All @@ -65,6 +65,6 @@ public function testRule(): void

public function testOnAppNamespaceWithNonAppCall(): void
{
$this->analyse([__DIR__ . '/../../Fixtures/Rules/Functions/bug-9.php'], []);
$this->analyse([__DIR__ . '/data/bug-9.php'], []);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ protected function getRule(): Rule

public function testRule(): void
{
$this->analyse([__DIR__ . '/../../Fixtures/Type/services.php'], [
$this->analyse([__DIR__ . '/../../Type/data/services.php'], [
[
'The method \'createRequest\' is reserved for service location internals and cannot be used as a service method.',
51,
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/Rules/Superglobals/SuperglobalAccessRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function getRule(): Rule

public function testRule(): void
{
$this->analyse([__DIR__ . '/../../Fixtures/Rules/Superglobals/superglobal-access-cases.php'], [
$this->analyse([__DIR__ . '/data/superglobal-access-cases.php'], [
[
'Accessing offset \'foo\' directly on $_SERVER is discouraged.',
21,
Expand Down
2 changes: 1 addition & 1 deletion tests/Rules/Superglobals/SuperglobalAssignRuleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ protected function getRule(): Rule

public function testRule(): void
{
$this->analyse([__DIR__ . '/../../Fixtures/Rules/Superglobals/superglobal-assign-cases.php'], [
$this->analyse([__DIR__ . '/data/superglobal-assign-cases.php'], [
[
'Assigning \'https://localhost\' directly on offset \'HTTP_HOST\' of $_SERVER is discouraged.',
18,
Expand Down
8 changes: 4 additions & 4 deletions tests/Type/DynamicFunctionReturnTypeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ public function testFileAsserts(string $assertType, string $file, mixed ...$args
*/
public static function provideFileAssertsCases(): iterable
{
yield from self::gatherAssertTypes(__DIR__ . '/../Fixtures/Type/config.php');
yield from self::gatherAssertTypes(__DIR__ . '/data/config.php');

yield from self::gatherAssertTypes(__DIR__ . '/../Fixtures/Type/fake.php');
yield from self::gatherAssertTypes(__DIR__ . '/data/fake.php');

yield from self::gatherAssertTypes(__DIR__ . '/../Fixtures/Type/model.php');
yield from self::gatherAssertTypes(__DIR__ . '/data/model.php');

yield from self::gatherAssertTypes(__DIR__ . '/../Fixtures/Type/services.php');
yield from self::gatherAssertTypes(__DIR__ . '/data/services.php');
}
}
2 changes: 1 addition & 1 deletion tests/Type/DynamicMethodReturnTypeExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ public function testFileAsserts(string $assertType, string $file, mixed ...$args
*/
public static function provideFileAssertsCases(): iterable
{
yield from self::gatherAssertTypes(__DIR__ . '/../Fixtures/Type/model-find.php');
yield from self::gatherAssertTypes(__DIR__ . '/data/model-find.php');
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 0acb40e

Please sign in to comment.