Skip to content

Commit fbf0ee0

Browse files
authored
Cakephp 5.2.9, phpunit 11/12 (#40)
* feat: upgrade dependencies + refactor tests * feat: release workflow update dist_branches * fix: release workflow dist_branches
1 parent ef4bec1 commit fbf0ee0

12 files changed

Lines changed: 78 additions & 64 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ jobs:
99
uses: bedita/github-workflows/.github/workflows/release.yml@v2
1010
with:
1111
main_branch: 'master'
12-
dist_branches: '["master","1.x"]'
12+
dist_branches: '["master", "1.x"]'

composer.json

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@
2323
"require": {
2424
"php": ">=8.3",
2525
"ext-json": "*",
26-
"cakephp/cakephp": "^5.1.0",
27-
"cakephp/debug_kit": "^5.0.0"
26+
"cakephp/cakephp": "~5.2.9",
27+
"cakephp/debug_kit": "^5.3.0"
2828
},
2929
"require-dev": {
30-
"cakephp/bake": "^3.0.0",
31-
"cakephp/migrations": "^4.0.0",
30+
"cakephp/bake": "^3.5.0",
31+
"cakephp/migrations": "^4.8",
3232
"cakephp/cakephp-codesniffer": "^5.0",
3333
"phpstan/phpstan": "^1.10",
34-
"phpunit/phpunit": "^10.1.0"
34+
"phpstan/extension-installer": "^1.0",
35+
"phpstan/phpstan-deprecation-rules": "^1.0",
36+
"phpunit/phpunit": "^11.5 || ^12.1"
3537
},
3638
"autoload": {
3739
"psr-4": {
@@ -44,22 +46,24 @@
4446
"Cake\\Test\\": "./vendor/cakephp/cakephp/tests"
4547
}
4648
},
47-
"minimum-stability": "stable",
49+
"minimum-stability": "dev",
4850
"prefer-stable": true,
4951
"scripts": {
5052
"check": [
5153
"@test",
5254
"@cs-check"
5355
],
56+
"cs-check": "vendor/bin/phpcs --colors -p --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
57+
"cs-fix": "vendor/bin/phpcbf --colors --standard=vendor/cakephp/cakephp-codesniffer/CakePHP ./src ./tests",
5458
"stan": "vendor/bin/phpstan analyse",
55-
"cs-check": "vendor/bin/phpcs",
56-
"cs-fix": "vendor/bin/phpcbf",
57-
"test": "vendor/bin/phpunit --colors=always"
59+
"test": "vendor/bin/phpunit --colors=always",
60+
"coverage": "vendor/bin/phpunit --colors=always --coverage-html coverage"
5861
},
5962
"config": {
6063
"allow-plugins": {
6164
"cakephp/plugin-installer": true,
62-
"dealerdirect/phpcodesniffer-composer-installer": true
65+
"dealerdirect/phpcodesniffer-composer-installer": true,
66+
"phpstan/extension-installer": true
6367
}
6468
}
6569
}

phpcs.xml.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
<file>tests</file>
55

66
<arg name="colors"/>
7+
<arg value="n" />
78
<arg value="p" />
9+
<arg name="extensions" value="php"/>
810

911
<config name="installed_paths" value="../../cakephp/cakephp-codesniffer"/>
1012

11-
<rule ref="CakePHP"/>
12-
13-
<exclude-pattern>/tests/comparisons/*</exclude-pattern>
13+
<rule ref="CakePHP" />
1414
</ruleset>

phpstan.neon.dist

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ parameters:
1010
ignoreErrors:
1111
- identifier: missingType.iterableValue
1212
- identifier: missingType.generics
13-
excludePaths:
14-
- tests/comparisons/*

tests/TestCase/Command/ChangeLogCommandTest.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,29 @@
1414
*/
1515
namespace BEdita\Core\Test\TestCase\Command;
1616

17+
use BEdita\DevTools\Command\ChangeLogCommand;
1718
use Cake\Console\TestSuite\ConsoleIntegrationTestTrait;
1819
use Cake\Core\Configure;
1920
use Cake\Http\Client\Adapter\Stream;
2021
use Cake\Http\Client\Response;
2122
use Cake\Routing\Router;
2223
use Cake\TestSuite\TestCase;
24+
use PHPUnit\Framework\Attributes\CoversClass;
25+
use PHPUnit\Framework\Attributes\CoversMethod;
2326

2427
/**
2528
* {@see BEdita\DevTools\Command\ChangeLogCommand} Test Case
26-
*
27-
* @coversDefaultClass \BEdita\DevTools\Command\ChangeLogCommand
2829
*/
30+
#[CoversClass(ChangeLogCommand::class)]
31+
#[CoversMethod(ChangeLogCommand::class, 'buildOptionParser')]
32+
#[CoversMethod(ChangeLogCommand::class, 'classify')]
33+
#[CoversMethod(ChangeLogCommand::class, 'createChangeLog')]
34+
#[CoversMethod(ChangeLogCommand::class, 'execute')]
35+
#[CoversMethod(ChangeLogCommand::class, 'fetchPrs')]
36+
#[CoversMethod(ChangeLogCommand::class, 'filterItems')]
37+
#[CoversMethod(ChangeLogCommand::class, 'initialize')]
38+
#[CoversMethod(ChangeLogCommand::class, 'loglines')]
39+
#[CoversMethod(ChangeLogCommand::class, 'saveChangeLog')]
2940
class ChangeLogCommandTest extends TestCase
3041
{
3142
use ConsoleIntegrationTestTrait;
@@ -45,7 +56,6 @@ public function setUp(): void
4556
* Test buildOptionParser method
4657
*
4758
* @return void
48-
* @covers ::buildOptionParser()
4959
*/
5060
public function testBuildOptionParser()
5161
{
@@ -58,14 +68,6 @@ public function testBuildOptionParser()
5868
* Test `execute` method
5969
*
6070
* @return void
61-
* @covers ::execute()
62-
* @covers ::initialize()
63-
* @covers ::fetchPrs()
64-
* @covers ::classify()
65-
* @covers ::createChangeLog()
66-
* @covers ::saveChangeLog()
67-
* @covers ::filterItems()
68-
* @covers ::loglines()
6971
*/
7072
public function testExecute(): void
7173
{

tests/TestCase/Command/ResourcesMigrationCommandTest.php

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,18 @@
2121
use Cake\Routing\Router;
2222
use Cake\TestSuite\StringCompareTrait;
2323
use Cake\TestSuite\TestCase;
24+
use PHPUnit\Framework\Attributes\CoversClass;
25+
use PHPUnit\Framework\Attributes\CoversMethod;
2426

2527
/**
26-
* Test resources migration task.
27-
*
28-
* @coversDefaultClass \BEdita\DevTools\Command\ResourcesMigrationCommand
28+
* Test resources migration task
2929
*/
30+
#[CoversClass(ResourcesMigrationCommand::class)]
31+
#[CoversMethod(ResourcesMigrationCommand::class, 'bake')]
32+
#[CoversMethod(ResourcesMigrationCommand::class, 'buildOptionParser')]
33+
#[CoversMethod(ResourcesMigrationCommand::class, 'fileName')]
34+
#[CoversMethod(ResourcesMigrationCommand::class, 'name')]
35+
#[CoversMethod(ResourcesMigrationCommand::class, 'template')]
3036
class ResourcesMigrationCommandTest extends TestCase
3137
{
3238
use ConsoleIntegrationTestTrait;
@@ -48,7 +54,7 @@ public function setUp(): void
4854
Router::reload();
4955
$this->loadPlugins(['Bake']);
5056
$this->setAppNamespace('BEdita\DevTools\Test\TestApp');
51-
$this->_compareBasePath = Plugin::path('BEdita/DevTools') . 'tests' . DS . 'comparisons' . DS . 'Migrations' . DS;
57+
$this->_compareBasePath = Plugin::path('BEdita/DevTools') . 'tests' . DS . 'Migrations' . DS;
5258
}
5359

5460
/**
@@ -67,7 +73,6 @@ public function tearDown(): void
6773
* Test `name`.
6874
*
6975
* @return void
70-
* @covers ::name()
7176
*/
7277
public function testName(): void
7378
{
@@ -81,7 +86,6 @@ public function testName(): void
8186
* Test `fileName`.
8287
*
8388
* @return void
84-
* @covers ::fileName()
8589
*/
8690
public function testFileName(): void
8791
{
@@ -103,7 +107,6 @@ public function setArgs(Arguments $args): void
103107
* Test `template`.
104108
*
105109
* @return void
106-
* @covers ::template()
107110
*/
108111
public function testTemplate(): void
109112
{
@@ -117,8 +120,6 @@ public function testTemplate(): void
117120
* Test `bake`.
118121
*
119122
* @return void
120-
* @covers ::bake()
121-
* @covers ::buildOptionParser()
122123
*/
123124
public function testBake(): void
124125
{
@@ -140,8 +141,26 @@ public function testBake(): void
140141
$this->createdFiles[] = $phpFile;
141142
$this->createdFiles[] = $yamlFile;
142143

143-
self::assertSameMigration((string)$phpResult, (string)file_get_contents($this->_compareBasePath . 'testMyMigration.php'));
144-
self::assertSameMigration((string)$yamlResult, (string)file_get_contents($this->_compareBasePath . 'testMyMigration.yml'));
144+
$expectedPhp = <<<PHP
145+
<?php
146+
use BEdita\Core\Migration\ResourcesMigration;
147+
148+
class MyMigration extends ResourcesMigration
149+
{
150+
}
151+
PHP;
152+
self::assertSameMigration((string)$phpResult, $expectedPhp);
153+
$expectedYaml = <<<YAML
154+
# MyMigration migration
155+
---
156+
157+
#create:
158+
159+
#update:
160+
161+
#remove:
162+
YAML;
163+
self::assertSameMigration((string)$yamlResult, $expectedYaml);
145164
}
146165

147166
/**

tests/TestCase/Middleware/HtmlMiddlewareTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@
1919
use Cake\Http\Response;
2020
use Cake\Http\ServerRequest;
2121
use Cake\TestSuite\TestCase;
22+
use PHPUnit\Framework\Attributes\CoversClass;
2223
use Psr\Http\Message\ResponseInterface;
2324
use Psr\Http\Message\ServerRequestInterface;
2425
use Psr\Http\Server\RequestHandlerInterface;
2526

2627
/**
27-
* @covers \BEdita\DevTools\Middleware\HtmlMiddleware
28+
* {@see BEdita\DevTools\Middleware\HtmlMiddleware} Test Case
2829
*/
30+
#[CoversClass(HtmlMiddleware::class)]
2931
class HtmlMiddlewareTest extends TestCase
3032
{
3133
/**

tests/TestCase/Panel/ConfigurationPanelTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,14 @@
1818
use BEdita\DevTools\Panel\ConfigurationPanel;
1919
use Cake\Core\Configure;
2020
use Cake\TestSuite\TestCase;
21+
use PHPUnit\Framework\Attributes\CoversClass;
22+
use PHPUnit\Framework\Attributes\CoversMethod;
2123

2224
/**
23-
* Test configuration panel.
24-
*
25-
* @coversDefaultClass \BEdita\DevTools\Panel\ConfigurationPanel
25+
* {@see BEdita\DevTools\Panel\ConfigurationPanel} Test Case
2626
*/
27+
#[CoversClass(ConfigurationPanel::class)]
28+
#[CoversMethod(ConfigurationPanel::class, 'initialize')]
2729
class ConfigurationPanelTest extends TestCase
2830
{
2931
/**
@@ -62,7 +64,6 @@ public function tearDown(): void
6264
* Check data being serialized in panel.
6365
*
6466
* @return void
65-
* @covers ::initialize()
6667
*/
6768
public function testData(): void
6869
{

tests/TestCase/PluginTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@
2323
use Cake\Http\MiddlewareQueue;
2424
use Cake\Http\ServerRequest;
2525
use Cake\Routing\Middleware\AssetMiddleware;
26+
use PHPUnit\Framework\Attributes\CoversClass;
27+
use PHPUnit\Framework\Attributes\CoversMethod;
28+
use PHPUnit\Framework\Attributes\DataProvider;
2629
use PHPUnit\Framework\TestCase;
2730

2831
/**
2932
* Test {@see \BEdita\DevTools\Plugin}.
30-
*
31-
* @coversDefaultClass \BEdita\DevTools\Plugin
3233
*/
34+
#[CoversClass(Plugin::class)]
35+
#[CoversMethod(Plugin::class, 'bootstrap')]
36+
#[CoversMethod(Plugin::class, 'middleware')]
3337
class PluginTest extends TestCase
3438
{
3539
/**
@@ -53,7 +57,6 @@ protected function setUp(): void
5357
* Test {@see Plugin::bootstrap()} method.
5458
*
5559
* @return void
56-
* @covers ::bootstrap()
5760
*/
5861
public function testBootstrap(): void
5962
{
@@ -105,9 +108,8 @@ public static function middlewareProvider(): array
105108
* @param class-string[] $expected Expected middleware queue.
106109
* @param bool|null $acceptHtml Value of `Accept.html` configuration.
107110
* @return void
108-
* @dataProvider middlewareProvider()
109-
* @covers ::middleware()
110111
*/
112+
#[DataProvider('middlewareProvider')]
111113
public function testMiddleware(array $expected, ?bool $acceptHtml): void
112114
{
113115
$queue = new MiddlewareQueue();

tests/bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@
5858
]);
5959

6060
Cache::setConfig([
61-
'_cake_core_' => [
61+
'_cake_translations_' => [
6262
'engine' => 'File',
63-
'prefix' => 'cake_core_',
63+
'prefix' => 'cake_translations_',
6464
'serialize' => true,
6565
],
6666
'_cake_model_' => [

0 commit comments

Comments
 (0)