X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=tests%2Ffront%2Fcontroller%2Fvisitor%2FTagCloudControllerTest.php;h=4915573d11cf40f5e35f437a9cda47f0e00bf681;hb=d9d71b10c3bc70a0881d630b37dc4e918c9e812f;hp=9a6a4bc008c386bad89f53d80b4d6ffa6417678d;hpb=af41d5ab5d2bd3ba64d052c997bc6afa6966a63c;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/front/controller/visitor/TagCloudControllerTest.php b/tests/front/controller/visitor/TagCloudControllerTest.php index 9a6a4bc0..4915573d 100644 --- a/tests/front/controller/visitor/TagCloudControllerTest.php +++ b/tests/front/controller/visitor/TagCloudControllerTest.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Shaarli\Front\Controller\Visitor; -use PHPUnit\Framework\TestCase; use Shaarli\Bookmark\BookmarkFilter; +use Shaarli\TestCase; use Slim\Http\Request; use Slim\Http\Response; @@ -53,14 +53,16 @@ class TagCloudControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_tagcloud']) ->willReturnCallback(function (string $hook, array $data, array $param): array { - static::assertSame('render_tagcloud', $hook); - static::assertSame('', $data['search_tags']); - static::assertCount(3, $data['tags']); + if ('render_tagcloud' === $hook) { + static::assertSame('', $data['search_tags']); + static::assertCount(3, $data['tags']); - static::assertArrayHasKey('loggedin', $param); + static::assertArrayHasKey('loggedin', $param); + } return $data; }) @@ -98,7 +100,7 @@ class TagCloudControllerTest extends TestCase ->with() ->willReturnCallback(function (string $key): ?string { if ('searchtags' === $key) { - return 'ghi def'; + return 'ghi@def'; } return null; @@ -124,14 +126,16 @@ class TagCloudControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_tagcloud']) ->willReturnCallback(function (string $hook, array $data, array $param): array { - static::assertSame('render_tagcloud', $hook); - static::assertSame('ghi def', $data['search_tags']); - static::assertCount(1, $data['tags']); + if ('render_tagcloud' === $hook) { + static::assertSame('ghi@def@', $data['search_tags']); + static::assertCount(1, $data['tags']); - static::assertArrayHasKey('loggedin', $param); + static::assertArrayHasKey('loggedin', $param); + } return $data; }) @@ -143,7 +147,7 @@ class TagCloudControllerTest extends TestCase static::assertSame('tag.cloud', (string) $result->getBody()); static::assertSame('ghi def - Tag cloud - Shaarli', $assignedVariables['pagetitle']); - static::assertSame('ghi def', $assignedVariables['search_tags']); + static::assertSame('ghi@def@', $assignedVariables['search_tags']); static::assertCount(1, $assignedVariables['tags']); static::assertArrayHasKey('abc', $assignedVariables['tags']); @@ -175,14 +179,16 @@ class TagCloudControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_tagcloud']) ->willReturnCallback(function (string $hook, array $data, array $param): array { - static::assertSame('render_tagcloud', $hook); - static::assertSame('', $data['search_tags']); - static::assertCount(0, $data['tags']); + if ('render_tagcloud' === $hook) { + static::assertSame('', $data['search_tags']); + static::assertCount(0, $data['tags']); - static::assertArrayHasKey('loggedin', $param); + static::assertArrayHasKey('loggedin', $param); + } return $data; }) @@ -227,14 +233,16 @@ class TagCloudControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_taglist']) ->willReturnCallback(function (string $hook, array $data, array $param): array { - static::assertSame('render_taglist', $hook); - static::assertSame('', $data['search_tags']); - static::assertCount(3, $data['tags']); + if ('render_taglist' === $hook) { + static::assertSame('', $data['search_tags']); + static::assertCount(3, $data['tags']); - static::assertArrayHasKey('loggedin', $param); + static::assertArrayHasKey('loggedin', $param); + } return $data; }) @@ -269,7 +277,7 @@ class TagCloudControllerTest extends TestCase ->with() ->willReturnCallback(function (string $key): ?string { if ('searchtags' === $key) { - return 'ghi def'; + return 'ghi@def'; } elseif ('sort' === $key) { return 'alpha'; } @@ -297,14 +305,16 @@ class TagCloudControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_taglist']) ->willReturnCallback(function (string $hook, array $data, array $param): array { - static::assertSame('render_taglist', $hook); - static::assertSame('ghi def', $data['search_tags']); - static::assertCount(1, $data['tags']); + if ('render_taglist' === $hook) { + static::assertSame('ghi@def@', $data['search_tags']); + static::assertCount(1, $data['tags']); - static::assertArrayHasKey('loggedin', $param); + static::assertArrayHasKey('loggedin', $param); + } return $data; }) @@ -316,7 +326,7 @@ class TagCloudControllerTest extends TestCase static::assertSame('tag.list', (string) $result->getBody()); static::assertSame('ghi def - Tag list - Shaarli', $assignedVariables['pagetitle']); - static::assertSame('ghi def', $assignedVariables['search_tags']); + static::assertSame('ghi@def@', $assignedVariables['search_tags']); static::assertCount(1, $assignedVariables['tags']); static::assertSame(3, $assignedVariables['tags']['abc']); } @@ -344,14 +354,16 @@ class TagCloudControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_taglist']) ->willReturnCallback(function (string $hook, array $data, array $param): array { - static::assertSame('render_taglist', $hook); - static::assertSame('', $data['search_tags']); - static::assertCount(0, $data['tags']); + if ('render_taglist' === $hook) { + static::assertSame('', $data['search_tags']); + static::assertCount(0, $data['tags']); - static::assertArrayHasKey('loggedin', $param); + static::assertArrayHasKey('loggedin', $param); + } return $data; })