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.
22
* PublishXp controller tests
25
* @author Bharat Mediratta <bharat@menalto.com>
26
* @version $Revision: 15759 $
28
class PublishXpLoginControllerTest extends GalleryControllerTestCase {
29
function PublishXpLoginControllerTest($methodName) {
30
$this->GalleryControllerTestCase($methodName, 'publishxp.PublishXpLogin');
37
list ($ret, $this->_user) = $this->_createRandomUser();
39
print $ret->getAsHtml();
40
return $this->failWithStatus($ret);
42
$this->_markForCleanup($this->_user);
45
function testLogin() {
46
GalleryUtilities::putRequestVariable('form[userName]', $this->_user->getUserName());
47
GalleryUtilities::putRequestVariable('form[password]', 'password');
48
GalleryUtilities::putRequestVariable('form[action][login]', 1);
50
$listener = new NullEventListener();
51
$this->_registerTestEventListener('Gallery::Login', $listener);
53
$result = $this->handleRequest();
55
array('status' => array(),
57
'redirect' => array('view' => 'publishxp.SelectAlbum')),
60
/* Verify our event got posted */
61
$this->assertEquals('Gallery::Login', $listener->_event->getEventName(), 'wrong event');
62
$this->assertEquals($this->_user, $listener->_event->getEntity());
65
function testLoginDisabledUser() {
66
GalleryUtilities::putRequestVariable('form[userName]', $this->_user->getUserName());
67
GalleryUtilities::putRequestVariable('form[password]', 'password');
68
GalleryUtilities::putRequestVariable('form[action][login]', 1);
70
$ret = $this->_disableUserName($this->_user->getUserName());
72
return $this->failWithStatus($ret);
75
$listener = new NullEventListener();
76
$this->_registerTestEventListener('Gallery::FailedLogin', $listener);
78
$result = $this->handleRequest();
80
array('status' => array(),
81
'error' => array('form[error][userName][disabled]'),
82
'delegate' => array('view' => 'publishxp.PublishXpLogin')),
85
/* Verify our event got posted */
87
'Gallery::FailedLogin', $listener->_event->getEventName(), 'wrong event');
88
$this->assertEquals(array('userName' => $this->_user->getUserName()),
89
$listener->_event->getData());