3
3
* $RCSfile: AlbumTest.class,v $
5
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2005 Bharat Mediratta
6
* Copyright (C) 2000-2006 Bharat Mediratta
8
8
* This program is free software; you can redistribute it and/or modify
9
9
* it under the terms of the GNU General Public License as published by
20
20
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
23
* @version $Revision: 1.38 $ $Date: 2005/08/30 04:02:53 $
23
* @version $Revision: 1.41 $ $Date: 2006/01/13 03:39:32 $
24
24
* @package GalleryCore
25
25
* @subpackage PHPUnit
26
26
* @author Bharat Mediratta <bharat@menalto.com>
54
54
$ret = GalleryCoreApi::registerFactoryImplementation(
55
55
'GalleryToolkit', 'AlbumTestToolkit', 'AlbumTestToolkit',
56
56
$path, 'coreTest', null);
57
if ($ret->isError()) {
58
58
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
60
60
$this->_markToolkitForCleanup('AlbumTestToolkit');
65
65
array(array('type' => 'int', 'description' => 'test'),
66
66
array('type' => 'int', 'description' => 'test')),
67
67
'test-description', '');
68
if ($ret->isError()) {
69
69
print $ret->getAsHtml();
70
70
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
73
73
$ret = $this->_markPluginParametersForCleanup('module', 'core');
74
if ($ret->isError()) {
75
75
print $ret->getAsHtml();
76
76
return $ret->wrap(__FILE__, __LINE__);
83
83
list ($ret, $rootAlbum) = GalleryCoreApi::loadEntitiesById($this->_parentAlbum->getId());
84
if ($ret->isError()) {
85
85
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
88
88
if (!GalleryUtilities::isA($rootAlbum, 'GalleryAlbumItem')) {
89
89
return $this->failWithStatus(
90
GalleryStatus::error(ERROR_DELETED_OBJECT, __FILE__, __LINE__));
90
GalleryCoreApi::error(ERROR_DELETED_OBJECT, __FILE__, __LINE__));
97
97
list ($ret, $album) = $this->_createRandomAlbum($this->_parentAlbum->getId());
98
if ($ret->isError()) {
99
99
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
103
103
$ret = $this->_verifyEntity($album);
104
if ($ret->isError()) {
105
105
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
109
109
$ret = $this->_deleteAndVerifyEntity($album->getId());
110
if ($ret->isError()) {
111
111
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
118
118
list ($ret, $album) = $this->_createRandomAlbum($this->_parentAlbum->getId());
119
if ($ret->isError()) {
120
120
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
124
124
$ret = $this->_verifyEntity($album);
125
if ($ret->isError()) {
126
126
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
129
129
/* Lock and refresh it */
130
130
list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($album->getId());
131
if ($ret->isError()) {
132
132
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
135
135
list ($ret, $album) = $album->refresh();
136
if ($ret->isError()) {
137
137
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
141
141
$ret = $album->rename('newname-' . rand());
142
if ($ret->isError()) {
143
143
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
147
147
$ret = $album->save();
148
if ($ret->isError()) {
149
149
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
153
153
$ret = GalleryCoreApi::releaseLocks($lockId);
154
if ($ret->isError()) {
155
155
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
159
159
$ret = $this->_verifyEntity($album);
160
if ($ret->isError()) {
161
161
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
165
165
$ret = $this->_deleteAndVerifyEntity($album->getId());
166
if ($ret->isError()) {
167
167
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
188
188
$ret = $this->_deleteAndVerifyEntity($nested[0]->getId());
189
if ($ret->isError()) {
190
190
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
193
193
for ($i = 0; $i < $iterations; $i++) {
194
194
$ret = $this->_verifyMissing($nested[$i]->getId());
195
if ($ret->isError()) {
196
196
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
211
211
$parentId = $this->_parentAlbum->getId();
212
212
for ($i = 0; $i < 3; $i++) {
213
213
list ($ret, $album[$i]) = $this->_createRandomAlbum($parentId);
214
if ($ret->isError()) {
215
215
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
217
217
$parentId = $album[$i]->getId();
250
250
/* Read lock the root, write lock the two new albums */
251
251
list ($ret, $lockIds[]) =
252
252
GalleryCoreApi::acquireReadLock(array($this->_parentAlbum->getId()));
253
if ($ret->isError()) {
254
254
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
257
257
list ($ret, $lockIds[]) = GalleryCoreApi::acquireWriteLock(array($album[0]->getId(),
258
258
$album[1]->getId(),
260
if ($ret->isError()) {
261
261
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
264
264
for ($i = 0; $i < 2; $i++) {
265
265
list ($ret, $album[$i]) = $album[$i]->refresh();
266
if ($ret->isError()) {
267
267
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
271
271
/* Move one of the target albums */
272
272
$ret = $album[1]->move($this->_parentAlbum->getId());
273
if ($ret->isError()) {
274
274
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
278
278
$ret = $album[1]->save();
279
if ($ret->isError()) {
280
280
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
283
283
$ret = GalleryCoreApi::releaseLocks($lockIds);
284
if ($ret->isError()) {
285
285
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
288
288
/* Verify parents */
289
289
for ($i = 0; $i < 2; $i++) {
290
290
list ($ret, $album[$i]) = $album[$i]->refresh();
291
if ($ret->isError()) {
292
292
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
343
343
/* Now we've created our nested tree. Fetch it all back again */
344
344
list ($ret, $actual) = GalleryCoreApi::fetchParents($nested[$iterations-1]);
345
if ($ret->isError()) {
346
346
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
349
349
list ($ret, $expected[0]) = GalleryCoreApi::loadEntitiesById($this->_getRootId());
350
if ($ret->isError()) {
351
351
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
353
353
list ($ret, $expected[1]) = GalleryCoreApi::loadEntitiesById($this->_parentAlbum->getId());
354
if ($ret->isError()) {
355
355
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
357
357
for ($i = 0; $i < sizeof($nested)-1; $i++) {
364
364
function testFetchParentsWithPermission() {
365
365
list ($ret, $album) = $this->_createRandomAlbum($this->_parentAlbum->getId());
366
if ($ret->isError()) {
367
367
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
369
369
list ($ret, $subalbum) = $this->_createRandomAlbum($album->getId());
370
if ($ret->isError()) {
371
371
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
373
373
$ret = GalleryCoreApi::removeItemPermissions($this->_parentAlbum->getId());
374
if ($ret->isError()) {
375
375
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
377
377
list ($ret, $root) = GalleryCoreApi::loadEntitiesById($this->_getRootId());
378
if ($ret->isError()) {
379
379
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
382
382
list ($ret, $actual) = GalleryCoreApi::fetchParents($subalbum, 'core.view');
383
if ($ret->isError()) {
384
384
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
392
392
$this->_becomeGuestUser();
393
393
GalleryDataCache::clearPermissionCache();
394
394
$ret = GalleryCoreApi::assertHasItemPermission($this->_getRootId(), 'core.delete');
395
if ($ret->isSuccess()) {
396
396
$this->assert(false, 'Guest should not have core.delete on root album');
400
400
list ($ret, $actual) = GalleryCoreApi::fetchParents($this->_parentAlbum, 'core.delete');
401
if ($ret->isError()) {
402
402
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
415
415
list ($ret, $parent) = $this->_createRandomAlbum($this->_parentAlbum->getId());
416
if ($ret->isError()) {
417
417
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
420
420
list ($ret, $child) = $this->_createRandomAlbum($parent->getId());
421
if ($ret->isError()) {
422
422
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
425
425
GalleryDataCache::reset();
427
427
list ($ret, $actual) = GalleryCoreApi::fetchChildItemIds($parent);
428
if ($ret->isError()) {
429
429
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
448
448
/* Album has no thumbnail, 1 child */
449
449
list ($ret, $child) =
450
450
$this->_createRandomDataItem($this->_parentAlbum->getId(), 'test/file');
451
if ($ret->isError()) {
452
452
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
455
455
list ($ret, $success) =
456
456
GalleryCoreApi::guaranteeAlbumHasThumbnail($this->_parentAlbum->getId());
457
if ($ret->isError()) {
458
458
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
478
478
function testGuaranteeAlbumHasThumbnail3() {
479
479
/* Album has a thumbnail but its source isn't in the album, 1 child */
480
480
list ($ret, $subAlbum) = $this->_createRandomAlbum($this->_parentAlbum->getId());
481
if ($ret->isError()) {
482
482
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
485
485
/* Create a thumbnail sourced from the parent album */
486
486
list ($ret, $derivative) =
487
487
GalleryCoreApi::newFactoryInstanceByHint('GalleryDerivative', '*');
488
if ($ret->isError()) {
489
489
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
492
$ret = $derivative->create($subAlbum->getId(), DERIVATIVE_TYPE_IMAGE_THUMBNAIL, 'test/file');
493
if ($ret->isError()) {
492
$ret = $derivative->create($subAlbum->getId(), DERIVATIVE_TYPE_IMAGE_THUMBNAIL,
494
495
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
496
497
$derivative->setMimeType('test/file');
497
498
$derivative->setDerivativeSourceId($this->_parentAlbum->getId());
498
499
$derivative->setDerivativeOperations('thumbnail|150');
499
500
$ret = $derivative->save();
500
if ($ret->isError()) {
501
502
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
504
505
list ($ret, $child) = $this->_createRandomDataItem($subAlbum->getId(), 'test/file');
505
if ($ret->isError()) {
506
507
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
509
510
list ($ret, $success) = GalleryCoreApi::guaranteeAlbumHasThumbnail($subAlbum->getId());
510
if ($ret->isError()) {
511
512
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
540
541
list ($ret, $lockId) = GalleryCoreApi::acquireWriteLock($this->_parentAlbum->getId());
541
if ($ret->isError()) {
542
543
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
545
546
list ($ret, $basePath) = $this->_parentAlbum->fetchPath();
546
if ($ret->isError()) {
547
548
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
550
$platform = $gallery->getPlatform();
551
$platform =& $gallery->getPlatform();
551
552
$slash = $platform->getDirectorySeparator();
553
554
for ($i = 0; $i < 3; $i++) {
554
555
$entity[$i] = new GalleryAlbumItem();
555
556
$ret = $entity[$i]->create($this->_parentAlbum->getId(), 'valid_path');
556
if ($ret->isError()) {
557
558
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
560
561
$ret = $entity[$i]->save();
561
if ($ret->isError()) {
562
563
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
592
593
list ($ret, $outerAlbum) = $this->_createRandomAlbum($this->_parentAlbum->getId());
593
if ($ret->isError()) {
594
595
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
597
598
list ($ret, $innerAlbum) = $this->_createRandomAlbum($outerAlbum->getId());
598
if ($ret->isError()) {
599
600
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
602
603
list ($ret, $lockIds[]) = GalleryCoreApi::acquireReadLock(
603
604
array($this->_getRootId(), $this->_parentAlbum->getId()));
606
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
605
609
list ($ret, $lockIds[]) =
606
610
GalleryCoreApi::acquireWriteLock(array($innerAlbum->getId(), $outerAlbum->getId()));
612
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
608
615
$ret = $innerAlbum->rename('test');
609
if ($ret->isError()) {
610
617
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
612
619
$ret = $innerAlbum->save();
613
if ($ret->isError()) {
614
621
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
617
624
$ret = $outerAlbum->rename('test');
618
if ($ret->isError()) {
619
626
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
621
628
$ret = $outerAlbum->save();
622
if ($ret->isError()) {
623
630
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
626
633
$ret = $innerAlbum->move($this->_parentAlbum->getId());
627
if ($ret->isError()) {
628
635
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
631
638
list ($ret, $basePath) = $this->_parentAlbum->fetchPath();
632
if ($ret->isError()) {
633
640
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
636
643
list ($ret, $newPath) = $innerAlbum->fetchPath();
637
if ($ret->isError()) {
638
645
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
641
$platform = $gallery->getPlatform();
648
$platform =& $gallery->getPlatform();
642
649
$slash = $platform->getDirectorySeparator();
643
650
$this->assertEquals($basePath . 'test_001' . $slash, $newPath, 'full path mismatch');
645
$platform = $gallery->getPlatform();
646
652
$this->assert($platform->file_exists($newPath), "$newPath does not exist");
647
653
$this->assert($platform->is_dir($newPath), "$newPath is not a file");
649
655
$ret = GalleryCoreApi::releaseLocks($lockIds);
650
if ($ret->isError()) {
651
657
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
658
664
/* Create an album with one group of settings */
659
665
list ($ret, $album) = $this->_createRandomAlbum(
660
666
$this->_parentAlbum->getId(),
661
array('theme' => 'a', 'orderby' => 'b', 'orderdirection' => 'c'));
662
if ($ret->isError()) {
667
array('theme' => 'a', 'orderBy' => 'b', 'orderDirection' => 'c'));
663
669
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
670
676
'default.newAlbumsUseDefaults' => 'false')
671
677
as $key => $value) {
672
678
$ret = GalleryCoreApi::setPluginParameter('module', 'core', $key, $value);
673
if ($ret->isError()) {
674
680
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
678
684
/* Create a sub album. It should inherit from the parent */
679
685
list ($ret, $child1) = $this->_createRandomAlbum($album->getId());
680
if ($ret->isError()) {
681
687
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
688
694
/* Now switch to using the defaults */
689
695
$ret = GalleryCoreApi::setPluginParameter(
690
696
'module', 'core', 'default.newAlbumsUseDefaults', 'true');
691
if ($ret->isError()) {
692
698
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
695
701
/* Create a sub album. It should pick up the defaults */
696
702
list ($ret, $child2) = $this->_createRandomAlbum($album->getId());
697
if ($ret->isError()) {
698
704
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
712
718
* \_1-3 \_5--6--7 should appear as a child of 2 in the tree
714
720
list ($ret, $album[0]) = $this->_createRandomAlbum($this->_parentAlbum->getId());
715
if ($ret->isError()) {
716
722
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
718
724
list ($ret, $album[1]) = $this->_createRandomAlbum($this->_parentAlbum->getId());
719
if ($ret->isError()) {
720
726
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
722
728
list ($ret, $album[2]) = $this->_createRandomAlbum($album[0]->getId());
723
if ($ret->isError()) {
724
730
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
726
732
list ($ret, $album[3]) = $this->_createRandomAlbum($album[1]->getId());
727
if ($ret->isError()) {
728
734
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
730
736
list ($ret, $album[4]) = $this->_createRandomAlbum($album[2]->getId());
731
if ($ret->isError()) {
732
738
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
734
740
list ($ret, $album[5]) = $this->_createRandomAlbum($album[2]->getId());
735
if ($ret->isError()) {
736
742
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
738
744
list ($ret, $album[6]) = $this->_createRandomAlbum($album[5]->getId());
739
if ($ret->isError()) {
740
746
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
742
748
list ($ret, $album[7]) = $this->_createRandomAlbum($album[6]->getId());
743
if ($ret->isError()) {
744
750
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
746
752
$ret = GalleryCoreApi::removeItemPermissions($album[5]->getId());
747
if ($ret->isError()) {
748
754
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
781
787
$this->assertEquals($allIds, $ids, 'all ids');
783
789
list ($ret, $tree) = GalleryCoreApi::fetchAlbumTree($album[0]->getId());
784
if ($ret->isError()) {
785
791
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
787
793
$this->assertEquals($subTree, $tree, 'sub tree');
789
795
list ($ret, $tree) = GalleryCoreApi::fetchAlbumTree($this->_parentAlbum->getId(), 2);
790
if ($ret->isError()) {
791
797
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
793
799
$this->assertEquals($depthTree, $tree, 'depth tree');
795
801
list ($ret, $tree) = GalleryCoreApi::fetchAlbumTree(null, 1);
796
if ($ret->isError()) {
797
803
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
799
805
$this->assertEquals(array(), $tree[$this->_parentAlbum->getId()], 'test album');
804
810
function testFetchAlbumTreeNoPermissions() {
812
$session =& $gallery->getSession();
807
814
list ($ret, $user) = $this->_createRandomUser();
808
if ($ret->isError()) {
809
816
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
811
818
$this->_markForCleanup($user);
813
820
/* Delete all acls for this user */
814
GalleryCoreApi::relativeRequireOnce('modules/core/classes/GalleryAccessMap.class');
815
$ret = GalleryAccessMap::removeMapEntry(array('userId' => $user->getId()));
816
if ($ret->isError()) {
821
$ret = GalleryCoreApi::removeMapEntry(
822
'GalleryAccessMap', array('userOrGroupId' => $user->getId()));
817
824
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
819
826
GalleryDataCache::reset();
823
830
* some permissions.
825
832
$ret = GalleryCoreApi::removeUserFromAllGroups($user->getId());
826
if ($ret->isError()) {
827
834
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
830
837
/* Put user in some random group that has no permissions */
831
838
list ($ret, $group) = $this->_createRandomGroup();
832
if ($ret->isError()) {
833
840
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
835
842
$this->_markForCleanup($group);
837
844
$ret = GalleryCoreApi::addUserToGroup($user->getId(), $group->getId());
838
if ($ret->isError()) {
839
846
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
849
/* Clear any session permissions */
850
$session->remove(GALLERY_PERMISSION_SESSION_KEY);
842
852
$gallery->setActiveUser($user);
844
854
/* Verify that the album tree is empty */
845
855
list ($ret, $tree) = GalleryCoreApi::fetchAlbumTree($this->_getRootId());
846
if ($ret->isError()) {
847
857
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
857
867
list ($ret, $album) = GalleryCoreApi::createAlbum(
858
868
$this->_parentAlbum->getId(), $albumName,
859
869
'title', 'summary', 'description', 'keywords');
860
if ($ret->isError()) {
861
871
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
864
874
list ($ret, $album) = $album->refresh();
865
if ($ret->isError()) {
866
876
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
869
879
list ($ret, $path) = $album->fetchPath();
870
if ($ret->isError()) {
871
881
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
878
888
* Verify that the path in the database matches the path on disk, since we're expecting
879
889
* that the whitespace will get trimmed on both sides.
881
$platform = $gallery->getPlatform();
891
$platform =& $gallery->getPlatform();
882
892
$this->assert($platform->file_exists($path), 'Path doesn\'t exist');
888
898
list ($ret, $album) = $this->_createRandomAlbum($this->_parentAlbum->getId());
889
if ($ret->isError()) {
890
900
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
893
903
$newAlbumName = sprintf(' album %d test ', rand());
895
905
list ($ret, $locks[]) = GalleryCoreApi::acquireWriteLock($album->getId());
896
if ($ret->isError()) {
897
907
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
900
910
$ret = $album->rename($newAlbumName);
901
if ($ret->isError()) {
902
912
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
905
915
$ret = $album->save();
906
if ($ret->isError()) {
907
917
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
910
920
list ($ret, $album) = $album->refresh();
911
if ($ret->isError()) {
912
922
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
915
925
list ($ret, $path) = $album->fetchPath();
916
if ($ret->isError()) {
917
927
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
920
930
$ret = GalleryCoreApi::releaseLocks($locks);
921
if ($ret->isError()) {
922
932
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
926
936
* Verify that the path in the database matches the path on disk, since we're expecting
927
937
* that the whitespace will get trimmed on both sides.
929
$platform = $gallery->getPlatform();
939
$platform =& $gallery->getPlatform();
930
940
$this->assert($platform->file_exists($path), 'Path doesn\'t exist');
932
942
$this->assertEquals(trim($newAlbumName), basename($path));
954
964
$destFilename, $parameters, $context=array()) {
956
966
if ($sourceFilename != $destFilename) {
957
$platform = $gallery->getPlatform();
967
$platform =& $gallery->getPlatform();
958
968
$platform->copy($sourceFilename, $destFilename);
960
return array(GalleryStatus::success(), $mimeType, $context);
970
return array(null, $mimeType, $context);