HELP_MY_TESTS_DONT_WORK_ANYMORE 15 KB

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