-
-
Notifications
You must be signed in to change notification settings - Fork 401
/
RegexTest.php
61 lines (54 loc) · 2.18 KB
/
RegexTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?php
/*
* This file is part of the Symfony MakerBundle package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\MakerBundle\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Bundle\MakerBundle\Test\MakerTestEnvironment;
class RegexTest extends TestCase
{
/** @dataProvider regexDataProvider */
public function testRegex(string $data, array $expectedResult): void
{
$result = [];
preg_match_all(MakerTestEnvironment::GENERATED_FILES_REGEX, $data, $result, \PREG_PATTERN_ORDER);
self::assertSame($expectedResult, $result[1]);
}
public function regexDataProvider(): \Generator
{
yield 'Created Prefix' => ['created: test/something.php', ['test/something.php']];
yield 'Updated Prefix' => ['updated: test/something.php', ['test/something.php']];
yield 'Twig file' => ['created: test/something.html.twig', ['test/something.html.twig']];
yield 'Config file (no dir)' => ['updated: service.yaml', ['service.yaml']];
yield 'Line Char + 2 dir' => ['\n success\ncreated: test/somewhere/else.php\n', ['test/somewhere/else.php']];
yield 'Multiline' => [<<< 'EOT'
Congrats!\n
Created: some/file.php\n
Updated: another/config.yaml\n
\n
EOT,
['some/file.php', 'another/config.yaml'],
];
yield 'Linux CI Results' => [<<< 'EOT'
Bundled PHP-CS-Fixer & Bundled PHP-CS-Fixer Configuration\n
\n
created: \e]8;;file:///home/runner/work/maker-bundle/maker-bundle/tests/tmp/cache/maker_app_40cd750bba9870f18aada2478b24840a_6.4.x-dev/tests/FooBarTest.php#L1\e\tests/FooBarTest.php\e]8;;\e\\n
\n
EOT,
['tests/FooBarTest.php'],
];
yield 'Windows CI Results' => [<<< 'EOT'
Bundled PHP-CS-Fixer & Bundled PHP-CS-Fixer Configuration\r\n
\r\n
created: tests/FooBarTest.php\r\n
\r\n
EOT,
['tests/FooBarTest.php'],
];
}
}