updated packages

This commit is contained in:
2019-05-18 09:06:43 +00:00
parent 901d16349e
commit e9487fa58a
2025 changed files with 30366 additions and 49653 deletions

View File

@@ -54,7 +54,7 @@ abstract class AbstractHandlerTest extends TestCase
$property = new \ReflectionProperty($stream, 'tokens');
$property->setAccessible(true);
$this->assertEquals(array(), $property->getValue($stream));
$this->assertEquals([], $property->getValue($stream));
}
protected function assertRemainingContent(Reader $reader, $remainingContent)

View File

@@ -32,20 +32,20 @@ class CommentHandlerTest extends AbstractHandlerTest
public function getHandleValueTestData()
{
return array(
return [
// 2nd argument only exists for inherited method compatibility
array('/* comment */', new Token(null, null, null), ''),
array('/* comment */foo', new Token(null, null, null), 'foo'),
);
['/* comment */', new Token(null, null, null), ''],
['/* comment */foo', new Token(null, null, null), 'foo'],
];
}
public function getDontHandleValueTestData()
{
return array(
array('>'),
array('+'),
array(' '),
);
return [
['>'],
['+'],
[' '],
];
}
protected function generateHandler()

View File

@@ -20,24 +20,24 @@ class HashHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array('#id', new Token(Token::TYPE_HASH, 'id', 0), ''),
array('#123', new Token(Token::TYPE_HASH, '123', 0), ''),
return [
['#id', new Token(Token::TYPE_HASH, 'id', 0), ''],
['#123', new Token(Token::TYPE_HASH, '123', 0), ''],
array('#id.class', new Token(Token::TYPE_HASH, 'id', 0), '.class'),
array('#id element', new Token(Token::TYPE_HASH, 'id', 0), ' element'),
);
['#id.class', new Token(Token::TYPE_HASH, 'id', 0), '.class'],
['#id element', new Token(Token::TYPE_HASH, 'id', 0), ' element'],
];
}
public function getDontHandleValueTestData()
{
return array(
array('id'),
array('123'),
array('<'),
array('<'),
array('#'),
);
return [
['id'],
['123'],
['<'],
['<'],
['#'],
];
}
protected function generateHandler()

View File

@@ -20,24 +20,24 @@ class IdentifierHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array('foo', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ''),
array('foo|bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '|bar'),
array('foo.class', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '.class'),
array('foo[attr]', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '[attr]'),
array('foo bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ' bar'),
);
return [
['foo', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ''],
['foo|bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '|bar'],
['foo.class', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '.class'],
['foo[attr]', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), '[attr]'],
['foo bar', new Token(Token::TYPE_IDENTIFIER, 'foo', 0), ' bar'],
];
}
public function getDontHandleValueTestData()
{
return array(
array('>'),
array('+'),
array(' '),
array('*|foo'),
array('/* comment */'),
);
return [
['>'],
['+'],
[' '],
['*|foo'],
['/* comment */'],
];
}
protected function generateHandler()

View File

@@ -19,26 +19,26 @@ class NumberHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array('12', new Token(Token::TYPE_NUMBER, '12', 0), ''),
array('12.34', new Token(Token::TYPE_NUMBER, '12.34', 0), ''),
array('+12.34', new Token(Token::TYPE_NUMBER, '+12.34', 0), ''),
array('-12.34', new Token(Token::TYPE_NUMBER, '-12.34', 0), ''),
return [
['12', new Token(Token::TYPE_NUMBER, '12', 0), ''],
['12.34', new Token(Token::TYPE_NUMBER, '12.34', 0), ''],
['+12.34', new Token(Token::TYPE_NUMBER, '+12.34', 0), ''],
['-12.34', new Token(Token::TYPE_NUMBER, '-12.34', 0), ''],
array('12 arg', new Token(Token::TYPE_NUMBER, '12', 0), ' arg'),
array('12]', new Token(Token::TYPE_NUMBER, '12', 0), ']'),
);
['12 arg', new Token(Token::TYPE_NUMBER, '12', 0), ' arg'],
['12]', new Token(Token::TYPE_NUMBER, '12', 0), ']'],
];
}
public function getDontHandleValueTestData()
{
return array(
array('hello'),
array('>'),
array('+'),
array(' '),
array('/* comment */'),
);
return [
['hello'],
['>'],
['+'],
[' '],
['/* comment */'],
];
}
protected function generateHandler()

View File

@@ -20,25 +20,25 @@ class StringHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array('"hello"', new Token(Token::TYPE_STRING, 'hello', 1), ''),
array('"1"', new Token(Token::TYPE_STRING, '1', 1), ''),
array('" "', new Token(Token::TYPE_STRING, ' ', 1), ''),
array('""', new Token(Token::TYPE_STRING, '', 1), ''),
array("'hello'", new Token(Token::TYPE_STRING, 'hello', 1), ''),
return [
['"hello"', new Token(Token::TYPE_STRING, 'hello', 1), ''],
['"1"', new Token(Token::TYPE_STRING, '1', 1), ''],
['" "', new Token(Token::TYPE_STRING, ' ', 1), ''],
['""', new Token(Token::TYPE_STRING, '', 1), ''],
["'hello'", new Token(Token::TYPE_STRING, 'hello', 1), ''],
array("'foo'bar", new Token(Token::TYPE_STRING, 'foo', 1), 'bar'),
);
["'foo'bar", new Token(Token::TYPE_STRING, 'foo', 1), 'bar'],
];
}
public function getDontHandleValueTestData()
{
return array(
array('hello'),
array('>'),
array('1'),
array(' '),
);
return [
['hello'],
['>'],
['1'],
[' '],
];
}
protected function generateHandler()

View File

@@ -18,23 +18,23 @@ class WhitespaceHandlerTest extends AbstractHandlerTest
{
public function getHandleValueTestData()
{
return array(
array(' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''),
array("\n", new Token(Token::TYPE_WHITESPACE, "\n", 0), ''),
array("\t", new Token(Token::TYPE_WHITESPACE, "\t", 0), ''),
return [
[' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''],
["\n", new Token(Token::TYPE_WHITESPACE, "\n", 0), ''],
["\t", new Token(Token::TYPE_WHITESPACE, "\t", 0), ''],
array(' foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), 'foo'),
array(' .foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), '.foo'),
);
[' foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), 'foo'],
[' .foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), '.foo'],
];
}
public function getDontHandleValueTestData()
{
return array(
array('>'),
array('1'),
array('a'),
);
return [
['>'],
['1'],
['a'],
];
}
protected function generateHandler()

View File

@@ -77,7 +77,7 @@ class ParserTest extends TestCase
/** @var FunctionNode $function */
$function = $selectors[0]->getTree();
$this->assertEquals(array($a, $b), Parser::parseSeries($function->getArguments()));
$this->assertEquals([$a, $b], Parser::parseSeries($function->getArguments()));
}
/** @dataProvider getParseSeriesExceptionTestData */
@@ -95,159 +95,159 @@ class ParserTest extends TestCase
public function getParserTestData()
{
return array(
array('*', array('Element[*]')),
array('*|*', array('Element[*]')),
array('*|foo', array('Element[foo]')),
array('foo|*', array('Element[foo|*]')),
array('foo|bar', array('Element[foo|bar]')),
array('#foo#bar', array('Hash[Hash[Element[*]#foo]#bar]')),
array('div>.foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')),
array('div> .foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')),
array('div >.foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')),
array('div > .foo', array('CombinedSelector[Element[div] > Class[Element[*].foo]]')),
array("div \n> \t \t .foo", array('CombinedSelector[Element[div] > Class[Element[*].foo]]')),
array('td.foo,.bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')),
array('td.foo, .bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')),
array("td.foo\t\r\n\f ,\t\r\n\f .bar", array('Class[Element[td].foo]', 'Class[Element[*].bar]')),
array('td.foo,.bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')),
array('td.foo, .bar', array('Class[Element[td].foo]', 'Class[Element[*].bar]')),
array("td.foo\t\r\n\f ,\t\r\n\f .bar", array('Class[Element[td].foo]', 'Class[Element[*].bar]')),
array('div, td.foo, div.bar span', array('Element[div]', 'Class[Element[td].foo]', 'CombinedSelector[Class[Element[div].bar] <followed> Element[span]]')),
array('div > p', array('CombinedSelector[Element[div] > Element[p]]')),
array('td:first', array('Pseudo[Element[td]:first]')),
array('td :first', array('CombinedSelector[Element[td] <followed> Pseudo[Element[*]:first]]')),
array('a[name]', array('Attribute[Element[a][name]]')),
array("a[ name\t]", array('Attribute[Element[a][name]]')),
array('a [name]', array('CombinedSelector[Element[a] <followed> Attribute[Element[*][name]]]')),
array('[name="foo"]', array("Attribute[Element[*][name = 'foo']]")),
array("[name='foo[1]']", array("Attribute[Element[*][name = 'foo[1]']]")),
array("[name='foo[0][bar]']", array("Attribute[Element[*][name = 'foo[0][bar]']]")),
array('a[rel="include"]', array("Attribute[Element[a][rel = 'include']]")),
array('a[rel = include]', array("Attribute[Element[a][rel = 'include']]")),
array("a[hreflang |= 'en']", array("Attribute[Element[a][hreflang |= 'en']]")),
array('a[hreflang|=en]', array("Attribute[Element[a][hreflang |= 'en']]")),
array('div:nth-child(10)', array("Function[Element[div]:nth-child(['10'])]")),
array(':nth-child(2n+2)', array("Function[Element[*]:nth-child(['2', 'n', '+2'])]")),
array('div:nth-of-type(10)', array("Function[Element[div]:nth-of-type(['10'])]")),
array('div div:nth-of-type(10) .aclass', array("CombinedSelector[CombinedSelector[Element[div] <followed> Function[Element[div]:nth-of-type(['10'])]] <followed> Class[Element[*].aclass]]")),
array('label:only', array('Pseudo[Element[label]:only]')),
array('a:lang(fr)', array("Function[Element[a]:lang(['fr'])]")),
array('div:contains("foo")', array("Function[Element[div]:contains(['foo'])]")),
array('div#foobar', array('Hash[Element[div]#foobar]')),
array('div:not(div.foo)', array('Negation[Element[div]:not(Class[Element[div].foo])]')),
array('td ~ th', array('CombinedSelector[Element[td] ~ Element[th]]')),
array('.foo[data-bar][data-baz=0]', array("Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]")),
);
return [
['*', ['Element[*]']],
['*|*', ['Element[*]']],
['*|foo', ['Element[foo]']],
['foo|*', ['Element[foo|*]']],
['foo|bar', ['Element[foo|bar]']],
['#foo#bar', ['Hash[Hash[Element[*]#foo]#bar]']],
['div>.foo', ['CombinedSelector[Element[div] > Class[Element[*].foo]]']],
['div> .foo', ['CombinedSelector[Element[div] > Class[Element[*].foo]]']],
['div >.foo', ['CombinedSelector[Element[div] > Class[Element[*].foo]]']],
['div > .foo', ['CombinedSelector[Element[div] > Class[Element[*].foo]]']],
["div \n> \t \t .foo", ['CombinedSelector[Element[div] > Class[Element[*].foo]]']],
['td.foo,.bar', ['Class[Element[td].foo]', 'Class[Element[*].bar]']],
['td.foo, .bar', ['Class[Element[td].foo]', 'Class[Element[*].bar]']],
["td.foo\t\r\n\f ,\t\r\n\f .bar", ['Class[Element[td].foo]', 'Class[Element[*].bar]']],
['td.foo,.bar', ['Class[Element[td].foo]', 'Class[Element[*].bar]']],
['td.foo, .bar', ['Class[Element[td].foo]', 'Class[Element[*].bar]']],
["td.foo\t\r\n\f ,\t\r\n\f .bar", ['Class[Element[td].foo]', 'Class[Element[*].bar]']],
['div, td.foo, div.bar span', ['Element[div]', 'Class[Element[td].foo]', 'CombinedSelector[Class[Element[div].bar] <followed> Element[span]]']],
['div > p', ['CombinedSelector[Element[div] > Element[p]]']],
['td:first', ['Pseudo[Element[td]:first]']],
['td :first', ['CombinedSelector[Element[td] <followed> Pseudo[Element[*]:first]]']],
['a[name]', ['Attribute[Element[a][name]]']],
["a[ name\t]", ['Attribute[Element[a][name]]']],
['a [name]', ['CombinedSelector[Element[a] <followed> Attribute[Element[*][name]]]']],
['[name="foo"]', ["Attribute[Element[*][name = 'foo']]"]],
["[name='foo[1]']", ["Attribute[Element[*][name = 'foo[1]']]"]],
["[name='foo[0][bar]']", ["Attribute[Element[*][name = 'foo[0][bar]']]"]],
['a[rel="include"]', ["Attribute[Element[a][rel = 'include']]"]],
['a[rel = include]', ["Attribute[Element[a][rel = 'include']]"]],
["a[hreflang |= 'en']", ["Attribute[Element[a][hreflang |= 'en']]"]],
['a[hreflang|=en]', ["Attribute[Element[a][hreflang |= 'en']]"]],
['div:nth-child(10)', ["Function[Element[div]:nth-child(['10'])]"]],
[':nth-child(2n+2)', ["Function[Element[*]:nth-child(['2', 'n', '+2'])]"]],
['div:nth-of-type(10)', ["Function[Element[div]:nth-of-type(['10'])]"]],
['div div:nth-of-type(10) .aclass', ["CombinedSelector[CombinedSelector[Element[div] <followed> Function[Element[div]:nth-of-type(['10'])]] <followed> Class[Element[*].aclass]]"]],
['label:only', ['Pseudo[Element[label]:only]']],
['a:lang(fr)', ["Function[Element[a]:lang(['fr'])]"]],
['div:contains("foo")', ["Function[Element[div]:contains(['foo'])]"]],
['div#foobar', ['Hash[Element[div]#foobar]']],
['div:not(div.foo)', ['Negation[Element[div]:not(Class[Element[div].foo])]']],
['td ~ th', ['CombinedSelector[Element[td] ~ Element[th]]']],
['.foo[data-bar][data-baz=0]', ["Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]"]],
];
}
public function getParserExceptionTestData()
{
return array(
array('attributes(href)/html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()),
array('attributes(href)', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()),
array('html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '/', 4))->getMessage()),
array(' ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 1))->getMessage()),
array('div, ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 5))->getMessage()),
array(' , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 1))->getMessage()),
array('p, , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 3))->getMessage()),
array('div > ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 6))->getMessage()),
array(' > div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '>', 2))->getMessage()),
array('foo|#bar', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_HASH, 'bar', 4))->getMessage()),
array('#.foo', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '#', 0))->getMessage()),
array('.#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()),
array(':#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()),
array('[*]', SyntaxErrorException::unexpectedToken('"|"', new Token(Token::TYPE_DELIMITER, ']', 2))->getMessage()),
array('[foo|]', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_DELIMITER, ']', 5))->getMessage()),
array('[#]', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_DELIMITER, '#', 1))->getMessage()),
array('[foo=#]', SyntaxErrorException::unexpectedToken('string or identifier', new Token(Token::TYPE_DELIMITER, '#', 5))->getMessage()),
array(':nth-child()', SyntaxErrorException::unexpectedToken('at least one argument', new Token(Token::TYPE_DELIMITER, ')', 11))->getMessage()),
array('[href]a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_IDENTIFIER, 'a', 6))->getMessage()),
array('[rel:stylesheet]', SyntaxErrorException::unexpectedToken('operator', new Token(Token::TYPE_DELIMITER, ':', 4))->getMessage()),
array('[rel=stylesheet', SyntaxErrorException::unexpectedToken('"]"', new Token(Token::TYPE_FILE_END, '', 15))->getMessage()),
array(':lang(fr', SyntaxErrorException::unexpectedToken('an argument', new Token(Token::TYPE_FILE_END, '', 8))->getMessage()),
array(':contains("foo', SyntaxErrorException::unclosedString(10)->getMessage()),
array('foo!', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '!', 3))->getMessage()),
);
return [
['attributes(href)/html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()],
['attributes(href)', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '(', 10))->getMessage()],
['html/body/a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '/', 4))->getMessage()],
[' ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 1))->getMessage()],
['div, ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 5))->getMessage()],
[' , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 1))->getMessage()],
['p, , div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, ',', 3))->getMessage()],
['div > ', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_FILE_END, '', 6))->getMessage()],
[' > div', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '>', 2))->getMessage()],
['foo|#bar', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_HASH, 'bar', 4))->getMessage()],
['#.foo', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '#', 0))->getMessage()],
['.#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()],
[':#foo', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_HASH, 'foo', 1))->getMessage()],
['[*]', SyntaxErrorException::unexpectedToken('"|"', new Token(Token::TYPE_DELIMITER, ']', 2))->getMessage()],
['[foo|]', SyntaxErrorException::unexpectedToken('identifier', new Token(Token::TYPE_DELIMITER, ']', 5))->getMessage()],
['[#]', SyntaxErrorException::unexpectedToken('identifier or "*"', new Token(Token::TYPE_DELIMITER, '#', 1))->getMessage()],
['[foo=#]', SyntaxErrorException::unexpectedToken('string or identifier', new Token(Token::TYPE_DELIMITER, '#', 5))->getMessage()],
[':nth-child()', SyntaxErrorException::unexpectedToken('at least one argument', new Token(Token::TYPE_DELIMITER, ')', 11))->getMessage()],
['[href]a', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_IDENTIFIER, 'a', 6))->getMessage()],
['[rel:stylesheet]', SyntaxErrorException::unexpectedToken('operator', new Token(Token::TYPE_DELIMITER, ':', 4))->getMessage()],
['[rel=stylesheet', SyntaxErrorException::unexpectedToken('"]"', new Token(Token::TYPE_FILE_END, '', 15))->getMessage()],
[':lang(fr', SyntaxErrorException::unexpectedToken('an argument', new Token(Token::TYPE_FILE_END, '', 8))->getMessage()],
[':contains("foo', SyntaxErrorException::unclosedString(10)->getMessage()],
['foo!', SyntaxErrorException::unexpectedToken('selector', new Token(Token::TYPE_DELIMITER, '!', 3))->getMessage()],
];
}
public function getPseudoElementsTestData()
{
return array(
array('foo', 'Element[foo]', ''),
array('*', 'Element[*]', ''),
array(':empty', 'Pseudo[Element[*]:empty]', ''),
array(':BEfore', 'Element[*]', 'before'),
array(':aftER', 'Element[*]', 'after'),
array(':First-Line', 'Element[*]', 'first-line'),
array(':First-Letter', 'Element[*]', 'first-letter'),
array('::befoRE', 'Element[*]', 'before'),
array('::AFter', 'Element[*]', 'after'),
array('::firsT-linE', 'Element[*]', 'first-line'),
array('::firsT-letteR', 'Element[*]', 'first-letter'),
array('::Selection', 'Element[*]', 'selection'),
array('foo:after', 'Element[foo]', 'after'),
array('foo::selection', 'Element[foo]', 'selection'),
array('lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'),
array('video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'),
);
return [
['foo', 'Element[foo]', ''],
['*', 'Element[*]', ''],
[':empty', 'Pseudo[Element[*]:empty]', ''],
[':BEfore', 'Element[*]', 'before'],
[':aftER', 'Element[*]', 'after'],
[':First-Line', 'Element[*]', 'first-line'],
[':First-Letter', 'Element[*]', 'first-letter'],
['::befoRE', 'Element[*]', 'before'],
['::AFter', 'Element[*]', 'after'],
['::firsT-linE', 'Element[*]', 'first-line'],
['::firsT-letteR', 'Element[*]', 'first-letter'],
['::Selection', 'Element[*]', 'selection'],
['foo:after', 'Element[foo]', 'after'],
['foo::selection', 'Element[foo]', 'selection'],
['lorem#ipsum ~ a#b.c[href]:empty::selection', 'CombinedSelector[Hash[Element[lorem]#ipsum] ~ Pseudo[Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'],
['video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'],
];
}
public function getSpecificityTestData()
{
return array(
array('*', 0),
array(' foo', 1),
array(':empty ', 10),
array(':before', 1),
array('*:before', 1),
array(':nth-child(2)', 10),
array('.bar', 10),
array('[baz]', 10),
array('[baz="4"]', 10),
array('[baz^="4"]', 10),
array('#lipsum', 100),
array(':not(*)', 0),
array(':not(foo)', 1),
array(':not(.foo)', 10),
array(':not([foo])', 10),
array(':not(:empty)', 10),
array(':not(#foo)', 100),
array('foo:empty', 11),
array('foo:before', 2),
array('foo::before', 2),
array('foo:empty::before', 12),
array('#lorem + foo#ipsum:first-child > bar:first-line', 213),
);
return [
['*', 0],
[' foo', 1],
[':empty ', 10],
[':before', 1],
['*:before', 1],
[':nth-child(2)', 10],
['.bar', 10],
['[baz]', 10],
['[baz="4"]', 10],
['[baz^="4"]', 10],
['#lipsum', 100],
[':not(*)', 0],
[':not(foo)', 1],
[':not(.foo)', 10],
[':not([foo])', 10],
[':not(:empty)', 10],
[':not(#foo)', 100],
['foo:empty', 11],
['foo:before', 2],
['foo::before', 2],
['foo:empty::before', 12],
['#lorem + foo#ipsum:first-child > bar:first-line', 213],
];
}
public function getParseSeriesTestData()
{
return array(
array('1n+3', 1, 3),
array('1n +3', 1, 3),
array('1n + 3', 1, 3),
array('1n+ 3', 1, 3),
array('1n-3', 1, -3),
array('1n -3', 1, -3),
array('1n - 3', 1, -3),
array('1n- 3', 1, -3),
array('n-5', 1, -5),
array('odd', 2, 1),
array('even', 2, 0),
array('3n', 3, 0),
array('n', 1, 0),
array('+n', 1, 0),
array('-n', -1, 0),
array('5', 0, 5),
);
return [
['1n+3', 1, 3],
['1n +3', 1, 3],
['1n + 3', 1, 3],
['1n+ 3', 1, 3],
['1n-3', 1, -3],
['1n -3', 1, -3],
['1n - 3', 1, -3],
['1n- 3', 1, -3],
['n-5', 1, -5],
['odd', 2, 1],
['even', 2, 0],
['3n', 3, 0],
['n', 1, 0],
['+n', 1, 0],
['-n', -1, 0],
['5', 0, 5],
];
}
public function getParseSeriesExceptionTestData()
{
return array(
array('foo'),
array('n+'),
);
return [
['foo'],
['n+'],
];
}
}

View File

@@ -70,11 +70,11 @@ class ReaderTest extends TestCase
$reader = new Reader('hello');
$this->assertFalse($reader->findPattern('/world/'));
$this->assertEquals(array('hello', 'h'), $reader->findPattern('/^([a-z]).*/'));
$this->assertEquals(['hello', 'h'], $reader->findPattern('/^([a-z]).*/'));
$this->assignPosition($reader, 2);
$this->assertFalse($reader->findPattern('/^h.*/'));
$this->assertEquals(array('llo'), $reader->findPattern('/^llo$/'));
$this->assertEquals(['llo'], $reader->findPattern('/^llo$/'));
}
public function testMoveForward()

View File

@@ -34,12 +34,12 @@ class ClassParserTest extends TestCase
public function getParseTestData()
{
return array(
array('.testclass', 'Class[Element[*].testclass]'),
array('testel.testclass', 'Class[Element[testel].testclass]'),
array('testns|.testclass', 'Class[Element[testns|*].testclass]'),
array('testns|*.testclass', 'Class[Element[testns|*].testclass]'),
array('testns|testel.testclass', 'Class[Element[testns|testel].testclass]'),
);
return [
['.testclass', 'Class[Element[*].testclass]'],
['testel.testclass', 'Class[Element[testel].testclass]'],
['testns|.testclass', 'Class[Element[testns|*].testclass]'],
['testns|*.testclass', 'Class[Element[testns|*].testclass]'],
['testns|testel.testclass', 'Class[Element[testns|testel].testclass]'],
];
}
}

View File

@@ -34,11 +34,11 @@ class ElementParserTest extends TestCase
public function getParseTestData()
{
return array(
array('*', 'Element[*]'),
array('testel', 'Element[testel]'),
array('testns|*', 'Element[testns|*]'),
array('testns|testel', 'Element[testns|testel]'),
);
return [
['*', 'Element[*]'],
['testel', 'Element[testel]'],
['testns|*', 'Element[testns|*]'],
['testns|testel', 'Element[testns|testel]'],
];
}
}

View File

@@ -34,12 +34,12 @@ class HashParserTest extends TestCase
public function getParseTestData()
{
return array(
array('#testid', 'Hash[Element[*]#testid]'),
array('testel#testid', 'Hash[Element[testel]#testid]'),
array('testns|#testid', 'Hash[Element[testns|*]#testid]'),
array('testns|*#testid', 'Hash[Element[testns|*]#testid]'),
array('testns|testel#testid', 'Hash[Element[testns|testel]#testid]'),
);
return [
['#testid', 'Hash[Element[*]#testid]'],
['testel#testid', 'Hash[Element[testel]#testid]'],
['testns|#testid', 'Hash[Element[testns|*]#testid]'],
['testns|*#testid', 'Hash[Element[testns|*]#testid]'],
['testns|testel#testid', 'Hash[Element[testns|testel]#testid]'],
];
}
}