diff --git a/tests/Unit/Console/Command/GenerateFiltersTest.php b/tests/Unit/Console/Command/GenerateFiltersTest.php new file mode 100644 index 0000000..cf3755b --- /dev/null +++ b/tests/Unit/Console/Command/GenerateFiltersTest.php @@ -0,0 +1,51 @@ +commandTester = new CommandTester(new GenerateCommand()); + $this->fs = new Filesystem(); + } + + protected function tearDown() + { + // Ensure that files generated during tests are removed to prevent + // failures on future runs. + $this->fs->remove([self::OUTPUT_FILENAME]); + } + + /** @test */ + public function it_converts_filters_from_php_to_xml() + { + $this->commandTester->execute([ + '--input-file' => self::INPUT_FILENAME, + '--output-file' => self::OUTPUT_FILENAME, + ]); + + $this->assertTrue($this->fs->exists(self::OUTPUT_FILENAME)); + + $expected = file_get_contents(__DIR__ . '/../../../fixtures/simple/output.xml'); + $result = file_get_contents(self::OUTPUT_FILENAME); + + $this->assertEquals(trim($expected), $result); + } +} diff --git a/tests/fixtures/simple/input.php b/tests/fixtures/simple/input.php new file mode 100644 index 0000000..5a8d77e --- /dev/null +++ b/tests/fixtures/simple/input.php @@ -0,0 +1,9 @@ +from('example.com') + ->labelAndArchive('Test'), +];