Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update tests to account for changes in CakePHP 5.1 #103

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpstan" version="1.10.56" installed="1.10.56" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.20.0" installed="5.20.0" location="./tools/psalm" copy="false"/>
<phar name="phpstan" version="1.12.6" installed="1.12.6" location="./tools/phpstan" copy="false"/>
<phar name="psalm" version="5.26.1" installed="5.26.1" location="./tools/psalm" copy="false"/>
</phive>
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,9 @@
"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.1.0"
"phpunit/phpunit": "^10.5.5 || ^11.1.3"
},
"conflict": {
"wyrihaximus/twig-view": "*"
Expand Down
5 changes: 3 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
parameters:
level: 6
checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false
treatPhpDocTypesAsCertain: false
bootstrapFiles:
- tests/bootstrap.php
paths:
- src/
ignoreErrors:
-
identifier: missingType.iterableValue
4 changes: 3 additions & 1 deletion tests/TestCase/Command/CompileCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function setUp(): void

Router::reload();
Configure::write('App.encoding', 'UTF-8');

$this->loadPlugins(['Cake/TwigView']);
}

/**
Expand Down Expand Up @@ -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();
Expand Down
13 changes: 10 additions & 3 deletions tests/TestCase/Twig/Extension/StringsExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -98,23 +99,29 @@ 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()
{
$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()
{
$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()
Expand Down