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,15 +14,17 @@
|
||||
// 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 'missing' behaviour.
|
||||
*
|
||||
* @package qbehaviour
|
||||
* @subpackage missing
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
namespace qbehaviour_missing;
|
||||
|
||||
use qbehaviour_missing;
|
||||
use question_attempt;
|
||||
use question_attempt_pending_step;
|
||||
use question_attempt_step;
|
||||
use question_bank;
|
||||
use question_display_options;
|
||||
use question_state;
|
||||
use question_test_recordset;
|
||||
use question_usage_null_observer;
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
@@ -31,40 +33,40 @@ require_once(__DIR__ . '/../../../engine/lib.php');
|
||||
require_once(__DIR__ . '/../../../engine/tests/helpers.php');
|
||||
require_once(__DIR__ . '/../behaviour.php');
|
||||
|
||||
|
||||
/**
|
||||
* Unit tests for the 'missing' behaviour.
|
||||
*
|
||||
* @package qbehaviour_missing
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qbehaviour_missing_test extends advanced_testcase {
|
||||
class missingbehaviour_test extends \advanced_testcase {
|
||||
|
||||
public function test_missing_cannot_start() {
|
||||
$qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0);
|
||||
$qa = new question_attempt(\test_question_maker::make_question('truefalse', 'true'), 0);
|
||||
$behaviour = new qbehaviour_missing($qa, 'deferredfeedback');
|
||||
$this->expectException(moodle_exception::class);
|
||||
$this->expectException(\moodle_exception::class);
|
||||
$behaviour->init_first_step(new question_attempt_step(array()), 1);
|
||||
}
|
||||
|
||||
public function test_missing_cannot_process() {
|
||||
$qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0);
|
||||
$qa = new question_attempt(\test_question_maker::make_question('truefalse', 'true'), 0);
|
||||
$behaviour = new qbehaviour_missing($qa, 'deferredfeedback');
|
||||
$this->expectException(moodle_exception::class);
|
||||
$this->expectException(\moodle_exception::class);
|
||||
$behaviour->process_action(new question_attempt_pending_step(array()));
|
||||
}
|
||||
|
||||
public function test_missing_cannot_get_min_fraction() {
|
||||
$qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0);
|
||||
$qa = new question_attempt(\test_question_maker::make_question('truefalse', 'true'), 0);
|
||||
$behaviour = new qbehaviour_missing($qa, 'deferredfeedback');
|
||||
$this->expectException(moodle_exception::class);
|
||||
$this->expectException(\moodle_exception::class);
|
||||
$behaviour->get_min_fraction();
|
||||
}
|
||||
|
||||
public function test_missing_cannot_get_max_fraction() {
|
||||
$qa = new question_attempt(test_question_maker::make_question('truefalse', 'true'), 0);
|
||||
$qa = new question_attempt(\test_question_maker::make_question('truefalse', 'true'), 0);
|
||||
$behaviour = new qbehaviour_missing($qa, 'deferredfeedback');
|
||||
$this->expectException(moodle_exception::class);
|
||||
$this->expectException(\moodle_exception::class);
|
||||
$behaviour->get_max_fraction();
|
||||
}
|
||||
|
||||
@@ -83,7 +85,7 @@ class qbehaviour_missing_test extends advanced_testcase {
|
||||
1256233790, 2, 1, 'complete', 0.50, 1256233705, 1, 'choice0', '1'),
|
||||
));
|
||||
|
||||
$question = test_question_maker::make_question('truefalse', 'true');
|
||||
$question = \test_question_maker::make_question('truefalse', 'true');
|
||||
$question->id = -1;
|
||||
|
||||
question_bank::start_unit_test();
|
||||
|
||||
Reference in New Issue
Block a user