From bae6580a6648beb520ea1b6db2b1a6b36a9259a5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 11:57:32 +0000 Subject: [PATCH 1/4] Initial plan From f2171ef66e1311aeae370f093954e04ed79844ba Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 12:05:50 +0000 Subject: [PATCH 2/4] Add AJAX dismiss functionality for cache purge notice Co-authored-by: mustafauysal <1421387+mustafauysal@users.noreply.github.com> --- includes/admin/notices.php | 71 ++- .../Tests/CssSelectorConverterTest.php | 83 ++++ .../Tests/Node/AbstractNodeTestCase.php | 34 ++ .../Tests/Node/AttributeNodeTest.php | 37 ++ .../CssSelector/Tests/Node/ClassNodeTest.php | 33 ++ .../Tests/Node/CombinedSelectorNodeTest.php | 35 ++ .../Tests/Node/ElementNodeTest.php | 35 ++ .../Tests/Node/FunctionNodeTest.php | 47 ++ .../CssSelector/Tests/Node/HashNodeTest.php | 33 ++ .../Tests/Node/NegationNodeTest.php | 33 ++ .../CssSelector/Tests/Node/PseudoNodeTest.php | 32 ++ .../Tests/Node/SelectorNodeTest.php | 34 ++ .../Tests/Node/SpecificityTest.php | 63 +++ .../Handler/AbstractHandlerTestCase.php | 70 +++ .../Parser/Handler/CommentHandlerTest.php | 55 +++ .../Tests/Parser/Handler/HashHandlerTest.php | 49 +++ .../Parser/Handler/IdentifierHandlerTest.php | 49 +++ .../Parser/Handler/NumberHandlerTest.php | 50 +++ .../Parser/Handler/StringHandlerTest.php | 50 +++ .../Parser/Handler/WhitespaceHandlerTest.php | 44 ++ .../CssSelector/Tests/Parser/ParserTest.php | 263 +++++++++++ .../CssSelector/Tests/Parser/ReaderTest.php | 102 +++++ .../Tests/Parser/Shortcut/ClassParserTest.php | 45 ++ .../Parser/Shortcut/ElementParserTest.php | 44 ++ .../Parser/Shortcut/EmptyStringParserTest.php | 36 ++ .../Tests/Parser/Shortcut/HashParserTest.php | 45 ++ .../Tests/Parser/TokenStreamTest.php | 97 ++++ .../CssSelector/Tests/XPath/Fixtures/ids.html | 52 +++ .../CssSelector/Tests/XPath/Fixtures/lang.xml | 11 + .../Tests/XPath/Fixtures/shakespear.html | 308 +++++++++++++ .../Tests/XPath/TranslatorTest.php | 416 ++++++++++++++++++ .../Component/CssSelector/phpunit.xml.dist | 31 ++ 32 files changed, 2381 insertions(+), 6 deletions(-) create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php create mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/phpunit.xml.dist diff --git a/includes/admin/notices.php b/includes/admin/notices.php index 4173fe0..076fe16 100644 --- a/includes/admin/notices.php +++ b/includes/admin/notices.php @@ -39,6 +39,7 @@ function setup() { add_action( 'activated_plugin', __NAMESPACE__ . '\\observe_plugin_changes', 10, 2 ); add_action( 'deactivated_plugin', __NAMESPACE__ . '\\observe_plugin_changes', 10, 2 ); add_action( 'admin_post_powered_cache_dismiss_notice', __NAMESPACE__ . '\\dismiss_notice' ); + add_action( 'wp_ajax_powered_cache_dismiss_notice_ajax', __NAMESPACE__ . '\\dismiss_notice_ajax' ); } /** @@ -364,9 +365,10 @@ function maybe_display_purge_cache_plugin_notice() { } if ( $has_notice ) { - $message = __( 'Powered Cache: One or more plugins have been activated or deactivated; consider clearing the cache if these changes impact your site\'s front end.', 'powered-cache' ); + $message = __( 'Powered Cache: One or more plugins have been activated or deactivated; consider clearing the cache if these changes impact your site\'s front end.', 'powered-cache' ); + $dismiss_nonce = wp_create_nonce( 'powered_cache_dismiss_notice_ajax' ); ?> -
+

@@ -374,14 +376,43 @@ function maybe_display_purge_cache_plugin_notice() { - +

- - -
+ __( 'Permission denied', 'powered-cache' ) ) ); + } + + if ( empty( $_POST['notice'] ) ) { + wp_send_json_error( array( 'message' => __( 'Notice ID missing', 'powered-cache' ) ) ); + } + + $notice = sanitize_text_field( wp_unslash( $_POST['notice'] ) ); + + if ( POWERED_CACHE_IS_NETWORK ) { + delete_site_transient( $notice ); + } else { + delete_transient( $notice ); + } + + wp_send_json_success( array( 'message' => __( 'Notice dismissed', 'powered-cache' ) ) ); +} + /** * Display a notice when development mode is active * diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php new file mode 100644 index 0000000..d42ce90 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php @@ -0,0 +1,83 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\CssSelectorConverter; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\ParseException; + +class CssSelectorConverterTest extends TestCase +{ + public function testCssToXPath() + { + $converter = new CssSelectorConverter(); + + $this->assertEquals('descendant-or-self::*', $converter->toXPath('')); + $this->assertEquals('descendant-or-self::h1', $converter->toXPath('h1')); + $this->assertEquals("descendant-or-self::h1[@id = 'foo']", $converter->toXPath('h1#foo')); + $this->assertEquals("descendant-or-self::h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", $converter->toXPath('h1.foo')); + $this->assertEquals('descendant-or-self::foo:h1', $converter->toXPath('foo|h1')); + $this->assertEquals('descendant-or-self::h1', $converter->toXPath('H1')); + + // Test the cache layer + $converter = new CssSelectorConverter(); + $this->assertEquals('descendant-or-self::h1', $converter->toXPath('H1')); + } + + public function testCssToXPathXml() + { + $converter = new CssSelectorConverter(false); + + $this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1')); + + $converter = new CssSelectorConverter(false); + // Test the cache layer + $this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1')); + } + + public function testParseExceptions() + { + $this->expectException(ParseException::class); + $this->expectExceptionMessage('Expected identifier, but found.'); + $converter = new CssSelectorConverter(); + $converter->toXPath('h1:'); + } + + /** @dataProvider getCssToXPathWithoutPrefixTestData */ + public function testCssToXPathWithoutPrefix($css, $xpath) + { + $converter = new CssSelectorConverter(); + + $this->assertEquals($xpath, $converter->toXPath($css, ''), '->parse() parses an input string and returns a node'); + } + + public static function getCssToXPathWithoutPrefixTestData() + { + return [ + ['h1', 'h1'], + ['foo|h1', 'foo:h1'], + ['h1, h2, h3', 'h1 | h2 | h3'], + ['h1:nth-child(3n+1)', "*/*[(name() = 'h1') and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"], + ['h1 > p', 'h1/p'], + ['h1#foo', "h1[@id = 'foo']"], + ['h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], + ['h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"], + ['h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"], + ['h1[class]', 'h1[@class]'], + ['h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], + ['h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"], + ['h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"], + ['div>.foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], + ['div > .foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php new file mode 100644 index 0000000..99460ae --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\NodeInterface; + +abstract class AbstractNodeTestCase extends TestCase +{ + /** @dataProvider getToStringConversionTestData */ + public function testToStringConversion(NodeInterface $node, $representation) + { + $this->assertEquals($representation, (string) $node); + } + + /** @dataProvider getSpecificityValueTestData */ + public function testSpecificityValue(NodeInterface $node, $value) + { + $this->assertEquals($value, $node->getSpecificity()->getValue()); + } + + abstract public static function getToStringConversionTestData(); + + abstract public static function getSpecificityValueTestData(); +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php new file mode 100644 index 0000000..5115605 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php @@ -0,0 +1,37 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\AttributeNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; + +class AttributeNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 'Powered_Cache_Attribute[Element[*][attribute]]'], + [new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), "Powered_Cache_Attribute[Element[*][attribute $= 'value']]"], + [new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), "Powered_Cache_Attribute[Element[*][namespace|attribute $= 'value']]"], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 10], + [new AttributeNode(new ElementNode(null, 'element'), null, 'attribute', 'exists', null), 11], + [new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), 10], + [new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), 10], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php new file mode 100644 index 0000000..ae43a62 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ClassNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; + +class ClassNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new ClassNode(new ElementNode(), 'class'), 'Class[Element[*].class]'], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new ClassNode(new ElementNode(), 'class'), 10], + [new ClassNode(new ElementNode(null, 'element'), 'class'), 11], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php new file mode 100644 index 0000000..d9b2a38 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\CombinedSelectorNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; + +class CombinedSelectorNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 'CombinedSelector[Element[*] > Element[*]]'], + [new CombinedSelectorNode(new ElementNode(), ' ', new ElementNode()), 'CombinedSelector[Element[*] Element[*]]'], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 0], + [new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode()), 1], + [new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode(null, 'element')), 2], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php new file mode 100644 index 0000000..b3ef2b2 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php @@ -0,0 +1,35 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; + +class ElementNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new ElementNode(), 'Element[*]'], + [new ElementNode(null, 'element'), 'Element[element]'], + [new ElementNode('namespace', 'element'), 'Element[namespace|element]'], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new ElementNode(), 0], + [new ElementNode(null, 'element'), 1], + [new ElementNode('namespace', 'element'), 1], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php new file mode 100644 index 0000000..f99a66b --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php @@ -0,0 +1,47 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\FunctionNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; + +class FunctionNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new FunctionNode(new ElementNode(), 'function'), 'Function[Element[*]:function()]'], + [new FunctionNode(new ElementNode(), 'function', [ + new Token(Token::TYPE_IDENTIFIER, 'value', 0), + ]), "Function[Element[*]:function(['value'])]"], + [new FunctionNode(new ElementNode(), 'function', [ + new Token(Token::TYPE_STRING, 'value1', 0), + new Token(Token::TYPE_NUMBER, 'value2', 0), + ]), "Function[Element[*]:function(['value1', 'value2'])]"], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new FunctionNode(new ElementNode(), 'function'), 10], + [new FunctionNode(new ElementNode(), 'function', [ + new Token(Token::TYPE_IDENTIFIER, 'value', 0), + ]), 10], + [new FunctionNode(new ElementNode(), 'function', [ + new Token(Token::TYPE_STRING, 'value1', 0), + new Token(Token::TYPE_NUMBER, 'value2', 0), + ]), 10], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php new file mode 100644 index 0000000..d43aac1 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\HashNode; + +class HashNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new HashNode(new ElementNode(), 'id'), 'Hash[Element[*]#id]'], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new HashNode(new ElementNode(), 'id'), 100], + [new HashNode(new ElementNode(null, 'id'), 'class'), 101], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php new file mode 100644 index 0000000..9aafe8f --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php @@ -0,0 +1,33 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ClassNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\NegationNode; + +class NegationNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 'Negation[Element[*]:not(Class[Element[*].class])]'], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 10], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php new file mode 100644 index 0000000..cf13881 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php @@ -0,0 +1,32 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\PseudoNode; + +class PseudoNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new PseudoNode(new ElementNode(), 'pseudo'), 'Pseudo[Element[*]:pseudo]'], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new PseudoNode(new ElementNode(), 'pseudo'), 10], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php new file mode 100644 index 0000000..142b104 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php @@ -0,0 +1,34 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; + +class SelectorNodeTest extends AbstractNodeTestCase +{ + public static function getToStringConversionTestData() + { + return [ + [new SelectorNode(new ElementNode()), 'Selector[Element[*]]'], + [new SelectorNode(new ElementNode(), 'pseudo'), 'Selector[Element[*]::pseudo]'], + ]; + } + + public static function getSpecificityValueTestData() + { + return [ + [new SelectorNode(new ElementNode()), 0], + [new SelectorNode(new ElementNode(), 'pseudo'), 1], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php new file mode 100644 index 0000000..790f8c1 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php @@ -0,0 +1,63 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\Specificity; + +class SpecificityTest extends TestCase +{ + /** @dataProvider getValueTestData */ + public function testValue(Specificity $specificity, $value) + { + $this->assertEquals($value, $specificity->getValue()); + } + + /** @dataProvider getValueTestData */ + public function testPlusValue(Specificity $specificity, $value) + { + $this->assertEquals($value + 123, $specificity->plus(new Specificity(1, 2, 3))->getValue()); + } + + public static function getValueTestData() + { + return [ + [new Specificity(0, 0, 0), 0], + [new Specificity(0, 0, 2), 2], + [new Specificity(0, 3, 0), 30], + [new Specificity(4, 0, 0), 400], + [new Specificity(4, 3, 2), 432], + ]; + } + + /** @dataProvider getCompareTestData */ + public function testCompareTo(Specificity $a, Specificity $b, $result) + { + $this->assertEquals($result, $a->compareTo($b)); + } + + public static function getCompareTestData() + { + return [ + [new Specificity(0, 0, 0), new Specificity(0, 0, 0), 0], + [new Specificity(0, 0, 1), new Specificity(0, 0, 1), 0], + [new Specificity(0, 0, 2), new Specificity(0, 0, 1), 1], + [new Specificity(0, 0, 2), new Specificity(0, 0, 3), -1], + [new Specificity(0, 4, 0), new Specificity(0, 4, 0), 0], + [new Specificity(0, 6, 0), new Specificity(0, 5, 11), 1], + [new Specificity(0, 7, 0), new Specificity(0, 8, 0), -1], + [new Specificity(9, 0, 0), new Specificity(9, 0, 0), 0], + [new Specificity(11, 0, 0), new Specificity(10, 11, 0), 1], + [new Specificity(12, 11, 0), new Specificity(13, 0, 0), -1], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php new file mode 100644 index 0000000..b46f2f7 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php @@ -0,0 +1,70 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Reader; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\TokenStream; + +/** + * @author Jean-François Simon + */ +abstract class AbstractHandlerTestCase extends TestCase +{ + /** @dataProvider getHandleValueTestData */ + public function testHandleValue($value, Token $expectedToken, $remainingContent) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertTrue($this->generateHandler()->handle($reader, $stream)); + $this->assertEquals($expectedToken, $stream->getNext()); + $this->assertRemainingContent($reader, $remainingContent); + } + + /** @dataProvider getDontHandleValueTestData */ + public function testDontHandleValue($value) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertFalse($this->generateHandler()->handle($reader, $stream)); + $this->assertStreamEmpty($stream); + $this->assertRemainingContent($reader, $value); + } + + abstract public static function getHandleValueTestData(); + + abstract public static function getDontHandleValueTestData(); + + abstract protected function generateHandler(); + + protected function assertStreamEmpty(TokenStream $stream) + { + $property = new \ReflectionProperty($stream, 'tokens'); + $property->setAccessible(true); + + $this->assertEquals([], $property->getValue($stream)); + } + + protected function assertRemainingContent(Reader $reader, $remainingContent) + { + if ('' === $remainingContent) { + $this->assertEquals(0, $reader->getRemainingLength()); + $this->assertTrue($reader->isEOF()); + } else { + $this->assertEquals(\strlen($remainingContent), $reader->getRemainingLength()); + $this->assertEquals(0, $reader->getOffset($remainingContent)); + } + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php new file mode 100644 index 0000000..459d8de --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php @@ -0,0 +1,55 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\CommentHandler; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Reader; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\TokenStream; + +class CommentHandlerTest extends AbstractHandlerTestCase +{ + /** @dataProvider getHandleValueTestData */ + public function testHandleValue($value, Token $unusedArgument, $remainingContent) + { + $reader = new Reader($value); + $stream = new TokenStream(); + + $this->assertTrue($this->generateHandler()->handle($reader, $stream)); + // comments are ignored (not pushed as token in stream) + $this->assertStreamEmpty($stream); + $this->assertRemainingContent($reader, $remainingContent); + } + + public static function getHandleValueTestData() + { + return [ + // 2nd argument only exists for inherited method compatibility + ['/* comment */', new Token(null, null, null), ''], + ['/* comment */foo', new Token(null, null, null), 'foo'], + ]; + } + + public static function getDontHandleValueTestData() + { + return [ + ['>'], + ['+'], + [' '], + ]; + } + + protected function generateHandler() + { + return new CommentHandler(); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php new file mode 100644 index 0000000..a96c861 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\HashHandler; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +class HashHandlerTest extends AbstractHandlerTestCase +{ + public static function getHandleValueTestData() + { + return [ + ['#id', new Token(Token::TYPE_HASH, 'id', 0), ''], + ['#123', new Token(Token::TYPE_HASH, '123', 0), ''], + + ['#id.class', new Token(Token::TYPE_HASH, 'id', 0), '.class'], + ['#id element', new Token(Token::TYPE_HASH, 'id', 0), ' element'], + ]; + } + + public static function getDontHandleValueTestData() + { + return [ + ['id'], + ['123'], + ['<'], + ['<'], + ['#'], + ]; + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new HashHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php new file mode 100644 index 0000000..1cb9ffe --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php @@ -0,0 +1,49 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +class IdentifierHandlerTest extends AbstractHandlerTestCase +{ + public static function getHandleValueTestData() + { + 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 static function getDontHandleValueTestData() + { + return [ + ['>'], + ['+'], + [' '], + ['*|foo'], + ['/* comment */'], + ]; + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new IdentifierHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php new file mode 100644 index 0000000..e40b86f --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\NumberHandler; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +class NumberHandlerTest extends AbstractHandlerTestCase +{ + public static function getHandleValueTestData() + { + 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), ''], + + ['12 arg', new Token(Token::TYPE_NUMBER, '12', 0), ' arg'], + ['12]', new Token(Token::TYPE_NUMBER, '12', 0), ']'], + ]; + } + + public static function getDontHandleValueTestData() + { + return [ + ['hello'], + ['>'], + ['+'], + [' '], + ['/* comment */'], + ]; + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new NumberHandler($patterns); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php new file mode 100644 index 0000000..d00233c --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php @@ -0,0 +1,50 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\StringHandler; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; + +class StringHandlerTest extends AbstractHandlerTestCase +{ + public static function getHandleValueTestData() + { + 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), ''], + + ["'foo'bar", new Token(Token::TYPE_STRING, 'foo', 1), 'bar'], + ]; + } + + public static function getDontHandleValueTestData() + { + return [ + ['hello'], + ['>'], + ['1'], + [' '], + ]; + } + + protected function generateHandler() + { + $patterns = new TokenizerPatterns(); + + return new StringHandler($patterns, new TokenizerEscaping($patterns)); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php new file mode 100644 index 0000000..1cd3e9d --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; + +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\WhitespaceHandler; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; + +class WhitespaceHandlerTest extends AbstractHandlerTestCase +{ + public static function getHandleValueTestData() + { + return [ + [' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''], + ["\n", new Token(Token::TYPE_WHITESPACE, "\n", 0), ''], + ["\t", new Token(Token::TYPE_WHITESPACE, "\t", 0), ''], + + [' foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), 'foo'], + [' .foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), '.foo'], + ]; + } + + public static function getDontHandleValueTestData() + { + return [ + ['>'], + ['1'], + ['a'], + ]; + } + + protected function generateHandler() + { + return new WhitespaceHandler(); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php new file mode 100644 index 0000000..a9ef9d6 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php @@ -0,0 +1,263 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\FunctionNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Parser; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; + +class ParserTest extends TestCase +{ + /** @dataProvider getParserTestData */ + public function testParser($source, $representation) + { + $parser = new Parser(); + + $this->assertEquals($representation, array_map(function (SelectorNode $node) { + return (string) $node->getTree(); + }, $parser->parse($source))); + } + + /** @dataProvider getParserExceptionTestData */ + public function testParserException($source, $message) + { + $parser = new Parser(); + + try { + $parser->parse($source); + $this->fail('Parser should throw a SyntaxErrorException.'); + } catch (SyntaxErrorException $e) { + $this->assertEquals($message, $e->getMessage()); + } + } + + /** @dataProvider getPseudoElementsTestData */ + public function testPseudoElements($source, $element, $pseudo) + { + $parser = new Parser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($element, (string) $selector->getTree()); + $this->assertEquals($pseudo, (string) $selector->getPseudoElement()); + } + + /** @dataProvider getSpecificityTestData */ + public function testSpecificity($source, $value) + { + $parser = new Parser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($value, $selector->getSpecificity()->getValue()); + } + + /** @dataProvider getParseSeriesTestData */ + public function testParseSeries($series, $a, $b) + { + $parser = new Parser(); + $selectors = $parser->parse(sprintf(':nth-child(%s)', $series)); + $this->assertCount(1, $selectors); + + /** @var FunctionNode $function */ + $function = $selectors[0]->getTree(); + $this->assertEquals([$a, $b], Parser::parseSeries($function->getArguments())); + } + + /** @dataProvider getParseSeriesExceptionTestData */ + public function testParseSeriesException($series) + { + $parser = new Parser(); + $selectors = $parser->parse(sprintf(':nth-child(%s)', $series)); + $this->assertCount(1, $selectors); + + /** @var FunctionNode $function */ + $function = $selectors[0]->getTree(); + $this->expectException(SyntaxErrorException::class); + Parser::parseSeries($function->getArguments()); + } + + public static function getParserTestData() + { + 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] Element[span]]']], + ['div > p', ['CombinedSelector[Element[div] > Element[p]]']], + ['td:first', ['Pseudo[Element[td]:first]']], + ['td :first', ['CombinedSelector[Element[td] Pseudo[Element[*]:first]]']], + ['a[name]', ['Powered_Cache_Attribute[Element[a][name]]']], + ["a[ name\t]", ['Powered_Cache_Attribute[Element[a][name]]']], + ['a [name]', ['CombinedSelector[Element[a] Powered_Cache_Attribute[Element[*][name]]]']], + ['[name="foo"]', ["Powered_Cache_Attribute[Element[*][name = 'foo']]"]], + ["[name='foo[1]']", ["Powered_Cache_Attribute[Element[*][name = 'foo[1]']]"]], + ["[name='foo[0][bar]']", ["Powered_Cache_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']", ["Powered_Cache_Attribute[Element[a][hreflang |= 'en']]"]], + ['a[hreflang|=en]', ["Powered_Cache_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] Function[Element[div]:nth-of-type(['10'])]] 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]', ["Powered_Cache_Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]"]], + ['div#foo\.bar', ['Hash[Element[div]#foo.bar]']], + ['div.w-1\/3', ['Class[Element[div].w-1/3]']], + ['#test\:colon', ['Hash[Element[*]#test:colon]']], + [".a\xc1b", ["Class[Element[*].a\xc1b]"]], + // unicode escape: \22 == " + ['*[aval="\'\22\'"]', ['Powered_Cache_Attribute[Element[*][aval = \'\'"\'\']]']], + ['*[aval="\'\22 2\'"]', ['Powered_Cache_Attribute[Element[*][aval = \'\'"2\'\']]']], + // unicode escape: \20 == (space) + ['*[aval="\'\20 \'"]', ['Powered_Cache_Attribute[Element[*][aval = \'\' \'\']]']], + ["*[aval=\"'\\20\r\n '\"]", ['Powered_Cache_Attribute[Element[*][aval = \'\' \'\']]']], + ]; + } + + public static function getParserExceptionTestData() + { + 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 static function getPseudoElementsTestData() + { + 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[Powered_Cache_Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'], + ['video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'], + ]; + } + + public static function getSpecificityTestData() + { + 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 static function getParseSeriesTestData() + { + 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 static function getParseSeriesExceptionTestData() + { + return [ + ['foo'], + ['n+'], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php new file mode 100644 index 0000000..b160113 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php @@ -0,0 +1,102 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Reader; + +class ReaderTest extends TestCase +{ + public function testIsEOF() + { + $reader = new Reader(''); + $this->assertTrue($reader->isEOF()); + + $reader = new Reader('hello'); + $this->assertFalse($reader->isEOF()); + + $this->assignPosition($reader, 2); + $this->assertFalse($reader->isEOF()); + + $this->assignPosition($reader, 5); + $this->assertTrue($reader->isEOF()); + } + + public function testGetRemainingLength() + { + $reader = new Reader('hello'); + $this->assertEquals(5, $reader->getRemainingLength()); + + $this->assignPosition($reader, 2); + $this->assertEquals(3, $reader->getRemainingLength()); + + $this->assignPosition($reader, 5); + $this->assertEquals(0, $reader->getRemainingLength()); + } + + public function testGetSubstring() + { + $reader = new Reader('hello'); + $this->assertEquals('he', $reader->getSubstring(2)); + $this->assertEquals('el', $reader->getSubstring(2, 1)); + + $this->assignPosition($reader, 2); + $this->assertEquals('ll', $reader->getSubstring(2)); + $this->assertEquals('lo', $reader->getSubstring(2, 1)); + } + + public function testGetOffset() + { + $reader = new Reader('hello'); + $this->assertEquals(2, $reader->getOffset('ll')); + $this->assertFalse($reader->getOffset('w')); + + $this->assignPosition($reader, 2); + $this->assertEquals(0, $reader->getOffset('ll')); + $this->assertFalse($reader->getOffset('he')); + } + + public function testFindPattern() + { + $reader = new Reader('hello'); + + $this->assertFalse($reader->findPattern('/world/')); + $this->assertEquals(['hello', 'h'], $reader->findPattern('/^([a-z]).*/')); + + $this->assignPosition($reader, 2); + $this->assertFalse($reader->findPattern('/^h.*/')); + $this->assertEquals(['llo'], $reader->findPattern('/^llo$/')); + } + + public function testMoveForward() + { + $reader = new Reader('hello'); + $this->assertEquals(0, $reader->getPosition()); + + $reader->moveForward(2); + $this->assertEquals(2, $reader->getPosition()); + } + + public function testToEnd() + { + $reader = new Reader('hello'); + $reader->moveToEnd(); + $this->assertTrue($reader->isEOF()); + } + + private function assignPosition(Reader $reader, int $value) + { + $position = new \ReflectionProperty($reader, 'position'); + $position->setAccessible(true); + $position->setValue($reader, $value); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php new file mode 100644 index 0000000..188d29f --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Shortcut\ClassParser; + +/** + * @author Jean-François Simon + */ +class ClassParserTest extends TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new ClassParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public static function getParseTestData() + { + 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]'], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php new file mode 100644 index 0000000..58540ea --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php @@ -0,0 +1,44 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Shortcut\ElementParser; + +/** + * @author Jean-François Simon + */ +class ElementParserTest extends TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new ElementParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public static function getParseTestData() + { + return [ + ['*', 'Element[*]'], + ['testel', 'Element[testel]'], + ['testns|*', 'Element[testns|*]'], + ['testns|testel', 'Element[testns|testel]'], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php new file mode 100644 index 0000000..b6540ff --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php @@ -0,0 +1,36 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Shortcut\EmptyStringParser; + +/** + * @author Jean-François Simon + */ +class EmptyStringParserTest extends TestCase +{ + public function testParse() + { + $parser = new EmptyStringParser(); + $selectors = $parser->parse(''); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals('Element[*]', (string) $selector->getTree()); + + $selectors = $parser->parse('this will produce an empty array'); + $this->assertCount(0, $selectors); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php new file mode 100644 index 0000000..9a92ca4 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php @@ -0,0 +1,45 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Shortcut; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Shortcut\HashParser; + +/** + * @author Jean-François Simon + */ +class HashParserTest extends TestCase +{ + /** @dataProvider getParseTestData */ + public function testParse($source, $representation) + { + $parser = new HashParser(); + $selectors = $parser->parse($source); + $this->assertCount(1, $selectors); + + /** @var SelectorNode $selector */ + $selector = $selectors[0]; + $this->assertEquals($representation, (string) $selector->getTree()); + } + + public static function getParseTestData() + { + 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]'], + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php new file mode 100644 index 0000000..ec7f7f5 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php @@ -0,0 +1,97 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\SyntaxErrorException; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\TokenStream; + +class TokenStreamTest extends TestCase +{ + public function testGetNext() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3)); + + $this->assertSame($t1, $stream->getNext()); + $this->assertSame($t2, $stream->getNext()); + $this->assertSame($t3, $stream->getNext()); + } + + public function testGetPeek() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3)); + + $this->assertSame($t1, $stream->getPeek()); + $this->assertSame($t1, $stream->getNext()); + $this->assertSame($t2, $stream->getPeek()); + $this->assertSame($t2, $stream->getPeek()); + $this->assertSame($t2, $stream->getNext()); + } + + public function testGetNextIdentifier() + { + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + + $this->assertEquals('h1', $stream->getNextIdentifier()); + } + + public function testFailToGetNextIdentifier() + { + $this->expectException(SyntaxErrorException::class); + + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->getNextIdentifier(); + } + + public function testGetNextIdentifierOrStar() + { + $stream = new TokenStream(); + + $stream->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $this->assertEquals('h1', $stream->getNextIdentifierOrStar()); + + $stream->push(new Token(Token::TYPE_DELIMITER, '*', 0)); + $this->assertNull($stream->getNextIdentifierOrStar()); + } + + public function testFailToGetNextIdentifierOrStar() + { + $this->expectException(SyntaxErrorException::class); + + $stream = new TokenStream(); + $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); + $stream->getNextIdentifierOrStar(); + } + + public function testSkipWhitespace() + { + $stream = new TokenStream(); + $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); + $stream->push($t2 = new Token(Token::TYPE_WHITESPACE, ' ', 2)); + $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'h1', 3)); + + $stream->skipWhitespace(); + $this->assertSame($t1, $stream->getNext()); + + $stream->skipWhitespace(); + $this->assertSame($t3, $stream->getNext()); + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html new file mode 100644 index 0000000..1147bf3 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html @@ -0,0 +1,52 @@ + + + + +
+ + + + link +
    +
  1. content
  2. +
  3. +
    +
    +
  4. +
  5. +
  6. +
  7. +
  8. +
  9. +
+

+ hi there + guy + + + + + + + +

+ + +
+

+
    +
+ + + + +
+
+
+ +
+ + diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml new file mode 100644 index 0000000..14f8dbe --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml @@ -0,0 +1,11 @@ + + a + b + c + d + e + f + + + + diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html new file mode 100644 index 0000000..15d1ad3 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html @@ -0,0 +1,308 @@ + + + + + + +
+
+

As You Like It

+
+ by William Shakespeare +
+
+

ACT I, SCENE III. A room in the palace.

+
+
Enter CELIA and ROSALIND
+
+
CELIA
+
+
Why, cousin! why, Rosalind! Cupid have mercy! not a word?
+
+
ROSALIND
+
+
Not one to throw at a dog.
+
+
CELIA
+
+
No, thy words are too precious to be cast away upon
+
curs; throw some of them at me; come, lame me with reasons.
+
+
ROSALIND
+
CELIA
+
+
But is all this for your father?
+
+
+
Then there were two cousins laid up; when the one
+
should be lamed with reasons and the other mad
+
without any.
+
+
ROSALIND
+
+
No, some of it is for my child's father. O, how
+
full of briers is this working-day world!
+
+
CELIA
+
+
They are but burs, cousin, thrown upon thee in
+
holiday foolery: if we walk not in the trodden
+
paths our very petticoats will catch them.
+
+
ROSALIND
+
+
I could shake them off my coat: these burs are in my heart.
+
+
CELIA
+
+
Hem them away.
+
+
ROSALIND
+
+
I would try, if I could cry 'hem' and have him.
+
+
CELIA
+
+
Come, come, wrestle with thy affections.
+
+
ROSALIND
+
+
O, they take the part of a better wrestler than myself!
+
+
CELIA
+
+
O, a good wish upon you! you will try in time, in
+
despite of a fall. But, turning these jests out of
+
service, let us talk in good earnest: is it
+
possible, on such a sudden, you should fall into so
+
strong a liking with old Sir Rowland's youngest son?
+
+
ROSALIND
+
+
The duke my father loved his father dearly.
+
+
CELIA
+
+
Doth it therefore ensue that you should love his son
+
dearly? By this kind of chase, I should hate him,
+
for my father hated his father dearly; yet I hate
+
not Orlando.
+
+
ROSALIND
+
+
No, faith, hate him not, for my sake.
+
+
CELIA
+
+
Why should I not? doth he not deserve well?
+
+
ROSALIND
+
+
Let me love him for that, and do you love him
+
because I do. Look, here comes the duke.
+
+
CELIA
+
+
With his eyes full of anger.
+
Enter DUKE FREDERICK, with Lords
+
+
DUKE FREDERICK
+
+
Mistress, dispatch you with your safest haste
+
And get you from our court.
+
+
ROSALIND
+
+
Me, uncle?
+
+
DUKE FREDERICK
+
+
You, cousin
+
Within these ten days if that thou be'st found
+
So near our public court as twenty miles,
+
Thou diest for it.
+
+
ROSALIND
+
+
I do beseech your grace,
+
Let me the knowledge of my fault bear with me:
+
If with myself I hold intelligence
+
Or have acquaintance with mine own desires,
+
If that I do not dream or be not frantic,--
+
As I do trust I am not--then, dear uncle,
+
Never so much as in a thought unborn
+
Did I offend your highness.
+
+
DUKE FREDERICK
+
+
Thus do all traitors:
+
If their purgation did consist in words,
+
They are as innocent as grace itself:
+
Let it suffice thee that I trust thee not.
+
+
ROSALIND
+
+
Yet your mistrust cannot make me a traitor:
+
Tell me whereon the likelihood depends.
+
+
DUKE FREDERICK
+
+
Thou art thy father's daughter; there's enough.
+
+
ROSALIND
+
+
So was I when your highness took his dukedom;
+
So was I when your highness banish'd him:
+
Treason is not inherited, my lord;
+
Or, if we did derive it from our friends,
+
What's that to me? my father was no traitor:
+
Then, good my liege, mistake me not so much
+
To think my poverty is treacherous.
+
+
CELIA
+
+
Dear sovereign, hear me speak.
+
+
DUKE FREDERICK
+
+
Ay, Celia; we stay'd her for your sake,
+
Else had she with her father ranged along.
+
+
CELIA
+
+
I did not then entreat to have her stay;
+
It was your pleasure and your own remorse:
+
I was too young that time to value her;
+
But now I know her: if she be a traitor,
+
Why so am I; we still have slept together,
+
Rose at an instant, learn'd, play'd, eat together,
+
And wheresoever we went, like Juno's swans,
+
Still we went coupled and inseparable.
+
+
DUKE FREDERICK
+
+
She is too subtle for thee; and her smoothness,
+
Her very silence and her patience
+
Speak to the people, and they pity her.
+
Thou art a fool: she robs thee of thy name;
+
And thou wilt show more bright and seem more virtuous
+
When she is gone. Then open not thy lips:
+
Firm and irrevocable is my doom
+
Which I have pass'd upon her; she is banish'd.
+
+
CELIA
+
+
Pronounce that sentence then on me, my liege:
+
I cannot live out of her company.
+
+
DUKE FREDERICK
+
+
You are a fool. You, niece, provide yourself:
+
If you outstay the time, upon mine honour,
+
And in the greatness of my word, you die.
+
Exeunt DUKE FREDERICK and Lords
+
+
CELIA
+
+
O my poor Rosalind, whither wilt thou go?
+
Wilt thou change fathers? I will give thee mine.
+
I charge thee, be not thou more grieved than I am.
+
+
ROSALIND
+
+
I have more cause.
+
+
CELIA
+
+
Thou hast not, cousin;
+
Prithee be cheerful: know'st thou not, the duke
+
Hath banish'd me, his daughter?
+
+
ROSALIND
+
+
That he hath not.
+
+
CELIA
+
+
No, hath not? Rosalind lacks then the love
+
Which teacheth thee that thou and I am one:
+
Shall we be sunder'd? shall we part, sweet girl?
+
No: let my father seek another heir.
+
Therefore devise with me how we may fly,
+
Whither to go and what to bear with us;
+
And do not seek to take your change upon you,
+
To bear your griefs yourself and leave me out;
+
For, by this heaven, now at our sorrows pale,
+
Say what thou canst, I'll go along with thee.
+
+
ROSALIND
+
+
Why, whither shall we go?
+
+
CELIA
+
+
To seek my uncle in the forest of Arden.
+
+
ROSALIND
+
+
Alas, what danger will it be to us,
+
Maids as we are, to travel forth so far!
+
Beauty provoketh thieves sooner than gold.
+
+
CELIA
+
+
I'll put myself in poor and mean attire
+
And with a kind of umber smirch my face;
+
The like do you: so shall we pass along
+
And never stir assailants.
+
+
ROSALIND
+
+
Were it not better,
+
Because that I am more than common tall,
+
That I did suit me all points like a man?
+
A gallant curtle-axe upon my thigh,
+
A boar-spear in my hand; and--in my heart
+
Lie there what hidden woman's fear there will--
+
We'll have a swashing and a martial outside,
+
As many other mannish cowards have
+
That do outface it with their semblances.
+
+
CELIA
+
+
What shall I call thee when thou art a man?
+
+
ROSALIND
+
+
I'll have no worse a name than Jove's own page;
+
And therefore look you call me Ganymede.
+
But what will you be call'd?
+
+
CELIA
+
+
Something that hath a reference to my state
+
No longer Celia, but Aliena.
+
+
ROSALIND
+
+
But, cousin, what if we assay'd to steal
+
The clownish fool out of your father's court?
+
Would he not be a comfort to our travel?
+
+
CELIA
+
+
He'll go along o'er the wide world with me;
+
Leave me alone to woo him. Let's away,
+
And get our jewels and our wealth together,
+
Devise the fittest time and safest way
+
To hide us from pursuit that will be made
+
After my flight. Now go we in content
+
To liberty and not to banishment.
+
Exeunt
+
+
+
+
+ + diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php new file mode 100644 index 0000000..fad6105 --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php @@ -0,0 +1,416 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\XPath; + +use PHPUnit\Framework\TestCase; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\ExpressionErrorException; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\FunctionNode; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Parser; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\XPath\Extension\HtmlExtension; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\XPath\Translator; +use PoweredCache\Dependencies\Symfony\Component\CssSelector\XPath\XPathExpr; + +class TranslatorTest extends TestCase +{ + /** @dataProvider getXpathLiteralTestData */ + public function testXpathLiteral($value, $literal) + { + $this->assertEquals($literal, Translator::getXpathLiteral($value)); + } + + /** @dataProvider getCssToXPathTestData */ + public function testCssToXPath($css, $xpath) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $this->assertEquals($xpath, $translator->cssToXPath($css, '')); + } + + public function testCssToXPathPseudoElement() + { + $this->expectException(ExpressionErrorException::class); + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $translator->cssToXPath('e::first-line'); + } + + public function testGetExtensionNotExistsExtension() + { + $this->expectException(ExpressionErrorException::class); + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $translator->getExtension('fake'); + } + + public function testAddCombinationNotExistsExtension() + { + $this->expectException(ExpressionErrorException::class); + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $parser = new Parser(); + $xpath = $parser->parse('*')[0]; + $combinedXpath = $parser->parse('*')[0]; + $translator->addCombination('fake', $xpath, $combinedXpath); + } + + public function testAddFunctionNotExistsFunction() + { + $this->expectException(ExpressionErrorException::class); + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $xpath = new XPathExpr(); + $function = new FunctionNode(new ElementNode(), 'fake'); + $translator->addFunction($xpath, $function); + } + + public function testAddPseudoClassNotExistsClass() + { + $this->expectException(ExpressionErrorException::class); + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $xpath = new XPathExpr(); + $translator->addPseudoClass($xpath, 'fake'); + } + + public function testAddAttributeMatchingClassNotExistsClass() + { + $this->expectException(ExpressionErrorException::class); + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $xpath = new XPathExpr(); + $translator->addAttributeMatching($xpath, '', '', ''); + } + + /** @dataProvider getXmlLangTestData */ + public function testXmlLang($css, array $elementsId) + { + $translator = new Translator(); + $document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml')); + $elements = $document->xpath($translator->cssToXPath($css)); + $this->assertCount(\count($elementsId), $elements); + foreach ($elements as $element) { + $this->assertContains((string) $element->attributes()->id, $elementsId); + } + } + + /** @dataProvider getHtmlIdsTestData */ + public function testHtmlIds($css, array $elementsId) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $document = new \DOMDocument(); + $document->strictErrorChecking = false; + $internalErrors = libxml_use_internal_errors(true); + $document->loadHTMLFile(__DIR__.'/Fixtures/ids.html'); + $document = simplexml_import_dom($document); + $elements = $document->xpath($translator->cssToXPath($css)); + $this->assertCount(\count($elementsId), $elements); + foreach ($elements as $element) { + if (null !== $element->attributes()->id) { + $this->assertContains((string) $element->attributes()->id, $elementsId); + } + } + libxml_clear_errors(); + libxml_use_internal_errors($internalErrors); + } + + /** @dataProvider getHtmlShakespearTestData */ + public function testHtmlShakespear($css, $count) + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $document = new \DOMDocument(); + $document->strictErrorChecking = false; + $document->loadHTMLFile(__DIR__.'/Fixtures/shakespear.html'); + $document = simplexml_import_dom($document); + $bodies = $document->xpath('//body'); + $elements = $bodies[0]->xpath($translator->cssToXPath($css)); + $this->assertCount($count, $elements); + } + + public function testOnlyOfTypeFindsSingleChildrenOfGivenType() + { + $translator = new Translator(); + $translator->registerExtension(new HtmlExtension($translator)); + $document = new \DOMDocument(); + $document->loadHTML(<<<'HTML' + + +

+ A +

+

+ B + C +

+ + +HTML + ); + + $xpath = new \DOMXPath($document); + $nodeList = $xpath->query($translator->cssToXPath('span:only-of-type')); + + $this->assertSame(1, $nodeList->length); + $this->assertSame('A', $nodeList->item(0)->textContent); + } + + public static function getXpathLiteralTestData() + { + return [ + ['foo', "'foo'"], + ["foo's bar", '"foo\'s bar"'], + ["foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'], + ["foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'], + ]; + } + + public static function getCssToXPathTestData() + { + return [ + ['*', '*'], + ['e', 'e'], + ['*|e', 'e'], + ['e|f', 'e:f'], + ['e[foo]', 'e[@foo]'], + ['e[foo|bar]', 'e[@foo:bar]'], + ['e[foo="bar"]', "e[@foo = 'bar']"], + ['e[foo~="bar"]', "e[@foo and contains(concat(' ', normalize-space(@foo), ' '), ' bar ')]"], + ['e[foo^="bar"]', "e[@foo and starts-with(@foo, 'bar')]"], + ['e[foo$="bar"]', "e[@foo and substring(@foo, string-length(@foo)-2) = 'bar']"], + ['e[foo*="bar"]', "e[@foo and contains(@foo, 'bar')]"], + ['e[foo!="bar"]', "e[not(@foo) or @foo != 'bar']"], + ['e[foo!="bar"][foo!="baz"]', "e[(not(@foo) or @foo != 'bar') and (not(@foo) or @foo != 'baz')]"], + ['e[hreflang|="en"]', "e[@hreflang and (@hreflang = 'en' or starts-with(@hreflang, 'en-'))]"], + ['e:nth-child(1)', "*/*[(name() = 'e') and (position() = 1)]"], + ['e:nth-last-child(1)', "*/*[(name() = 'e') and (position() = last() - 0)]"], + ['e:nth-last-child(2n+2)', "*/*[(name() = 'e') and (last() - position() - 1 >= 0 and (last() - position() - 1) mod 2 = 0)]"], + ['e:nth-of-type(1)', '*/e[position() = 1]'], + ['e:nth-last-of-type(1)', '*/e[position() = last() - 0]'], + ['div e:nth-last-of-type(1) .aclass', "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')]"], + ['e:first-child', "*/*[(name() = 'e') and (position() = 1)]"], + ['e:last-child', "*/*[(name() = 'e') and (position() = last())]"], + ['e:first-of-type', '*/e[position() = 1]'], + ['e:last-of-type', '*/e[position() = last()]'], + ['e:only-child', "*/*[(name() = 'e') and (last() = 1)]"], + ['e:only-of-type', 'e[count(preceding-sibling::e)=0 and count(following-sibling::e)=0]'], + ['e:empty', 'e[not(*) and not(string-length())]'], + ['e:EmPTY', 'e[not(*) and not(string-length())]'], + ['e:root', 'e[not(parent::*)]'], + ['e:hover', 'e[0]'], + ['e:contains("foo")', "e[contains(string(.), 'foo')]"], + ['e:ConTains(foo)', "e[contains(string(.), 'foo')]"], + ['e.warning', "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')]"], + ['e#myid', "e[@id = 'myid']"], + ['e:not(:nth-child(odd))', 'e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]'], + ['e:nOT(*)', 'e[0]'], + ['e f', 'e/descendant-or-self::*/f'], + ['e > f', 'e/f'], + ['e + f', "e/following-sibling::*[(name() = 'f') and (position() = 1)]"], + ['e ~ f', 'e/following-sibling::f'], + ['div#container p', "div[@id = 'container']/descendant-or-self::*/p"], + ]; + } + + public static function getXmlLangTestData() + { + return [ + [':lang("EN")', ['first', 'second', 'third', 'fourth']], + [':lang("en-us")', ['second', 'fourth']], + [':lang(en-nz)', ['third']], + [':lang(fr)', ['fifth']], + [':lang(ru)', ['sixth']], + [":lang('ZH')", ['eighth']], + [':lang(de) :lang(zh)', ['eighth']], + [':lang(en), :lang(zh)', ['first', 'second', 'third', 'fourth', 'eighth']], + [':lang(es)', []], + ]; + } + + public static function getHtmlIdsTestData() + { + return [ + ['div', ['outer-div', 'li-div', 'foobar-div']], + ['DIV', ['outer-div', 'li-div', 'foobar-div']], // case-insensitive in HTML + ['div div', ['li-div']], + ['div, div div', ['outer-div', 'li-div', 'foobar-div']], + ['a[name]', ['name-anchor']], + ['a[NAme]', ['name-anchor']], // case-insensitive in HTML: + ['a[rel]', ['tag-anchor', 'nofollow-anchor']], + ['a[rel="tag"]', ['tag-anchor']], + ['a[href*="localhost"]', ['tag-anchor']], + ['a[href*=""]', []], + ['a[href^="http"]', ['tag-anchor', 'nofollow-anchor']], + ['a[href^="http:"]', ['tag-anchor']], + ['a[href^=""]', []], + ['a[href$="org"]', ['nofollow-anchor']], + ['a[href$=""]', []], + ['div[foobar~="bc"]', ['foobar-div']], + ['div[foobar~="cde"]', ['foobar-div']], + ['[foobar~="ab bc"]', ['foobar-div']], + ['[foobar~=""]', []], + ['[foobar~=" \t"]', []], + ['div[foobar~="cd"]', []], + ['*[lang|="En"]', ['second-li']], + ['[lang|="En-us"]', ['second-li']], + // Powered_Cache_Attribute values are case sensitive + ['*[lang|="en"]', []], + ['[lang|="en-US"]', []], + ['*[lang|="e"]', []], + // ... :lang() is not. + [':lang("EN")', ['second-li', 'li-div']], + ['*:lang(en-US)', ['second-li', 'li-div']], + [':lang("e")', []], + ['li:nth-child(3)', ['third-li']], + ['li:nth-child(10)', []], + ['li:nth-child(2n)', ['second-li', 'fourth-li', 'sixth-li']], + ['li:nth-child(even)', ['second-li', 'fourth-li', 'sixth-li']], + ['li:nth-child(2n+0)', ['second-li', 'fourth-li', 'sixth-li']], + ['li:nth-child(+2n+1)', ['first-li', 'third-li', 'fifth-li', 'seventh-li']], + ['li:nth-child(odd)', ['first-li', 'third-li', 'fifth-li', 'seventh-li']], + ['li:nth-child(2n+4)', ['fourth-li', 'sixth-li']], + ['li:nth-child(3n+1)', ['first-li', 'fourth-li', 'seventh-li']], + ['li:nth-child(n)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], + ['li:nth-child(n-1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], + ['li:nth-child(n+1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], + ['li:nth-child(n+3)', ['third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], + ['li:nth-child(-n)', []], + ['li:nth-child(-n-1)', []], + ['li:nth-child(-n+1)', ['first-li']], + ['li:nth-child(-n+3)', ['first-li', 'second-li', 'third-li']], + ['li:nth-last-child(0)', []], + ['li:nth-last-child(2n)', ['second-li', 'fourth-li', 'sixth-li']], + ['li:nth-last-child(even)', ['second-li', 'fourth-li', 'sixth-li']], + ['li:nth-last-child(2n+2)', ['second-li', 'fourth-li', 'sixth-li']], + ['li:nth-last-child(n)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], + ['li:nth-last-child(n-1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], + ['li:nth-last-child(n-3)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], + ['li:nth-last-child(n+1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], + ['li:nth-last-child(n+3)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li']], + ['li:nth-last-child(-n)', []], + ['li:nth-last-child(-n-1)', []], + ['li:nth-last-child(-n+1)', ['seventh-li']], + ['li:nth-last-child(-n+3)', ['fifth-li', 'sixth-li', 'seventh-li']], + ['ol:first-of-type', ['first-ol']], + ['ol:nth-child(4)', ['first-ol']], + ['ol:nth-of-type(2)', ['second-ol']], + ['ol:nth-last-of-type(1)', ['second-ol']], + ['span:only-child', ['foobar-span', 'no-siblings-of-any-type']], + ['li div:only-child', ['li-div']], + ['div *:only-child', ['li-div', 'foobar-span']], + ['p:only-of-type', ['paragraph']], + [':only-of-type', ['html', 'li-div', 'foobar-span', 'no-siblings-of-any-type']], + ['div#foobar-div :only-of-type', ['foobar-span']], + ['a:empty', ['name-anchor']], + ['a:EMpty', ['name-anchor']], + ['li:empty', ['third-li', 'fourth-li', 'fifth-li', 'sixth-li']], + [':root', ['html']], + ['html:root', ['html']], + ['li:root', []], + ['* :root', []], + ['*:contains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']], + [':CONtains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']], + ['*:contains("LInk")', []], // case sensitive + ['*:contains("e")', ['html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em']], + ['*:contains("E")', []], // case-sensitive + ['.a', ['first-ol']], + ['.b', ['first-ol']], + ['*.a', ['first-ol']], + ['ol.a', ['first-ol']], + ['.c', ['first-ol', 'third-li', 'fourth-li']], + ['*.c', ['first-ol', 'third-li', 'fourth-li']], + ['ol *.c', ['third-li', 'fourth-li']], + ['ol li.c', ['third-li', 'fourth-li']], + ['li ~ li.c', ['third-li', 'fourth-li']], + ['ol > li.c', ['third-li', 'fourth-li']], + ['#first-li', ['first-li']], + ['li#first-li', ['first-li']], + ['*#first-li', ['first-li']], + ['li div', ['li-div']], + ['li > div', ['li-div']], + ['div div', ['li-div']], + ['div > div', []], + ['div>.c', ['first-ol']], + ['div > .c', ['first-ol']], + ['div + div', ['foobar-div']], + ['a ~ a', ['tag-anchor', 'nofollow-anchor']], + ['a[rel="tag"] ~ a', ['nofollow-anchor']], + ['ol#first-ol li:last-child', ['seventh-li']], + ['ol#first-ol *:last-child', ['li-div', 'seventh-li']], + ['#outer-div:first-child', ['outer-div']], + ['#outer-div :first-child', ['name-anchor', 'first-li', 'li-div', 'p-b', 'checkbox-fieldset-disabled', 'area-href']], + ['a[href]', ['tag-anchor', 'nofollow-anchor']], + [':not(*)', []], + ['a:not([href])', ['name-anchor']], + ['ol :Not(li[class])', ['first-li', 'second-li', 'li-div', 'fifth-li', 'sixth-li', 'seventh-li']], + // HTML-specific + [':link', ['link-href', 'tag-anchor', 'nofollow-anchor', 'area-href']], + [':visited', []], + [':enabled', ['link-href', 'tag-anchor', 'nofollow-anchor', 'checkbox-unchecked', 'text-checked', 'checkbox-checked', 'area-href']], + [':disabled', ['checkbox-disabled', 'checkbox-disabled-checked', 'fieldset', 'checkbox-fieldset-disabled']], + [':checked', ['checkbox-checked', 'checkbox-disabled-checked']], + ]; + } + + public static function getHtmlShakespearTestData() + { + return [ + ['*', 246], + ['div:contains(CELIA)', 26], + ['div:only-child', 22], // ? + ['div:nth-child(even)', 106], + ['div:nth-child(2n)', 106], + ['div:nth-child(odd)', 137], + ['div:nth-child(2n+1)', 137], + ['div:nth-child(n)', 243], + ['div:last-child', 53], + ['div:first-child', 51], + ['div > div', 242], + ['div + div', 190], + ['div ~ div', 190], + ['body', 1], + ['body div', 243], + ['div', 243], + ['div div', 242], + ['div div div', 241], + ['div, div, div', 243], + ['div, a, span', 243], + ['.dialog', 51], + ['div.dialog', 51], + ['div .dialog', 51], + ['div.character, div.dialog', 99], + ['div.direction.dialog', 0], + ['div.dialog.direction', 0], + ['div.dialog.scene', 1], + ['div.scene.scene', 1], + ['div.scene .scene', 0], + ['div.direction .dialog ', 0], + ['div .dialog .direction', 4], + ['div.dialog .dialog .direction', 4], + ['#speech5', 1], + ['div#speech5', 1], + ['div #speech5', 1], + ['div.scene div.dialog', 49], + ['div#scene1 div.dialog div', 142], + ['#scene1 #speech1', 1], + ['div[class]', 103], + ['div[class=dialog]', 50], + ['div[class^=dia]', 51], + ['div[class$=log]', 50], + ['div[class*=sce]', 1], + ['div[class|=dialog]', 50], // ? Seems right + ['div[class!=madeup]', 243], // ? Seems right + ['div[class~=dialog]', 51], // ? Seems right + ]; + } +} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/phpunit.xml.dist b/includes/classes/Dependencies/Symfony/Component/CssSelector/phpunit.xml.dist new file mode 100644 index 0000000..a8e537e --- /dev/null +++ b/includes/classes/Dependencies/Symfony/Component/CssSelector/phpunit.xml.dist @@ -0,0 +1,31 @@ + + + + + + + + + + ./Tests/ + + + + + + ./ + + ./Resources + ./Tests + ./vendor + + + + From 17e6c34b9952f18a8a050e87229c356e611d8be6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 12:08:00 +0000 Subject: [PATCH 3/4] Remove vendor test files and update gitignore Co-authored-by: mustafauysal <1421387+mustafauysal@users.noreply.github.com> --- .gitignore | 2 + .../Tests/CssSelectorConverterTest.php | 83 ---- .../Tests/Node/AbstractNodeTestCase.php | 34 -- .../Tests/Node/AttributeNodeTest.php | 37 -- .../CssSelector/Tests/Node/ClassNodeTest.php | 33 -- .../Tests/Node/CombinedSelectorNodeTest.php | 35 -- .../Tests/Node/ElementNodeTest.php | 35 -- .../Tests/Node/FunctionNodeTest.php | 47 -- .../CssSelector/Tests/Node/HashNodeTest.php | 33 -- .../Tests/Node/NegationNodeTest.php | 33 -- .../CssSelector/Tests/Node/PseudoNodeTest.php | 32 -- .../Tests/Node/SelectorNodeTest.php | 34 -- .../Tests/Node/SpecificityTest.php | 63 --- .../Handler/AbstractHandlerTestCase.php | 70 --- .../Parser/Handler/CommentHandlerTest.php | 55 --- .../Tests/Parser/Handler/HashHandlerTest.php | 49 --- .../Parser/Handler/IdentifierHandlerTest.php | 49 --- .../Parser/Handler/NumberHandlerTest.php | 50 --- .../Parser/Handler/StringHandlerTest.php | 50 --- .../Parser/Handler/WhitespaceHandlerTest.php | 44 -- .../CssSelector/Tests/Parser/ParserTest.php | 263 ----------- .../CssSelector/Tests/Parser/ReaderTest.php | 102 ----- .../Tests/Parser/Shortcut/ClassParserTest.php | 45 -- .../Parser/Shortcut/ElementParserTest.php | 44 -- .../Parser/Shortcut/EmptyStringParserTest.php | 36 -- .../Tests/Parser/Shortcut/HashParserTest.php | 45 -- .../Tests/Parser/TokenStreamTest.php | 97 ---- .../CssSelector/Tests/XPath/Fixtures/ids.html | 52 --- .../CssSelector/Tests/XPath/Fixtures/lang.xml | 11 - .../Tests/XPath/Fixtures/shakespear.html | 308 ------------- .../Tests/XPath/TranslatorTest.php | 416 ------------------ .../Component/CssSelector/phpunit.xml.dist | 31 -- 32 files changed, 2 insertions(+), 2316 deletions(-) delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php delete mode 100644 includes/classes/Dependencies/Symfony/Component/CssSelector/phpunit.xml.dist diff --git a/.gitignore b/.gitignore index 4821b74..d02d62a 100755 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,8 @@ release vendor .idea *.log +includes/classes/Dependencies/*/Tests/ +includes/classes/Dependencies/*/phpunit.xml.dist # Project Files diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php deleted file mode 100644 index d42ce90..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/CssSelectorConverterTest.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\CssSelectorConverter; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\ParseException; - -class CssSelectorConverterTest extends TestCase -{ - public function testCssToXPath() - { - $converter = new CssSelectorConverter(); - - $this->assertEquals('descendant-or-self::*', $converter->toXPath('')); - $this->assertEquals('descendant-or-self::h1', $converter->toXPath('h1')); - $this->assertEquals("descendant-or-self::h1[@id = 'foo']", $converter->toXPath('h1#foo')); - $this->assertEquals("descendant-or-self::h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]", $converter->toXPath('h1.foo')); - $this->assertEquals('descendant-or-self::foo:h1', $converter->toXPath('foo|h1')); - $this->assertEquals('descendant-or-self::h1', $converter->toXPath('H1')); - - // Test the cache layer - $converter = new CssSelectorConverter(); - $this->assertEquals('descendant-or-self::h1', $converter->toXPath('H1')); - } - - public function testCssToXPathXml() - { - $converter = new CssSelectorConverter(false); - - $this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1')); - - $converter = new CssSelectorConverter(false); - // Test the cache layer - $this->assertEquals('descendant-or-self::H1', $converter->toXPath('H1')); - } - - public function testParseExceptions() - { - $this->expectException(ParseException::class); - $this->expectExceptionMessage('Expected identifier, but found.'); - $converter = new CssSelectorConverter(); - $converter->toXPath('h1:'); - } - - /** @dataProvider getCssToXPathWithoutPrefixTestData */ - public function testCssToXPathWithoutPrefix($css, $xpath) - { - $converter = new CssSelectorConverter(); - - $this->assertEquals($xpath, $converter->toXPath($css, ''), '->parse() parses an input string and returns a node'); - } - - public static function getCssToXPathWithoutPrefixTestData() - { - return [ - ['h1', 'h1'], - ['foo|h1', 'foo:h1'], - ['h1, h2, h3', 'h1 | h2 | h3'], - ['h1:nth-child(3n+1)', "*/*[(name() = 'h1') and (position() - 1 >= 0 and (position() - 1) mod 3 = 0)]"], - ['h1 > p', 'h1/p'], - ['h1#foo', "h1[@id = 'foo']"], - ['h1.foo', "h1[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], - ['h1[class*="foo bar"]', "h1[@class and contains(@class, 'foo bar')]"], - ['h1[foo|class*="foo bar"]', "h1[@foo:class and contains(@foo:class, 'foo bar')]"], - ['h1[class]', 'h1[@class]'], - ['h1 .foo', "h1/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], - ['h1 #foo', "h1/descendant-or-self::*/*[@id = 'foo']"], - ['h1 [class*=foo]', "h1/descendant-or-self::*/*[@class and contains(@class, 'foo')]"], - ['div>.foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], - ['div > .foo', "div/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' foo ')]"], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php deleted file mode 100644 index 99460ae..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AbstractNodeTestCase.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\NodeInterface; - -abstract class AbstractNodeTestCase extends TestCase -{ - /** @dataProvider getToStringConversionTestData */ - public function testToStringConversion(NodeInterface $node, $representation) - { - $this->assertEquals($representation, (string) $node); - } - - /** @dataProvider getSpecificityValueTestData */ - public function testSpecificityValue(NodeInterface $node, $value) - { - $this->assertEquals($value, $node->getSpecificity()->getValue()); - } - - abstract public static function getToStringConversionTestData(); - - abstract public static function getSpecificityValueTestData(); -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php deleted file mode 100644 index 5115605..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/AttributeNodeTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\AttributeNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; - -class AttributeNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 'Powered_Cache_Attribute[Element[*][attribute]]'], - [new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), "Powered_Cache_Attribute[Element[*][attribute $= 'value']]"], - [new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), "Powered_Cache_Attribute[Element[*][namespace|attribute $= 'value']]"], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new AttributeNode(new ElementNode(), null, 'attribute', 'exists', null), 10], - [new AttributeNode(new ElementNode(null, 'element'), null, 'attribute', 'exists', null), 11], - [new AttributeNode(new ElementNode(), null, 'attribute', '$=', 'value'), 10], - [new AttributeNode(new ElementNode(), 'namespace', 'attribute', '$=', 'value'), 10], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php deleted file mode 100644 index ae43a62..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ClassNodeTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ClassNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; - -class ClassNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new ClassNode(new ElementNode(), 'class'), 'Class[Element[*].class]'], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new ClassNode(new ElementNode(), 'class'), 10], - [new ClassNode(new ElementNode(null, 'element'), 'class'), 11], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php deleted file mode 100644 index d9b2a38..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/CombinedSelectorNodeTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\CombinedSelectorNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; - -class CombinedSelectorNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 'CombinedSelector[Element[*] > Element[*]]'], - [new CombinedSelectorNode(new ElementNode(), ' ', new ElementNode()), 'CombinedSelector[Element[*] Element[*]]'], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new CombinedSelectorNode(new ElementNode(), '>', new ElementNode()), 0], - [new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode()), 1], - [new CombinedSelectorNode(new ElementNode(null, 'element'), '>', new ElementNode(null, 'element')), 2], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php deleted file mode 100644 index b3ef2b2..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/ElementNodeTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; - -class ElementNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new ElementNode(), 'Element[*]'], - [new ElementNode(null, 'element'), 'Element[element]'], - [new ElementNode('namespace', 'element'), 'Element[namespace|element]'], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new ElementNode(), 0], - [new ElementNode(null, 'element'), 1], - [new ElementNode('namespace', 'element'), 1], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php deleted file mode 100644 index f99a66b..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/FunctionNodeTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\FunctionNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; - -class FunctionNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new FunctionNode(new ElementNode(), 'function'), 'Function[Element[*]:function()]'], - [new FunctionNode(new ElementNode(), 'function', [ - new Token(Token::TYPE_IDENTIFIER, 'value', 0), - ]), "Function[Element[*]:function(['value'])]"], - [new FunctionNode(new ElementNode(), 'function', [ - new Token(Token::TYPE_STRING, 'value1', 0), - new Token(Token::TYPE_NUMBER, 'value2', 0), - ]), "Function[Element[*]:function(['value1', 'value2'])]"], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new FunctionNode(new ElementNode(), 'function'), 10], - [new FunctionNode(new ElementNode(), 'function', [ - new Token(Token::TYPE_IDENTIFIER, 'value', 0), - ]), 10], - [new FunctionNode(new ElementNode(), 'function', [ - new Token(Token::TYPE_STRING, 'value1', 0), - new Token(Token::TYPE_NUMBER, 'value2', 0), - ]), 10], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php deleted file mode 100644 index d43aac1..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/HashNodeTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\HashNode; - -class HashNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new HashNode(new ElementNode(), 'id'), 'Hash[Element[*]#id]'], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new HashNode(new ElementNode(), 'id'), 100], - [new HashNode(new ElementNode(null, 'id'), 'class'), 101], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php deleted file mode 100644 index 9aafe8f..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/NegationNodeTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ClassNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\NegationNode; - -class NegationNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 'Negation[Element[*]:not(Class[Element[*].class])]'], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new NegationNode(new ElementNode(), new ClassNode(new ElementNode(), 'class')), 10], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php deleted file mode 100644 index cf13881..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/PseudoNodeTest.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\PseudoNode; - -class PseudoNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new PseudoNode(new ElementNode(), 'pseudo'), 'Pseudo[Element[*]:pseudo]'], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new PseudoNode(new ElementNode(), 'pseudo'), 10], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php deleted file mode 100644 index 142b104..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SelectorNodeTest.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; - -class SelectorNodeTest extends AbstractNodeTestCase -{ - public static function getToStringConversionTestData() - { - return [ - [new SelectorNode(new ElementNode()), 'Selector[Element[*]]'], - [new SelectorNode(new ElementNode(), 'pseudo'), 'Selector[Element[*]::pseudo]'], - ]; - } - - public static function getSpecificityValueTestData() - { - return [ - [new SelectorNode(new ElementNode()), 0], - [new SelectorNode(new ElementNode(), 'pseudo'), 1], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php deleted file mode 100644 index 790f8c1..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Node/SpecificityTest.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Node; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\Specificity; - -class SpecificityTest extends TestCase -{ - /** @dataProvider getValueTestData */ - public function testValue(Specificity $specificity, $value) - { - $this->assertEquals($value, $specificity->getValue()); - } - - /** @dataProvider getValueTestData */ - public function testPlusValue(Specificity $specificity, $value) - { - $this->assertEquals($value + 123, $specificity->plus(new Specificity(1, 2, 3))->getValue()); - } - - public static function getValueTestData() - { - return [ - [new Specificity(0, 0, 0), 0], - [new Specificity(0, 0, 2), 2], - [new Specificity(0, 3, 0), 30], - [new Specificity(4, 0, 0), 400], - [new Specificity(4, 3, 2), 432], - ]; - } - - /** @dataProvider getCompareTestData */ - public function testCompareTo(Specificity $a, Specificity $b, $result) - { - $this->assertEquals($result, $a->compareTo($b)); - } - - public static function getCompareTestData() - { - return [ - [new Specificity(0, 0, 0), new Specificity(0, 0, 0), 0], - [new Specificity(0, 0, 1), new Specificity(0, 0, 1), 0], - [new Specificity(0, 0, 2), new Specificity(0, 0, 1), 1], - [new Specificity(0, 0, 2), new Specificity(0, 0, 3), -1], - [new Specificity(0, 4, 0), new Specificity(0, 4, 0), 0], - [new Specificity(0, 6, 0), new Specificity(0, 5, 11), 1], - [new Specificity(0, 7, 0), new Specificity(0, 8, 0), -1], - [new Specificity(9, 0, 0), new Specificity(9, 0, 0), 0], - [new Specificity(11, 0, 0), new Specificity(10, 11, 0), 1], - [new Specificity(12, 11, 0), new Specificity(13, 0, 0), -1], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php deleted file mode 100644 index b46f2f7..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/AbstractHandlerTestCase.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Reader; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\TokenStream; - -/** - * @author Jean-François Simon - */ -abstract class AbstractHandlerTestCase extends TestCase -{ - /** @dataProvider getHandleValueTestData */ - public function testHandleValue($value, Token $expectedToken, $remainingContent) - { - $reader = new Reader($value); - $stream = new TokenStream(); - - $this->assertTrue($this->generateHandler()->handle($reader, $stream)); - $this->assertEquals($expectedToken, $stream->getNext()); - $this->assertRemainingContent($reader, $remainingContent); - } - - /** @dataProvider getDontHandleValueTestData */ - public function testDontHandleValue($value) - { - $reader = new Reader($value); - $stream = new TokenStream(); - - $this->assertFalse($this->generateHandler()->handle($reader, $stream)); - $this->assertStreamEmpty($stream); - $this->assertRemainingContent($reader, $value); - } - - abstract public static function getHandleValueTestData(); - - abstract public static function getDontHandleValueTestData(); - - abstract protected function generateHandler(); - - protected function assertStreamEmpty(TokenStream $stream) - { - $property = new \ReflectionProperty($stream, 'tokens'); - $property->setAccessible(true); - - $this->assertEquals([], $property->getValue($stream)); - } - - protected function assertRemainingContent(Reader $reader, $remainingContent) - { - if ('' === $remainingContent) { - $this->assertEquals(0, $reader->getRemainingLength()); - $this->assertTrue($reader->isEOF()); - } else { - $this->assertEquals(\strlen($remainingContent), $reader->getRemainingLength()); - $this->assertEquals(0, $reader->getOffset($remainingContent)); - } - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php deleted file mode 100644 index 459d8de..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/CommentHandlerTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\CommentHandler; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Reader; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\TokenStream; - -class CommentHandlerTest extends AbstractHandlerTestCase -{ - /** @dataProvider getHandleValueTestData */ - public function testHandleValue($value, Token $unusedArgument, $remainingContent) - { - $reader = new Reader($value); - $stream = new TokenStream(); - - $this->assertTrue($this->generateHandler()->handle($reader, $stream)); - // comments are ignored (not pushed as token in stream) - $this->assertStreamEmpty($stream); - $this->assertRemainingContent($reader, $remainingContent); - } - - public static function getHandleValueTestData() - { - return [ - // 2nd argument only exists for inherited method compatibility - ['/* comment */', new Token(null, null, null), ''], - ['/* comment */foo', new Token(null, null, null), 'foo'], - ]; - } - - public static function getDontHandleValueTestData() - { - return [ - ['>'], - ['+'], - [' '], - ]; - } - - protected function generateHandler() - { - return new CommentHandler(); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php deleted file mode 100644 index a96c861..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/HashHandlerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\HashHandler; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; - -class HashHandlerTest extends AbstractHandlerTestCase -{ - public static function getHandleValueTestData() - { - return [ - ['#id', new Token(Token::TYPE_HASH, 'id', 0), ''], - ['#123', new Token(Token::TYPE_HASH, '123', 0), ''], - - ['#id.class', new Token(Token::TYPE_HASH, 'id', 0), '.class'], - ['#id element', new Token(Token::TYPE_HASH, 'id', 0), ' element'], - ]; - } - - public static function getDontHandleValueTestData() - { - return [ - ['id'], - ['123'], - ['<'], - ['<'], - ['#'], - ]; - } - - protected function generateHandler() - { - $patterns = new TokenizerPatterns(); - - return new HashHandler($patterns, new TokenizerEscaping($patterns)); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php deleted file mode 100644 index 1cb9ffe..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/IdentifierHandlerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\IdentifierHandler; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; - -class IdentifierHandlerTest extends AbstractHandlerTestCase -{ - public static function getHandleValueTestData() - { - 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 static function getDontHandleValueTestData() - { - return [ - ['>'], - ['+'], - [' '], - ['*|foo'], - ['/* comment */'], - ]; - } - - protected function generateHandler() - { - $patterns = new TokenizerPatterns(); - - return new IdentifierHandler($patterns, new TokenizerEscaping($patterns)); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php deleted file mode 100644 index e40b86f..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/NumberHandlerTest.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\NumberHandler; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; - -class NumberHandlerTest extends AbstractHandlerTestCase -{ - public static function getHandleValueTestData() - { - 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), ''], - - ['12 arg', new Token(Token::TYPE_NUMBER, '12', 0), ' arg'], - ['12]', new Token(Token::TYPE_NUMBER, '12', 0), ']'], - ]; - } - - public static function getDontHandleValueTestData() - { - return [ - ['hello'], - ['>'], - ['+'], - [' '], - ['/* comment */'], - ]; - } - - protected function generateHandler() - { - $patterns = new TokenizerPatterns(); - - return new NumberHandler($patterns); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php deleted file mode 100644 index d00233c..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/StringHandlerTest.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\StringHandler; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerEscaping; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Tokenizer\TokenizerPatterns; - -class StringHandlerTest extends AbstractHandlerTestCase -{ - public static function getHandleValueTestData() - { - 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), ''], - - ["'foo'bar", new Token(Token::TYPE_STRING, 'foo', 1), 'bar'], - ]; - } - - public static function getDontHandleValueTestData() - { - return [ - ['hello'], - ['>'], - ['1'], - [' '], - ]; - } - - protected function generateHandler() - { - $patterns = new TokenizerPatterns(); - - return new StringHandler($patterns, new TokenizerEscaping($patterns)); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php deleted file mode 100644 index 1cd3e9d..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Handler/WhitespaceHandlerTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Handler; - -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Handler\WhitespaceHandler; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; - -class WhitespaceHandlerTest extends AbstractHandlerTestCase -{ - public static function getHandleValueTestData() - { - return [ - [' ', new Token(Token::TYPE_WHITESPACE, ' ', 0), ''], - ["\n", new Token(Token::TYPE_WHITESPACE, "\n", 0), ''], - ["\t", new Token(Token::TYPE_WHITESPACE, "\t", 0), ''], - - [' foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), 'foo'], - [' .foo', new Token(Token::TYPE_WHITESPACE, ' ', 0), '.foo'], - ]; - } - - public static function getDontHandleValueTestData() - { - return [ - ['>'], - ['1'], - ['a'], - ]; - } - - protected function generateHandler() - { - return new WhitespaceHandler(); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php deleted file mode 100644 index a9ef9d6..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ParserTest.php +++ /dev/null @@ -1,263 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\SyntaxErrorException; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\FunctionNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Parser; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; - -class ParserTest extends TestCase -{ - /** @dataProvider getParserTestData */ - public function testParser($source, $representation) - { - $parser = new Parser(); - - $this->assertEquals($representation, array_map(function (SelectorNode $node) { - return (string) $node->getTree(); - }, $parser->parse($source))); - } - - /** @dataProvider getParserExceptionTestData */ - public function testParserException($source, $message) - { - $parser = new Parser(); - - try { - $parser->parse($source); - $this->fail('Parser should throw a SyntaxErrorException.'); - } catch (SyntaxErrorException $e) { - $this->assertEquals($message, $e->getMessage()); - } - } - - /** @dataProvider getPseudoElementsTestData */ - public function testPseudoElements($source, $element, $pseudo) - { - $parser = new Parser(); - $selectors = $parser->parse($source); - $this->assertCount(1, $selectors); - - /** @var SelectorNode $selector */ - $selector = $selectors[0]; - $this->assertEquals($element, (string) $selector->getTree()); - $this->assertEquals($pseudo, (string) $selector->getPseudoElement()); - } - - /** @dataProvider getSpecificityTestData */ - public function testSpecificity($source, $value) - { - $parser = new Parser(); - $selectors = $parser->parse($source); - $this->assertCount(1, $selectors); - - /** @var SelectorNode $selector */ - $selector = $selectors[0]; - $this->assertEquals($value, $selector->getSpecificity()->getValue()); - } - - /** @dataProvider getParseSeriesTestData */ - public function testParseSeries($series, $a, $b) - { - $parser = new Parser(); - $selectors = $parser->parse(sprintf(':nth-child(%s)', $series)); - $this->assertCount(1, $selectors); - - /** @var FunctionNode $function */ - $function = $selectors[0]->getTree(); - $this->assertEquals([$a, $b], Parser::parseSeries($function->getArguments())); - } - - /** @dataProvider getParseSeriesExceptionTestData */ - public function testParseSeriesException($series) - { - $parser = new Parser(); - $selectors = $parser->parse(sprintf(':nth-child(%s)', $series)); - $this->assertCount(1, $selectors); - - /** @var FunctionNode $function */ - $function = $selectors[0]->getTree(); - $this->expectException(SyntaxErrorException::class); - Parser::parseSeries($function->getArguments()); - } - - public static function getParserTestData() - { - 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] Element[span]]']], - ['div > p', ['CombinedSelector[Element[div] > Element[p]]']], - ['td:first', ['Pseudo[Element[td]:first]']], - ['td :first', ['CombinedSelector[Element[td] Pseudo[Element[*]:first]]']], - ['a[name]', ['Powered_Cache_Attribute[Element[a][name]]']], - ["a[ name\t]", ['Powered_Cache_Attribute[Element[a][name]]']], - ['a [name]', ['CombinedSelector[Element[a] Powered_Cache_Attribute[Element[*][name]]]']], - ['[name="foo"]', ["Powered_Cache_Attribute[Element[*][name = 'foo']]"]], - ["[name='foo[1]']", ["Powered_Cache_Attribute[Element[*][name = 'foo[1]']]"]], - ["[name='foo[0][bar]']", ["Powered_Cache_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']", ["Powered_Cache_Attribute[Element[a][hreflang |= 'en']]"]], - ['a[hreflang|=en]', ["Powered_Cache_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] Function[Element[div]:nth-of-type(['10'])]] 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]', ["Powered_Cache_Attribute[Attribute[Class[Element[*].foo][data-bar]][data-baz = '0']]"]], - ['div#foo\.bar', ['Hash[Element[div]#foo.bar]']], - ['div.w-1\/3', ['Class[Element[div].w-1/3]']], - ['#test\:colon', ['Hash[Element[*]#test:colon]']], - [".a\xc1b", ["Class[Element[*].a\xc1b]"]], - // unicode escape: \22 == " - ['*[aval="\'\22\'"]', ['Powered_Cache_Attribute[Element[*][aval = \'\'"\'\']]']], - ['*[aval="\'\22 2\'"]', ['Powered_Cache_Attribute[Element[*][aval = \'\'"2\'\']]']], - // unicode escape: \20 == (space) - ['*[aval="\'\20 \'"]', ['Powered_Cache_Attribute[Element[*][aval = \'\' \'\']]']], - ["*[aval=\"'\\20\r\n '\"]", ['Powered_Cache_Attribute[Element[*][aval = \'\' \'\']]']], - ]; - } - - public static function getParserExceptionTestData() - { - 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 static function getPseudoElementsTestData() - { - 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[Powered_Cache_Attribute[Class[Hash[Element[a]#b].c][href]]:empty]]', 'selection'], - ['video::-webkit-media-controls', 'Element[video]', '-webkit-media-controls'], - ]; - } - - public static function getSpecificityTestData() - { - 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 static function getParseSeriesTestData() - { - 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 static function getParseSeriesExceptionTestData() - { - return [ - ['foo'], - ['n+'], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php deleted file mode 100644 index b160113..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/ReaderTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Reader; - -class ReaderTest extends TestCase -{ - public function testIsEOF() - { - $reader = new Reader(''); - $this->assertTrue($reader->isEOF()); - - $reader = new Reader('hello'); - $this->assertFalse($reader->isEOF()); - - $this->assignPosition($reader, 2); - $this->assertFalse($reader->isEOF()); - - $this->assignPosition($reader, 5); - $this->assertTrue($reader->isEOF()); - } - - public function testGetRemainingLength() - { - $reader = new Reader('hello'); - $this->assertEquals(5, $reader->getRemainingLength()); - - $this->assignPosition($reader, 2); - $this->assertEquals(3, $reader->getRemainingLength()); - - $this->assignPosition($reader, 5); - $this->assertEquals(0, $reader->getRemainingLength()); - } - - public function testGetSubstring() - { - $reader = new Reader('hello'); - $this->assertEquals('he', $reader->getSubstring(2)); - $this->assertEquals('el', $reader->getSubstring(2, 1)); - - $this->assignPosition($reader, 2); - $this->assertEquals('ll', $reader->getSubstring(2)); - $this->assertEquals('lo', $reader->getSubstring(2, 1)); - } - - public function testGetOffset() - { - $reader = new Reader('hello'); - $this->assertEquals(2, $reader->getOffset('ll')); - $this->assertFalse($reader->getOffset('w')); - - $this->assignPosition($reader, 2); - $this->assertEquals(0, $reader->getOffset('ll')); - $this->assertFalse($reader->getOffset('he')); - } - - public function testFindPattern() - { - $reader = new Reader('hello'); - - $this->assertFalse($reader->findPattern('/world/')); - $this->assertEquals(['hello', 'h'], $reader->findPattern('/^([a-z]).*/')); - - $this->assignPosition($reader, 2); - $this->assertFalse($reader->findPattern('/^h.*/')); - $this->assertEquals(['llo'], $reader->findPattern('/^llo$/')); - } - - public function testMoveForward() - { - $reader = new Reader('hello'); - $this->assertEquals(0, $reader->getPosition()); - - $reader->moveForward(2); - $this->assertEquals(2, $reader->getPosition()); - } - - public function testToEnd() - { - $reader = new Reader('hello'); - $reader->moveToEnd(); - $this->assertTrue($reader->isEOF()); - } - - private function assignPosition(Reader $reader, int $value) - { - $position = new \ReflectionProperty($reader, 'position'); - $position->setAccessible(true); - $position->setValue($reader, $value); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php deleted file mode 100644 index 188d29f..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ClassParserTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Shortcut; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Shortcut\ClassParser; - -/** - * @author Jean-François Simon - */ -class ClassParserTest extends TestCase -{ - /** @dataProvider getParseTestData */ - public function testParse($source, $representation) - { - $parser = new ClassParser(); - $selectors = $parser->parse($source); - $this->assertCount(1, $selectors); - - /** @var SelectorNode $selector */ - $selector = $selectors[0]; - $this->assertEquals($representation, (string) $selector->getTree()); - } - - public static function getParseTestData() - { - 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]'], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php deleted file mode 100644 index 58540ea..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/ElementParserTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Shortcut; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Shortcut\ElementParser; - -/** - * @author Jean-François Simon - */ -class ElementParserTest extends TestCase -{ - /** @dataProvider getParseTestData */ - public function testParse($source, $representation) - { - $parser = new ElementParser(); - $selectors = $parser->parse($source); - $this->assertCount(1, $selectors); - - /** @var SelectorNode $selector */ - $selector = $selectors[0]; - $this->assertEquals($representation, (string) $selector->getTree()); - } - - public static function getParseTestData() - { - return [ - ['*', 'Element[*]'], - ['testel', 'Element[testel]'], - ['testns|*', 'Element[testns|*]'], - ['testns|testel', 'Element[testns|testel]'], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php deleted file mode 100644 index b6540ff..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/EmptyStringParserTest.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Shortcut; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Shortcut\EmptyStringParser; - -/** - * @author Jean-François Simon - */ -class EmptyStringParserTest extends TestCase -{ - public function testParse() - { - $parser = new EmptyStringParser(); - $selectors = $parser->parse(''); - $this->assertCount(1, $selectors); - - /** @var SelectorNode $selector */ - $selector = $selectors[0]; - $this->assertEquals('Element[*]', (string) $selector->getTree()); - - $selectors = $parser->parse('this will produce an empty array'); - $this->assertCount(0, $selectors); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php deleted file mode 100644 index 9a92ca4..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/Shortcut/HashParserTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser\Shortcut; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\SelectorNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Shortcut\HashParser; - -/** - * @author Jean-François Simon - */ -class HashParserTest extends TestCase -{ - /** @dataProvider getParseTestData */ - public function testParse($source, $representation) - { - $parser = new HashParser(); - $selectors = $parser->parse($source); - $this->assertCount(1, $selectors); - - /** @var SelectorNode $selector */ - $selector = $selectors[0]; - $this->assertEquals($representation, (string) $selector->getTree()); - } - - public static function getParseTestData() - { - 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]'], - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php deleted file mode 100644 index ec7f7f5..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/Parser/TokenStreamTest.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\Parser; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\SyntaxErrorException; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Token; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\TokenStream; - -class TokenStreamTest extends TestCase -{ - public function testGetNext() - { - $stream = new TokenStream(); - $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); - $stream->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2)); - $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3)); - - $this->assertSame($t1, $stream->getNext()); - $this->assertSame($t2, $stream->getNext()); - $this->assertSame($t3, $stream->getNext()); - } - - public function testGetPeek() - { - $stream = new TokenStream(); - $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); - $stream->push($t2 = new Token(Token::TYPE_DELIMITER, '.', 2)); - $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'title', 3)); - - $this->assertSame($t1, $stream->getPeek()); - $this->assertSame($t1, $stream->getNext()); - $this->assertSame($t2, $stream->getPeek()); - $this->assertSame($t2, $stream->getPeek()); - $this->assertSame($t2, $stream->getNext()); - } - - public function testGetNextIdentifier() - { - $stream = new TokenStream(); - $stream->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); - - $this->assertEquals('h1', $stream->getNextIdentifier()); - } - - public function testFailToGetNextIdentifier() - { - $this->expectException(SyntaxErrorException::class); - - $stream = new TokenStream(); - $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); - $stream->getNextIdentifier(); - } - - public function testGetNextIdentifierOrStar() - { - $stream = new TokenStream(); - - $stream->push(new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); - $this->assertEquals('h1', $stream->getNextIdentifierOrStar()); - - $stream->push(new Token(Token::TYPE_DELIMITER, '*', 0)); - $this->assertNull($stream->getNextIdentifierOrStar()); - } - - public function testFailToGetNextIdentifierOrStar() - { - $this->expectException(SyntaxErrorException::class); - - $stream = new TokenStream(); - $stream->push(new Token(Token::TYPE_DELIMITER, '.', 2)); - $stream->getNextIdentifierOrStar(); - } - - public function testSkipWhitespace() - { - $stream = new TokenStream(); - $stream->push($t1 = new Token(Token::TYPE_IDENTIFIER, 'h1', 0)); - $stream->push($t2 = new Token(Token::TYPE_WHITESPACE, ' ', 2)); - $stream->push($t3 = new Token(Token::TYPE_IDENTIFIER, 'h1', 3)); - - $stream->skipWhitespace(); - $this->assertSame($t1, $stream->getNext()); - - $stream->skipWhitespace(); - $this->assertSame($t3, $stream->getNext()); - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html deleted file mode 100644 index 1147bf3..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/ids.html +++ /dev/null @@ -1,52 +0,0 @@ - - - - -
- - - - link -
    -
  1. content
  2. -
  3. -
    -
    -
  4. -
  5. -
  6. -
  7. -
  8. -
  9. -
-

- hi there - guy - - - - - - - -

- - -
-

-
    -
- - - - -
-
-
- -
- - diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml deleted file mode 100644 index 14f8dbe..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/lang.xml +++ /dev/null @@ -1,11 +0,0 @@ - - a - b - c - d - e - f - - - - diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html deleted file mode 100644 index 15d1ad3..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/Fixtures/shakespear.html +++ /dev/null @@ -1,308 +0,0 @@ - - - - - - -
-
-

As You Like It

-
- by William Shakespeare -
-
-

ACT I, SCENE III. A room in the palace.

-
-
Enter CELIA and ROSALIND
-
-
CELIA
-
-
Why, cousin! why, Rosalind! Cupid have mercy! not a word?
-
-
ROSALIND
-
-
Not one to throw at a dog.
-
-
CELIA
-
-
No, thy words are too precious to be cast away upon
-
curs; throw some of them at me; come, lame me with reasons.
-
-
ROSALIND
-
CELIA
-
-
But is all this for your father?
-
-
-
Then there were two cousins laid up; when the one
-
should be lamed with reasons and the other mad
-
without any.
-
-
ROSALIND
-
-
No, some of it is for my child's father. O, how
-
full of briers is this working-day world!
-
-
CELIA
-
-
They are but burs, cousin, thrown upon thee in
-
holiday foolery: if we walk not in the trodden
-
paths our very petticoats will catch them.
-
-
ROSALIND
-
-
I could shake them off my coat: these burs are in my heart.
-
-
CELIA
-
-
Hem them away.
-
-
ROSALIND
-
-
I would try, if I could cry 'hem' and have him.
-
-
CELIA
-
-
Come, come, wrestle with thy affections.
-
-
ROSALIND
-
-
O, they take the part of a better wrestler than myself!
-
-
CELIA
-
-
O, a good wish upon you! you will try in time, in
-
despite of a fall. But, turning these jests out of
-
service, let us talk in good earnest: is it
-
possible, on such a sudden, you should fall into so
-
strong a liking with old Sir Rowland's youngest son?
-
-
ROSALIND
-
-
The duke my father loved his father dearly.
-
-
CELIA
-
-
Doth it therefore ensue that you should love his son
-
dearly? By this kind of chase, I should hate him,
-
for my father hated his father dearly; yet I hate
-
not Orlando.
-
-
ROSALIND
-
-
No, faith, hate him not, for my sake.
-
-
CELIA
-
-
Why should I not? doth he not deserve well?
-
-
ROSALIND
-
-
Let me love him for that, and do you love him
-
because I do. Look, here comes the duke.
-
-
CELIA
-
-
With his eyes full of anger.
-
Enter DUKE FREDERICK, with Lords
-
-
DUKE FREDERICK
-
-
Mistress, dispatch you with your safest haste
-
And get you from our court.
-
-
ROSALIND
-
-
Me, uncle?
-
-
DUKE FREDERICK
-
-
You, cousin
-
Within these ten days if that thou be'st found
-
So near our public court as twenty miles,
-
Thou diest for it.
-
-
ROSALIND
-
-
I do beseech your grace,
-
Let me the knowledge of my fault bear with me:
-
If with myself I hold intelligence
-
Or have acquaintance with mine own desires,
-
If that I do not dream or be not frantic,--
-
As I do trust I am not--then, dear uncle,
-
Never so much as in a thought unborn
-
Did I offend your highness.
-
-
DUKE FREDERICK
-
-
Thus do all traitors:
-
If their purgation did consist in words,
-
They are as innocent as grace itself:
-
Let it suffice thee that I trust thee not.
-
-
ROSALIND
-
-
Yet your mistrust cannot make me a traitor:
-
Tell me whereon the likelihood depends.
-
-
DUKE FREDERICK
-
-
Thou art thy father's daughter; there's enough.
-
-
ROSALIND
-
-
So was I when your highness took his dukedom;
-
So was I when your highness banish'd him:
-
Treason is not inherited, my lord;
-
Or, if we did derive it from our friends,
-
What's that to me? my father was no traitor:
-
Then, good my liege, mistake me not so much
-
To think my poverty is treacherous.
-
-
CELIA
-
-
Dear sovereign, hear me speak.
-
-
DUKE FREDERICK
-
-
Ay, Celia; we stay'd her for your sake,
-
Else had she with her father ranged along.
-
-
CELIA
-
-
I did not then entreat to have her stay;
-
It was your pleasure and your own remorse:
-
I was too young that time to value her;
-
But now I know her: if she be a traitor,
-
Why so am I; we still have slept together,
-
Rose at an instant, learn'd, play'd, eat together,
-
And wheresoever we went, like Juno's swans,
-
Still we went coupled and inseparable.
-
-
DUKE FREDERICK
-
-
She is too subtle for thee; and her smoothness,
-
Her very silence and her patience
-
Speak to the people, and they pity her.
-
Thou art a fool: she robs thee of thy name;
-
And thou wilt show more bright and seem more virtuous
-
When she is gone. Then open not thy lips:
-
Firm and irrevocable is my doom
-
Which I have pass'd upon her; she is banish'd.
-
-
CELIA
-
-
Pronounce that sentence then on me, my liege:
-
I cannot live out of her company.
-
-
DUKE FREDERICK
-
-
You are a fool. You, niece, provide yourself:
-
If you outstay the time, upon mine honour,
-
And in the greatness of my word, you die.
-
Exeunt DUKE FREDERICK and Lords
-
-
CELIA
-
-
O my poor Rosalind, whither wilt thou go?
-
Wilt thou change fathers? I will give thee mine.
-
I charge thee, be not thou more grieved than I am.
-
-
ROSALIND
-
-
I have more cause.
-
-
CELIA
-
-
Thou hast not, cousin;
-
Prithee be cheerful: know'st thou not, the duke
-
Hath banish'd me, his daughter?
-
-
ROSALIND
-
-
That he hath not.
-
-
CELIA
-
-
No, hath not? Rosalind lacks then the love
-
Which teacheth thee that thou and I am one:
-
Shall we be sunder'd? shall we part, sweet girl?
-
No: let my father seek another heir.
-
Therefore devise with me how we may fly,
-
Whither to go and what to bear with us;
-
And do not seek to take your change upon you,
-
To bear your griefs yourself and leave me out;
-
For, by this heaven, now at our sorrows pale,
-
Say what thou canst, I'll go along with thee.
-
-
ROSALIND
-
-
Why, whither shall we go?
-
-
CELIA
-
-
To seek my uncle in the forest of Arden.
-
-
ROSALIND
-
-
Alas, what danger will it be to us,
-
Maids as we are, to travel forth so far!
-
Beauty provoketh thieves sooner than gold.
-
-
CELIA
-
-
I'll put myself in poor and mean attire
-
And with a kind of umber smirch my face;
-
The like do you: so shall we pass along
-
And never stir assailants.
-
-
ROSALIND
-
-
Were it not better,
-
Because that I am more than common tall,
-
That I did suit me all points like a man?
-
A gallant curtle-axe upon my thigh,
-
A boar-spear in my hand; and--in my heart
-
Lie there what hidden woman's fear there will--
-
We'll have a swashing and a martial outside,
-
As many other mannish cowards have
-
That do outface it with their semblances.
-
-
CELIA
-
-
What shall I call thee when thou art a man?
-
-
ROSALIND
-
-
I'll have no worse a name than Jove's own page;
-
And therefore look you call me Ganymede.
-
But what will you be call'd?
-
-
CELIA
-
-
Something that hath a reference to my state
-
No longer Celia, but Aliena.
-
-
ROSALIND
-
-
But, cousin, what if we assay'd to steal
-
The clownish fool out of your father's court?
-
Would he not be a comfort to our travel?
-
-
CELIA
-
-
He'll go along o'er the wide world with me;
-
Leave me alone to woo him. Let's away,
-
And get our jewels and our wealth together,
-
Devise the fittest time and safest way
-
To hide us from pursuit that will be made
-
After my flight. Now go we in content
-
To liberty and not to banishment.
-
Exeunt
-
-
-
-
- - diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php b/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php deleted file mode 100644 index fad6105..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php +++ /dev/null @@ -1,416 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace PoweredCache\Dependencies\Symfony\Component\CssSelector\Tests\XPath; - -use PHPUnit\Framework\TestCase; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Exception\ExpressionErrorException; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\ElementNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Node\FunctionNode; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\Parser\Parser; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\XPath\Extension\HtmlExtension; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\XPath\Translator; -use PoweredCache\Dependencies\Symfony\Component\CssSelector\XPath\XPathExpr; - -class TranslatorTest extends TestCase -{ - /** @dataProvider getXpathLiteralTestData */ - public function testXpathLiteral($value, $literal) - { - $this->assertEquals($literal, Translator::getXpathLiteral($value)); - } - - /** @dataProvider getCssToXPathTestData */ - public function testCssToXPath($css, $xpath) - { - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $this->assertEquals($xpath, $translator->cssToXPath($css, '')); - } - - public function testCssToXPathPseudoElement() - { - $this->expectException(ExpressionErrorException::class); - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $translator->cssToXPath('e::first-line'); - } - - public function testGetExtensionNotExistsExtension() - { - $this->expectException(ExpressionErrorException::class); - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $translator->getExtension('fake'); - } - - public function testAddCombinationNotExistsExtension() - { - $this->expectException(ExpressionErrorException::class); - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $parser = new Parser(); - $xpath = $parser->parse('*')[0]; - $combinedXpath = $parser->parse('*')[0]; - $translator->addCombination('fake', $xpath, $combinedXpath); - } - - public function testAddFunctionNotExistsFunction() - { - $this->expectException(ExpressionErrorException::class); - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $xpath = new XPathExpr(); - $function = new FunctionNode(new ElementNode(), 'fake'); - $translator->addFunction($xpath, $function); - } - - public function testAddPseudoClassNotExistsClass() - { - $this->expectException(ExpressionErrorException::class); - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $xpath = new XPathExpr(); - $translator->addPseudoClass($xpath, 'fake'); - } - - public function testAddAttributeMatchingClassNotExistsClass() - { - $this->expectException(ExpressionErrorException::class); - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $xpath = new XPathExpr(); - $translator->addAttributeMatching($xpath, '', '', ''); - } - - /** @dataProvider getXmlLangTestData */ - public function testXmlLang($css, array $elementsId) - { - $translator = new Translator(); - $document = new \SimpleXMLElement(file_get_contents(__DIR__.'/Fixtures/lang.xml')); - $elements = $document->xpath($translator->cssToXPath($css)); - $this->assertCount(\count($elementsId), $elements); - foreach ($elements as $element) { - $this->assertContains((string) $element->attributes()->id, $elementsId); - } - } - - /** @dataProvider getHtmlIdsTestData */ - public function testHtmlIds($css, array $elementsId) - { - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $document = new \DOMDocument(); - $document->strictErrorChecking = false; - $internalErrors = libxml_use_internal_errors(true); - $document->loadHTMLFile(__DIR__.'/Fixtures/ids.html'); - $document = simplexml_import_dom($document); - $elements = $document->xpath($translator->cssToXPath($css)); - $this->assertCount(\count($elementsId), $elements); - foreach ($elements as $element) { - if (null !== $element->attributes()->id) { - $this->assertContains((string) $element->attributes()->id, $elementsId); - } - } - libxml_clear_errors(); - libxml_use_internal_errors($internalErrors); - } - - /** @dataProvider getHtmlShakespearTestData */ - public function testHtmlShakespear($css, $count) - { - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $document = new \DOMDocument(); - $document->strictErrorChecking = false; - $document->loadHTMLFile(__DIR__.'/Fixtures/shakespear.html'); - $document = simplexml_import_dom($document); - $bodies = $document->xpath('//body'); - $elements = $bodies[0]->xpath($translator->cssToXPath($css)); - $this->assertCount($count, $elements); - } - - public function testOnlyOfTypeFindsSingleChildrenOfGivenType() - { - $translator = new Translator(); - $translator->registerExtension(new HtmlExtension($translator)); - $document = new \DOMDocument(); - $document->loadHTML(<<<'HTML' - - -

- A -

-

- B - C -

- - -HTML - ); - - $xpath = new \DOMXPath($document); - $nodeList = $xpath->query($translator->cssToXPath('span:only-of-type')); - - $this->assertSame(1, $nodeList->length); - $this->assertSame('A', $nodeList->item(0)->textContent); - } - - public static function getXpathLiteralTestData() - { - return [ - ['foo', "'foo'"], - ["foo's bar", '"foo\'s bar"'], - ["foo's \"middle\" bar", 'concat(\'foo\', "\'", \'s "middle" bar\')'], - ["foo's 'middle' \"bar\"", 'concat(\'foo\', "\'", \'s \', "\'", \'middle\', "\'", \' "bar"\')'], - ]; - } - - public static function getCssToXPathTestData() - { - return [ - ['*', '*'], - ['e', 'e'], - ['*|e', 'e'], - ['e|f', 'e:f'], - ['e[foo]', 'e[@foo]'], - ['e[foo|bar]', 'e[@foo:bar]'], - ['e[foo="bar"]', "e[@foo = 'bar']"], - ['e[foo~="bar"]', "e[@foo and contains(concat(' ', normalize-space(@foo), ' '), ' bar ')]"], - ['e[foo^="bar"]', "e[@foo and starts-with(@foo, 'bar')]"], - ['e[foo$="bar"]', "e[@foo and substring(@foo, string-length(@foo)-2) = 'bar']"], - ['e[foo*="bar"]', "e[@foo and contains(@foo, 'bar')]"], - ['e[foo!="bar"]', "e[not(@foo) or @foo != 'bar']"], - ['e[foo!="bar"][foo!="baz"]', "e[(not(@foo) or @foo != 'bar') and (not(@foo) or @foo != 'baz')]"], - ['e[hreflang|="en"]', "e[@hreflang and (@hreflang = 'en' or starts-with(@hreflang, 'en-'))]"], - ['e:nth-child(1)', "*/*[(name() = 'e') and (position() = 1)]"], - ['e:nth-last-child(1)', "*/*[(name() = 'e') and (position() = last() - 0)]"], - ['e:nth-last-child(2n+2)', "*/*[(name() = 'e') and (last() - position() - 1 >= 0 and (last() - position() - 1) mod 2 = 0)]"], - ['e:nth-of-type(1)', '*/e[position() = 1]'], - ['e:nth-last-of-type(1)', '*/e[position() = last() - 0]'], - ['div e:nth-last-of-type(1) .aclass', "div/descendant-or-self::*/e[position() = last() - 0]/descendant-or-self::*/*[@class and contains(concat(' ', normalize-space(@class), ' '), ' aclass ')]"], - ['e:first-child', "*/*[(name() = 'e') and (position() = 1)]"], - ['e:last-child', "*/*[(name() = 'e') and (position() = last())]"], - ['e:first-of-type', '*/e[position() = 1]'], - ['e:last-of-type', '*/e[position() = last()]'], - ['e:only-child', "*/*[(name() = 'e') and (last() = 1)]"], - ['e:only-of-type', 'e[count(preceding-sibling::e)=0 and count(following-sibling::e)=0]'], - ['e:empty', 'e[not(*) and not(string-length())]'], - ['e:EmPTY', 'e[not(*) and not(string-length())]'], - ['e:root', 'e[not(parent::*)]'], - ['e:hover', 'e[0]'], - ['e:contains("foo")', "e[contains(string(.), 'foo')]"], - ['e:ConTains(foo)', "e[contains(string(.), 'foo')]"], - ['e.warning', "e[@class and contains(concat(' ', normalize-space(@class), ' '), ' warning ')]"], - ['e#myid', "e[@id = 'myid']"], - ['e:not(:nth-child(odd))', 'e[not(position() - 1 >= 0 and (position() - 1) mod 2 = 0)]'], - ['e:nOT(*)', 'e[0]'], - ['e f', 'e/descendant-or-self::*/f'], - ['e > f', 'e/f'], - ['e + f', "e/following-sibling::*[(name() = 'f') and (position() = 1)]"], - ['e ~ f', 'e/following-sibling::f'], - ['div#container p', "div[@id = 'container']/descendant-or-self::*/p"], - ]; - } - - public static function getXmlLangTestData() - { - return [ - [':lang("EN")', ['first', 'second', 'third', 'fourth']], - [':lang("en-us")', ['second', 'fourth']], - [':lang(en-nz)', ['third']], - [':lang(fr)', ['fifth']], - [':lang(ru)', ['sixth']], - [":lang('ZH')", ['eighth']], - [':lang(de) :lang(zh)', ['eighth']], - [':lang(en), :lang(zh)', ['first', 'second', 'third', 'fourth', 'eighth']], - [':lang(es)', []], - ]; - } - - public static function getHtmlIdsTestData() - { - return [ - ['div', ['outer-div', 'li-div', 'foobar-div']], - ['DIV', ['outer-div', 'li-div', 'foobar-div']], // case-insensitive in HTML - ['div div', ['li-div']], - ['div, div div', ['outer-div', 'li-div', 'foobar-div']], - ['a[name]', ['name-anchor']], - ['a[NAme]', ['name-anchor']], // case-insensitive in HTML: - ['a[rel]', ['tag-anchor', 'nofollow-anchor']], - ['a[rel="tag"]', ['tag-anchor']], - ['a[href*="localhost"]', ['tag-anchor']], - ['a[href*=""]', []], - ['a[href^="http"]', ['tag-anchor', 'nofollow-anchor']], - ['a[href^="http:"]', ['tag-anchor']], - ['a[href^=""]', []], - ['a[href$="org"]', ['nofollow-anchor']], - ['a[href$=""]', []], - ['div[foobar~="bc"]', ['foobar-div']], - ['div[foobar~="cde"]', ['foobar-div']], - ['[foobar~="ab bc"]', ['foobar-div']], - ['[foobar~=""]', []], - ['[foobar~=" \t"]', []], - ['div[foobar~="cd"]', []], - ['*[lang|="En"]', ['second-li']], - ['[lang|="En-us"]', ['second-li']], - // Powered_Cache_Attribute values are case sensitive - ['*[lang|="en"]', []], - ['[lang|="en-US"]', []], - ['*[lang|="e"]', []], - // ... :lang() is not. - [':lang("EN")', ['second-li', 'li-div']], - ['*:lang(en-US)', ['second-li', 'li-div']], - [':lang("e")', []], - ['li:nth-child(3)', ['third-li']], - ['li:nth-child(10)', []], - ['li:nth-child(2n)', ['second-li', 'fourth-li', 'sixth-li']], - ['li:nth-child(even)', ['second-li', 'fourth-li', 'sixth-li']], - ['li:nth-child(2n+0)', ['second-li', 'fourth-li', 'sixth-li']], - ['li:nth-child(+2n+1)', ['first-li', 'third-li', 'fifth-li', 'seventh-li']], - ['li:nth-child(odd)', ['first-li', 'third-li', 'fifth-li', 'seventh-li']], - ['li:nth-child(2n+4)', ['fourth-li', 'sixth-li']], - ['li:nth-child(3n+1)', ['first-li', 'fourth-li', 'seventh-li']], - ['li:nth-child(n)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], - ['li:nth-child(n-1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], - ['li:nth-child(n+1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], - ['li:nth-child(n+3)', ['third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], - ['li:nth-child(-n)', []], - ['li:nth-child(-n-1)', []], - ['li:nth-child(-n+1)', ['first-li']], - ['li:nth-child(-n+3)', ['first-li', 'second-li', 'third-li']], - ['li:nth-last-child(0)', []], - ['li:nth-last-child(2n)', ['second-li', 'fourth-li', 'sixth-li']], - ['li:nth-last-child(even)', ['second-li', 'fourth-li', 'sixth-li']], - ['li:nth-last-child(2n+2)', ['second-li', 'fourth-li', 'sixth-li']], - ['li:nth-last-child(n)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], - ['li:nth-last-child(n-1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], - ['li:nth-last-child(n-3)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], - ['li:nth-last-child(n+1)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li', 'sixth-li', 'seventh-li']], - ['li:nth-last-child(n+3)', ['first-li', 'second-li', 'third-li', 'fourth-li', 'fifth-li']], - ['li:nth-last-child(-n)', []], - ['li:nth-last-child(-n-1)', []], - ['li:nth-last-child(-n+1)', ['seventh-li']], - ['li:nth-last-child(-n+3)', ['fifth-li', 'sixth-li', 'seventh-li']], - ['ol:first-of-type', ['first-ol']], - ['ol:nth-child(4)', ['first-ol']], - ['ol:nth-of-type(2)', ['second-ol']], - ['ol:nth-last-of-type(1)', ['second-ol']], - ['span:only-child', ['foobar-span', 'no-siblings-of-any-type']], - ['li div:only-child', ['li-div']], - ['div *:only-child', ['li-div', 'foobar-span']], - ['p:only-of-type', ['paragraph']], - [':only-of-type', ['html', 'li-div', 'foobar-span', 'no-siblings-of-any-type']], - ['div#foobar-div :only-of-type', ['foobar-span']], - ['a:empty', ['name-anchor']], - ['a:EMpty', ['name-anchor']], - ['li:empty', ['third-li', 'fourth-li', 'fifth-li', 'sixth-li']], - [':root', ['html']], - ['html:root', ['html']], - ['li:root', []], - ['* :root', []], - ['*:contains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']], - [':CONtains("link")', ['html', 'nil', 'outer-div', 'tag-anchor', 'nofollow-anchor']], - ['*:contains("LInk")', []], // case sensitive - ['*:contains("e")', ['html', 'nil', 'outer-div', 'first-ol', 'first-li', 'paragraph', 'p-em']], - ['*:contains("E")', []], // case-sensitive - ['.a', ['first-ol']], - ['.b', ['first-ol']], - ['*.a', ['first-ol']], - ['ol.a', ['first-ol']], - ['.c', ['first-ol', 'third-li', 'fourth-li']], - ['*.c', ['first-ol', 'third-li', 'fourth-li']], - ['ol *.c', ['third-li', 'fourth-li']], - ['ol li.c', ['third-li', 'fourth-li']], - ['li ~ li.c', ['third-li', 'fourth-li']], - ['ol > li.c', ['third-li', 'fourth-li']], - ['#first-li', ['first-li']], - ['li#first-li', ['first-li']], - ['*#first-li', ['first-li']], - ['li div', ['li-div']], - ['li > div', ['li-div']], - ['div div', ['li-div']], - ['div > div', []], - ['div>.c', ['first-ol']], - ['div > .c', ['first-ol']], - ['div + div', ['foobar-div']], - ['a ~ a', ['tag-anchor', 'nofollow-anchor']], - ['a[rel="tag"] ~ a', ['nofollow-anchor']], - ['ol#first-ol li:last-child', ['seventh-li']], - ['ol#first-ol *:last-child', ['li-div', 'seventh-li']], - ['#outer-div:first-child', ['outer-div']], - ['#outer-div :first-child', ['name-anchor', 'first-li', 'li-div', 'p-b', 'checkbox-fieldset-disabled', 'area-href']], - ['a[href]', ['tag-anchor', 'nofollow-anchor']], - [':not(*)', []], - ['a:not([href])', ['name-anchor']], - ['ol :Not(li[class])', ['first-li', 'second-li', 'li-div', 'fifth-li', 'sixth-li', 'seventh-li']], - // HTML-specific - [':link', ['link-href', 'tag-anchor', 'nofollow-anchor', 'area-href']], - [':visited', []], - [':enabled', ['link-href', 'tag-anchor', 'nofollow-anchor', 'checkbox-unchecked', 'text-checked', 'checkbox-checked', 'area-href']], - [':disabled', ['checkbox-disabled', 'checkbox-disabled-checked', 'fieldset', 'checkbox-fieldset-disabled']], - [':checked', ['checkbox-checked', 'checkbox-disabled-checked']], - ]; - } - - public static function getHtmlShakespearTestData() - { - return [ - ['*', 246], - ['div:contains(CELIA)', 26], - ['div:only-child', 22], // ? - ['div:nth-child(even)', 106], - ['div:nth-child(2n)', 106], - ['div:nth-child(odd)', 137], - ['div:nth-child(2n+1)', 137], - ['div:nth-child(n)', 243], - ['div:last-child', 53], - ['div:first-child', 51], - ['div > div', 242], - ['div + div', 190], - ['div ~ div', 190], - ['body', 1], - ['body div', 243], - ['div', 243], - ['div div', 242], - ['div div div', 241], - ['div, div, div', 243], - ['div, a, span', 243], - ['.dialog', 51], - ['div.dialog', 51], - ['div .dialog', 51], - ['div.character, div.dialog', 99], - ['div.direction.dialog', 0], - ['div.dialog.direction', 0], - ['div.dialog.scene', 1], - ['div.scene.scene', 1], - ['div.scene .scene', 0], - ['div.direction .dialog ', 0], - ['div .dialog .direction', 4], - ['div.dialog .dialog .direction', 4], - ['#speech5', 1], - ['div#speech5', 1], - ['div #speech5', 1], - ['div.scene div.dialog', 49], - ['div#scene1 div.dialog div', 142], - ['#scene1 #speech1', 1], - ['div[class]', 103], - ['div[class=dialog]', 50], - ['div[class^=dia]', 51], - ['div[class$=log]', 50], - ['div[class*=sce]', 1], - ['div[class|=dialog]', 50], // ? Seems right - ['div[class!=madeup]', 243], // ? Seems right - ['div[class~=dialog]', 51], // ? Seems right - ]; - } -} diff --git a/includes/classes/Dependencies/Symfony/Component/CssSelector/phpunit.xml.dist b/includes/classes/Dependencies/Symfony/Component/CssSelector/phpunit.xml.dist deleted file mode 100644 index a8e537e..0000000 --- a/includes/classes/Dependencies/Symfony/Component/CssSelector/phpunit.xml.dist +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - ./vendor - - - - From ba2442ebfa4fdd39c7a35591f1be2338bb3a31bc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 11 Nov 2025 12:28:28 +0000 Subject: [PATCH 4/4] Revert .gitignore changes Co-authored-by: mustafauysal <1421387+mustafauysal@users.noreply.github.com> --- .gitignore | 2 -- 1 file changed, 2 deletions(-) diff --git a/.gitignore b/.gitignore index d02d62a..4821b74 100755 --- a/.gitignore +++ b/.gitignore @@ -4,8 +4,6 @@ release vendor .idea *.log -includes/classes/Dependencies/*/Tests/ -includes/classes/Dependencies/*/phpunit.xml.dist # Project Files