From 9f5755823cf205b827149407f4e5a62c075d72cc Mon Sep 17 00:00:00 2001 From: Demian Katz <demian.katz@villanova.edu> Date: Thu, 4 Oct 2018 09:27:19 -0400 Subject: [PATCH] Fix bug: login followup not handled correctly by bulk actions. --- .../src/VuFind/Controller/CartController.php | 5 +- .../src/VuFindTest/Mink/FavoritesTest.php | 50 ++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/module/VuFind/src/VuFind/Controller/CartController.php b/module/VuFind/src/VuFind/Controller/CartController.php index 68980fb2a00..db97500faf4 100644 --- a/module/VuFind/src/VuFind/Controller/CartController.php +++ b/module/VuFind/src/VuFind/Controller/CartController.php @@ -213,7 +213,10 @@ class CartController extends AbstractBase } elseif (strlen($this->params()->fromPost('export', '')) > 0) { $action = 'Export'; } else { - throw new \Exception('Unrecognized bulk action.'); + $action = $this->followup()->retrieveAndClear('cartAction', null); + if (empty($action)) { + throw new \Exception('Unrecognized bulk action.'); + } } return $this->forwardTo($controller, $action); } diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php index 9b7272c2ee8..94248564d81 100644 --- a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/FavoritesTest.php @@ -454,6 +454,7 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase // Now do it for real. $this->selectAllItemsInList($page); $button->click(); + $this->snooze(); $this->findCssAndSetValue($page, '.modal #email_to', 'tester@vufind.org'); $this->findCssAndSetValue($page, '.modal #email_from', 'asdf@vufind.org'); $this->findCssAndSetValue($page, '.modal #email_message', 'message'); @@ -527,7 +528,54 @@ class FavoritesTest extends \VuFindTest\Unit\MinkTestCase } /** - * Test that the print control works. + * Test that it is possible to email a public list. + * + * @return void + */ + public function testEmailPublicList() + { + $page = $this->setupBulkTest(); + + // Click on the first list and make it public: + $link = $this->findAndAssertLink($page, 'Test List'); + $link->click(); + $this->snooze(); + $button = $this->findAndAssertLink($page, 'Edit List'); + $button->click(); + $this->snooze(); + $this->findCss($page, '#list_public_1')->click(); // radio button + $this->findCss($page, 'input[name="submit"]')->click(); // submit button + $this->snooze(); + + // Now log out: + $this->findCss($page, '.logoutOptions a.logout')->click(); + $this->snooze(); + + // Now try to email the list: + $this->selectAllItemsInList($page); + $this->findCss($page, '[name=bulkActionForm] .btn-group [name=email]') + ->click(); + $this->snooze(); + + // Log in as different user: + $this->fillInLoginForm($page, 'username2', 'test'); + $this->submitLoginForm($page); + + // Send the email: + $this->findCssAndSetValue($page, '.modal #email_to', 'tester@vufind.org'); + $this->findCssAndSetValue($page, '.modal #email_from', 'asdf@vufind.org'); + $this->findCssAndSetValue($page, '.modal #email_message', 'message'); + $this->findCss($page, '.modal-body .btn.btn-primary')->click(); + $this->snooze(); + // Check for confirmation message + $this->assertEquals( + 'Your item(s) were emailed', + $this->findCss($page, '.modal .alert-success')->getText() + ); + } + + /** + * Test that the bulk delete control works. * * @return void */ -- GitLab