~ubuntu-branches/ubuntu/hardy/gallery2/hardy-security

« back to all changes in this revision

Viewing changes to modules/rating/test/phpunit/RatingSiteAdminControllerTest.class

  • Committer: Bazaar Package Importer
  • Author(s): Michael C. Schultheiss
  • Date: 2006-04-16 16:42:35 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20060416164235-8uy0u4bfjdxpge2o
Tags: 2.1.1-1
* New upstream release (Closes: #362936)
  + Bugfixes for Postgres7 (Closes: #359000, #362152)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*
 
3
 * $RCSfile: RatingSiteAdminControllerTest.class,v $
 
4
 *
 
5
 * Gallery - a web based photo album viewer and editor
 
6
 * Copyright (C) 2000-2006 Bharat Mediratta
 
7
 *
 
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.
 
12
 *
 
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.
 
17
 *
 
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.
 
21
 */
 
22
/**
 
23
 * @version $Revision: 1.2 $ $Date: 2006/01/10 04:41:54 $
 
24
 * @package Rating
 
25
 * @subpackage PHPUnit
 
26
 * @author Don Seiler <don@seiler.us>
 
27
 */
 
28
 
 
29
/**
 
30
 * RatingSiteAdmin controller tests
 
31
 *
 
32
 * @package Rating
 
33
 * @subpackage PHPUnit
 
34
 */
 
35
class RatingSiteAdminControllerTest extends GalleryControllerTestCase {
 
36
 
 
37
    function RatingSiteAdminControllerTest($methodName) {
 
38
        $this->GalleryControllerTestCase($methodName, 'rating.RatingSiteAdmin');
 
39
    }
 
40
 
 
41
    function setUp() {
 
42
        parent::setUp();
 
43
 
 
44
        $ret = $this->_markPluginParametersForCleanup('module', 'rating');
 
45
        if ($ret) {
 
46
            print $ret->getAsHtml();
 
47
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
48
        }
 
49
    }
 
50
 
 
51
    function testEnableAlbumRatings() {
 
52
        GalleryUtilities::putRequestVariable('form[action][save]', 'Save');
 
53
        GalleryUtilities::putRequestVariable('form[allowAlbumRating]', 'on');
 
54
        $results = $this->handleRequest();
 
55
        $this->assertEquals(array(
 
56
                    'redirect' => array(
 
57
                        'view' => 'core.SiteAdmin', 'subView' => 'rating.RatingSiteAdmin'),
 
58
                    'status' => array('saved' => 1),
 
59
                    'error' => array()),
 
60
                $results);
 
61
 
 
62
        list ($ret, $allowAlbumRating) = GalleryCoreApi::getPluginParameter('module', 'rating',
 
63
                'allowAlbumRating');
 
64
        if ($ret) {
 
65
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
66
        }
 
67
        $this->assertEquals(1, (int)$allowAlbumRating);
 
68
    }
 
69
 
 
70
    function testDisableAlbumRatings() {
 
71
        GalleryUtilities::putRequestVariable('form[action][save]', 'Save');
 
72
        $results = $this->handleRequest();
 
73
        $this->assertEquals(array(
 
74
                    'redirect' => array(
 
75
                        'view' => 'core.SiteAdmin', 'subView' => 'rating.RatingSiteAdmin'),
 
76
                    'status' => array('saved' => 1),
 
77
                    'error' => array()),
 
78
                $results);
 
79
 
 
80
        list ($ret, $allowAlbumRating) = GalleryCoreApi::getPluginParameter('module', 'rating',
 
81
                'allowAlbumRating');
 
82
        if ($ret) {
 
83
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
 
84
        }
 
85
        $this->assertEquals(0, (int)$allowAlbumRating);
 
86
    }
 
87
 
 
88
    function testReset() {
 
89
        GalleryUtilities::putRequestVariable('form[action][reset]', 'Reset');
 
90
        $results = $this->handleRequest();
 
91
        $this->assertEquals(array(
 
92
                    'redirect' => array(
 
93
                        'view' => 'core.SiteAdmin', 'subView' => 'rating.RatingSiteAdmin'),
 
94
                    'status' => array(),
 
95
                    'error' => array()),
 
96
                $results);
 
97
    }
 
98
}
 
99
?>