Browse Source

Fix more non-conventional association names.

Mark Story 8 years ago
parent
commit
fe38d41cf8

+ 4 - 4
tests/TestCase/ORM/TableTest.php

@@ -1429,7 +1429,7 @@ class TableTest extends TestCase
         $table = new \TestApp\Model\Table\ArticlesTable([
             'connection' => $this->connection,
         ]);
-        $result = $table->find('all')->contain(['authors'])->first();
+        $result = $table->find('all')->contain(['Authors'])->first();
         $this->assertInstanceOf('TestApp\Model\Entity\Author', $result->author);
     }
 
@@ -1444,7 +1444,7 @@ class TableTest extends TestCase
         $table = new \TestApp\Model\Table\ArticlesTable([
             'connection' => $this->connection,
         ]);
-        $result = $table->find('all')->contain(['authors' => ['articles']])->first();
+        $result = $table->find('all')->contain(['Authors' => ['Articles']])->first();
         $this->assertCount(2, $result->author->articles);
         foreach ($result->author->articles as $article) {
             $this->assertInstanceOf('TestApp\Model\Entity\Article', $article);
@@ -1462,7 +1462,7 @@ class TableTest extends TestCase
         $table = new \TestApp\Model\Table\ArticlesTable([
             'connection' => $this->connection,
         ]);
-        $result = $table->find('all')->contain(['tags'])->first();
+        $result = $table->find('all')->contain(['Tags'])->first();
         $this->assertInstanceOf('TestApp\Model\Entity\Tag', $result->tags[0]);
         $this->assertInstanceOf(
             'TestApp\Model\Entity\ArticlesTag',
@@ -1480,7 +1480,7 @@ class TableTest extends TestCase
         $table = new \TestApp\Model\Table\ArticlesTable([
             'connection' => $this->connection,
         ]);
-        $results = $table->find('all')->contain(['tags', 'authors'])->toArray();
+        $results = $table->find('all')->contain(['Tags', 'Authors'])->toArray();
         $this->assertCount(3, $results);
         foreach ($results as $article) {
             $this->assertFalse($article->dirty('id'));

+ 2 - 2
tests/test_app/TestApp/Model/Table/ArticlesTable.php

@@ -22,8 +22,8 @@ class ArticlesTable extends Table
 
     public function initialize(array $config)
     {
-        $this->belongsTo('authors');
-        $this->belongsToMany('tags');
+        $this->belongsTo('Authors');
+        $this->belongsToMany('Tags');
         $this->hasMany('ArticlesTags');
     }
 

+ 2 - 2
tests/test_app/TestApp/Model/Table/ArticlesTagsTable.php

@@ -22,7 +22,7 @@ class ArticlesTagsTable extends Table
 
     public function initialize(array $config)
     {
-        $this->belongsTo('articles');
-        $this->belongsTo('tags');
+        $this->belongsTo('Articles');
+        $this->belongsTo('Tags');
     }
 }