mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-37655 phpunit: Avoid having multiple testcase classes in 1 file
Note that there wasn't any case of multiple testcase classes in 1 file. All the cases reported in the issue were false positives caused but other "mock/fixture" files being named _test. So all this issue does is: 1) rename any _test suffixed class in test files, because we are going to start renaming a lot of test classes to _test. 2) ensure that the 2 test case classes modified in this issue, are already observing the filename = classname rule that will be implemented soon (and verigy it works).
This commit is contained in:
parent
f0eb6a5729
commit
870a8de3fb
@ -145,7 +145,7 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
$this->expectOutputRegex($ouputregex);
|
||||
|
||||
$finder = new tool_httpreplace_url_finder_test();
|
||||
$finder = new tool_httpreplace_url_finder_mock();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$course = $generator->create_course((object) [
|
||||
@ -216,7 +216,7 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
public function test_http_link_stats($content, $domain, $expectedcount) {
|
||||
$this->resetAfterTest();
|
||||
|
||||
$finder = new tool_httpreplace_url_finder_test();
|
||||
$finder = new tool_httpreplace_url_finder_mock();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$course = $generator->create_course((object) [
|
||||
@ -237,7 +237,7 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
$this->expectOutputRegex('/^$/');
|
||||
|
||||
$finder = new tool_httpreplace_url_finder_test();
|
||||
$finder = new tool_httpreplace_url_finder_mock();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$course = $generator->create_course((object) [
|
||||
@ -269,7 +269,7 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
$CFG->wwwroot = preg_replace('/^https:/', 'http:', $CFG->wwwroot);
|
||||
$this->expectOutputRegex('/^$/');
|
||||
|
||||
$finder = new tool_httpreplace_url_finder_test();
|
||||
$finder = new tool_httpreplace_url_finder_mock();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$course = $generator->create_course((object) [
|
||||
@ -292,7 +292,7 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
|
||||
set_config('test_upgrade_http_links', '<img src="http://somesite/someimage.png" />');
|
||||
|
||||
$finder = new tool_httpreplace_url_finder_test();
|
||||
$finder = new tool_httpreplace_url_finder_mock();
|
||||
ob_start();
|
||||
$results = $finder->upgrade_http_links();
|
||||
$output = ob_get_contents();
|
||||
@ -318,7 +318,7 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
|
||||
set_config('renames', json_encode($renames), 'tool_httpsreplace');
|
||||
|
||||
$finder = new tool_httpreplace_url_finder_test();
|
||||
$finder = new tool_httpreplace_url_finder_mock();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$course = $generator->create_course((object) [
|
||||
@ -353,7 +353,7 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
$original2 .= '<img src="http://example.com/image' . ($i + 15 ) . '.png">';
|
||||
$expected2 .= '<img src="https://example.com/image' . ($i + 15) . '.png">';
|
||||
}
|
||||
$finder = new tool_httpreplace_url_finder_test();
|
||||
$finder = new tool_httpreplace_url_finder_mock();
|
||||
|
||||
$generator = $this->getDataGenerator();
|
||||
$course1 = $generator->create_course((object) ['summary' => $original1]);
|
||||
@ -397,7 +397,7 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
$columnamequoted = $dbman->generator->getEncQuoted('where');
|
||||
$DB->execute("INSERT INTO {reserved_words_temp} ($columnamequoted) VALUES (?)", [$content]);
|
||||
|
||||
$finder = new tool_httpreplace_url_finder_test();
|
||||
$finder = new tool_httpreplace_url_finder_mock();
|
||||
$finder->upgrade_http_links();
|
||||
|
||||
$record = $DB->get_record('reserved_words_temp', []);
|
||||
@ -408,13 +408,13 @@ class httpsreplace_test extends \advanced_testcase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Class tool_httpreplace_url_finder_test for testing replace tool without calling curl
|
||||
* Class tool_httpreplace_url_finder_mock for testing replace tool without calling curl
|
||||
*
|
||||
* @package tool_httpsreplace
|
||||
* @copyright 2017 Marina Glancy
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class tool_httpreplace_url_finder_test extends \tool_httpsreplace\url_finder {
|
||||
class tool_httpreplace_url_finder_mock extends \tool_httpsreplace\url_finder {
|
||||
/**
|
||||
* Check if url is available (check hardcoded for unittests)
|
||||
*
|
||||
|
@ -36,7 +36,7 @@ use core_files\converter;
|
||||
* @copyright 2017 Andrew nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_files_converter_testcase extends advanced_testcase {
|
||||
class converter_test extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Get a testable mock of the abstract files_converter class.
|
||||
@ -247,7 +247,7 @@ class core_files_converter_testcase extends advanced_testcase {
|
||||
* Test the get_document_converter_classes function when the returned classes do not meet requirements.
|
||||
*/
|
||||
public function test_get_document_converter_classes_plugin_class_requirements_not_met() {
|
||||
$plugin = $this->getMockBuilder(\core_file_converter_requirements_not_met_test::class)
|
||||
$plugin = $this->getMockBuilder(\core_file_converter_requirements_not_met::class)
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
|
||||
@ -266,7 +266,7 @@ class core_files_converter_testcase extends advanced_testcase {
|
||||
* Test the get_document_converter_classes function when the returned classes do not meet requirements.
|
||||
*/
|
||||
public function test_get_document_converter_classes_plugin_class_met_not_supported() {
|
||||
$plugin = $this->getMockBuilder(\core_file_converter_type_not_supported_test::class)
|
||||
$plugin = $this->getMockBuilder(\core_file_converter_type_not_supported::class)
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
|
||||
@ -285,7 +285,7 @@ class core_files_converter_testcase extends advanced_testcase {
|
||||
* Test the get_document_converter_classes function when the returned classes do not meet requirements.
|
||||
*/
|
||||
public function test_get_document_converter_classes_plugin_class_met_and_supported() {
|
||||
$plugin = $this->getMockBuilder(\core_file_converter_type_supported_test::class)
|
||||
$plugin = $this->getMockBuilder(\core_file_converter_type_supported::class)
|
||||
->onlyMethods([])
|
||||
->getMock();
|
||||
$classname = get_class($plugin);
|
||||
@ -741,7 +741,7 @@ class core_files_converter_testcase extends advanced_testcase {
|
||||
}
|
||||
}
|
||||
|
||||
class core_file_converter_requirements_test_base implements \core_files\converter_interface {
|
||||
class core_file_converter_requirements_base implements \core_files\converter_interface {
|
||||
|
||||
/**
|
||||
* Whether the plugin is configured and requirements are met.
|
||||
@ -799,7 +799,7 @@ class core_file_converter_requirements_test_base implements \core_files\converte
|
||||
* @copyright 2017 Andrew nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_file_converter_requirements_not_met_test extends core_file_converter_requirements_test_base {
|
||||
class core_file_converter_requirements_not_met extends core_file_converter_requirements_base {
|
||||
}
|
||||
|
||||
/**
|
||||
@ -809,7 +809,7 @@ class core_file_converter_requirements_not_met_test extends core_file_converter_
|
||||
* @copyright 2017 Andrew nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_file_converter_type_not_supported_test extends core_file_converter_requirements_test_base {
|
||||
class core_file_converter_type_not_supported extends core_file_converter_requirements_base {
|
||||
|
||||
/**
|
||||
* Whether the plugin is configured and requirements are met.
|
||||
@ -828,7 +828,7 @@ class core_file_converter_type_not_supported_test extends core_file_converter_re
|
||||
* @copyright 2017 Andrew nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_file_converter_type_supported_test extends core_file_converter_requirements_test_base {
|
||||
class core_file_converter_type_supported extends core_file_converter_requirements_base {
|
||||
|
||||
/**
|
||||
* Whether the plugin is configured and requirements are met.
|
||||
@ -858,7 +858,7 @@ class core_file_converter_type_supported_test extends core_file_converter_requir
|
||||
* @copyright 2017 Andrew nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_file_converter_type_successful extends core_file_converter_requirements_test_base {
|
||||
class core_file_converter_type_successful extends core_file_converter_requirements_base {
|
||||
|
||||
/**
|
||||
* Convert a document to a new format and return a conversion object relating to the conversion in progress.
|
||||
@ -891,7 +891,7 @@ class core_file_converter_type_successful extends core_file_converter_requiremen
|
||||
* @copyright 2017 Andrew nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_file_converter_type_failed extends core_file_converter_requirements_test_base {
|
||||
class core_file_converter_type_failed extends core_file_converter_requirements_base {
|
||||
|
||||
/**
|
||||
* Whether the plugin is configured and requirements are met.
|
||||
|
@ -32,7 +32,7 @@ require_once($CFG->dirroot.'/grade/report/lib.php');
|
||||
/**
|
||||
* A test class used to test grade_report, the abstract grade report parent class
|
||||
*/
|
||||
class grade_report_test extends grade_report {
|
||||
class grade_report_mock extends grade_report {
|
||||
public function __construct($courseid, $gpr, $context, $user) {
|
||||
parent::__construct($courseid, $gpr, $context);
|
||||
$this->user = $user;
|
||||
@ -61,7 +61,7 @@ class grade_report_test extends grade_report {
|
||||
/**
|
||||
* Tests grade_report, the parent class for all grade reports.
|
||||
*/
|
||||
class core_grade_reportlib_testcase extends advanced_testcase {
|
||||
class reportlib_test extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Tests grade_report::blank_hidden_total_and_adjust_bounds()
|
||||
@ -117,7 +117,7 @@ class core_grade_reportlib_testcase extends advanced_testcase {
|
||||
set_coursemodule_visible($datacm->id, 0);
|
||||
|
||||
$gpr = new grade_plugin_return(array('type' => 'report', 'courseid' => $course->id));
|
||||
$report = new grade_report_test($course->id, $gpr, $coursecontext, $student);
|
||||
$report = new grade_report_mock($course->id, $gpr, $coursecontext, $student);
|
||||
|
||||
// Should return the supplied student total grade regardless of hiding.
|
||||
$report->showtotalsifcontainhidden = array($course->id => GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN);
|
||||
@ -193,7 +193,7 @@ class core_grade_reportlib_testcase extends advanced_testcase {
|
||||
set_coursemodule_visible($forumcm->id, 0);
|
||||
|
||||
$gpr = new grade_plugin_return(array('type' => 'report', 'courseid' => $course->id));
|
||||
$report = new grade_report_test($course->id, $gpr, $coursecontext, $student);
|
||||
$report = new grade_report_mock($course->id, $gpr, $coursecontext, $student);
|
||||
|
||||
// Should return the supplied student total grade regardless of hiding.
|
||||
$report->showtotalsifcontainhidden = array($course->id => GRADE_REPORT_SHOW_REAL_TOTAL_IF_CONTAINS_HIDDEN);
|
||||
|
@ -35,7 +35,7 @@ require_once($CFG->libdir.'/portfolio/formats.php');
|
||||
* @copyright 2014 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_portfoliolib_testcase extends advanced_testcase {
|
||||
class portfoliolib_test extends advanced_testcase {
|
||||
|
||||
public function test_portfolio_rewrite_pluginfile_urls() {
|
||||
$this->resetAfterTest();
|
||||
@ -78,7 +78,7 @@ class core_portfoliolib_testcase extends advanced_testcase {
|
||||
$this->assertSame($input, $output);
|
||||
|
||||
// Now use our dummy format.
|
||||
$format = new core_portfolio_format_dummytest();
|
||||
$format = new core_portfolio_format_dummy();
|
||||
$options = null;
|
||||
|
||||
// Test that the link is matching.
|
||||
@ -155,7 +155,7 @@ class core_portfoliolib_testcase extends advanced_testcase {
|
||||
* @copyright 2014 Frédéric Massart
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class core_portfolio_format_dummytest extends portfolio_format {
|
||||
class core_portfolio_format_dummy extends portfolio_format {
|
||||
|
||||
public static function file_output($file, $options = null) {
|
||||
if (isset($options['attributes']) && is_array($options['attributes'])) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user