|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * This file is part of OPUS. The software OPUS has been originally developed |
| 5 | + * at the University of Stuttgart with funding from the German Research Net, |
| 6 | + * the Federal Department of Higher Education and Research and the Ministry |
| 7 | + * of Science, Research and the Arts of the State of Baden-Wuerttemberg. |
| 8 | + * |
| 9 | + * OPUS 4 is a complete rewrite of the original OPUS software and was developed |
| 10 | + * by the Stuttgart University Library, the Library Service Center |
| 11 | + * Baden-Wuerttemberg, the Cooperative Library Network Berlin-Brandenburg, |
| 12 | + * the Saarland University and State Library, the Saxon State Library - |
| 13 | + * Dresden State and University Library, the Bielefeld University Library and |
| 14 | + * the University Library of Hamburg University of Technology with funding from |
| 15 | + * the German Research Foundation and the European Regional Development Fund. |
| 16 | + * |
| 17 | + * LICENCE |
| 18 | + * OPUS is free software; you can redistribute it and/or modify it under the |
| 19 | + * terms of the GNU General Public License as published by the Free Software |
| 20 | + * Foundation; either version 2 of the Licence, or any later version. |
| 21 | + * OPUS is distributed in the hope that it will be useful, but WITHOUT ANY |
| 22 | + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 23 | + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 24 | + * details. You should have received a copy of the GNU General Public License |
| 25 | + * along with OPUS; if not, write to the Free Software Foundation, Inc., 51 |
| 26 | + * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 27 | + * |
| 28 | + * @copyright Copyright (c) 2026, OPUS 4 development team |
| 29 | + * @license http://www.gnu.org/licenses/gpl.html General Public License |
| 30 | + */ |
| 31 | + |
| 32 | +class Application_View_Helper_ResultsPerPageOptionsTest extends ControllerTestCase |
| 33 | +{ |
| 34 | + /** @var string[] */ |
| 35 | + protected $additionalResources = ['view']; |
| 36 | + |
| 37 | + /** @var Application_View_Helper_ResultsPerPageOptions */ |
| 38 | + protected $helper; |
| 39 | + |
| 40 | + public function setUp(): void |
| 41 | + { |
| 42 | + parent::setUp(); |
| 43 | + |
| 44 | + $this->helper = new Application_View_Helper_ResultsPerPageOptions(); |
| 45 | + $this->helper->setView($this->getView()); |
| 46 | + } |
| 47 | + |
| 48 | + public function testGetOptions() |
| 49 | + { |
| 50 | + $this->assertEqualsCanonicalizing( |
| 51 | + ['10', '20', '50', '100'], |
| 52 | + $this->helper->getOptions() |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + public function testGetOptionsMalformedList() |
| 57 | + { |
| 58 | + $this->adjustConfiguration([ |
| 59 | + 'search' => ['resultsPerPageOptions' => '10, , 20, 50,100, 200, , '], |
| 60 | + ]); |
| 61 | + $this->assertEqualsCanonicalizing( |
| 62 | + ['10', '20', '50', '100', '200'], |
| 63 | + $this->helper->getOptions() |
| 64 | + ); |
| 65 | + } |
| 66 | + |
| 67 | + public function testGetOptionsEmptyList() |
| 68 | + { |
| 69 | + $this->adjustConfiguration([ |
| 70 | + 'search' => ['resultsPerPageOptions' => ''], |
| 71 | + ]); |
| 72 | + $this->assertEqualsCanonicalizing( |
| 73 | + ['10', '20', '50', '100'], |
| 74 | + $this->helper->getOptions() |
| 75 | + ); |
| 76 | + } |
| 77 | +} |
0 commit comments