Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/Command/TestCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,11 @@ protected function _processController(Controller $subject): void
// No fixtures needed or possible
return;
}

$models = [$model->getAlias()];
foreach ($models as $model) {
[, $model] = pluginSplit($model);
$this->_processModel($subject->{$model});
if (!$model instanceof Table) {
return;
}

$this->_processModel($model);
}

/**
Expand Down
18 changes: 18 additions & 0 deletions tests/TestCase/Command/TestCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,24 @@ public function testFixtureGenerationFromController()
$this->assertEquals($expected, $result);
}

/**
* The alias of the default table does not have to match the controller's table name.
*
* @return void
*/
public function testFixtureGenerationFromControllerWithCustomAlias()
{
$this->getTableLocator()->get('Posts')->setAlias('RenamedPosts');

$subject = new PostsController(new Request(), new Response());
$command = new TestCommand();
$result = $command->generateFixtureList($subject);
$expected = [
'app.RenamedPosts',
];
$this->assertEquals($expected, $result);
}

/**
* Dataprovider for class name generation.
*
Expand Down
Loading