aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller/visitor/DailyControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/front/controller/visitor/DailyControllerTest.php')
-rw-r--r--tests/front/controller/visitor/DailyControllerTest.php48
1 files changed, 25 insertions, 23 deletions
diff --git a/tests/front/controller/visitor/DailyControllerTest.php b/tests/front/controller/visitor/DailyControllerTest.php
index cb5b96f3..fc78bc13 100644
--- a/tests/front/controller/visitor/DailyControllerTest.php
+++ b/tests/front/controller/visitor/DailyControllerTest.php
@@ -4,9 +4,9 @@ declare(strict_types=1);
4 4
5namespace Shaarli\Front\Controller\Visitor; 5namespace Shaarli\Front\Controller\Visitor;
6 6
7use PHPUnit\Framework\TestCase;
8use Shaarli\Bookmark\Bookmark; 7use Shaarli\Bookmark\Bookmark;
9use Shaarli\Feed\CachedPage; 8use Shaarli\Feed\CachedPage;
9use Shaarli\TestCase;
10use Slim\Http\Request; 10use Slim\Http\Request;
11use Slim\Http\Response; 11use Slim\Http\Response;
12 12
@@ -78,19 +78,20 @@ class DailyControllerTest extends TestCase
78 78
79 // Make sure that PluginManager hook is triggered 79 // Make sure that PluginManager hook is triggered
80 $this->container->pluginManager 80 $this->container->pluginManager
81 ->expects(static::at(0)) 81 ->expects(static::atLeastOnce())
82 ->method('executeHooks') 82 ->method('executeHooks')
83 ->withConsecutive(['render_daily'])
83 ->willReturnCallback(function (string $hook, array $data, array $param) use ($currentDay): array { 84 ->willReturnCallback(function (string $hook, array $data, array $param) use ($currentDay): array {
84 static::assertSame('render_daily', $hook); 85 if ('render_daily' === $hook) {
86 static::assertArrayHasKey('linksToDisplay', $data);
87 static::assertCount(3, $data['linksToDisplay']);
88 static::assertSame(1, $data['linksToDisplay'][0]['id']);
89 static::assertSame($currentDay->getTimestamp(), $data['day']);
90 static::assertSame('20200510', $data['previousday']);
91 static::assertSame('20200516', $data['nextday']);
85 92
86 static::assertArrayHasKey('linksToDisplay', $data); 93 static::assertArrayHasKey('loggedin', $param);
87 static::assertCount(3, $data['linksToDisplay']); 94 }
88 static::assertSame(1, $data['linksToDisplay'][0]['id']);
89 static::assertSame($currentDay->getTimestamp(), $data['day']);
90 static::assertSame('20200510', $data['previousday']);
91 static::assertSame('20200516', $data['nextday']);
92
93 static::assertArrayHasKey('loggedin', $param);
94 95
95 return $data; 96 return $data;
96 }) 97 })
@@ -203,19 +204,20 @@ class DailyControllerTest extends TestCase
203 204
204 // Make sure that PluginManager hook is triggered 205 // Make sure that PluginManager hook is triggered
205 $this->container->pluginManager 206 $this->container->pluginManager
206 ->expects(static::at(0)) 207 ->expects(static::atLeastOnce())
207 ->method('executeHooks') 208 ->method('executeHooks')
209 ->withConsecutive(['render_daily'])
208 ->willReturnCallback(function (string $hook, array $data, array $param) use ($currentDay): array { 210 ->willReturnCallback(function (string $hook, array $data, array $param) use ($currentDay): array {
209 static::assertSame('render_daily', $hook); 211 if ('render_daily' === $hook) {
210 212 static::assertArrayHasKey('linksToDisplay', $data);
211 static::assertArrayHasKey('linksToDisplay', $data); 213 static::assertCount(1, $data['linksToDisplay']);
212 static::assertCount(1, $data['linksToDisplay']); 214 static::assertSame(1, $data['linksToDisplay'][0]['id']);
213 static::assertSame(1, $data['linksToDisplay'][0]['id']); 215 static::assertSame($currentDay->getTimestamp(), $data['day']);
214 static::assertSame($currentDay->getTimestamp(), $data['day']); 216 static::assertEmpty($data['previousday']);
215 static::assertEmpty($data['previousday']); 217 static::assertEmpty($data['nextday']);
216 static::assertEmpty($data['nextday']);
217 218
218 static::assertArrayHasKey('loggedin', $param); 219 static::assertArrayHasKey('loggedin', $param);
220 }
219 221
220 return $data; 222 return $data;
221 }); 223 });
@@ -281,7 +283,7 @@ class DailyControllerTest extends TestCase
281 283
282 // Make sure that PluginManager hook is triggered 284 // Make sure that PluginManager hook is triggered
283 $this->container->pluginManager 285 $this->container->pluginManager
284 ->expects(static::at(0)) 286 ->expects(static::atLeastOnce())
285 ->method('executeHooks') 287 ->method('executeHooks')
286 ->willReturnCallback(function (string $hook, array $data, array $param): array { 288 ->willReturnCallback(function (string $hook, array $data, array $param): array {
287 return $data; 289 return $data;
@@ -333,7 +335,7 @@ class DailyControllerTest extends TestCase
333 335
334 // Make sure that PluginManager hook is triggered 336 // Make sure that PluginManager hook is triggered
335 $this->container->pluginManager 337 $this->container->pluginManager
336 ->expects(static::at(0)) 338 ->expects(static::atLeastOnce())
337 ->method('executeHooks') 339 ->method('executeHooks')
338 ->willReturnCallback(function (string $hook, array $data, array $param): array { 340 ->willReturnCallback(function (string $hook, array $data, array $param): array {
339 return $data; 341 return $data;