1 | Simple Test interface changes |
---|
2 | ============================= |
---|
3 | Because the SimpleTest tool set is still evolving it is likely that tests |
---|
4 | written with earlier versions will fail with the newest ones. The most |
---|
5 | dramatic changes are in the alpha releases. Here is a list of possible |
---|
6 | problems and their fixes... |
---|
7 | |
---|
8 | No method getRelativeUrls() or getAbsoluteUrls() |
---|
9 | ------------------------------------------------ |
---|
10 | These methods were always a bit weird anyway, and |
---|
11 | the new parsing of the base tag makes them more so. |
---|
12 | They have been replaced with getUrls() instead. If |
---|
13 | you want the old functionality then simply chop |
---|
14 | off the current domain from getUrl(). |
---|
15 | |
---|
16 | Method setWildcard() removed in mocks |
---|
17 | ------------------------------------- |
---|
18 | Even setWildcard() has been removed in 1.0.1beta now. |
---|
19 | If you want to test explicitely for a '*' string, then |
---|
20 | simply pass in new IdenticalExpectation('*') instead. |
---|
21 | |
---|
22 | No method _getTest() on mocks |
---|
23 | ----------------------------- |
---|
24 | This has finally been removed. It was a pretty esoteric |
---|
25 | flex point anyway. It was there to allow the mocks to |
---|
26 | work with other test tools, but no one does this. |
---|
27 | |
---|
28 | No method assertError(), assertNoErrors(), swallowErrors() |
---|
29 | ---------------------------------------------------------- |
---|
30 | These have been deprecated in 1.0.1beta in favour of |
---|
31 | expectError() and expectException(). assertNoErrors() is |
---|
32 | redundant if you use expectError() as failures are now reported |
---|
33 | immediately. |
---|
34 | |
---|
35 | No method TestCase::signal() |
---|
36 | ---------------------------- |
---|
37 | This has been deprecated in favour of triggering an error or |
---|
38 | throwing an exception. Deprecated as of 1.0.1beta. |
---|
39 | |
---|
40 | No method TestCase::sendMessage() |
---|
41 | --------------------------------- |
---|
42 | This has been deprecated as of 1.0.1beta. |
---|
43 | |
---|
44 | Failure to connect now emits failures |
---|
45 | ------------------------------------- |
---|
46 | It used to be that you would have to use the |
---|
47 | getTransferError() call on the web tester to see if |
---|
48 | there was a socket level error in a fetch. This check |
---|
49 | is now always carried out by the WebTestCase unless |
---|
50 | the fetch is prefaced with WebTestCase::ignoreErrors(). |
---|
51 | The ignore directive only lasts for test case fetching |
---|
52 | action such as get() and click(). |
---|
53 | |
---|
54 | No method SimpleTestOptions::ignore() |
---|
55 | ------------------------------------- |
---|
56 | This is deprecated in version 1.0.1beta and has been moved |
---|
57 | to SimpleTest::ignore() as that is more readable. In |
---|
58 | addition, parent classes are also ignored automatically. |
---|
59 | If you are using PHP5 you can skip this directive simply |
---|
60 | by marking your test case as abstract. |
---|
61 | |
---|
62 | No method assertCopy() |
---|
63 | ---------------------- |
---|
64 | This is deprecated in 1.0.1 in favour of assertClone(). |
---|
65 | The assertClone() method is slightly different in that |
---|
66 | the objects must be identical, but without being a |
---|
67 | reference. It is thus not a strict inversion of |
---|
68 | assertReference(). |
---|
69 | |
---|
70 | Constructor wildcard override has no effect in mocks |
---|
71 | ---------------------------------------------------- |
---|
72 | As of 1.0.1beta this is now set with setWildcard() instead |
---|
73 | of in the constructor. |
---|
74 | |
---|
75 | No methods setStubBaseClass()/getStubBaseClass() |
---|
76 | ------------------------------------------------ |
---|
77 | As mocks are now used instead of stubs, these methods |
---|
78 | stopped working and are now removed as of the 1.0.1beta |
---|
79 | release. The mock objects may be freely used instead. |
---|
80 | |
---|
81 | No method addPartialMockCode() |
---|
82 | ------------------------------ |
---|
83 | The ability to insert arbitrary partial mock code |
---|
84 | has been removed. This was a low value feature |
---|
85 | causing needless complications. It was removed |
---|
86 | in the 1.0.1beta release. |
---|
87 | |
---|
88 | No method setMockBaseClass() |
---|
89 | ---------------------------- |
---|
90 | The ability to change the mock base class has been |
---|
91 | scheduled for removal and is deprecated since the |
---|
92 | 1.0.1beta version. This was a rarely used feature |
---|
93 | except as a workaround for PHP5 limitations. As |
---|
94 | these limitations are being resolved it's hoped |
---|
95 | that the bundled mocks can be used directly. |
---|
96 | |
---|
97 | No class Stub |
---|
98 | ------------- |
---|
99 | Server stubs are deprecated from 1.0.1 as the mocks now |
---|
100 | have exactly the same interface. Just use mock objects |
---|
101 | instead. |
---|
102 | |
---|
103 | No class SimpleTestOptions |
---|
104 | -------------------------- |
---|
105 | This was replced by the shorter SimpleTest in 1.0.1beta1 |
---|
106 | and is since deprecated. |
---|
107 | |
---|
108 | No file simple_test.php |
---|
109 | ----------------------- |
---|
110 | This was renamed test_case.php in 1.0.1beta to more accurately |
---|
111 | reflect it's purpose. This file should never be directly |
---|
112 | included in test suites though, as it's part of the |
---|
113 | underlying mechanics and has a tendency to be refactored. |
---|
114 | |
---|
115 | No class WantedPatternExpectation |
---|
116 | --------------------------------- |
---|
117 | This was deprecated in 1.0.1alpha in favour of the simpler |
---|
118 | name PatternExpectation. |
---|
119 | |
---|
120 | No class NoUnwantedPatternExpectation |
---|
121 | ------------------------------------- |
---|
122 | This was deprecated in 1.0.1alpha in favour of the simpler |
---|
123 | name NoPatternExpectation. |
---|
124 | |
---|
125 | No method assertNoUnwantedPattern() |
---|
126 | ----------------------------------- |
---|
127 | This has been renamed to assertNoPattern() in 1.0.1alpha and |
---|
128 | the old form is deprecated. |
---|
129 | |
---|
130 | No method assertWantedPattern() |
---|
131 | ------------------------------- |
---|
132 | This has been renamed to assertPattern() in 1.0.1alpha and |
---|
133 | the old form is deprecated. |
---|
134 | |
---|
135 | No method assertExpectation() |
---|
136 | ----------------------------- |
---|
137 | This was renamed as assert() in 1.0.1alpha and the old form |
---|
138 | has been deprecated. |
---|
139 | |
---|
140 | No class WildcardExpectation |
---|
141 | ---------------------------- |
---|
142 | This was a mostly internal class for the mock objects. It was |
---|
143 | renamed AnythingExpectation to bring it closer to JMock and |
---|
144 | NMock in version 1.0.1alpha. |
---|
145 | |
---|
146 | Missing UnitTestCase::assertErrorPattern() |
---|
147 | ------------------------------------------ |
---|
148 | This method is deprecated for version 1.0.1 onwards. |
---|
149 | This method has been subsumed by assertError() that can now |
---|
150 | take an expectation. Simply pass a PatternExpectation |
---|
151 | into assertError() to simulate the old behaviour. |
---|
152 | |
---|
153 | No HTML when matching page elements |
---|
154 | ----------------------------------- |
---|
155 | This behaviour has been switched to using plain text as if it |
---|
156 | were seen by the user of the browser. This means that HTML tags |
---|
157 | are suppressed, entities are converted and whitespace is |
---|
158 | normalised. This should make it easier to match items in forms. |
---|
159 | Also images are replaced with their "alt" text so that they |
---|
160 | can be matched as well. |
---|
161 | |
---|
162 | No method SimpleRunner::_getTestCase() |
---|
163 | -------------------------------------- |
---|
164 | This was made public as getTestCase() in 1.0RC2. |
---|
165 | |
---|
166 | No method restartSession() |
---|
167 | -------------------------- |
---|
168 | This was renamed to restart() in the WebTestCase, SimpleBrowser |
---|
169 | and the underlying SimpleUserAgent in 1.0RC2. Because it was |
---|
170 | undocumented anyway, no attempt was made at backward |
---|
171 | compatibility. |
---|
172 | |
---|
173 | My custom test case ignored by tally() |
---|
174 | -------------------------------------- |
---|
175 | The _assertTrue method has had it's signature changed due to a bug |
---|
176 | in the PHP 5.0.1 release. You must now use getTest() from within |
---|
177 | that method to get the test case. Mock compatibility with other |
---|
178 | unit testers is now deprecated as of 1.0.1alpha as PEAR::PHPUnit2 |
---|
179 | should soon have mock support of it's own. |
---|
180 | |
---|
181 | Broken code extending SimpleRunner |
---|
182 | ---------------------------------- |
---|
183 | This was replaced with SimpleScorer so that I could use the runner |
---|
184 | name in another class. This happened in RC1 development and there |
---|
185 | is no easy backward compatibility fix. The solution is simply to |
---|
186 | extend SimpleScorer instead. |
---|
187 | |
---|
188 | Missing method getBaseCookieValue() |
---|
189 | ----------------------------------- |
---|
190 | This was renamed getCurrentCookieValue() in RC1. |
---|
191 | |
---|
192 | Missing files from the SimpleTest suite |
---|
193 | --------------------------------------- |
---|
194 | Versions of SimpleTest prior to Beta6 required a SIMPLE_TEST constant |
---|
195 | to point at the SimpleTest folder location before any of the toolset |
---|
196 | was loaded. This is no longer documented as it is now unnecessary |
---|
197 | for later versions. If you are using an earlier version you may |
---|
198 | need this constant. Consult the documentation that was bundled with |
---|
199 | the release that you are using or upgrade to Beta6 or later. |
---|
200 | |
---|
201 | No method SimpleBrowser::getCurrentUrl() |
---|
202 | -------------------------------------- |
---|
203 | This is replaced with the more versatile showRequest() for |
---|
204 | debugging. It only existed in this context for version Beta5. |
---|
205 | Later versions will have SimpleBrowser::getHistory() for tracking |
---|
206 | paths through pages. It is renamed as getUrl() since 1.0RC1. |
---|
207 | |
---|
208 | No method Stub::setStubBaseClass() |
---|
209 | ---------------------------------- |
---|
210 | This method has finally been removed in 1.0RC1. Use |
---|
211 | SimpleTestOptions::setStubBaseClass() instead. |
---|
212 | |
---|
213 | No class CommandLineReporter |
---|
214 | ---------------------------- |
---|
215 | This was renamed to TextReporter in Beta3 and the deprecated version |
---|
216 | was removed in 1.0RC1. |
---|
217 | |
---|
218 | No method requireReturn() |
---|
219 | ------------------------- |
---|
220 | This was deprecated in Beta3 and is now removed. |
---|
221 | |
---|
222 | No method expectCookie() |
---|
223 | ------------------------ |
---|
224 | This method was abruptly removed in Beta4 so as to simplify the internals |
---|
225 | until another mechanism can replace it. As a workaround it is necessary |
---|
226 | to assert that the cookie has changed by setting it before the page |
---|
227 | fetch and then assert the desired value. |
---|
228 | |
---|
229 | No method clickSubmitByFormId() |
---|
230 | ------------------------------- |
---|
231 | This method had an incorrect name as no button was involved. It was |
---|
232 | renamed to submitByFormId() in Beta4 and the old version deprecated. |
---|
233 | Now removed. |
---|
234 | |
---|
235 | No method paintStart() or paintEnd() |
---|
236 | ------------------------------------ |
---|
237 | You should only get this error if you have subclassed the lower level |
---|
238 | reporting and test runner machinery. These methods have been broken |
---|
239 | down into events for test methods, events for test cases and events |
---|
240 | for group tests. The new methods are... |
---|
241 | |
---|
242 | paintStart() --> paintMethodStart(), paintCaseStart(), paintGroupStart() |
---|
243 | paintEnd() --> paintMethodEnd(), paintCaseEnd(), paintGroupEnd() |
---|
244 | |
---|
245 | This change was made in Beta3, ironically to make it easier to subclass |
---|
246 | the inner machinery. Simply duplicating the code you had in the previous |
---|
247 | methods should provide a temporary fix. |
---|
248 | |
---|
249 | No class TestDisplay |
---|
250 | -------------------- |
---|
251 | This has been folded into SimpleReporter in Beta3 and is now deprecated. |
---|
252 | It was removed in RC1. |
---|
253 | |
---|
254 | No method WebTestCase::fetch() |
---|
255 | ------------------------------ |
---|
256 | This was renamed get() in Alpha8. It is removed in Beta3. |
---|
257 | |
---|
258 | No method submit() |
---|
259 | ------------------ |
---|
260 | This has been renamed clickSubmit() in Beta1. The old method was |
---|
261 | removed in Beta2. |
---|
262 | |
---|
263 | No method clearHistory() |
---|
264 | ------------------------ |
---|
265 | This method is deprecated in Beta2 and removed in RC1. |
---|
266 | |
---|
267 | No method getCallCount() |
---|
268 | ------------------------ |
---|
269 | This method has been deprecated since Beta1 and has now been |
---|
270 | removed. There are now more ways to set expectations on counts |
---|
271 | and so this method should be unecessery. Removed in RC1. |
---|
272 | |
---|
273 | Cannot find file * |
---|
274 | ------------------ |
---|
275 | The following public name changes have occoured... |
---|
276 | |
---|
277 | simple_html_test.php --> reporter.php |
---|
278 | simple_mock.php --> mock_objects.php |
---|
279 | simple_unit.php --> unit_tester.php |
---|
280 | simple_web.php --> web_tester.php |
---|
281 | |
---|
282 | The old names were deprecated in Alpha8 and removed in Beta1. |
---|
283 | |
---|
284 | No method attachObserver() |
---|
285 | -------------------------- |
---|
286 | Prior to the Alpha8 release the old internal observer pattern was |
---|
287 | gutted and replaced with a visitor. This is to trade flexibility of |
---|
288 | test case expansion against the ease of writing user interfaces. |
---|
289 | |
---|
290 | Code such as... |
---|
291 | |
---|
292 | $test = &new MyTestCase(); |
---|
293 | $test->attachObserver(new TestHtmlDisplay()); |
---|
294 | $test->run(); |
---|
295 | |
---|
296 | ...should be rewritten as... |
---|
297 | |
---|
298 | $test = &new MyTestCase(); |
---|
299 | $test->run(new HtmlReporter()); |
---|
300 | |
---|
301 | If you previously attached multiple observers then the workaround |
---|
302 | is to run the tests twice, once with each, until they can be combined. |
---|
303 | For one observer the old method is simulated in Alpha 8, but is |
---|
304 | removed in Beta1. |
---|
305 | |
---|
306 | No class TestHtmlDisplay |
---|
307 | ------------------------ |
---|
308 | This class has been renamed to HtmlReporter in Alpha8. It is supported, |
---|
309 | but deprecated in Beta1 and removed in Beta2. If you have subclassed |
---|
310 | the display for your own design, then you will have to extend this |
---|
311 | class (HtmlReporter) instead. |
---|
312 | |
---|
313 | If you have accessed the event queue by overriding the notify() method |
---|
314 | then I am afraid you are in big trouble :(. The reporter is now |
---|
315 | carried around the test suite by the runner classes and the methods |
---|
316 | called directly. In the unlikely event that this is a problem and |
---|
317 | you don't want to upgrade the test tool then simplest is to write your |
---|
318 | own runner class and invoke the tests with... |
---|
319 | |
---|
320 | $test->accept(new MyRunner(new MyReporter())); |
---|
321 | |
---|
322 | ...rather than the run method. This should be easier to extend |
---|
323 | anyway and gives much more control. Even this method is overhauled |
---|
324 | in Beta3 where the runner class can be set within the test case. Really |
---|
325 | the best thing to do is to upgrade to this version as whatever you were |
---|
326 | trying to achieve before should now be very much easier. |
---|
327 | |
---|
328 | Missing set options method |
---|
329 | -------------------------- |
---|
330 | All test suite options are now in one class called SimpleTestOptions. |
---|
331 | This means that options are set differently... |
---|
332 | |
---|
333 | GroupTest::ignore() --> SimpleTestOptions::ignore() |
---|
334 | Mock::setMockBaseClass() --> SimpleTestOptions::setMockBaseClass() |
---|
335 | |
---|
336 | These changed in Alpha8 and the old versions are now removed in RC1. |
---|
337 | |
---|
338 | No method setExpected*() |
---|
339 | ------------------------ |
---|
340 | The mock expectations changed their names in Alpha4 and the old names |
---|
341 | ceased to be supported in Alpha8. The changes are... |
---|
342 | |
---|
343 | setExpectedArguments() --> expectArguments() |
---|
344 | setExpectedArgumentsSequence() --> expectArgumentsAt() |
---|
345 | setExpectedCallCount() --> expectCallCount() |
---|
346 | setMaximumCallCount() --> expectMaximumCallCount() |
---|
347 | |
---|
348 | The parameters remained the same. |
---|