Browse Source

Fix more TableRegistry references.

Robert Pustułka 8 years ago
parent
commit
ff222a86a9

+ 1 - 1
src/TestSuite/TestCase.php

@@ -695,7 +695,7 @@ abstract class TestCase extends BaseTestCase
 
         list(, $baseClass) = pluginSplit($alias);
         $options += ['alias' => $baseClass, 'connection' => $connection];
-        $options += $locator->config($alias);
+        $options += $locator->getConfig($alias);
 
         /** @var \Cake\ORM\Table|\PHPUnit_Framework_MockObject_MockObject $mock */
         $mock = $this->getMockBuilder($options['className'])

+ 1 - 1
tests/TestCase/Controller/Component/PaginatorComponentTest.php

@@ -236,7 +236,7 @@ class PaginatorComponentTest extends TestCase
             ]
         ];
 
-        $table = TableRegistry::get('PaginatorPosts');
+        $table = $this->getTableLocator()->get('PaginatorPosts');
 
         $this->Paginator->paginate($table, $settings);
         $this->assertArrayHasKey('PaginatorPosts', $this->controller->request->getParam('paging'));

+ 1 - 2
tests/TestCase/ORM/AssociationCollectionTest.php

@@ -19,7 +19,6 @@ use Cake\ORM\Association\BelongsTo;
 use Cake\ORM\Association\BelongsToMany;
 use Cake\ORM\Entity;
 use Cake\ORM\Locator\LocatorInterface;
-use Cake\ORM\TableRegistry;
 use Cake\TestSuite\TestCase;
 
 /**
@@ -50,7 +49,7 @@ class AssociationCollectionTest extends TestCase
      */
     public function testConstructor()
     {
-        $this->assertSame(TableRegistry::getTableLocator(), $this->associations->getTableLocator());
+        $this->assertSame($this->getTableLocator(), $this->associations->getTableLocator());
 
         $tableLocator = $this->createMock(LocatorInterface::class);
         $associations = new AssociationCollection($tableLocator);

+ 2 - 2
tests/TestCase/ORM/Behavior/TreeBehaviorTest.php

@@ -36,7 +36,7 @@ class TreeBehaviorTest extends TestCase
     public function setUp()
     {
         parent::setUp();
-        $this->table = TableRegistry::get('NumberTrees');
+        $this->table = $this->getTableLocator()->get('NumberTrees');
         $this->table->setPrimaryKey(['id']);
         $this->table->addBehavior('Tree');
     }
@@ -239,7 +239,7 @@ class TreeBehaviorTest extends TestCase
      */
     public function testScopeNull()
     {
-        $table = TableRegistry::get('MenuLinkTrees');
+        $table = $this->getTableLocator()->get('MenuLinkTrees');
         $table->addBehavior('Tree');
         $table->behaviors()->get('Tree')->setConfig('scope', null);
 

+ 1 - 1
tests/TestCase/ORM/QueryTest.php

@@ -3323,7 +3323,7 @@ class QueryTest extends TestCase
      */
     public function testLeftJoinWithAutoFields()
     {
-        $table = TableRegistry::get('articles');
+        $table = $this->getTableLocator()->get('articles');
         $table->belongsTo('authors');
 
         $results = $table

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

@@ -652,7 +652,7 @@ class TableTest extends TestCase
     {
         $this->expectException(InvalidArgumentException::class);
 
-        TableRegistry::get('Groups')->getAssociation('FooBar');
+        $this->getTableLocator()->get('Groups')->getAssociation('FooBar');
     }
 
     /**
@@ -5905,7 +5905,7 @@ class TableTest extends TestCase
      */
     public function testPatchEntity()
     {
-        $table = TableRegistry::get('Articles');
+        $table = $this->getTableLocator()->get('Articles');
         $entity = new Entity(['title' => 'old title'], ['markNew' => false]);
         $data = ['title' => 'new title'];
         $entity = $table->patchEntity($entity, $data);
@@ -5950,7 +5950,7 @@ class TableTest extends TestCase
      */
     public function testPatchEntities()
     {
-        $table = TableRegistry::get('Articles');
+        $table = $this->getTableLocator()->get('Articles');
         $entities = $table->find()->limit(2)->toArray();
 
         $data = [
@@ -6770,7 +6770,7 @@ class TableTest extends TestCase
         ]);
         $entity->setError('field', 'Some message');
         $entity->setError('multiple', ['one' => 'One', 'two' => 'Two']);
-        $table = TableRegistry::get('users');
+        $table = $this->getTableLocator()->get('users');
 
         $table->saveOrFail($entity);
     }