Skip to content

Commit b11df8e

Browse files
authored
Merge pull request #103 from cakephp/chore/tests
Update tests to account for changes in CakePHP 5.1
2 parents 9293c13 + 53c4336 commit b11df8e

File tree

5 files changed

+19
-10
lines changed

5 files changed

+19
-10
lines changed

.phive/phars.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phive xmlns="https://phar.io/phive">
3-
<phar name="phpstan" version="1.10.56" installed="1.10.56" location="./tools/phpstan" copy="false"/>
4-
<phar name="psalm" version="5.20.0" installed="5.20.0" location="./tools/psalm" copy="false"/>
3+
<phar name="phpstan" version="1.12.6" installed="1.12.6" location="./tools/phpstan" copy="false"/>
4+
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
55
</phive>

composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,9 @@
3030
"require-dev": {
3131
"cakephp/cakephp-codesniffer": "^5.0",
3232
"cakephp/debug_kit": "^5.0",
33-
"cakephp/plugin-installer": "^1.3",
3433
"michelf/php-markdown": "^1.9",
3534
"mikey179/vfsstream": "^1.6.10",
36-
"phpunit/phpunit": "^10.1.0"
35+
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
3736
},
3837
"conflict": {
3938
"wyrihaximus/twig-view": "*"

phpstan.neon

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
parameters:
22
level: 6
3-
checkMissingIterableValueType: false
4-
checkGenericClassInNonGenericObjectType: false
53
treatPhpDocTypesAsCertain: false
64
bootstrapFiles:
75
- tests/bootstrap.php
86
paths:
97
- src/
8+
ignoreErrors:
9+
-
10+
identifier: missingType.iterableValue

tests/TestCase/Command/CompileCommandTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public function setUp(): void
3939

4040
Router::reload();
4141
Configure::write('App.encoding', 'UTF-8');
42+
43+
$this->loadPlugins(['Cake/TwigView']);
4244
}
4345

4446
/**
@@ -85,7 +87,7 @@ public function testFile()
8587
*/
8688
public function testPlugin()
8789
{
88-
$this->loadPlugins(['TestTwigView']);
90+
$this->loadPlugins(['Cake/TwigView', 'TestTwigView']);
8991

9092
$this->exec('twig-view compile plugin TestTwigView');
9193
$this->assertExitSuccess();

tests/TestCase/Twig/Extension/StringsExtensionTest.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
namespace Cake\TwigView\Test\TestCase\Twig\Extension;
2020

2121
use Cake\TwigView\Twig\Extension\StringsExtension;
22+
use Cake\Utility\Text;
2223

2324
class StringsExtensionTest extends AbstractExtensionTest
2425
{
@@ -98,23 +99,29 @@ public function testFilterTail()
9899
$input = 'Bob is 65 years old.';
99100
$callable = $this->getFilter('tail')->getCallable();
100101
$result = call_user_func_array($callable, [$input, 7]);
101-
$this->assertSame('...old.', $result);
102+
// Cake >= 5.1 '…s old.'
103+
// Cake < 5.1 '...old.'
104+
$this->assertSame(Text::tail($input, 7), $result);
102105
}
103106

104107
public function testFilterTruncate()
105108
{
106109
$input = 'Bob is 65 years old.';
107110
$callable = $this->getFilter('truncate')->getCallable();
108111
$result = call_user_func_array($callable, [$input, 7]);
109-
$this->assertSame('Bob ...', $result);
112+
// Cake >= 5.1 'Bob is…'
113+
// Cake < 5.1 'Bob ...'
114+
$this->assertSame(Text::truncate($input, 7), $result);
110115
}
111116

112117
public function testFilterExcerpt()
113118
{
114119
$input = 'Bob is 65 years old.';
115120
$callable = $this->getFilter('excerpt')->getCallable();
116121
$result = call_user_func_array($callable, [$input, '65', 4]);
117-
$this->assertSame('... is 65 yea...', $result);
122+
// Cake >= 5.1 '… is 65 yea…'
123+
// Cake < 5.1 '... is 65 yea...'
124+
$this->assertSame(Text::excerpt($input, '65', 4), $result);
118125
}
119126

120127
public function testFilterToList()

0 commit comments

Comments
 (0)