Skip to content

Commit

Permalink
Adding tests for issue #65
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasWeinert committed Jun 28, 2017
1 parent bb675a3 commit a8c925b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/FluentDOM/Query/Issue65.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace FluentDOM\Query {

use FluentDOM\TestCase;

require_once(__DIR__ . '/../TestCase.php');

class Issue65Test extends TestCase {

public function testWithFind() {
$fd = \FluentDOM::Query(
'<p>Paragraph 1</p> <p>Paragraph 2</p><p>Paragraph 3</p><div><b>5</b><p>4</p></div>',
'html-fragment'
);
$fd->find('/p')->first()->replaceWith('hi');

$this->assertEquals(
"hi <p>Paragraph 2</p><p>Paragraph 3</p><div>\n<b>5</b><p>4</p>\n</div>\n",
(string)$fd
);
}

public function testWithFilter() {
$fd = \FluentDOM::Query(
'<p>Paragraph 1</p> <p>Paragraph 2</p><p>Paragraph 3</p><div><b>5</b><p>4</p></div>',
'html-fragment'
);
$fd->filter('self::p')->first()->replaceWith('hi');

$this->assertEquals(
"hi <p>Paragraph 2</p><p>Paragraph 3</p><div>\n<b>5</b><p>4</p>\n</div>\n",
(string)$fd
);
}

}
}

0 comments on commit a8c925b

Please sign in to comment.