|
21 | 21 | use Symfony\Component\Console\Tester\CommandTester; |
22 | 22 | use Symfony\Component\Filesystem\Filesystem; |
23 | 23 |
|
| 24 | +use function file_get_contents; |
| 25 | +use function preg_replace; |
| 26 | + |
24 | 27 | class MakeFilterTest extends KernelTestCase |
25 | 28 | { |
26 | 29 | protected function setup(): void |
@@ -61,6 +64,25 @@ public function testMakeFilter(string $type, string $name, bool $isInteractive): |
61 | 64 | $this->assertStringContainsString(' Next: Open your filter class and start customizing it.', $display); |
62 | 65 | } |
63 | 66 |
|
| 67 | + public function testMakeFilterWithCustomNamespace(): void |
| 68 | + { |
| 69 | + $inputs = ['name' => 'CustomOrmFilter', 'type' => 'orm', '--namespace-prefix' => 'Api\\Filter\\']; |
| 70 | + $newFilterFile = self::tempFile('src/Api/Filter/CustomOrmFilter.php'); |
| 71 | + |
| 72 | + $tester = new CommandTester((new Application(self::bootKernel()))->find('make:filter')); |
| 73 | + $tester->execute($inputs); |
| 74 | + |
| 75 | + $this->assertFileExists($newFilterFile); |
| 76 | + |
| 77 | + // Unify line endings |
| 78 | + $expected = preg_replace('~\R~u', "\r\n", file_get_contents(__DIR__.'/../../Fixtures/Symfony/Maker/NamespacedCustomOrmFilter.fixture')); |
| 79 | + $result = preg_replace('~\R~u', "\r\n", file_get_contents($newFilterFile)); |
| 80 | + $this->assertStringContainsString($expected, $result); |
| 81 | + |
| 82 | + $display = $tester->getDisplay(); |
| 83 | + $this->assertStringContainsString('Success!', $display); |
| 84 | + } |
| 85 | + |
64 | 86 | public static function filterProvider(): \Generator |
65 | 87 | { |
66 | 88 | yield 'Generate ORM filter' => ['orm', 'CustomOrmFilter', true]; |
|
0 commit comments