From 941d3318730ffc4beb13b54df23511fa2d623fcf Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 11 Oct 2024 12:59:51 +0530 Subject: [PATCH 1/3] Update tests to account for changes in CakePHP 5.1 --- composer.json | 2 +- tests/TestCase/Command/CompileCommandTest.php | 4 +++- .../Twig/Extension/StringsExtensionTest.php | 13 ++++++++++--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index 2482e5d..884e6f2 100644 --- a/composer.json +++ b/composer.json @@ -33,7 +33,7 @@ "cakephp/plugin-installer": "^1.3", "michelf/php-markdown": "^1.9", "mikey179/vfsstream": "^1.6.10", - "phpunit/phpunit": "^10.1.0" + "phpunit/phpunit": "^10.5.5 || ^11.1.3" }, "conflict": { "wyrihaximus/twig-view": "*" diff --git a/tests/TestCase/Command/CompileCommandTest.php b/tests/TestCase/Command/CompileCommandTest.php index fd24ee1..eeec76e 100644 --- a/tests/TestCase/Command/CompileCommandTest.php +++ b/tests/TestCase/Command/CompileCommandTest.php @@ -39,6 +39,8 @@ public function setUp(): void Router::reload(); Configure::write('App.encoding', 'UTF-8'); + + $this->loadPlugins(['Cake/TwigView']); } /** @@ -85,7 +87,7 @@ public function testFile() */ public function testPlugin() { - $this->loadPlugins(['TestTwigView']); + $this->loadPlugins(['Cake/TwigView', 'TestTwigView']); $this->exec('twig-view compile plugin TestTwigView'); $this->assertExitSuccess(); diff --git a/tests/TestCase/Twig/Extension/StringsExtensionTest.php b/tests/TestCase/Twig/Extension/StringsExtensionTest.php index c5ea73b..b024df1 100644 --- a/tests/TestCase/Twig/Extension/StringsExtensionTest.php +++ b/tests/TestCase/Twig/Extension/StringsExtensionTest.php @@ -19,6 +19,7 @@ namespace Cake\TwigView\Test\TestCase\Twig\Extension; use Cake\TwigView\Twig\Extension\StringsExtension; +use Cake\Utility\Text; class StringsExtensionTest extends AbstractExtensionTest { @@ -98,7 +99,9 @@ public function testFilterTail() $input = 'Bob is 65 years old.'; $callable = $this->getFilter('tail')->getCallable(); $result = call_user_func_array($callable, [$input, 7]); - $this->assertSame('...old.', $result); + // Cake >= 5.1 '…s old.' + // Cake < 5.1 '...old.' + $this->assertSame(Text::tail($input, 7), $result); } public function testFilterTruncate() @@ -106,7 +109,9 @@ public function testFilterTruncate() $input = 'Bob is 65 years old.'; $callable = $this->getFilter('truncate')->getCallable(); $result = call_user_func_array($callable, [$input, 7]); - $this->assertSame('Bob ...', $result); + // Cake >= 5.1 'Bob is…' + // Cake < 5.1 'Bob ...' + $this->assertSame(Text::truncate($input, 7), $result); } public function testFilterExcerpt() @@ -114,7 +119,9 @@ public function testFilterExcerpt() $input = 'Bob is 65 years old.'; $callable = $this->getFilter('excerpt')->getCallable(); $result = call_user_func_array($callable, [$input, '65', 4]); - $this->assertSame('... is 65 yea...', $result); + // Cake >= 5.1 '… is 65 yea…' + // Cake < 5.1 '... is 65 yea...' + $this->assertSame(Text::excerpt($input, '65', 4), $result); } public function testFilterToList() From 1716265e87a3e26da39900d566fffea7f489871a Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 11 Oct 2024 13:19:48 +0530 Subject: [PATCH 2/3] Bump up phpstan and psalm --- .phive/phars.xml | 4 ++-- phpstan.neon | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.phive/phars.xml b/.phive/phars.xml index 1f56b2b..a6a3cbe 100644 --- a/.phive/phars.xml +++ b/.phive/phars.xml @@ -1,5 +1,5 @@ - - + + diff --git a/phpstan.neon b/phpstan.neon index fcfb25f..6feb634 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,9 +1,10 @@ parameters: level: 6 - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false treatPhpDocTypesAsCertain: false bootstrapFiles: - tests/bootstrap.php paths: - src/ + ignoreErrors: + - + identifier: missingType.iterableValue From 53c4336787bcb112ae2475cb95699d1e0ee9db7e Mon Sep 17 00:00:00 2001 From: ADmad Date: Fri, 11 Oct 2024 13:20:10 +0530 Subject: [PATCH 3/3] remove unneeded dependency --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 884e6f2..274e32e 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,6 @@ "require-dev": { "cakephp/cakephp-codesniffer": "^5.0", "cakephp/debug_kit": "^5.0", - "cakephp/plugin-installer": "^1.3", "michelf/php-markdown": "^1.9", "mikey179/vfsstream": "^1.6.10", "phpunit/phpunit": "^10.5.5 || ^11.1.3"