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
* Test CoreModule functionality
23
* @package GalleryCore
25
* @author Bharat Mediratta <bharat@menalto.com>
26
* @version $Revision: 15513 $
28
class CoreModuleTest extends GalleryTestCase {
31
function CoreModuleTest($methodName) {
32
$this->GalleryTestCase($methodName);
39
list ($ret, $this->_module) = GalleryCoreApi::loadPlugin('module', 'core');
41
return $this->failWithStatus($ret);
44
list ($ret, $this->_parentAlbum) = $this->_createRandomAlbum($this->_getRootId());
46
print $ret->getAsHtml();
47
return $this->failWithStatus($ret);
50
$this->_markForCleanup($this->_parentAlbum);
52
$ret = GalleryCoreApi::addUserPermission($this->_parentAlbum->getId(),
53
$gallery->getActiveUserId(),
56
print $ret->getAsHtml();
57
return $this->failWithStatus($ret);
61
function testGetItemAdminViews() {
62
list ($ret, $content) = $this->_module->getItemAdminViews($this->_parentAlbum);
64
return $this->failWithStatus($ret);
69
array('name' => $this->_module->_translate(
70
array('text' => 'Edit %s',
71
'arg1' => $this->_module->translate('Album')),
73
'view' => 'core.ItemEdit'),
74
array('name' => $this->_module->translate('Edit Permissions'),
75
'view' => 'core.ItemPermissions'),
76
array('name' => $this->_module->_translate(
77
array('text' => 'Delete %s',
78
'arg1' => $this->_module->translate('Album')),
80
'view' => 'core.ItemDeleteSingle'),
81
array('name' => $this->_module->_translate(
82
array('text' => 'Move %s',
83
'arg1' => $this->_module->translate('Album')),
85
'view' => 'core.ItemMoveSingle'),
86
array('name' => $this->_module->translate('Add Items'),
87
'view' => 'core.ItemAdd'),
88
array('name' => $this->_module->translate('Add Album'),
89
'view' => 'core.ItemAddAlbum')
91
$content, 'empty album');
93
list ($ret) = $this->_createRandomDataItem($this->_parentAlbum->getId());
95
return $this->failWithStatus($ret);
98
list ($ret, $content) = $this->_module->getItemAdminViews($this->_parentAlbum);
100
return $this->failWithStatus($ret);
105
array('name' => $this->_module->translate('Edit Captions'),
106
'view' => 'core.ItemEditCaptions'),
107
array('name' => $this->_module->_translate(
108
array('text' => 'Edit %s',
109
'arg1' => $this->_module->translate('Album')),
111
'view' => 'core.ItemEdit'),
112
array('name' => $this->_module->translate('Edit Permissions'),
113
'view' => 'core.ItemPermissions'),
114
array('name' => $this->_module->_translate(
115
array('text' => 'Delete %s',
116
'arg1' => $this->_module->translate('Album')),
118
'view' => 'core.ItemDeleteSingle'),
119
array('name' => $this->_module->_translate(
120
array('text' => 'Move %s',
121
'arg1' => $this->_module->translate('Album')),
123
'view' => 'core.ItemMoveSingle'),
124
array('name' => $this->_module->translate('Add Items'),
125
'view' => 'core.ItemAdd'),
126
array('name' => $this->_module->translate('Add Album'),
127
'view' => 'core.ItemAddAlbum')
129
$content, 'nonempty album');
132
function testGetConfigurationView() {
133
$content = $this->_module->getConfigurationView();
134
$this->assertEquals(null, $content);
137
function testGetSystemLinks() {
140
list ($ret, $content) = $this->_module->getSystemLinks();
142
return $this->failWithStatus($ret);
146
array('SiteAdmin' => array(
147
'text' => $this->_module->translate('Site Admin'),
148
'params' => array('view' => 'core.SiteAdmin',
150
'YourAccount' => array(
151
'text' => $this->_module->translate('Your Account'),
152
'params' => array('view' => 'core.UserAdmin',
153
'subView' => 'core.UserPreferences',
156
'text' => $this->_module->translate('Logout'),
157
'params' => array('controller' => 'core.Logout',
160
$content, 'Admin User');
163
list ($ret, $this->_user1) =
164
$this->_createUser(array('hashedPassword' => GalleryUtilities::md5Salt('TestPassword'),
165
'email' => 'test2@email.com',
166
'fullName' => 'Test User 2',
170
return $this->failWithStatus($ret);
173
$this->_markForCleanup($this->_user1);
175
$gallery->setActiveUser($this->_user1);
177
list ($ret, $content) = $this->_module->getSystemLinks();
179
return $this->failWithStatus($ret);
183
array('YourAccount' => array(
184
'text' => $this->_module->translate('Your Account'),
185
'params' => array('view' => 'core.UserAdmin',
186
'subView' => 'core.UserPreferences',
189
'text' => $this->_module->translate('Logout'),
190
'params' => array('controller' => 'core.Logout',
193
$content, 'Normal User');
195
list ($ret, $this->_user2) =
196
$this->_createUser(array('hashedPassword' => GalleryUtilities::md5Salt('TestPassword'),
197
'email' => 'test2@email.com',
198
'fullName' => 'Test User 2',
202
return $this->failWithStatus($ret);
205
$this->_markForCleanup($this->_user2);
207
$gallery->setActiveUser($this->_user2);
209
list ($ret, $content) = $this->_module->getSystemLinks();
211
return $this->failWithStatus($ret);
215
array('YourAccount' => array(
216
'text' => $this->_module->translate('Your Account'),
217
'params' => array('view' => 'core.UserAdmin',
218
'subView' => 'core.UserPreferences',
221
'text' => $this->_module->translate('Logout'),
222
'params' => array('controller' => 'core.Logout',
225
$content, 'Locked User');
228
function testSetModuleParameter() {
232
$ret = $this->_module->setParameter($key, $value);
234
return $this->failWithStatus($ret);
237
list ($ret, $newValue) = $this->_module->getParameter($key);
239
return $this->failWithStatus($ret);
243
$ret = GalleryCoreApi::removePluginParameter('module', 'core', $key);
245
return $this->failWithStatus($ret);
248
$this->assertEquals($value, (int)$newValue);
253
* Mock template class
255
* @package GalleryCore
256
* @subpackage PHPUnit
258
class CoreModuleMockTemplate {
259
function setVariable() {