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
* ItemEditThumbPage controller tests
25
* @author Alan Harder <alan.harder@sun.com>
26
* @version $Revision: 15513 $
28
class ThumbPageItemEditPluginTest extends ItemEditPluginTestCase {
30
function ThumbPageItemEditPluginTest($methodName) {
31
$this->ItemEditPluginTestCase($methodName, 'thumbpage', 'ItemEditThumbPage');
37
/* Register a dummy toolkit and property */
38
$ret = GalleryCoreApi::registerFactoryImplementation(
39
'GalleryToolkit', 'ThumbPageTestToolkit', 'ThumbPageTestToolkit',
40
'modules/thumbpage/test/phpunit/ThumbPageItemEditPluginTest.class',
41
'thumbpageTest', null);
43
print $ret->getAsHtml();
44
return $this->failWithStatus($ret);
46
$this->_markToolkitForCleanup('ThumbPageTestToolkit');
48
$ret = GalleryCoreApi::registerToolkitProperty('ThumbPageTestToolkit',
49
array('test/document'), 'page-count', 'int', 'desc');
51
print $ret->getAsHtml();
52
return $this->failWithStatus($ret);
55
list ($ret, $this->_item) = $this->_createRandomDataItem(
56
$this->_getRootId(), 'test/document', array(), __FILE__, 'GalleryPhotoItem');
58
print $ret->getAsHtml();
59
return $this->failWithStatus($ret);
62
$this->_markForCleanup($this->_item);
64
list ($ret, $this->_thumbnail) = $this->_createDerivative(
65
$this->_item, $this->_item->getId(), DERIVATIVE_TYPE_IMAGE_THUMBNAIL);
67
print $ret->getAsHtml();
68
return $this->failWithStatus($ret);
72
function testReset() {
73
GalleryUtilities::putRequestVariable('form[action][reset]', 1);
76
$results = $this->handleRequest($this->_item, $preferred);
77
$this->assertEquals(array(array(), null), $results);
81
GalleryUtilities::putRequestVariable('form[action][save]', 1);
82
GalleryUtilities::putRequestVariable('form[page]', 2);
85
$results = $this->handleRequest($this->_item, $preferred);
86
$this->assertEquals(array(array(), $this->_translate('Changes saved successfully')),
87
$results, 'page two result');
89
list ($ret, $item) = $this->_thumbnail->refresh();
91
return $this->failWithStatus($ret);
93
$this->assertEquals('select-page|2;test-operation|100', $item->getDerivativeOperations(),
96
// Set back to page one, which removes select-page operation..
97
GalleryUtilities::putRequestVariable('form[page]', 1);
99
$results = $this->handleRequest($this->_item, $preferred);
100
$this->assertEquals(array(array(), $this->_translate('Changes saved successfully')),
101
$results, 'page one result');
103
list ($ret, $item) = $this->_thumbnail->refresh();
105
return $this->failWithStatus($ret);
107
$this->assertEquals('test-operation|100', $item->getDerivativeOperations(),
112
GalleryCoreApi::requireOnce('modules/core/classes/GalleryToolkit.class');
117
* @subpackage PHPUnit
119
class ThumbPageTestToolkit extends GalleryToolkit {
120
function getProperty($mimeType, $propertyName, $sourceFilename) {
121
if ($propertyName != 'page-count') {
122
return array(GalleryCoreApi::error(ERROR_UNSUPPORTED_OPERATION, __FILE__, __LINE__,
123
"$propertyName $sourceFilename"), null);
125
return array(null, array(5));