3
* $RCSfile: AdminDeleteGroupQuotaControllerTest.class,v $
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2005 Bharat Mediratta
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or (at
11
* your option) any later version.
13
* This program is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
23
* @version $Revision: 1.5 $ $Date: 2005/08/23 03:49:50 $
26
* @author Robert Balousek <volksport@users.sf.net>
29
GalleryCoreApi::relativeRequireOnce('modules/quotas/classes/GalleryQuotasHelper.class');
30
GalleryCoreApi::relativeRequireOnce('modules/quotas/classes/QuotasMap.class');
33
* AdminDeleteGroupQuota controller tests
37
class AdminDeleteGroupQuotaControllerTest extends GalleryControllerTestCase {
39
function AdminDeleteGroupQuotaControllerTest($methodName) {
40
$this->GalleryControllerTestCase($methodName, 'quotas.AdminDeleteGroupQuota');
46
/* Create a group for quota testing */
47
list ($ret, $this->_group) = $this->_createRandomGroup();
48
if ($ret->isError()) {
49
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
51
$this->_markForCleanup($this->_group);
54
function testCancel() {
55
GalleryUtilities::putRequestVariable('form[action][cancel]', 1);
56
GalleryUtilities::putRequestVariable('groupId', $this->_group->getId());
58
$results = $this->handleRequest();
59
$this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
60
'subView' => 'quotas.AdminQuotas'),
67
* Create and delete a group quota
69
function testDeleteGroupQuota() {
70
$this->_createUserOrGroupQuota($this->_group->getId(), 2048);
72
GalleryUtilities::putRequestVariable('groupId', $this->_group->getId());
73
GalleryUtilities::putRequestVariable('form[action][delete]', 1);
75
$results = $this->handleRequest();
77
array('redirect' => array('view' => 'core.SiteAdmin',
78
'subView' => 'quotas.AdminQuotas'),
79
'status' => array('deletedGroup' => $this->_group->getGroupName()),
81
$results, 'Failed to delete group quota');
83
/* Verify the group quota is gone */
84
list ($ret, $quotaExists, $quota) =
85
GalleryQuotasHelper::fetchGroupQuota($this->_group->getId());
87
$this->assert(false, 'The group quota was not actually deleted');
89
$this->_deleteUserOrGroupQuota($this->_group->getId());
93
function testDeleteGroupQuotaGroupIdMissing() {
94
GalleryUtilities::putRequestVariable('form[action][save]', 1);
95
$results = $this->handleRequest(ERROR_BAD_PARAMETER);
99
* Delete a non-existant group quota
101
function testDeleteNonExistantGroupQuota() {
102
GalleryUtilities::putRequestVariable('groupId', $this->_group->getId());
103
GalleryUtilities::putRequestVariable('form[action][delete]', 1);
105
$results = $this->handleRequest();
107
$this->assertEquals(array('delegate' => array('view' => 'core.SiteAdmin',
108
'subView' => 'quotas.AdminDeleteGroupQuota'),
114
function _createUserOrGroupQuota($userOrGroupId, $quota) {
115
$ret = QuotasMap::addMapEntry(array('userOrGroupId' => $userOrGroupId,
116
'quotaSize' => $quota));
117
if ($ret->isError()) {
118
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
122
function _deleteUserOrGroupQuota($userOrGroupId) {
123
$ret = QuotasMap::removeMapEntry(array('userOrGroupId' => $userOrGroupId));
124
if ($ret->isError()) {
125
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));