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

« back to all changes in this revision

Viewing changes to modules/publishxp/test/phpunit/PublishXpLoginControllerTest.class

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2007-09-10 20:22:19 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070910202219-0jsuntvqge4ade6b
Tags: 2.2.3-2
Add Slovak translation of Debconf templates.  (Thanks to 
Ivan Masá.  Closes: #441671)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?php
2
 
/*
3
 
 * Gallery - a web based photo album viewer and editor
4
 
 * Copyright (C) 2000-2007 Bharat Mediratta
5
 
 *
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.
10
 
 *
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.
15
 
 *
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.
19
 
 */
20
 
 
21
 
/**
22
 
 * PublishXp controller tests
23
 
 * @package PublishXp
24
 
 * @subpackage PHPUnit
25
 
 * @author Bharat Mediratta <bharat@menalto.com>
26
 
 * @version $Revision: 15759 $
27
 
 */
28
 
class PublishXpLoginControllerTest extends GalleryControllerTestCase {
29
 
    function PublishXpLoginControllerTest($methodName) {
30
 
        $this->GalleryControllerTestCase($methodName, 'publishxp.PublishXpLogin');
31
 
    }
32
 
 
33
 
    function setUp() {
34
 
        global $gallery;
35
 
        parent::setUp();
36
 
 
37
 
        list ($ret, $this->_user) = $this->_createRandomUser();
38
 
        if ($ret) {
39
 
            print $ret->getAsHtml();
40
 
            return $this->failWithStatus($ret);
41
 
        }
42
 
        $this->_markForCleanup($this->_user);
43
 
    }
44
 
 
45
 
    function testLogin() {
46
 
        GalleryUtilities::putRequestVariable('form[userName]', $this->_user->getUserName());
47
 
        GalleryUtilities::putRequestVariable('form[password]', 'password');
48
 
        GalleryUtilities::putRequestVariable('form[action][login]', 1);
49
 
 
50
 
        $listener = new NullEventListener();
51
 
        $this->_registerTestEventListener('Gallery::Login', $listener);
52
 
 
53
 
        $result = $this->handleRequest();
54
 
        $this->assertEquals(
55
 
            array('status' => array(),
56
 
                  'error' => array(),
57
 
                  'redirect' => array('view' => 'publishxp.SelectAlbum')),
58
 
            $result);
59
 
 
60
 
        /* Verify our event got posted */
61
 
        $this->assertEquals('Gallery::Login', $listener->_event->getEventName(), 'wrong event');
62
 
        $this->assertEquals($this->_user, $listener->_event->getEntity());
63
 
    }
64
 
 
65
 
    function testLoginDisabledUser() {
66
 
        GalleryUtilities::putRequestVariable('form[userName]', $this->_user->getUserName());
67
 
        GalleryUtilities::putRequestVariable('form[password]', 'password');
68
 
        GalleryUtilities::putRequestVariable('form[action][login]', 1);
69
 
 
70
 
        $ret = $this->_disableUserName($this->_user->getUserName());
71
 
        if ($ret) {
72
 
            return $this->failWithStatus($ret);
73
 
        }
74
 
 
75
 
        $listener = new NullEventListener();
76
 
        $this->_registerTestEventListener('Gallery::FailedLogin', $listener);
77
 
 
78
 
        $result = $this->handleRequest();
79
 
        $this->assertEquals(
80
 
            array('status' => array(),
81
 
                  'error' => array('form[error][userName][disabled]'),
82
 
                  'delegate' => array('view' => 'publishxp.PublishXpLogin')),
83
 
            $result);
84
 
 
85
 
        /* Verify our event got posted */
86
 
        $this->assertEquals(
87
 
            'Gallery::FailedLogin', $listener->_event->getEventName(), 'wrong event');
88
 
        $this->assertEquals(array('userName' => $this->_user->getUserName()),
89
 
                            $listener->_event->getData());
90
 
    }
91
 
}
92
 
?>