mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge branch '4.7' into 4
This commit is contained in:
commit
2c54a3fd2f
@ -263,8 +263,8 @@ class ShortcodeParser
|
||||
([^\s\/\'"=,]+) # Name
|
||||
\s* = \s*
|
||||
(?:
|
||||
(?:\'([^\']+)\') | # Value surrounded by \'
|
||||
(?:"([^"]+)") | # Value surrounded by "
|
||||
(?:\'([^\']*)\') | # Value surrounded by \'
|
||||
(?:"([^"]*)") | # Value surrounded by "
|
||||
([^\s,\]]+) # Bare value
|
||||
)
|
||||
';
|
||||
|
@ -79,37 +79,54 @@ class ShortcodeParserTest extends SapphireTest
|
||||
);
|
||||
}
|
||||
|
||||
public function testSimpleTag()
|
||||
public function simpleTagDataProvider()
|
||||
{
|
||||
$tests = [
|
||||
'[test_shortcode]',
|
||||
'[test_shortcode ]', '[test_shortcode,]', '[test_shortcode, ]' . '[test_shortcode/]', '[test_shortcode /]', '[test_shortcode,/]', '[test_shortcode, /]'
|
||||
return [
|
||||
['[test_shortcode]'],
|
||||
['[test_shortcode ]'],
|
||||
['[test_shortcode,]'],
|
||||
['[test_shortcode, ][test_shortcode/]'],
|
||||
['[test_shortcode /]'],
|
||||
['[test_shortcode,/]'],
|
||||
['[test_shortcode, /]']
|
||||
];
|
||||
|
||||
foreach ($tests as $test) {
|
||||
$this->parser->parse($test);
|
||||
|
||||
$this->assertEquals([], $this->arguments, $test);
|
||||
$this->assertEquals('', $this->contents, $test);
|
||||
$this->assertEquals('test_shortcode', $this->tagName, $test);
|
||||
}
|
||||
}
|
||||
|
||||
public function testOneArgument()
|
||||
/**
|
||||
* @dataProvider simpleTagDataProvider
|
||||
*/
|
||||
public function testSimpleTag($test)
|
||||
{
|
||||
$tests = [
|
||||
'[test_shortcode foo="bar"]', '[test_shortcode,foo="bar"]',
|
||||
"[test_shortcode foo='bar']", "[test_shortcode,foo='bar']",
|
||||
'[test_shortcode foo = "bar" /]', '[test_shortcode, foo = "bar" /]'
|
||||
$this->parser->parse($test);
|
||||
$this->assertEquals([], $this->arguments, $test);
|
||||
$this->assertEquals('', $this->contents, $test);
|
||||
$this->assertEquals('test_shortcode', $this->tagName, $test);
|
||||
}
|
||||
|
||||
public function oneArgumentDataProvider()
|
||||
{
|
||||
return [
|
||||
['[test_shortcode foo="bar"]'],
|
||||
['[test_shortcode,foo="bar"]'],
|
||||
["[test_shortcode foo='bar']"],
|
||||
["[test_shortcode,foo='bar']"],
|
||||
["[test_shortcode foo=bar]"],
|
||||
["[test_shortcode,foo=bar]"],
|
||||
['[test_shortcode foo = "bar" /]'],
|
||||
['[test_shortcode, foo = "bar" /]']
|
||||
];
|
||||
}
|
||||
|
||||
foreach ($tests as $test) {
|
||||
$this->parser->parse($test);
|
||||
/**
|
||||
* @dataProvider oneArgumentDataProvider
|
||||
*/
|
||||
public function testOneArgument($test)
|
||||
{
|
||||
$this->parser->parse($test);
|
||||
|
||||
$this->assertEquals(['foo' => 'bar'], $this->arguments, $test);
|
||||
$this->assertEquals('', $this->contents, $test);
|
||||
$this->assertEquals('test_shortcode', $this->tagName, $test);
|
||||
}
|
||||
$this->assertEquals(['foo' => 'bar'], $this->arguments, $test);
|
||||
$this->assertEquals('', $this->contents, $test);
|
||||
$this->assertEquals('test_shortcode', $this->tagName, $test);
|
||||
}
|
||||
|
||||
public function testMultipleArguments()
|
||||
@ -121,6 +138,26 @@ class ShortcodeParserTest extends SapphireTest
|
||||
$this->assertEquals('test_shortcode', $this->tagName);
|
||||
}
|
||||
|
||||
public function emptyArgumentsDataProvider()
|
||||
{
|
||||
return [
|
||||
['[test_shortcode foo=""]'],
|
||||
['[test_shortcode,foo=\'\']'],
|
||||
['[test_shortcode foo=""][/test_shortcode]'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider emptyArgumentsDataProvider
|
||||
*/
|
||||
public function testEmptyArguments($test)
|
||||
{
|
||||
$this->parser->parse($test);
|
||||
$this->assertEquals(['foo' => ''], $this->arguments);
|
||||
$this->assertEquals('', $this->contents);
|
||||
$this->assertEquals('test_shortcode', $this->tagName);
|
||||
}
|
||||
|
||||
public function testEnclosing()
|
||||
{
|
||||
$this->parser->parse('[test_shortcode]foo[/test_shortcode]');
|
||||
|
Loading…
Reference in New Issue
Block a user