diff --git a/.gitignore b/.gitignore index 54fca72..d0300e9 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ composer.lock filters.php *.xml +!/tests/fixtures/*/*.xml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..eb49fde --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,8 @@ +# CHANGELOG + +## 2.2.0 + +Released 2019-04-19 + +* [#19](https://github.com/opdavies/gmail-filter-builder/issues/19): Update test method names +* [#21](https://github.com/opdavies/gmail-filter-builder/issues/21): Minify the generated XML by default diff --git a/bin/generate-filters.php b/bin/generate-filters.php old mode 100644 new mode 100755 index 985eac1..d3b85e8 --- a/bin/generate-filters.php +++ b/bin/generate-filters.php @@ -13,6 +13,6 @@ if (file_exists(__DIR__.'/../vendor/autoload.php')) { $container = new Container(); /** @var Application $application */ -$application = $container->get('app.cli'); +$application = $container->get(Application::class); $application->setDefaultCommand(GenerateCommand::NAME); $application->run(); diff --git a/composer.json b/composer.json index ef300a0..01d2f31 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "authors": [ { "name": "Oliver Davies", - "email": "opdavies@gmail.com" + "email": "oliver@oliverdavies.uk" } ], "require": { @@ -44,7 +44,7 @@ "sort-packages": true }, "scripts": { - "style": "php-cs-fixer fix", + "lint": "php-cs-fixer fix", "test": "phpunit" } } diff --git a/config/services.yml b/config/services.yml deleted file mode 100644 index 75f8706..0000000 --- a/config/services.yml +++ /dev/null @@ -1,13 +0,0 @@ -services: - app.cli: - class: Symfony\Component\Console\Application - autowire: true - - app.builder: - class: Opdavies\GmailFilterBuilder\Service\Builder - - app.generate.command: - class: Opdavies\GmailFilterBuilder\Console\Command\GenerateCommand - autowire: true - tags: - - { name: ConsoleCommand } diff --git a/services.yml b/services.yml new file mode 100644 index 0000000..b8352c3 --- /dev/null +++ b/services.yml @@ -0,0 +1,8 @@ +services: + Symfony\Component\Console\Application: + autowire: true + + Opdavies\GmailFilterBuilder\Console\Command\GenerateCommand: + autowire: true + tags: + - { name: ConsoleCommand } diff --git a/src/Console/Command/GenerateCommand.php b/src/Console/Command/GenerateCommand.php index a81fe46..40af0e6 100644 --- a/src/Console/Command/GenerateCommand.php +++ b/src/Console/Command/GenerateCommand.php @@ -2,13 +2,14 @@ namespace Opdavies\GmailFilterBuilder\Console\Command; -use Opdavies\GmailFilterBuilder\Builder; +use Opdavies\GmailFilterBuilder\Service\Builder; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Style\SymfonyStyle; use Symfony\Component\Filesystem\Exception\IOException; +use Symfony\Component\Filesystem\Filesystem; class GenerateCommand extends Command { @@ -22,8 +23,9 @@ class GenerateCommand extends Command $this ->setName(self::NAME) ->setDefinition([ - new InputOption('input-file', null, InputOption::VALUE_OPTIONAL, 'The name of the PHP file containing your filters.', 'filters.php'), - new InputOption('output-file', null, InputOption::VALUE_OPTIONAL, 'The name of the XML file to generate.', 'filters.xml') + new InputOption('input-file', 'i', InputOption::VALUE_OPTIONAL, 'The name of the PHP file containing your filters.', 'filters.php'), + new InputOption('output-file', 'o', InputOption::VALUE_OPTIONAL, 'The name of the XML file to generate.', 'filters.xml'), + new InputOption('expanded', 'e', InputOption::VALUE_NONE, 'Whether to generate expanded XML.') ]) ->setDescription('Generates XML for Gmail filters.') ; @@ -34,26 +36,31 @@ class GenerateCommand extends Command */ protected function execute(InputInterface $input, OutputInterface $output) { - $inputFile = $input->getOption('input-file'); - $outputFile = $input->getOption('output-file'); - - if (file_exists(__DIR__.'/'.$inputFile)) { - $filters = require_once __DIR__.'/'.$inputFile; - } elseif (file_exists(__DIR__.'/../../../../../../'.$inputFile)) { - # Installed as a dependency within "vendor". - $filters = require_once __DIR__.'/../../../../../../'.$inputFile; - } else { - throw new \Exception('No filters.php file found.'); - } - $io = new SymfonyStyle($input, $output); try { - new Builder($filters, $outputFile); + // TODO: Inject this. + new Builder($this->filters($input), $outputFile = $this->outputFile($input), true, $input->getOption('expanded')); $io->success(sprintf('%s file generated.', $outputFile)); } catch (IOException $e) { $io->error($e->getMessage()); } } + + private function outputFile(InputInterface $input): string + { + return $input->getOption('output-file') ?? getcwd() . '/filters.xml'; + } + + private function filters(InputInterface $input): array + { + $fs = new Filesystem(); + + if (!$fs->exists($inputFile = $input->getOption('input-file') ?? getcwd() . '/filters.php')) { + throw new \RuntimeException('No input file found.'); + } + + return require $inputFile; + } } diff --git a/src/Container/CommandCompilerClass.php b/src/Container/CommandCompilerClass.php index 64f441a..5e447ea 100644 --- a/src/Container/CommandCompilerClass.php +++ b/src/Container/CommandCompilerClass.php @@ -2,6 +2,7 @@ namespace Opdavies\GmailFilterBuilder\Container; +use Symfony\Component\Console\Application; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; @@ -13,7 +14,7 @@ class CommandCompilerClass implements CompilerPassInterface */ public function process(ContainerBuilder $container) { - $definition = $container->findDefinition('app.cli'); + $definition = $container->findDefinition(Application::class); $taggedServices = $container->findTaggedServiceIds('ConsoleCommand'); foreach ($taggedServices as $id => $tags) { diff --git a/src/Container/Container.php b/src/Container/Container.php index 905a9e4..b846d9f 100644 --- a/src/Container/Container.php +++ b/src/Container/Container.php @@ -11,7 +11,7 @@ class Container public function __construct() { $this->containerBuilder = new ContainerBuilder(); - $loader = new YamlFileLoader($this->containerBuilder, new FileLocator(__DIR__.'/../../config')); + $loader = new YamlFileLoader($this->containerBuilder, new FileLocator(__DIR__.'/../../')); $loader->load('services.yml'); $this->containerBuilder->addCompilerPass(new CommandCompilerClass()); $this->containerBuilder->compile(); diff --git a/src/Model/Filter.php b/src/Model/Filter.php index 2d13862..e5af3f6 100644 --- a/src/Model/Filter.php +++ b/src/Model/Filter.php @@ -6,6 +6,9 @@ use Tightenco\Collect\Support\Collection; class Filter { + /** @var string */ + const SEPARATOR = '|'; + /** * @var array */ @@ -22,7 +25,7 @@ class Filter /** * @return static */ - public static function create() + public static function create(): self { return new static(); } @@ -32,7 +35,7 @@ class Filter * * @return $this */ - public function has($value) + public function has(string $value): self { $this->properties['hasTheWord'] = $value; @@ -48,7 +51,7 @@ class Filter * * @return $this */ - public function hasNot($value) + public function hasNot(string $value): self { $this->properties['doesNotHaveTheWord'] = $value; @@ -60,7 +63,7 @@ class Filter * * @return $this */ - public function from($values) + public function from($values): self { if (!empty($values)) { $this->properties['from'] = collect($values)->map(function ($value) { @@ -76,7 +79,7 @@ class Filter * * @return $this */ - public function to($values) + public function to($values): self { if (!empty($values)) { $this->properties['to'] = collect($values)->map(function ($value) { @@ -92,7 +95,7 @@ class Filter * * @return $this */ - public function subject($values) + public function subject($values): self { $this->properties['subject'] = collect($values)->map(function ($value) { return json_encode($value); @@ -104,7 +107,7 @@ class Filter /** * @return $this */ - public function hasAttachment() + public function hasAttachment(): self { $this->properties['hasAttachment'] = 'true'; @@ -114,12 +117,13 @@ class Filter /** * Filter a message if it was sent from a mailing list. * - * @param $value The mailing list address + * @param string|array $value The mailing list address * * @return $this */ - public function fromList($value) + public function fromList($value): self { + $value = collect($value)->implode(self::SEPARATOR); $this->has("list:{$value}"); return $this; @@ -128,7 +132,7 @@ class Filter /** * @return $this */ - public function excludeChats() + public function excludeChats(): self { $this->properties['excludeChats'] = 'true'; @@ -140,7 +144,7 @@ class Filter * * @return $this */ - public function label($label) + public function label(string $label): self { $this->properties['label'] = $label; @@ -150,7 +154,7 @@ class Filter /** * @return $this */ - public function archive() + public function archive(): self { $this->properties['shouldArchive'] = 'true'; @@ -162,7 +166,7 @@ class Filter * * @return $this */ - public function labelAndArchive($label) + public function labelAndArchive(string $label): self { $this->label($label)->archive(); @@ -172,7 +176,7 @@ class Filter /** * @return $this */ - public function spam() + public function spam(): self { $this->properties['shouldSpam'] = 'true'; $this->properties['shouldNeverSpam'] = 'false'; @@ -183,7 +187,7 @@ class Filter /** * @return $this */ - public function neverSpam() + public function neverSpam(): self { $this->properties['shouldSpam'] = 'false'; $this->properties['shouldNeverSpam'] = 'true'; @@ -194,7 +198,7 @@ class Filter /** * @return $this */ - public function trash() + public function trash(): self { $this->properties['shouldTrash'] = 'true'; @@ -204,7 +208,7 @@ class Filter /** * @return $this */ - public function read() + public function read(): self { $this->properties['markAsRead'] = 'true'; @@ -214,7 +218,7 @@ class Filter /** * @return $this */ - public function star() + public function star(): self { $this->properties['shouldStar'] = 'true'; @@ -226,7 +230,7 @@ class Filter * * @return $this */ - public function forward($to) + public function forward(string $to): self { $this->properties['forwardTo'] = $to; @@ -236,7 +240,7 @@ class Filter /** * @return $this */ - public function important() + public function important(): self { $this->properties['shouldAlwaysMarkAsImportant'] = 'true'; @@ -246,7 +250,7 @@ class Filter /** * @return $this */ - public function notImportant() + public function notImportant(): self { $this->properties['shouldNeverMarkAsImportant'] = 'true'; @@ -258,7 +262,7 @@ class Filter * * @return $this */ - public function categorise($category) + public function categorise(string $category): self { $this->properties['smartLabelToApply'] = $category; @@ -271,7 +275,7 @@ class Filter * @return array * @deprecated toArray() */ - public function getProperties() + public function getProperties(): array { return $this->properties; } @@ -281,7 +285,7 @@ class Filter * * @return array */ - public function toArray() + public function toArray(): array { return $this->properties; } diff --git a/src/Service/Builder.php b/src/Service/Builder.php index 509fe37..0092b7b 100644 --- a/src/Service/Builder.php +++ b/src/Service/Builder.php @@ -29,17 +29,21 @@ class Builder */ private $xml; - public function __construct(array $filters, $outputFile = 'filters.xml', $writeFile = true) + /** @var bool */ + private $expanded; + + public function __construct(array $filters, $outputFile = 'filters.xml', $writeFile = true, $expanded = false) { $this->filesystem = new Filesystem(); $this->filters = $filters; $this->outputFile = $outputFile; $this->writeFile = $writeFile; + $this->expanded = $expanded; $this->build(); } - public function __toString() + public function __toString(): string { return $this->build(); } @@ -49,7 +53,7 @@ class Builder * * @return string */ - public function getXml() + public function getXml(): string { return $this->xml; } @@ -59,16 +63,16 @@ class Builder * * @return string */ - private function build() + private function build(): void { - $prefix = "" . PHP_EOL . ""; + $prefix = "" . $this->glue() . ""; $suffix = ''; $xml = collect($this->filters)->map(function ($items) { return $this->buildEntry($items); - })->implode(PHP_EOL); + })->implode($this->glue()); - $this->xml = collect([$prefix, $xml, $suffix])->implode(PHP_EOL); + $this->xml = collect([$prefix, $xml, $suffix])->implode($this->glue()); if ($this->writeFile) { $this->filesystem->dumpFile($this->outputFile, $this->xml); @@ -82,13 +86,15 @@ class Builder * * @return string */ - private function buildEntry(Filter $filter) + private function buildEntry(Filter $filter): string { - $entry = collect($filter->getProperties())->map(function ($value, $key) { - return $this->buildProperty($value, $key); - })->implode(PHP_EOL); + $entry = collect($filter->toArray()) + ->map(function ($value, $key): string { + return $this->buildProperty($value, $key); + }) + ->implode($this->glue()); - return collect(['', $entry, ''])->implode(PHP_EOL); + return collect(['', $entry, ''])->implode($this->glue()); } /** @@ -99,7 +105,7 @@ class Builder * * @return string */ - private function buildProperty($value, $key) + private function buildProperty($value, $key): string { if (collect(['from', 'to'])->contains($key)) { $value = $this->implode($value); @@ -114,7 +120,7 @@ class Builder /** * Implode values with the appropriate prefix, suffix and separator. */ - private function implode($value, $separator = '|') + private function implode($value, $separator = '|'): string { if (is_string($value)) { return $value; @@ -126,4 +132,9 @@ class Builder return sprintf('(%s)', collect($value)->implode($separator)); } + + private function glue(): ?string + { + return $this->expanded ? PHP_EOL : null; + } } diff --git a/src/Service/Partials.php b/src/Service/Partials.php index 70fe0cb..472c092 100644 --- a/src/Service/Partials.php +++ b/src/Service/Partials.php @@ -14,7 +14,7 @@ class Partials * * @return array The loaded filters. */ - public static function load($directoryName = 'filters') + public static function load($directoryName = 'filters'): array { $files = static::getFilePattern($directoryName); @@ -23,7 +23,7 @@ class Partials return include $filename; }) ->flatten(1) - ->all(); + ->toArray(); } /** @@ -36,7 +36,7 @@ class Partials * * @return string The full path. */ - protected static function getFilePattern($directoryName) + protected static function getFilePattern($directoryName): string { return getcwd() . DIRECTORY_SEPARATOR . $directoryName . DIRECTORY_SEPARATOR . '*.php'; } diff --git a/tests/Unit/Console/Command/GenerateFiltersTest.php b/tests/Unit/Console/Command/GenerateFiltersTest.php new file mode 100644 index 0000000..59bca9f --- /dev/null +++ b/tests/Unit/Console/Command/GenerateFiltersTest.php @@ -0,0 +1,68 @@ +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_minified_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); + } + + /** @test */ + public function it_converts_filters_from_php_to_expanded_xml() + { + $this->commandTester->execute([ + '--input-file' => self::INPUT_FILENAME, + '--output-file' => self::OUTPUT_FILENAME, + '--expanded' => true, + ]); + + $this->assertTrue($this->fs->exists(self::OUTPUT_FILENAME)); + + $expected = file_get_contents(__DIR__ . '/../../../fixtures/simple/output-expanded.xml'); + $result = file_get_contents(self::OUTPUT_FILENAME); + + $this->assertEquals(trim($expected), $result); + } +} diff --git a/tests/Unit/Model/FilterTest.php b/tests/Unit/Model/FilterTest.php index 44f8752..8b8adcd 100644 --- a/tests/Unit/Model/FilterTest.php +++ b/tests/Unit/Model/FilterTest.php @@ -26,9 +26,10 @@ class FilterTest extends TestCase } /** - * @covers ::has + * @test + * @covers::has */ - public function testHas() + public function can_filter_on_a_has_value() { $this->assertEquals( ['hasTheWord' => 'something'], @@ -37,9 +38,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::hasNot */ - public function testHasNot() + public function can_filter_on_a_has_not_value() { $this->assertEquals( ['doesNotHaveTheWord' => 'something'], @@ -48,9 +50,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::from */ - public function testFrom() + public function can_filter_based_on_the_sender() { // Ensure that we can set one from address. $this->assertEquals( @@ -66,20 +69,20 @@ class FilterTest extends TestCase } /** - * Test that no 'from' key exists if no values were entered. - * + * @test * @covers ::from */ - public function testNoFromPropertyExistsIfTheValueIsEmpty() + public function no_from_property_exists_if_the_value_is_empty() { $this->assertArrayNotHasKey('from', $this->filter->from('')->toArray()); $this->assertArrayNotHasKey('from', $this->filter->from([])->toArray()); } /** + * @test * @covers ::to */ - public function testTo() + public function can_filter_based_on_the_recipient() { $this->assertEquals( ['to' => ['foo@example.com']], @@ -92,31 +95,24 @@ class FilterTest extends TestCase ); } - /** - * Test that no 'to' key exists if values were entered. - */ - public function testNoToPropertyExistsIfTheValueIsEmpty() + /** @test */ + public function no_to_property_exists_if_the_value_is_empty() { $this->assertArrayNotHasKey('to', $this->filter->to('')->toArray()); $this->assertArrayNotHasKey('to', $this->filter->to([])->toArray()); } /** + * @test * @covers ::subject */ - public function testSubject() + public function can_filter_based_on_the_subject() { $this->assertEquals( ['subject' => '"Something"'], $this->filter->subject('Something')->toArray() ); - } - /** - * Test that multiple subject conditions can be added. - */ - public function testMultipleSubjectsCanBeAdded() - { $this->assertEquals( ['subject' => '"Test"|"Foo bar"'], $this->filter->subject(['Test', 'Foo bar'])->toArray() @@ -124,9 +120,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::hasAttachment */ - public function testHasAttachment() + public function can_filter_based_on_whether_there_is_an_attachment() { $this->assertEquals( ['hasAttachment' => 'true'], @@ -135,20 +132,27 @@ class FilterTest extends TestCase } /** + * @test * @covers ::fromList */ - public function testFromList() + public function can_filter_based_on_wether_it_was_sent_to_a_list() { $this->assertEquals( ['hasTheWord' => 'list:foobar'], $this->filter->fromList('foobar')->toArray() ); + + $this->assertEquals( + ['hasTheWord' => 'list:list-one.com|list-two.com'], + $this->filter->fromList(['list-one.com', 'list-two.com'])->toArray() + ); } /** + * @test * @covers ::excludeChats */ - public function testExcludeChats() + public function chats_can_be_excluded() { $this->assertEquals( ['excludeChats' => 'true'], @@ -157,9 +161,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::label */ - public function testLabel() + public function labels_can_be_added() { $this->assertEquals( ['label' => 'Foo'], @@ -168,9 +173,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::archive */ - public function testArchive() + public function messages_can_be_archived() { $this->assertEquals( ['shouldArchive' => 'true'], @@ -179,9 +185,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::labelAndArchive */ - public function testLabelAndArchive() + public function messages_can_be_labelled_and_archived() { $this->assertEquals( ['shouldArchive' => 'true', 'label' => 'Foo'], @@ -190,9 +197,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::spam */ - public function testSpam() + public function messages_can_be_marked_as_spam() { $this->assertEquals( [ @@ -204,9 +212,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::neverSpam */ - public function testNeverSpam() + public function messages_can_be_marked_as_not_spam() { $this->assertEquals( [ @@ -218,9 +227,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::trash */ - public function testTrash() + public function messages_can_be_deleted() { $this->assertEquals( ['shouldTrash' => 'true'], @@ -229,9 +239,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::read */ - public function testMarkAsRead() + public function messages_can_be_marked_as_read() { $this->assertEquals( ['markAsRead' => 'true'], @@ -240,9 +251,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::star */ - public function testStar() + public function messages_can_be_starred() { $this->assertEquals( ['shouldStar' => 'true'], @@ -251,9 +263,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::forward */ - public function testForwardTo() + public function messages_can_be_forwarded() { $this->assertEquals( ['forwardTo' => 'foo@example.com'], @@ -262,9 +275,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::important */ - public function testMarkImportant() + public function messages_can_be_marked_as_important() { $this->assertEquals( ['shouldAlwaysMarkAsImportant' => 'true'], @@ -273,9 +287,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::notImportant */ - public function testMarkNotImportant() + public function messages_can_be_marked_as_not_important() { $this->assertEquals( ['shouldNeverMarkAsImportant' => 'true'], @@ -284,9 +299,10 @@ class FilterTest extends TestCase } /** + * @test * @covers ::categorise */ - public function testCategorise() + public function messages_can_be_categorised() { $this->assertEquals( ['smartLabelToApply' => 'Foo'], @@ -294,7 +310,8 @@ class FilterTest extends TestCase ); } - public function testMethodsCanBeChained() + /** @test */ + public function methods_can_be_chained() { $this->assertEquals( [ diff --git a/tests/Unit/Service/BuilderTest.php b/tests/Unit/Service/BuilderTest.php index 4c40fc2..715299f 100644 --- a/tests/Unit/Service/BuilderTest.php +++ b/tests/Unit/Service/BuilderTest.php @@ -8,7 +8,8 @@ use PHPUnit\Framework\TestCase; class BuilderTest extends TestCase { - public function testBuild() + /** @test */ + public function it_can_build_filters() { $filterA = (new Filter()) ->from(['foo@example.com', 'test@example.com']) @@ -20,7 +21,7 @@ class BuilderTest extends TestCase ->star() ->important(); - $result = new Builder([$filterA, $filterB], '', false); + $result = new Builder([$filterA, $filterB], '', false, true); $expected = << diff --git a/tests/Unit/Service/PartialsTest.php b/tests/Unit/Service/PartialsTest.php index 802f1bf..47a1b3c 100644 --- a/tests/Unit/Service/PartialsTest.php +++ b/tests/Unit/Service/PartialsTest.php @@ -8,19 +8,17 @@ use PHPUnit\Framework\TestCase; class PartialsTest extends TestCase { - /** - * Test loading partials from multiple partial files. - */ - public function testLoadingFiltersFromPartials() + /** @test */ + public function filters_can_be_loaded_from_partials() { /** @var Filter[] $filters */ $filters = FakePartials::load('filters'); $this->assertCount(3, $filters); - $this->assertSame('foo@example.com', $filters[0]->getProperties()['from'][0]); - $this->assertSame('bar@example.com', $filters[1]->getProperties()['from'][0]); - $this->assertSame('baz@example.com', $filters[2]->getProperties()['from'][0]); + $this->assertSame('foo@example.com', $filters[0]->toArray()['from'][0]); + $this->assertSame('bar@example.com', $filters[1]->toArray()['from'][0]); + $this->assertSame('baz@example.com', $filters[2]->toArray()['from'][0]); } } @@ -29,7 +27,7 @@ class FakePartials extends Partials /** * {@inheritdoc} */ - protected static function getFilePattern($directoryName) + protected static function getFilePattern($directoryName): string { return __DIR__ . '/../../stubs/filters/*.php'; } 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'), +]; diff --git a/tests/fixtures/simple/output-expanded.xml b/tests/fixtures/simple/output-expanded.xml new file mode 100644 index 0000000..5ab840f --- /dev/null +++ b/tests/fixtures/simple/output-expanded.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/tests/fixtures/simple/output.xml b/tests/fixtures/simple/output.xml new file mode 100644 index 0000000..eebac51 --- /dev/null +++ b/tests/fixtures/simple/output.xml @@ -0,0 +1 @@ +