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

« back to all changes in this revision

Viewing changes to modules/mime/test/phpunit/MimeAdminControllerTest.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
 
 * @package Mime
23
 
 * @subpackage PHPUnit
24
 
 * @author Felix Rabinovich <felix@rabinovich.org>
25
 
 * @version $Revision: 15513 $
26
 
 */
27
 
class MimeAdminControllerTest extends GalleryControllerTestCase {
28
 
 
29
 
    function MimeAdminControllerTest($methodName) {
30
 
        $this->GalleryControllerTestCase($methodName, 'mime.MimeAdmin');
31
 
    }
32
 
 
33
 
    function setUp() {
34
 
        parent::setUp();
35
 
 
36
 
        $ret = $this->_markPluginParametersForCleanup('module', 'mime');
37
 
        if ($ret) {
38
 
            print $ret->getAsHtml();
39
 
            return $this->failWithStatus($ret);
40
 
        }
41
 
        $ret = GalleryCoreApi::addMimeType('xxx', 'test/test', false);
42
 
        if ($ret) {
43
 
            print $ret->getAsHtml();
44
 
            return $this->failWithStatus($ret);
45
 
        }
46
 
    }
47
 
 
48
 
    function tearDown() {
49
 
        $ret = GalleryCoreApi::removeMimeType(array('mimeType' => 'test/test'));
50
 
        if ($ret) {
51
 
            $this->failWithStatus($ret);
52
 
        }
53
 
 
54
 
        parent::tearDown();
55
 
    }
56
 
 
57
 
    function testSaveAllowAll() {
58
 
        GalleryUtilities::putRequestVariable('form[action][save]', 'Save');
59
 
        GalleryUtilities::putRequestVariable('form[allowMime]', 'all');
60
 
        GalleryUtilities::putRequestVariable('form[upload][test/test]', 'on');
61
 
 
62
 
        $results = $this->handleRequest();
63
 
        $this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
64
 
                                                      'subView' => 'mime.MimeAdmin'),
65
 
                                  'status' => array('saved' => true),
66
 
                                  'error' => array()),
67
 
                            $results);
68
 
 
69
 
        list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'mime');
70
 
        if ($ret) {
71
 
            return $this->failWithStatus($ret);
72
 
        }
73
 
        $this->assertEquals('all', $params['allowMime'], 'allowMime');
74
 
        $this->assertEquals('', $params['mimeList'], 'mimeList');
75
 
    }
76
 
 
77
 
    function testSaveBlock() {
78
 
        GalleryUtilities::putRequestVariable('form[action][save]', 'Save');
79
 
        GalleryUtilities::putRequestVariable('form[allowMime]', 'block');
80
 
        GalleryUtilities::putRequestVariable('form[upload][image/bmp]', 'on');
81
 
        GalleryUtilities::putRequestVariable('form[upload][test/test]', 'on');
82
 
 
83
 
        $results = $this->handleRequest();
84
 
        $this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
85
 
                                                      'subView' => 'mime.MimeAdmin'),
86
 
                                  'status' => array('saved' => true),
87
 
                                  'error' => array()),
88
 
                            $results);
89
 
 
90
 
        list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'mime');
91
 
        if ($ret) {
92
 
            return $this->failWithStatus($ret);
93
 
        }
94
 
        $this->assertEquals('block', $params['allowMime'], 'allowMime');
95
 
        $this->assertEquals('image/bmp | test/test', $params['mimeList'], 'mimeList');
96
 
    }
97
 
 
98
 
    function testDelete() {
99
 
        GalleryUtilities::putRequestVariable('form[action][delete]', 'test/test');
100
 
        $results = $this->handleRequest();
101
 
        $this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
102
 
                                                      'subView' => 'mime.MimeAdmin'),
103
 
                                  'status' => array('deleted' => 'test/test'),
104
 
                                  'error' => array()),
105
 
                            $results, 'Delete');
106
 
        list ($ret, $extensions) = GalleryCoreApi::convertMimeToExtensions('test/test');
107
 
        if ($ret) {
108
 
            return array($ret, null);
109
 
        }
110
 
        $this->assertEquals(array(), $extensions, 'Delete results');
111
 
    }
112
 
}
113
 
?>