Skip to content

Commit

Permalink
rename option to "skip-relation-check"
Browse files Browse the repository at this point in the history
  • Loading branch information
passchn committed Mar 14, 2023
1 parent f9d0682 commit b285ca9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/Command/ModelCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ public function findBelongsTo(Table $model, array $associations, ?Arguments $arg
get_class($associationTable) === Table::class &&
!in_array(Inflector::tableize($tmpModelName), $tables, true)
) {
$allowAliasRelations = $args && $args->getOption('allow-alias-relations');
$allowAliasRelations = $args && $args->getOption('skip-relation-check');
$found = $this->findTableReferencedBy($schema, $fieldName);
if ($found) {
$tmpModelName = Inflector::camelize($found);
Expand Down Expand Up @@ -1322,9 +1322,10 @@ public function buildOptionParser(ConsoleOptionParser $parser): ConsoleOptionPar
])->addOption('no-fixture', [
'boolean' => true,
'help' => 'Do not generate a test fixture skeleton.',
])->addOption('allow-alias-relations', [
])->addOption('skip-relation-check', [
'boolean' => true,
'help' => 'Skip checks for existing tables of has one relations, e.g. for an example_id field.',
'help' => 'Generate relations for all "example_id" fields'
. ' without checking the database if a table "examples" exists.',
])->setEpilog(
'Omitting all arguments and options will list the table names you can generate models for.'
);
Expand Down
4 changes: 2 additions & 2 deletions tests/TestCase/Command/ModelCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ public function testGetAssociationsAddAssociationIfTableExist()

/**
* Test that association generation adds `Anythings` association for `anything_id` field
* when using `--allow-alias-relations` option, even if no db table exists
* when using `--skip-relation-check` option, even if no db table exists
*
* @return void
*/
Expand All @@ -504,7 +504,7 @@ public function testGetAssociationsAddAssociationIfNoTableExistButAliasIsAllowed
$command = new ModelCommand();
$command->connection = 'test';

$args = new Arguments([], ['allow-alias-relations' => true], []);
$args = new Arguments([], ['skip-relation-check' => true], []);
$io = $this->createMock(ConsoleIo::class);
$result = $command->getAssociations($items, $args, $io);
$expected = [
Expand Down

0 comments on commit b285ca9

Please sign in to comment.