Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshyPHP committed Oct 13, 2023
1 parent 440627e commit 7bf357f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/ElementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use PHPUnit\Framework\Attributes\WithoutErrorHandler;
use PHPUnit\Framework\TestCase;
use s9e\SweetDOM\Document;
use s9e\SweetDOM\Element;
use s9e\SweetDOM\NodeCreator;

#[CoversClass('s9e\SweetDOM\Element')]
#[CoversClass('s9e\SweetDOM\NodeTraits\DeprecatedMethods')]
Expand Down Expand Up @@ -47,6 +49,19 @@ public function testUnknownXslMethod()
$dom->documentElement->appendXslUnknown();
}

public function testCustomNodeCreator()
{
$dom = new Document;
$dom->loadXML('<html/>');
$dom->nodeCreator = new MyNodeCreator($dom);
$dom->documentElement->appendBr();

$this->assertXmlStringEqualsXmlString(
'<html><br/></html>',
$dom->saveXML()
);
}

#[DataProvider('getMagicMethodsTests')]
public function testMagicMethods(string $expected, string $methodName, array $args = [])
{
Expand Down Expand Up @@ -540,4 +555,12 @@ public static function getInsertAdjacentXMLTests()
],
];
}
}

class MyNodeCreator extends NodeCreator
{
public function createBr(): Element
{
return $this->ownerDocument->createElement('br');
}
}

0 comments on commit 7bf357f

Please sign in to comment.