aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller/visitor
diff options
context:
space:
mode:
Diffstat (limited to 'tests/front/controller/visitor')
-rw-r--r--tests/front/controller/visitor/BookmarkListControllerTest.php29
-rw-r--r--tests/front/controller/visitor/DailyControllerTest.php45
-rw-r--r--tests/front/controller/visitor/PictureWallControllerTest.php7
3 files changed, 49 insertions, 32 deletions
diff --git a/tests/front/controller/visitor/BookmarkListControllerTest.php b/tests/front/controller/visitor/BookmarkListControllerTest.php
index dec938f2..0fbab9d4 100644
--- a/tests/front/controller/visitor/BookmarkListControllerTest.php
+++ b/tests/front/controller/visitor/BookmarkListControllerTest.php
@@ -6,6 +6,7 @@ namespace Shaarli\Front\Controller\Visitor;
6 6
7use Shaarli\Bookmark\Bookmark; 7use Shaarli\Bookmark\Bookmark;
8use Shaarli\Bookmark\Exception\BookmarkNotFoundException; 8use Shaarli\Bookmark\Exception\BookmarkNotFoundException;
9use Shaarli\Bookmark\SearchResult;
9use Shaarli\Config\ConfigManager; 10use Shaarli\Config\ConfigManager;
10use Shaarli\Security\LoginManager; 11use Shaarli\Security\LoginManager;
11use Shaarli\TestCase; 12use Shaarli\TestCase;
@@ -45,13 +46,15 @@ class BookmarkListControllerTest extends TestCase
45 ['searchtags' => '', 'searchterm' => ''], 46 ['searchtags' => '', 'searchterm' => ''],
46 null, 47 null,
47 false, 48 false,
48 false 49 false,
50 false,
51 ['offset' => 0, 'limit' => 2]
49 ) 52 )
50 ->willReturn([ 53 ->willReturn(SearchResult::getSearchResult([
51 (new Bookmark())->setId(1)->setUrl('http://url1.tld')->setTitle('Title 1'), 54 (new Bookmark())->setId(1)->setUrl('http://url1.tld')->setTitle('Title 1'),
52 (new Bookmark())->setId(2)->setUrl('http://url2.tld')->setTitle('Title 2'), 55 (new Bookmark())->setId(2)->setUrl('http://url2.tld')->setTitle('Title 2'),
53 (new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'), 56 (new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'),
54 ] 57 ], 0, 2)
55 ); 58 );
56 59
57 $this->container->sessionManager 60 $this->container->sessionManager
@@ -119,13 +122,15 @@ class BookmarkListControllerTest extends TestCase
119 ['searchtags' => '', 'searchterm' => ''], 122 ['searchtags' => '', 'searchterm' => ''],
120 null, 123 null,
121 false, 124 false,
122 false 125 false,
126 false,
127 ['offset' => 2, 'limit' => 2]
123 ) 128 )
124 ->willReturn([ 129 ->willReturn(SearchResult::getSearchResult([
125 (new Bookmark())->setId(1)->setUrl('http://url1.tld')->setTitle('Title 1'), 130 (new Bookmark())->setId(1)->setUrl('http://url1.tld')->setTitle('Title 1'),
126 (new Bookmark())->setId(2)->setUrl('http://url2.tld')->setTitle('Title 2'), 131 (new Bookmark())->setId(2)->setUrl('http://url2.tld')->setTitle('Title 2'),
127 (new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'), 132 (new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'),
128 ]) 133 ], 2, 2))
129 ; 134 ;
130 135
131 $this->container->sessionManager 136 $this->container->sessionManager
@@ -207,13 +212,15 @@ class BookmarkListControllerTest extends TestCase
207 ['searchtags' => 'abc@def', 'searchterm' => 'ghi jkl'], 212 ['searchtags' => 'abc@def', 'searchterm' => 'ghi jkl'],
208 'private', 213 'private',
209 false, 214 false,
210 true 215 true,
216 false,
217 ['offset' => 0, 'limit' => 2]
211 ) 218 )
212 ->willReturn([ 219 ->willReturn(SearchResult::getSearchResult([
213 (new Bookmark())->setId(1)->setUrl('http://url1.tld')->setTitle('Title 1'), 220 (new Bookmark())->setId(1)->setUrl('http://url1.tld')->setTitle('Title 1'),
214 (new Bookmark())->setId(2)->setUrl('http://url2.tld')->setTitle('Title 2'), 221 (new Bookmark())->setId(2)->setUrl('http://url2.tld')->setTitle('Title 2'),
215 (new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'), 222 (new Bookmark())->setId(3)->setUrl('http://url3.tld')->setTitle('Title 3'),
216 ]) 223 ], 0, 2))
217 ; 224 ;
218 225
219 $result = $this->controller->index($request, $response); 226 $result = $this->controller->index($request, $response);
@@ -358,13 +365,13 @@ class BookmarkListControllerTest extends TestCase
358 $this->container->bookmarkService 365 $this->container->bookmarkService
359 ->expects(static::once()) 366 ->expects(static::once())
360 ->method('search') 367 ->method('search')
361 ->willReturn([ 368 ->willReturn(SearchResult::getSearchResult([
362 (new Bookmark())->setId(1)->setUrl('https://url1.tld')->setTitle('Title 1')->setThumbnail(false), 369 (new Bookmark())->setId(1)->setUrl('https://url1.tld')->setTitle('Title 1')->setThumbnail(false),
363 $b1 = (new Bookmark())->setId(2)->setUrl('https://url2.tld')->setTitle('Title 2'), 370 $b1 = (new Bookmark())->setId(2)->setUrl('https://url2.tld')->setTitle('Title 2'),
364 (new Bookmark())->setId(3)->setUrl('https://url3.tld')->setTitle('Title 3')->setThumbnail(false), 371 (new Bookmark())->setId(3)->setUrl('https://url3.tld')->setTitle('Title 3')->setThumbnail(false),
365 $b2 = (new Bookmark())->setId(2)->setUrl('https://url4.tld')->setTitle('Title 4'), 372 $b2 = (new Bookmark())->setId(2)->setUrl('https://url4.tld')->setTitle('Title 4'),
366 (new Bookmark())->setId(2)->setUrl('ftp://url5.tld', ['ftp'])->setTitle('Title 5'), 373 (new Bookmark())->setId(2)->setUrl('ftp://url5.tld', ['ftp'])->setTitle('Title 5'),
367 ]) 374 ]))
368 ; 375 ;
369 $this->container->bookmarkService 376 $this->container->bookmarkService
370 ->expects(static::exactly(2)) 377 ->expects(static::exactly(2))
diff --git a/tests/front/controller/visitor/DailyControllerTest.php b/tests/front/controller/visitor/DailyControllerTest.php
index 70fbce54..821ba321 100644
--- a/tests/front/controller/visitor/DailyControllerTest.php
+++ b/tests/front/controller/visitor/DailyControllerTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
5namespace Shaarli\Front\Controller\Visitor; 5namespace Shaarli\Front\Controller\Visitor;
6 6
7use Shaarli\Bookmark\Bookmark; 7use Shaarli\Bookmark\Bookmark;
8use Shaarli\Bookmark\SearchResult;
8use Shaarli\Feed\CachedPage; 9use Shaarli\Feed\CachedPage;
9use Shaarli\TestCase; 10use Shaarli\TestCase;
10use Slim\Http\Request; 11use Slim\Http\Request;
@@ -347,13 +348,15 @@ class DailyControllerTest extends TestCase
347 $request = $this->createMock(Request::class); 348 $request = $this->createMock(Request::class);
348 $response = new Response(); 349 $response = new Response();
349 350
350 $this->container->bookmarkService->expects(static::once())->method('search')->willReturn([ 351 $this->container->bookmarkService->expects(static::once())->method('search')->willReturn(
351 (new Bookmark())->setId(1)->setCreated($dates[0])->setUrl('http://domain.tld/1'), 352 SearchResult::getSearchResult([
352 (new Bookmark())->setId(2)->setCreated($dates[1])->setUrl('http://domain.tld/2'), 353 (new Bookmark())->setId(1)->setCreated($dates[0])->setUrl('http://domain.tld/1'),
353 (new Bookmark())->setId(3)->setCreated($dates[1])->setUrl('http://domain.tld/3'), 354 (new Bookmark())->setId(2)->setCreated($dates[1])->setUrl('http://domain.tld/2'),
354 (new Bookmark())->setId(4)->setCreated($dates[2])->setUrl('http://domain.tld/4'), 355 (new Bookmark())->setId(3)->setCreated($dates[1])->setUrl('http://domain.tld/3'),
355 (new Bookmark())->setId(5)->setCreated($dates[3])->setUrl('http://domain.tld/5'), 356 (new Bookmark())->setId(4)->setCreated($dates[2])->setUrl('http://domain.tld/4'),
356 ]); 357 (new Bookmark())->setId(5)->setCreated($dates[3])->setUrl('http://domain.tld/5'),
358 ])
359 );
357 360
358 $this->container->pageCacheManager 361 $this->container->pageCacheManager
359 ->expects(static::once()) 362 ->expects(static::once())
@@ -454,7 +457,9 @@ class DailyControllerTest extends TestCase
454 $request = $this->createMock(Request::class); 457 $request = $this->createMock(Request::class);
455 $response = new Response(); 458 $response = new Response();
456 459
457 $this->container->bookmarkService->expects(static::once())->method('search')->willReturn([]); 460 $this->container->bookmarkService
461 ->expects(static::once())->method('search')
462 ->willReturn(SearchResult::getSearchResult([]));
458 463
459 // Save RainTPL assigned variables 464 // Save RainTPL assigned variables
460 $assignedVariables = []; 465 $assignedVariables = [];
@@ -613,11 +618,13 @@ class DailyControllerTest extends TestCase
613 }); 618 });
614 $response = new Response(); 619 $response = new Response();
615 620
616 $this->container->bookmarkService->expects(static::once())->method('search')->willReturn([ 621 $this->container->bookmarkService->expects(static::once())->method('search')->willReturn(
617 (new Bookmark())->setId(1)->setCreated($dates[0])->setUrl('http://domain.tld/1'), 622 SearchResult::getSearchResult([
618 (new Bookmark())->setId(2)->setCreated($dates[1])->setUrl('http://domain.tld/2'), 623 (new Bookmark())->setId(1)->setCreated($dates[0])->setUrl('http://domain.tld/1'),
619 (new Bookmark())->setId(3)->setCreated($dates[1])->setUrl('http://domain.tld/3'), 624 (new Bookmark())->setId(2)->setCreated($dates[1])->setUrl('http://domain.tld/2'),
620 ]); 625 (new Bookmark())->setId(3)->setCreated($dates[1])->setUrl('http://domain.tld/3'),
626 ])
627 );
621 628
622 // Save RainTPL assigned variables 629 // Save RainTPL assigned variables
623 $assignedVariables = []; 630 $assignedVariables = [];
@@ -674,11 +681,13 @@ class DailyControllerTest extends TestCase
674 }); 681 });
675 $response = new Response(); 682 $response = new Response();
676 683
677 $this->container->bookmarkService->expects(static::once())->method('search')->willReturn([ 684 $this->container->bookmarkService->expects(static::once())->method('search')->willReturn(
678 (new Bookmark())->setId(1)->setCreated($dates[0])->setUrl('http://domain.tld/1'), 685 SearchResult::getSearchResult([
679 (new Bookmark())->setId(2)->setCreated($dates[1])->setUrl('http://domain.tld/2'), 686 (new Bookmark())->setId(1)->setCreated($dates[0])->setUrl('http://domain.tld/1'),
680 (new Bookmark())->setId(3)->setCreated($dates[1])->setUrl('http://domain.tld/3'), 687 (new Bookmark())->setId(2)->setCreated($dates[1])->setUrl('http://domain.tld/2'),
681 ]); 688 (new Bookmark())->setId(3)->setCreated($dates[1])->setUrl('http://domain.tld/3'),
689 ])
690 );
682 691
683 // Save RainTPL assigned variables 692 // Save RainTPL assigned variables
684 $assignedVariables = []; 693 $assignedVariables = [];
diff --git a/tests/front/controller/visitor/PictureWallControllerTest.php b/tests/front/controller/visitor/PictureWallControllerTest.php
index b868231d..429e99a2 100644
--- a/tests/front/controller/visitor/PictureWallControllerTest.php
+++ b/tests/front/controller/visitor/PictureWallControllerTest.php
@@ -5,6 +5,7 @@ declare(strict_types=1);
5namespace Shaarli\Front\Controller\Visitor; 5namespace Shaarli\Front\Controller\Visitor;
6 6
7use Shaarli\Bookmark\Bookmark; 7use Shaarli\Bookmark\Bookmark;
8use Shaarli\Bookmark\SearchResult;
8use Shaarli\Config\ConfigManager; 9use Shaarli\Config\ConfigManager;
9use Shaarli\Front\Exception\ThumbnailsDisabledException; 10use Shaarli\Front\Exception\ThumbnailsDisabledException;
10use Shaarli\TestCase; 11use Shaarli\TestCase;
@@ -50,17 +51,17 @@ class PictureWallControllerTest extends TestCase
50 $this->container->bookmarkService 51 $this->container->bookmarkService
51 ->expects(static::once()) 52 ->expects(static::once())
52 ->method('search') 53 ->method('search')
53 ->willReturnCallback(function (array $parameters, ?string $visibility): array { 54 ->willReturnCallback(function (array $parameters, ?string $visibility): SearchResult {
54 // Visibility is set through the container, not the call 55 // Visibility is set through the container, not the call
55 static::assertNull($visibility); 56 static::assertNull($visibility);
56 57
57 // No query parameters 58 // No query parameters
58 if (count($parameters) === 0) { 59 if (count($parameters) === 0) {
59 return [ 60 return SearchResult::getSearchResult([
60 (new Bookmark())->setId(1)->setUrl('http://url.tld')->setThumbnail('thumb1'), 61 (new Bookmark())->setId(1)->setUrl('http://url.tld')->setThumbnail('thumb1'),
61 (new Bookmark())->setId(2)->setUrl('http://url2.tld'), 62 (new Bookmark())->setId(2)->setUrl('http://url2.tld'),
62 (new Bookmark())->setId(3)->setUrl('http://url3.tld')->setThumbnail('thumb2'), 63 (new Bookmark())->setId(3)->setUrl('http://url3.tld')->setThumbnail('thumb2'),
63 ]; 64 ]);
64 } 65 }
65 }) 66 })
66 ; 67 ;