Skip to content

Commit

Permalink
Add commented out assertions back in
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Dec 23, 2023
1 parent 8a196e3 commit f5cbb1e
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tests/Toolkit/DomTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use DOMElement;
use Kirby\Cms\App;
use Kirby\Exception\InvalidArgumentException;
use PHPUnit\Framework\AssertionFailedError;

/**
* @coversDefaultClass \Kirby\Toolkit\Dom
Expand Down Expand Up @@ -1665,7 +1666,9 @@ public static function sanitizeProvider(): array
'<xml a="A" b="B"/>',
[
'attrCallback' => function (DOMAttr $attr, array $options): array {
// $this->assertInstanceOf(Closure::class, $options['attrCallback']);
if (is_a($options['attrCallback'], Closure::class) !== true) {
throw new AssertionFailedError('Options provided to callback are not complete or invalid');
}

if ($attr->nodeName === 'b') {
$attr->ownerElement->removeAttributeNode($attr);
Expand Down Expand Up @@ -1733,7 +1736,9 @@ public static function sanitizeProvider(): array
'<!DOCTYPE svg><xml/>',
[
'doctypeCallback' => function (DOMDocumentType $doctype, array $options): void {
// $this->assertInstanceOf(Closure::class, $options['doctypeCallback']);
if (is_a($options['doctypeCallback'], Closure::class) !== true) {
throw new AssertionFailedError('Options provided to callback are not complete or invalid');
}

throw new InvalidArgumentException('The "' . $doctype->name . '" doctype is not allowed');
}
Expand All @@ -1759,7 +1764,9 @@ public static function sanitizeProvider(): array
'<xml><a class="a">A</a><b class="b">B</b></xml>',
[
'elementCallback' => function (DOMElement $element, array $options): array {
// $this->assertInstanceOf(Closure::class, $options['elementCallback']);
if (is_a($options['elementCallback'], Closure::class) !== true) {
throw new AssertionFailedError('Options provided to callback are not complete or invalid');
}

if ($element->nodeName === 'b') {
Dom::remove($element);
Expand Down

0 comments on commit f5cbb1e

Please sign in to comment.