MDL-68483 contentbank: remove unneeded MOODLE_INTERNAL

These improvements were suggested by Eloy when MDL-67795 and other
content bank issues (such as MDL-67790) were integrated.
This commit is contained in:
Sara Arjona 2020-05-06 10:07:10 +02:00
parent 54ce66bd76
commit f3126f84b4
6 changed files with 45 additions and 30 deletions

View File

@ -25,15 +25,10 @@
namespace core_contentbank;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php');
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_content.php');
use stdClass;
use context_system;
use contenttype_testable\contenttype as contenttype;
/**
* Test for content bank contenttype class.
*
@ -46,6 +41,16 @@ use contenttype_testable\contenttype as contenttype;
*/
class core_contenttype_content_testcase extends \advanced_testcase {
/**
* Setup to ensure that fixtures are loaded.
*/
public static function setupBeforeClass(): void {
global $CFG;
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php');
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_content.php');
}
/**
* Tests for behaviour of get_name().
*

View File

@ -23,10 +23,11 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
namespace core_contentbank;
global $CFG;
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php');
use advanced_testcase;
use context_course;
use context_system;
/**
* Test for extensions manager.
@ -38,6 +39,16 @@ require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.p
* @coversDefaultClass \core_contentbank\contentbank
*/
class core_contentbank_testcase extends advanced_testcase {
/**
* Setup to ensure that fixtures are loaded.
*/
public static function setupBeforeClass(): void {
global $CFG;
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php');
}
/**
* Data provider for test_get_extension_supporter.
*
@ -62,7 +73,7 @@ class core_contentbank_testcase extends advanced_testcase {
public function test_get_extension(string $filename, string $expected) {
$this->resetAfterTest();
$cb = new \core_contentbank\contentbank();
$cb = new contentbank();
$extension = $cb->get_extension($filename);
$this->assertEquals($expected, $extension);
@ -93,7 +104,7 @@ class core_contentbank_testcase extends advanced_testcase {
public function test_get_extension_supporter_for_admins(array $supporters, string $extension, string $expected) {
$this->resetAfterTest();
$cb = new \core_contentbank\contentbank();
$cb = new contentbank();
$expectedsupporters = [$extension => $expected];
$systemcontext = context_system::instance();
@ -117,7 +128,7 @@ class core_contentbank_testcase extends advanced_testcase {
public function test_get_extension_supporter_for_users(array $supporters, string $extension, string $expected) {
$this->resetAfterTest();
$cb = new \core_contentbank\contentbank();
$cb = new contentbank();
$systemcontext = context_system::instance();
// Set a user with no permissions.
@ -142,7 +153,7 @@ class core_contentbank_testcase extends advanced_testcase {
public function test_get_extension_supporter_for_teachers(array $supporters, string $extension, string $expected) {
$this->resetAfterTest();
$cb = new \core_contentbank\contentbank();
$cb = new contentbank();
$expectedsupporters = [$extension => $expected];
$course = $this->getDataGenerator()->create_course();
@ -168,7 +179,7 @@ class core_contentbank_testcase extends advanced_testcase {
public function test_get_extension_supporter(array $supporters, string $extension, string $expected) {
$this->resetAfterTest();
$cb = new \core_contentbank\contentbank();
$cb = new contentbank();
$systemcontext = context_system::instance();
$this->setAdminUser();
@ -219,7 +230,7 @@ class core_contentbank_testcase extends advanced_testcase {
}
// Search for some content.
$cb = new \core_contentbank\contentbank();
$cb = new contentbank();
$contents = $cb->search_contents($search, $contextid, $contenttypes);
$this->assertCount($expectedresult, $contents);
@ -358,7 +369,7 @@ class core_contentbank_testcase extends advanced_testcase {
$fs = get_file_storage();
$dummyh5pfile = $fs->create_file_from_string($dummyh5p, 'Dummy H5Pcontent');
$cb = new \core_contentbank\contentbank();
$cb = new contentbank();
$content = $cb->create_content_from_file($systemcontext, $USER->id, $dummyh5pfile);
$this->assertEquals('contenttype_h5p', $content->get_content_type());

View File

@ -25,12 +25,6 @@
namespace core_contentbank;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php');
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_content.php');
use stdClass;
use context_system;
use contenttype_testable\contenttype as contenttype;
@ -64,6 +58,16 @@ class core_contenttype_contenttype_testcase extends \advanced_testcase {
/** @var contenttype The contenttype instance. */
protected $contenttype;
/**
* Setup to ensure that fixtures are loaded.
*/
public static function setupBeforeClass(): void {
global $CFG;
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.php');
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_content.php');
}
/**
* Tests get_contenttype_name result.
*

View File

@ -24,14 +24,14 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace core_contentbank;
namespace core_contentbank\external;
defined('MOODLE_INTERNAL') || die();
global $CFG;
require_once($CFG->dirroot . '/webservice/tests/helpers.php');
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_content.php');
use core_contentbank\external\delete_content;
use dml_missing_record_exception;
use external_api;
use externallib_advanced_testcase;

View File

@ -24,7 +24,7 @@
* @since Moodle 3.9
*/
namespace core_contentbank;
namespace core_contentbank\external;
defined('MOODLE_INTERNAL') || die();
@ -33,9 +33,6 @@ require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_contenttype.p
require_once($CFG->dirroot . '/contentbank/tests/fixtures/testable_content.php');
require_once($CFG->dirroot . '/webservice/tests/helpers.php');
use core_contentbank\external\delete_content;
use core_contentbank\external\external;
use core_contentbank\external\rename_content;
use external_api;
/**

View File

@ -25,8 +25,6 @@
namespace core_contentbank;
defined('MOODLE_INTERNAL') || die();
use stdClass;
use context_system;
use context_coursecat;