From 5d8de7587d67b5c3e5d1fed8562d9b87ecde80c1 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Sat, 10 Oct 2020 17:40:26 +0200 Subject: 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 --- .../SharePrivateTest.php | 139 --------------------- 1 file changed, 139 deletions(-) delete mode 100644 tests/front/controller/admin/ManageShaareControllerTest/SharePrivateTest.php (limited to 'tests/front/controller/admin/ManageShaareControllerTest/SharePrivateTest.php') diff --git a/tests/front/controller/admin/ManageShaareControllerTest/SharePrivateTest.php b/tests/front/controller/admin/ManageShaareControllerTest/SharePrivateTest.php deleted file mode 100644 index 1e7877c7..00000000 --- a/tests/front/controller/admin/ManageShaareControllerTest/SharePrivateTest.php +++ /dev/null @@ -1,139 +0,0 @@ -createContainer(); - - $this->container->httpAccess = $this->createMock(HttpAccess::class); - $this->controller = new ManageShaareController($this->container); - } - - /** - * Test shaare private with a private bookmark which does not have a key yet. - */ - public function testSharePrivateWithNewPrivateBookmark(): void - { - $hash = 'abcdcef'; - $request = $this->createMock(Request::class); - $response = new Response(); - - $bookmark = (new Bookmark()) - ->setId(123) - ->setUrl('http://domain.tld') - ->setTitle('Title 123') - ->setPrivate(true) - ; - - $this->container->bookmarkService - ->expects(static::once()) - ->method('findByHash') - ->with($hash) - ->willReturn($bookmark) - ; - $this->container->bookmarkService - ->expects(static::once()) - ->method('set') - ->with($bookmark, true) - ->willReturnCallback(function (Bookmark $bookmark): Bookmark { - static::assertSame(32, strlen($bookmark->getAdditionalContentEntry('private_key'))); - - return $bookmark; - }) - ; - - $result = $this->controller->sharePrivate($request, $response, ['hash' => $hash]); - - static::assertSame(302, $result->getStatusCode()); - static::assertRegExp('#/subfolder/shaare/' . $hash . '\?key=\w{32}#', $result->getHeaderLine('Location')); - } - - /** - * Test shaare private with a private bookmark which does already have a key. - */ - public function testSharePrivateWithExistingPrivateBookmark(): void - { - $hash = 'abcdcef'; - $existingKey = 'this is a private key'; - $request = $this->createMock(Request::class); - $response = new Response(); - - $bookmark = (new Bookmark()) - ->setId(123) - ->setUrl('http://domain.tld') - ->setTitle('Title 123') - ->setPrivate(true) - ->addAdditionalContentEntry('private_key', $existingKey) - ; - - $this->container->bookmarkService - ->expects(static::once()) - ->method('findByHash') - ->with($hash) - ->willReturn($bookmark) - ; - $this->container->bookmarkService - ->expects(static::never()) - ->method('set') - ; - - $result = $this->controller->sharePrivate($request, $response, ['hash' => $hash]); - - static::assertSame(302, $result->getStatusCode()); - static::assertSame('/subfolder/shaare/' . $hash . '?key=' . $existingKey, $result->getHeaderLine('Location')); - } - - /** - * Test shaare private with a public bookmark. - */ - public function testSharePrivateWithPublicBookmark(): void - { - $hash = 'abcdcef'; - $request = $this->createMock(Request::class); - $response = new Response(); - - $bookmark = (new Bookmark()) - ->setId(123) - ->setUrl('http://domain.tld') - ->setTitle('Title 123') - ->setPrivate(false) - ; - - $this->container->bookmarkService - ->expects(static::once()) - ->method('findByHash') - ->with($hash) - ->willReturn($bookmark) - ; - $this->container->bookmarkService - ->expects(static::never()) - ->method('set') - ; - - $result = $this->controller->sharePrivate($request, $response, ['hash' => $hash]); - - static::assertSame(302, $result->getStatusCode()); - static::assertSame('/subfolder/shaare/' . $hash, $result->getHeaderLine('Location')); - } -} -- cgit v1.2.3