Commit 796e48a5 authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

MDL-60611 phpunit: remove deprecated stuff and other minor fixes

Thanks @scara for MDL-60611 phpunit: improved redis skipping reasons
parent 6be1923d
......@@ -149,7 +149,8 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
->chown(\org\bovigo\vfs\vfsStream::OWNER_USER_2);
// This should generate an exception.
$this->setExpectedExceptionRegexp('file_exception',
$this->expectException('file_exception');
$this->expectExceptionMessageRegExp(
'/Can not create local file pool directories, please verify permissions in dataroot./');
new file_system_filedir();
......@@ -170,7 +171,8 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
->chown(\org\bovigo\vfs\vfsStream::OWNER_USER_2);
// This should generate an exception.
$this->setExpectedExceptionRegexp('file_exception',
$this->expectException('file_exception');
$this->expectExceptionMessageRegExp(
'/Can not create local file pool directories, please verify permissions in dataroot./');
new file_system_filedir();
......@@ -693,7 +695,8 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
// Setup the filedir.
$vfileroot = $this->setup_vfile_root();
$this->setExpectedExceptionRegexp('file_exception',
$this->expectException('file_exception');
$this->expectExceptionMessageRegExp(
'/Cannot read file\. Either the file does not exist or there is a permission problem\./');
$fs = new file_system_filedir();
......@@ -785,10 +788,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
->chmod(0444)
->chown(\org\bovigo\vfs\vfsStream::OWNER_USER_2);
$this->setExpectedException(
'file_exception',
"Can not create local file pool directories, please verify permissions in dataroot."
);
$this->expectException('file_exception');
$this->expectExceptionMessageRegExp(
"/Can not create local file pool directories, please verify permissions in dataroot./");
// Attempt to add the file to the file pool.
$fs = new file_system_filedir();
......@@ -840,10 +842,9 @@ class core_files_file_system_filedir_testcase extends advanced_testcase {
->chmod(0444)
->chown(\org\bovigo\vfs\vfsStream::OWNER_USER_2);
$this->setExpectedException(
'file_exception',
"Can not create local file pool directories, please verify permissions in dataroot."
);
$this->expectException('file_exception');
$this->expectExceptionMessageRegExp(
"/Can not create local file pool directories, please verify permissions in dataroot./");
// Attempt to add the file to the file pool.
$fs = new file_system_filedir();
......
......@@ -55,6 +55,12 @@ class core_session_redis_testcase extends advanced_testcase {
if (!defined('TEST_SESSION_REDIS_HOST')) {
$this->markTestSkipped('Session test server not set. define: TEST_SESSION_REDIS_HOST');
}
$version = phpversion('Redis');
if (!$version) {
$this->markTestSkipped('Redis extension version missing');
} else if (version_compare($version, '2.0') <= 0) {
$this->markTestSkipped('Redis extension version must be at least 2.0: now running "' . $version . '"');
}
$this->resetAfterTest();
......
......@@ -194,10 +194,10 @@ class core_statslib_testcase extends advanced_testcase {
$clean->addFullReplacement($placeholder, $value);
}
$logs = new PHPUnit\DbUnit\DataSet\DataSetFilter($clean);
$logs = new PHPUnit\DbUnit\DataSet\Filter($clean);
$logs->addIncludeTables(array('log'));
$stats = new PHPUnit\DbUnit\DataSet\DataSetFilter($clean);
$stats = new PHPUnit\DbUnit\DataSet\Filter($clean);
$stats->addIncludeTables(array('stats_daily', 'stats_user_daily'));
return array($logs, $stats);
......
......@@ -264,7 +264,7 @@ class mod_feedback_external_testcase extends externallib_advanced_testcase {
*/
public function test_view_feedback_invalid_id() {
// Test invalid instance id.
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_feedback_external::view_feedback(0);
}
/**
......@@ -273,7 +273,7 @@ class mod_feedback_external_testcase extends externallib_advanced_testcase {
public function test_view_feedback_not_enrolled_user() {
$usernotenrolled = self::getDataGenerator()->create_user();
$this->setUser($usernotenrolled);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_feedback_external::view_feedback(0);
}
/**
......@@ -284,7 +284,7 @@ class mod_feedback_external_testcase extends externallib_advanced_testcase {
// We need a explicit prohibit since this capability is allowed for students by default.
assign_capability('mod/feedback:view', CAP_PROHIBIT, $this->studentrole->id, $this->context->id);
accesslib_clear_all_caches_for_unit_testing();
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_feedback_external::view_feedback(0);
}
/**
......@@ -671,7 +671,7 @@ class mod_feedback_external_testcase extends externallib_advanced_testcase {
*/
public function test_get_non_respondents_no_permissions() {
$this->setUser($this->student);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_feedback_external::get_non_respondents($this->feedback->id);
}
......
......@@ -360,7 +360,7 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
* Test test_view_lesson invalid id.
*/
public function test_view_lesson_invalid_id() {
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_lesson_external::view_lesson(0);
}
......@@ -371,7 +371,7 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
// Test not-enrolled user.
$usernotenrolled = self::getDataGenerator()->create_user();
$this->setUser($usernotenrolled);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_lesson_external::view_lesson($this->lesson->id);
}
......@@ -414,7 +414,7 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
course_modinfo::clear_instance_cache();
$this->setUser($this->student);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_lesson_external::view_lesson($this->lesson->id);
}
......@@ -814,7 +814,7 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
// Should fails as student.
$this->setUser($this->student);
// Now, try to review this attempt. We should not be able because is a non-finished attempt.
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_lesson_external::launch_attempt($this->lesson->id, '', 1, true);
}
......@@ -893,7 +893,7 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
// Fail as student.
$this->setUser($this->student);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_lesson_external::launch_attempt($this->lesson->id, '', 1, true);
}
......@@ -966,7 +966,7 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
// Now check using a normal student account.
$this->setUser($this->student);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
$result = mod_lesson_external::get_page_data($this->lesson->id, $this->page2->id, '', false, true);
}
......@@ -1245,7 +1245,7 @@ class mod_lesson_external_testcase extends externallib_advanced_testcase {
$this->assertEquals(1, $result['userstats']['gradeinfo']['total']); // Total correct answers.
$this->assertEquals(100, $result['userstats']['gradeinfo']['grade']); // Correct answer.
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
$result = mod_lesson_external::get_user_attempt($this->lesson->id, $this->teacher->id, 0);
}
......
......@@ -1260,7 +1260,7 @@ class mod_workshop_external_testcase extends externallib_advanced_testcase {
// Switch to closed phase.
$this->setUser($this->anotherstudentg1);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_workshop_external::get_assessment($assessmentid);
}
......@@ -1283,7 +1283,7 @@ class mod_workshop_external_testcase extends externallib_advanced_testcase {
$DB->set_field('workshop', 'phase', workshop::PHASE_CLOSED, array('id' => $this->workshop->id));
$this->setUser($this->anotherstudentg2);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_workshop_external::get_assessment($assessmentid);
}
......@@ -1359,7 +1359,7 @@ class mod_workshop_external_testcase extends externallib_advanced_testcase {
$DB->set_field('workshop', 'phase', workshop::PHASE_EVALUATION, array('id' => $this->workshop->id));
$this->setUser($this->student);
// Since we are not reviewers we can't see the assessment until the workshop is closed.
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_workshop_external::get_assessment_form_definition($assessmentid);
}
......@@ -1414,7 +1414,7 @@ class mod_workshop_external_testcase extends externallib_advanced_testcase {
$DB->set_field('workshop', 'phase', workshop::PHASE_ASSESSMENT, array('id' => $this->workshop->id));
// Try to get other user assessments.
$this->setUser($this->student);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_workshop_external::get_reviewer_assessments($this->workshop->id, $this->anotherstudentg1->id);
}
......@@ -1427,7 +1427,7 @@ class mod_workshop_external_testcase extends externallib_advanced_testcase {
$DB->set_field('workshop', 'phase', workshop::PHASE_SUBMISSION, array('id' => $this->workshop->id));
// Try to get other user assessments.
$this->setUser($this->student);
$this->setExpectedException('moodle_exception');
$this->expectException('moodle_exception');
mod_workshop_external::get_reviewer_assessments($this->workshop->id, $this->anotherstudentg1->id);
}
......
......@@ -1200,7 +1200,7 @@ class core_user_externallib_testcase extends externallib_advanced_testcase {
$user2 = self::getDataGenerator()->create_user();
$this->setUser($user1);
$this->setExpectedException('required_capability_exception');
$this->expectException('required_capability_exception');
// Try to retrieve other user private files info.
core_user_external::get_private_files_info($user2->id);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment