aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php')
-rw-r--r--tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php b/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php
new file mode 100644
index 00000000..34547120
--- /dev/null
+++ b/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php
@@ -0,0 +1,62 @@
1<?php
2
3declare(strict_types=1);
4
5namespace Shaarli\Front\Controller\Admin\ShaarePublishControllerTest;
6
7use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper;
8use Shaarli\Front\Controller\Admin\ShaarePublishController;
9use Shaarli\Http\HttpAccess;
10use Shaarli\Http\MetadataRetriever;
11use Shaarli\TestCase;
12use Slim\Http\Request;
13use Slim\Http\Response;
14
15class DisplayCreateBatchFormTest extends TestCase
16{
17 use FrontAdminControllerMockHelper;
18
19 /** @var ShaarePublishController */
20 protected $controller;
21
22 public function setUp(): void
23 {
24 $this->createContainer();
25
26 $this->container->httpAccess = $this->createMock(HttpAccess::class);
27 $this->container->metadataRetriever = $this->createMock(MetadataRetriever::class);
28 $this->controller = new ShaarePublishController($this->container);
29 }
30
31 /**
32 * TODO
33 */
34 public function testDisplayCreateFormBatch(): void
35 {
36 $urls = [
37 'https://domain1.tld/url1',
38 'https://domain2.tld/url2',
39 'https://domain3.tld/url3',
40 ];
41
42 $request = $this->createMock(Request::class);
43 $request->method('getParam')->willReturnCallback(function (string $key) use ($urls): ?string {
44 return $key === 'urls' ? implode(PHP_EOL, $urls) : null;
45 });
46 $response = new Response();
47
48 $assignedVariables = [];
49 $this->assignTemplateVars($assignedVariables);
50
51 $result = $this->controller->displayCreateBatchForms($request, $response);
52
53 static::assertSame(200, $result->getStatusCode());
54 static::assertSame('editlink.batch', (string) $result->getBody());
55
56 static::assertTrue($assignedVariables['batch_mode']);
57 static::assertCount(3, $assignedVariables['links']);
58 static::assertSame($urls[0], $assignedVariables['links'][0]['link']['url']);
59 static::assertSame($urls[1], $assignedVariables['links'][1]['link']['url']);
60 static::assertSame($urls[2], $assignedVariables['links'][2]['link']['url']);
61 }
62}