~ubuntu-branches/ubuntu/maverick/gallery2/maverick

« back to all changes in this revision

Viewing changes to modules/comment/test/phpunit/CommentSiteAdminControllerTest.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
 
 * CommentSiteAdmin controller tests
23
 
 *
24
 
 * @package Comment
25
 
 * @subpackage PHPUnit
26
 
 * @author Alan Harder <alan.harder@sun.com>
27
 
 * @version $Revision: 15513 $
28
 
 */
29
 
class CommentSiteAdminControllerTest extends GalleryControllerTestCase {
30
 
 
31
 
    function CommentSiteAdminControllerTest($methodName) {
32
 
        $this->GalleryControllerTestCase($methodName, 'comment.CommentSiteAdmin');
33
 
    }
34
 
 
35
 
    function setUp() {
36
 
        parent::setUp();
37
 
 
38
 
        $ret = $this->_markPluginParametersForCleanup('module', 'comment');
39
 
        if ($ret) {
40
 
            print $ret->getAsHtml();
41
 
            return $this->failWithStatus($ret);
42
 
        }
43
 
    }
44
 
 
45
 
    function testCommentSiteAdminControllerReset() {
46
 
        GalleryUtilities::putRequestVariable('form[action][reset]', '1');
47
 
 
48
 
        $results = $this->handleRequest();
49
 
        $this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
50
 
                                                      'subView' => 'comment.CommentSiteAdmin'),
51
 
                                  'status' => array(),
52
 
                                  'error' => array()),
53
 
                            $results);
54
 
    }
55
 
 
56
 
    function testCommentSiteAdminControllerSave() {
57
 
        GalleryUtilities::putRequestVariable('form[latest]', 1);
58
 
        GalleryUtilities::putRequestVariable('form[show]', '12');
59
 
        GalleryUtilities::putRequestVariable('form[action][save]', '1');
60
 
 
61
 
        $results = $this->handleRequest();
62
 
        $this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
63
 
                                                      'subView' => 'comment.CommentSiteAdmin'),
64
 
                                  'status' => array('saved' => 1),
65
 
                                  'error' => array()),
66
 
                            $results);
67
 
 
68
 
        foreach (array('latest' => '1', 'show' => '12') as $key => $expectedValue) {
69
 
            list ($ret, $value) =
70
 
                GalleryCoreApi::getPluginParameter('module', 'comment', 'comments.' . $key);
71
 
            if ($ret) {
72
 
                return $this->failWithStatus($ret);
73
 
            }
74
 
            $this->assertEquals($expectedValue, $value, $key);
75
 
        }
76
 
    }
77
 
 
78
 
    function testCommentSiteAdminControllerSaveNoShow() {
79
 
        GalleryUtilities::putRequestVariable('form[action][save]', '1');
80
 
 
81
 
        $results = $this->handleRequest();
82
 
        $this->assertEquals(array('delegate' => array('view' => 'core.SiteAdmin',
83
 
                                                      'subView' => 'comment.CommentSiteAdmin'),
84
 
                                  'status' => array(),
85
 
                                  'error' => array('form[error][show]')),
86
 
                            $results);
87
 
    }
88
 
 
89
 
    function testCommentSiteAdminControllerSaveBadShow() {
90
 
        GalleryUtilities::putRequestVariable('form[show]', 'abc5000');
91
 
        GalleryUtilities::putRequestVariable('form[action][save]', '1');
92
 
 
93
 
        $results = $this->handleRequest();
94
 
        $this->assertEquals(array('delegate' => array('view' => 'core.SiteAdmin',
95
 
                                                      'subView' => 'comment.CommentSiteAdmin'),
96
 
                                  'status' => array(),
97
 
                                  'error' => array('form[error][show]')),
98
 
                            $results);
99
 
    }
100
 
}
101
 
?>