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
5 changes: 5 additions & 0 deletions src/Shell/Task/ModelTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,11 @@ public function all()
*/
public function getTableObject($className, $table)
{
$plugin = $this->param('plugin');
if (!empty($plugin)) {
$className = $plugin . '.' . $className;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any way we could get a test for this?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you tell me how? All I know is that testing console stuff is pain in the ass. :(

Copy link
Copy Markdown
Member

@dereuromark dereuromark Jan 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could unit test the getTableObject() here. Mock the rest away.

}

if (TableRegistry::exists($className)) {
return TableRegistry::get($className);
}
Expand Down
4 changes: 4 additions & 0 deletions tests/TestCase/Shell/Task/ModelTaskTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ public function testGetTableObject()
$this->assertInstanceOf('Cake\ORM\Table', $result);
$this->assertEquals('bake_articles', $result->table());
$this->assertEquals('Article', $result->alias());

$this->Task->params['plugin'] = 'BakeTest';
$result = $this->Task->getTableObject('Authors', 'bake_articles');
$this->assertInstanceOf('BakeTest\Model\Table\AuthorsTable', $result);
}

/**
Expand Down