From 34c8f558e595d4f90e46e3753c8455b0b515771a Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Fri, 23 Oct 2020 13:28:02 +0200 Subject: [PATCH] Bulk creation: ignore blank lines --- application/front/controller/admin/ShaarePublishController.php | 3 +++ .../ShaarePublishControllerTest/DisplayCreateBatchFormTest.php | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/application/front/controller/admin/ShaarePublishController.php b/application/front/controller/admin/ShaarePublishController.php index 65fdcdee..ddcffdc7 100644 --- a/application/front/controller/admin/ShaarePublishController.php +++ b/application/front/controller/admin/ShaarePublishController.php @@ -46,6 +46,9 @@ public function displayCreateBatchForms(Request $request, Response $response): R $links = []; foreach ($urls as $url) { + if (empty($url)) { + continue; + } $link = $this->buildLinkDataFromUrl($request, $url); $data = $this->buildFormData($link, $link['linkIsNew'], $request); $data['token'] = $this->container->sessionManager->generateToken(); diff --git a/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php b/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php index 34547120..ce8e112b 100644 --- a/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php +++ b/tests/front/controller/admin/ShaarePublishControllerTest/DisplayCreateBatchFormTest.php @@ -36,6 +36,7 @@ public function testDisplayCreateFormBatch(): void $urls = [ 'https://domain1.tld/url1', 'https://domain2.tld/url2', + ' ', 'https://domain3.tld/url3', ]; @@ -57,6 +58,6 @@ public function testDisplayCreateFormBatch(): void static::assertCount(3, $assignedVariables['links']); static::assertSame($urls[0], $assignedVariables['links'][0]['link']['url']); static::assertSame($urls[1], $assignedVariables['links'][1]['link']['url']); - static::assertSame($urls[2], $assignedVariables['links'][2]['link']['url']); + static::assertSame($urls[3], $assignedVariables['links'][2]['link']['url']); } }