diff --git a/src/Command/BakeFixtureFactoryCommand.php b/src/Command/BakeFixtureFactoryCommand.php index f61d36b..8f0ce26 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, '\\')) { @@ -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.' ) 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']); + } }