diff --git a/course/format/tests/external/delete_section_test.php b/course/format/tests/external/delete_section_test.php index 3b0267882e1..68eb7a18fd5 100644 --- a/course/format/tests/external/delete_section_test.php +++ b/course/format/tests/external/delete_section_test.php @@ -37,14 +37,6 @@ require_once($CFG->dirroot . '/webservice/tests/helpers.php'); */ final class delete_section_test extends \externallib_advanced_testcase { - /** - * Setup to ensure that fixtures are loaded. - */ - public static function setupBeforeClass(): void { // phpcs:ignore - global $CFG; - require_once($CFG->dirroot . '/course/format/tests/fixtures/format_theunittestdelete.php'); - } - /** * Test the webservice can execute the section_delete action. * @@ -52,16 +44,15 @@ final class delete_section_test extends \externallib_advanced_testcase { * @dataProvider section_delete_provider * @param int $sectionum * @param string $format - * @param array $formatoptions * @param int $expectedsectionum * * @throws \moodle_exception */ - public function test_delete_section(int $sectionum, string $format, array $formatoptions, int $expectedsectionum): void { + public function test_delete_section(int $sectionum, string $format, int $expectedsectionum): void { $this->resetAfterTest(); $course = - $this->getDataGenerator()->create_course(['numsections' => $sectionum, 'format' => $format, ...$formatoptions]); + $this->getDataGenerator()->create_course(['numsections' => $sectionum, 'format' => $format]); $teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher'); // Execute the method. $courseformat = course_get_format($course->id); @@ -94,21 +85,18 @@ final class delete_section_test extends \externallib_advanced_testcase { 'format topic' => [ 'sectionum' => 4, 'format' => 'topics', - 'formatoptions' => [], 'expectedsectionum' => 1, ], - 'format theunittestdelete' => [ + 'format weeks' => [ 'sectionum' => 4, - 'format' => 'theunittestdelete', - 'formatoptions' => [], + 'format' => 'weeks', + 'expectedsectionum' => 1, + ], + 'format social' => [ + 'sectionum' => 4, + 'format' => 'social', 'expectedsectionum' => 5, ], - 'format theunittestdelete can delete' => [ - 'sectionum' => 4, - 'format' => 'theunittestdelete', - 'formatoptions' => ['can_delete_sections' => true], - 'expectedsectionum' => 1, - ], ]; } } diff --git a/course/format/tests/fixtures/format_theunittestdelete.php b/course/format/tests/fixtures/format_theunittestdelete.php deleted file mode 100644 index edfae4a4082..00000000000 --- a/course/format/tests/fixtures/format_theunittestdelete.php +++ /dev/null @@ -1,63 +0,0 @@ -. - -defined('MOODLE_INTERNAL') || die(); -require_once(__DIR__ . '/format_theunittest.php'); - -/** - * Fixture for fake course format testing course format API. - * - * @package core_courseformat - * @copyright 2025 Laurent David - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ -class format_theunittestdelete extends format_theunittest { - - /** - * Definitions of the additional options that format uses - * - * @param bool $foreditform - * @return array of options - */ - public function course_format_options($foreditform = false) { - static $courseformatoptions = false; - if ($courseformatoptions === false) { - $courseformatoptions = parent::course_format_options(true); - $courseformatoptionsadditional = [ - 'can_delete_sections' => [ - 'default' => false, - 'type' => PARAM_BOOL, - ], - ]; - $courseformatoptions = array_merge_recursive($courseformatoptions, $courseformatoptionsadditional); - } - return $courseformatoptions; - } - - /** - * Whether this format allows to delete sections - * - * Here for test purpose we just can delete one section every two sections - * - * Do not call this function directly, instead use course_can_delete_section() - * - * @param int|stdClass|section_info $section - * @return bool - */ - public function can_delete_section($section) { - return $this->get_format_options()['can_delete_sections'] ?? false; - } -}