~ubuntu-branches/ubuntu/quantal/gallery2/quantal

« back to all changes in this revision

Viewing changes to modules/remote/test/phpunit/GalleryRemoteControllerTest.class

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2005-11-29 15:50:12 UTC
  • Revision ID: james.westby@ubuntu.com-20051129155012-wtophp03lu01kdgl
Tags: upstream-2.0.2
ImportĀ upstreamĀ versionĀ 2.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * $RCSfile: GalleryRemoteControllerTest.class,v $
 
4
 *
 
5
 * Gallery - a web based photo album viewer and editor
 
6
 * Copyright (C) 2000-2005 Bharat Mediratta
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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.
 
21
 */
 
22
/**
 
23
 * @version $Revision: 1.21 $ $Date: 2005/08/26 05:15:13 $
 
24
 * @package GalleryRemote
 
25
 * @subpackage PHPUnit
 
26
 * @author Bharat Mediratta <bharat@menalto.com>
 
27
 */
 
28
 
 
29
/**
 
30
 * GalleryRemote controller tests
 
31
 *
 
32
 * @package GalleryRemote
 
33
 * @subpackage PHPUnit
 
34
 */
 
35
class GalleryRemoteControllerTest extends GalleryControllerTestCase {
 
36
 
 
37
    function GalleryRemoteControllerTest($methodName) {
 
38
        $this->GalleryControllerTestCase($methodName, 'remote.GalleryRemote');
 
39
    }
 
40
 
 
41
    function setUp() {
 
42
        global $gallery;
 
43
 
 
44
        parent::setUp();
 
45
 
 
46
        /* Create a new user */
 
47
        list ($ret, $this->_user) = $this->_createRandomUser();
 
48
        if ($ret->isError()) {
 
49
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
50
        }
 
51
 
 
52
        $this->_markForCleanup($this->_user);
 
53
 
 
54
        list ($ret, $this->_rootAlbum) = $this->_createRandomAlbum($this->_getRootId());
 
55
        if ($ret->isError()) {
 
56
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
57
        }
 
58
 
 
59
        $this->_markForCleanup($this->_rootAlbum);
 
60
 
 
61
        $this->_saveUser = $gallery->getActiveUser();
 
62
        $this->_code = GalleryRemoteConstants::getStatusCodes();
 
63
        $this->_version = GalleryRemoteConstants::getVersionCodes();
 
64
    }
 
65
 
 
66
    function testLogin() {
 
67
        global $gallery;
 
68
 
 
69
        GalleryUtilities::putRequestVariable('form[cmd]', 'login');
 
70
        GalleryUtilities::putRequestVariable('form[uname]', $this->_user->getUserName());
 
71
        GalleryUtilities::putRequestVariable('form[password]', 'password');
 
72
 
 
73
        $results = $this->handleRequest();
 
74
        $this->assertEquals(array(), $results['error']);
 
75
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
76
 
 
77
        $response = $results['status']['controllerResponse'];
 
78
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
79
        $this->assertEquals(sprintf('%d.%d', $this->_version['MAJ'], $this->_version['MIN']),
 
80
                            $response->getProperty('server_version'));
 
81
        $this->assert($response->hasProperty('status_text'));
 
82
 
 
83
        $this->assertEquals($this->_user->getId(), $gallery->getActiveUserId());
 
84
    }
 
85
 
 
86
    function testLoginInvalidUser() {
 
87
        global $gallery;
 
88
 
 
89
        GalleryUtilities::putRequestVariable('form[cmd]', 'login');
 
90
        GalleryUtilities::putRequestVariable('form[uname]', 'some-bogus-user');
 
91
        GalleryUtilities::putRequestVariable('form[password]', 'password');
 
92
 
 
93
        $results = $this->handleRequest();
 
94
        $this->assertEquals(array(), $results['error']);
 
95
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
96
 
 
97
        $response = $results['status']['controllerResponse'];
 
98
        $this->assertEquals($this->_code['PASSWORD_WRONG'], (int)$response->getProperty('status'));
 
99
        $this->assert($response->hasProperty('status_text'));
 
100
 
 
101
        $this->assertEquals($this->_saveUser->getId(), $gallery->getActiveUserId());
 
102
    }
 
103
 
 
104
    function testLoginValidUserInvalidPassword() {
 
105
        global $gallery;
 
106
 
 
107
        GalleryUtilities::putRequestVariable('form[cmd]', 'login');
 
108
        GalleryUtilities::putRequestVariable('form[uname]', $this->_user->getUserName());
 
109
        GalleryUtilities::putRequestVariable('form[password]', 'wrong password');
 
110
 
 
111
        $results = $this->handleRequest();
 
112
        $this->assertEquals(array(), $results['error']);
 
113
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
114
 
 
115
        $response = $results['status']['controllerResponse'];
 
116
        $this->assertEquals($this->_code['PASSWORD_WRONG'], (int)$response->getProperty('status'));
 
117
        $this->assert($response->hasProperty('status_text'));
 
118
 
 
119
        $this->assertEquals($this->_saveUser->getId(), $gallery->getActiveUserId());
 
120
    }
 
121
 
 
122
    function testLoginGuestUser() {
 
123
        global $gallery;
 
124
 
 
125
        list ($ret, $anonymousUserId) =
 
126
            GalleryCoreApi::getPluginParameter('module', 'core', 'id.anonymousUser');
 
127
        if ($ret->isError()) {
 
128
            $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
129
        }
 
130
 
 
131
        /*
 
132
         * Logging in as anonymous works when no existing session exists.
 
133
         * Simulate this by dropping the activeUser.
 
134
         */
 
135
        $gallery->_activeUser = null;
 
136
 
 
137
        GalleryUtilities::putRequestVariable('form[cmd]', 'login');
 
138
 
 
139
        $results = $this->handleRequest();
 
140
        $this->assertEquals(array(), $results['error']);
 
141
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
142
 
 
143
        $response = $results['status']['controllerResponse'];
 
144
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
145
        $this->assertEquals(sprintf('%d.%d', $this->_version['MAJ'], $this->_version['MIN']),
 
146
                            $response->getProperty('server_version'));
 
147
        $this->assert($response->hasProperty('status_text'));
 
148
 
 
149
        $this->assertEquals((int)$anonymousUserId, $gallery->getActiveUserId());
 
150
    }
 
151
 
 
152
    function testLoginCurrentUser() {
 
153
        global $gallery;
 
154
 
 
155
        GalleryUtilities::putRequestVariable('form[cmd]', 'login');
 
156
 
 
157
        $results = $this->handleRequest();
 
158
        $this->assertEquals(array(), $results['error']);
 
159
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
160
 
 
161
        $response = $results['status']['controllerResponse'];
 
162
        $this->assertEquals($this->_code['LOGIN_MISSING'], (int)$response->getProperty('status'));
 
163
        $this->assertEquals(sprintf('%d.%d', $this->_version['MAJ'], $this->_version['MIN']),
 
164
                            $response->getProperty('server_version'));
 
165
        $this->assert($response->hasProperty('status_text'));
 
166
 
 
167
        $user = $gallery->getActiveUser();
 
168
        $this->assertEquals($response->getProperty('debug_user'), $user->getuserName());
 
169
    }
 
170
 
 
171
    function testFetchAlbums() {
 
172
        global $gallery;
 
173
 
 
174
        /* Create some albums */
 
175
        $parentId = $this->_rootAlbum->getId();
 
176
        for ($i = 0; $i < 2; $i++) {
 
177
            list ($ret, $album[$i]) = $this->_createRandomAlbum($parentId);
 
178
            if ($ret->isError()) {
 
179
                return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
180
            }
 
181
            $parentId = $album[$i]->getId();
 
182
        }
 
183
 
 
184
        /* give the 2nd album only view permissions */
 
185
        $ret = GalleryCoreApi::removeItemPermissions($album[1]->getId());
 
186
        if ($ret->isError()) {
 
187
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
188
        }
 
189
        $ret = GalleryCoreApi::addUserPermission(
 
190
            $album[1]->getId(), $gallery->getActiveUserId(), 'core.view');
 
191
        if ($ret->isError()) {
 
192
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
193
        }
 
194
 
 
195
        GalleryUtilities::putRequestVariable('form[cmd]', 'fetch-albums-prune');
 
196
        $results = $this->handleRequest();
 
197
        $this->assertEquals(array(), $results['error']);
 
198
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
199
 
 
200
        $response = $results['status']['controllerResponse'];
 
201
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
202
 
 
203
        /* Make sure the albums we created are in the list -- Ignore the rest of the results */
 
204
        $this->assert($response->getProperty('album_count') >= 4);
 
205
        $this->assert($response->hasProperty('status_text'));
 
206
 
 
207
        $seen = array();
 
208
        for ($i = 1; $i <= $response->getProperty('album_count'); $i++) {
 
209
            for ($j = 0; $j < sizeof($album); $j++) {
 
210
                if ($response->getProperty('album.name.' . $i) == $album[$j]->getId()) {
 
211
                    $seen[$j] = 1;
 
212
                    $this->assertEquals(
 
213
                        $album[$j]->getTitle(), $response->getProperty('album.title.' . $i));
 
214
                    $this->assertEquals(
 
215
                        $album[$j]->getSummary(), $response->getProperty('album.summary.' . $i));
 
216
                    $this->assertEquals($album[$j]->getParentId(),
 
217
                                        (int)$response->getProperty('album.parent.' . $i));
 
218
 
 
219
                    $expected = $j == 0 ? 'true' : 'false';
 
220
                    $this->assertEquals($expected, $response->getProperty('album.perms.add.' . $i));
 
221
                    $this->assertEquals(
 
222
                        $expected, $response->getProperty('album.perms.write.' . $i));
 
223
                    $this->assertEquals(
 
224
                        $expected, $response->getProperty('album.perms.del_alb.' . $i));
 
225
                    $this->assertEquals(
 
226
                        $expected, $response->getProperty('album.perms.create_sub.' . $i));
 
227
                }
 
228
            }
 
229
        }
 
230
        $this->assert($seen[0]);
 
231
        $this->assert($seen[1]);
 
232
    }
 
233
 
 
234
    function testAddItem() {
 
235
        global $gallery;
 
236
 
 
237
        $platform = $gallery->getPlatform();
 
238
        GalleryUtilities::putRequestVariable('form[cmd]', 'add-item');
 
239
        GalleryUtilities::putRequestVariable('form[set_albumName]', $this->_rootAlbum->getId());
 
240
        GalleryUtilities::putRequestVariable('form[caption]', 'this is a caption');
 
241
 
 
242
        $this->_controller->setOptionInstances(array());
 
243
 
 
244
        $_FILES[GalleryUtilities::prefixFormVariable('userfile')] =
 
245
            array('name' => 'testfile.txt',
 
246
                  'type' => 'text/plain',
 
247
                  'tmp_name' => __FILE__,
 
248
                  'error' => 0,
 
249
                  'size' => $platform->filesize(__FILE__));
 
250
 
 
251
        $results = $this->handleRequest();
 
252
        $this->assertEquals(array(), $results['error']);
 
253
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
254
 
 
255
        $response = $results['status']['controllerResponse'];
 
256
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
257
 
 
258
        /* Make sure the item was added */
 
259
        list ($ret, $childIds) = GalleryCoreApi::fetchChildItemIds($this->_rootAlbum);
 
260
        if ($ret->isError()) {
 
261
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
262
        }
 
263
 
 
264
        $this->assertEquals(1, sizeof($childIds));
 
265
 
 
266
        list ($ret, $newItem) = GalleryCoreApi::loadEntitiesById($childIds[0]);
 
267
        if ($ret->isError()) {
 
268
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
269
        }
 
270
 
 
271
        $this->assertEquals('testfile.txt', $newItem->getPathComponent());
 
272
        $this->assertEquals('this is a caption', $newItem->getTitle());
 
273
        $this->assertEquals($platform->filesize(__FILE__), $newItem->getSize());
 
274
    }
 
275
 
 
276
    function testAddItemWithOption() {
 
277
        global $gallery;
 
278
 
 
279
        $platform = $gallery->getPlatform();
 
280
        GalleryUtilities::putRequestVariable('form[cmd]', 'add-item');
 
281
        GalleryUtilities::putRequestVariable('form[set_albumName]', $this->_rootAlbum->getId());
 
282
        GalleryUtilities::putRequestVariable('form[caption]', 'this is a caption');
 
283
        GalleryUtilities::putRequestVariable('form[extrafield.Summary]', 'this is a summary');
 
284
        GalleryUtilities::putRequestVariable('form[extrafield.Description]', 'this is a description');
 
285
        GalleryUtilities::putRequestVariable('form[caption]', 'this is a caption');
 
286
 
 
287
        $this->_controller->setOptionInstances(
 
288
            array('instance' => new GalleryRemoteControllerTestAddOption()));
 
289
 
 
290
        $_FILES[GalleryUtilities::prefixFormVariable('userfile')] =
 
291
            array('name' => 'testfile.txt',
 
292
                  'type' => 'text/plain',
 
293
                  'tmp_name' => __FILE__,
 
294
                  'error' => 0,
 
295
                  'size' => $platform->filesize(__FILE__));
 
296
 
 
297
        $results = $this->handleRequest();
 
298
        $this->assertEquals(array(), $results['error']);
 
299
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
300
 
 
301
        $response = $results['status']['controllerResponse'];
 
302
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
303
 
 
304
        /* Make sure the item was added */
 
305
        list ($ret, $childIds) = GalleryCoreApi::fetchChildItemIds($this->_rootAlbum);
 
306
        if ($ret->isError()) {
 
307
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
308
        }
 
309
 
 
310
        $this->assertEquals(1, sizeof($childIds));
 
311
 
 
312
        list ($ret, $newItem) = GalleryCoreApi::loadEntitiesById($childIds[0]);
 
313
        if ($ret->isError()) {
 
314
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
315
        }
 
316
 
 
317
        /* Make sure our option was called */
 
318
        $this->assertEquals($newItem->getId(),
 
319
                            GalleryRemoteControllerTestAddOption::getCalledWithId());
 
320
 
 
321
        $this->assertEquals('testfile.txt', $newItem->getPathComponent());
 
322
        $this->assertEquals('this is a caption', $newItem->getTitle());
 
323
        $this->assertEquals('this is a description', $newItem->getDescription());
 
324
        $this->assertEquals('this is a summary', $newItem->getSummary());
 
325
        $this->assertEquals($platform->filesize(__FILE__), $newItem->getSize());
 
326
    }
 
327
 
 
328
    function testNewAlbum() {
 
329
        global $gallery;
 
330
 
 
331
        $platform = $gallery->getPlatform();
 
332
        GalleryUtilities::putRequestVariable('form[cmd]', 'new-album');
 
333
        GalleryUtilities::putRequestVariable('form[set_albumName]', $this->_rootAlbum->getId());
 
334
        GalleryUtilities::putRequestVariable('form[newAlbumName]', 'name'.rand());
 
335
        GalleryUtilities::putRequestVariable('form[newAlbumTitle]', 'title');
 
336
        GalleryUtilities::putRequestVariable('form[newAlbumDesc]', 'desc');
 
337
 
 
338
        $results = $this->handleRequest();
 
339
        $this->assertEquals(array(), $results['error']);
 
340
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
341
 
 
342
        $response = $results['status']['controllerResponse'];
 
343
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
344
 
 
345
        $newAlbumId = (int)$response->getProperty('album_name');
 
346
 
 
347
        /* Make sure the item was added */
 
348
        list ($ret, $newAlbum) = GalleryCoreApi::loadEntitiesById($newAlbumId);
 
349
        if ($ret->isError()) {
 
350
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
351
        }
 
352
 
 
353
        $this->assertEquals('title', $newAlbum->getTitle());
 
354
        $this->assertEquals('desc', $newAlbum->getDescription());
 
355
    }
 
356
 
 
357
    function testFetchAlbumImagesEmpty() {
 
358
        global $gallery;
 
359
 
 
360
        GalleryUtilities::putRequestVariable('form[cmd]', 'fetch-album-images');
 
361
        GalleryUtilities::putRequestVariable('form[set_albumName]', $this->_rootAlbum->getId());
 
362
        $results = $this->handleRequest();
 
363
        $this->assertEquals(array(), $results['error']);
 
364
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
365
 
 
366
        $response = $results['status']['controllerResponse'];
 
367
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
368
 
 
369
        /* Make sure the there are no images */
 
370
        $this->assert($response->getProperty('image_count') == 0);
 
371
        $this->assert($response->hasProperty('status_text'));
 
372
    }
 
373
 
 
374
    function testFetchAlbumImages() {
 
375
        global $gallery;
 
376
 
 
377
        /* Create some images */
 
378
        $parentId = $this->_rootAlbum->getId();
 
379
        for ($i = 0; $i < 2; $i++) {
 
380
            list ($ret, $image[$i]) = $this->_createRandomDataItem($parentId, 'image/jpg');
 
381
            if ($ret->isError()) {
 
382
                return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
383
            }
 
384
            
 
385
            list ($ret, $derivative[$i]) = $this->_createDerivative(
 
386
                $image[$i], $image[$i]->getId(), DERIVATIVE_TYPE_IMAGE_THUMBNAIL);
 
387
            if ($ret->isError()) {
 
388
                return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
389
            }
 
390
        }
 
391
        GalleryUtilities::putRequestVariable('form[cmd]', 'fetch-album-images');
 
392
        GalleryUtilities::putRequestVariable('form[set_albumName]', $this->_rootAlbum->getId());
 
393
        $results = $this->handleRequest();
 
394
        $this->assertEquals(array(), $results['error']);
 
395
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
396
 
 
397
        $response = $results['status']['controllerResponse'];
 
398
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
399
 
 
400
        /* Make sure the there are 2 images */
 
401
        $this->assertEquals('2', $response->getProperty('image_count'));
 
402
        $this->assert($response->hasProperty('status_text'));
 
403
    }
 
404
 
 
405
    function testFetchAlbumImagesAlbumsToo() {
 
406
        global $gallery;
 
407
 
 
408
        /* Create some images */
 
409
        $parentId = $this->_rootAlbum->getId();
 
410
        for ($i = 0; $i < 2; $i++) {
 
411
            list ($ret, $image[$i]) = $this->_createRandomDataItem($parentId, 'image/jpg');
 
412
            if ($ret->isError()) {
 
413
                return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
414
            }
 
415
            
 
416
            list ($ret, $derivative[$i]) = $this->_createDerivative(
 
417
                $image[$i], $image[$i]->getId(), DERIVATIVE_TYPE_IMAGE_THUMBNAIL);
 
418
            if ($ret->isError()) {
 
419
                return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
420
            }
 
421
        }
 
422
        list ($ret, $album) = $this->_createRandomAlbum($parentId);
 
423
        if ($ret->isError()) {
 
424
        return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
425
        }
 
426
        
 
427
        GalleryUtilities::putRequestVariable('form[cmd]', 'fetch-album-images');
 
428
        GalleryUtilities::putRequestVariable('form[set_albumName]', $this->_rootAlbum->getId());
 
429
        GalleryUtilities::putRequestVariable('form[albums_too]', 'yes');
 
430
        $results = $this->handleRequest();
 
431
        $this->assertEquals(array(), $results['error']);
 
432
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
433
 
 
434
        $response = $results['status']['controllerResponse'];
 
435
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
436
 
 
437
        /* Make sure the there are 2 images and 1 album */
 
438
        $this->assertEquals('3', $response->getProperty('image_count'));
 
439
        $this->assert($response->hasProperty('status_text'));
 
440
    }
 
441
 
 
442
    function testNoop() {
 
443
        global $gallery;
 
444
 
 
445
        $platform = $gallery->getPlatform();
 
446
        GalleryUtilities::putRequestVariable('form[cmd]', 'no-op');
 
447
 
 
448
        $results = $this->handleRequest();
 
449
        $this->assertEquals(array(), $results['error']);
 
450
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
451
 
 
452
        $response = $results['status']['controllerResponse'];
 
453
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
454
        $this->assert($response->hasProperty('status_text'));
 
455
    }
 
456
 
 
457
    function testAlbumProperties() {
 
458
        global $gallery;
 
459
 
 
460
        /* Set the preferences */
 
461
        $ret = GalleryCoreApi::addDerivativePreference(
 
462
                1, $this->_rootAlbum->getId(), DERIVATIVE_TYPE_IMAGE_RESIZE, 'scale|640,640');
 
463
        if ($ret->isError()) {
 
464
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
465
        }
 
466
 
 
467
        GalleryUtilities::putRequestVariable('form[cmd]', 'album-properties');
 
468
        GalleryUtilities::putRequestVariable('form[set_albumName]', $this->_rootAlbum->getId());
 
469
        $results = $this->handleRequest();
 
470
        $this->assertEquals(array(), $results['error']);
 
471
        $this->assertEquals('remote.GalleryRemote', $results['delegate']['view']);
 
472
 
 
473
        $response = $results['status']['controllerResponse'];
 
474
        $this->assertEquals($this->_code['SUCCESS'], (int)$response->getProperty('status'));
 
475
 
 
476
        $this->assertEquals('640', $response->getProperty('auto_resize'));
 
477
        $this->assert($response->hasProperty('status_text'));
 
478
    }
 
479
}
 
480
 
 
481
class GalleryRemoteControllerTestAddOption {
 
482
 
 
483
    function handleRequestAfterAdd($form, $items) {
 
484
        GalleryUtilities::putRequestVariable('calledWith', $items[0]->getId());
 
485
        return array(GalleryStatus::success(), array(), array());
 
486
    }
 
487
 
 
488
    function getCalledWithId() {
 
489
        return (int)GalleryUtilities::getRequestVariables('calledWith');
 
490
    }
 
491
}
 
492
?>