Skip to content

Commit

Permalink
DX: fix checking test class extends PhpCsFixer\Tests\TestCase (PHP-…
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos authored and danog committed Feb 2, 2024
1 parent 493ed21 commit 0579e57
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion tests/AutoReview/ComposerFileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

namespace PhpCsFixer\Tests\AutoReview;

use PHPUnit\Framework\TestCase;
use PhpCsFixer\Tests\TestCase;

/**
* @internal
Expand Down
7 changes: 2 additions & 5 deletions tests/AutoReview/DocumentationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,14 @@
use PhpCsFixer\Fixer\FixerInterface;
use PhpCsFixer\FixerFactory;
use PhpCsFixer\RuleSet\RuleSets;
use PHPUnit\Framework\TestCase;
use PhpCsFixer\Tests\TestCase;
use Symfony\Bridge\PhpUnit\ExpectDeprecationTrait;
use Symfony\Component\Finder\Finder;

/**
* @internal
*
* @covers \PhpCsFixer\Documentation\DocumentationLocator
* @covers \PhpCsFixer\Documentation\FixerDocumentGenerator
* @covers \PhpCsFixer\Documentation\RstUtils
* @covers \PhpCsFixer\Documentation\RuleSetDocumentationGenerator
* @coversNothing
*
* @group legacy
* @group auto-review
Expand Down
13 changes: 9 additions & 4 deletions tests/AutoReview/ProjectCodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ public function testThatSrcClassHaveTestClass(string $className): void
}

self::assertTrue(class_exists($testClassName), sprintf('Expected test class "%s" for "%s" not found.', $testClassName, $className));
self::assertTrue(is_subclass_of($testClassName, TestCase::class), sprintf('Expected test class "%s" to be a subclass of "\PhpCsFixer\Tests\TestCase".', $testClassName));
}

/**
Expand Down Expand Up @@ -199,6 +198,14 @@ public function testThatSrcClassesNotExposeProperties(string $className): void
);
}

/**
* @dataProvider provideTestClassCases
*/
public function testThatTestClassExtendsPhpCsFixerTestCaseClass(string $className): void
{
self::assertTrue(is_subclass_of($className, TestCase::class), sprintf('Expected test class "%s" to be a subclass of "%s".', $className, TestCase::class));
}

/**
* @dataProvider provideTestClassCases
*/
Expand Down Expand Up @@ -848,7 +855,7 @@ private static function getTestClasses(): array

$finder = Finder::create()
->files()
->name('*.php')
->name('*Test.php')
->in(__DIR__.'/..')
->exclude([
'Fixtures',
Expand All @@ -865,8 +872,6 @@ private static function getTestClasses(): array
iterator_to_array($finder, false)
);

$classes = array_filter($classes, static fn (string $class): bool => is_subclass_of($class, TestCase::class));

sort($classes);

return $classes;
Expand Down

0 comments on commit 0579e57

Please sign in to comment.