]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - tests/front/controller/visitor/FeedControllerTest.php
Compatibility with PHPUnit 9
[github/shaarli/Shaarli.git] / tests / front / controller / visitor / FeedControllerTest.php
index fd4679ea0816db16c33a7801996dbee21823bb2e..4ae7c9252913a6c36719dbd117ef0954358b5447 100644 (file)
@@ -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']);
+                }
             })
         ;