HELP_MY_TESTS_DONT_WORK_ANYMORE 13 KB

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