->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();
->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();
// 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();
->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();
->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();
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();
$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);
*/
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);
}
/**
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);
}
/**
// 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);
}
/**
*/
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);
}
* 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);
}
// 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);
}
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);
}
// 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);
}
// 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);
}
// 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);
}
$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);
}
// Switch to closed phase.
$this->setUser($this->anotherstudentg1);
- $this->setExpectedException('moodle_exception');
+ $this->expectException('moodle_exception');
mod_workshop_external::get_assessment($assessmentid);
}
$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);
}
$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);
}
$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);
}
$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);
}
$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);
}