Skip to content

Commit

Permalink
Add a test for load model being plugin-prefixed
Browse files Browse the repository at this point in the history
  • Loading branch information
AD7six committed Feb 10, 2015
1 parent 8a6e2e1 commit 91e8016
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/TestCase/Datasource/ModelAwareTraitTest.php
Expand Up @@ -70,6 +70,29 @@ public function testLoadModel()
$this->assertInstanceOf('Cake\ORM\Table', $stub->Comments);
}

/**
* test loadModel() with plugin prefixed models
*
* Load model should not be called with Foo.Model Bar.Model Model
* But if it is, the first call wins.
*
* @return void
*/
public function testLoadModelPlugin()
{
$stub = new Stub();
$stub->setProps('Articles');
$stub->modelFactory('Table', ['\Cake\ORM\TableRegistry', 'get']);

$result = $stub->loadModel('TestPlugin.Comments');
$this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $result);
$this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $stub->Comments);

$result = $stub->loadModel('Comments');
$this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $result);
$this->assertInstanceOf('TestPlugin\Model\Table\CommentsTable', $stub->Comments);
}

/**
* test alternate model factories.
*
Expand Down

0 comments on commit 91e8016

Please sign in to comment.