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
* KeywordAlbumSiteAdmin controller tests
26
* @author Alan Harder <alan.harder@sun.com>
27
* @version $Revision: 15513 $
29
class KeywordAlbumSiteAdminControllerTest extends GalleryControllerTestCase {
31
function KeywordAlbumSiteAdminControllerTest($methodName) {
32
$this->GalleryControllerTestCase($methodName, 'keyalbum.KeywordAlbumSiteAdmin');
38
$ret = $this->_markPluginParametersForCleanup('module', 'keyalbum');
40
print $ret->getAsHtml();
41
return $this->failWithStatus($ret);
44
list ($ret, $this->_entity) = $this->_createRandomAlbum($this->_getRootId());
46
print $ret->getAsHtml();
47
return $this->failWithStatus($ret);
49
$this->_markForCleanup($this->_entity);
51
foreach (array('themeId' => 'keyalbumTest',
52
'themeSettingsId' => $this->_entity->getId()) as $key => $value) {
53
$ret = GalleryCoreApi::setPluginParameter('module', 'keyalbum', $key, $value);
55
print $ret->getAsHtml();
56
return $this->failWithStatus($ret);
60
list ($ret, $this->_defaultThemeId) =
61
GalleryCoreApi::getPluginParameter('module', 'core', 'default.theme');
63
print $ret->getAsHtml();
64
return $this->failWithStatus($ret);
68
function testKeywordAlbumSiteAdminControllerReset() {
69
GalleryUtilities::putRequestVariable('form[action][reset]', '1');
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()),
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');
92
list ($ret, $core) = GalleryCoreApi::loadPlugin('module', 'core');
94
return $this->failWithStatus($ret);
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),
106
/* Verify the information in the DB */
107
list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'keyalbum');
109
return $this->failWithStatus($ret);
111
foreach ($params as $key => $value) {
112
if (in_array($key[0], array('_', 'a'))) {
113
unset($params[$key]);
117
$this->assertEquals(array('description' => 'test desc',
118
'orderBy' => 'albumsFirst|originationTimestamp',
119
'orderDirection' => ORDER_DESCENDING,
121
'summaryLinks' => 'album',
122
'themeId' => $this->_defaultThemeId,
123
'themeSettingsId' => $this->_entity->getId()),
124
$params, 'Verify DB Data');
126
list ($ret, $themeParam) = GalleryCoreApi::getPluginParameter(
127
'theme', 'keyalbumTest', 'perPage', $this->_entity->getId());
129
return $this->failWithStatus($ret);
131
$this->assertEquals('5', $themeParam, 'Theme param');
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');
145
$results = $this->handleRequest();
146
$this->assertEquals(array('delegate' =>
147
array('view' => 'core.SiteAdmin', 'subView' => 'keyalbum.KeywordAlbumSiteAdmin'),
149
'error' => array('form[error][split]')),
154
GalleryCoreApi::requireOnce('modules/core/classes/GalleryTheme.class');
159
class KeyAlbumTestTheme extends GalleryTheme {
160
function KeyAlbumTestTheme() {
161
$this->setId('keyalbumTest');
162
$this->setStandardSettings(array('perPage' => 9));