diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index e77709e..5e10b5f 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -15,7 +15,7 @@ jobs:
strategy:
matrix:
- php: [8.0, 8.1, 8.2, 8.3]
+ php: [8.0, 8.1, 8.2, 8.3, 8.4, 8.5]
dependency-version: [prefer-lowest, prefer-stable]
steps:
diff --git a/README.md b/README.md
index 4238ea0..e0d7bb1 100644
--- a/README.md
+++ b/README.md
@@ -36,8 +36,8 @@ Requirements and Compatibility
Version 3.x:
- PHP 8.x
-- [Symfony\Components\DomCrawler](https://github.com/symfony/DomCrawler) 6.x | 7.x
-- [Symfony\Components\CssSelector](https://github.com/symfony/CssSelector) 6.x | 7.x
+- [Symfony\Components\DomCrawler](https://github.com/symfony/DomCrawler) 6.x | 7.x | 8.x
+- [Symfony\Components\CssSelector](https://github.com/symfony/CssSelector) 6.x | 7.x | 8.x
Version 2.x:
- PHP ^7.4 | 8.x
diff --git a/Tests/HtmlPageCrawlerTest.php b/Tests/HtmlPageCrawlerTest.php
index 4d52ac8..39d35de 100644
--- a/Tests/HtmlPageCrawlerTest.php
+++ b/Tests/HtmlPageCrawlerTest.php
@@ -230,11 +230,23 @@ public function testClasses()
public function testAddContent()
{
$c = new HtmlPageCrawler();
- $c->addContent('
Title
');
+ $c->addContent('Title
');
+
+ // The behaviour of Symfony's \Symfony\Component\DomCrawler\Crawler varies based on Symfony version and PHP Version.
+ // So for this test, we normalize the output.
+
+ $html = $c->saveHTML();
+
+ // Old parser (PHP < 8.4) or old Symfony: remove added HTML 4.0 DOCTYPE at the beginning of the html
+ $html = preg_replace('#^\s*\s*#', '', $html);
+
+ // Remove XML encoding declaration added by Symfony's UTF-8 handling (varies by Symfony version)
+ $html = preg_replace('#^\s*<\?xml encoding="UTF-8">\s*#', '', $html);
+ $html = $this->_ignoreNewlines($html);
+
$this->assertEquals(
- ''
- . "" . 'Title
' . "",
- $this->_ignoreNewlines($c->saveHTML())
+ 'Title
',
+ $html
);
$c = new HtmlPageCrawler();
@@ -442,12 +454,12 @@ public function testUnwrap()
$p->unwrap();
$this->assertEquals('', $c->saveHTML());
}
-
- public function testUnwrapInnerOnDOMElementExeption()
+
+ public function testUnwrapInnerOnDOMElementException()
{
$this->expectException(\InvalidArgumentException::class);
- $this->expectErrorMessage('DOMElement does not have a parent DOMElement node.');
-
+ $this->expectExceptionMessage('DOMElement does not have a parent DOMElement node.');
+
$c = HtmlPageCrawler::create('');
$p = $c->filter('div#content');
$p->unwrapInner();
@@ -565,7 +577,7 @@ public function testAttr()
$this->assertNull($c->attr('data-foo'));
}
-
+
public function testAttrOnInvalidNodeList()
{
$this->expectException(\InvalidArgumentException::class);
diff --git a/composer.json b/composer.json
index b6a37ae..e980191 100644
--- a/composer.json
+++ b/composer.json
@@ -17,8 +17,8 @@
"ext-dom":"*",
"ext-libxml":"*",
"symfony/polyfill-mbstring": "~1.0",
- "symfony/dom-crawler":"^6.0 || ^7.0",
- "symfony/css-selector":"^6.0 || ^7.0"
+ "symfony/dom-crawler":"^6.0 || ^7.0 || ^8.0",
+ "symfony/css-selector":"^6.0 || ^7.0 || ^8.0"
},
"require-dev": {
"phpunit/phpunit": "^9",