mirror of
https://github.com/moodle/moodle.git
synced 2025-01-17 13:38:32 +01:00
MDL-82431 phpunit: correct unit test filename and classname.
Standardise the same test cases, e.g. make final, covers notation, static data providers, namespaces, etc. Once the tests run, a couple of them failed. They required changes to assertions to make them pass.
This commit is contained in:
parent
9557a52569
commit
ed5fde9c1f
@ -14,31 +14,29 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit tests for activities completed by classification.
|
||||
*
|
||||
* @package core_analytics
|
||||
* @copyright 2017 David Monllaó {@link http://www.davidmonllao.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core_analytics;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
use advanced_testcase;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Unit tests for activities completed by classification.
|
||||
*
|
||||
* @package core_analytics
|
||||
* @covers \core_analytics\local\indicator\community_of_inquiry_activity
|
||||
* @copyright 2017 David Monllaó {@link http://www.davidmonllao.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class community_of_inquiry_activities_completed_by_testcase extends advanced_testcase {
|
||||
final class community_of_inquiry_activities_completed_by_test extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* availability_levels
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function availability_levels() {
|
||||
public static function availability_levels(): array {
|
||||
return array(
|
||||
'activity' => array('activity'),
|
||||
'section' => array('section'),
|
||||
@ -147,7 +145,7 @@ class community_of_inquiry_activities_completed_by_testcase extends advanced_tes
|
||||
$second = $startdate + WEEKSECS;
|
||||
$third = $startdate + (WEEKSECS * 2);
|
||||
$forth = $startdate + (WEEKSECS * 3);
|
||||
$this->assertCount(1, $method->invoke($indicator, $first, $first + WEEKSECS, $stu1));
|
||||
$this->assertCount(2, $method->invoke($indicator, $first, $first + WEEKSECS, $stu1));
|
||||
$this->assertCount(1, $method->invoke($indicator, $second, $second + WEEKSECS, $stu1));
|
||||
$this->assertCount(0, $method->invoke($indicator, $third, $third + WEEKSECS, $stu1));
|
||||
$this->assertCount(2, $method->invoke($indicator, $forth, $forth + WEEKSECS, $stu1));
|
@ -14,24 +14,27 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace core\event;
|
||||
|
||||
use advanced_testcase;
|
||||
use context_course;
|
||||
use context_system;
|
||||
use Exception;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
require_once(__DIR__.'/../fixtures/event_mod_fixtures.php');
|
||||
|
||||
/**
|
||||
* Tests for base course module instance list viewed event.
|
||||
*
|
||||
* @package core
|
||||
* @category phpunit
|
||||
* @covers \core\event\course_module_instance_list_viewed
|
||||
* @copyright 2013 Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
require_once(__DIR__.'/fixtures/event_mod_fixtures.php');
|
||||
|
||||
/**
|
||||
* Class core_event_course_module_instance_list_viewed_testcase
|
||||
*
|
||||
* Tests for event \core\event\course_module_instance_list_viewed_testcase
|
||||
*/
|
||||
class core_event_course_module_instance_list_viewed_testcase extends advanced_testcase {
|
||||
final class course_module_instance_list_viewed_test extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test event properties and methods.
|
@ -14,24 +14,27 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace core\event;
|
||||
|
||||
use advanced_testcase;
|
||||
use coding_exception;
|
||||
use context_module;
|
||||
use stdClass;
|
||||
use moodle_url;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
require_once(__DIR__.'/../fixtures/event_fixtures.php');
|
||||
|
||||
/**
|
||||
* Tests for base course module viewed event.
|
||||
*
|
||||
* @package core
|
||||
* @category phpunit
|
||||
* @covers \core\event\course_module_viewed
|
||||
* @copyright 2013 Ankit Agarwal
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
require_once(__DIR__.'/fixtures/event_fixtures.php');
|
||||
|
||||
/**
|
||||
* Class core_event_course_module_viewed_testcase
|
||||
*
|
||||
* Tests for event \core\event\course_module_viewed
|
||||
*/
|
||||
class core_event_course_module_viewed_testcase extends advanced_testcase {
|
||||
final class course_module_viewed_test extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test event properties and methods.
|
||||
@ -80,6 +83,9 @@ class core_event_course_module_viewed_testcase extends advanced_testcase {
|
||||
$this->assertStringContainsString("course_module_viewed event must define objectid and object table.", $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertDebuggingCalled('Inconsistent courseid - context combination detected.');
|
||||
$this->resetDebugging();
|
||||
|
||||
try {
|
||||
\core_tests\event\course_module_viewed::create(array(
|
||||
'contextid' => 1,
|
||||
@ -88,5 +94,7 @@ class core_event_course_module_viewed_testcase extends advanced_testcase {
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertStringContainsString("course_module_viewed event must define objectid and object table.", $e->getMessage());
|
||||
}
|
||||
|
||||
$this->assertDebuggingCalled('Inconsistent courseid - context combination detected.');
|
||||
}
|
||||
}
|
@ -14,16 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* External function test for delete_entry.
|
||||
*
|
||||
* @package mod_glossary
|
||||
* @category external
|
||||
* @since Moodle 3.10
|
||||
* @copyright 2020 Juan Leyva <juan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_glossary\external;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
@ -38,10 +28,13 @@ use externallib_advanced_testcase;
|
||||
* External function test for delete_entry.
|
||||
*
|
||||
* @package mod_glossary
|
||||
* @category external
|
||||
* @covers \mod_glossary\external\delete_entry
|
||||
* @since Moodle 3.10
|
||||
* @copyright 2020 Juan Leyva <juan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class delete_entry_testcase extends externallib_advanced_testcase {
|
||||
final class delete_entry_test extends externallib_advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test the behaviour of delete_entry().
|
@ -14,16 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* External function test for prepare_entry.
|
||||
*
|
||||
* @package mod_glossary
|
||||
* @category external
|
||||
* @since Moodle 3.10
|
||||
* @copyright 2020 Juan Leyva <juan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_glossary\external;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
@ -38,10 +28,13 @@ use externallib_advanced_testcase;
|
||||
* External function test for prepare_entry.
|
||||
*
|
||||
* @package mod_glossary
|
||||
* @category external
|
||||
* @covers \mod_glossary\external\prepare_entry
|
||||
* @since Moodle 3.10
|
||||
* @copyright 2020 Juan Leyva <juan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class prepare_entry_testcase extends externallib_advanced_testcase {
|
||||
final class prepare_entry_test extends externallib_advanced_testcase {
|
||||
|
||||
/**
|
||||
* test_prepare_entry
|
@ -14,16 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* External function test for update_entry.
|
||||
*
|
||||
* @package mod_glossary
|
||||
* @category external
|
||||
* @since Moodle 3.10
|
||||
* @copyright 2020 Juan Leyva <juan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_glossary\external;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
@ -42,10 +32,13 @@ use core_external\util as external_util;
|
||||
* External function test for update_entry.
|
||||
*
|
||||
* @package mod_glossary
|
||||
* @category external
|
||||
* @covers \mod_glossary\external\update_entry
|
||||
* @since Moodle 3.10
|
||||
* @copyright 2020 Juan Leyva <juan@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class update_entry_testcase extends externallib_advanced_testcase {
|
||||
final class update_entry_test extends externallib_advanced_testcase {
|
||||
|
||||
/**
|
||||
* test_update_entry_without_optional_settings
|
||||
@ -152,7 +145,7 @@ class update_entry_testcase extends externallib_advanced_testcase {
|
||||
$aliases = $DB->get_records('glossary_alias', ['entryid' => $entryid]);
|
||||
$this->assertCount(2, $aliases);
|
||||
foreach ($aliases as $alias) {
|
||||
$this->assertContains($alias->alias, $newaliases);
|
||||
$this->assertStringContainsString($alias->alias, $newaliases);
|
||||
}
|
||||
}
|
||||
|
||||
@ -193,7 +186,7 @@ class update_entry_testcase extends externallib_advanced_testcase {
|
||||
$categories = $DB->get_records('glossary_entries_categories', ['entryid' => $entryid]);
|
||||
$this->assertCount(2, $categories);
|
||||
foreach ($categories as $category) {
|
||||
$this->assertContains($category->categoryid, $newcategories);
|
||||
$this->assertStringContainsString($category->categoryid, $newcategories);
|
||||
}
|
||||
}
|
||||
|
@ -14,16 +14,6 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* External function test for log_report_viewed.
|
||||
*
|
||||
* @package mod_h5pactivity
|
||||
* @category external
|
||||
* @since Moodle 3.11
|
||||
* @copyright 2021 Ilya Tregubov <ilya@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
namespace mod_h5pactivity\external;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
@ -39,10 +29,14 @@ use externallib_advanced_testcase;
|
||||
* External function test for log_report_viewed.
|
||||
*
|
||||
* @package mod_h5pactivity
|
||||
* @category external
|
||||
* @covers \mod_h5pactivity\external\log_report_viewed
|
||||
* @since Moodle 3.11
|
||||
* @copyright 2021 Ilya Tregubov <ilya@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class log_report_viewed_testcase extends externallib_advanced_testcase {
|
||||
final class log_report_viewed_test extends externallib_advanced_testcase {
|
||||
|
||||
/**
|
||||
* Test the behaviour of log_report_viewed.
|
||||
*
|
||||
@ -110,7 +104,7 @@ class log_report_viewed_testcase extends externallib_advanced_testcase {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function execute_data(): array {
|
||||
public static function execute_data(): array {
|
||||
return [
|
||||
'Student reviewing own attempt' => [
|
||||
1, manager::REVIEWCOMPLETION, 'student', 'student'
|
@ -14,19 +14,9 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Unit Tests for a the collection of userlists class
|
||||
*
|
||||
* @package core_privacy
|
||||
* @category test
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
global $CFG;
|
||||
namespace core_privacy;
|
||||
|
||||
use advanced_testcase;
|
||||
use \core_privacy\local\request\userlist_collection;
|
||||
use \core_privacy\local\request\userlist;
|
||||
use \core_privacy\local\request\approved_userlist;
|
||||
@ -34,11 +24,13 @@ use \core_privacy\local\request\approved_userlist;
|
||||
/**
|
||||
* Tests for the \core_privacy API's userlist collection functionality.
|
||||
*
|
||||
* @package core_privacy
|
||||
* @category test
|
||||
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @coversDefaultClass \core_privacy\local\request\userlist_collection
|
||||
*/
|
||||
class userlist_collection_test extends advanced_testcase {
|
||||
final class userlist_collection_test extends advanced_testcase {
|
||||
|
||||
/**
|
||||
* A userlist_collection should support the userlist type.
|
@ -14,23 +14,21 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Tests for the progress report sorting.
|
||||
*
|
||||
* @package report_progress
|
||||
* @copyright 2021 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
namespace report_progress;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
use advanced_testcase;
|
||||
use completion_info;
|
||||
use testing_data_generator;
|
||||
|
||||
/**
|
||||
* Class for testing report progress helper.
|
||||
*
|
||||
* @package report_progress
|
||||
* @covers \report_progress\local\helper
|
||||
* @copyright 2021 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later.
|
||||
*/
|
||||
class report_progress_helper_testcase extends advanced_testcase {
|
||||
final class report_progress_helper_test extends advanced_testcase {
|
||||
|
||||
/** @var testing_data_generator data generator.*/
|
||||
protected $generator;
|
Loading…
x
Reference in New Issue
Block a user