From 28c8f56b49ea5c1ceb545fab095d97913f0c1791 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 10 Oct 2023 07:19:42 +0200 Subject: [PATCH 1/3] fix warning --- src/Command/BakeFixtureFactoryCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Command/BakeFixtureFactoryCommand.php b/src/Command/BakeFixtureFactoryCommand.php index f61d36b..9902468 100644 --- a/src/Command/BakeFixtureFactoryCommand.php +++ b/src/Command/BakeFixtureFactoryCommand.php @@ -324,7 +324,7 @@ public function templateData(Arguments $arg): array $data['useStatements'] = array_unique(array_values(Hash::flatten($useStatements))); } - if ($data['useStatements']) { + if (!empty($data['useStatements'])) { foreach ($data['useStatements'] as $index => $useStatement) { $nameSpaceCheck = str_replace($data['namespace'] . '\\', '', $useStatement); if (!str_contains($nameSpaceCheck, '\\')) { From e4f167360868bfaf7e162c03d16c074d164a1533 Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 10 Oct 2023 07:37:31 +0200 Subject: [PATCH 2/3] fix common options missing --- src/Command/BakeFixtureFactoryCommand.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Command/BakeFixtureFactoryCommand.php b/src/Command/BakeFixtureFactoryCommand.php index 9902468..8f0ce26 100644 --- a/src/Command/BakeFixtureFactoryCommand.php +++ b/src/Command/BakeFixtureFactoryCommand.php @@ -420,6 +420,8 @@ public function getOptionParser(): ConsoleOptionParser $name = ($this->plugin ? $this->plugin . '.' : '') . $this->name; $parser = new ConsoleOptionParser($name); + $parser = $this->_setCommonOptions($parser); + $parser->setDescription( 'Fixture factory generator.' ) From 968af8b74f2bcb3264e87921ff1ce8d19192ee1a Mon Sep 17 00:00:00 2001 From: Kevin Pfeifer Date: Tue, 10 Oct 2023 07:50:06 +0200 Subject: [PATCH 3/3] add test for error --- tests/TestCase/Command/BakeFixtureFactoryCommandTest.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/TestCase/Command/BakeFixtureFactoryCommandTest.php b/tests/TestCase/Command/BakeFixtureFactoryCommandTest.php index 09a900e..739956a 100644 --- a/tests/TestCase/Command/BakeFixtureFactoryCommandTest.php +++ b/tests/TestCase/Command/BakeFixtureFactoryCommandTest.php @@ -343,4 +343,10 @@ public function testThisTableShouldBeBaked(string $model, $plugin, bool $expecte $this->assertSame($expected, $this->FactoryCommand->thisTableShouldBeBaked($model, $this->io)); } + + public function testCommandHasCommonOptions() + { + $options = $this->FactoryCommand->getOptionParser()->toArray(); + $this->assertArrayHasKey('connection', $options['options']); + } }