]>
Commit | Line | Data |
---|---|---|
5d8de758 A |
1 | <?php |
2 | ||
3 | declare(strict_types=1); | |
4 | ||
5 | namespace Shaarli\Front\Controller\Admin\ShaarePublishControllerTest; | |
6 | ||
7 | use Shaarli\Front\Controller\Admin\FrontAdminControllerMockHelper; | |
8 | use Shaarli\Front\Controller\Admin\ShaarePublishController; | |
9 | use Shaarli\Http\HttpAccess; | |
10 | use Shaarli\Http\MetadataRetriever; | |
11 | use Shaarli\TestCase; | |
12 | use Slim\Http\Request; | |
13 | use Slim\Http\Response; | |
14 | ||
15 | class 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', | |
34c8f558 | 39 | ' ', |
5d8de758 A |
40 | 'https://domain3.tld/url3', |
41 | ]; | |
42 | ||
43 | $request = $this->createMock(Request::class); | |
44 | $request->method('getParam')->willReturnCallback(function (string $key) use ($urls): ?string { | |
45 | return $key === 'urls' ? implode(PHP_EOL, $urls) : null; | |
46 | }); | |
47 | $response = new Response(); | |
48 | ||
49 | $assignedVariables = []; | |
50 | $this->assignTemplateVars($assignedVariables); | |
51 | ||
52 | $result = $this->controller->displayCreateBatchForms($request, $response); | |
53 | ||
54 | static::assertSame(200, $result->getStatusCode()); | |
55 | static::assertSame('editlink.batch', (string) $result->getBody()); | |
56 | ||
57 | static::assertTrue($assignedVariables['batch_mode']); | |
58 | static::assertCount(3, $assignedVariables['links']); | |
59 | static::assertSame($urls[0], $assignedVariables['links'][0]['link']['url']); | |
60 | static::assertSame($urls[1], $assignedVariables['links'][1]['link']['url']); | |
34c8f558 | 61 | static::assertSame($urls[3], $assignedVariables['links'][2]['link']['url']); |
5d8de758 A |
62 | } |
63 | } |