Skip to content

Commit 5c6a9b0

Browse files
committed
Update use of deprecated TableRegistry
1 parent 1c196ff commit 5c6a9b0

3 files changed

Lines changed: 4 additions & 7 deletions

File tree

src/Auth/FootprintAwareTrait.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
use Cake\Datasource\EntityInterface;
77
use Cake\Event\EventInterface;
88
use Cake\Event\EventManager;
9-
use Cake\ORM\TableRegistry;
109
use Muffin\Footprint\Event\FootprintListener;
1110
use RuntimeException;
1211

@@ -151,7 +150,7 @@ protected function _circumventEventManager(string $method, array $args = [])
151150
{
152151
EventManager::instance()->off('Model.initialize', [$this, 'footprint']);
153152
$result = call_user_func_array(
154-
[TableRegistry::getTableLocator()->get($this->_userModel), $method],
153+
[$this->getTableLocator()->get($this->_userModel), $method],
155154
$args
156155
);
157156
EventManager::instance()->on('Model.initialize', [$this, 'footprint']);

tests/TestCase/Auth/FootprintAwareTraitTest.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Cake\Event\Event;
88
use Cake\Event\EventManager;
99
use Cake\ORM\Table;
10-
use Cake\ORM\TableRegistry;
1110
use Cake\TestSuite\TestCase;
1211
use TestApp\Controller\ArticlesController;
1312

@@ -25,7 +24,7 @@ public function setUp(): void
2524
->withData('password', 'cake'));
2625
$this->controller->Auth->setConfig('authenticate', ['Form']);
2726

28-
$Users = TableRegistry::getTableLocator()->get('Users');
27+
$Users = $this->getTableLocator()->get('Users');
2928
$Users->updateAll(['password' => password_hash('cake', PASSWORD_BCRYPT)], []);
3029
}
3130

tests/TestCase/Model/Behavior/FootprintBehaviorTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
namespace Muffin\Footprint\Test\TestCase\Model\Behavior;
55

66
use Cake\ORM\Entity;
7-
use Cake\ORM\TableRegistry;
87
use Cake\TestSuite\TestCase;
98

109
class FootprintBehaviorTest extends TestCase
@@ -17,7 +16,7 @@ public function setUp(): void
1716
{
1817
parent::setUp();
1918

20-
$table = TableRegistry::get('Muffin/Footprint.Articles');
19+
$table = $this->getTableLocator()->get('Muffin/Footprint.Articles');
2120
$table->addBehavior('Muffin/Footprint.Footprint', [
2221
'events' => [
2322
'Model.beforeSave' => [
@@ -42,7 +41,7 @@ public function setUp(): void
4241
public function tearDown(): void
4342
{
4443
parent::tearDown();
45-
TableRegistry::clear();
44+
$this->getTableLocator()->clear();
4645
}
4746

4847
public function testSave()

0 commit comments

Comments
 (0)