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
GalleryCoreApi::requireOnce('modules/rss/classes/RssMapHelper.class');
24
* EditFeed controller tests
28
* @author Jonatan Heyman <http://heyman.info>
29
* @author Pierre-Luc Paour
30
* @author Daniel Grund <http://www.photogrund.nl>
31
* @version $Revision: 15513 $
33
class RssEditFeedTest extends GalleryControllerTestCase {
37
function RssEditFeedTest($methodName) {
38
$this->GalleryControllerTestCase($methodName, 'rss.EditFeed');
44
$ret = $this->_markPluginParametersForCleanup('module', 'rss');
46
print $ret->getAsHtml();
47
return $this->failWithStatus($ret);
50
$ret = GalleryCoreApi::setPluginParameter('module', 'rss', 'allowConfigurableFeed', 1);
52
return $this->failWithStatus($ret);
54
$ret = GalleryCoreApi::setPluginParameter('module', 'rss', 'allowAlbums', 1);
56
return $this->failWithStatus($ret);
61
if (!empty($this->_feedsToDelete)) {
62
foreach ($this->_feedsToDelete as $name) {
63
$ret = RssMapHelper::deleteFeed($name);
65
return $this->failWithStatus($ret);
73
function testRssEditFeedCancel() {
74
GalleryUtilities::putRequestVariable('form[action][cancel]', '1');
75
GalleryUtilities::putRequestVariable('form[itemId]', $this->_getRootId());
76
GalleryUtilities::putRequestVariable('form[mode]', 'edit');
78
$results = $this->handleRequest();
79
$this->assertEquals(array(
83
'view' => 'core.ItemAdmin',
84
'subView' => 'rss.EditFeed',
85
'itemId' => $this->_getRootId(),
88
'action' => array('cancel' => '1'),
90
'itemId' => (string) $this->_getRootId()))),
94
function testRssEditFeed() {
95
$name = 'feed' .rand();
96
GalleryUtilities::putRequestVariable('form[action][create]', '1');
97
GalleryUtilities::putRequestVariable('form[action][save]', '1');
98
GalleryUtilities::putRequestVariable('form[mode]', 'new');
101
'itemId' => (string) $this->_getRootId(),
103
'feedType' => 'photosRecurse',
104
'photosRecurseLimit'=> '0',
109
'description' => 'description',
112
'useEnclosure' => '1',
113
'useCategory' => '1',
115
'cloudDomain' => 'Gallery',
116
'cloudPort' => '202',
117
'cloudPath' => 'rss',
118
'cloudRegisterProcedure' => 'register',
119
'cloudProtocol' => 'tcp',
122
'category' => 'photo',
123
'useItemCategory' => '1',
124
'language' => 'en-us',
125
'feedDate' => 'updated');
127
foreach ($values as $key => $value) {
128
GalleryUtilities::putRequestVariable('form['.$key.']', $value);
131
$results = $this->handleRequest();
133
$this->assertEquals(array(
134
'status' => array('saved' => 1),
137
'view' => 'core.ItemAdmin',
138
'subView' => 'rss.EditFeed',
139
'itemId' => $this->_getRootId(),
141
'form' => array_merge(array(
142
'action' => array('save' => '1', 'create' => '1'),
147
/* remember to delete this new feed */
148
$this->_feedsToDelete[] = $name;
150
/* check the feed values */
151
list ($ret, $feed) = RssMapHelper::fetchFeed($name);
153
return $this->failWithStatus($ret);
157
function testRssUpdateFeed() {
158
$name = 'feed' .rand();
160
/* create feed we're going to edit */
161
$params = array('itemId' => $this->_getRootId());
162
$ret = RssMapHelper::createFeed($name, $params);
164
return $this->failWithStatus($ret);
167
/* remember to delete this new feed */
168
$this->_feedsToDelete[] = $name;
170
GalleryUtilities::putRequestVariable('form[action][update]', '1');
171
GalleryUtilities::putRequestVariable('form[action][save]', '1');
172
GalleryUtilities::putRequestVariable('form[mode]', 'edit');
175
'itemId' => (string) $this->_getRootId(),
177
'feedType' => 'photosRecurse',
178
'photosRecurseLimit'=> '0',
183
'description' => 'description',
186
'useEnclosure' => '1',
187
'useCategory' => '1',
189
'cloudDomain' => 'Gallery',
190
'cloudPort' => '202',
191
'cloudPath' => 'rss',
192
'cloudRegisterProcedure' => 'register',
193
'cloudProtocol' => 'tcp',
196
'category' => 'photo',
197
'useItemCategory' => '1',
198
'language' => 'en-us',
199
'feedDate' => 'updated');
201
foreach ($values as $key => $value) {
202
GalleryUtilities::putRequestVariable('form['.$key.']', $value);
205
$results = $this->handleRequest();
207
$this->assertEquals(array(
208
'status' => array('saved' => 1),
211
'view' => 'core.ItemAdmin',
212
'subView' => 'rss.EditFeed',
213
'itemId' => $this->_getRootId(),
215
'form' => array_merge(array(
216
'action' => array('save' => '1', 'update' => '1'),
221
/* check the feed values */
222
list ($ret, $feed) = RssMapHelper::fetchFeed($name);
224
return $this->failWithStatus($ret);
228
function testRssUpdateFeedNew() {
229
$name = 'feed' .rand();
231
GalleryUtilities::putRequestVariable('form[action][update]', '1');
232
GalleryUtilities::putRequestVariable('form[action][save]', '1');
233
GalleryUtilities::putRequestVariable('form[mode]', 'edit');
236
'itemId' => (string) $this->_getRootId(),
238
'feedType' => 'photosRecurse',
239
'photosRecurseLimit'=> '0',
244
'description' => 'description',
247
'useEnclosure' => '1',
248
'useCategory' => '1',
250
'cloudDomain' => 'Gallery',
251
'cloudPort' => '202',
252
'cloudPath' => 'rss',
253
'cloudRegisterProcedure' => 'register',
254
'cloudProtocol' => 'tcp',
257
'category' => 'photo',
258
'useItemCategory' => '1',
259
'language' => 'en-us',
260
'feedDate' => 'updated');
262
foreach ($values as $key => $value) {
263
GalleryUtilities::putRequestVariable('form['.$key.']', $value);
266
$results = $this->handleRequest();
268
$this->assertEquals(array(
269
'status' => array('saved' => 1),
272
'view' => 'core.ItemAdmin',
273
'subView' => 'rss.EditFeed',
274
'itemId' => $this->_getRootId(),
276
'form' => array_merge(array(
277
'action' => array('save' => '1', 'update' => '1'),
283
function testDeleteFeed() {
284
$name = 'feed' .rand();
286
/* Create feed that we're going to delete */
287
$params = array('itemId' => $this->_getRootId());
288
$ret = RssMapHelper::createFeed($name, $params);
290
return $this->failWithStatus($ret);
292
/* Cleanup if things go wrong */
293
$this->_feedsToDelete[] = $name;
295
GalleryUtilities::putRequestVariable('form[action][delete]', $name);
296
GalleryUtilities::putRequestVariable('itemId', $this->_getRootId());
297
GalleryUtilities::putRequestVariable('controller', 'rss.EditFeed');
299
$results = $this->handleRequest();
301
$this->assertEquals(array(
302
'status' => array('deleted' => 1),
305
'view' => 'core.ItemAdmin',
306
'subView' => 'rss.EditFeed',
307
'itemId' => $this->_getRootId(),
309
'form' => array('action' => array('delete' => $name))