~ubuntu-branches/ubuntu/quantal/gallery2/quantal

« back to all changes in this revision

Viewing changes to modules/publishxp/test/phpunit/OptionsControllerTest.class

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2007-09-10 20:22:19 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070910202219-0jsuntvqge4ade6b
Tags: 2.2.3-2
Add Slovak translation of Debconf templates.  (Thanks to 
Ivan Masá.  Closes: #441671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Gallery - a web based photo album viewer and editor
4
 
 * Copyright (C) 2000-2007 Bharat Mediratta
5
 
 *
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.
10
 
 *
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.
15
 
 *
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.
19
 
 */
20
 
 
21
 
/**
22
 
 * Options controller tests
23
 
 * @package PublishXp
24
 
 * @subpackage PHPUnit
25
 
 * @author Bharat Mediratta <bharat@menalto.com>
26
 
 * @version $Revision: 15513 $
27
 
 */
28
 
class OptionsControllerTest extends GalleryControllerTestCase {
29
 
 
30
 
    function OptionsControllerTest($methodName) {
31
 
        $this->GalleryControllerTestCase($methodName, 'publishxp.Options');
32
 
    }
33
 
 
34
 
    function setUp() {
35
 
        global $gallery;
36
 
        parent::setUp();
37
 
 
38
 
        $this->_saveSession =& $gallery->getSession();
39
 
        $this->_mockSession = new OptionsControllerTestMockSession();
40
 
        $gallery->_session =& $this->_mockSession;
41
 
    }
42
 
 
43
 
    function tearDown() {
44
 
        global $gallery;
45
 
        $gallery->_session = $this->_saveSession;
46
 
        parent::tearDown();
47
 
    }
48
 
 
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);
54
 
 
55
 
        $results = $this->handleRequest();
56
 
        $this->assertEquals(array('redirect' => array(
57
 
                                      'view' => 'publishxp.UploadItems',
58
 
                                      'stripExtensions' => true,
59
 
                                      'setCaptions' => true,
60
 
                                      'albumId' => 3),
61
 
                                  'status' => array(),
62
 
                                  'error' => array()),
63
 
                            $results);
64
 
    }
65
 
 
66
 
    function testNoAction() {
67
 
        GalleryUtilities::putRequestVariable('form[stripExtensions]', 1);
68
 
        GalleryUtilities::putRequestVariable('form[setCaptions]', 2);
69
 
        GalleryUtilities::putRequestVariable('form[albumId]', 3);
70
 
 
71
 
        $results = $this->handleRequest();
72
 
        $this->assertEquals(array('delegate' => array('view' => 'publishxp.Options'),
73
 
                                  'status' => array(),
74
 
                                  'error' => array()),
75
 
                            $results);
76
 
    }
77
 
 
78
 
    function testSetExtraOptions() {
79
 
        GalleryUtilities::putRequestVariable('form[action][setOptions]', 1);
80
 
        GalleryUtilities::putRequestVariable('form[albumId]', 2);
81
 
        GalleryUtilities::putRequestVariable('form[SomeOption][someValue]', 3);
82
 
 
83
 
        $results = $this->handleRequest();
84
 
        $this->assertEquals(array('redirect' => array(
85
 
                                      'view' => 'publishxp.UploadItems',
86
 
                                      'stripExtensions' => false,
87
 
                                      'setCaptions' => false,
88
 
                                      'albumId' => 2),
89
 
                                  'status' => array(),
90
 
                                  'error' => array()),
91
 
                            $results);
92
 
 
93
 
        $this->assertEquals(serialize(array('action' => array('setOptions' => '1'),
94
 
                                            'albumId' => '2',
95
 
                                            'SomeOption' => array('someValue' => '3'))),
96
 
                            $this->_mockSession->get('publishxp.extraOptionsForm'));
97
 
    }
98
 
}
99
 
 
100
 
class OptionsControllerTestMockSession {
101
 
    function put($key, $value) {
102
 
        $this->_data[$key] = $value;
103
 
    }
104
 
 
105
 
    function get($key) {
106
 
        return $this->_data[$key];
107
 
    }
108
 
}
109
 
?>