X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tests%2Ffront%2Fcontroller%2Fvisitor%2FFeedControllerTest.php;h=4ae7c9252913a6c36719dbd117ef0954358b5447;hb=a5a9cf23acd1248585173aa32757d9720b5f2d62;hp=fd4679ea0816db16c33a7801996dbee21823bb2e;hpb=2899ebb5b5e82890c877151f5c02045266ac9973;p=github%2Fshaarli%2FShaarli.git diff --git a/tests/front/controller/visitor/FeedControllerTest.php b/tests/front/controller/visitor/FeedControllerTest.php index fd4679ea..4ae7c925 100644 --- a/tests/front/controller/visitor/FeedControllerTest.php +++ b/tests/front/controller/visitor/FeedControllerTest.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace Shaarli\Front\Controller\Visitor; -use PHPUnit\Framework\TestCase; use Shaarli\Feed\FeedBuilder; +use Shaarli\TestCase; use Slim\Http\Request; use Slim\Http\Response; @@ -30,8 +30,6 @@ class FeedControllerTest extends TestCase */ public function testDefaultRssController(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -47,14 +45,16 @@ class FeedControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_feed']) ->willReturnCallback(function (string $hook, array $data, array $param): void { - static::assertSame('render_feed', $hook); - static::assertSame('data', $data['content']); + if ('render_feed' === $hook) { + static::assertSame('data', $data['content']); - static::assertArrayHasKey('loggedin', $param); - static::assertSame('rss', $param['target']); + static::assertArrayHasKey('loggedin', $param); + static::assertSame('feed.rss', $param['target']); + } }) ; @@ -71,8 +71,6 @@ class FeedControllerTest extends TestCase */ public function testDefaultAtomController(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $response = new Response(); @@ -88,14 +86,16 @@ class FeedControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_feed']) ->willReturnCallback(function (string $hook, array $data, array $param): void { - static::assertSame('render_feed', $hook); - static::assertSame('data', $data['content']); + if ('render_feed' === $hook) { + static::assertSame('data', $data['content']); - static::assertArrayHasKey('loggedin', $param); - static::assertSame('atom', $param['target']); + static::assertArrayHasKey('loggedin', $param); + static::assertSame('feed.atom', $param['target']); + } }) ; @@ -112,8 +112,6 @@ class FeedControllerTest extends TestCase */ public function testAtomControllerWithParameters(): void { - $this->createValidContainerMockSet(); - $request = $this->createMock(Request::class); $request->method('getParams')->willReturn(['parameter' => 'value']); $response = new Response(); @@ -130,14 +128,16 @@ class FeedControllerTest extends TestCase // Make sure that PluginManager hook is triggered $this->container->pluginManager - ->expects(static::at(0)) + ->expects(static::atLeastOnce()) ->method('executeHooks') + ->withConsecutive(['render_feed']) ->willReturnCallback(function (string $hook, array $data, array $param): void { - static::assertSame('render_feed', $hook); - static::assertSame('data', $data['content']); + if ('render_feed' === $hook) { + static::assertSame('data', $data['content']); - static::assertArrayHasKey('loggedin', $param); - static::assertSame('atom', $param['target']); + static::assertArrayHasKey('loggedin', $param); + static::assertSame('feed.atom', $param['target']); + } }) ;