3
* $RCSfile: LinkItemOptionTest.class,v $
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2006 Bharat Mediratta
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.
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.
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.
23
* @version $Revision: 1.2 $ $Date: 2006/01/10 04:40:36 $
26
* @author Alan Harder <alan.harder@sun.com>
29
GalleryCoreApi::requireOnce('lib/tools/phpunit/ItemEditOptionTestCase.class');
32
* LinkItemOption tests
36
class LinkItemOptionTest extends ItemEditOptionTestCase {
38
function LinkItemOptionTest($methodName) {
39
$this->ItemEditOptionTestCase($methodName, 'linkitem', 'LinkItemOption');
45
list ($ret, $this->_album) = $this->_createRandomAlbum($this->_getRootId());
47
print $ret->getAsHtml();
48
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
50
$this->_markForCleanup($this->_album);
52
list ($ret, $lockId) = GalleryCoreApi::acquireReadLock(array($this->_album->getId()));
54
print $ret->getAsHtml();
55
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
58
list ($ret, $this->_link) =
59
GalleryCoreApi::newFactoryInstance('GalleryEntity', 'GalleryLinkItem');
61
print $ret->getAsHtml();
62
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
64
if (empty($this->_link)) {
65
return $this->failWithStatus(
66
GalleryCoreApi::error(ERROR_MISSING_OBJECT, __FILE__, __LINE__));
68
$ret = $this->_link->create($this->_album->getId(), 'http://test.com/test.html');
70
print $ret->getAsHtml();
71
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
73
$ret = $this->_link->save();
75
print $ret->getAsHtml();
76
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
79
$ret = GalleryCoreApi::releaseLocks($lockId);
81
print $ret->getAsHtml();
82
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
86
function testSetUrl() {
87
$form = array('LinkItemOption' => array('link' => 'http://test.net/'));
89
list ($error, $warning) = $this->_handleRequestAfterEdit($form, $this->_link);
90
$this->assertEquals(array(), $error);
91
$this->assertEquals(array(), $warning);
93
list ($ret, $link) = $this->_link->refresh();
95
return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
97
$this->assertEquals('http://test.net/', $link->getLink());
100
function testMissingUrl() {
101
$form = array('LinkItemOption' => array('link' => ''));
103
list ($error, $warning) = $this->_handleRequestAfterEdit($form, $this->_link);
104
$this->assertEquals(array('form[LinkItemOption][error][link][missing]'), $error);
105
$this->assertEquals(array(), $warning);