Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
}
],
"require": {
"php": "^7.2|8.0.*|8.1.*|8.2.*|8.3.*",
"php": ">= 8.1",
"ext-dom": "*",
"ext-xml": "*"
},
"require-dev": {
"phpunit/phpunit": "^8.5"
"phpunit/phpunit": "^10.5.58"
},
"autoload": {
"psr-4": {
Expand Down
29 changes: 13 additions & 16 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,25 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile=".phpunit.cache/test-results"
failOnDeprecation="true"
failOnPhpunitDeprecation="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnPhpunitDeprecations="true"
>
<source ignoreSuppressionOfDeprecations="true">
<include>
<directory>src</directory>
</include>
</source>

<testsuites>
<testsuite name="default">
<directory>tests/*</directory>
<directory>tests</directory>
</testsuite>
</testsuites>

<!-- Filter for code coverage -->
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src/</directory>
</whitelist>
</filter>
</phpunit>
36 changes: 18 additions & 18 deletions tests/Webfactory/Dom/Test/BaseParsingHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@
use Webfactory\Dom\Exception\EmptyXMLStringException;
use Webfactory\Dom\Exception\ParsingException;

class BaseParsingHelperTest extends ParsingHelperTest
class BaseParsingHelperTest extends ParsingHelperTestCase
{
protected function createParsingHelper()
protected function createParsingHelper(): BaseParsingHelper
{
return new BaseParsingHelper();
}

/**
* @test
*/
public function entireDocumentIsPreserved()
public function entireDocumentIsPreserved(): void
{
/* Ein gesamtes Dokument, mit default-Namespace und NS-Deklarationen in unterschiedlichen Scopes */
$entireDocument = <<<XML
Expand All @@ -46,7 +46,7 @@ public function entireDocumentIsPreserved()
/**
* @test
*/
public function parseFragment()
public function parseFragment(): void
{
// Unterschiedliche Fragmente mit verschiedenen NS-Deklarationen
$this->readDumpAssertFragment('<tag>Foo</tag>');
Expand All @@ -58,7 +58,7 @@ public function parseFragment()
/**
* @test
*/
public function defaultNamespaceOnInnerElementIsNotPrefixed()
public function defaultNamespaceOnInnerElementIsNotPrefixed(): void
{
$this->markTestSkipped(
'Pending bugs in PHP: https://bugs.php.net/bug.php?id=47530, https://bugs.php.net/bug.php?id=55294'
Expand Down Expand Up @@ -95,7 +95,7 @@ public function defaultNamespaceOnInnerElementIsNotPrefixed()
/**
* @test
*/
public function parseFragmentWithUnknownNamespaceDecl()
public function parseFragmentWithUnknownNamespaceDecl(): void
{
$this->expectException(ParsingException::class);
$this->readDumpAssertFragment('<foo:tag>xxx</foo:tag>');
Expand All @@ -104,7 +104,7 @@ public function parseFragmentWithUnknownNamespaceDecl()
/**
* @test
*/
public function parseDocumentWithUnknownNamespaceDecl()
public function parseDocumentWithUnknownNamespaceDecl(): void
{
$this->expectException(ParsingException::class);
$document = $this->parser->parseDocument('<root><foo:fail>failme</foo:fail></root>');
Expand All @@ -113,7 +113,7 @@ public function parseDocumentWithUnknownNamespaceDecl()
/**
* @test
*/
public function parseFragmentWithImplicitNamespaceDecl()
public function parseFragmentWithImplicitNamespaceDecl(): void
{
$this->parser->addImplicitNamespace('foo', 'urn:some-namespace-uri');
$this->readDumpAssertFragment('<foo:tag>xxx</foo:tag>');
Expand All @@ -122,7 +122,7 @@ public function parseFragmentWithImplicitNamespaceDecl()
/**
* @test
*/
public function parseFragmentImplicitNamespaceOnLoadIsAddedOnDump()
public function parseFragmentImplicitNamespaceOnLoadIsAddedOnDump(): void
{
$this->readDumpAssertFragment(
'<foo:tag>xxx</foo:tag>',
Expand Down Expand Up @@ -152,7 +152,7 @@ public function parseFragmentImplicitNamespaceOnLoadIsAddedOnDump()
/**
* @test
*/
public function parseFragmentWithImplicitNamespaceOnDump()
public function parseFragmentWithImplicitNamespaceOnDump(): void
{
// Wenn der Namespace schon deklariert ist, entfällt die erneute Angabe
$this->readDumpAssertFragment(
Expand All @@ -166,7 +166,7 @@ public function parseFragmentWithImplicitNamespaceOnDump()
/**
* @test
*/
public function implicitNamespaceDeclDoesNotInterfereWithFragment()
public function implicitNamespaceDeclDoesNotInterfereWithFragment(): void
{
$this->parser->addImplicitNamespace('foo', 'urn:some-namespace-uri');
$this->readDumpAssertFragment('<foo:tag xmlns:foo="urn:some-other-uri">xxx</foo:tag>');
Expand All @@ -175,7 +175,7 @@ public function implicitNamespaceDeclDoesNotInterfereWithFragment()
/**
* @test
*/
public function implicitNamespaceDeclOnDumpMismatchesFragment()
public function implicitNamespaceDeclOnDumpMismatchesFragment(): void
{
$this->readDumpAssertFragment(
'<foo:tag xmlns:foo="urn:some-namespace-uri">xxx</foo:tag>',
Expand All @@ -194,7 +194,7 @@ public function implicitNamespaceDeclOnDumpMismatchesFragment()
/**
* @test
*/
public function implicitNamespaceDeclDoesNotChangePrefix()
public function implicitNamespaceDeclDoesNotChangePrefix(): void
{
// Eine Deklaration über ein anderes Prefix ändert nichts - Prefixe werden nicht umgeschrieben
$this->readDumpAssertFragment(
Expand All @@ -207,7 +207,7 @@ public function implicitNamespaceDeclDoesNotChangePrefix()
/**
* @test
*/
public function partialDumpCarriesOverNamespaceDeclaration()
public function partialDumpCarriesOverNamespaceDeclaration(): void
{
$document = $this->parser->parseDocument('<root xmlns="urn:test"><foo>test</foo></root>');
$this->assertEquals(
Expand All @@ -219,7 +219,7 @@ public function partialDumpCarriesOverNamespaceDeclaration()
/**
* @test
*/
public function xPathExpressionAndNodeListDump()
public function xPathExpressionAndNodeListDump(): void
{
$this->parser->addImplicitNamespace('foo', 'urn:some-uri');
$f = $this->parser->parseFragment(
Expand All @@ -239,7 +239,7 @@ public function xPathExpressionAndNodeListDump()
/**
* @test
*/
public function parsingEmptyDocumentFails()
public function parsingEmptyDocumentFails(): void
{
$this->expectException(EmptyXMLStringException::class);
$this->parser->parseDocument('');
Expand All @@ -248,7 +248,7 @@ public function parsingEmptyDocumentFails()
/**
* @test
*/
public function parsingEmptyFragmentFails()
public function parsingEmptyFragmentFails(): void
{
$this->expectException(EmptyXMLStringException::class);
$this->parser->parseFragment('');
Expand All @@ -257,7 +257,7 @@ public function parsingEmptyFragmentFails()
/**
* @test
*/
public function invalidCharactersAreTolerated()
public function invalidCharactersAreTolerated(): void
{
$fragment = "<root>\x0b\t\n</root>";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@

namespace Webfactory\Dom\Test;

abstract class HTMLParsingHelperTest extends ParsingHelperTest
abstract class HTMLParsingHelperTestCase extends ParsingHelperTestCase
{
/**
* @test
*/
public function scriptWithCDataIsPreserved()
public function scriptWithCDataIsPreserved(): void
{
$this->readDumpAssertFragment('
<script type="text/javascript" xml:space="preserve">
Expand All @@ -27,15 +27,15 @@ public function scriptWithCDataIsPreserved()
/**
* @test
*/
public function esiTagIsPreserved()
public function esiTagIsPreserved(): void
{
$this->readDumpAssertFragment('<p>Test <esi:include foo="bar"/></p>');
}

/**
* @test
*/
public function esiTagWithXMLSpecialCharsIsPreserved()
public function esiTagWithXMLSpecialCharsIsPreserved(): void
{
$this->readDumpAssertFragment('<p>Test <esi:include foo="http://foo.bar?one=two&three=four"/></p>');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use PHPUnit\Framework\TestCase;

abstract class ParsingHelperTest extends TestCase
abstract class ParsingHelperTestCase extends TestCase
{
/** @var \Webfactory\Dom\BaseParsingHelper */
protected $parser;
Expand All @@ -27,7 +27,7 @@ protected function readDumpAssertFragment(
$result = null,
$declaredNamespacesInDump = null,
$declaredNamespacesInRead = null
) {
): void {
if (!$result) {
$result = $fragment;
}
Expand Down
18 changes: 9 additions & 9 deletions tests/Webfactory/Dom/Test/PolyglotHTML5ParsingHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@

use Webfactory\Dom\PolyglotHTML5ParsingHelper;

class PolyglotHTML5ParsingHelperTest extends HTMLParsingHelperTest
class PolyglotHTML5ParsingHelperTest extends HTMLParsingHelperTestCase
{
protected function createParsingHelper()
protected function createParsingHelper(): PolyglotHTML5ParsingHelper
{
return new PolyglotHTML5ParsingHelper();
}

/**
* @test
*/
public function voidTagsArePreservedWhileEmptyTagsAreExpanded()
public function voidTagsArePreservedWhileEmptyTagsAreExpanded(): void
{
$this->readDumpAssertFragment(
'<area/><base/><br/><col/><command/><embed/><hr/><img/><input/><keygen/><link/><meta/><param/><source/>'
Expand All @@ -32,7 +32,7 @@ public function voidTagsArePreservedWhileEmptyTagsAreExpanded()
/**
* @test
*/
public function htmlEntitiesSupportedAsConvenience()
public function htmlEntitiesSupportedAsConvenience(): void
{
// webfactory Case 12739,
// http://dev.w3.org/html5/html-xhtml-author-guide/#named-entity-references
Expand All @@ -56,7 +56,7 @@ public function htmlEntitiesSupportedAsConvenience()
/**
* @test
*/
public function svgNamespaceIsNotReconciled()
public function svgNamespaceIsNotReconciled(): void
{
/*
* libxml2 will attempt (under which circumstances?) to reconciliate namespace declarations, that is, find
Expand Down Expand Up @@ -95,7 +95,7 @@ public function svgNamespaceIsNotReconciled()
* @test
* @dataProvider provideXpathForDocuments
*/
public function xpathParseDocument($xml, $xpathExpression)
public function xpathParseDocument($xml, $xpathExpression): void
{
$document = $this->parser->parseDocument($xml);
$xpath = $this->parser->createXPath($document);
Expand All @@ -106,7 +106,7 @@ public function xpathParseDocument($xml, $xpathExpression)
self::assertSame('test', $domNodeList[0]->textContent);
}

public function provideXpathForDocuments()
public static function provideXpathForDocuments(): ?\Generator
{
yield 'HTML document that does not use a default namespace' => [
/*
Expand Down Expand Up @@ -155,7 +155,7 @@ public function provideXpathForDocuments()
* @test
* @dataProvider provideXpathForFragments
*/
public function xpathParseFragment($xmlFragment, $xpathExpression)
public function xpathParseFragment($xmlFragment, $xpathExpression): void
{
$fragment = $this->parser->parseFragment($xmlFragment);
$xpath = $this->parser->createXPath($fragment);
Expand All @@ -166,7 +166,7 @@ public function xpathParseFragment($xmlFragment, $xpathExpression)
self::assertSame('test', $domNodeList[0]->textContent);
}

public function provideXpathForFragments()
public static function provideXpathForFragments(): ?\Generator
{
yield 'default namespace assumed for fragments' => [
/*
Expand Down
10 changes: 5 additions & 5 deletions tests/Webfactory/Dom/Test/XHTML10ParsingHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@

namespace Webfactory\Dom\Test;

class XHTML10ParsingHelperTest extends HTMLParsingHelperTest
class XHTML10ParsingHelperTest extends HTMLParsingHelperTestCase
{
protected function createParsingHelper()
protected function createParsingHelper(): \Webfactory\Dom\XHTML10ParsingHelper
{
return new \Webfactory\Dom\XHTML10ParsingHelper();
}

/**
* @test
*/
public function entireDocumentIsPreserved()
public function entireDocumentIsPreserved(): void
{
$entireDocument = <<<XML
<?xml version="1.0"?>
Expand All @@ -45,7 +45,7 @@ public function entireDocumentIsPreserved()
/**
* @test
*/
public function incompleteDocumentIsFixed()
public function incompleteDocumentIsFixed(): void
{
$missingNSDecl = <<<XML
<?xml version="1.0"?>
Expand All @@ -66,7 +66,7 @@ public function incompleteDocumentIsFixed()
/**
* @test
*/
public function voidTagsArePreservedWhileEmptyTagsAreExpanded()
public function voidTagsArePreservedWhileEmptyTagsAreExpanded(): void
{
$this->readDumpAssertFragment(
'<area/><base/><br/><col/><hr/><img/><input/><link/><meta/><param/>',
Expand Down