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.
21
require_once(dirname(__FILE__) . '/../../../modules/core/classes/GalleryView.class');
22
require_once(dirname(__FILE__) . '/../../../modules/core/classes/GalleryController.class');
23
require_once(dirname(__FILE__) . '/../../../modules/core/ItemEdit.inc');
26
* An ItemEditOption specific version of GalleryTestCase
29
* @author Alan Harder <alan.harder@sun.com>
30
* @version $Revision: 15513 $
32
class ItemEditOptionTestCase extends GalleryTestCase {
41
* immediate status view
46
function ItemEditOptionTestCase($methodName, $moduleName, $optionName) {
47
$this->GalleryTestCase($methodName);
49
list ($ret, $this->_option) =
50
GalleryCoreApi::newFactoryInstanceById('ItemEditOption', $optionName);
52
return $this->failWithStatus($ret);
54
if (!isset($this->_option)) {
55
return $this->failWithStatus(
56
GalleryCoreApi::error(ERROR_MISSING_OBJECT));
59
list ($ret, $this->_module) = GalleryCoreApi::loadPlugin('module', $moduleName);
61
return $this->failWithStatus($ret);
63
$this->_statusMonitor = new ItemEditOptionTestImmediateStatusView();
66
function _handleRequestAfterEdit($form, &$item, $errorCode=null) {
67
list ($ret, $preferred) = GalleryCoreApi::fetchPreferredsByItemIds(array($item->getId()));
69
return array($ret, null);
71
$preferred = empty($preferred) ? null : array_shift($preferred);
73
list ($ret, $error, $warning) = $this->_option->handleRequestAfterEdit(
74
$form, $item, $preferred, $this->_statusMonitor);
75
if (isset($errorCode)) {
76
if (($ret->getErrorCode() & $errorCode) != $errorCode) {
78
sprintf('Expected error code (%s) but received (%s)',
79
implode(' | ', GalleryStatus::getErrorCodeConstants($errorCode)),
80
implode(' | ', GalleryStatus::getErrorCodeConstants(
81
$ret->getErrorCode()))));
84
$this->failWithStatus($ret);
86
/* Check to make sure we got back everything we want */
87
$this->assert(isset($error) && is_array($error), 'option error results missing');
89
/* Check to make sure we got back everything we want */
90
$this->assert(isset($warning) && is_array($warning), 'option warning results missing');
93
return array($error, $warning);
96
function _translate($message) {
97
return $this->_module->translate($message);
102
* Test ImmediateStatusView implementation
104
class ItemEditOptionTestImmediateStatusView extends GalleryView {
105
function doLoadImmediateTemplate() {
106
$this->_l10Domain = 'test';
107
$this->_template = 'test';
111
function renderHeader() {
115
function renderStatusMessage($statusMessage) {
119
function renderRedirect($redirectUrl) {
123
function renderFooter() {
127
function setMain($main) {