| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* Unit Tests for the IntermediateParser->addPrivatePage() method
|
|
|
4 |
* @package tests
|
|
|
5 |
* @subpackage PhpDocumentorUnitTests
|
|
|
6 |
* @author Chuck Burgess
|
|
|
7 |
* @since 1.4.0a2
|
|
|
8 |
*/
|
|
|
9 |
|
|
|
10 |
/**
|
|
|
11 |
* PHPUnit main() hack
|
|
|
12 |
*
|
|
|
13 |
* "Call class::main() if this source file is executed directly."
|
|
|
14 |
* @since 1.4.0a2
|
|
|
15 |
*/
|
|
|
16 |
if (!defined("PHPUnit_MAIN_METHOD")) {
|
|
|
17 |
define("PHPUnit_MAIN_METHOD", "IntermediateParserAddPrivatePageTests::main");
|
|
|
18 |
}
|
|
|
19 |
/**
|
|
|
20 |
* TestCase
|
|
|
21 |
*
|
|
|
22 |
* required by PHPUnit
|
|
|
23 |
* @since 1.4.0a2
|
|
|
24 |
*/
|
|
|
25 |
require_once "PHPUnit/Framework/TestCase.php";
|
|
|
26 |
/**
|
|
|
27 |
* TestSuite
|
|
|
28 |
*
|
|
|
29 |
* required by PHPUnit
|
|
|
30 |
* @since 1.4.0a2
|
|
|
31 |
*/
|
|
|
32 |
require_once "PHPUnit/Framework/TestSuite.php";
|
|
|
33 |
|
|
|
34 |
/**
|
|
|
35 |
* Base directory of code
|
|
|
36 |
*
|
|
|
37 |
* Needed by some of the objects being tested in the suites.
|
|
|
38 |
* @since 1.4.1
|
|
|
39 |
*/
|
|
|
40 |
chdir(dirname(dirname(__FILE__)));
|
|
|
41 |
if (!defined("PHPDOCUMENTOR_BASE")) {
|
|
|
42 |
define("PHPDOCUMENTOR_BASE", dirname(dirname(__FILE__)));
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* PhpDocumentor Setup
|
|
|
47 |
*
|
|
|
48 |
* required by PhpDocumentor to instantiate the environment
|
|
|
49 |
* @since 1.4.0a2
|
|
|
50 |
*/
|
|
|
51 |
require_once 'PhpDocumentor/phpDocumentor/Setup.inc.php';
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Unit Testing of the IntermediateParser's addPrivatePage() method
|
|
|
55 |
* @package tests
|
|
|
56 |
* @subpackage PhpDocumentorUnitTests
|
|
|
57 |
* @author Chuck Burgess
|
|
|
58 |
* @since 1.4.0a2
|
|
|
59 |
*/
|
|
|
60 |
class tests_IntermediateParserAddPrivatePageTests extends PHPUnit_Framework_TestCase {
|
|
|
61 |
|
|
|
62 |
/**
|
|
|
63 |
* phpDocumentor_setup object
|
|
|
64 |
* @access private
|
|
|
65 |
* @since 1.4.0a2
|
|
|
66 |
*/
|
|
|
67 |
private $ps;
|
|
|
68 |
/**
|
|
|
69 |
* IntermediateParser object
|
|
|
70 |
* @access private
|
|
|
71 |
* @since 1.4.0a2
|
|
|
72 |
*/
|
|
|
73 |
private $ip;
|
|
|
74 |
/**
|
|
|
75 |
* parserPage object
|
|
|
76 |
* @access private
|
|
|
77 |
* @since 1.4.0a2
|
|
|
78 |
*/
|
|
|
79 |
private $pp;
|
|
|
80 |
/**
|
|
|
81 |
* parserData object
|
|
|
82 |
* @access private
|
|
|
83 |
* @since 1.4.0a2
|
|
|
84 |
*/
|
|
|
85 |
private $pd;
|
|
|
86 |
/**
|
|
|
87 |
* path to file string
|
|
|
88 |
* @access private
|
|
|
89 |
* @since 1.4.0a2
|
|
|
90 |
*/
|
|
|
91 |
private $path;
|
|
|
92 |
|
|
|
93 |
/**
|
|
|
94 |
* Runs the test methods of this class.
|
|
|
95 |
* @access public
|
|
|
96 |
* @static
|
|
|
97 |
* @since 1.4.0a2
|
|
|
98 |
*/
|
|
|
99 |
public static function main() {
|
|
|
100 |
require_once "PHPUnit/TextUI/TestRunner.php";
|
|
|
101 |
|
|
|
102 |
$suite = new PHPUnit_Framework_TestSuite("tests_IntermediateParserAddPrivatePageTests");
|
|
|
103 |
$result = PHPUnit_TextUI_TestRunner::run($suite);
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
/**
|
|
|
107 |
* Sets up the fixture, for example, open a network connection.
|
|
|
108 |
* This method is called before a test is executed.
|
|
|
109 |
* @access protected
|
|
|
110 |
* @since 1.4.0a2
|
|
|
111 |
*/
|
|
|
112 |
protected function setUp() {
|
|
|
113 |
$GLOBALS['_phpDocumentor_install_dir'] = PHPDOCUMENTOR_BASE;
|
|
|
114 |
$GLOBALS['_phpDocumentor_setting']['quiet'] = "on";
|
|
|
115 |
|
|
|
116 |
$this->ps = new phpDocumentor_setup();
|
|
|
117 |
$this->ip = new phpDocumentor_IntermediateParser();
|
|
|
118 |
$this->pp = new parserPage();
|
|
|
119 |
$this->pd = new ParserData;
|
|
|
120 |
$this->pd->package = 'TESTING';
|
|
|
121 |
$this->path = PHPDOCUMENTOR_BASE . 'TestFile.php';
|
|
|
122 |
$this->ip->pages = array($this->path => $this->pd);
|
|
|
123 |
}
|
|
|
124 |
|
|
|
125 |
/**
|
|
|
126 |
* Tears down the fixture, for example, close a network connection.
|
|
|
127 |
* This method is called after a test is executed.
|
|
|
128 |
* @access protected
|
|
|
129 |
* @since 1.4.0a2
|
|
|
130 |
*/
|
|
|
131 |
protected function tearDown() {
|
|
|
132 |
unset($this->path);
|
|
|
133 |
unset($this->pd);
|
|
|
134 |
unset($this->pp);
|
|
|
135 |
unset($this->ip);
|
|
|
136 |
unset($this->ps);
|
|
|
137 |
}
|
|
|
138 |
|
|
|
139 |
|
|
|
140 |
/**
|
|
|
141 |
* NOW LIST THE TEST CASES -------------------------------------------------------|
|
|
|
142 |
*/
|
|
|
143 |
|
|
|
144 |
/**
|
|
|
145 |
* normal, expected cases ------------------------------------------|
|
|
|
146 |
*/
|
|
|
147 |
|
|
|
148 |
/**
|
|
|
149 |
* demonstrate the correct behavior -----------------------|
|
|
|
150 |
*/
|
|
|
151 |
|
|
|
152 |
/**
|
|
|
153 |
* Shows correct behavior for adding a private page object,
|
|
|
154 |
* when the privatepages array already has an element
|
|
|
155 |
* @since 1.4.0a2
|
|
|
156 |
*/
|
|
|
157 |
public function testShowCorrectBehaviorWhenPrivatePageArrayIsNotAlreadyEmpty() {
|
|
|
158 |
$this->ip->privatepages = array($this->path => $this->pd);
|
|
|
159 |
$this->ip->addPrivatePage($this->pp, $this->path);
|
|
|
160 |
|
|
|
161 |
// verify parent attributes are set correctly
|
|
|
162 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->type, "page");
|
|
|
163 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->id, "");
|
|
|
164 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->file, "");
|
|
|
165 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->sourceLocation, "");
|
|
|
166 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->name, "");
|
|
|
167 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->origName, "");
|
|
|
168 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->category, "default");
|
|
|
169 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->package, "default");
|
|
|
170 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->subpackage, "");
|
|
|
171 |
/**
|
|
|
172 |
* don't bother checking '[$this->path]->parent->parserVersion,
|
|
|
173 |
* because it will change between PhpDocumentor versions,
|
|
|
174 |
* and we don't want to keep it hand-updated in here
|
|
|
175 |
*/
|
|
|
176 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->modDate, "");
|
|
|
177 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->path, "");
|
|
|
178 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->packageOutput, "");
|
|
|
179 |
|
|
|
180 |
// now verify current page attributes are set correctly
|
|
|
181 |
$this->assertEquals($this->ip->privatepages[$this->path]->elements, array());
|
|
|
182 |
$this->assertEquals($this->ip->privatepages[$this->path]->_hasclasses, "");
|
|
|
183 |
$this->assertEquals($this->ip->privatepages[$this->path]->_hasinterfaces, "");
|
|
|
184 |
$this->assertEquals($this->ip->privatepages[$this->path]->privateelements, array());
|
|
|
185 |
$this->assertEquals($this->ip->privatepages[$this->path]->classelements, array());
|
|
|
186 |
$this->assertEquals($this->ip->privatepages[$this->path]->tutorial, "");
|
|
|
187 |
$this->assertEquals($this->ip->privatepages[$this->path]->privateclasselements, array());
|
|
|
188 |
$this->assertEquals($this->ip->privatepages[$this->path]->links, array());
|
|
|
189 |
$this->assertEquals($this->ip->privatepages[$this->path]->clean, true);
|
|
|
190 |
$this->assertEquals($this->ip->privatepages[$this->path]->docblock, "");
|
|
|
191 |
$this->assertEquals($this->ip->privatepages[$this->path]->_explicitdocblock, "");
|
|
|
192 |
$this->assertEquals($this->ip->privatepages[$this->path]->type, "page");
|
|
|
193 |
$this->assertEquals($this->ip->privatepages[$this->path]->package, "TESTING");
|
|
|
194 |
}
|
|
|
195 |
/**
|
|
|
196 |
* Shows correct behavior for adding a private page object,
|
|
|
197 |
* when the privatepages array is completely empty
|
|
|
198 |
* @since 1.4.0a2
|
|
|
199 |
*/
|
|
|
200 |
public function testShowCorrectBehaviorWhenPrivatePageArrayIsEmpty() {
|
|
|
201 |
$this->ip->addPrivatePage($this->pp, $this->path);
|
|
|
202 |
|
|
|
203 |
// verify parent attributes are set correctly
|
|
|
204 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->type, "page");
|
|
|
205 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->id, "");
|
|
|
206 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->file, "");
|
|
|
207 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->sourceLocation, "");
|
|
|
208 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->name, "");
|
|
|
209 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->origName, "");
|
|
|
210 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->category, "default");
|
|
|
211 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->package, "default");
|
|
|
212 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->subpackage, "");
|
|
|
213 |
/**
|
|
|
214 |
* don't bother checking '[$this->path]->parent->parserVersion,
|
|
|
215 |
* because it will change between PhpDocumentor versions,
|
|
|
216 |
* and we don't want to keep it hand-updated in here
|
|
|
217 |
*/
|
|
|
218 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->modDate, "");
|
|
|
219 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->path, "");
|
|
|
220 |
$this->assertEquals($this->ip->privatepages[$this->path]->parent->packageOutput, "");
|
|
|
221 |
|
|
|
222 |
// now verify current page attributes are set correctly
|
|
|
223 |
$this->assertEquals($this->ip->privatepages[$this->path]->elements, array());
|
|
|
224 |
$this->assertEquals($this->ip->privatepages[$this->path]->_hasclasses, "");
|
|
|
225 |
$this->assertEquals($this->ip->privatepages[$this->path]->_hasinterfaces, "");
|
|
|
226 |
$this->assertEquals($this->ip->privatepages[$this->path]->privateelements, array());
|
|
|
227 |
$this->assertEquals($this->ip->privatepages[$this->path]->classelements, array());
|
|
|
228 |
$this->assertEquals($this->ip->privatepages[$this->path]->tutorial, "");
|
|
|
229 |
$this->assertEquals($this->ip->privatepages[$this->path]->privateclasselements, array());
|
|
|
230 |
$this->assertEquals($this->ip->privatepages[$this->path]->links, array());
|
|
|
231 |
$this->assertEquals($this->ip->privatepages[$this->path]->clean, true);
|
|
|
232 |
$this->assertEquals($this->ip->privatepages[$this->path]->docblock, "");
|
|
|
233 |
$this->assertEquals($this->ip->privatepages[$this->path]->_explicitdocblock, "");
|
|
|
234 |
$this->assertEquals($this->ip->privatepages[$this->path]->type, "page");
|
|
|
235 |
}
|
|
|
236 |
|
|
|
237 |
/**
|
|
|
238 |
* END OF "demonstrate the correct behavior" --------------|
|
|
|
239 |
*/
|
|
|
240 |
/**
|
|
|
241 |
* END OF "normal, expected cases" ---------------------------------|
|
|
|
242 |
* @todo write more "normal" test cases
|
|
|
243 |
*/
|
|
|
244 |
|
|
|
245 |
|
|
|
246 |
/**
|
|
|
247 |
* odd, edge cases -------------------------------------------------|
|
|
|
248 |
*/
|
|
|
249 |
/**
|
|
|
250 |
* END OF "odd, edge cases" ----------------------------------------|
|
|
|
251 |
* @todo write some "edge" test cases
|
|
|
252 |
*/
|
|
|
253 |
|
|
|
254 |
/**
|
|
|
255 |
* END OF "NOW LIST THE TEST CASES" ----------------------------------------------|
|
|
|
256 |
*/
|
|
|
257 |
}
|
|
|
258 |
|
|
|
259 |
/**
|
|
|
260 |
* PHPUnit main() hack
|
|
|
261 |
* "Call class::main() if this source file is executed directly."
|
|
|
262 |
* @since 1.4.0a2
|
|
|
263 |
*/
|
|
|
264 |
if (PHPUnit_MAIN_METHOD == "IntermediateParserAddPrivatePageTests::main") {
|
|
|
265 |
tests_IntermediateParserAddPrivatePageTests::main();
|
|
|
266 |
}
|
|
|
267 |
?>
|