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

« back to all changes in this revision

Viewing changes to modules/core/test/phpunit/MarkupTest.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:
3
3
 * $RCSfile: MarkupTest.class,v $
4
4
 *
5
5
 * Gallery - a web based photo album viewer and editor
6
 
 * Copyright (C) 2000-2005 Bharat Mediratta
 
6
 * Copyright (C) 2000-2006 Bharat Mediratta
7
7
 *
8
8
 * This program is free software; you can redistribute it and/or modify
9
9
 * it under the terms of the GNU General Public License as published by
20
20
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
21
21
 */
22
22
/**
23
 
 * @version $Revision: 1.14 $ $Date: 2005/08/23 03:49:33 $
 
23
 * @version $Revision: 1.17 $ $Date: 2006/02/03 16:52:34 $
24
24
 * @package GalleryCore
25
25
 * @subpackage PHPUnit
26
26
 * @author Bharat Mediratta <bharat@menalto.com>
30
30
/**
31
31
 * Required classes
32
32
 */
33
 
GalleryCoreApi::relativeRequireOnce('lib/smarty_plugins/modifier.markup.php');
 
33
GalleryCoreApi::requireOnce('lib/smarty_plugins/modifier.markup.php');
34
34
 
35
35
/**
36
36
 * Test Markup functionality
53
53
 
54
54
        list ($ret, $this->_markup) =
55
55
            GalleryCoreApi::getPluginParameter('module', 'core', 'misc.markup');
56
 
        if ($ret->isError()) {
 
56
        if ($ret) {
57
57
            print $ret->getAsHtml();
58
58
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
59
59
        }
61
61
 
62
62
    function tearDown() {
63
63
        $ret = GalleryCoreApi::setPluginParameter('module', 'core', 'misc.markup', $this->_markup);
64
 
        if ($ret->isError()) {
 
64
        if ($ret) {
65
65
            $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
66
66
        }
67
67
 
121
121
                            "\n<li>four<br /></li>\n</ul>", $results);
122
122
    }
123
123
 
124
 
    function testImage() {
 
124
    function testImageUrl() {
125
125
        $results = $this->_bbcode->parse('[img]http://example.com/foo.gif[/img]');
126
 
        $this->assertEquals('<img src="http://example.com/foo.gif" alt="">', $results);
 
126
        $this->assertEquals('<img src="http://example.com/foo.gif" alt=""/>', $results);
 
127
    }
 
128
 
 
129
    function testImagePath() {
 
130
        $results = $this->_bbcode->parse('[img]/path/foo.gif[/img]');
 
131
        $this->assertEquals('<img src="/path/foo.gif" alt=""/>', $results);
 
132
    }
 
133
 
 
134
    function testImageEntity() {
 
135
        /* Our input should be properly escaped, so bbcode doesn't need to entitize things */
 
136
        $results = $this->_bbcode->parse('[img]http://image.com/get?id=123&amp;size=small[/img]');
 
137
        $this->assertEquals('<img src="http://image.com/get?id=123&amp;size=small" alt=""/>',
 
138
                            $results);
127
139
    }
128
140
 
129
141
    function testJavascriptInImage() {
162
174
        $this->assertEquals('[url=bogus://example.com]content[/url]', $results);
163
175
    }
164
176
 
 
177
    function testUrl7() {
 
178
        $results = $this->_bbcode->parse('[url=/path/file.php]content[/url]');
 
179
        $this->assertEquals('<a href="/path/file.php">content</a>', $results);
 
180
    }
 
181
 
 
182
    function testUrl8() {
 
183
        $results = $this->_bbcode->parse('[url=javascript:alert()]content[/url]');
 
184
        $this->assertEquals('[url=javascript:alert()]content[/url]', $results);
 
185
        $results = $this->_bbcode->parse('[url]javascript:alert()[/url]');
 
186
        $this->assertEquals('[url]javascript:alert()[/url]', $results);
 
187
    }
 
188
 
165
189
    function testJavascript() {
166
190
        $results = $this->_bbcode->parse('[url=javascript:alert(\'hi\')]content[/url]');
167
191
        $this->assertEquals('[url=javascript:alert(\'hi\')]content[/url]', $results);
181
205
 
182
206
    function testMarkupNone() {
183
207
        $ret = GalleryCoreApi::setPluginParameter('module', 'core', 'misc.markup', 'none');
184
 
        if ($ret->isError()) {
 
208
        if ($ret) {
185
209
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
186
210
        }
187
211
 
193
217
 
194
218
    function testMarkupBbcode() {
195
219
        $ret = GalleryCoreApi::setPluginParameter('module', 'core', 'misc.markup', 'bbcode');
196
 
        if ($ret->isError()) {
 
220
        if ($ret) {
197
221
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
198
222
        }
199
223
 
206
230
 
207
231
    function testMarkupHtml() {
208
232
        $ret = GalleryCoreApi::setPluginParameter('module', 'core', 'misc.markup', 'html');
209
 
        if ($ret->isError()) {
 
233
        if ($ret) {
210
234
            return $this->failWithStatus($ret->wrap(__FILE__, __LINE__));
211
235
        }
212
236