Skip to content

Commit 12b92ee

Browse files
committed
fix failing test cases
1 parent 2550901 commit 12b92ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+35
-87
lines changed

src/Service/Action/Collection/DeleteAction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ protected function _deleteMany(array $entities): array
8585
$errors = [];
8686
foreach ($entities as $index => $entity) {
8787
/** @var \Cake\ORM\Entity $entity */
88-
$entity->isNew(false);
88+
$entity->setNew(false);
8989
try {
9090
$this->getTable()->deleteOrFail($entity, ['atomic' => false]);
9191
} catch (\InvalidArgumentException $ex) {

src/TestSuite/IntegrationTestCase.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,15 @@ class IntegrationTestCase extends \Cake\TestSuite\TestCase
3030
{
3131
use IntegrationTestTrait;
3232

33+
protected $fixtures = [
34+
'plugin.CakeDC/Api.SocialAccounts',
35+
'plugin.CakeDC/Api.Users',
36+
'plugin.CakeDC/Api.Articles',
37+
'plugin.CakeDC/Api.Authors',
38+
'plugin.CakeDC/Api.Tags',
39+
'plugin.CakeDC/Api.ArticlesTags',
40+
];
41+
3342
/**
3443
* @var string|int Current logged in user
3544
*/
@@ -86,9 +95,13 @@ protected function _userToken(?string $userId = null)
8695
$userId = $this->getDefaultUser();
8796
}
8897
$Users = TableRegistry::getTableLocator()->get('CakeDC/Users.Users');
89-
$user = $Users->find()->where(['id' => $userId])->first();
90-
if ($user instanceof EntityInterface) {
91-
return $user['api_token'];
98+
if ($userId) {
99+
$user = $Users->find()
100+
->where(['id' => $userId])
101+
->first();
102+
if ($user instanceof EntityInterface) {
103+
return $user['api_token'];
104+
}
92105
}
93106

94107
return null;

src/TestSuite/TestCase.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@
2323
*/
2424
class TestCase extends BaseTestCase
2525
{
26+
protected $fixtures = [
27+
'plugin.CakeDC/Api.SocialAccounts',
28+
'plugin.CakeDC/Api.Users',
29+
'plugin.CakeDC/Api.Articles',
30+
'plugin.CakeDC/Api.Authors',
31+
'plugin.CakeDC/Api.Tags',
32+
'plugin.CakeDC/Api.ArticlesTags',
33+
];
34+
2635
/**
2736
* setUp
2837
*

tests/FixturesTrait.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,19 @@ trait FixturesTrait
2525
*
2626
* @var array
2727
*/
28-
public $fixtures = [
28+
public $defaultFixtures = [
2929
'plugin.CakeDC/Api.SocialAccounts',
3030
'plugin.CakeDC/Api.Users',
3131
'plugin.CakeDC/Api.Articles',
3232
'plugin.CakeDC/Api.Authors',
3333
'plugin.CakeDC/Api.Tags',
3434
'plugin.CakeDC/Api.ArticlesTags',
3535
];
36+
37+
public function mergeFixtures()
38+
{
39+
if (empty($this->fixtures)) {
40+
$this->fixtures = $this->defaultFixtures;
41+
}
42+
}
3643
}

tests/TestCase/Auth/Authenticate/SocialAuthenticateTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@
2020
use CakeDC\Api\Service\Auth\Authenticate\SocialAuthenticate;
2121
use CakeDC\Api\Service\FallbackService;
2222
use CakeDC\Api\Test\ConfigTrait;
23-
use CakeDC\Api\Test\FixturesTrait;
2423
use CakeDC\Api\TestSuite\TestCase;
2524

2625
class SocialAuthenticateTest extends TestCase
2726
{
2827
use ConfigTrait;
29-
use FixturesTrait;
3028

3129
/**
3230
* @var SocialAuthenticate

tests/TestCase/Auth/Authenticate/TokenAuthenticateTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@
2020
use CakeDC\Api\Service\Auth\Authenticate\TokenAuthenticate;
2121
use CakeDC\Api\Service\FallbackService;
2222
use CakeDC\Api\Test\ConfigTrait;
23-
use CakeDC\Api\Test\FixturesTrait;
2423
use CakeDC\Api\TestSuite\TestCase;
2524

2625
class TokenAuthenticateTest extends TestCase
2726
{
2827
use ConfigTrait;
29-
use FixturesTrait;
3028

3129
/**
3230
* @var TokenAuthenticate

tests/TestCase/Auth/Authorize/SimpleRbacAuthorizeTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
class SimpleRbacAuthorizeTest extends TestCase
2626
{
27+
2728
/**
2829
* @var Service
2930
*/

tests/TestCase/Integration/Service/Action/Auth/LoginActionTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Cake\Core\Configure;
1717
use Cake\Utility\Hash;
1818
use CakeDC\Api\Test\ConfigTrait;
19-
use CakeDC\Api\Test\FixturesTrait;
2019
use CakeDC\Api\TestSuite\IntegrationTestCase;
2120

2221
/**
@@ -27,7 +26,6 @@
2726
class LoginActionTest extends IntegrationTestCase
2827
{
2928
use ConfigTrait;
30-
use FixturesTrait;
3129

3230
/**
3331
* setUp

tests/TestCase/Integration/Service/Action/Auth/RegisterActionTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Cake\Routing\Router;
1818
use Cake\Utility\Hash;
1919
use CakeDC\Api\Test\ConfigTrait;
20-
use CakeDC\Api\Test\FixturesTrait;
2120
use CakeDC\Api\TestSuite\IntegrationTestCase;
2221

2322
/**
@@ -28,7 +27,6 @@
2827
class RegisterActionTest extends IntegrationTestCase
2928
{
3029
use ConfigTrait;
31-
use FixturesTrait;
3230

3331
/**
3432
* setUp

tests/TestCase/Integration/Service/Action/Auth/ResetPasswordActionTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Cake\Core\Configure;
1717
use Cake\ORM\TableRegistry;
1818
use CakeDC\Api\Test\ConfigTrait;
19-
use CakeDC\Api\Test\FixturesTrait;
2019
use CakeDC\Api\Test\Settings;
2120
use CakeDC\Api\TestSuite\IntegrationTestCase;
2221

@@ -28,7 +27,6 @@
2827
class ResetPasswordActionTest extends IntegrationTestCase
2928
{
3029
use ConfigTrait;
31-
use FixturesTrait;
3230

3331
/**
3432
* setUp

0 commit comments

Comments
 (0)