Skip to content

Commit

Permalink
PHPStan 2.0 update.
Browse files Browse the repository at this point in the history
  • Loading branch information
dereuromark committed Nov 11, 2024
1 parent b331e1b commit f8f21a1
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sandbox\Test\TestCase\Controller;

use Cake\ORM\TableRegistry;
use Shim\TestSuite\IntegrationTestCase;

/**
Expand Down Expand Up @@ -44,7 +43,7 @@ public function testView() {
$this->disableErrorHandlerMiddleware();

/** @var \Sandbox\Model\Entity\ExposedUser $user */
$user = TableRegistry::getTableLocator()->get('Sandbox.ExposedUsers')->find()->firstOrFail();
$user = $this->fetchTable('Sandbox.ExposedUsers')->find()->firstOrFail();

$this->get(['plugin' => 'Sandbox', 'controller' => 'ExposeExamples', 'action' => 'view', $user->uuid]);

Expand All @@ -71,7 +70,7 @@ public function testSuperimposedView() {
$this->disableErrorHandlerMiddleware();

/** @var \Sandbox\Model\Entity\ExposedUser $user */
$user = TableRegistry::getTableLocator()->get('Sandbox.ExposedUsers')->find()->firstOrFail();
$user = $this->fetchTable('Sandbox.ExposedUsers')->find()->firstOrFail();

$this->get(['plugin' => 'Sandbox', 'controller' => 'ExposeExamples', 'action' => 'superimposedView', $user->uuid]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace Sandbox\Test\TestCase\Controller;

use Cake\ORM\TableRegistry;
use Shim\TestSuite\IntegrationTestCase;

/**
Expand Down Expand Up @@ -56,7 +55,7 @@ public function testConfig() {
public function testCancelJob() {
$this->disableErrorHandlerMiddleware();

$queuedJobs = TableRegistry::getTableLocator()->get('Queue.QueuedJobs');
$queuedJobs = $this->fetchTable('Queue.QueuedJobs');
$queuedJob = $queuedJobs->newEntity([
'job_task' => 'Queue.ProgressExample',
'reference' => 'demo-cli',
Expand All @@ -80,7 +79,7 @@ public function testScheduleDemo() {
$this->assertResponseCode(302);
$this->assertRedirect();

$queuedJobs = TableRegistry::getTableLocator()->get('Queue.QueuedJobs');
$queuedJobs = $this->fetchTable('Queue.QueuedJobs');
/** @var \Queue\Model\Entity\QueuedJob $queuedJob */
$queuedJob = $queuedJobs->find()->orderByDesc('id')->firstOrFail();
$this->assertSame('Queue.ProgressExample', $queuedJob->job_task);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class EventsTableTest extends TestCase {
public function setUp(): void {
parent::setUp();
$config = TableRegistry::getTableLocator()->exists('Events') ? [] : ['className' => 'Sandbox\Model\Table\EventsTable'];
$this->Events = TableRegistry::getTableLocator()->get('Events', $config);
$this->Events = $this->fetchTable('Events', $config);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ExposedUsersTableTest extends TestCase {
public function setUp(): void {
parent::setUp();
$config = TableRegistry::getTableLocator()->exists('ExposedUsers') ? [] : ['className' => ExposedUsersTable::class];
$this->ExposedUsers = TableRegistry::getTableLocator()->get('ExposedUsers', $config);
$this->ExposedUsers = $this->fetchTable('ExposedUsers', $config);
}

/**
Expand Down
9 changes: 4 additions & 5 deletions tests/TestCase/Controller/AccountControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Test\TestCase\Controller;

use Cake\ORM\TableRegistry;
use Shim\TestSuite\IntegrationTestCase;

/**
Expand Down Expand Up @@ -89,7 +88,7 @@ public function testLoginPostValidData() {
'email' => '[email protected]',
'pwd' => '123456',
];
$Users = TableRegistry::getTableLocator()->get('Users');
$Users = $this->fetchTable('Users');
$Users->addBehavior('Tools.Passwordable', ['confirm' => false]);
$user = $Users->newEntity($data);
$result = $Users->save($user);
Expand All @@ -113,7 +112,7 @@ public function testLoginPostValidDataEmail() {
'email' => '[email protected]',
'pwd' => '123456',
];
$Users = TableRegistry::getTableLocator()->get('Users');
$Users = $this->fetchTable('Users');
$Users->addBehavior('Tools.Passwordable', ['confirm' => false]);
$user = $Users->newEntity($data);
$result = $Users->save($user);
Expand All @@ -137,7 +136,7 @@ public function testLoginPostValidDataReferrer() {
'email' => '[email protected]',
'pwd' => '123456',
];
$Users = TableRegistry::getTableLocator()->get('Users');
$Users = $this->fetchTable('Users');
$Users->addBehavior('Tools.Passwordable', ['confirm' => false]);
$user = $Users->newEntity($data);
$result = $Users->save($user);
Expand Down Expand Up @@ -202,7 +201,7 @@ public function testChangePassword() {
public function testChangePasswordPost() {
$this->skipIf(true); // not needed right now

$Users = TableRegistry::getTableLocator()->get('Users');
$Users = $this->fetchTable('Users');
$username = $Users->field('username');

$session = ['Auth' => ['Tmp' => ['id' => '1']]];
Expand Down
3 changes: 1 addition & 2 deletions tests/TestCase/Model/Table/UsersTableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Test\TestCase\Model\Table;

use Cake\ORM\TableRegistry;
use Cake\TestSuite\TestCase;

/**
Expand Down Expand Up @@ -31,7 +30,7 @@ class UsersTableTest extends TestCase {
*/
public function setUp(): void {
parent::setUp();
$this->Users = TableRegistry::getTableLocator()->get('Users');
$this->Users = $this->fetchTable('Users');
}

/**
Expand Down

0 comments on commit f8f21a1

Please sign in to comment.