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