Skip to content

Commit

Permalink
Merge branch 'w14_MDL-32250_m23_simpletest110' of git://github.com/sk…
Browse files Browse the repository at this point in the history
…odak/moodle
  • Loading branch information
danpoltawski committed Apr 2, 2012
2 parents 6461e14 + 97621c3 commit 8408d23
Show file tree
Hide file tree
Showing 88 changed files with 17,428 additions and 5,837 deletions.
6 changes: 3 additions & 3 deletions admin/tool/unittest/ex_reporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class ExHtmlReporter extends HtmlReporter {
*
* @param bool $showpasses Whether this reporter should output anything for passes.
*/
function ExHtmlReporter($showpasses) {
$this->HtmlReporter();
function __construct($showpasses) {
parent::__construct('UTF-8');
$this->showpasses = $showpasses;

$this->strrunonlyfolder = $this->get_string('runonlyfolder');
Expand Down Expand Up @@ -254,7 +254,7 @@ function paintFooter($test_name) {
echo '<div class="performanceinfo">',
$this->get_string('runat', userdate($this->timestart)), ' ',
$this->get_string('timetakes', format_time(time() - $this->timestart)), ' ',
$this->get_string('version', SimpleTestOptions::getVersion()),
$this->get_string('version', SimpleTest::getVersion()),
'</div>';
}

Expand Down
15 changes: 8 additions & 7 deletions admin/tool/unittest/ex_simple_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function AutoGroupTest($showsearch, $test_name = null) {
$this->showsearch = $showsearch;
}

function run(&$reporter) {
function run($reporter) {
global $UNITTEST;

$UNITTEST->running = true;
Expand Down Expand Up @@ -85,7 +85,7 @@ function _recurseFolders($path) {

$s_count++;
// OK, found: this shows as a 'Notice' for any 'simpletest/test*.php' file.
$this->addTestCase(new FindFileNotice($file_path, 'Found unit test file, '. $s_count));
$this->add(new FindFileNotice($file_path, 'Found unit test file, '. $s_count));

// addTestFile: Unfortunately this doesn't return fail/success (bool).
$this->addTestFile($file_path, true);
Expand All @@ -105,9 +105,9 @@ function findTestFiles($dir) {
$path = $dir;
$count = $this->_recurseFolders($path);
if ($count <= 0) {
$this->addTestCase(new BadAutoGroupTest($path, 'Search complete. No unit test files found'));
$this->add(new BadAutoGroupTest($path, 'Search complete. No unit test files found'));
} else {
$this->addTestCase(new AutoGroupTestNotice($path, 'Search complete. Total unit test files found: '. $count));
$this->add(new AutoGroupTestNotice($path, 'Search complete. Total unit test files found: '. $count));
}
if ($this->showsearch) {
echo '</ul>';
Expand All @@ -116,6 +116,7 @@ function findTestFiles($dir) {
}

function addTestFile($file, $internalcall = false) {

if ($this->showsearch) {
if ($internalcall) {
echo '<li><b>' . basename($file) . '</b></li>';
Expand All @@ -126,10 +127,10 @@ function addTestFile($file, $internalcall = false) {
// get blank screens because evil people turn down error_reporting elsewhere.
error_reporting(E_ALL);
}
if(!is_file($file) ){
parent::addTestCase(new BadTest($file, 'Not a file or does not exist'));
if (!is_file($file) ){
parent::add(new BadTest($file, 'Not a file or does not exist'));
}
parent::addTestFile($file);
parent::addFile($file);
}
}

Expand Down
4 changes: 2 additions & 2 deletions admin/tool/unittest/simpletestcoveragelib.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function add_coverage_exclude_path($path) {
* automatically generating the coverage report. Only supports one instrumentation
* to be executed and reported.
*/
public function run(&$simpletestreporter) {
public function run($simpletestreporter) {
global $CFG;

if (moodle_coverage_recorder::can_run_codecoverage() && $this->performcoverage) {
Expand All @@ -148,7 +148,7 @@ public function run(&$simpletestreporter) {
* allowing further process of coverage data once tests are over. Supports multiple
* instrumentations (code coverage gathering sessions) to be executed.
*/
public function run_with_external_coverage(&$simpletestreporter, &$covrecorder) {
public function run_with_external_coverage($simpletestreporter, $covrecorder) {

if (moodle_coverage_recorder::can_run_codecoverage() && $this->performcoverage) {
$covrecorder->setIncludePaths($this->includecoverage);
Expand Down
16 changes: 8 additions & 8 deletions admin/tool/unittest/simpletestlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ function recurseFolders($path, $callback, $fileregexp = '/.*/', $exclude = false
class IgnoreWhitespaceExpectation extends SimpleExpectation {
var $expect;

function IgnoreWhitespaceExpectation($content, $message = '%s') {
$this->SimpleExpectation($message);
function __construct($content, $message = '%s') {
parent::__construct($message);
$this->expect=$this->normalise($content);
}

Expand Down Expand Up @@ -111,8 +111,8 @@ function testMessage($ip) {
class ArraysHaveSameValuesExpectation extends SimpleExpectation {
var $expect;

function ArraysHaveSameValuesExpectation($expected, $message = '%s') {
$this->SimpleExpectation($message);
function __construct($expected, $message = '%s') {
parent::__construct($message);
if (!is_array($expected)) {
trigger_error('Attempt to create an ArraysHaveSameValuesExpectation ' .
'with an expected value that is not an array.');
Expand Down Expand Up @@ -149,8 +149,8 @@ function testMessage($actual) {
class CheckSpecifiedFieldsExpectation extends SimpleExpectation {
var $expect;

function CheckSpecifiedFieldsExpectation($expected, $message = '%s') {
$this->SimpleExpectation($message);
function __construct($expected, $message = '%s') {
parent::__construct($message);
if (!is_object($expected)) {
trigger_error('Attempt to create a CheckSpecifiedFieldsExpectation ' .
'with an expected value that is not an object.');
Expand Down Expand Up @@ -651,7 +651,7 @@ public function __construct($label = false) {
}

// Only do this after the above text.
parent::UnitTestCase($label);
parent::__construct($label);

// Create the test DB instance.
$this->realdb = $DB;
Expand Down Expand Up @@ -974,7 +974,7 @@ public function __construct($label = false) {
return;
}

parent::UnitTestCase($label);
parent::__construct($label);
// MDL-16483 Get PKs and save data to text file

$this->pkfile = $CFG->dataroot.'/testtablespks.csv';
Expand Down
28 changes: 14 additions & 14 deletions lib/simpletest/testcompletionlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ function test_update_state() {
new TimeModifiedExpectation(array('completionstate'=>COMPLETION_COMPLETE_PASS))));
$c->update_state($cm,COMPLETION_COMPLETE_PASS);

$c->tally();
//$c->tally();
}

function test_internal_get_state() {
Expand Down Expand Up @@ -242,8 +242,8 @@ function test_internal_get_state() {
// * the grade_item/grade_grade calls are static and can't be mocked
// * the plugin_supports call is static and can't be mocked

$DB->tally();
$c->tally();
//$DB->tally();
//$c->tally();
}

function test_set_module_viewed() {
Expand Down Expand Up @@ -281,7 +281,7 @@ function test_set_module_viewed() {
$c->expectOnce('update_state',array($cm,COMPLETION_COMPLETE,1337));
$c->set_module_viewed($cm,1337);

$c->tally();
//$c->tally();
}

function test_count_user_data() {
Expand All @@ -298,7 +298,7 @@ function test_count_user_data() {
$c=new completion_info($course);
$this->assertEqual(666,$c->count_user_data($cm));

$DB->tally();
//$DB->tally();
}

function test_delete_all_state() {
Expand All @@ -325,7 +325,7 @@ function test_delete_all_state() {
$this->assertEqual(array(13=>array(43=>'foo'),14=>array(42=>'foo')),
$SESSION->completioncache);

$DB->tally();
//$DB->tally();
}

function test_reset_all_state() {
Expand Down Expand Up @@ -355,8 +355,8 @@ function test_reset_all_state() {

$c->reset_all_state($cm);

$DB->tally();
$c->tally();
//$DB->tally();
//$c->tally();
}

function test_get_data() {
Expand Down Expand Up @@ -447,7 +447,7 @@ function test_get_data() {
'id'=>'0','coursemoduleid'=>14,'userid'=>314159,'completionstate'=>0,
'viewed'=>0,'timemodified'=>0),'updated'=>$now)),$SESSION->completioncache);

$DB->tally();
//$DB->tally();
}

function test_internal_set_data() {
Expand Down Expand Up @@ -487,7 +487,7 @@ function test_internal_set_data() {
$DB->expectAt(1,'update_record', array('course_modules_completion', $d3));
$c->internal_set_data($cm, $data);

$DB->tally();
//$DB->tally();
}

function test_get_activities() {
Expand All @@ -514,7 +514,7 @@ function test_get_activities() {
$result=$c->get_activities($modinfo);
$this->assertEqual(array(13=>(object)array('id'=>13,'modname'=>'frog','name'=>'kermit')),$result);

$DB->tally();
//$DB->tally();
}

// get_tracked_users() cannot easily be tested because it uses
Expand Down Expand Up @@ -606,8 +606,8 @@ function test_get_progress_all() {
}
$this->assertTrue($resultok);

$DB->tally();
$c->tally();
//$DB->tally();
//$c->tally();
}

function test_inform_grade_changed() {
Expand Down Expand Up @@ -652,7 +652,7 @@ function test_inform_grade_changed() {
$c->expectAt(1,'update_state',array($cm,COMPLETION_INCOMPLETE,31337));
$c->inform_grade_changed($cm,$item,$grade,false);

$c->tally();
//$c->tally();
}

function test_internal_get_grade_state() {
Expand Down
59 changes: 55 additions & 4 deletions lib/simpletestlib/HELP_MY_TESTS_DONT_WORK_ANYMORE
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,64 @@ written with earlier versions will fail with the newest ones. The most
dramatic changes are in the alpha releases. Here is a list of possible
problems and their fixes...

assertText() no longer finds a string inside a <script> tag
-----------------------------------------------------------
The assertText() method is intended to match only visible,
human-readable text on the web page. Therefore, the contents of script
tags should not be matched by this assertion. However there was a bug
in the text normalisation code of simpletest which meant that <script>
tags spanning multiple lines would not have their content stripped
out. If you want to check the content of a <script> tag, use
assertPattern(), or write a custom expectation.

Overloaded method not working
-----------------------------
All protected and private methods had underscores
removed. This means that any private/protected methods that
you overloaded with those names need to be updated.

Fatal error: Call to undefined method Classname::classname()
------------------------------------------------------------
SimpleTest renamed all of its constructors from
Classname to __construct; derived classes invoking
their parent constructors should replace parent::Classname()
with parent::__construct().

Custom CSS in HtmlReporter not being applied
--------------------------------------------
Batch rename of protected and private methods
means that _getCss() was renamed to getCss().
Please rename your method and it should work again.

setReturnReference() throws errors in E_STRICT
----------------------------------------------
Happens when an object is passed by reference.
This also happens with setReturnReferenceAt().
If you want to return objects then replace these
with calls to returns() and returnsAt() with the
same arguments. This change was forced in the 1.1
version for E_STRICT compatibility.

assertReference() throws errors in E_STRICT
-------------------------------------------
Due to language restrictions you cannot compare
both variables and objects in E_STRICT mode. Use
assertSame() in this mode with objects. This change
was forced the 1.1 version.

Cannot create GroupTest
-----------------------
The GroupTest has been renamed TestSuite (see below).
It was removed completely in 1.1 in favour of this
name.

No method getRelativeUrls() or getAbsoluteUrls()
------------------------------------------------
These methods were always a bit weird anyway, and
the new parsing of the base tag makes them more so.
They have been replaced with getUrls() instead. If
you want the old functionality then simply chop
off the current domain from getUrl().
off the current domain from getUrls().

Method setWildcard() removed in mocks
-------------------------------------
Expand Down Expand Up @@ -48,7 +99,7 @@ getTransferError() call on the web tester to see if
there was a socket level error in a fetch. This check
is now always carried out by the WebTestCase unless
the fetch is prefaced with WebTestCase::ignoreErrors().
The ignore directive only lasts for test case fetching
The ignore directive only lasts for the next fetching
action such as get() and click().

No method SimpleTestOptions::ignore()
Expand Down Expand Up @@ -289,13 +340,13 @@ test case expansion against the ease of writing user interfaces.

Code such as...

$test = new MyTestCase();
$test = &new MyTestCase();
$test->attachObserver(new TestHtmlDisplay());
$test->run();

...should be rewritten as...

$test = new MyTestCase();
$test = &new MyTestCase();
$test->run(new HtmlReporter());

If you previously attached multiple observers then the workaround
Expand Down
Empty file modified lib/simpletestlib/LICENSE
100644 → 100755
Empty file.
Loading

0 comments on commit 8408d23

Please sign in to comment.