File tree Expand file tree Collapse file tree 5 files changed +70
-6
lines changed Expand file tree Collapse file tree 5 files changed +70
-6
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ namespace PHPHtmlParser \Dom ;
3+
4+ /**
5+ * This mock object is used solely for testing the abstract
6+ * class Node with out any potential side effects caused
7+ * by testing a supperclass of Node.
8+ *
9+ * This object is not to be used for any other reason.
10+ */
11+ class MockNode extends Node {
12+
13+ public function innerHtml () {}
14+
15+ public function outerHtml () {}
16+
17+ public function text () {}
18+
19+ protected function clear () {}
20+ }
Original file line number Diff line number Diff line change 77/**
88 * Dom node object.
99 */
10- class Node {
10+ abstract class Node {
1111
1212 /**
1313 * Contains the tag name/type
@@ -621,9 +621,33 @@ public function get_display_size()
621621 return $ result ;
622622 }
623623
624+ /**
625+ * Gets the inner html of this node.
626+ *
627+ * @return string
628+ */
629+ abstract public function innerHtml ();
630+
631+ /**
632+ * Gets the html of this node, including it's own
633+ * tag.
634+ *
635+ * @return string
636+ */
637+ abstract public function outerHtml ();
638+
639+ /**
640+ * Gets the text of this node (if there is any text).
641+ *
642+ * @return string
643+ */
644+ abstract public function text ();
645+
624646 /**
625647 * Call this when something in the node tree has changed. Like a child has been added
626648 * or a parent has been changed.
649+ *
650+ * @return void
627651 */
628- protected function clear () {}
652+ abstract protected function clear ();
629653}
Original file line number Diff line number Diff line change 11<?php
22namespace PHPHtmlParser \Dom ;
33
4- use PHPHtmlParser \Dom ;
5-
64class TextNode extends Node {
75
86 /**
@@ -69,6 +67,28 @@ public function text()
6967 }
7068 }
7169
70+ /**
71+ * This node has no html, just return the text.
72+ *
73+ * @return string
74+ * @uses $this->text()
75+ */
76+ public function innerHtml ()
77+ {
78+ return $ this ->text ();
79+ }
80+
81+ /**
82+ * This node has no html, just return the text.
83+ *
84+ * @return string
85+ * @uses $this->text()
86+ */
87+ public function outerHtml ()
88+ {
89+ return $ this ->text ();
90+ }
91+
7292 /**
7393 * Call this when something in the node tree has changed. Like a child has been added
7494 * or a parent has been changed.
Original file line number Diff line number Diff line change 11<?php
22
3- use PHPHtmlParser \Dom \Node ;
3+ use PHPHtmlParser \Dom \MockNode as Node ;
44
55class NodeChildTest extends PHPUnit_Framework_TestCase {
66
Original file line number Diff line number Diff line change 11<?php
22
3- use PHPHtmlParser \Dom \Node ;
3+ use PHPHtmlParser \Dom \MockNode as Node ;
44
55class NodeParentTest extends PHPUnit_Framework_TestCase {
66
You can’t perform that action at this time.
0 commit comments