mirror of
https://github.com/moodle/moodle.git
synced 2025-03-14 12:40:01 +01:00
MDL-27898 fix question/engine/simpletest/testdatalib.php unit tests.
Now that MDL-27897 is fixed.
This commit is contained in:
parent
cfcf9bb4e3
commit
5f79a9bcb6
@ -1159,8 +1159,6 @@ class qubaid_list extends qubaid_condition {
|
||||
$this->params = array();
|
||||
return '1 = 0';
|
||||
}
|
||||
list($where, $this->params) = $DB->get_in_or_equal(
|
||||
$this->qubaids, SQL_PARAMS_NAMED, 'qubaid');
|
||||
|
||||
return $this->columntotest . ' ' . $this->usage_id_in();
|
||||
}
|
||||
@ -1173,6 +1171,7 @@ class qubaid_list extends qubaid_condition {
|
||||
global $DB;
|
||||
|
||||
if (empty($this->qubaids)) {
|
||||
$this->params = array();
|
||||
return '= 0';
|
||||
}
|
||||
list($where, $this->params) = $DB->get_in_or_equal(
|
||||
|
@ -35,7 +35,17 @@ require_once(dirname(__FILE__) . '/../lib.php');
|
||||
* @copyright 2009 The Open University
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class qubaid_condition_test extends UnitTestCase {
|
||||
class qubaid_condition_test extends UnitTestCaseUsingDatabase {
|
||||
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->switch_to_test_db();
|
||||
}
|
||||
|
||||
public function tearDown() {
|
||||
$this->revert_to_real_db();
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function check_typical_question_attempts_query(
|
||||
qubaid_condition $qubaids, $expectedsql, $expectedparams) {
|
||||
@ -64,8 +74,8 @@ class qubaid_condition_test extends UnitTestCase {
|
||||
$this->check_typical_question_attempts_query($qubaids,
|
||||
"SELECT qa.id, qa.maxmark
|
||||
FROM {question_attempts} qa
|
||||
WHERE qa.questionusageid = :qubaid8 AND qa.slot = :slot",
|
||||
array('qubaid8' => 1, 'slot' => 1));
|
||||
WHERE qa.questionusageid = :qubaid1 AND qa.slot = :slot",
|
||||
array('qubaid1' => 1, 'slot' => 1));
|
||||
}
|
||||
|
||||
public function test_qubaid_list_several_join() {
|
||||
@ -73,8 +83,8 @@ class qubaid_condition_test extends UnitTestCase {
|
||||
$this->check_typical_question_attempts_query($qubaids,
|
||||
"SELECT qa.id, qa.maxmark
|
||||
FROM {question_attempts} qa
|
||||
WHERE qa.questionusageid IN (:qubaid12,:qubaid13,:qubaid14) AND qa.slot = :slot",
|
||||
array('qubaid12' => 1, 'qubaid13' => 3, 'qubaid14' => 7, 'slot' => 1));
|
||||
WHERE qa.questionusageid IN (:qubaid2,:qubaid3,:qubaid4) AND qa.slot = :slot",
|
||||
array('qubaid2' => 1, 'qubaid3' => 3, 'qubaid4' => 7, 'slot' => 1));
|
||||
}
|
||||
|
||||
public function test_qubaid_join() {
|
||||
@ -103,7 +113,7 @@ class qubaid_condition_test extends UnitTestCase {
|
||||
$this->check_typical_in_query($qubaids,
|
||||
"SELECT qa.id, qa.maxmark
|
||||
FROM {question_attempts} qa
|
||||
WHERE qa.questionusageid = :qubaid15", array('qubaid15' => 1));
|
||||
WHERE qa.questionusageid = :qubaid5", array('qubaid5' => 1));
|
||||
}
|
||||
|
||||
public function test_qubaid_list_several_in() {
|
||||
@ -112,8 +122,8 @@ class qubaid_condition_test extends UnitTestCase {
|
||||
$this->check_typical_in_query($qubaids,
|
||||
"SELECT qa.id, qa.maxmark
|
||||
FROM {question_attempts} qa
|
||||
WHERE qa.questionusageid IN (:qubaid16,:qubaid17,:qubaid18)",
|
||||
array('qubaid16' => 1, 'qubaid17' => 2, 'qubaid18' => 3));
|
||||
WHERE qa.questionusageid IN (:qubaid6,:qubaid7,:qubaid8)",
|
||||
array('qubaid6' => 1, 'qubaid7' => 2, 'qubaid8' => 3));
|
||||
}
|
||||
|
||||
public function test_qubaid_join_in() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user