diff --git a/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchActionsTest.php b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchActionsTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1c539093ca9bf9a78f4ba9eb99b0bbed2e922bee --- /dev/null +++ b/module/VuFind/tests/integration-tests/src/VuFindTest/Mink/SearchActionsTest.php @@ -0,0 +1,114 @@ +<?php +/** + * Mink search actions test class. + * + * PHP version 5 + * + * Copyright (C) Villanova University 2011. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +namespace VuFindTest\Mink; + +/** + * Mink search actions test class. + * + * @category VuFind2 + * @package Tests + * @author Demian Katz <demian.katz@villanova.edu> + * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License + * @link http://www.vufind.org Main Page + */ +class SearchActionsTest extends \VuFindTest\Unit\MinkTestCase +{ + use \VuFindTest\Unit\UserCreationTrait; + + /** + * Standard setup method. + * + * @return void + */ + public static function setUpBeforeClass() + { + return static::failIfUsersExist(); + } + + /** + * Standard setup method. + * + * @return void + */ + public function setUp() + { + // Give up if we're not running in CI: + if (!$this->continuousIntegrationRunning()) { + return $this->markTestSkipped('Continuous integration not running.'); + } + } + + /** + * Search for the specified query. + * + * @param string $query Search term(s) + * + * @return \Behat\Mink\Element\Element + */ + protected function performSearch($query) + { + $session = $this->getMinkSession(); + $session->visit($this->getVuFindUrl() . '/Search/Home'); + $page = $session->getPage(); + $this->findCss($page, '.searchForm [name="lookfor"]')->setValue($query); + $this->findCss($page, '.btn.btn-primary')->click(); + $this->snooze(); + return $page; + } + + /** + * Test saving and clearing a search. + * + * @return void + */ + public function testSaveSearch() + { + $page = $this->performSearch('test'); + $this->findCss($page, '.fa.fa-save')->click(); + $this->snooze(); + $this->findCss($page, '.createAccountLink')->click(); + $this->snooze(); + $this->fillInAccountForm($page); + $this->findCss($page, 'input.btn.btn-primary')->click(); + $this->snooze(); + $this->assertEquals( + 'Search saved successfully.', + $this->findCss($page, '.alert.alert-success')->getText() + ); + } + + /** + * Standard teardown method. + * + * @return void + */ + public static function tearDownAfterClass() + { + static::removeUsers(['username1']); + } +}