Completed
Push — 3.4 ( fd9b87...94c3bc )
by Damian
07:31
created

ShortcodeParserTest::testEnclosing()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * @package framework
4
 * @subpackage tests
5
 */
6
class ShortcodeParserTest extends SapphireTest {
7
8
	protected $arguments, $contents, $tagName, $parser;
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
9
	protected $extra = array();
10
11
	public function setUp() {
12
		ShortcodeParser::get('test')->register('test_shortcode', array($this, 'shortcodeSaver'));
13
		$this->parser = ShortcodeParser::get('test');
14
15
		parent::setUp();
16
	}
17
18
	public function tearDown() {
19
		ShortcodeParser::get('test')->unregister('test_shortcode');
20
21
		parent::tearDown();
22
	}
23
24
	/**
25
	 * Tests that valid short codes that have not been registered are not replaced.
26
	 */
27
	public function testNotRegisteredShortcode() {
28
		ShortcodeParser::$error_behavior = ShortcodeParser::STRIP;
29
30
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
31
			'',
32
			$this->parser->parse('[not_shortcode]')
33
		);
34
35
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
36
			'<img class="">',
37
			$this->parser->parse('<img class="[not_shortcode]">')
38
		);
39
40
		ShortcodeParser::$error_behavior = ShortcodeParser::WARN;
41
42
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
43
			'<strong class="warning">[not_shortcode]</strong>',
44
			$this->parser->parse('[not_shortcode]')
45
		);
46
47
		ShortcodeParser::$error_behavior = ShortcodeParser::LEAVE;
48
49
		$this->assertEquals('[not_shortcode]',
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
50
			$this->parser->parse('[not_shortcode]'));
51
		$this->assertEquals('[not_shortcode /]',
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
52
			$this->parser->parse('[not_shortcode /]'));
53
		$this->assertEquals('[not_shortcode,foo="bar"]',
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
54
			$this->parser->parse('[not_shortcode,foo="bar"]'));
55
		$this->assertEquals('[not_shortcode]a[/not_shortcode]',
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
56
			$this->parser->parse('[not_shortcode]a[/not_shortcode]'));
57
		$this->assertEquals('[/not_shortcode]',
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
58
			$this->parser->parse('[/not_shortcode]'));
59
60
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
61
			'<img class="[not_shortcode]">',
62
			$this->parser->parse('<img class="[not_shortcode]">')
63
		);
64
	}
65
66
	public function testSimpleTag() {
67
		$tests = array(
68
			'[test_shortcode]',
69
			'[test_shortcode ]', '[test_shortcode,]', '[test_shortcode, ]'.
70
			'[test_shortcode/]', '[test_shortcode /]', '[test_shortcode,/]', '[test_shortcode, /]'
71
		);
72
73
		foreach($tests as $test) {
74
			$this->parser->parse($test);
75
76
			$this->assertEquals(array(), $this->arguments, $test);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
77
			$this->assertEquals('', $this->contents, $test);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
78
			$this->assertEquals('test_shortcode', $this->tagName, $test);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
79
		}
80
	}
81
82
	public function testOneArgument() {
83
		$tests = array (
84
			'[test_shortcode foo="bar"]', '[test_shortcode,foo="bar"]',
85
			"[test_shortcode foo='bar']", "[test_shortcode,foo='bar']",
86
			'[test_shortcode  foo  =  "bar"  /]', '[test_shortcode,  foo  =  "bar"  /]'
87
		);
88
89
		foreach($tests as $test) {
90
			$this->parser->parse($test);
91
92
			$this->assertEquals(array('foo' => 'bar'), $this->arguments, $test);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
93
			$this->assertEquals('', $this->contents, $test);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
94
			$this->assertEquals('test_shortcode', $this->tagName, $test);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
95
		}
96
	}
97
98
	public function testMultipleArguments() {
99
		$this->parser->parse('[test_shortcode foo = "bar",bar=\'foo\', baz="buz"]');
100
101
		$this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', 'baz' => 'buz'), $this->arguments);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
102
		$this->assertEquals('', $this->contents);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
103
		$this->assertEquals('test_shortcode', $this->tagName);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
104
	}
105
106
	public function testEnclosing() {
107
		$this->parser->parse('[test_shortcode]foo[/test_shortcode]');
108
109
		$this->assertEquals(array(), $this->arguments);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
110
		$this->assertEquals('foo', $this->contents);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
111
		$this->assertEquals('test_shortcode', $this->tagName);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
112
	}
113
114
	public function testEnclosingWithArguments() {
115
		$this->parser->parse('[test_shortcode,foo = "bar",bar=\'foo\',baz="buz"]foo[/test_shortcode]');
116
117
		$this->assertEquals(array('foo' => 'bar', 'bar' => 'foo', 'baz' => 'buz'), $this->arguments);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
118
		$this->assertEquals('foo', $this->contents);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
119
		$this->assertEquals('test_shortcode', $this->tagName);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
120
	}
121
122
	public function testShortcodeEscaping() {
123
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
124
			'[test_shortcode]',
125
			$this->parser->parse('[[test_shortcode]]')
126
		);
127
128
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
129
			'[test_shortcode /]',
130
			$this->parser->parse('[[test_shortcode /]]')
131
		);
132
133
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
134
			'[test_shortcode]content[/test_shortcode]',
135
			$this->parser->parse('[[test_shortcode]content[/test_shortcode]]'
136
		));
137
138
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
139
			'[test_shortcode]content',
140
			$this->parser->parse('[[test_shortcode]][test_shortcode]content[/test_shortcode]')
141
		);
142
143
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
144
			'[test_shortcode]content[/test_shortcode]content2',
145
			$this->parser->parse('[[test_shortcode]content[/test_shortcode]][test_shortcode]content2[/test_shortcode]'
146
		));
147
148
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
149
			'[[Doesnt strip double [ character if not a shortcode',
150
			$this->parser->parse('[[Doesnt strip double [ character if not a [test_shortcode]shortcode[/test_shortcode]'
151
		));
152
153
		$this->assertEquals(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
154
			'[[Doesnt shortcode get confused by double ]] characters',
155
			$this->parser->parse(
156
				'[[Doesnt [test_shortcode]shortcode[/test_shortcode] get confused by double ]] characters')
157
		);
158
	}
159
160
	public function testUnquotedArguments() {
161
		$this->assertEquals('', $this->parser->parse('[test_shortcode,foo=bar!,baz = buz123]'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
162
		$this->assertEquals(array('foo' => 'bar!', 'baz' => 'buz123'), $this->arguments);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
163
	}
164
165
	public function testSpacesForDelimiter() {
166
		$this->assertEquals('', $this->parser->parse('[test_shortcode foo=bar! baz = buz123]'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
167
		$this->assertEquals(array('foo' => 'bar!', 'baz' => 'buz123'), $this->arguments);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
168
	}
169
170
	public function testSelfClosingTag() {
171
		$this->assertEquals (
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
172
			'morecontent',
173
			$this->parser->parse('[test_shortcode,id="1"/]more[test_shortcode,id="2"]content[/test_shortcode]'),
174
			'Assert that self-closing tags are respected during parsing.'
175
		);
176
177
		$this->assertEquals(2, $this->arguments['id']);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
178
	}
179
180
	public function testConsecutiveTags() {
181
		$this->assertEquals('', $this->parser->parse('[test_shortcode][test_shortcode]'));
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
182
	}
183
184
	protected function assertEqualsIgnoringWhitespace($a, $b, $message = null) {
185
		$this->assertEquals(preg_replace('/\s+/', '', $a), preg_replace('/\s+/', '', $b), $message);
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
186
	}
187
188
	public function testtExtractBefore()
189
	{
190
		// Left extracts to before the current block
191
		$this->assertEqualsIgnoringWhitespace(
192
			'Code<div>FooBar</div>',
193
			$this->parser->parse('<div>Foo[test_shortcode class=left]Code[/test_shortcode]Bar</div>')
194
		);
195
196
		// Even if the immediate parent isn't a the current block
197
		$this->assertEqualsIgnoringWhitespace(
198
			'Code<div>Foo<b>BarBaz</b>Qux</div>',
199
			$this->parser->parse('<div>Foo<b>Bar[test_shortcode class=left]Code[/test_shortcode]Baz</b>Qux</div>')
200
		);
201
	}
202
203
	public function testExtractSplit()
204
	{
205
		$this->markTestSkipped(
206
			'Feature disabled due to https://github.com/silverstripe/silverstripe-framework/issues/5987'
207
		);
208
209
		// Center splits the current block
210
		$this->assertEqualsIgnoringWhitespace(
211
			'<div>Foo</div>Code<div>Bar</div>',
212
			$this->parser->parse('<div>Foo[test_shortcode class=center]Code[/test_shortcode]Bar</div>')
213
		);
214
215
		// Even if the immediate parent isn't a the current block
216
		$this->assertEqualsIgnoringWhitespace(
217
			'<div>Foo<b>Bar</b></div>Code<div><b>Baz</b>Qux</div>',
218
			$this->parser->parse('<div>Foo<b>Bar[test_shortcode class=center]Code[/test_shortcode]Baz</b>Qux</div>')
219
		);
220
	}
221
222
	public function testExtractNone() {
223
		// No class means don't extract
224
		$this->assertEqualsIgnoringWhitespace(
225
			'<div>FooCodeBar</div>',
226
			$this->parser->parse('<div>Foo[test_shortcode]Code[/test_shortcode]Bar</div>')
227
		);
228
	}
229
230
	public function testShortcodesInsideScriptTag() {
231
		$this->assertEqualsIgnoringWhitespace(
232
			'<script>hello</script>',
233
			$this->parser->parse('<script>[test_shortcode]hello[/test_shortcode]</script>')
234
		);
235
	}
236
237
	public function testFalseyArguments() {
238
		$this->parser->parse('<p>[test_shortcode falsey=0]');
239
240
		$this->assertEquals(array(
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
241
			'falsey' => '',
242
		), $this->arguments);
243
	}
244
245
	public function testNumericShortcodes() {
246
		$this->assertEqualsIgnoringWhitespace(
247
			'[2]',
248
			$this->parser->parse('[2]')
249
		);
250
		$this->assertEqualsIgnoringWhitespace(
251
			'<script>[2]</script>',
252
			$this->parser->parse('<script>[2]</script>')
253
		);
254
255
		$this->parser->register('2', function($attributes, $content, $this, $tag, $extra) {
0 ignored issues
show
Unused Code introduced by
The parameter $attributes is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $content is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $this is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $tag is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $extra is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
256
			return 'this is 2';
257
		});
258
259
		$this->assertEqualsIgnoringWhitespace(
260
			'this is 2',
261
			$this->parser->parse('[2]')
262
		);
263
		$this->assertEqualsIgnoringWhitespace(
264
			'<script>this is 2</script>',
265
			$this->parser->parse('<script>[2]</script>')
266
		);
267
268
		$this->parser->unregister('2');
269
	}
270
271
	public function testExtraContext() {
272
		$this->parser->parse('<a href="[test_shortcode]">Test</a>');
273
274
		$this->assertInstanceOf('DOMNode', $this->extra['node']);
275
		$this->assertInstanceOf('DOMElement', $this->extra['element']);
276
		$this->assertEquals($this->extra['element']->tagName, 'a');
0 ignored issues
show
Bug introduced by
The method assertEquals() does not exist on ShortcodeParserTest. Did you maybe mean assertEqualsIgnoringWhitespace()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
277
	}
278
279
	public function testNoParseAttemptIfNoCode() {
280
		$stub = $this->getMock('ShortcodeParser', array('replaceElementTagsWithMarkers'));
281
		$stub->register('test', function() {
282
			return '';
283
		});
284
285
		$stub->expects($this->never())
286
			->method('replaceElementTagsWithMarkers')->will($this->returnValue(array('', '')));
287
288
		$stub->parse('<p>test</p>');
289
	}
290
291
	// -----------------------------------------------------------------------------------------------------------------
292
293
	/**
294
	 * Stores the result of a shortcode parse in object properties for easy testing access.
295
	 */
296
	public function shortcodeSaver($arguments, $content, $parser, $tagName, $extra) {
297
		$this->arguments = $arguments;
298
		$this->contents = $content;
299
		$this->tagName = $tagName;
300
		$this->extra = $extra;
301
302
		return $content;
303
	}
304
305
}
306