Skip to content

Commit

Permalink
Rename Model/Repository -> Model/Table.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Jan 17, 2014
1 parent d38888e commit 197ebd1
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 44 deletions.
4 changes: 2 additions & 2 deletions src/ORM/TableRegistry.php
Expand Up @@ -117,7 +117,7 @@ public static function config($alias = null, $options = null) {
*
* If $options does not contain `className` CakePHP will attempt to construct the
* class name based on the alias. For example 'Users' would result in
* `App\Model\Repository\UsersTable` being attempted. If this class does not exist,
* `App\Model\Table\UsersTable` being attempted. If this class does not exist,
* then the default `Cake\ORM\Table` class will be used. By setting the `className`
* option you can define the specific class to use. This className can
* use a short class reference.
Expand Down Expand Up @@ -151,7 +151,7 @@ public static function get($alias, $options = []) {

if (empty($options['className'])) {
$class = Inflector::camelize($alias);
$className = App::classname($class, 'Model/Repository', 'Table');
$className = App::classname($class, 'Model/Table', 'Table');
$options['className'] = $className ?: 'Cake\ORM\Table';
}

Expand Down
2 changes: 1 addition & 1 deletion src/TestSuite/TestCase.php
Expand Up @@ -595,7 +595,7 @@ protected function skipUnless($condition, $message = '') {
public function getMockForModel($alias, $methods = array(), $options = array()) {
if (empty($options['className'])) {
$class = Inflector::camelize($alias);
$className = App::classname($class, 'Model/Repository', 'Table');
$className = App::classname($class, 'Model/Table', 'Table');
if (!$className) {
throw new \Cake\ORM\Error\MissingTableClassException(array($alias));
}
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Console/ShellTest.php
Expand Up @@ -176,7 +176,7 @@ public function testInitialize() {

$this->assertTrue(isset($this->Shell->TestPluginComments));
$this->assertInstanceOf(
'TestPlugin\Model\Repository\TestPluginCommentsTable',
'TestPlugin\Model\Table\TestPluginCommentsTable',
$this->Shell->TestPluginComments
);
}
Expand All @@ -191,7 +191,7 @@ public function testLoadModel() {

$Shell = new MergeShell();
$this->assertInstanceOf(
'TestApp\Model\Repository\ArticlesTable',
'TestApp\Model\Table\ArticlesTable',
$Shell->Articles
);
$this->assertEquals('Articles', $Shell->modelClass);
Expand All @@ -200,7 +200,7 @@ public function testLoadModel() {
$this->Shell->loadModel('TestPlugin.TestPluginComments');
$this->assertTrue(isset($this->Shell->TestPluginComments));
$this->assertInstanceOf(
'TestPlugin\Model\Repository\TestPluginCommentsTable',
'TestPlugin\Model\Table\TestPluginCommentsTable',
$this->Shell->TestPluginComments
);
}
Expand Down
Expand Up @@ -710,7 +710,7 @@ public function testPaginateCustomFindCount() {
*/
protected function _getMockPosts($methods = []) {
return $this->getMock(
'TestApp\Model\Repository\PaginatorPostsTable',
'TestApp\Model\Table\PaginatorPostsTable',
$methods,
[['connection' => ConnectionManager::get('test'), 'alias' => 'PaginatorPosts']]
);
Expand Down
8 changes: 4 additions & 4 deletions tests/TestCase/Controller/ControllerTest.php
Expand Up @@ -234,15 +234,15 @@ public function tearDown() {
*
* @return void
*/
public function testRepositoryAutoload() {
public function testTableAutoload() {
Configure::write('App.namespace', 'TestApp');
$request = new Request('controller_posts/index');
$response = $this->getMock('Cake\Network\Response');
$Controller = new Controller($request, $response);
$Controller->modelClass = 'Articles';

$this->assertInstanceOf(
'TestApp\Model\Repository\ArticlesTable',
'TestApp\Model\Table\ArticlesTable',
$Controller->Articles
);
}
Expand All @@ -263,7 +263,7 @@ public function testLoadModel() {
$result = $Controller->loadModel('Articles');
$this->assertTrue($result);
$this->assertInstanceOf(
'TestApp\Model\Repository\ArticlesTable',
'TestApp\Model\Table\ArticlesTable',
$Controller->Articles
);
}
Expand All @@ -285,7 +285,7 @@ public function testLoadModelInPlugins() {
$result = $Controller->loadModel('TestPlugin.TestPluginComments');
$this->assertTrue($result);
$this->assertInstanceOf(
'TestPlugin\Model\Repository\TestPluginCommentsTable',
'TestPlugin\Model\Table\TestPluginCommentsTable',
$Controller->TestPluginComments
);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Core/AppTest.php
Expand Up @@ -173,7 +173,7 @@ public function testListObjects() {
$result = App::objects('View/Helper', null, false);
$this->assertContains('BananaHelper', $result);

$result = App::objects('Model/Repository', null, false);
$result = App::objects('Model/Table', null, false);
$this->assertContains('ArticlesTable', $result);

$result = App::objects('file');
Expand Down Expand Up @@ -214,7 +214,7 @@ public function testListObjectsIgnoreDotDirectories() {
public function testListObjectsInPlugin() {
Plugin::load(array('TestPlugin', 'TestPluginTwo'));

$result = App::objects('TestPlugin.Model/Repository');
$result = App::objects('TestPlugin.Model/Table');
$this->assertContains('TestPluginCommentsTable', $result);

$result = App::objects('TestPlugin.Model/Behavior');
Expand All @@ -230,7 +230,7 @@ public function testListObjectsInPlugin() {
$result = App::objects('TestPluginTwo.Model/Behavior');
$this->assertSame(array(), $result);

$result = App::objects('Model/Repository', null, false);
$result = App::objects('Model/Table', null, false);
$this->assertContains('PostsTable', $result);
$this->assertContains('ArticlesTable', $result);
}
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/ORM/TableRegistryTest.php
Expand Up @@ -159,22 +159,22 @@ public function testGetExistingWithConfigData() {
*/
public function testBuildConvention() {
$table = TableRegistry::get('articles');
$this->assertInstanceOf('\TestApp\Model\Repository\ArticlesTable', $table);
$this->assertInstanceOf('\TestApp\Model\Table\ArticlesTable', $table);
$table = TableRegistry::get('Articles');
$this->assertInstanceOf('\TestApp\Model\Repository\ArticlesTable', $table);
$this->assertInstanceOf('\TestApp\Model\Table\ArticlesTable', $table);

$table = TableRegistry::get('authors');
$this->assertInstanceOf('\TestApp\Model\Repository\AuthorsTable', $table);
$this->assertInstanceOf('\TestApp\Model\Table\AuthorsTable', $table);
$table = TableRegistry::get('Authors');
$this->assertInstanceOf('\TestApp\Model\Repository\AuthorsTable', $table);
$this->assertInstanceOf('\TestApp\Model\Table\AuthorsTable', $table);

$class = $this->getMockClass('\Cake\ORM\Table');
$class::staticExpects($this->once())
->method('defaultConnectionName')
->will($this->returnValue('test'));

if (!class_exists('MyPlugin\Model\Repository\SuperTestsTable')) {
class_alias($class, 'MyPlugin\Model\Repository\SuperTestsTable');
if (!class_exists('MyPlugin\Model\Table\SuperTestsTable')) {
class_alias($class, 'MyPlugin\Model\Table\SuperTestsTable');
}

$table = TableRegistry::get('MyPlugin.SuperTests');
Expand Down
20 changes: 10 additions & 10 deletions tests/TestCase/ORM/TableTest.php
Expand Up @@ -807,7 +807,7 @@ public function testEntityClassDefault() {
*
* @return void
*/
public function testRepositoryClassInApp() {
public function testTableClassInApp() {
$class = $this->getMockClass('\Cake\ORM\Entity');

if (!class_exists('TestApp\Model\Entity\TestUser')) {
Expand All @@ -824,7 +824,7 @@ class_alias($class, 'TestApp\Model\Entity\TestUser');
*
* @return void
*/
public function testRepositoryClassInPlugin() {
public function testTableClassInPlugin() {
$class = $this->getMockClass('\Cake\ORM\Entity');

if (!class_exists('MyPlugin\Model\Entity\SuperUser')) {
Expand All @@ -846,7 +846,7 @@ class_alias($class, 'MyPlugin\Model\Entity\SuperUser');
* @expectedExceptionMessage Entity class FooUser could not be found.
* @return void
*/
public function testRepositoryClassNonExisting() {
public function testTableClassNonExisting() {
$table = new Table;
$this->assertFalse($table->entityClass('FooUser'));
}
Expand All @@ -857,8 +857,8 @@ public function testRepositoryClassNonExisting() {
*
* @return void
*/
public function testRepositoryClassConventionForAPP() {
$table = new \TestApp\Model\Repository\ArticlesTable;
public function testTableClassConventionForAPP() {
$table = new \TestApp\Model\Table\ArticlesTable;
$this->assertEquals('TestApp\Model\Entity\Article', $table->entityClass());
}

Expand All @@ -881,7 +881,7 @@ public function testSetEntityClass() {
* @return void
*/
public function testReciprocalBelongsToLoading() {
$table = new \TestApp\Model\Repository\ArticlesTable([
$table = new \TestApp\Model\Table\ArticlesTable([
'connection' => $this->connection,
]);
$result = $table->find('all')->contain(['authors'])->first();
Expand All @@ -895,7 +895,7 @@ public function testReciprocalBelongsToLoading() {
* @return void
*/
public function testReciprocalHasManyLoading() {
$table = new \TestApp\Model\Repository\ArticlesTable([
$table = new \TestApp\Model\Table\ArticlesTable([
'connection' => $this->connection,
]);
$result = $table->find('all')->contain(['authors' => ['articles']])->first();
Expand All @@ -912,7 +912,7 @@ public function testReciprocalHasManyLoading() {
* @return void
*/
public function testReciprocalBelongsToMany() {
$table = new \TestApp\Model\Repository\ArticlesTable([
$table = new \TestApp\Model\Table\ArticlesTable([
'connection' => $this->connection,
]);
$result = $table->find('all')->contain(['tags'])->first();
Expand All @@ -929,7 +929,7 @@ public function testReciprocalBelongsToMany() {
* @return void
*/
public function testFindCleanEntities() {
$table = new \TestApp\Model\Repository\ArticlesTable([
$table = new \TestApp\Model\Table\ArticlesTable([
'connection' => $this->connection,
]);
$results = $table->find('all')->contain(['tags', 'authors'])->toArray();
Expand All @@ -956,7 +956,7 @@ public function testFindCleanEntities() {
* @return void
*/
public function testFindPersistedEntities() {
$table = new \TestApp\Model\Repository\ArticlesTable([
$table = new \TestApp\Model\Table\ArticlesTable([
'connection' => $this->connection,
]);
$results = $table->find('all')->contain(['tags', 'authors'])->toArray();
Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/TestSuite/TestCaseTest.php
Expand Up @@ -352,7 +352,7 @@ public function testGetMockForModel() {
$Posts = $this->getMockForModel('Posts');
$entity = new \Cake\ORM\Entity(array());

$this->assertInstanceOf('TestApp\Model\Repository\PostsTable', $Posts);
$this->assertInstanceOf('TestApp\Model\Table\PostsTable', $Posts);
$this->assertNull($Posts->save($entity));
$this->assertNull($Posts->table());

Expand Down Expand Up @@ -381,11 +381,11 @@ public function testGetMockForModelWithPlugin() {
$TestPluginComment = $this->getMockForModel('TestPlugin.TestPluginComments');

$result = TableRegistry::get('TestPlugin.TestPluginComments');
$this->assertInstanceOf('\TestPlugin\Model\Repository\TestPluginCommentsTable', $result);
$this->assertInstanceOf('\TestPlugin\Model\Table\TestPluginCommentsTable', $result);

$TestPluginComment = $this->getMockForModel('TestPlugin.TestPluginComments', array('save'));

$this->assertInstanceOf('\TestPlugin\Model\Repository\TestPluginCommentsTable', $TestPluginComment);
$this->assertInstanceOf('\TestPlugin\Model\Table\TestPluginCommentsTable', $TestPluginComment);
$TestPluginComment->expects($this->at(0))
->method('save')
->will($this->returnValue(true));
Expand Down
Expand Up @@ -14,15 +14,14 @@
* @since CakePHP v 3.0.0
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace TestPlugin\Model\Table;

use Cake\ORM\Table;

/**
* Class TestPluginCommentsTable
*
*/
namespace TestPlugin\Model\Repository;

use Cake\ORM\Table;

class TestPluginCommentsTable extends Table {

protected $_table = 'test_plugin_comments';
Expand Down
Expand Up @@ -9,7 +9,7 @@
* @since CakePHP(tm) v 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace TestApp\Model\Repository;
namespace TestApp\Model\Table;

use Cake\ORM\Table;

Expand Down
Expand Up @@ -9,7 +9,7 @@
* @since CakePHP(tm) v 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace TestApp\Model\Repository;
namespace TestApp\Model\Table;

use Cake\ORM\Table;

Expand Down
Expand Up @@ -9,7 +9,7 @@
* @since CakePHP(tm) v 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace TestApp\Model\Repository;
namespace TestApp\Model\Table;

use Cake\ORM\Table;

Expand Down
Expand Up @@ -9,7 +9,7 @@
* @since CakePHP(tm) v 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace TestApp\Model\Repository;
namespace TestApp\Model\Table;

use Cake\ORM\Table;

Expand Down
Expand Up @@ -11,7 +11,7 @@
* @since CakePHP v 3.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace TestApp\Model\Repository;
namespace TestApp\Model\Table;

use Cake\ORM\Query;
use Cake\ORM\Table;
Expand Down
Expand Up @@ -13,7 +13,7 @@
* @since CakePHP v 3.0.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace TestApp\Model\Repository;
namespace TestApp\Model\Table;

use Cake\ORM\Table;

Expand Down
Expand Up @@ -9,7 +9,7 @@
* @since CakePHP(tm) v 3.0
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
*/
namespace TestApp\Model\Repository;
namespace TestApp\Model\Table;

use Cake\ORM\Table;

Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.

0 comments on commit 197ebd1

Please sign in to comment.