MDL-75777 phpunit: Move tests to use correct names and ns (take#6)
Applied the following changes to various testcase classes: - Namespaced with component[\level2-API] - Moved to level2-API subdirectory when required. - Fixed incorrect use statements with leading backslash. - Remove file phpdoc block - Remove MOODLE_INTERNAL if not needed. - Changed code to point to global scope when needed. - Fix some relative paths and comments here and there. - All them passing individually. - Complete runs passing too.
This commit is contained in:
@@ -14,14 +14,11 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file contains tests for the question_usage_by_activity class.
|
||||
*
|
||||
* @package core_question
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace core_question;
|
||||
|
||||
use question_bank;
|
||||
use question_engine;
|
||||
use question_state;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -29,19 +26,19 @@ global $CFG;
|
||||
require_once(__DIR__ . '/../lib.php');
|
||||
require_once(__DIR__ . '/helpers.php');
|
||||
|
||||
|
||||
/**
|
||||
* Unit tests for the question_usage_by_activity class.
|
||||
*
|
||||
* @package core_question
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class question_usage_by_activity_test extends advanced_testcase {
|
||||
class questionusagebyactivity_test extends \advanced_testcase {
|
||||
|
||||
public function test_set_get_preferred_model() {
|
||||
// Set up
|
||||
$quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
|
||||
// Exercise SUT and verify.
|
||||
$quba->set_preferred_behaviour('deferredfeedback');
|
||||
@@ -51,7 +48,7 @@ class question_usage_by_activity_test extends advanced_testcase {
|
||||
public function test_set_get_id() {
|
||||
// Set up
|
||||
$quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
|
||||
// Exercise SUT and verify
|
||||
$quba->set_id_from_database(123);
|
||||
@@ -61,7 +58,7 @@ class question_usage_by_activity_test extends advanced_testcase {
|
||||
public function test_fake_id() {
|
||||
// Set up
|
||||
$quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
|
||||
// Exercise SUT and verify
|
||||
$this->assertNotEmpty($quba->get_id());
|
||||
@@ -69,10 +66,10 @@ class question_usage_by_activity_test extends advanced_testcase {
|
||||
|
||||
public function test_create_usage_and_add_question() {
|
||||
// Exercise SUT
|
||||
$context = context_system::instance();
|
||||
$context = \context_system::instance();
|
||||
$quba = question_engine::make_questions_usage_by_activity('unit_test', $context);
|
||||
$quba->set_preferred_behaviour('deferredfeedback');
|
||||
$tf = test_question_maker::make_question('truefalse', 'true');
|
||||
$tf = \test_question_maker::make_question('truefalse', 'true');
|
||||
$slot = $quba->add_question($tf);
|
||||
|
||||
// Verify.
|
||||
@@ -86,9 +83,9 @@ class question_usage_by_activity_test extends advanced_testcase {
|
||||
public function test_get_question() {
|
||||
// Set up.
|
||||
$quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
$quba->set_preferred_behaviour('deferredfeedback');
|
||||
$tf = test_question_maker::make_question('truefalse', 'true');
|
||||
$tf = \test_question_maker::make_question('truefalse', 'true');
|
||||
$slot = $quba->add_question($tf);
|
||||
|
||||
// Exercise SUT and verify.
|
||||
@@ -100,9 +97,9 @@ class question_usage_by_activity_test extends advanced_testcase {
|
||||
|
||||
public function test_extract_responses() {
|
||||
// Start a deferred feedback attempt with CBM and add the question to it.
|
||||
$tf = test_question_maker::make_question('truefalse', 'true');
|
||||
$tf = \test_question_maker::make_question('truefalse', 'true');
|
||||
$quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
$quba->set_preferred_behaviour('deferredcbm');
|
||||
$slot = $quba->add_question($tf);
|
||||
$quba->start_all_questions();
|
||||
@@ -126,9 +123,9 @@ class question_usage_by_activity_test extends advanced_testcase {
|
||||
|
||||
public function test_access_out_of_sequence_throws_exception() {
|
||||
// Start a deferred feedback attempt with CBM and add the question to it.
|
||||
$tf = test_question_maker::make_question('truefalse', 'true');
|
||||
$tf = \test_question_maker::make_question('truefalse', 'true');
|
||||
$quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
$quba->set_preferred_behaviour('deferredcbm');
|
||||
$slot = $quba->add_question($tf);
|
||||
$quba->start_all_questions();
|
||||
@@ -167,7 +164,7 @@ class question_usage_by_activity_test extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
// Set up.
|
||||
$quba = question_engine::make_questions_usage_by_activity('unit_test',
|
||||
context_system::instance());
|
||||
\context_system::instance());
|
||||
|
||||
// Create an essay question in the DB.
|
||||
$generator = $this->getDataGenerator()->get_plugin_generator('core_question');
|
||||
|
||||
Reference in New Issue
Block a user