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/migrate/classes/G1MigrateHelper.class');
24
* ConfirmImport controller tests
27
* @author Jay Rossiter <cryptographite@users.sf.net>
28
* @version $Revision: 15513 $
30
class MigrateEventHandlerTest extends GalleryControllerTestCase {
31
var $_temporaryAlbumId;
33
function MigrateEventHandlerTest($methodName) {
34
$this->GalleryTestCase($methodName, 'migrate.ConfirmImport');
42
list ($ret, $this->_temporaryAlbum) = $this->_createRandomAlbum($this->_getRootId());
44
print $ret->getAsHtml();
45
return $this->failWithStatus($ret);
48
$this->_markForCleanup($this->_temporaryAlbum);
50
$this->_temporaryAlbumId = $this->_temporaryAlbum->getId();
52
list ($ret, $this->_mapCount) = G1MigrateHelper::fetchMapCount();
54
return $this->failWithStatus($ret);
61
list ($ret, $mapCount) = G1MigrateHelper::fetchMapCount();
63
return $this->failWithStatus($ret);
65
$this->assertEquals($this->_mapCount, $mapCount, 'Test altered number of map entries!');
70
function testMigrateDeleteEventHandler() {
71
// Create random album
72
list ($ret, $g1MapHandlerAlbum) = $this->_createRandomAlbum($this->_temporaryAlbumId);
74
return $this->failWithStatus($ret);
77
// Add map entry for $g1MapHandlerAlbum
78
$ret = GalleryCoreApi::addMapEntry(
80
array('itemId' => $g1MapHandlerAlbum->getId(),
81
'g1album' => $g1MapHandlerAlbum->getPathComponent(),
84
return $this->failWithStatus($ret);
87
// Create random data item
88
list ($ret, $g1MapHandlerItem) = $this->_createRandomDataItem($g1MapHandlerAlbum->getId());
90
return $this->failWithStatus($ret);
93
// Add map entry for $g1MapHandlerItem
94
$ret = GalleryCoreApi::addMapEntry(
96
array('itemId' => $g1MapHandlerItem->getId(),
97
'g1album' => $g1MapHandlerAlbum->getPathComponent(),
98
'g1item' => $g1MapHandlerItem->getPathComponent()));
100
return $this->failWithStatus($ret);
103
// Verify album mapping
104
list ($ret, $mapping) =
105
G1MigrateHelper::fetchMapping($g1MapHandlerAlbum->getPathComponent());
107
return $this->failWithStatus($ret);
109
$this->assertEquals($g1MapHandlerAlbum->getId(),
110
$mapping, 'G1MigrateMap does not match Album Id');
112
// Verify item mapping
113
list ($ret, $mapping) = G1MigrateHelper::fetchMapping(
114
$g1MapHandlerAlbum->getPathComponent(), $g1MapHandlerItem->getPathComponent());
116
return $this->failWithStatus($ret);
118
$this->assertEquals($g1MapHandlerItem->getId(), $mapping,
119
'G1MigrateMap does not match Item Id');
121
$event = GalleryCoreApi::newEvent('GalleryEntity::delete');
122
$event->setEntity($g1MapHandlerItem);
123
list ($ret) = MigrateModule::handleEvent($event);
125
return $this->failWithStatus($ret);
128
$event = GalleryCoreApi::newEvent('GalleryEntity::delete');
129
$event->setEntity($g1MapHandlerAlbum);
130
list ($ret) = MigrateModule::handleEvent($event);
132
return $this->failWithStatus($ret);
135
// Verify album mapping deleted
136
list ($ret, $mapping) =
137
G1MigrateHelper::fetchMapping($g1MapHandlerAlbum->getPathComponent());
139
return $this->failWithStatus($ret);
141
$this->assertEquals(NULL, $mapping, 'G1MigrateMap does not match Album Id');
143
// Verify item mapping
144
list ($ret, $mapping) = G1MigrateHelper::fetchMapping(
145
$g1MapHandlerAlbum->getPathComponent(), $g1MapHandlerItem->getPathComponent());
147
return $this->failWithStatus($ret);
149
$this->assertEquals(NULL, $mapping, 'G1MigrateMap does not match Item Id');