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