~ubuntu-branches/ubuntu/maverick/gallery2/maverick

« back to all changes in this revision

Viewing changes to modules/keyalbum/test/phpunit/KeywordAlbumSiteAdminControllerTest.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
 
 * KeywordAlbumSiteAdmin controller tests
23
 
 *
24
 
 * @package KeyAlbum
25
 
 * @subpackage PHPUnit
26
 
 * @author Alan Harder <alan.harder@sun.com>
27
 
 * @version $Revision: 15513 $
28
 
 */
29
 
class KeywordAlbumSiteAdminControllerTest extends GalleryControllerTestCase {
30
 
 
31
 
    function KeywordAlbumSiteAdminControllerTest($methodName) {
32
 
        $this->GalleryControllerTestCase($methodName, 'keyalbum.KeywordAlbumSiteAdmin');
33
 
    }
34
 
 
35
 
    function setUp() {
36
 
        parent::setUp();
37
 
 
38
 
        $ret = $this->_markPluginParametersForCleanup('module', 'keyalbum');
39
 
        if ($ret) {
40
 
            print $ret->getAsHtml();
41
 
            return $this->failWithStatus($ret);
42
 
        }
43
 
 
44
 
        list ($ret, $this->_entity) = $this->_createRandomAlbum($this->_getRootId());
45
 
        if ($ret) {
46
 
            print $ret->getAsHtml();
47
 
            return $this->failWithStatus($ret);
48
 
        }
49
 
        $this->_markForCleanup($this->_entity);
50
 
 
51
 
        foreach (array('themeId' => 'keyalbumTest',
52
 
                       'themeSettingsId' => $this->_entity->getId()) as $key => $value) {
53
 
            $ret = GalleryCoreApi::setPluginParameter('module', 'keyalbum', $key, $value);
54
 
            if ($ret) {
55
 
                print $ret->getAsHtml();
56
 
                return $this->failWithStatus($ret);
57
 
            }
58
 
        }
59
 
 
60
 
        list ($ret, $this->_defaultThemeId) =
61
 
            GalleryCoreApi::getPluginParameter('module', 'core', 'default.theme');
62
 
        if ($ret) {
63
 
            print $ret->getAsHtml();
64
 
            return $this->failWithStatus($ret);
65
 
        }
66
 
    }
67
 
 
68
 
    function testKeywordAlbumSiteAdminControllerReset() {
69
 
        GalleryUtilities::putRequestVariable('form[action][reset]', '1');
70
 
 
71
 
        /* Perform the request and verify that we succeeded */
72
 
        $results = $this->handleRequest();
73
 
        $this->assertEquals(array('redirect' =>
74
 
                array('view' => 'core.SiteAdmin', 'subView' => 'keyalbum.KeywordAlbumSiteAdmin'),
75
 
                                  'status' => array(), 'error' => array()),
76
 
                            $results);
77
 
    }
78
 
 
79
 
    function testKeywordAlbumSiteAdminControllerSave() {
80
 
        GalleryUtilities::putRequestVariable('form[action][save]', '1');
81
 
        GalleryUtilities::putRequestVariable('form[summaryLinks]', 'album');
82
 
        GalleryUtilities::putRequestVariable('form[split][comma]', '1');
83
 
        GalleryUtilities::putRequestVariable('form[split][space]', '1');
84
 
        GalleryUtilities::putRequestVariable('form[orderBy]', 'originationTimestamp');
85
 
        GalleryUtilities::putRequestVariable('form[orderDirection]', ORDER_DESCENDING);
86
 
        GalleryUtilities::putRequestVariable('form[presort]', 'albumsFirst');
87
 
        GalleryUtilities::putRequestVariable('form[description]', 'test desc');
88
 
        GalleryUtilities::putRequestVariable('form[themeId]', $this->_defaultThemeId);
89
 
        GalleryUtilities::putRequestVariable('form[currentThemeId]', 'keyalbumTest');
90
 
        GalleryUtilities::putRequestVariable('form[key][perPage]', '5');
91
 
 
92
 
        list ($ret, $core) = GalleryCoreApi::loadPlugin('module', 'core');
93
 
        if ($ret) {
94
 
            return $this->failWithStatus($ret);
95
 
        }
96
 
 
97
 
        /* Perform the request and verify that we succeeded */
98
 
        $results = $this->handleRequest();
99
 
        $this->assertEquals(array('redirect' =>
100
 
                array('view' => 'core.SiteAdmin', 'subView' => 'keyalbum.KeywordAlbumSiteAdmin'),
101
 
                                  'status' => array('statusMessage' => $core->translate(
102
 
                                          'Successfully saved theme settings'), 'saved' => 1),
103
 
                                  'error' => array()),
104
 
                            $results);
105
 
 
106
 
        /* Verify the information in the DB */
107
 
        list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'keyalbum');
108
 
        if ($ret) {
109
 
            return $this->failWithStatus($ret);
110
 
        }
111
 
        foreach ($params as $key => $value) {
112
 
            if (in_array($key[0], array('_', 'a'))) {
113
 
                unset($params[$key]);
114
 
            }
115
 
        }
116
 
        ksort($params);
117
 
        $this->assertEquals(array('description' => 'test desc',
118
 
                                  'orderBy' => 'albumsFirst|originationTimestamp',
119
 
                                  'orderDirection' => ORDER_DESCENDING,
120
 
                                  'split' => ',\s',
121
 
                                  'summaryLinks' => 'album',
122
 
                                  'themeId' => $this->_defaultThemeId,
123
 
                                  'themeSettingsId' => $this->_entity->getId()),
124
 
                            $params, 'Verify DB Data');
125
 
 
126
 
        list ($ret, $themeParam) = GalleryCoreApi::getPluginParameter(
127
 
                'theme', 'keyalbumTest', 'perPage', $this->_entity->getId());
128
 
        if ($ret) {
129
 
            return $this->failWithStatus($ret);
130
 
        }
131
 
        $this->assertEquals('5', $themeParam, 'Theme param');
132
 
    }
133
 
 
134
 
    function testKeywordAlbumSiteAdminControllerNoSplit() {
135
 
        GalleryUtilities::putRequestVariable('form[action][save]', '1');
136
 
        GalleryUtilities::putRequestVariable('form[summaryLinks]', 'none');
137
 
        GalleryUtilities::putRequestVariable('form[orderBy]', 'title');
138
 
        GalleryUtilities::putRequestVariable('form[orderDirection]', ORDER_ASCENDING);
139
 
        GalleryUtilities::putRequestVariable('form[presort]', '');
140
 
        GalleryUtilities::putRequestVariable('form[description]', 'test desc');
141
 
        GalleryUtilities::putRequestVariable('form[themeId]', 'keyalbumTest');
142
 
        GalleryUtilities::putRequestVariable('form[currentThemeId]', 'keyalbumTest');
143
 
        GalleryUtilities::putRequestVariable('form[key][perPage]', '5');
144
 
 
145
 
        $results = $this->handleRequest();
146
 
        $this->assertEquals(array('delegate' =>
147
 
                array('view' => 'core.SiteAdmin', 'subView' => 'keyalbum.KeywordAlbumSiteAdmin'),
148
 
                                  'status' => array(),
149
 
                                  'error' => array('form[error][split]')),
150
 
                            $results);
151
 
    }
152
 
}
153
 
 
154
 
GalleryCoreApi::requireOnce('modules/core/classes/GalleryTheme.class');
155
 
 
156
 
/**
157
 
 * Test theme
158
 
 */
159
 
class KeyAlbumTestTheme extends GalleryTheme {
160
 
    function KeyAlbumTestTheme() {
161
 
        $this->setId('keyalbumTest');
162
 
        $this->setStandardSettings(array('perPage' => 9));
163
 
    }
164
 
}
165
 
?>