Skip to content

Commit 6d92b13

Browse files
committed
Migrating TableRegistry to use the new table name convention
1 parent b2485eb commit 6d92b13

File tree

5 files changed

+24
-24
lines changed

5 files changed

+24
-24
lines changed

Cake/Test/TestApp/Model/Repository/ArticleTable.php renamed to Cake/Test/TestApp/Model/Repository/ArticlesTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Article table class
1818
*
1919
*/
20-
class ArticleTable extends Table {
20+
class ArticlesTable extends Table {
2121

2222
public function initialize(array $config) {
2323
$this->belongsTo('author');

Cake/Test/TestApp/Model/Repository/ArticlesTagTable.php renamed to Cake/Test/TestApp/Model/Repository/ArticlesTagsTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Tag table class
1818
*
1919
*/
20-
class ArticlesTagTable extends Table {
20+
class ArticlesTagsTable extends Table {
2121

2222
public function initialize(array $config) {
2323
$this->belongsTo('article');

Cake/Test/TestApp/Model/Repository/AuthorTable.php renamed to Cake/Test/TestApp/Model/Repository/AuthorsTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Author table class
1818
*
1919
*/
20-
class AuthorTable extends Table {
20+
class AuthorsTable extends Table {
2121

2222
public function initialize(array $config) {
2323
$this->hasMany('article');

Cake/Test/TestApp/Model/Repository/TagTable.php renamed to Cake/Test/TestApp/Model/Repository/TagsTable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Tag table class
1818
*
1919
*/
20-
class TagTable extends Table {
20+
class TagsTable extends Table {
2121

2222
public function initialize(array $config) {
2323
$this->belongsTo('author');

Cake/Test/TestCase/ORM/TableRegistryTest.php

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,17 @@ public function tearDown() {
6868
* @return void
6969
*/
7070
public function testConfig() {
71-
$this->assertEquals([], TableRegistry::config('Test'));
71+
$this->assertEquals([], TableRegistry::config('Tests'));
7272

7373
$data = [
7474
'connection' => 'testing',
7575
'entityClass' => 'TestApp\Model\Entity\Article',
7676
];
77-
$result = TableRegistry::config('Test', $data);
77+
$result = TableRegistry::config('Tests', $data);
7878
$this->assertEquals($data, $result, 'Returns config data.');
7979

8080
$result = TableRegistry::config();
81-
$expected = ['Test' => $data];
81+
$expected = ['Tests' => $data];
8282
$this->assertEquals($expected, $result);
8383
}
8484

@@ -88,13 +88,13 @@ public function testConfig() {
8888
* @return void
8989
*/
9090
public function testGet() {
91-
$result = TableRegistry::get('Article', [
91+
$result = TableRegistry::get('Articles', [
9292
'table' => 'my_articles',
9393
]);
9494
$this->assertInstanceOf('Cake\ORM\Table', $result);
9595
$this->assertEquals('my_articles', $result->table());
9696

97-
$result2 = TableRegistry::get('Article', [
97+
$result2 = TableRegistry::get('Articles', [
9898
'table' => 'herp_derp',
9999
]);
100100
$this->assertSame($result, $result2);
@@ -107,10 +107,10 @@ public function testGet() {
107107
* @return void
108108
*/
109109
public function testGetWithConfig() {
110-
TableRegistry::config('Article', [
110+
TableRegistry::config('Articles', [
111111
'table' => 'my_articles',
112112
]);
113-
$result = TableRegistry::get('Article');
113+
$result = TableRegistry::get('Articles');
114114
$this->assertEquals('my_articles', $result->table(), 'Should use config() data.');
115115
}
116116

@@ -121,26 +121,26 @@ public function testGetWithConfig() {
121121
* @return void
122122
*/
123123
public function testBuildConvention() {
124-
$table = TableRegistry::get('article');
125-
$this->assertInstanceOf('\TestApp\Model\Repository\ArticleTable', $table);
126-
$table = TableRegistry::get('Article');
127-
$this->assertInstanceOf('\TestApp\Model\Repository\ArticleTable', $table);
124+
$table = TableRegistry::get('articles');
125+
$this->assertInstanceOf('\TestApp\Model\Repository\ArticlesTable', $table);
126+
$table = TableRegistry::get('Articles');
127+
$this->assertInstanceOf('\TestApp\Model\Repository\ArticlesTable', $table);
128128

129-
$table = TableRegistry::get('author');
130-
$this->assertInstanceOf('\TestApp\Model\Repository\AuthorTable', $table);
131-
$table = TableRegistry::get('Author');
132-
$this->assertInstanceOf('\TestApp\Model\Repository\AuthorTable', $table);
129+
$table = TableRegistry::get('authors');
130+
$this->assertInstanceOf('\TestApp\Model\Repository\AuthorsTable', $table);
131+
$table = TableRegistry::get('Authors');
132+
$this->assertInstanceOf('\TestApp\Model\Repository\AuthorsTable', $table);
133133

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

139-
if (!class_exists('MyPlugin\Model\Repository\SuperTestTable')) {
140-
class_alias($class, 'MyPlugin\Model\Repository\SuperTestTable');
139+
if (!class_exists('MyPlugin\Model\Repository\SuperTestsTable')) {
140+
class_alias($class, 'MyPlugin\Model\Repository\SuperTestsTable');
141141
}
142142

143-
$table = TableRegistry::get('MyPlugin.SuperTest');
143+
$table = TableRegistry::get('MyPlugin.SuperTests');
144144
$this->assertInstanceOf($class, $table);
145145
}
146146

@@ -192,8 +192,8 @@ public function testConfigAndBuild() {
192192
*/
193193
public function testSet() {
194194
$mock = $this->getMock('Cake\ORM\Table');
195-
$this->assertSame($mock, TableRegistry::set('Article', $mock));
196-
$this->assertSame($mock, TableRegistry::get('Article'));
195+
$this->assertSame($mock, TableRegistry::set('Articles', $mock));
196+
$this->assertSame($mock, TableRegistry::get('Articles'));
197197
}
198198

199199
}

0 commit comments

Comments
 (0)