SimpleTest conversion: Difference between revisions
From MoodleDocs
No edit summary |
|||
Line 9: | Line 9: | ||
# fix assert syntax | # fix assert syntax | ||
# add $this->resetAfterTest() in advanced test cases that modify database | # add $this->resetAfterTest() in advanced test cases that modify database | ||
# add missing global $CFG for includes outside of testcase classes | |||
=Assert differences= | =Assert differences= | ||
=SimpleTest emulation= |
Revision as of 19:37, 20 April 2012
Overview
The migration is pretty straightforward:
- create new test file in `xxx/tests/yyy_test.php`
- copy contents of the old test file
- replace
extends UnitTestCase
withextends basic_testcase
andextends UnitTestCaseUsingDatabase
withextends advanced_testcase
- move constructor code to setUp
- fix setUp(), tearDown()
- fix assert syntax
- add $this->resetAfterTest() in advanced test cases that modify database
- add missing global $CFG for includes outside of testcase classes