Skip to content

Commit

Permalink
[ci] minor refactor to allow for more regex tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jrushlow committed Mar 28, 2024
1 parent fd6b34a commit c8589b1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions tests/RegexTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,27 @@
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\MakerBundle\Test\MakerTestEnvironment;

/**
* Common class for testing regex's used in MakerBundle.
*
* Create a new test method and dataProvider to test regex
* expressions introduced in MakerBundle
*
* @author Jesse Rushlow <jr@rushlow.dev>
*/
class RegexTest extends TestCase
{
/** @dataProvider regexDataProvider */
public function testRegex(string $data, array $expectedResult): void
/** @dataProvider generatedFilesRegexDataProvider */
public function testMakerTestEnvironmentGeneratedFilesRegex(string $subjectData, array $expectedResult): void
{
$result = [];

preg_match_all(MakerTestEnvironment::GENERATED_FILES_REGEX, $data, $result, \PREG_PATTERN_ORDER);
preg_match_all(MakerTestEnvironment::GENERATED_FILES_REGEX, $subjectData, $result, \PREG_PATTERN_ORDER);

self::assertSame($expectedResult, $result[1]);
}

public function regexDataProvider(): \Generator
private function generatedFilesRegexDataProvider(): \Generator
{
yield 'Created Prefix' => ['created: test/something.php', ['test/something.php']];
yield 'Updated Prefix' => ['updated: test/something.php', ['test/something.php']];
Expand Down

0 comments on commit c8589b1

Please sign in to comment.