diff options
author | ArthurHoaro <arthur@hoa.ro> | 2020-10-10 17:40:26 +0200 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2020-10-27 20:11:30 +0100 |
commit | 5d8de7587d67b5c3e5d1fed8562d9b87ecde80c1 (patch) | |
tree | 2236e571035332a63f87a09222f2278b93f63515 /tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php | |
parent | b8e5a253ab5521ce2be6c0d3e04e0101527df3c1 (diff) | |
download | Shaarli-5d8de7587d67b5c3e5d1fed8562d9b87ecde80c1.tar.gz Shaarli-5d8de7587d67b5c3e5d1fed8562d9b87ecde80c1.tar.zst Shaarli-5d8de7587d67b5c3e5d1fed8562d9b87ecde80c1.zip |
Feature: bulk creation of bookmarks
This changes creates a new form in addlink page allowing to create
multiple bookmarks at once more easily. It focuses on re-using as much
existing code and template component as possible.
These changes includes:
- a new form in addlink (hidden behind a button by default),
containing a text area for URL, and tags/private status to apply to
created links
- this form displays a new template called editlink.batch, itself
including editlink template multiple times
- User interation in this new templates are handle by a new JS script
(shaare-batch.js) making AJAX requests, and therefore does not need page
reloading
- ManageShaareController has been split into 3 distinct controllers:
+ ShaareAdd: displays addlink template
+ ShaareManage: various operation applied on existing shaares
(change visibility, pin, deletion, etc.)
+ ShaarePublish: handles creation/edit forms and saving Shaare's
form
- Updated translations
Fixes #137
Diffstat (limited to 'tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php')
-rw-r--r-- | tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php | 62 |
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 | |||
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', | ||
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 | } | ||