Files
piratepoet/tests/unit/Util/DOMTest.php
Jan Jakeš 1b5b9d89ff Autofix namespace declaration spacing
[MAILPOET-2409]
2019-10-01 14:29:30 +01:00

31 lines
856 B
PHP

<?php
namespace MailPoet\Test\Util;
use pQuery;
use MailPoet\Util\DOM as DOMUtil;
class DOMTest extends \MailPoetUnitTest {
function _before() {
$this->root = pQuery::parseStr('<p><i>italic</i><em>previous text<a href="#mylink"><img src="#myimage" /></a>next text</em><b>bolded</b></p>');
}
function testItDeepSplitsDOMTreeByElement() {
DOMUtil::splitOn($this->root, $this->root->query('a')->offsetGet(0));
expect($this->root->html())->equals(
'<p><i>italic</i><em>previous text</em></p>' .
'<a href="#mylink"><img src="#myimage" /></a>' .
'<p><em>next text</em><b>bolded</b></p>'
);
}
function testItFindsTopAncestor() {
$image = $this->root->query('img')->offsetGet(0);
$paragraph = $this->root->query('p')->offsetGet(0);
expect(DOMUtil::findTopAncestor($image))->equals($paragraph);
}
}