1<?php
2/**
3 * A mock decorator, handy for unit testing.
4 */
5require_once DOKU_PLUGIN . 'latexport/implementation/decorator.php';
6require_once DOKU_PLUGIN . 'latexport/_test/command.php';
7
8class DecoratorMock extends Decorator {
9
10	public $listOfCommands;
11
12	public $recursionLevel;
13
14	function __construct() {
15		$this->listOfCommands = new SplQueue();
16	}
17
18	function nextCommand() {
19		if ($this->noCommands()) {
20			return false;
21		} else {
22			return $this->listOfCommands->dequeue();
23		}
24	}
25
26	function noCommands() {
27		return $this->listOfCommands->isEmpty();
28	}
29
30	function document_start($pageId = NULL, $recursionLevel = 0) {
31		$this->recursionLevel = $recursionLevel;
32		// Nothing to do?
33	}
34
35	function header($text, $level, $pos) {
36		$this->listOfCommands->enqueue(new CommandHeader($text, $level, $pos));
37	}
38
39	function p_open() {
40		$this->listOfCommands->enqueue(new CommandPOpen());
41	}
42
43	function cdata($text) {
44		$this->listOfCommands->enqueue(new CommandCData($text));
45	}
46
47	function p_close() {
48		$this->listOfCommands->enqueue(new CommandPClose());
49	}
50
51  function linebreak() {
52		$this->listOfCommands->enqueue(new CommandLinebreak());
53  }
54
55	function emphasis_open() {
56		// Nothing to do?
57	}
58
59	function emphasis_close() {
60		// Nothing to do?
61	}
62
63	function strong_open() {
64		// Nothing to do?
65	}
66
67	function strong_close() {
68		// Nothing to do?
69	}
70
71	function underline_open() {
72		// Nothing to do?
73	}
74
75	function underline_close() {
76		// Nothing to do?
77	}
78
79	function internallink($link, $title = null) {
80		$this->listOfCommands->enqueue(new CommandInternalLink($link, $title));
81	}
82
83	function input($link) {
84		// Nothing to do?
85	}
86
87	function internalmedia($src, $title = null, $align = null, $width = null, $height = null,
88	                       $cache = null, $linking = null, $positionInGroup = 1, $totalInGroup = 1) {
89
90		$this->listOfCommands->enqueue(new CommandInternalMedia($src, $title, $align, $width, $height,
91		                                                        $positionInGroup, $totalInGroup));
92	}
93
94	function footnote_open() {
95		$this->listOfCommands->enqueue(new CommandFootnoteOpen());
96	}
97
98	function footnote_close() {
99		$this->listOfCommands->enqueue(new CommandFootnoteClose());
100	}
101
102  function listo_open() {
103		$this->listOfCommands->enqueue(new CommandListOOpen());
104  }
105
106  function listo_close() {
107		$this->listOfCommands->enqueue(new CommandListOClose());
108  }
109
110	function listu_open() {
111		$this->listOfCommands->enqueue(new CommandListUOpen());
112	}
113
114	function listu_close() {
115		$this->listOfCommands->enqueue(new CommandListUClose());
116	}
117
118	function listitem_open($level,$node=false) {
119		$this->listOfCommands->enqueue(new CommandListItemOpen($level, $node));
120	}
121
122	function listcontent_open() {
123		$this->listOfCommands->enqueue(new CommandListContentOpen());
124	}
125
126	function listcontent_close() {
127		$this->listOfCommands->enqueue(new CommandListContentClose());
128	}
129
130  function listitem_close() {
131		$this->listOfCommands->enqueue(new CommandListItemClose());
132  }
133
134	function mathjax_content($formula) {
135		$this->listOfCommands->enqueue(new CommandMathjaxContent($formula));
136	}
137
138	function document_end($recursionLevel = 0){
139		// Nothing to do?
140	}
141
142	function appendCommand($command, $scope, $argument = '') {
143		$this->listOfCommands->enqueue(new CommandAppendCommand($command, $scope, $argument));
144	}
145
146  function table_open($maxcols = null, $numrows = null, $pos = null) {
147		$this->listOfCommands->enqueue(new CommandTableOpen($maxcols, $numrows, $pos));
148  }
149
150  function table_close($pos = null) {
151		$this->listOfCommands->enqueue(new CommandTableClose($pos));
152  }
153
154  function tablethead_open() {
155		$this->listOfCommands->enqueue(new CommandTableHeadOpen());
156  }
157
158  function tablethead_close() {
159		$this->listOfCommands->enqueue(new CommandTableHeadClose());
160  }
161
162  function tabletbody_open() {
163		$this->listOfCommands->enqueue(new CommandTableBodyOpen());
164  }
165
166  function tabletbody_close() {
167		$this->listOfCommands->enqueue(new CommandTableBodyClose());
168  }
169
170  function tabletfoot_open() {
171		$this->listOfCommands->enqueue(new CommandTableFootOpen());
172  }
173
174  function tabletfoot_close() {
175		$this->listOfCommands->enqueue(new CommandTableFootClose());
176  }
177
178  function tablerow_open() {
179		$this->listOfCommands->enqueue(new CommandTableRowOpen());
180  }
181
182  function tablerow_close() {
183		$this->listOfCommands->enqueue(new CommandTableRowClose());
184  }
185
186  function tableheader_open($colspan = 1, $align = null, $rowspan = 1) {
187		$this->listOfCommands->enqueue(new CommandTableHeaderOpen($colspan, $align, $rowspan));
188  }
189
190  function tableheader_close() {
191		$this->listOfCommands->enqueue(new CommandTableHeaderClose());
192  }
193
194  function tablecell_open($colspan = 1, $align = null, $rowspan = 1) {
195		$this->listOfCommands->enqueue(new CommandTableCellOpen($colspan, $align, $rowspan));
196  }
197
198  function tablecell_close() {
199		$this->listOfCommands->enqueue(new CommandTableCellClose());
200  }
201
202	function table_cline($start, $end) {
203		$this->listOfCommands->enqueue(new CommandTableCline($start, $end));
204	}
205}
206?>
207