summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTechnosophos <[email protected]>2013-04-10 11:50:06 -0500
committerTechnosophos <[email protected]>2013-04-10 11:50:06 -0500
commitbdd5822cda3df4c1ef6e7a1d66b844ff534491ce (patch)
tree97708c1dadbe6b50071d2ec5eab6ebb7b15c6556
parent843732d17e0ce98573b1228df6b3ca75e95a4703 (diff)
Added EventStack testing event handler.
-rw-r--r--test/HTML5/Parser/EventStack.php57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/HTML5/Parser/EventStack.php b/test/HTML5/Parser/EventStack.php
new file mode 100644
index 0000000..6f5576e
--- /dev/null
+++ b/test/HTML5/Parser/EventStack.php
@@ -0,0 +1,57 @@
+<?php
+namespace HTML5\Parser;
+require __DIR__ . '/../TestCase.php';
+
+class EventStack implements EventHandler {
+ protected $stack;
+
+ public function __construct() {
+ $this->stack = array();
+ }
+
+ /**
+ * Get the event stack.
+ */
+ public function events() {
+ return $this->stack;
+ }
+
+ public function depth() {
+ return count($this->stack);
+ }
+
+ protected function store($event, $data = NULL) {
+ $stack[] = array(
+ 'name' => $event,
+ 'data' => $data,
+ );
+ }
+
+ public function doctype($name, $publicId, $systemID, $quirks) {
+ $args = func_get_args();
+ $this->store('doctype', $args);
+ }
+
+ public function startTag($name, $attributes = array(), $selfClosing = FALSE) {
+ $args = func_get_args();
+ $this->store('startTag', $args);
+ }
+
+ public function endTag($name) {
+ $this->store('endTag', array($name));
+ }
+
+ public function comment($cdata) {
+ $this->store('comment', array($cdata));
+ }
+
+ public function text($cdata) {
+ $this->store('character', array($cdata));
+ }
+
+ public function eof() {
+ $this->store('eof');
+ }
+
+
+}