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.
24
* @author Felix Rabinovich <felix@rabinovich.org>
25
* @version $Revision: 15513 $
27
class MimeAdminControllerTest extends GalleryControllerTestCase {
29
function MimeAdminControllerTest($methodName) {
30
$this->GalleryControllerTestCase($methodName, 'mime.MimeAdmin');
36
$ret = $this->_markPluginParametersForCleanup('module', 'mime');
38
print $ret->getAsHtml();
39
return $this->failWithStatus($ret);
41
$ret = GalleryCoreApi::addMimeType('xxx', 'test/test', false);
43
print $ret->getAsHtml();
44
return $this->failWithStatus($ret);
49
$ret = GalleryCoreApi::removeMimeType(array('mimeType' => 'test/test'));
51
$this->failWithStatus($ret);
57
function testSaveAllowAll() {
58
GalleryUtilities::putRequestVariable('form[action][save]', 'Save');
59
GalleryUtilities::putRequestVariable('form[allowMime]', 'all');
60
GalleryUtilities::putRequestVariable('form[upload][test/test]', 'on');
62
$results = $this->handleRequest();
63
$this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
64
'subView' => 'mime.MimeAdmin'),
65
'status' => array('saved' => true),
69
list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'mime');
71
return $this->failWithStatus($ret);
73
$this->assertEquals('all', $params['allowMime'], 'allowMime');
74
$this->assertEquals('', $params['mimeList'], 'mimeList');
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');
83
$results = $this->handleRequest();
84
$this->assertEquals(array('redirect' => array('view' => 'core.SiteAdmin',
85
'subView' => 'mime.MimeAdmin'),
86
'status' => array('saved' => true),
90
list ($ret, $params) = GalleryCoreApi::fetchAllPluginParameters('module', 'mime');
92
return $this->failWithStatus($ret);
94
$this->assertEquals('block', $params['allowMime'], 'allowMime');
95
$this->assertEquals('image/bmp | test/test', $params['mimeList'], 'mimeList');
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'),
106
list ($ret, $extensions) = GalleryCoreApi::convertMimeToExtensions('test/test');
108
return array($ret, null);
110
$this->assertEquals(array(), $extensions, 'Delete results');