3
* Gallery - a web based photo album viewer and editor
4
* Copyright (C) 2000-2007 Bharat Mediratta
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or (at
9
* your option) any later version.
11
* This program is distributed in the hope that it will be useful, but
12
* WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
22
* Options controller tests
25
* @author Bharat Mediratta <bharat@menalto.com>
26
* @version $Revision: 15513 $
28
class OptionsControllerTest extends GalleryControllerTestCase {
30
function OptionsControllerTest($methodName) {
31
$this->GalleryControllerTestCase($methodName, 'publishxp.Options');
38
$this->_saveSession =& $gallery->getSession();
39
$this->_mockSession = new OptionsControllerTestMockSession();
40
$gallery->_session =& $this->_mockSession;
45
$gallery->_session = $this->_saveSession;
49
function testSetOptions() {
50
GalleryUtilities::putRequestVariable('form[stripExtensions]', 1);
51
GalleryUtilities::putRequestVariable('form[setCaptions]', 2);
52
GalleryUtilities::putRequestVariable('form[albumId]', 3);
53
GalleryUtilities::putRequestVariable('form[action][setOptions]', 1);
55
$results = $this->handleRequest();
56
$this->assertEquals(array('redirect' => array(
57
'view' => 'publishxp.UploadItems',
58
'stripExtensions' => true,
59
'setCaptions' => true,
66
function testNoAction() {
67
GalleryUtilities::putRequestVariable('form[stripExtensions]', 1);
68
GalleryUtilities::putRequestVariable('form[setCaptions]', 2);
69
GalleryUtilities::putRequestVariable('form[albumId]', 3);
71
$results = $this->handleRequest();
72
$this->assertEquals(array('delegate' => array('view' => 'publishxp.Options'),
78
function testSetExtraOptions() {
79
GalleryUtilities::putRequestVariable('form[action][setOptions]', 1);
80
GalleryUtilities::putRequestVariable('form[albumId]', 2);
81
GalleryUtilities::putRequestVariable('form[SomeOption][someValue]', 3);
83
$results = $this->handleRequest();
84
$this->assertEquals(array('redirect' => array(
85
'view' => 'publishxp.UploadItems',
86
'stripExtensions' => false,
87
'setCaptions' => false,
93
$this->assertEquals(serialize(array('action' => array('setOptions' => '1'),
95
'SomeOption' => array('someValue' => '3'))),
96
$this->_mockSession->get('publishxp.extraOptionsForm'));
100
class OptionsControllerTestMockSession {
101
function put($key, $value) {
102
$this->_data[$key] = $value;
106
return $this->_data[$key];