MDL-51756 tests: Refactor test to use data-provider

The benefit is that this becomes one test per external function instead of one
test testing them all - so more information is shown on failure and we get lots
more dots (we love dots!).
This commit is contained in:
Andrew Nicols 2015-10-15 14:40:49 +08:00 committed by Damyon Wiese
parent 1dc4dc989d
commit 8413376088

View File

@ -265,14 +265,24 @@ class core_externallib_testcase extends advanced_testcase {
test_exernal_api::get_context_wrapper(array('roleid' => 3, 'userid' => $USER->id, 'instanceid' => $course->id));
}
public function test_all_external_info() {
public function all_external_info_provider() {
global $DB;
$functions = $DB->get_records('external_functions', array(), 'name');
// We are testing here that all the external function descriptions can be generated without
// producing warnings. E.g. misusing optional params will generate a debugging message which
// will fail this test.
$functions = $DB->get_records('external_functions', array(), 'name');
$return = array();
foreach ($functions as $f) {
$return[$f->name] = array($f);
}
return $return;
}
/**
* @dataProvider all_external_info_provider
*/
public function test_all_external_info($f) {
$desc = external_function_info($f);
$this->assertNotEmpty($desc->name);
$this->assertNotEmpty($desc->classname);
@ -283,7 +293,6 @@ class core_externallib_testcase extends advanced_testcase {
$this->assertInstanceOf('external_description', $desc->returns_desc);
}
}
}
}
/*