Skip to content

Commit 728ba22

Browse files
committed
Upgrade to new fixture management per CakePHP 4.3.0.
1 parent b427932 commit 728ba22

10 files changed

+93
-66
lines changed

phpunit.xml.dist

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,12 @@
1313
<directory suffix=".ctp">./src/</directory>
1414
</include>
1515
</coverage>
16+
<extensions>
17+
<extension class="\Cake\TestSuite\Fixture\PHPUnitExtension" />
18+
</extensions>
1619
<testsuites>
1720
<testsuite name="Crud">
1821
<directory>./tests/</directory>
1922
</testsuite>
2023
</testsuites>
21-
<listeners>
22-
<listener class="\Cake\TestSuite\Fixture\FixtureInjector">
23-
<arguments>
24-
<object class="\Cake\TestSuite\Fixture\FixtureManager"/>
25-
</arguments>
26-
</listener>
27-
</listeners>
2824
</phpunit>

tests/Fixture/CountriesFixture.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,6 @@
55

66
class CountriesFixture extends TestFixture
77
{
8-
public $fields = [
9-
'id' => ['type' => 'integer'],
10-
'code' => ['type' => 'string', 'length' => 2, 'null' => false],
11-
'name' => ['type' => 'string', 'length' => 255, 'null' => false],
12-
'dummy_counter' => ['type' => 'integer'],
13-
'currency_id' => ['type' => 'integer', 'null' => true],
14-
'national_capital_id' => ['type' => 'integer', 'null' => true],
15-
'supercountry_id' => ['type' => 'integer', 'null' => true],
16-
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
17-
];
18-
198
public $records = [
209
['code' => 'NL', 'name' => 'The Netherlands', 'dummy_counter' => 11111, 'currency_id' => 1, 'national_capital_id' => 1],
2110
['code' => 'BG', 'name' => 'Bulgaria', 'dummy_counter' => 22222, 'currency_id' => 1, 'national_capital_id' => 2],

tests/Fixture/CountriesLanguagesFixture.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55

66
class CountriesLanguagesFixture extends TestFixture
77
{
8-
public $fields = [
9-
'id' => ['type' => 'integer'],
10-
'country_id' => ['type' => 'integer', 'length' => 3, 'null' => false],
11-
'language_id' => ['type' => 'integer', 'length' => 100, 'null' => false],
12-
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
13-
];
14-
158
public $records = [
169
['country_id' => 1, 'language_id' => 1],
1710
['country_id' => 1, 'language_id' => 2],

tests/Fixture/CulturesFixture.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,6 @@
55

66
class CulturesFixture extends TestFixture
77
{
8-
public $fields = [
9-
'id' => ['type' => 'integer'],
10-
'code' => ['type' => 'string', 'length' => 5, 'null' => false],
11-
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
12-
'another_dummy_counter' => ['type' => 'integer'],
13-
'country_id' => ['type' => 'integer', 'null' => false],
14-
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
15-
];
16-
178
public $records = [
189
['code' => 'nl-NL', 'name' => 'Dutch', 'another_dummy_counter' => 11111, 'country_id' => 1],
1910
['code' => 'bg-BG', 'name' => 'Bulgarian', 'another_dummy_counter' => 22222, 'country_id' => 2],

tests/Fixture/CurrenciesFixture.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55

66
class CurrenciesFixture extends TestFixture
77
{
8-
public $fields = [
9-
'id' => ['type' => 'integer'],
10-
'code' => ['type' => 'string', 'length' => 3, 'null' => false],
11-
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
12-
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
13-
];
14-
158
public $records = [
169
['code' => 'EUR', 'name' => 'Euro'],
1710
['code' => 'USD', 'name' => 'US Dollar'],

tests/Fixture/LanguagesFixture.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55

66
class LanguagesFixture extends TestFixture
77
{
8-
public $fields = [
9-
'id' => ['type' => 'integer'],
10-
'code' => ['type' => 'string', 'length' => 2, 'null' => false],
11-
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
12-
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
13-
];
14-
158
public $records = [
169
['id' => 1, 'code' => 'en', 'name' => 'English'],
1710
['id' => 2, 'code' => 'nl', 'name' => 'Dutch'],

tests/Fixture/NationalCapitalsFixture.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55

66
class NationalCapitalsFixture extends TestFixture
77
{
8-
public $fields = [
9-
'id' => ['type' => 'integer'],
10-
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
11-
'description' => ['type' => 'string', 'length' => 255, 'null' => false],
12-
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
13-
];
14-
158
public $records = [
169
['name' => 'Amsterdam', 'description' => 'National capital of the Netherlands'],
1710
['name' => 'Sofia', 'description' => 'National capital of Bulgaria'],

tests/Fixture/NationalCitiesFixture.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,6 @@
55

66
class NationalCitiesFixture extends TestFixture
77
{
8-
public $fields = [
9-
'id' => ['type' => 'integer'],
10-
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
11-
'country_id' => ['type' => 'integer', 'null' => false],
12-
'_constraints' => ['primary' => ['type' => 'primary', 'columns' => ['id']]],
13-
];
14-
158
public $records = [
169
['name' => 'Amsterdam', 'country_id' => 1],
1710
['name' => 'Rotterdam', 'country_id' => 1],

tests/Fixture/schema.php

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<?php
2+
/**
3+
* Schema file for CrudJsonApi tests
4+
*
5+
* This file defines the database schema for the test fixtures.
6+
* It is used by the SchemaLoader to create the test database.
7+
*/
8+
return [
9+
'countries' => [
10+
'columns' => [
11+
'id' => ['type' => 'integer'],
12+
'code' => ['type' => 'string', 'length' => 2, 'null' => false],
13+
'name' => ['type' => 'string', 'length' => 255, 'null' => false],
14+
'dummy_counter' => ['type' => 'integer'],
15+
'currency_id' => ['type' => 'integer', 'null' => true],
16+
'national_capital_id' => ['type' => 'integer', 'null' => true],
17+
'supercountry_id' => ['type' => 'integer', 'null' => true],
18+
],
19+
'constraints' => [
20+
'primary' => ['type' => 'primary', 'columns' => ['id']],
21+
],
22+
],
23+
'countries_languages' => [
24+
'columns' => [
25+
'id' => ['type' => 'integer'],
26+
'country_id' => ['type' => 'integer', 'length' => 3, 'null' => false],
27+
'language_id' => ['type' => 'integer', 'length' => 100, 'null' => false],
28+
],
29+
'constraints' => [
30+
'primary' => ['type' => 'primary', 'columns' => ['id']],
31+
],
32+
],
33+
'cultures' => [
34+
'columns' => [
35+
'id' => ['type' => 'integer'],
36+
'code' => ['type' => 'string', 'length' => 5, 'null' => false],
37+
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
38+
'another_dummy_counter' => ['type' => 'integer'],
39+
'country_id' => ['type' => 'integer', 'null' => false],
40+
],
41+
'constraints' => [
42+
'primary' => ['type' => 'primary', 'columns' => ['id']],
43+
],
44+
],
45+
'currencies' => [
46+
'columns' => [
47+
'id' => ['type' => 'integer'],
48+
'code' => ['type' => 'string', 'length' => 3, 'null' => false],
49+
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
50+
],
51+
'constraints' => [
52+
'primary' => ['type' => 'primary', 'columns' => ['id']],
53+
],
54+
],
55+
'languages' => [
56+
'columns' => [
57+
'id' => ['type' => 'integer'],
58+
'code' => ['type' => 'string', 'length' => 2, 'null' => false],
59+
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
60+
],
61+
'constraints' => [
62+
'primary' => ['type' => 'primary', 'columns' => ['id']],
63+
],
64+
],
65+
'national_capitals' => [
66+
'columns' => [
67+
'id' => ['type' => 'integer'],
68+
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
69+
'description' => ['type' => 'string', 'length' => 255, 'null' => false],
70+
],
71+
'constraints' => [
72+
'primary' => ['type' => 'primary', 'columns' => ['id']],
73+
],
74+
],
75+
'national_cities' => [
76+
'columns' => [
77+
'id' => ['type' => 'integer'],
78+
'name' => ['type' => 'string', 'length' => 100, 'null' => false],
79+
'country_id' => ['type' => 'integer', 'null' => false],
80+
],
81+
'constraints' => [
82+
'primary' => ['type' => 'primary', 'columns' => ['id']],
83+
],
84+
],
85+
];

tests/bootstrap.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use Cake\Core\Configure;
44
use Cake\Core\Plugin;
5+
use Cake\TestSuite\Fixture\SchemaLoader;
56

67
// @codingStandardsIgnoreFile
78

@@ -98,9 +99,9 @@
9899
]
99100
);
100101

102+
// Load schema from schema.php file
103+
$loader = new SchemaLoader();
104+
$loader->loadInternalFile(ROOT . '/tests/Fixture/schema.php');
105+
101106
Plugin::getCollection()->add(new \Crud\Plugin());
102107
Plugin::getCollection()->add(new \CrudJsonApi\Plugin());
103-
104-
Configure::write('Error.ignoredDeprecationPaths', [
105-
'vendor/cakephp/cakephp/src/TestSuite/Fixture/FixtureInjector.php',
106-
]);

0 commit comments

Comments
 (0)