MDL-71036 phpunit: Renamed various regexp-related assertions
In PHPUnit 9.1, the following regexp-related assertions
have been deprecated and there are new alternatives for
all them:
- assertRegExp() -> assertMatchesRegularExpression()
- assertNotRegExp() -> assertDoesNotMatchRegularExpression()
This is about to, simply, move all cases to the new alternatives.
Source: https://github.com/sebastianbergmann/phpunit/blob/9.1.0/ChangeLog-9.1.md
Regexp to find all them:
ag 'assertRegExp|assertNotRegExp' -li
This commit is contained in:
@@ -133,7 +133,7 @@ class tool_dataprivacy_api_testcase extends advanced_testcase {
|
||||
$result = api::update_request_status($requestid, api::DATAREQUEST_STATUS_AWAITING_APPROVAL, 0, $secondcomment);
|
||||
$this->assertTrue($result);
|
||||
$datarequest = new data_request($requestid);
|
||||
$this->assertRegExp("/.*{$comment}.*{$secondcomment}/s", $datarequest->get('dpocomment'));
|
||||
$this->assertMatchesRegularExpression("/.*{$comment}.*{$secondcomment}/s", $datarequest->get('dpocomment'));
|
||||
|
||||
// Update with a valid status.
|
||||
$result = api::update_request_status($requestid, api::DATAREQUEST_STATUS_DOWNLOAD_READY);
|
||||
|
||||
@@ -203,8 +203,8 @@ class healthlib_testcase extends advanced_testcase {
|
||||
$missingparent = array((object) array('id' => 2, 'parent' => 3, 'name' => 'test'),
|
||||
(object) array('id' => 4, 'parent' => 5, 'name' => 'test2'));
|
||||
$result = tool_health_category_list_missing_parents($missingparent);
|
||||
$this->assertRegExp('/Category 2: test/', $result);
|
||||
$this->assertRegExp('/Category 4: test2/', $result);
|
||||
$this->assertMatchesRegularExpression('/Category 2: test/', $result);
|
||||
$this->assertMatchesRegularExpression('/Category 4: test2/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -213,6 +213,6 @@ class healthlib_testcase extends advanced_testcase {
|
||||
public function test_tool_health_category_list_loops() {
|
||||
$loops = array((object) array('id' => 2, 'parent' => 3, 'name' => 'test'));
|
||||
$result = tool_health_category_list_loops($loops);
|
||||
$this->assertRegExp('/Category 2: test/', $result);
|
||||
$this->assertMatchesRegularExpression('/Category 2: test/', $result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -347,13 +347,13 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals($this->c1->id, $warning['courseid']);
|
||||
$this->assertEquals($this->f1comps['A1']->get('id'), $warning['competencyid']);
|
||||
$this->assertEquals(null, $warning['cmid']);
|
||||
$this->assertRegexp('/competency already exists/', $warning['message']);
|
||||
$this->assertMatchesRegularExpression('/competency already exists/', $warning['message']);
|
||||
|
||||
$warning = array_shift($warnings);
|
||||
$this->assertEquals($this->c2->id, $warning['courseid']);
|
||||
$this->assertEquals($this->f1comps['A2']->get('id'), $warning['competencyid']);
|
||||
$this->assertEquals($this->cms[$this->c2->id]['F1']->cmid, $warning['cmid']);
|
||||
$this->assertRegexp('/competency already exists/', $warning['message']);
|
||||
$this->assertMatchesRegularExpression('/competency already exists/', $warning['message']);
|
||||
|
||||
$this->assertCourseCompetencyExists($this->c1, $this->f1comps['A1']);
|
||||
$this->assertModuleCompetencyExists($this->cms[$this->c2->id]['F1'], $this->f1comps['A2']);
|
||||
@@ -436,7 +436,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals($this->c1->id, $errors[0]['courseid']);
|
||||
$this->assertEquals($this->f1comps['A1']->get('id'), $errors[0]['competencyid']);
|
||||
$this->assertEquals(null, $errors[0]['cmid']);
|
||||
$this->assertRegexp('/Sorry, but you do not currently have permissions to do that/', $errors[0]['message']);
|
||||
$this->assertMatchesRegularExpression('/Sorry, but you do not currently have permissions to do that/', $errors[0]['message']);
|
||||
$this->assertEquals($this->f1comps['A3']->get('id'), $errors[1]['competencyid']);
|
||||
|
||||
$this->assertCourseCompetencyNotMigrated($this->c1, $this->f1comps['A1'], $this->f2comps['A1']);
|
||||
@@ -465,7 +465,7 @@ class tool_lpmigrate_framework_processor_testcase extends advanced_testcase {
|
||||
$this->assertEquals($this->c2->id, $errors[0]['courseid']);
|
||||
$this->assertEquals($this->f1comps['A2']->get('id'), $errors[0]['competencyid']);
|
||||
$this->assertEquals($this->cms[$this->c2->id]['F1']->cmid, $errors[0]['cmid']);
|
||||
$this->assertRegexp('/Sorry, but you do not currently have permissions to do that/', $errors[0]['message']);
|
||||
$this->assertMatchesRegularExpression('/Sorry, but you do not currently have permissions to do that/', $errors[0]['message']);
|
||||
$this->assertEquals($this->f1comps['A3']->get('id'), $errors[1]['competencyid']);
|
||||
|
||||
// The new competencies were added to the course, but the old ones were not removed because they are still in modules.
|
||||
|
||||
@@ -498,8 +498,8 @@ class tool_monitor_eventobservers_testcase extends advanced_testcase {
|
||||
|
||||
$modurl = new moodle_url('/mod/book/view.php', array('id' => $book->cmid));
|
||||
|
||||
$this->assertRegExp('~<h2>.*' . preg_quote($event->get_url()->out(), '~') . '.*</h2>~', $msg->fullmessagehtml);
|
||||
$this->assertRegExp('~<li>.*' . preg_quote($modurl->out(), '~') . '.*</li>~', $msg->fullmessagehtml);
|
||||
$this->assertMatchesRegularExpression('~<h2>.*' . preg_quote($event->get_url()->out(), '~') . '.*</h2>~', $msg->fullmessagehtml);
|
||||
$this->assertMatchesRegularExpression('~<li>.*' . preg_quote($modurl->out(), '~') . '.*</li>~', $msg->fullmessagehtml);
|
||||
$this->assertStringContainsString('<li><strong>'.$rule->get_name($context).'</strong></li>', $msg->fullmessagehtml);
|
||||
$this->assertStringContainsString('<li>'.$rule->get_description($context).'</li>', $msg->fullmessagehtml);
|
||||
$this->assertStringContainsString('<li>'.$rule->get_event_name().'</li>', $msg->fullmessagehtml);
|
||||
|
||||
@@ -828,7 +828,7 @@ class tour_testcase extends advanced_testcase {
|
||||
set_user_preference(\tool_usertours\tour::TOUR_REQUESTED_BY_USER . $id, $userpref);
|
||||
}
|
||||
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'/' . $expectation . '/',
|
||||
$tour->get_tour_key()
|
||||
);
|
||||
|
||||
@@ -225,7 +225,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Page!.*is marked complete~', $information);
|
||||
$this->assertMatchesRegularExpression('~Page!.*is marked complete~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// INCOMPLETE state (true).
|
||||
@@ -236,7 +236,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Page!.*is marked complete~', $information);
|
||||
$this->assertMatchesRegularExpression('~Page!.*is marked complete~', $information);
|
||||
|
||||
// Mark page complete.
|
||||
$completion = new completion_info($course);
|
||||
@@ -250,7 +250,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Page!.*is incomplete~', $information);
|
||||
$this->assertMatchesRegularExpression('~Page!.*is incomplete~', $information);
|
||||
|
||||
// INCOMPLETE state (false).
|
||||
$cond = new condition((object)[
|
||||
@@ -259,7 +259,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Page!.*is incomplete~', $information);
|
||||
$this->assertMatchesRegularExpression('~Page!.*is incomplete~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info,
|
||||
true, $user->id));
|
||||
|
||||
@@ -289,7 +289,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Assign!.*is complete and passed~', $information);
|
||||
$this->assertMatchesRegularExpression('~Assign!.*is complete and passed~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
$cond = new condition((object)[
|
||||
@@ -298,7 +298,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Assign!.*is complete and failed~', $information);
|
||||
$this->assertMatchesRegularExpression('~Assign!.*is complete and failed~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// Change the grade to be complete and failed.
|
||||
@@ -322,7 +322,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Assign!.*is complete and passed~', $information);
|
||||
$this->assertMatchesRegularExpression('~Assign!.*is complete and passed~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
$cond = new condition((object)[
|
||||
@@ -332,7 +332,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Assign!.*is not complete and failed~', $information);
|
||||
$this->assertMatchesRegularExpression('~Assign!.*is not complete and failed~', $information);
|
||||
|
||||
// Now change it to pass.
|
||||
self::set_grade($assignrow, $user->id, 60);
|
||||
@@ -356,7 +356,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Assign!.*is not complete and passed~', $information);
|
||||
$this->assertMatchesRegularExpression('~Assign!.*is not complete and passed~', $information);
|
||||
|
||||
$cond = new condition((object)[
|
||||
'cm' => (int)$assigncm->id, 'e' => COMPLETION_COMPLETE_FAIL
|
||||
@@ -364,7 +364,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~Assign!.*is complete and failed~', $information);
|
||||
$this->assertMatchesRegularExpression('~Assign!.*is complete and failed~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// Simulate deletion of an activity by using an invalid cmid. These
|
||||
@@ -375,7 +375,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp('~(Missing activity).*is marked complete~', $information);
|
||||
$this->assertMatchesRegularExpression('~(Missing activity).*is marked complete~', $information);
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$cond = new condition((object)[
|
||||
'cm' => ($assigncm->id + 100), 'e' => COMPLETION_INCOMPLETE
|
||||
@@ -472,7 +472,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertEquals($resultnot, $cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp($description, $information);
|
||||
$this->assertMatchesRegularExpression($description, $information);
|
||||
}
|
||||
|
||||
public function test_previous_activity_data(): array {
|
||||
@@ -636,7 +636,7 @@ class availability_completion_condition_testcase extends advanced_testcase {
|
||||
$this->assertEquals($resultnot, $cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$information = \core_availability\info::format_info($information, $course);
|
||||
$this->assertRegExp($description, $information);
|
||||
$this->assertMatchesRegularExpression($description, $information);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ class availability_date_condition_testcase extends advanced_testcase {
|
||||
|
||||
// Note: PM is normally upper-case, but an issue with PHP on Mac means
|
||||
// that on that platform, it is reported lower-case.
|
||||
$this->assertRegExp('~from.*18 February 2014, 7:20 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~from.*18 February 2014, 7:20 (PM|pm)~', $information);
|
||||
|
||||
// Check if available (when available).
|
||||
condition::set_current_time_for_test($time);
|
||||
@@ -192,36 +192,36 @@ class availability_date_condition_testcase extends advanced_testcase {
|
||||
// Test with >=.
|
||||
$date = new condition((object)array('d' => '>=', 't' => $time));
|
||||
$information = $date->get_description(true, false, $info);
|
||||
$this->assertRegExp('~after.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~after.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$information = $date->get_description(true, true, $info);
|
||||
$this->assertRegExp('~before.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~before.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$information = $date->get_standalone_description(true, false, $info);
|
||||
$this->assertRegExp('~from.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~from.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$information = $date->get_standalone_description(true, true, $info);
|
||||
$this->assertRegExp('~until.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~until.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
|
||||
// Test with <.
|
||||
$date = new condition((object)array('d' => '<', 't' => $time));
|
||||
$information = $date->get_description(true, false, $info);
|
||||
$this->assertRegExp('~before.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~before.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$information = $date->get_description(true, true, $info);
|
||||
$this->assertRegExp('~after.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~after.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$information = $date->get_standalone_description(true, false, $info);
|
||||
$this->assertRegExp('~until.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~until.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$information = $date->get_standalone_description(true, true, $info);
|
||||
$this->assertRegExp('~from.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
$this->assertMatchesRegularExpression('~from.*18 February 2014, 2:55 (PM|pm)~', $information);
|
||||
|
||||
// Test special case for dates that are midnight.
|
||||
$date = new condition((object)array('d' => '>=',
|
||||
't' => strtotime('2014-03-05 00:00 GMT')));
|
||||
$information = $date->get_description(true, false, $info);
|
||||
$this->assertRegExp('~on or after.*5 March 2014([^0-9]*)$~', $information);
|
||||
$this->assertMatchesRegularExpression('~on or after.*5 March 2014([^0-9]*)$~', $information);
|
||||
$information = $date->get_description(true, true, $info);
|
||||
$this->assertRegExp('~before.*end of.*4 March 2014([^0-9]*)$~', $information);
|
||||
$this->assertMatchesRegularExpression('~before.*end of.*4 March 2014([^0-9]*)$~', $information);
|
||||
$information = $date->get_standalone_description(true, false, $info);
|
||||
$this->assertRegExp('~from.*5 March 2014([^0-9]*)$~', $information);
|
||||
$this->assertMatchesRegularExpression('~from.*5 March 2014([^0-9]*)$~', $information);
|
||||
$information = $date->get_standalone_description(true, true, $info);
|
||||
$this->assertRegExp('~until end of.*4 March 2014([^0-9]*)$~', $information);
|
||||
$this->assertMatchesRegularExpression('~until end of.*4 March 2014([^0-9]*)$~', $information);
|
||||
|
||||
// In the 'until' case for midnight, it shows the previous day. (I.e.
|
||||
// if the date is 5 March 00:00, then we show it as available until 4
|
||||
@@ -229,13 +229,13 @@ class availability_date_condition_testcase extends advanced_testcase {
|
||||
$date = new condition((object)array('d' => '<',
|
||||
't' => strtotime('2014-03-05 00:00 GMT')));
|
||||
$information = $date->get_description(true, false, $info);
|
||||
$this->assertRegExp('~before end of.*4 March 2014([^0-9]*)$~', $information);
|
||||
$this->assertMatchesRegularExpression('~before end of.*4 March 2014([^0-9]*)$~', $information);
|
||||
$information = $date->get_description(true, true, $info);
|
||||
$this->assertRegExp('~on or after.*5 March 2014([^0-9]*)$~', $information);
|
||||
$this->assertMatchesRegularExpression('~on or after.*5 March 2014([^0-9]*)$~', $information);
|
||||
$information = $date->get_standalone_description(true, false, $info);
|
||||
$this->assertRegExp('~until end of.*4 March 2014([^0-9]*)$~', $information);
|
||||
$this->assertMatchesRegularExpression('~until end of.*4 March 2014([^0-9]*)$~', $information);
|
||||
$information = $date->get_standalone_description(true, true, $info);
|
||||
$this->assertRegExp('~from.*5 March 2014([^0-9]*)$~', $information);
|
||||
$this->assertMatchesRegularExpression('~from.*5 March 2014([^0-9]*)$~', $information);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -68,7 +68,7 @@ class availability_grade_condition_testcase extends advanced_testcase {
|
||||
// Check if available (not available).
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~have a grade.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~have a grade.*Test!~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// Add grade and check available.
|
||||
@@ -76,7 +76,7 @@ class availability_grade_condition_testcase extends advanced_testcase {
|
||||
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp('~do not have a grade.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~do not have a grade.*Test!~', $information);
|
||||
|
||||
// Construct directly and test remaining conditions; first, min grade (fail).
|
||||
self::set_grade($assignrow, $user->id, 29.99999);
|
||||
@@ -84,7 +84,7 @@ class availability_grade_condition_testcase extends advanced_testcase {
|
||||
$cond = new condition($structure);
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~achieve a required score.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~achieve a required score.*Test!~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// Min grade (success).
|
||||
@@ -92,7 +92,7 @@ class availability_grade_condition_testcase extends advanced_testcase {
|
||||
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp('~do not get certain scores.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~do not get certain scores.*Test!~', $information);
|
||||
|
||||
// Max grade (fail).
|
||||
unset($structure->min);
|
||||
@@ -100,7 +100,7 @@ class availability_grade_condition_testcase extends advanced_testcase {
|
||||
$cond = new condition($structure);
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~get an appropriate score.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~get an appropriate score.*Test!~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// Max grade (success).
|
||||
@@ -108,7 +108,7 @@ class availability_grade_condition_testcase extends advanced_testcase {
|
||||
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp('~do not get certain scores.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~do not get certain scores.*Test!~', $information);
|
||||
|
||||
// Max and min (fail).
|
||||
$structure->min = 30.0;
|
||||
@@ -116,7 +116,7 @@ class availability_grade_condition_testcase extends advanced_testcase {
|
||||
$cond = new condition($structure);
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~get a particular score.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~get a particular score.*Test!~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// Still fail (other end).
|
||||
@@ -128,14 +128,14 @@ class availability_grade_condition_testcase extends advanced_testcase {
|
||||
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp('~do not get certain scores.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~do not get certain scores.*Test!~', $information);
|
||||
|
||||
// Success (bottom end).
|
||||
self::set_grade($assignrow, $user->id, 30.0);
|
||||
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp('~do not get certain scores.*Test!~', $information);
|
||||
$this->assertMatchesRegularExpression('~do not get certain scores.*Test!~', $information);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -73,7 +73,7 @@ class availability_group_condition_testcase extends advanced_testcase {
|
||||
// Check if available (when not available).
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~You belong to.*G1!~', $information);
|
||||
$this->assertMatchesRegularExpression('~You belong to.*G1!~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// Add user to groups and refresh cache.
|
||||
@@ -85,7 +85,7 @@ class availability_group_condition_testcase extends advanced_testcase {
|
||||
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp('~do not belong to.*G1!~', $information);
|
||||
$this->assertMatchesRegularExpression('~do not belong to.*G1!~', $information);
|
||||
|
||||
// Check group 2 works also.
|
||||
$cond = new condition((object)array('id' => (int)$group2->id));
|
||||
@@ -96,7 +96,7 @@ class availability_group_condition_testcase extends advanced_testcase {
|
||||
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp('~do not belong to any~', $information);
|
||||
$this->assertMatchesRegularExpression('~do not belong to any~', $information);
|
||||
|
||||
// Admin user doesn't belong to a group, but they can access it
|
||||
// either way (positive or NOT).
|
||||
@@ -108,7 +108,7 @@ class availability_group_condition_testcase extends advanced_testcase {
|
||||
$cond = new condition((object)array('id' => $group2->id + 1000));
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~You belong to.*\(Missing group\)~', $information);
|
||||
$this->assertMatchesRegularExpression('~You belong to.*\(Missing group\)~', $information);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -74,7 +74,7 @@ class availability_grouping_condition_testcase extends advanced_testcase {
|
||||
// Check if available (when not available).
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~belong to a group in.*Grouping!~', $information);
|
||||
$this->assertMatchesRegularExpression('~belong to a group in.*Grouping!~', $information);
|
||||
$this->assertTrue($cond->is_available(true, $info, true, $user->id));
|
||||
|
||||
// Add user to grouping and refresh cache.
|
||||
@@ -85,7 +85,7 @@ class availability_grouping_condition_testcase extends advanced_testcase {
|
||||
$this->assertTrue($cond->is_available(false, $info, true, $user->id));
|
||||
$this->assertFalse($cond->is_available(true, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp('~do not belong to a group in.*Grouping!~', $information);
|
||||
$this->assertMatchesRegularExpression('~do not belong to a group in.*Grouping!~', $information);
|
||||
|
||||
// Admin user doesn't belong to the grouping, but they can access it
|
||||
// either way (positive or NOT) because of accessallgroups.
|
||||
@@ -98,7 +98,7 @@ class availability_grouping_condition_testcase extends advanced_testcase {
|
||||
$cond = new condition((object)array('id' => $grouping->id + 1000));
|
||||
$this->assertFalse($cond->is_available(false, $info, true, $user->id));
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~belong to a group in.*(Missing grouping)~', $information);
|
||||
$this->assertMatchesRegularExpression('~belong to a group in.*(Missing grouping)~', $information);
|
||||
|
||||
// We need an actual cm object to test the 'grouping from cm' option.
|
||||
$pagegen = $generator->get_plugin_generator('mod_page');
|
||||
@@ -118,7 +118,7 @@ class availability_grouping_condition_testcase extends advanced_testcase {
|
||||
groups_remove_member($group, $user);
|
||||
get_fast_modinfo($course->id, 0, true);
|
||||
$this->assertFalse($info->is_available($information, false, $user->id));
|
||||
$this->assertRegExp('~belong to a group in.*Grouping!~', $information);
|
||||
$this->assertMatchesRegularExpression('~belong to a group in.*Grouping!~', $information);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -313,7 +313,7 @@ class availability_profile_condition_testcase extends advanced_testcase {
|
||||
// Check the message (should be using lang string with capital, which
|
||||
// is evidence that it called the right function to get the name).
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp('~Department~', $information);
|
||||
$this->assertMatchesRegularExpression('~Department~', $information);
|
||||
|
||||
// Set the field to true for both users and retry.
|
||||
$DB->set_field('user', 'department', 'Cheese Studies', array('id' => $user->id));
|
||||
@@ -394,7 +394,7 @@ class availability_profile_condition_testcase extends advanced_testcase {
|
||||
'Failed checking normal (positive) result');
|
||||
if (!$yes) {
|
||||
$information = $cond->get_description(false, false, $info);
|
||||
$this->assertRegExp($failpattern, $information);
|
||||
$this->assertMatchesRegularExpression($failpattern, $information);
|
||||
}
|
||||
|
||||
// Negative (NOT) test.
|
||||
@@ -402,7 +402,7 @@ class availability_profile_condition_testcase extends advanced_testcase {
|
||||
'Failed checking NOT (negative) result');
|
||||
if ($yes) {
|
||||
$information = $cond->get_description(false, true, $info);
|
||||
$this->assertRegExp($failpattern, $information);
|
||||
$this->assertMatchesRegularExpression($failpattern, $information);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -221,7 +221,7 @@ class tree_testcase extends \advanced_testcase {
|
||||
list ($available, $information) = $this->get_available_results(
|
||||
$structure, $info, $USER->id);
|
||||
$this->assertFalse($available);
|
||||
$this->assertRegExp('~any of.*no.*way~', $information);
|
||||
$this->assertMatchesRegularExpression('~any of.*no.*way~', $information);
|
||||
|
||||
// Two conditions, OR, resolving as false, no display.
|
||||
$structure->show = false;
|
||||
@@ -257,7 +257,7 @@ class tree_testcase extends \advanced_testcase {
|
||||
list ($available, $information) = $this->get_available_results(
|
||||
$structure, $info, $USER->id);
|
||||
$this->assertFalse($available);
|
||||
$this->assertRegExp('~wom.*bat~', $information);
|
||||
$this->assertMatchesRegularExpression('~wom.*bat~', $information);
|
||||
|
||||
// Two conditions, AND, both false, show turned off for one. When
|
||||
// show is turned off, that means if you don't have that condition
|
||||
@@ -287,7 +287,7 @@ class tree_testcase extends \advanced_testcase {
|
||||
list ($available, $information) = $this->get_available_results(
|
||||
$structure, $info, $USER->id);
|
||||
$this->assertFalse($available);
|
||||
$this->assertRegExp('~!wom.*!bat~', $information);
|
||||
$this->assertMatchesRegularExpression('~!wom.*!bat~', $information);
|
||||
|
||||
// Two conditions, NOT AND, both true.
|
||||
$structure->op = '!&';
|
||||
@@ -296,7 +296,7 @@ class tree_testcase extends \advanced_testcase {
|
||||
list ($available, $information) = $this->get_available_results(
|
||||
$structure, $info, $USER->id);
|
||||
$this->assertFalse($available);
|
||||
$this->assertRegExp('~any of.*!wom.*!bat~', $information);
|
||||
$this->assertMatchesRegularExpression('~any of.*!wom.*!bat~', $information);
|
||||
|
||||
// Two conditions, NOT AND, one true.
|
||||
$structure->c[1]->a = false;
|
||||
@@ -330,7 +330,7 @@ class tree_testcase extends \advanced_testcase {
|
||||
list ($available, $information) = $this->get_available_results(
|
||||
$structure, $info, $USER->id);
|
||||
$this->assertFalse($available);
|
||||
$this->assertRegExp('~<ul.*<ul.*<li.*1.*<li.*2.*</ul>.*<li.*3~', $information);
|
||||
$this->assertMatchesRegularExpression('~<ul.*<ul.*<li.*1.*<li.*2.*</ul>.*<li.*3~', $information);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -424,7 +424,7 @@ class tree_testcase extends \advanced_testcase {
|
||||
self::mock(array('m' => '2'))), tree::OP_AND),
|
||||
self::mock(array('m' => 3)));
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~<ul.*<ul.*<li.*1.*<li.*2.*</ul>.*<li.*3~',
|
||||
$this->assertMatchesRegularExpression('~<ul.*<ul.*<li.*1.*<li.*2.*</ul>.*<li.*3~',
|
||||
$renderer->render($tree->get_full_information($info)));
|
||||
|
||||
// Test intro messages before list. First, OR message.
|
||||
@@ -433,13 +433,13 @@ class tree_testcase extends \advanced_testcase {
|
||||
self::mock(array('m' => '2'))
|
||||
);
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~Not available unless any of:.*<ul>~',
|
||||
$this->assertMatchesRegularExpression('~Not available unless any of:.*<ul>~',
|
||||
$renderer->render($tree->get_full_information($info)));
|
||||
|
||||
// Now, OR message when not shown.
|
||||
$structure->show = false;
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~hidden.*<ul>~',
|
||||
$this->assertMatchesRegularExpression('~hidden.*<ul>~',
|
||||
$renderer->render($tree->get_full_information($info)));
|
||||
|
||||
// AND message.
|
||||
@@ -447,11 +447,11 @@ class tree_testcase extends \advanced_testcase {
|
||||
unset($structure->show);
|
||||
$structure->showc = array(false, false);
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~Not available unless:.*<ul>~',
|
||||
$this->assertMatchesRegularExpression('~Not available unless:.*<ul>~',
|
||||
$renderer->render($tree->get_full_information($info)));
|
||||
|
||||
// Hidden markers on items.
|
||||
$this->assertRegExp('~1.*hidden.*2.*hidden~',
|
||||
$this->assertMatchesRegularExpression('~1.*hidden.*2.*hidden~',
|
||||
$renderer->render($tree->get_full_information($info)));
|
||||
|
||||
// Hidden markers on child tree and items.
|
||||
@@ -459,11 +459,11 @@ class tree_testcase extends \advanced_testcase {
|
||||
self::mock(array('m' => '2')),
|
||||
self::mock(array('m' => '3'))), tree::OP_AND);
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~1.*hidden.*All of \(hidden.*2.*3~',
|
||||
$this->assertMatchesRegularExpression('~1.*hidden.*All of \(hidden.*2.*3~',
|
||||
$renderer->render($tree->get_full_information($info)));
|
||||
$structure->c[1]->op = '|';
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~1.*hidden.*Any of \(hidden.*2.*3~',
|
||||
$this->assertMatchesRegularExpression('~1.*hidden.*Any of \(hidden.*2.*3~',
|
||||
$renderer->render($tree->get_full_information($info)));
|
||||
|
||||
// Hidden markers on single-item display, AND and OR.
|
||||
@@ -472,14 +472,14 @@ class tree_testcase extends \advanced_testcase {
|
||||
self::mock(array('m' => '1'))
|
||||
);
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~1.*hidden~',
|
||||
$this->assertMatchesRegularExpression('~1.*hidden~',
|
||||
$tree->get_full_information($info));
|
||||
|
||||
unset($structure->showc);
|
||||
$structure->show = false;
|
||||
$structure->op = '|';
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~1.*hidden~',
|
||||
$this->assertMatchesRegularExpression('~1.*hidden~',
|
||||
$tree->get_full_information($info));
|
||||
|
||||
// Hidden marker if single item is tree.
|
||||
@@ -487,13 +487,13 @@ class tree_testcase extends \advanced_testcase {
|
||||
self::mock(array('m' => '1')),
|
||||
self::mock(array('m' => '2'))), tree::OP_AND);
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~Not available \(hidden.*1.*2~',
|
||||
$this->assertMatchesRegularExpression('~Not available \(hidden.*1.*2~',
|
||||
$renderer->render($tree->get_full_information($info)));
|
||||
|
||||
// Single item tree containing single item.
|
||||
unset($structure->c[0]->c[1]);
|
||||
$tree = new tree($structure);
|
||||
$this->assertRegExp('~SA.*1.*hidden~',
|
||||
$this->assertMatchesRegularExpression('~SA.*1.*hidden~',
|
||||
$tree->get_full_information($info));
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,7 @@ class core_backup_async_helper_testcase extends \core_privacy\tests\provider_tes
|
||||
$this->assertSame('Moodle backup completed sucessfully', $email->subject);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp("/$backupid/", $email->body);
|
||||
$this->assertMatchesRegularExpression("/$backupid/", $email->body);
|
||||
$this->assertThat($email->body, $this->logicalNot($this->stringContains('{')));
|
||||
$this->assertGreaterThan(0, $messageid);
|
||||
$sink->clear();
|
||||
|
||||
@@ -128,7 +128,7 @@ class backp_settings_testcase extends basic_testcase {
|
||||
$this->assertEquals($e->errorcode, 'incorrect_object_passed');
|
||||
} catch (TypeError $e) {
|
||||
// On PHP7+ we get a TypeError raised, lets check we've the right error.
|
||||
$this->assertRegexp('/must be an instance of backup_setting_ui/', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/must be an instance of backup_setting_ui/', $e->getMessage());
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
@@ -145,7 +145,7 @@ class backp_settings_testcase extends basic_testcase {
|
||||
$this->assertEquals($e->errorcode, 'incorrect_object_passed');
|
||||
} catch (TypeError $e) {
|
||||
// On PHP7+ we get a TypeError raised, lets check we've the right error.
|
||||
$this->assertRegexp('/must be an instance of backup_setting_ui/', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/must be an instance of backup_setting_ui/', $e->getMessage());
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
@@ -354,7 +354,7 @@ class backp_settings_testcase extends basic_testcase {
|
||||
$this->assertEquals($e->errorcode, 'incorrect_object_passed');
|
||||
} catch (TypeError $e) {
|
||||
// On PHP7+ we get a TypeError raised, lets check we've the right error.
|
||||
$this->assertRegexp('/must be an instance of base_setting/', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/must be an instance of base_setting/', $e->getMessage());
|
||||
}
|
||||
restore_error_handler();
|
||||
|
||||
|
||||
@@ -265,7 +265,7 @@ class core_calendar_event_exporter_testcase extends advanced_testcase {
|
||||
|
||||
$exportedevent = $exporter->export($renderer);
|
||||
// Links should always be stripped from the course short name.
|
||||
$this->assertRegExp("/$nolinkshortname/", $exportedevent->popupname);
|
||||
$this->assertMatchesRegularExpression("/$nolinkshortname/", $exportedevent->popupname);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -455,7 +455,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
$plan = api::update_plan($record);
|
||||
$this->fail('Updating the status is not allowed.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/To change the status of a plan use the appropriate methods./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/To change the status of a plan use the appropriate methods./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Test when user with manage own plan capability try to edit other user plan.
|
||||
@@ -909,7 +909,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_request_review($tplplan);
|
||||
$this->fail('The plan is based on a template.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Template plans cannot be reviewed./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not send for review when not draft.
|
||||
@@ -919,7 +919,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_request_review($plan);
|
||||
$this->fail('The plan cannot be sent for review at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be sent for review at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not send for review when not draft.
|
||||
@@ -929,7 +929,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_request_review($plan);
|
||||
$this->fail('The plan cannot be sent for review at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be sent for review at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not send for review when not draft.
|
||||
@@ -939,7 +939,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_request_review($plan);
|
||||
$this->fail('The plan cannot be sent for review at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be sent for review at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not send for review when not draft.
|
||||
@@ -949,7 +949,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_request_review($plan);
|
||||
$this->fail('The plan cannot be sent for review at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be sent for review at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be sent for review at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Sending for review as a reviewer.
|
||||
@@ -1010,7 +1010,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_cancel_review_request($tplplan);
|
||||
$this->fail('The plan is based on a template.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Template plans cannot be reviewed./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not cancel review request when not waiting for review.
|
||||
@@ -1020,7 +1020,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_cancel_review_request($plan);
|
||||
$this->fail('The plan cannot be sent for review at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be cancelled at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not cancel review request when not waiting for review.
|
||||
@@ -1030,7 +1030,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_cancel_review_request($plan);
|
||||
$this->fail('The plan review cannot be cancelled at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be cancelled at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not cancel review request when not waiting for review.
|
||||
@@ -1040,7 +1040,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_cancel_review_request($plan);
|
||||
$this->fail('The plan review cannot be cancelled at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be cancelled at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not cancel review request when not waiting for review.
|
||||
@@ -1050,7 +1050,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_cancel_review_request($plan);
|
||||
$this->fail('The plan review cannot be cancelled at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be cancelled at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be cancelled at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Cancelling as a reviewer.
|
||||
@@ -1111,7 +1111,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_start_review($tplplan);
|
||||
$this->fail('The plan is based on a template.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Template plans cannot be reviewed./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not start a review when not waiting for review.
|
||||
@@ -1121,7 +1121,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_start_review($plan);
|
||||
$this->fail('The plan review cannot be started at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be started at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not start a review when not waiting for review.
|
||||
@@ -1131,7 +1131,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_start_review($plan);
|
||||
$this->fail('The plan review cannot be started at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be started at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not start a review when not waiting for review.
|
||||
@@ -1141,7 +1141,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_start_review($plan);
|
||||
$this->fail('The plan review cannot be started at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be started at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not start a review when not waiting for review.
|
||||
@@ -1151,7 +1151,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_start_review($plan);
|
||||
$this->fail('The plan review cannot be started at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be started at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be started at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Starting as the owner.
|
||||
@@ -1215,7 +1215,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_stop_review($tplplan);
|
||||
$this->fail('The plan is based on a template.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/Template plans cannot be reviewed./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Template plans cannot be reviewed./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not stop a review whe not in review.
|
||||
@@ -1225,7 +1225,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_stop_review($plan);
|
||||
$this->fail('The plan review cannot be stopped at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be stopped at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not stop a review whe not in review.
|
||||
@@ -1235,7 +1235,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_stop_review($plan);
|
||||
$this->fail('The plan review cannot be stopped at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be stopped at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not stop a review whe not in review.
|
||||
@@ -1245,7 +1245,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_stop_review($plan);
|
||||
$this->fail('The plan review cannot be stopped at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be stopped at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not stop a review whe not in review.
|
||||
@@ -1255,7 +1255,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::plan_stop_review($plan);
|
||||
$this->fail('The plan review cannot be stopped at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan review cannot be stopped at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan review cannot be stopped at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Stopping as the owner.
|
||||
@@ -1316,7 +1316,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::approve_plan($tplplan);
|
||||
$this->fail('The plan is based on a template.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/Template plans are already approved./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Template plans are already approved./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not approve a plan already approved.
|
||||
@@ -1326,7 +1326,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::approve_plan($plan);
|
||||
$this->fail('The plan cannot be approved at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be approved at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not approve a plan already approved.
|
||||
@@ -1336,7 +1336,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::approve_plan($plan);
|
||||
$this->fail('The plan cannot be approved at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be approved at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be approved at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Approve as the owner.
|
||||
@@ -1411,7 +1411,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::unapprove_plan($tplplan);
|
||||
$this->fail('The plan is based on a template.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/Template plans are always approved./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Template plans are always approved./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not unapprove a non-draft plan.
|
||||
@@ -1421,7 +1421,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::unapprove_plan($plan);
|
||||
$this->fail('The plan cannot be sent back to draft at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be sent back to draft at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not unapprove a non-draft plan.
|
||||
@@ -1431,7 +1431,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::unapprove_plan($plan);
|
||||
$this->fail('The plan cannot be sent back to draft at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be sent back to draft at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not unapprove a non-draft plan.
|
||||
@@ -1441,7 +1441,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::unapprove_plan($plan);
|
||||
$this->fail('The plan cannot be sent back to draft at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be sent back to draft at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Can not unapprove a non-draft plan.
|
||||
@@ -1451,7 +1451,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::unapprove_plan($plan);
|
||||
$this->fail('The plan cannot be sent back to draft at this stage.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/The plan cannot be sent back to draft at this stage./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/The plan cannot be sent back to draft at this stage./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Unapprove as the owner.
|
||||
@@ -2074,7 +2074,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
'error', null, false, null, 1);
|
||||
$this->fail('A grade can not be set');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/grade MUST NOT be set/', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/grade MUST NOT be set/', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2170,7 +2170,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
api::add_evidence($u1->id, $c2->get('id'), $u1ctx->id, \core_competency\evidence::ACTION_COMPLETE, 'invaliddata',
|
||||
'error', null, false, null, 1);
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/grade MUST NOT be set/', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/grade MUST NOT be set/', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4063,7 +4063,7 @@ class core_competency_api_testcase extends advanced_testcase {
|
||||
} catch (moodle_exception $e) {
|
||||
$raised = true;
|
||||
$this->assertInstanceOf($exceptiontype, $e);
|
||||
$this->assertRegExp('@' . $exceptiontext . '@', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('@' . $exceptiontext . '@', $e->getMessage());
|
||||
}
|
||||
|
||||
if (!$raised) {
|
||||
|
||||
@@ -714,7 +714,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
$this->fail('To log the user competency in completed plan '
|
||||
. 'use user_competency_plan_viewed method.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/To log the user competency in completed plan '
|
||||
$this->assertMatchesRegularExpression('/To log the user competency in completed plan '
|
||||
. 'use user_competency_plan_viewed method./', $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -750,7 +750,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_viewed_in_plan::create($params)->trigger();
|
||||
$this->fail('The \'competencyid\' and \'planid\' values must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'competencyid' and 'planid' values must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'competencyid' and 'planid' values must be set./", $e->getMessage());
|
||||
}
|
||||
|
||||
$params['other']['anythingelse'] = '';
|
||||
@@ -759,7 +759,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_viewed_in_plan::create($params)->trigger();
|
||||
$this->fail('The \'competencyid\' value must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'competencyid' value must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'competencyid' value must be set./", $e->getMessage());
|
||||
}
|
||||
|
||||
$params['other']['competencyid'] = $c->get('id');
|
||||
@@ -768,7 +768,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_viewed_in_plan::create($params)->trigger();
|
||||
$this->fail('The \'planid\' value must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'planid' value must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'planid' value must be set./", $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -820,7 +820,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_viewed_in_course::create($params)->trigger();
|
||||
$this->fail('The \'courseid\' value must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'courseid' value must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'courseid' value must be set./", $e->getMessage());
|
||||
}
|
||||
|
||||
$params['contextid'] = context_course::instance($course->id)->id;
|
||||
@@ -830,7 +830,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_viewed_in_course::create($params)->trigger();
|
||||
$this->fail('The \'competencyid\' value must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'competencyid' value must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'competencyid' value must be set./", $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -859,7 +859,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
$this->fail('To log the user competency in non-completed plan '
|
||||
. 'use user_competency_viewed_in_plan method.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/To log the user competency in non-completed plan '
|
||||
$this->assertMatchesRegularExpression('/To log the user competency in non-completed plan '
|
||||
. 'use user_competency_viewed_in_plan method./', $e->getMessage());
|
||||
}
|
||||
|
||||
@@ -897,7 +897,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_plan_viewed::create($params)->trigger();
|
||||
$this->fail('The \'competencyid\' and \'planid\' values must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'competencyid' and 'planid' values must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'competencyid' and 'planid' values must be set./", $e->getMessage());
|
||||
}
|
||||
|
||||
$params['other']['anythingelse'] = '';
|
||||
@@ -906,7 +906,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_plan_viewed::create($params)->trigger();
|
||||
$this->fail('The \'competencyid\' value must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'competencyid' value must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'competencyid' value must be set./", $e->getMessage());
|
||||
}
|
||||
|
||||
$params['other']['competencyid'] = $c->get('id');
|
||||
@@ -915,7 +915,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_plan_viewed::create($params)->trigger();
|
||||
$this->fail('The \'planid\' value must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'planid' value must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'planid' value must be set./", $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -965,7 +965,7 @@ class core_competency_event_testcase extends advanced_testcase {
|
||||
\core\event\competency_user_competency_viewed::create($params)->trigger();
|
||||
$this->fail('The \'competencyid\' value must be set.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp("/The 'competencyid' value must be set./", $e->getMessage());
|
||||
$this->assertMatchesRegularExpression("/The 'competencyid' value must be set./", $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -614,7 +614,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
$result = $this->update_competency_framework($f2->get('id'), 4, true);
|
||||
$this->fail('The scale cannot be changed once used.');
|
||||
} catch (\core\invalid_persistent_exception $e) {
|
||||
$this->assertRegexp('/scaleid/', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/scaleid/', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,7 +1223,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
$plan4 = $this->create_plan(6, $this->creator->id, 0, plan::STATUS_COMPLETE, 0);
|
||||
$this->fail('Plans cannot be created as complete.');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegexp('/A plan cannot be created as complete./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/A plan cannot be created as complete./', $e->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -1241,7 +1241,7 @@ class core_competency_external_testcase extends externallib_advanced_testcase {
|
||||
$this->update_plan($plan2->id, 1, $this->user->id, 0, plan::STATUS_ACTIVE, 0);
|
||||
$this->fail('The user can not update their own plan without permissions.');
|
||||
} catch (required_capability_exception $e) {
|
||||
$this->assertRegexp('/Manage learning plans./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Manage learning plans./', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3070,11 +3070,11 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||
$this->setAdminUser();
|
||||
$res = course_get_tagged_course_modules(core_tag_tag::get_by_name(0, 'Cat'),
|
||||
/*$exclusivemode = */false, /*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$page = */0);
|
||||
$this->assertRegExp('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm31->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm31->name.'/', $res->content);
|
||||
// Results from course1 are returned before results from course2.
|
||||
$this->assertTrue(strpos($res->content, $cm11->name) < strpos($res->content, $cm21->name));
|
||||
|
||||
@@ -3096,21 +3096,21 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||
$context = context_course::instance($course1->id);
|
||||
$res = course_get_tagged_course_modules(core_tag_tag::get_by_name(0, 'Cat'),
|
||||
/*$exclusivemode = */false, /*$fromctx = */0, /*$ctx = */$context->id, /*$rec = */1, /*$page = */0);
|
||||
$this->assertRegExp('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm31->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm31->name.'/', $res->content);
|
||||
|
||||
// Searching FROM the course context returns visible modules in all courses.
|
||||
$context = context_course::instance($course2->id);
|
||||
$res = course_get_tagged_course_modules(core_tag_tag::get_by_name(0, 'Cat'),
|
||||
/*$exclusivemode = */false, /*$fromctx = */$context->id, /*$ctx = */0, /*$rec = */1, /*$page = */0);
|
||||
$this->assertRegExp('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm31->name.'/', $res->content); // No access to course3.
|
||||
$this->assertMatchesRegularExpression('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm31->name.'/', $res->content); // No access to course3.
|
||||
// Results from course2 are returned before results from course1.
|
||||
$this->assertTrue(strpos($res->content, $cm21->name) < strpos($res->content, $cm11->name));
|
||||
|
||||
@@ -3121,7 +3121,7 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||
$context = context_course::instance($course1->id);
|
||||
$res = course_get_tagged_course_modules(core_tag_tag::get_by_name(0, 'Cat'),
|
||||
/*$exclusivemode = */false, /*$fromctx = */$context->id, /*$ctx = */0, /*$rec = */1, /*$page = */0);
|
||||
$this->assertRegExp('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm12->name.'/', $res->content);
|
||||
|
||||
// Create more modules and try pagination.
|
||||
$cm14 = $this->getDataGenerator()->create_module('assign', array('course' => $course1->id,
|
||||
@@ -3134,27 +3134,27 @@ class core_course_courselib_testcase extends advanced_testcase {
|
||||
$context = context_course::instance($course1->id);
|
||||
$res = course_get_tagged_course_modules(core_tag_tag::get_by_name(0, 'Cat'),
|
||||
/*$exclusivemode = */false, /*$fromctx = */0, /*$ctx = */$context->id, /*$rec = */1, /*$page = */0);
|
||||
$this->assertRegExp('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm14->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm15->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm16->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm31->name.'/', $res->content); // No access to course3.
|
||||
$this->assertMatchesRegularExpression('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm14->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm15->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm16->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm31->name.'/', $res->content); // No access to course3.
|
||||
$this->assertEmpty($res->prevpageurl);
|
||||
$this->assertNotEmpty($res->nextpageurl);
|
||||
|
||||
$res = course_get_tagged_course_modules(core_tag_tag::get_by_name(0, 'Cat'),
|
||||
/*$exclusivemode = */false, /*$fromctx = */0, /*$ctx = */$context->id, /*$rec = */1, /*$page = */1);
|
||||
$this->assertNotRegExp('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm14->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm15->name.'/', $res->content);
|
||||
$this->assertRegExp('/'.$cm16->name.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$cm31->name.'/', $res->content); // No access to course3.
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm11->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm12->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm13->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm21->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm14->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm15->name.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$cm16->name.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$cm31->name.'/', $res->content); // No access to course3.
|
||||
$this->assertNotEmpty($res->prevpageurl);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
}
|
||||
|
||||
@@ -66,18 +66,18 @@ class filter_data_filter_testcase extends advanced_testcase {
|
||||
|
||||
// Testing at course level (both site and course).
|
||||
$filtered = format_text($html, FORMAT_HTML, array('context' => $coursecontext1));
|
||||
$this->assertRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
|
||||
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
|
||||
$this->assertMatchesRegularExpression('/title=(\'|")CourseEntry(\'|")/', $filtered);
|
||||
$this->assertMatchesRegularExpression('/title=(\'|")SiteEntry(\'|")/', $filtered);
|
||||
|
||||
// Testing at site level (only site).
|
||||
$filtered = format_text($html, FORMAT_HTML, array('context' => $sitecontext));
|
||||
$this->assertNotRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
|
||||
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
|
||||
$this->assertDoesNotMatchRegularExpression('/title=(\'|")CourseEntry(\'|")/', $filtered);
|
||||
$this->assertMatchesRegularExpression('/title=(\'|")SiteEntry(\'|")/', $filtered);
|
||||
|
||||
// Changing to another course to test the caches invalidation (only site).
|
||||
$filtered = format_text($html, FORMAT_HTML, array('context' => $coursecontext2));
|
||||
$this->assertNotRegExp('/title=(\'|")CourseEntry(\'|")/', $filtered);
|
||||
$this->assertRegExp('/title=(\'|")SiteEntry(\'|")/', $filtered);
|
||||
$this->assertDoesNotMatchRegularExpression('/title=(\'|")CourseEntry(\'|")/', $filtered);
|
||||
$this->assertMatchesRegularExpression('/title=(\'|")SiteEntry(\'|")/', $filtered);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -60,7 +60,7 @@ class filter_displayh5p_testcase extends advanced_testcase {
|
||||
$filterplugin = new filter_displayh5p(null, array());
|
||||
|
||||
$filteredtext = $filterplugin->filter($text);
|
||||
$this->assertRegExp($filteredtextpattern, $filteredtext);
|
||||
$this->assertMatchesRegularExpression($filteredtextpattern, $filteredtext);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2228,7 +2228,7 @@ class core_ddl_testcase extends database_driver_testcase {
|
||||
$result1 = $gen->getNameForObject($table, $fields, $suffix);
|
||||
|
||||
// Make sure we end up with _fl2_ in the result.
|
||||
$this->assertRegExp('/_fl2_/', $result1);
|
||||
$this->assertMatchesRegularExpression('/_fl2_/', $result1);
|
||||
|
||||
// Now, use a field that would result in the same key if it wasn't already taken.
|
||||
$fields = "fl2";
|
||||
@@ -2237,7 +2237,7 @@ class core_ddl_testcase extends database_driver_testcase {
|
||||
// - _fl2_ (removing the original 2, and adding a counter 2)
|
||||
// - then settle on _fl3_.
|
||||
$result2 = $gen->getNameForObject($table, $fields, $suffix);
|
||||
$this->assertRegExp('/_fl3_/', $result2);
|
||||
$this->assertMatchesRegularExpression('/_fl3_/', $result2);
|
||||
|
||||
// Make sure they don't match.
|
||||
$this->assertNotEquals($result1, $result2);
|
||||
@@ -2249,7 +2249,7 @@ class core_ddl_testcase extends database_driver_testcase {
|
||||
$result3 = $gen->getNameForObject($table, $fields, $suffix);
|
||||
|
||||
$this->assertNotEquals($result2, $result3);
|
||||
$this->assertRegExp('/_fl4_/', $result3);
|
||||
$this->assertMatchesRegularExpression('/_fl4_/', $result3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class core_dml_read_slave_testcase extends base_testcase {
|
||||
* @return void
|
||||
*/
|
||||
private function assert_readonly_handle($handle) : void {
|
||||
$this->assertRegExp('/^test_ro\d:\d:test\d:test\d$/', $handle);
|
||||
$this->assertMatchesRegularExpression('/^test_ro\d:\d:test\d:test\d$/', $handle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -4495,7 +4495,7 @@ EOD;
|
||||
$this->assertInstanceOf('coding_exception', $e);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error even earlier.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
|
||||
// Cover the function using placeholders in all positions.
|
||||
|
||||
@@ -144,7 +144,7 @@ class pgsql_native_moodle_database_testcase extends advanced_testcase {
|
||||
list($usql, $params) = $DB->get_in_or_equal($invalues, SQL_PARAMS_NAMED);
|
||||
$regex = '/^'.
|
||||
preg_quote('IN (VALUES (:param'.$index.'::bigint),(:param'.++$index.'::bigint),(:param'.++$index.'::bigint)').'/';
|
||||
$this->assertRegExp($regex, $usql);
|
||||
$this->assertMatchesRegularExpression($regex, $usql);
|
||||
foreach ($params as $value) {
|
||||
$this->assertEquals(current($invalues), $value);
|
||||
next($invalues);
|
||||
@@ -160,7 +160,7 @@ class pgsql_native_moodle_database_testcase extends advanced_testcase {
|
||||
// We are in same DBI instance, expect uniqie param indexes.
|
||||
$regex = '/^'.
|
||||
preg_quote('IN (VALUES (:ppp'.$index.'::bigint),(:ppp'.++$index.'::bigint),(:ppp'.++$index.'::bigint)').'/';
|
||||
$this->assertRegExp($regex, $usql);
|
||||
$this->assertMatchesRegularExpression($regex, $usql);
|
||||
foreach ($params as $value) {
|
||||
$this->assertEquals(current($invalues), $value);
|
||||
next($invalues);
|
||||
@@ -172,7 +172,7 @@ class pgsql_native_moodle_database_testcase extends advanced_testcase {
|
||||
// 65535 values, string.
|
||||
$invalues = array_fill(1, 65535, 'abc');
|
||||
list($usql, $params) = $DB->get_in_or_equal($invalues);
|
||||
$this->assertRegExp('/^' . preg_quote('IN (VALUES (?::text),(?::text),(?::text)') . '/', $usql);
|
||||
$this->assertMatchesRegularExpression('/^' . preg_quote('IN (VALUES (?::text),(?::text),(?::text)') . '/', $usql);
|
||||
foreach ($params as $value) {
|
||||
$this->assertEquals(current($invalues), $value);
|
||||
next($invalues);
|
||||
|
||||
@@ -423,7 +423,7 @@ class pgsql_native_recordset_testcase extends basic_testcase {
|
||||
if (!array_key_exists($index, $expected)) {
|
||||
$this->fail('More queries than expected');
|
||||
}
|
||||
$this->assertRegExp($expected[$index++], $line);
|
||||
$this->assertMatchesRegularExpression($expected[$index++], $line);
|
||||
}
|
||||
if (array_key_exists($index, $expected)) {
|
||||
$this->fail('Fewer queries than expected');
|
||||
|
||||
@@ -393,7 +393,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
|
||||
$this->assertEquals($userrepository->id, $newstoredfile->get_repository_id());
|
||||
$this->assertEquals($originalfile->get_contenthash(), $newstoredfile->get_contenthash());
|
||||
$this->assertEquals($originalfile->get_filesize(), $newstoredfile->get_filesize());
|
||||
$this->assertRegExp('#' . $filename. '$#', $newstoredfile->get_reference_details());
|
||||
$this->assertMatchesRegularExpression('#' . $filename. '$#', $newstoredfile->get_reference_details());
|
||||
|
||||
// Test looking for references.
|
||||
$count = $fs->get_references_count_by_storedfile($originalfile);
|
||||
@@ -485,7 +485,7 @@ class core_files_file_storage_testcase extends advanced_testcase {
|
||||
$this->assertEquals($userrepository->id, $newstoredfile->get_repository_id());
|
||||
$this->assertEquals($originalfile->get_contenthash(), $newstoredfile->get_contenthash());
|
||||
$this->assertEquals($originalfile->get_filesize(), $newstoredfile->get_filesize());
|
||||
$this->assertRegExp('#' . $filename . '$#', $newstoredfile->get_reference_details());
|
||||
$this->assertMatchesRegularExpression('#' . $filename . '$#', $newstoredfile->get_reference_details());
|
||||
}
|
||||
|
||||
private function setup_three_private_files() {
|
||||
|
||||
@@ -142,18 +142,18 @@ class core_test_generator_testcase extends advanced_testcase {
|
||||
$count = $DB->count_records('course_categories');
|
||||
$category = $generator->create_category();
|
||||
$this->assertEquals($count+1, $DB->count_records('course_categories'));
|
||||
$this->assertRegExp('/^Course category \d/', $category->name);
|
||||
$this->assertMatchesRegularExpression('/^Course category \d/', $category->name);
|
||||
$this->assertSame('', $category->idnumber);
|
||||
$this->assertRegExp('/^Test course category \d/', $category->description);
|
||||
$this->assertMatchesRegularExpression('/^Test course category \d/', $category->description);
|
||||
$this->assertSame(FORMAT_MOODLE, $category->descriptionformat);
|
||||
|
||||
$count = $DB->count_records('cohort');
|
||||
$cohort = $generator->create_cohort();
|
||||
$this->assertEquals($count+1, $DB->count_records('cohort'));
|
||||
$this->assertEquals(context_system::instance()->id, $cohort->contextid);
|
||||
$this->assertRegExp('/^Cohort \d/', $cohort->name);
|
||||
$this->assertMatchesRegularExpression('/^Cohort \d/', $cohort->name);
|
||||
$this->assertSame('', $cohort->idnumber);
|
||||
$this->assertRegExp("/^Description for '{$cohort->name}' \\n/", $cohort->description);
|
||||
$this->assertMatchesRegularExpression("/^Description for '{$cohort->name}' \\n/", $cohort->description);
|
||||
$this->assertSame(FORMAT_MOODLE, $cohort->descriptionformat);
|
||||
$this->assertSame('', $cohort->component);
|
||||
$this->assertLessThanOrEqual(time(), $cohort->timecreated);
|
||||
@@ -162,13 +162,13 @@ class core_test_generator_testcase extends advanced_testcase {
|
||||
$count = $DB->count_records('course');
|
||||
$course = $generator->create_course();
|
||||
$this->assertEquals($count+1, $DB->count_records('course'));
|
||||
$this->assertRegExp('/^Test course \d/', $course->fullname);
|
||||
$this->assertRegExp('/^tc_\d/', $course->shortname);
|
||||
$this->assertMatchesRegularExpression('/^Test course \d/', $course->fullname);
|
||||
$this->assertMatchesRegularExpression('/^tc_\d/', $course->shortname);
|
||||
$this->assertSame('', $course->idnumber);
|
||||
$this->assertSame('topics', $course->format);
|
||||
$this->assertEquals(0, $course->newsitems);
|
||||
$this->assertEquals(5, course_get_format($course)->get_last_section_number());
|
||||
$this->assertRegExp('/^Test course \d/', $course->summary);
|
||||
$this->assertMatchesRegularExpression('/^Test course \d/', $course->summary);
|
||||
$this->assertSame(FORMAT_MOODLE, $course->summaryformat);
|
||||
|
||||
$section = $generator->create_course_section(array('course'=>$course->id, 'section'=>3));
|
||||
|
||||
@@ -156,15 +156,15 @@ class core_admintree_testcase extends advanced_testcase {
|
||||
|
||||
// Check for an invalid path.
|
||||
$result = $executable->output_html($CFG->dirroot . '/lib/tests/other/file_does_not_exist');
|
||||
$this->assertRegexp('/class="text-danger"/', $result);
|
||||
$this->assertMatchesRegularExpression('/class="text-danger"/', $result);
|
||||
|
||||
// Check for a directory.
|
||||
$result = $executable->output_html($CFG->dirroot);
|
||||
$this->assertRegexp('/class="text-danger"/', $result);
|
||||
$this->assertMatchesRegularExpression('/class="text-danger"/', $result);
|
||||
|
||||
// Check for a file which is not executable.
|
||||
$result = $executable->output_html($CFG->dirroot . '/filter/tex/readme_moodle.txt');
|
||||
$this->assertRegexp('/class="text-danger"/', $result);
|
||||
$this->assertMatchesRegularExpression('/class="text-danger"/', $result);
|
||||
|
||||
// Check for an executable file.
|
||||
if ($CFG->ostype == 'WINDOWS') {
|
||||
@@ -173,12 +173,12 @@ class core_admintree_testcase extends advanced_testcase {
|
||||
$filetocheck = 'mimetex.darwin';
|
||||
}
|
||||
$result = $executable->output_html($CFG->dirroot . '/filter/tex/' . $filetocheck);
|
||||
$this->assertRegexp('/class="text-success"/', $result);
|
||||
$this->assertMatchesRegularExpression('/class="text-success"/', $result);
|
||||
|
||||
// Check for no file specified.
|
||||
$result = $executable->output_html('');
|
||||
$this->assertRegexp('/name="s__test1"/', $result);
|
||||
$this->assertRegexp('/value=""/', $result);
|
||||
$this->assertMatchesRegularExpression('/name="s__test1"/', $result);
|
||||
$this->assertMatchesRegularExpression('/value=""/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,7 +92,7 @@ class core_media_player_native_testcase extends advanced_testcase {
|
||||
$title = 'Some Filename Video';
|
||||
$content = $player->embed($urls, $title, 0, 0, []);
|
||||
|
||||
$this->assertRegExp('~title="' . $title . '"~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="' . $title . '"~', $content);
|
||||
$this->assertEquals($title, media_test_native_plugin::get_attribute($content, 'title'));
|
||||
}
|
||||
|
||||
@@ -112,27 +112,27 @@ class core_media_player_native_testcase extends advanced_testcase {
|
||||
|
||||
// Add attributes.
|
||||
$content = media_test_native_plugin::add_attributes($content, ['preload' => 'none', 'controls' => 'true']);
|
||||
$this->assertRegExp('~title="' . $title . '"~', $content);
|
||||
$this->assertRegExp('~preload="none"~', $content);
|
||||
$this->assertRegExp('~controls="true"~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="' . $title . '"~', $content);
|
||||
$this->assertMatchesRegularExpression('~preload="none"~', $content);
|
||||
$this->assertMatchesRegularExpression('~controls="true"~', $content);
|
||||
|
||||
// Change existing attribute.
|
||||
$content = media_test_native_plugin::add_attributes($content, ['controls' => 'false']);
|
||||
$this->assertRegExp('~title="' . $title . '"~', $content);
|
||||
$this->assertRegExp('~preload="none"~', $content);
|
||||
$this->assertRegExp('~controls="false"~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="' . $title . '"~', $content);
|
||||
$this->assertMatchesRegularExpression('~preload="none"~', $content);
|
||||
$this->assertMatchesRegularExpression('~controls="false"~', $content);
|
||||
|
||||
// Remove attributes.
|
||||
$content = media_test_native_plugin::remove_attributes($content, ['title']);
|
||||
$this->assertNotRegExp('~title="' . $title . '"~', $content);
|
||||
$this->assertRegExp('~preload="none"~', $content);
|
||||
$this->assertRegExp('~controls="false"~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~title="' . $title . '"~', $content);
|
||||
$this->assertMatchesRegularExpression('~preload="none"~', $content);
|
||||
$this->assertMatchesRegularExpression('~controls="false"~', $content);
|
||||
|
||||
// Remove another one.
|
||||
$content = media_test_native_plugin::remove_attributes($content, ['preload']);
|
||||
$this->assertNotRegExp('~title="' . $title . '"~', $content);
|
||||
$this->assertNotRegExp('~preload="none"~', $content);
|
||||
$this->assertRegExp('~controls="false"~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~title="' . $title . '"~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~preload="none"~', $content);
|
||||
$this->assertMatchesRegularExpression('~controls="false"~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -104,7 +104,7 @@ class core_filelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('stdClass', $response);
|
||||
$this->assertSame('200', $response->status);
|
||||
$this->assertTrue(is_array($response->headers));
|
||||
$this->assertRegExp('|^HTTP/1\.[01] 200 OK$|', rtrim($response->response_code));
|
||||
$this->assertMatchesRegularExpression('|^HTTP/1\.[01] 200 OK$|', rtrim($response->response_code));
|
||||
$this->assertSame($contents, $response->results);
|
||||
$this->assertSame('', $response->error);
|
||||
|
||||
@@ -128,7 +128,7 @@ class core_filelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('stdClass', $response);
|
||||
$this->assertSame('404', $response->status);
|
||||
$this->assertTrue(is_array($response->headers));
|
||||
$this->assertRegExp('|^HTTP/1\.[01] 404 Not Found$|', rtrim($response->response_code));
|
||||
$this->assertMatchesRegularExpression('|^HTTP/1\.[01] 404 Not Found$|', rtrim($response->response_code));
|
||||
// Do not test the response starts with DOCTYPE here because some servers may return different headers.
|
||||
$this->assertSame('', $response->error);
|
||||
|
||||
@@ -149,7 +149,7 @@ class core_filelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('stdClass', $response);
|
||||
$this->assertSame('200', $response->status);
|
||||
$this->assertTrue(is_array($response->headers));
|
||||
$this->assertRegExp('|^HTTP/1\.[01] 200 OK$|', rtrim($response->response_code));
|
||||
$this->assertMatchesRegularExpression('|^HTTP/1\.[01] 200 OK$|', rtrim($response->response_code));
|
||||
$this->assertSame('done', $response->results);
|
||||
$this->assertSame('', $response->error);
|
||||
|
||||
@@ -691,7 +691,7 @@ class core_filelib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($userrepository->id, $fileref->get_repository_id());
|
||||
$this->assertSame($userfile->get_contenthash(), $fileref->get_contenthash());
|
||||
$this->assertEquals($userfile->get_filesize(), $fileref->get_filesize());
|
||||
$this->assertRegExp('#' . $userfile->get_filename(). '$#', $fileref->get_reference_details());
|
||||
$this->assertMatchesRegularExpression('#' . $userfile->get_filename(). '$#', $fileref->get_reference_details());
|
||||
|
||||
$draftitemid = 0;
|
||||
file_prepare_draft_area($draftitemid, $syscontext->id, $component, $filearea, $itemid);
|
||||
@@ -789,7 +789,7 @@ class core_filelib_testcase extends advanced_testcase {
|
||||
$this->assertEquals($userrepository->id, $fileref->get_repository_id());
|
||||
$this->assertSame($userfile->get_contenthash(), $fileref->get_contenthash());
|
||||
$this->assertEquals($userfile->get_filesize(), $fileref->get_filesize());
|
||||
$this->assertRegExp('#' . $userfile->get_filename(). '$#', $fileref->get_reference_details());
|
||||
$this->assertMatchesRegularExpression('#' . $userfile->get_filename(). '$#', $fileref->get_reference_details());
|
||||
|
||||
$draftitemid = 0;
|
||||
file_prepare_draft_area($draftitemid, $usercontext->id, 'user', 'private', 0);
|
||||
|
||||
@@ -54,7 +54,7 @@ class core_filter_manager_testcase extends advanced_testcase {
|
||||
public function test_filter_normal() {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
$this->assertRegExp('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
$this->filter_text('<p>:-)</p>', array()));
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ class core_filter_manager_testcase extends advanced_testcase {
|
||||
public function test_disabling_other_filter_does_not_break_it() {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
$this->assertRegExp('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
$this->filter_text('<p>:-)</p>', array('urltolink')));
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class core_filter_manager_testcase extends advanced_testcase {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
filter_set_global_state('urltolink', TEXTFILTER_ON);
|
||||
$this->assertRegExp('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /> http://google.com/</p>$~',
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" title="smile" src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /> http://google.com/</p>$~',
|
||||
$this->filter_text('<p>:-) http://google.com/</p>', array('glossary', 'urltolink')));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ class core_message_testcase extends advanced_testcase {
|
||||
$this->assertSame(get_string('unreadnewmessage', 'message', fullname($user1)), $email->subject);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp('/test message body.*test/s', $email->body);
|
||||
$this->assertMatchesRegularExpression('/test message body.*test/s', $email->body);
|
||||
$sink->clear();
|
||||
|
||||
// Test that event fired includes the courseid.
|
||||
@@ -214,7 +214,7 @@ class core_message_testcase extends advanced_testcase {
|
||||
$this->assertSame(get_string('unreadnewmessage', 'message', fullname($user1)), $email->subject);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertNotRegExp('/test message body test/', $email->body);
|
||||
$this->assertDoesNotMatchRegularExpression('/test message body test/', $email->body);
|
||||
|
||||
// Test that event fired includes the courseid.
|
||||
$eventsink = $this->redirectEvents();
|
||||
|
||||
@@ -808,7 +808,7 @@ class core_messagelib_testcase extends advanced_testcase {
|
||||
// so verify the expected beginning and ends.
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp('/test message body.*test/s', $email->body);
|
||||
$this->assertMatchesRegularExpression('/test message body.*test/s', $email->body);
|
||||
$sink->clear();
|
||||
|
||||
// Now, send the message again, and verify that the event fired includes the courseid and conversationid.
|
||||
|
||||
@@ -271,7 +271,7 @@ class core_moodle_url_testcase extends advanced_testcase {
|
||||
|
||||
$CFG->slasharguments = $slashargs;
|
||||
$url = call_user_func_array('moodle_url::make_pluginfile_url', $args);
|
||||
$this->assertRegexp($expected, $url->out(true));
|
||||
$this->assertMatchesRegularExpression($expected, $url->out(true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -210,7 +210,7 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('coding_exception', $ex);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error even earlier.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
try {
|
||||
@optional_param('username');
|
||||
@@ -219,7 +219,7 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('coding_exception', $ex);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error even earlier.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
try {
|
||||
optional_param('', 'default_user', PARAM_RAW);
|
||||
@@ -262,7 +262,7 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('coding_exception', $ex);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error even earlier.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
try {
|
||||
@optional_param_array('username');
|
||||
@@ -271,7 +271,7 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('coding_exception', $ex);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error even earlier.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
try {
|
||||
optional_param_array('', array('a'=>'default_user'), PARAM_RAW);
|
||||
@@ -325,7 +325,7 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('coding_exception', $ex);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error even earlier.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
try {
|
||||
required_param('username', '');
|
||||
@@ -371,7 +371,7 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('coding_exception', $ex);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
try {
|
||||
required_param_array('', PARAM_RAW);
|
||||
@@ -435,7 +435,7 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('moodle_exception', $ex);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error even earlier.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -458,7 +458,7 @@ class core_moodlelib_testcase extends advanced_testcase {
|
||||
$this->assertInstanceOf('moodle_exception', $ex);
|
||||
} catch (Error $error) {
|
||||
// PHP 7.1 throws Error even earlier.
|
||||
$this->assertRegExp('/Too few arguments to function/', $error->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Too few arguments to function/', $error->getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -2455,7 +2455,7 @@ EOF;
|
||||
$this->assertEquals(0, $deluser->picture);
|
||||
$this->assertSame('', $deluser->idnumber);
|
||||
$this->assertSame(md5($user->username), $deluser->email);
|
||||
$this->assertRegExp('/^'.preg_quote($user->email, '/').'\.\d*$/', $deluser->username);
|
||||
$this->assertMatchesRegularExpression('/^'.preg_quote($user->email, '/').'\.\d*$/', $deluser->username);
|
||||
|
||||
$this->assertEquals(1, $DB->count_records('user', array('deleted'=>1)));
|
||||
|
||||
@@ -2556,7 +2556,7 @@ EOF;
|
||||
|
||||
// It should start with the user name, and end with the current time.
|
||||
$this->assertStringStartsWith("{$user->username}.{$user->id}@", $usernamedeleted);
|
||||
$this->assertRegExp('/\.\d{' . $timestrlength . '}$/', $usernamedeleted);
|
||||
$this->assertMatchesRegularExpression('/\.\d{' . $timestrlength . '}$/', $usernamedeleted);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2582,7 +2582,7 @@ EOF;
|
||||
|
||||
// Max username length is 100 chars. Select up to limit - (length of current time + 1 [period character]) from users email.
|
||||
$expectedemail = core_text::substr($user->email, 0, 100 - ($timestrlength + 1));
|
||||
$this->assertRegExp('/^' . preg_quote($expectedemail) . '\.\d{' . $timestrlength . '}$/', $usernamedeleted);
|
||||
$this->assertMatchesRegularExpression('/^' . preg_quote($expectedemail) . '\.\d{' . $timestrlength . '}$/', $usernamedeleted);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2874,8 +2874,8 @@ EOF;
|
||||
$this->assertFalse(password_is_legacy_hash($hash));
|
||||
|
||||
// Check that cost factor in hash is correctly set.
|
||||
$this->assertRegExp('/\$10\$/', $hash);
|
||||
$this->assertRegExp('/\$04\$/', $fasthash);
|
||||
$this->assertMatchesRegularExpression('/\$10\$/', $hash);
|
||||
$this->assertMatchesRegularExpression('/\$04\$/', $fasthash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4077,21 +4077,21 @@ EOF;
|
||||
|
||||
$result = random_string(10);
|
||||
$this->assertSame(10, strlen($result));
|
||||
$this->assertRegExp('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertMatchesRegularExpression('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertNotSame($result, random_string(10));
|
||||
|
||||
$result = random_string(21);
|
||||
$this->assertSame(21, strlen($result));
|
||||
$this->assertRegExp('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertMatchesRegularExpression('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertNotSame($result, random_string(21));
|
||||
|
||||
$result = random_string(666);
|
||||
$this->assertSame(666, strlen($result));
|
||||
$this->assertRegExp('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertMatchesRegularExpression('/^[' . $pool . ']+$/', $result);
|
||||
|
||||
$result = random_string();
|
||||
$this->assertSame(15, strlen($result));
|
||||
$this->assertRegExp('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertMatchesRegularExpression('/^[' . $pool . ']+$/', $result);
|
||||
|
||||
$this->assertDebuggingNotCalled();
|
||||
|
||||
@@ -4112,21 +4112,21 @@ EOF;
|
||||
|
||||
$result = complex_random_string(10);
|
||||
$this->assertSame(10, strlen($result));
|
||||
$this->assertRegExp('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertMatchesRegularExpression('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertNotSame($result, complex_random_string(10));
|
||||
|
||||
$result = complex_random_string(21);
|
||||
$this->assertSame(21, strlen($result));
|
||||
$this->assertRegExp('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertMatchesRegularExpression('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertNotSame($result, complex_random_string(21));
|
||||
|
||||
$result = complex_random_string(666);
|
||||
$this->assertSame(666, strlen($result));
|
||||
$this->assertRegExp('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertMatchesRegularExpression('/^[' . $pool . ']+$/', $result);
|
||||
|
||||
$result = complex_random_string();
|
||||
$this->assertEqualsWithDelta(28, strlen($result), 4); // Expected length is 24 - 32.
|
||||
$this->assertRegExp('/^[' . $pool . ']+$/', $result);
|
||||
$this->assertMatchesRegularExpression('/^[' . $pool . ']+$/', $result);
|
||||
|
||||
$this->assertDebuggingNotCalled();
|
||||
|
||||
@@ -4914,7 +4914,7 @@ EOF;
|
||||
$newname = rename_to_unused_name($file);
|
||||
|
||||
// Check new name has expected format.
|
||||
$this->assertRegExp('~/_temp_[a-f0-9]+$~', $newname);
|
||||
$this->assertMatchesRegularExpression('~/_temp_[a-f0-9]+$~', $newname);
|
||||
|
||||
// Check it's still in the same folder.
|
||||
$this->assertEquals($CFG->dataroot, dirname($newname));
|
||||
@@ -4940,7 +4940,7 @@ EOF;
|
||||
$newname = rename_to_unused_name($file);
|
||||
|
||||
// Check new name has expected format.
|
||||
$this->assertRegExp('~/_temp_[a-f0-9]+$~', $newname);
|
||||
$this->assertMatchesRegularExpression('~/_temp_[a-f0-9]+$~', $newname);
|
||||
|
||||
// Check it's still in the same folder.
|
||||
$this->assertEquals($CFG->dataroot, dirname($newname));
|
||||
|
||||
@@ -92,7 +92,7 @@ class core_plugin_manager_testcase extends advanced_testcase {
|
||||
foreach ($types as $type => $fulldir) {
|
||||
$installed = core_plugin_manager::instance()->get_installed_plugins($type);
|
||||
foreach ($installed as $plugin => $version) {
|
||||
$this->assertRegExp('/^[a-z]+[a-z0-9_]*$/', $plugin);
|
||||
$this->assertMatchesRegularExpression('/^[a-z]+[a-z0-9_]*$/', $plugin);
|
||||
$this->assertTrue(is_numeric($version), 'All plugins should have a version, plugin '.$type.'_'.$plugin.' does not have version info.');
|
||||
}
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class core_plugin_manager_testcase extends advanced_testcase {
|
||||
$enabled = core_plugin_manager::instance()->get_enabled_plugins($type);
|
||||
if (is_array($enabled)) {
|
||||
foreach ($enabled as $key => $val) {
|
||||
$this->assertRegExp('/^[a-z]+[a-z0-9_]*$/', $key);
|
||||
$this->assertMatchesRegularExpression('/^[a-z]+[a-z0-9_]*$/', $key);
|
||||
$this->assertSame($key, $val);
|
||||
}
|
||||
} else {
|
||||
@@ -119,7 +119,7 @@ class core_plugin_manager_testcase extends advanced_testcase {
|
||||
$present = core_plugin_manager::instance()->get_present_plugins($type);
|
||||
if (is_array($present)) {
|
||||
foreach ($present as $plugin => $version) {
|
||||
$this->assertRegExp('/^[a-z]+[a-z0-9_]*$/', $plugin, 'All plugins are supposed to have version.php file.');
|
||||
$this->assertMatchesRegularExpression('/^[a-z]+[a-z0-9_]*$/', $plugin, 'All plugins are supposed to have version.php file.');
|
||||
$this->assertIsObject($version);
|
||||
$this->assertTrue(is_numeric($version->version), 'All plugins should have a version, plugin '.$type.'_'.$plugin.' does not have version info.');
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ class core_setuplib_testcase extends advanced_testcase {
|
||||
} else {
|
||||
$docroot = $CFG->docroot;
|
||||
}
|
||||
$this->assertRegExp('~^' . preg_quote($docroot, '') . '/\d{2,3}/' . current_language() . '/course/editing$~',
|
||||
$this->assertMatchesRegularExpression('~^' . preg_quote($docroot, '') . '/\d{2,3}/' . current_language() . '/course/editing$~',
|
||||
get_docs_url('course/editing'));
|
||||
}
|
||||
|
||||
|
||||
@@ -425,9 +425,9 @@ class core_tablelib_testcase extends advanced_testcase {
|
||||
$table->define_baseurl('/invalid.php');
|
||||
|
||||
$row = $table->get_row_html($data);
|
||||
$this->assertRegExp('/row 0 col 0/', $row);
|
||||
$this->assertRegExp('/<tr class=""/', $row);
|
||||
$this->assertRegExp('/<td class="cell c0"/', $row);
|
||||
$this->assertMatchesRegularExpression('/row 0 col 0/', $row);
|
||||
$this->assertMatchesRegularExpression('/<tr class=""/', $row);
|
||||
$this->assertMatchesRegularExpression('/<td class="cell c0"/', $row);
|
||||
}
|
||||
|
||||
public function test_persistent_table() {
|
||||
|
||||
@@ -173,7 +173,7 @@ class core_theme_config_testcase extends advanced_testcase {
|
||||
theme_set_sub_revision_for_theme($themename, $themesubrevision);
|
||||
$url = $theme->editor_css_url();
|
||||
|
||||
$this->assertRegExp("/{$themerevision}_{$themesubrevision}/", $url->out(false));
|
||||
$this->assertMatchesRegularExpression("/{$themerevision}_{$themesubrevision}/", $url->out(false));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -497,14 +497,14 @@ class core_user_testcase extends advanced_testcase {
|
||||
try {
|
||||
core_user::get_property_definition('fullname');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/Invalid property requested./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Invalid property requested./', $e->getMessage());
|
||||
}
|
||||
|
||||
// Empty parameter.
|
||||
try {
|
||||
core_user::get_property_definition('');
|
||||
} catch (coding_exception $e) {
|
||||
$this->assertRegExp('/Invalid property requested./', $e->getMessage());
|
||||
$this->assertMatchesRegularExpression('/Invalid property requested./', $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class core_weblib_format_text_testcase extends advanced_testcase {
|
||||
public function test_format_text_format_html() {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
$this->assertRegExp('~^<p><img class="icon emoticon" alt="smile" title="smile" ' .
|
||||
$this->assertMatchesRegularExpression('~^<p><img class="icon emoticon" alt="smile" title="smile" ' .
|
||||
'src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p>$~',
|
||||
format_text('<p>:-)</p>', FORMAT_HTML));
|
||||
}
|
||||
@@ -67,7 +67,7 @@ class core_weblib_format_text_testcase extends advanced_testcase {
|
||||
public function test_format_text_format_markdown() {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
$this->assertRegExp('~^<p><em><img class="icon emoticon" alt="smile" title="smile" ' .
|
||||
$this->assertMatchesRegularExpression('~^<p><em><img class="icon emoticon" alt="smile" title="smile" ' .
|
||||
'src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" />' .
|
||||
'</em></p>\n$~',
|
||||
format_text('*:-)*', FORMAT_MARKDOWN));
|
||||
@@ -83,7 +83,7 @@ class core_weblib_format_text_testcase extends advanced_testcase {
|
||||
public function test_format_text_format_moodle() {
|
||||
$this->resetAfterTest();
|
||||
filter_set_global_state('emoticon', TEXTFILTER_ON);
|
||||
$this->assertRegExp('~^<div class="text_to_html"><p>' .
|
||||
$this->assertMatchesRegularExpression('~^<div class="text_to_html"><p>' .
|
||||
'<img class="icon emoticon" alt="smile" title="smile" ' .
|
||||
'src="https://www.example.com/moodle/theme/image.php/_s/boost/core/1/s/smiley" /></p></div>$~',
|
||||
format_text('<p>:-)</p>', FORMAT_MOODLE));
|
||||
|
||||
@@ -103,7 +103,7 @@ class core_weblib_testcase extends advanced_testcase {
|
||||
// This time we want to apply the filters.
|
||||
$options['filter'] = true;
|
||||
$filterresult = format_string($rawstring, $striplinks, $options);
|
||||
$this->assertRegExp("/$expectedfilter/", $filterresult);
|
||||
$this->assertMatchesRegularExpression("/$expectedfilter/", $filterresult);
|
||||
|
||||
filter_set_local_state('censor', $context->id, TEXTFILTER_OFF);
|
||||
|
||||
@@ -111,7 +111,7 @@ class core_weblib_testcase extends advanced_testcase {
|
||||
// the same as the filtered text above even though we've disabled the
|
||||
// censor filter in between.
|
||||
$cachedresult = format_string($rawstring, $striplinks, $options);
|
||||
$this->assertRegExp("/$expectedfilter/", $cachedresult);
|
||||
$this->assertMatchesRegularExpression("/$expectedfilter/", $cachedresult);
|
||||
}
|
||||
|
||||
public function test_s() {
|
||||
|
||||
@@ -53,7 +53,7 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/A password reset was requested for your account/', quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp('/Unfortunately your account on this site is disabled/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/Unfortunately your account on this site is disabled/', quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ class core_login_lib_testcase extends advanced_testcase {
|
||||
$this->assertSame($user->email, $email->to);
|
||||
$this->assertNotEmpty($email->header);
|
||||
$this->assertNotEmpty($email->body);
|
||||
$this->assertRegExp('/Unfortunately passwords cannot be reset on this site/', quoted_printable_decode($email->body));
|
||||
$this->assertMatchesRegularExpression('/Unfortunately passwords cannot be reset on this site/', quoted_printable_decode($email->body));
|
||||
$sink->clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -108,16 +108,16 @@ class media_html5audio_testcase extends advanced_testcase {
|
||||
$this->assertTrue($manager->can_embed_url($url, $embedoptions));
|
||||
$content = $manager->embed_url($url, 'Test & file', 0, 0, $embedoptions);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_html5audio~', $content);
|
||||
$this->assertRegExp('~</audio>~', $content);
|
||||
$this->assertRegExp('~title="Test & file"~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_html5audio~', $content);
|
||||
$this->assertMatchesRegularExpression('~</audio>~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="Test & file"~', $content);
|
||||
// Do not set default width/height (it's an audio after all).
|
||||
$this->assertNotRegExp('~width=~', $content);
|
||||
$this->assertNotRegExp('~height=~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~width=~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~height=~', $content);
|
||||
|
||||
// This plugin ignores size settings.
|
||||
$this->assertNotRegExp('~width=~', $content);
|
||||
$this->assertNotRegExp('~height=~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~width=~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~height=~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,10 +130,10 @@ class media_html5audio_testcase extends advanced_testcase {
|
||||
$text = html_writer::link($url, 'Watch this one');
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_html5audio~', $content);
|
||||
$this->assertRegExp('~</audio>~', $content);
|
||||
$this->assertRegExp('~title="Watch this one"~', $content);
|
||||
$this->assertNotRegExp('~<track\b~i', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_html5audio~', $content);
|
||||
$this->assertMatchesRegularExpression('~</audio>~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="Watch this one"~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<track\b~i', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +146,7 @@ class media_html5audio_testcase extends advanced_testcase {
|
||||
'<track src="'.$trackurl.'">Unsupported text</audio>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertNotRegExp('~mediaplugin_html5audio~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~mediaplugin_html5audio~', $content);
|
||||
$this->assertEquals(clean_text($text, FORMAT_HTML), $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,15 +105,15 @@ class media_html5video_testcase extends advanced_testcase {
|
||||
$this->assertTrue($manager->can_embed_url($url, $embedoptions));
|
||||
$content = $manager->embed_url($url, 'Test & file', 0, 0, $embedoptions);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_html5video~', $content);
|
||||
$this->assertRegExp('~</video>~', $content);
|
||||
$this->assertRegExp('~title="Test & file"~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '"~', $content);
|
||||
$this->assertNotRegExp('~height=~', $content); // Allow to set automatic height.
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_html5video~', $content);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="Test & file"~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '"~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~height=~', $content); // Allow to set automatic height.
|
||||
|
||||
// Repeat sending the specific size to the manager.
|
||||
$content = $manager->embed_url($url, 'New file', 123, 50, $embedoptions);
|
||||
$this->assertRegExp('~width="123" height="50"~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="123" height="50"~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -127,11 +127,11 @@ class media_html5video_testcase extends advanced_testcase {
|
||||
$text = html_writer::link($url, 'Watch this one');
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_html5video~', $content);
|
||||
$this->assertRegExp('~</video>~', $content);
|
||||
$this->assertRegExp('~title="Watch this one"~', $content);
|
||||
$this->assertNotRegExp('~<track\b~i', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '"~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_html5video~', $content);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="Watch this one"~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<track\b~i', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '"~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ class media_html5video_testcase extends advanced_testcase {
|
||||
'<track src="'.$trackurl.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertNotRegExp('~mediaplugin_html5video~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~mediaplugin_html5video~', $content);
|
||||
$this->assertEquals(clean_text($text, FORMAT_HTML), $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,14 +79,14 @@ class media_swf_testcase extends advanced_testcase {
|
||||
$this->assertTrue($manager->can_embed_url($url, $embedoptions));
|
||||
$content = $manager->embed_url($url, 'Test & file', 0, 0, $embedoptions);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_swf~', $content);
|
||||
$this->assertRegExp('~</object>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_swf~', $content);
|
||||
$this->assertMatchesRegularExpression('~</object>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
|
||||
// Repeat sending the specific size to the manager.
|
||||
$content = $manager->embed_url($url, 'New file', 123, 50, $embedoptions);
|
||||
$this->assertRegExp('~width="123" height="50"~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="123" height="50"~', $content);
|
||||
|
||||
// Not working without trust!
|
||||
$embedoptions = array(
|
||||
@@ -94,7 +94,7 @@ class media_swf_testcase extends advanced_testcase {
|
||||
);
|
||||
$this->assertFalse($manager->can_embed_url($url, $embedoptions));
|
||||
$content = $manager->embed_url($url, 'Test & file', 0, 0, $embedoptions);
|
||||
$this->assertNotRegExp('~mediaplugin_swf~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~mediaplugin_swf~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,14 +108,14 @@ class media_swf_testcase extends advanced_testcase {
|
||||
$text = html_writer::link($url, 'Watch this one');
|
||||
$content = format_text($text, FORMAT_HTML, ['trusted' => true]);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_swf~', $content);
|
||||
$this->assertRegExp('~</object>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_swf~', $content);
|
||||
$this->assertMatchesRegularExpression('~</object>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
|
||||
// Not working without trust!
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
$this->assertNotRegExp('~mediaplugin_swf~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~mediaplugin_swf~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,21 +131,21 @@ class media_swf_testcase extends advanced_testcase {
|
||||
'<track src="'.$trackurl.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML, ['trusted' => true]);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_swf~', $content);
|
||||
$this->assertRegExp('~</object>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_swf~', $content);
|
||||
$this->assertMatchesRegularExpression('~</object>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
// Video tag, unsupported text and tracks are removed.
|
||||
$this->assertNotRegExp('~</video>~', $content);
|
||||
$this->assertNotRegExp('~<source\b~', $content);
|
||||
$this->assertNotRegExp('~Unsupported text~', $content);
|
||||
$this->assertNotRegExp('~<track\b~i', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~</video>~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<source\b~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~Unsupported text~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<track\b~i', $content);
|
||||
|
||||
// Video with dimensions and source specified as src attribute without <source> tag.
|
||||
$text = '<video controls="true" width="123" height="35" src="'.$url.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML, ['trusted' => true]);
|
||||
$this->assertRegExp('~mediaplugin_swf~', $content);
|
||||
$this->assertRegExp('~</object>~', $content);
|
||||
$this->assertRegExp('~width="123" height="35"~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_swf~', $content);
|
||||
$this->assertMatchesRegularExpression('~</object>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="123" height="35"~', $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,21 +110,21 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$this->assertTrue($manager->can_embed_url($url, $embedoptions));
|
||||
$content = $manager->embed_url($url, 'Test & file', 0, 0, $embedoptions);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_videojs~', $content);
|
||||
$this->assertRegExp('~</video>~', $content);
|
||||
$this->assertRegExp('~title="Test & file"~', $content);
|
||||
$this->assertRegExp('~style="max-width:' . $CFG->media_default_width . 'px;~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_videojs~', $content);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="Test & file"~', $content);
|
||||
$this->assertMatchesRegularExpression('~style="max-width:' . $CFG->media_default_width . 'px;~', $content);
|
||||
|
||||
// Repeat sending the specific size to the manager.
|
||||
$content = $manager->embed_url($url, 'New file', 123, 50, $embedoptions);
|
||||
$this->assertRegExp('~style="max-width:123px;~', $content);
|
||||
$this->assertMatchesRegularExpression('~style="max-width:123px;~', $content);
|
||||
|
||||
// Repeat without sending the size and with unchecked setting to limit the video size.
|
||||
set_config('limitsize', false, 'media_videojs');
|
||||
|
||||
$manager = core_media_manager::instance();
|
||||
$content = $manager->embed_url($url, 'Test & file', 0, 0, $embedoptions);
|
||||
$this->assertNotRegExp('~style="max-width:~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~style="max-width:~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -138,11 +138,11 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$text = html_writer::link($url, 'Watch this one');
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_videojs~', $content);
|
||||
$this->assertRegExp('~</video>~', $content);
|
||||
$this->assertRegExp('~title="Watch this one"~', $content);
|
||||
$this->assertNotRegExp('~<track\b~i', $content);
|
||||
$this->assertRegExp('~style="max-width:' . $CFG->media_default_width . 'px;~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_videojs~', $content);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="Watch this one"~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<track\b~i', $content);
|
||||
$this->assertMatchesRegularExpression('~style="max-width:' . $CFG->media_default_width . 'px;~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -159,18 +159,18 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$manager = core_media_manager::instance();
|
||||
$content = $manager->embed_alternatives($urls, '', 0, 0, []);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_videojs~', $content);
|
||||
$this->assertRegExp('~</video>~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_videojs~', $content);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $content);
|
||||
// Title is taken from the name of the first supported file.
|
||||
$this->assertRegExp('~title="2"~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="2"~', $content);
|
||||
// Only supported files are in <source>'s.
|
||||
$this->assertNotRegExp('~<source src="http://example.org/1.rv"~', $content);
|
||||
$this->assertRegExp('~<source src="http://example.org/2.webm"~', $content);
|
||||
$this->assertRegExp('~<source src="http://example.org/3.ogv"~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<source src="http://example.org/1.rv"~', $content);
|
||||
$this->assertMatchesRegularExpression('~<source src="http://example.org/2.webm"~', $content);
|
||||
$this->assertMatchesRegularExpression('~<source src="http://example.org/3.ogv"~', $content);
|
||||
// Links to all files are included.
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="http://example.org/1.rv">1.rv</a>~', $content);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="http://example.org/2.webm">2.webm</a>~', $content);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="http://example.org/3.ogv">3.ogv</a>~', $content);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/1.rv">1.rv</a>~', $content);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/2.webm">2.webm</a>~', $content);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/3.ogv">3.ogv</a>~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -182,10 +182,10 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$text = html_writer::link($url, 'Apply one player only');
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_videojs~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_videojs~', $content);
|
||||
$this->assertEquals(1, substr_count($content, '</video>'));
|
||||
$this->assertNotRegExp('~mediaplugin_html5video~', $content);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="http://example.org/some_filename.webm">Apply one player only</a>~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~mediaplugin_html5video~', $content);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/some_filename.webm">Apply one player only</a>~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,25 +201,25 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
'<track src="'.$trackurl.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_videojs~', $content);
|
||||
$this->assertRegExp('~</video>~', $content);
|
||||
$this->assertRegExp('~title="some_filename.mp4"~', $content);
|
||||
$this->assertRegExp('~style="max-width:' . $CFG->media_default_width . 'px;~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_videojs~', $content);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="some_filename.mp4"~', $content);
|
||||
$this->assertMatchesRegularExpression('~style="max-width:' . $CFG->media_default_width . 'px;~', $content);
|
||||
// Unsupported text and tracks are preserved.
|
||||
$this->assertRegExp('~Unsupported text~', $content);
|
||||
$this->assertRegExp('~<track\b~i', $content);
|
||||
$this->assertMatchesRegularExpression('~Unsupported text~', $content);
|
||||
$this->assertMatchesRegularExpression('~<track\b~i', $content);
|
||||
// Invalid sources are removed.
|
||||
$this->assertNotRegExp('~somethinginvalid~i', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~somethinginvalid~i', $content);
|
||||
|
||||
// Video with dimensions and source specified as src attribute without <source> tag.
|
||||
$text = '<video controls="true" width="123" height="35" src="'.$url.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
$this->assertRegExp('~mediaplugin_videojs~', $content);
|
||||
$this->assertRegExp('~</video>~', $content);
|
||||
$this->assertRegExp('~<source\b~', $content);
|
||||
$this->assertRegExp('~style="max-width:123px;~', $content);
|
||||
$this->assertNotRegExp('~width="~', $content);
|
||||
$this->assertNotRegExp('~height="~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_videojs~', $content);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $content);
|
||||
$this->assertMatchesRegularExpression('~<source\b~', $content);
|
||||
$this->assertMatchesRegularExpression('~style="max-width:123px;~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~width="~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~height="~', $content);
|
||||
|
||||
// Audio tag.
|
||||
$url = new moodle_url('http://example.org/some_filename.mp3');
|
||||
@@ -228,16 +228,16 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
'<track src="'.$trackurl.'">Unsupported text</audio>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_videojs~', $content);
|
||||
$this->assertNotRegExp('~</video>~', $content);
|
||||
$this->assertRegExp('~</audio>~', $content);
|
||||
$this->assertRegExp('~title="some_filename.mp3"~', $content);
|
||||
$this->assertRegExp('~style="max-width:' . $CFG->media_default_width . 'px;~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_videojs~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~</video>~', $content);
|
||||
$this->assertMatchesRegularExpression('~</audio>~', $content);
|
||||
$this->assertMatchesRegularExpression('~title="some_filename.mp3"~', $content);
|
||||
$this->assertMatchesRegularExpression('~style="max-width:' . $CFG->media_default_width . 'px;~', $content);
|
||||
// Unsupported text and tracks are preserved.
|
||||
$this->assertRegExp('~Unsupported text~', $content);
|
||||
$this->assertRegExp('~<track\b~i', $content);
|
||||
$this->assertMatchesRegularExpression('~Unsupported text~', $content);
|
||||
$this->assertMatchesRegularExpression('~<track\b~i', $content);
|
||||
// Invalid sources are removed.
|
||||
$this->assertNotRegExp('~somethinginvalid~i', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~somethinginvalid~i', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,16 +341,16 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$url = new moodle_url('http://example.org/some_filename.flv');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->flash_plugin_engaged($t);
|
||||
$this->assertRegExp('~</video>~', $t);
|
||||
$this->assertRegExp('~<source src="http://example.org/some_filename.flv"~', $t);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<source src="http://example.org/some_filename.flv"~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
|
||||
|
||||
// Flash disabled.
|
||||
set_config('useflash', 0, 'media_videojs');
|
||||
$url = new moodle_url('http://example.org/some_filename.flv');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="http://example.org/some_filename.flv">some_filename.flv</a>~', $t);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -365,7 +365,7 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
|
||||
// RTMP enabled, flash disabled.
|
||||
set_config('useflash', 0, 'media_videojs');
|
||||
@@ -373,7 +373,7 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->assertStringNotContainsString('mediaplugin_videojs', $t);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
|
||||
// RTMP enabled, flash enabled, rtmp/mp4 type expected.
|
||||
set_config('useflash', 1, 'media_videojs');
|
||||
@@ -381,9 +381,9 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$url = new moodle_url('rtmp://example.com/fms&mp4:path/to/file.mp4');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->flash_plugin_engaged($t);
|
||||
$this->assertRegExp('~</video>~', $t);
|
||||
$this->assertRegExp('~<source src="rtmp://example.com/fms&mp4:path/to/file.mp4" type="rtmp/mp4"~', $t);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<source src="rtmp://example.com/fms&mp4:path/to/file.mp4" type="rtmp/mp4"~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="rtmp://example.com/fms&mp4:path/to/file.mp4">file.mp4</a>~', $t);
|
||||
|
||||
// RTMP enabled, flash enabled, rtmp/flv type expected.
|
||||
set_config('useflash', 1, 'media_videojs');
|
||||
@@ -391,8 +391,8 @@ class media_videojs_player_testcase extends advanced_testcase {
|
||||
$url = new moodle_url('rtmp://example.com/fms&flv:path/to/file.flv');
|
||||
$t = $manager->embed_url($url);
|
||||
$this->flash_plugin_engaged($t);
|
||||
$this->assertRegExp('~</video>~', $t);
|
||||
$this->assertRegExp('~<source src="rtmp://example.com/fms&flv:path/to/file.flv" type="rtmp/flv"~', $t);
|
||||
$this->assertRegExp('~<a class="mediafallbacklink" href="rtmp://example.com/fms&flv:path/to/file.flv">file.flv</a>~', $t);
|
||||
$this->assertMatchesRegularExpression('~</video>~', $t);
|
||||
$this->assertMatchesRegularExpression('~<source src="rtmp://example.com/fms&flv:path/to/file.flv" type="rtmp/flv"~', $t);
|
||||
$this->assertMatchesRegularExpression('~<a class="mediafallbacklink" href="rtmp://example.com/fms&flv:path/to/file.flv">file.flv</a>~', $t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,14 +74,14 @@ class media_vimeo_testcase extends advanced_testcase {
|
||||
$this->assertTrue($manager->can_embed_url($url, $embedoptions));
|
||||
$content = $manager->embed_url($url, 'Test & file', 0, 0, $embedoptions);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_vimeo~', $content);
|
||||
$this->assertRegExp('~</iframe>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_vimeo~', $content);
|
||||
$this->assertMatchesRegularExpression('~</iframe>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
|
||||
// Repeat sending the specific size to the manager.
|
||||
$content = $manager->embed_url($url, 'New file', 123, 50, $embedoptions);
|
||||
$this->assertRegExp('~width="123" height="50"~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="123" height="50"~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,9 +95,9 @@ class media_vimeo_testcase extends advanced_testcase {
|
||||
$text = html_writer::link($url, 'Watch this one');
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_vimeo~', $content);
|
||||
$this->assertRegExp('~</iframe>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_vimeo~', $content);
|
||||
$this->assertMatchesRegularExpression('~</iframe>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
}
|
||||
|
||||
@@ -114,21 +114,21 @@ class media_vimeo_testcase extends advanced_testcase {
|
||||
'<track src="'.$trackurl.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_vimeo~', $content);
|
||||
$this->assertRegExp('~</iframe>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_vimeo~', $content);
|
||||
$this->assertMatchesRegularExpression('~</iframe>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
// Video tag, unsupported text and tracks are removed.
|
||||
$this->assertNotRegExp('~</video>~', $content);
|
||||
$this->assertNotRegExp('~<source\b~', $content);
|
||||
$this->assertNotRegExp('~Unsupported text~', $content);
|
||||
$this->assertNotRegExp('~<track\b~i', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~</video>~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<source\b~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~Unsupported text~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<track\b~i', $content);
|
||||
|
||||
// Video with dimensions and source specified as src attribute without <source> tag.
|
||||
$text = '<video controls="true" width="123" height="35" src="'.$url.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
$this->assertRegExp('~mediaplugin_vimeo~', $content);
|
||||
$this->assertRegExp('~</iframe>~', $content);
|
||||
$this->assertRegExp('~width="123" height="35"~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_vimeo~', $content);
|
||||
$this->assertMatchesRegularExpression('~</iframe>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="123" height="35"~', $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,14 +133,14 @@ class media_youtube_testcase extends advanced_testcase {
|
||||
$this->assertTrue($manager->can_embed_url($url, $embedoptions));
|
||||
$content = $manager->embed_url($url, 'Test & file', 0, 0, $embedoptions);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_youtube~', $content);
|
||||
$this->assertRegExp('~</iframe>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_youtube~', $content);
|
||||
$this->assertMatchesRegularExpression('~</iframe>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
|
||||
// Repeat sending the specific size to the manager.
|
||||
$content = $manager->embed_url($url, 'New file', 123, 50, $embedoptions);
|
||||
$this->assertRegExp('~width="123" height="50"~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="123" height="50"~', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,9 +154,9 @@ class media_youtube_testcase extends advanced_testcase {
|
||||
$text = html_writer::link($url, 'Watch this one');
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_youtube~', $content);
|
||||
$this->assertRegExp('~</iframe>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_youtube~', $content);
|
||||
$this->assertMatchesRegularExpression('~</iframe>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
}
|
||||
|
||||
@@ -173,21 +173,21 @@ class media_youtube_testcase extends advanced_testcase {
|
||||
'<track src="'.$trackurl.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
|
||||
$this->assertRegExp('~mediaplugin_youtube~', $content);
|
||||
$this->assertRegExp('~</iframe>~', $content);
|
||||
$this->assertRegExp('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_youtube~', $content);
|
||||
$this->assertMatchesRegularExpression('~</iframe>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="' . $CFG->media_default_width . '" height="' .
|
||||
$CFG->media_default_height . '"~', $content);
|
||||
// Video tag, unsupported text and tracks are removed.
|
||||
$this->assertNotRegExp('~</video>~', $content);
|
||||
$this->assertNotRegExp('~<source\b~', $content);
|
||||
$this->assertNotRegExp('~Unsupported text~', $content);
|
||||
$this->assertNotRegExp('~<track\b~i', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~</video>~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<source\b~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~Unsupported text~', $content);
|
||||
$this->assertDoesNotMatchRegularExpression('~<track\b~i', $content);
|
||||
|
||||
// Video with dimensions and source specified as src attribute without <source> tag.
|
||||
$text = '<video controls="true" width="123" height="35" src="'.$url.'">Unsupported text</video>';
|
||||
$content = format_text($text, FORMAT_HTML);
|
||||
$this->assertRegExp('~mediaplugin_youtube~', $content);
|
||||
$this->assertRegExp('~</iframe>~', $content);
|
||||
$this->assertRegExp('~width="123" height="35"~', $content);
|
||||
$this->assertMatchesRegularExpression('~mediaplugin_youtube~', $content);
|
||||
$this->assertMatchesRegularExpression('~</iframe>~', $content);
|
||||
$this->assertMatchesRegularExpression('~width="123" height="35"~', $content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +130,7 @@ class core_message_send_email_task_testcase extends advanced_testcase {
|
||||
$this->assertStringContainsString('Group 1', $emailbody);
|
||||
$this->assertStringContainsString('Group 2', $emailbody);
|
||||
// 5 unread messages per conversation, this will be listed twice.
|
||||
$this->assertRegExp("/<span\b[^>]*>5<\/span> <span\b[^>]*>Unread message\w+/", $emailbody);
|
||||
$this->assertMatchesRegularExpression("/<span\b[^>]*>5<\/span> <span\b[^>]*>Unread message\w+/", $emailbody);
|
||||
|
||||
// Confirm table was emptied after task was run.
|
||||
$this->assertEquals(0, $DB->count_records('message_email_messages'));
|
||||
|
||||
@@ -232,7 +232,7 @@ class mod_assign_external_testcase extends externallib_advanced_testcase {
|
||||
$this->assertStringContainsString('the assignment intro text here', $assignment['intro']);
|
||||
$this->assertNotEmpty($assignment['configs']);
|
||||
// Check the url of the file attatched.
|
||||
$this->assertRegExp('@"' . $CFG->wwwroot . '/webservice/pluginfile.php/\d+/mod_assign/intro/intro\.txt"@', $assignment['intro']);
|
||||
$this->assertMatchesRegularExpression('@"' . $CFG->wwwroot . '/webservice/pluginfile.php/\d+/mod_assign/intro/intro\.txt"@', $assignment['intro']);
|
||||
$this->assertEquals(1, $assignment['markingworkflow']);
|
||||
$this->assertEquals(1, $assignment['markingallocation']);
|
||||
$this->assertEquals(0, $assignment['preventsubmissionnotingroup']);
|
||||
|
||||
@@ -173,7 +173,7 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
|
||||
$result = assign_user_outline($course, $student, $assign->get_course_module(), $assign->get_instance());
|
||||
|
||||
$this->assertRegExp('/50.5/', $result->info);
|
||||
$this->assertMatchesRegularExpression('/50.5/', $result->info);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2307,7 +2307,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// No feedback should be available because this student has not been graded.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertNotRegexp('/Feedback/', $output, 'Do not show feedback if there is no grade');
|
||||
$this->assertDoesNotMatchRegularExpression('/Feedback/', $output, 'Do not show feedback if there is no grade');
|
||||
|
||||
// Simulate adding a grade.
|
||||
$this->add_submission($student, $assign);
|
||||
@@ -2317,7 +2317,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// Now we should see the feedback.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertRegexp('/Feedback/', $output, 'Show feedback if there is a grade');
|
||||
$this->assertMatchesRegularExpression('/Feedback/', $output, 'Show feedback if there is a grade');
|
||||
|
||||
// Now hide the grade in gradebook.
|
||||
$this->setUser($teacher);
|
||||
@@ -2333,7 +2333,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// No feedback should be available because the grade is hidden.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertNotRegexp('/Feedback/', $output, 'Do not show feedback if the grade is hidden in the gradebook');
|
||||
$this->assertDoesNotMatchRegularExpression('/Feedback/', $output, 'Do not show feedback if the grade is hidden in the gradebook');
|
||||
}
|
||||
|
||||
public function test_show_student_summary_with_feedback() {
|
||||
@@ -2353,7 +2353,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// No feedback should be available because this student has not been graded.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertNotRegexp('/Feedback/', $output);
|
||||
$this->assertDoesNotMatchRegularExpression('/Feedback/', $output);
|
||||
|
||||
// Simulate adding a grade.
|
||||
$this->add_submission($student, $assign);
|
||||
@@ -2368,10 +2368,10 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// Should have feedback but no grade.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertRegexp('/Feedback/', $output);
|
||||
$this->assertRegexp('/Tomato sauce/', $output);
|
||||
$this->assertNotRegexp('/Grade/', $output, 'Do not show grade when there is no grade.');
|
||||
$this->assertNotRegexp('/Graded on/', $output, 'Do not show graded date when there is no grade.');
|
||||
$this->assertMatchesRegularExpression('/Feedback/', $output);
|
||||
$this->assertMatchesRegularExpression('/Tomato sauce/', $output);
|
||||
$this->assertDoesNotMatchRegularExpression('/Grade/', $output, 'Do not show grade when there is no grade.');
|
||||
$this->assertDoesNotMatchRegularExpression('/Graded on/', $output, 'Do not show graded date when there is no grade.');
|
||||
|
||||
// Add a grade now.
|
||||
$this->mark_submission($teacher, $assign, $student, 50.0, [
|
||||
@@ -2384,10 +2384,10 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// Should have feedback but no grade.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertNotRegexp('/Tomato sauce/', $output);
|
||||
$this->assertRegexp('/Bechamel sauce/', $output);
|
||||
$this->assertRegexp('/Grade/', $output);
|
||||
$this->assertRegexp('/Graded on/', $output);
|
||||
$this->assertDoesNotMatchRegularExpression('/Tomato sauce/', $output);
|
||||
$this->assertMatchesRegularExpression('/Bechamel sauce/', $output);
|
||||
$this->assertMatchesRegularExpression('/Grade/', $output);
|
||||
$this->assertMatchesRegularExpression('/Graded on/', $output);
|
||||
|
||||
// Now hide the grade in gradebook.
|
||||
$this->setUser($teacher);
|
||||
@@ -2402,7 +2402,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// No feedback should be available because the grade is hidden.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertNotRegexp('/Feedback/', $output, 'Do not show feedback if the grade is hidden in the gradebook');
|
||||
$this->assertDoesNotMatchRegularExpression('/Feedback/', $output, 'Do not show feedback if the grade is hidden in the gradebook');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2574,7 +2574,7 @@ class mod_assign_locallib_testcase extends advanced_testcase {
|
||||
// Check that the student now has a button for Add a new attempt.
|
||||
$this->setUser($student);
|
||||
$output = $assign->view_student_summary($student, true);
|
||||
$this->assertRegexp('/' . get_string('addnewattempt', 'assign') . '/', $output);
|
||||
$this->assertMatchesRegularExpression('/' . get_string('addnewattempt', 'assign') . '/', $output);
|
||||
$this->assertNotEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
|
||||
}
|
||||
|
||||
|
||||
+32
-32
@@ -461,30 +461,30 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
// Admin can see everything.
|
||||
$res = mod_book_get_tagged_chapters($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$chapter = */0);
|
||||
$this->assertRegExp('/'.$chapter11->title.'</', $res->content);
|
||||
$this->assertRegExp('/'.$chapter12->title.'</', $res->content);
|
||||
$this->assertRegExp('/'.$chapter13->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter14->title.'</', $res->content);
|
||||
$this->assertRegExp('/'.$chapter15->title.'</', $res->content);
|
||||
$this->assertRegExp('/'.$chapter16->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter21->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter22->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter23->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter31->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter11->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter12->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter13->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter14->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter15->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter16->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter21->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter22->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter23->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter31->title.'</', $res->content);
|
||||
$this->assertEmpty($res->prevpageurl);
|
||||
$this->assertNotEmpty($res->nextpageurl);
|
||||
$res = mod_book_get_tagged_chapters($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$chapter = */1);
|
||||
$this->assertNotRegExp('/'.$chapter11->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter12->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter13->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter14->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter15->title.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter16->title.'</', $res->content);
|
||||
$this->assertRegExp('/'.$chapter21->title.'</', $res->content);
|
||||
$this->assertRegExp('/'.$chapter22->title.'</', $res->content);
|
||||
$this->assertRegExp('/'.$chapter23->title.'</', $res->content);
|
||||
$this->assertRegExp('/'.$chapter31->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter11->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter12->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter13->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter14->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter15->title.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter16->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter21->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter22->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter23->title.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter31->title.'</', $res->content);
|
||||
$this->assertNotEmpty($res->prevpageurl);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
|
||||
@@ -499,25 +499,25 @@ class mod_book_lib_testcase extends advanced_testcase {
|
||||
// User can not see chapters in course 3 because he is not enrolled.
|
||||
$res = mod_book_get_tagged_chapters($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$chapter = */1);
|
||||
$this->assertRegExp('/'.$chapter22->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$chapter23->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter31->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter22->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter23->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter31->title.'/', $res->content);
|
||||
|
||||
// User can search book chapters inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$res = mod_book_get_tagged_chapters($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */$coursecontext->id, /*$rec = */1, /*$chapter = */0);
|
||||
$this->assertRegExp('/'.$chapter11->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$chapter12->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$chapter13->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter14->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$chapter15->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter21->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter22->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$chapter23->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter11->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter12->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter13->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter14->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$chapter15->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter21->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter22->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter23->title.'/', $res->content);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
|
||||
// User cannot see hidden chapters.
|
||||
$this->assertNotRegExp('/'.$chapter16->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$chapter16->title.'/', $res->content);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,7 @@ class mod_chat_format_message_testcase extends advanced_testcase {
|
||||
if (!empty($expecttext)) {
|
||||
$expecttext = str_replace('__CURRENTUSER__', fullname($currentuser), $expecttext);
|
||||
$expecttext = str_replace('__CURRENTUSER_FIRST__', $currentuser->firstname, $expecttext);
|
||||
$this->assertRegexp($expecttext, $result->text);
|
||||
$this->assertMatchesRegularExpression($expecttext, $result->text);
|
||||
}
|
||||
|
||||
$this->assertEquals($refreshusers, $result->refreshusers);
|
||||
|
||||
@@ -51,10 +51,10 @@ trait mod_forum_tests_cron_trait {
|
||||
$expect->mentioned = true;
|
||||
}
|
||||
if (!$expect->mentioned) {
|
||||
$this->assertNotRegExp("/Queued 0 for {$expect->userid}/", $output);
|
||||
$this->assertDoesNotMatchRegularExpression("/Queued 0 for {$expect->userid}/", $output);
|
||||
} else {
|
||||
$uniqueusers++;
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
"/Queued {$expect->digests} digests and {$expect->messages} messages for {$expect->userid}/",
|
||||
$output
|
||||
);
|
||||
@@ -62,9 +62,9 @@ trait mod_forum_tests_cron_trait {
|
||||
}
|
||||
|
||||
if (empty($expectations)) {
|
||||
$this->assertRegExp("/No posts found./", $output);
|
||||
$this->assertMatchesRegularExpression("/No posts found./", $output);
|
||||
} else {
|
||||
$this->assertRegExp("/Unique users: {$uniqueusers}/", $output);
|
||||
$this->assertMatchesRegularExpression("/Unique users: {$uniqueusers}/", $output);
|
||||
}
|
||||
|
||||
// Update the forum queue for digests.
|
||||
@@ -88,12 +88,12 @@ trait mod_forum_tests_cron_trait {
|
||||
if (empty($posts) && !$ignoreemptyposts) {
|
||||
$this->assertEquals('', $output);
|
||||
} else {
|
||||
$this->assertRegExp("/Sending messages to {$user->username}/", $output);
|
||||
$this->assertMatchesRegularExpression("/Sending messages to {$user->username}/", $output);
|
||||
foreach ($posts as $post) {
|
||||
$this->assertRegExp("/Post {$post->id} sent/", $output);
|
||||
$this->assertMatchesRegularExpression("/Post {$post->id} sent/", $output);
|
||||
}
|
||||
$count = count($posts);
|
||||
$this->assertRegExp("/Sent {$count} messages with 0 failures/", $output);
|
||||
$this->assertMatchesRegularExpression("/Sent {$count} messages with 0 failures/", $output);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,17 +113,17 @@ trait mod_forum_tests_cron_trait {
|
||||
|
||||
if (empty($shortposts) && empty($fullposts)) {
|
||||
$this->assertEquals('', $output);
|
||||
$this->assertRegExp("/Digest sent with 0 messages./", $output);
|
||||
$this->assertMatchesRegularExpression("/Digest sent with 0 messages./", $output);
|
||||
} else {
|
||||
$this->assertRegExp("/Sending forum digests for {$user->username}/", $output);
|
||||
$this->assertMatchesRegularExpression("/Sending forum digests for {$user->username}/", $output);
|
||||
foreach ($fullposts as $post) {
|
||||
$this->assertRegExp("/Adding post {$post->id} in format 1/", $output);
|
||||
$this->assertMatchesRegularExpression("/Adding post {$post->id} in format 1/", $output);
|
||||
}
|
||||
foreach ($shortposts as $post) {
|
||||
$this->assertRegExp("/Adding post {$post->id} in format 2/", $output);
|
||||
$this->assertMatchesRegularExpression("/Adding post {$post->id} in format 2/", $output);
|
||||
}
|
||||
$count = count($fullposts) + count($shortposts);
|
||||
$this->assertRegExp("/Digest sent with {$count} messages./", $output);
|
||||
$this->assertMatchesRegularExpression("/Digest sent with {$count} messages./", $output);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3327,30 +3327,30 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
// Admin can see everything.
|
||||
$res = mod_forum_get_tagged_posts($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$post = */0);
|
||||
$this->assertRegExp('/'.$post11->subject.'</', $res->content);
|
||||
$this->assertRegExp('/'.$post12->subject.'</', $res->content);
|
||||
$this->assertRegExp('/'.$post13->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post14->subject.'</', $res->content);
|
||||
$this->assertRegExp('/'.$post15->subject.'</', $res->content);
|
||||
$this->assertRegExp('/'.$post16->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post21->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post22->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post23->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post31->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post11->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post12->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post13->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post14->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post15->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post16->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post21->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post22->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post23->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post31->subject.'</', $res->content);
|
||||
$this->assertEmpty($res->prevpageurl);
|
||||
$this->assertNotEmpty($res->nextpageurl);
|
||||
$res = mod_forum_get_tagged_posts($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$post = */1);
|
||||
$this->assertNotRegExp('/'.$post11->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post12->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post13->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post14->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post15->subject.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$post16->subject.'</', $res->content);
|
||||
$this->assertRegExp('/'.$post21->subject.'</', $res->content);
|
||||
$this->assertRegExp('/'.$post22->subject.'</', $res->content);
|
||||
$this->assertRegExp('/'.$post23->subject.'</', $res->content);
|
||||
$this->assertRegExp('/'.$post31->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post11->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post12->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post13->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post14->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post15->subject.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post16->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post21->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post22->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post23->subject.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post31->subject.'</', $res->content);
|
||||
$this->assertNotEmpty($res->prevpageurl);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
|
||||
@@ -3365,23 +3365,23 @@ class mod_forum_lib_testcase extends advanced_testcase {
|
||||
// User can not see posts in course 3 because he is not enrolled.
|
||||
$res = mod_forum_get_tagged_posts($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$post = */1);
|
||||
$this->assertRegExp('/'.$post22->subject.'/', $res->content);
|
||||
$this->assertRegExp('/'.$post23->subject.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$post31->subject.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post22->subject.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post23->subject.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post31->subject.'/', $res->content);
|
||||
|
||||
// User can search forum posts inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$res = mod_forum_get_tagged_posts($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */$coursecontext->id, /*$rec = */1, /*$post = */0);
|
||||
$this->assertRegExp('/'.$post11->subject.'/', $res->content);
|
||||
$this->assertRegExp('/'.$post12->subject.'/', $res->content);
|
||||
$this->assertRegExp('/'.$post13->subject.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$post14->subject.'/', $res->content);
|
||||
$this->assertRegExp('/'.$post15->subject.'/', $res->content);
|
||||
$this->assertRegExp('/'.$post16->subject.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$post21->subject.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$post22->subject.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$post23->subject.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post11->subject.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post12->subject.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post13->subject.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post14->subject.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post15->subject.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$post16->subject.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post21->subject.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post22->subject.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$post23->subject.'/', $res->content);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
}
|
||||
|
||||
|
||||
@@ -888,7 +888,7 @@ class mod_forum_mail_testcase extends advanced_testcase {
|
||||
$this->assertEquals(2, count($messages));
|
||||
|
||||
foreach ($messages as $message) {
|
||||
$this->assertRegExp('/Reply-To: moodlemoodle123\+[^@]*@example.com/', $message->header);
|
||||
$this->assertMatchesRegularExpression('/Reply-To: moodlemoodle123\+[^@]*@example.com/', $message->header);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1255,10 +1255,10 @@ class mod_forum_mail_testcase extends advanced_testcase {
|
||||
}
|
||||
foreach ($foundexpectation['contents'] as $content) {
|
||||
if (strpos($content, '~') !== 0) {
|
||||
$this->assertRegexp('#' . $content . '#m', $mail->body);
|
||||
$this->assertMatchesRegularExpression('#' . $content . '#m', $mail->body);
|
||||
} else {
|
||||
preg_match('#' . substr($content, 1) . '#m', $mail->body, $matches);
|
||||
$this->assertNotRegexp('#' . substr($content, 1) . '#m', $mail->body);
|
||||
$this->assertDoesNotMatchRegularExpression('#' . substr($content, 1) . '#m', $mail->body);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,33 +408,33 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
// Get first page of tagged entries (first 5 entries).
|
||||
$res = mod_glossary_get_tagged_entries($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$entry = */0);
|
||||
$this->assertRegExp('/'.$entry11->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry12->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry13->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry14->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry15->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry16->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry17->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry21->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry22->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry23->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry31->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry11->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry12->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry13->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry14->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry15->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry16->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry17->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry21->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry22->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry23->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry31->concept.'</', $res->content);
|
||||
$this->assertEmpty($res->prevpageurl);
|
||||
$this->assertNotEmpty($res->nextpageurl);
|
||||
// Get second page of tagged entries (second 5 entries).
|
||||
$res = mod_glossary_get_tagged_entries($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$entry = */1);
|
||||
$this->assertNotRegExp('/'.$entry11->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry12->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry13->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry14->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry15->concept.'</', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry16->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry17->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry21->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry22->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry23->concept.'</', $res->content);
|
||||
$this->assertRegExp('/'.$entry31->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry11->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry12->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry13->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry14->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry15->concept.'</', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry16->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry17->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry21->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry22->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry23->concept.'</', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry31->concept.'</', $res->content);
|
||||
$this->assertNotEmpty($res->prevpageurl);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
|
||||
@@ -444,27 +444,27 @@ class mod_glossary_lib_testcase extends advanced_testcase {
|
||||
// User can not see entries in course 3 because he is not enrolled.
|
||||
$res = mod_glossary_get_tagged_entries($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$entry = */1);
|
||||
$this->assertRegExp('/'.$entry22->concept.'/', $res->content);
|
||||
$this->assertRegExp('/'.$entry23->concept.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry31->concept.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry22->concept.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry23->concept.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry31->concept.'/', $res->content);
|
||||
|
||||
// User can search glossary entries inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$res = mod_glossary_get_tagged_entries($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */$coursecontext->id, /*$rec = */1, /*$entry = */0);
|
||||
$this->assertRegExp('/'.$entry11->concept.'/', $res->content);
|
||||
$this->assertRegExp('/'.$entry12->concept.'/', $res->content);
|
||||
$this->assertRegExp('/'.$entry13->concept.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry14->concept.'/', $res->content);
|
||||
$this->assertRegExp('/'.$entry15->concept.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry21->concept.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry22->concept.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$entry23->concept.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry11->concept.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry12->concept.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry13->concept.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry14->concept.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry15->concept.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry21->concept.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry22->concept.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry23->concept.'/', $res->content);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
|
||||
// User cannot see unapproved entries unless he is an author.
|
||||
$this->assertNotRegExp('/'.$entry16->concept.'/', $res->content);
|
||||
$this->assertRegExp('/'.$entry17->concept.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$entry16->concept.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$entry17->concept.'/', $res->content);
|
||||
}
|
||||
|
||||
public function test_glossary_get_entries_search() {
|
||||
|
||||
+29
-29
@@ -684,28 +684,28 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
// Admin can see everything.
|
||||
$res = mod_wiki_get_tagged_pages($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$page = */0);
|
||||
$this->assertRegExp('/'.$page11->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page12->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page13->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page14->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page15->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page21->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page22->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page23->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page31->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page11->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page12->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page13->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page14->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page15->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page21->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page22->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page23->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page31->title.'/', $res->content);
|
||||
$this->assertEmpty($res->prevpageurl);
|
||||
$this->assertNotEmpty($res->nextpageurl);
|
||||
$res = mod_wiki_get_tagged_pages($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$page = */1);
|
||||
$this->assertNotRegExp('/'.$page11->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page12->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page13->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page14->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page15->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page21->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page22->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page23->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page31->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page11->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page12->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page13->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page14->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page15->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page21->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page22->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page23->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page31->title.'/', $res->content);
|
||||
$this->assertNotEmpty($res->prevpageurl);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
|
||||
@@ -720,22 +720,22 @@ class mod_wiki_lib_testcase extends advanced_testcase {
|
||||
// User can not see pages in course 3 because he is not enrolled.
|
||||
$res = mod_wiki_get_tagged_pages($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */0, /*$rec = */1, /*$page = */1);
|
||||
$this->assertRegExp('/'.$page22->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page23->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page31->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page22->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page23->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page31->title.'/', $res->content);
|
||||
|
||||
// User can search wiki pages inside a course.
|
||||
$coursecontext = context_course::instance($course1->id);
|
||||
$res = mod_wiki_get_tagged_pages($tag, /*$exclusivemode = */false,
|
||||
/*$fromctx = */0, /*$ctx = */$coursecontext->id, /*$rec = */1, /*$page = */0);
|
||||
$this->assertRegExp('/'.$page11->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page12->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page13->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page14->title.'/', $res->content);
|
||||
$this->assertRegExp('/'.$page15->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page21->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page22->title.'/', $res->content);
|
||||
$this->assertNotRegExp('/'.$page23->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page11->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page12->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page13->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page14->title.'/', $res->content);
|
||||
$this->assertMatchesRegularExpression('/'.$page15->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page21->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page22->title.'/', $res->content);
|
||||
$this->assertDoesNotMatchRegularExpression('/'.$page23->title.'/', $res->content);
|
||||
$this->assertEmpty($res->nextpageurl);
|
||||
}
|
||||
|
||||
|
||||
@@ -228,8 +228,8 @@ class mod_wiki_wikiparser_test extends basic_testcase {
|
||||
'link_callback' => '/mod/wiki/locallib.php:wiki_parser_link',
|
||||
'link_callback_args' => array('swid' => 1)
|
||||
));
|
||||
$this->assertRegExp($regexpoutput, $actual['parsed_text']);
|
||||
$this->assertRegExp($regexptoc, $actual['toc']);
|
||||
$this->assertMatchesRegularExpression($regexpoutput, $actual['parsed_text']);
|
||||
$this->assertMatchesRegularExpression($regexptoc, $actual['toc']);
|
||||
|
||||
// Now going to test Creole markup.
|
||||
// Note that Creole uses links to the escaped version of the section.
|
||||
|
||||
@@ -902,7 +902,7 @@ class moodle_content_writer_test extends advanced_testcase {
|
||||
$contextpath = $this->get_context_path($context, $subcontext, 'data.json');
|
||||
|
||||
$json = $fileroot->getChild($contextpath)->getContent();
|
||||
$this->assertRegExp("/$text/", $json);
|
||||
$this->assertMatchesRegularExpression("/$text/", $json);
|
||||
|
||||
$expanded = json_decode($json);
|
||||
$this->assertEquals($data, $expanded);
|
||||
@@ -928,7 +928,7 @@ class moodle_content_writer_test extends advanced_testcase {
|
||||
$contextpath = $this->get_context_path($context, $subcontext, 'metadata.json');
|
||||
|
||||
$json = $fileroot->getChild($contextpath)->getContent();
|
||||
$this->assertRegExp("/$text.*$text.*$text/is", $json);
|
||||
$this->assertMatchesRegularExpression("/$text.*$text.*$text/is", $json);
|
||||
|
||||
$expanded = json_decode($json);
|
||||
$this->assertTrue(isset($expanded->$text));
|
||||
@@ -957,7 +957,7 @@ class moodle_content_writer_test extends advanced_testcase {
|
||||
$contextpath = $this->get_context_path($context, $subcontext, 'name.json');
|
||||
|
||||
$json = $fileroot->getChild($contextpath)->getContent();
|
||||
$this->assertRegExp("/$text/", $json);
|
||||
$this->assertMatchesRegularExpression("/$text/", $json);
|
||||
|
||||
$expanded = json_decode($json);
|
||||
$this->assertEquals($data, $expanded);
|
||||
@@ -1011,7 +1011,7 @@ class moodle_content_writer_test extends advanced_testcase {
|
||||
$contextpath = $this->get_context_path($context, [get_string('userpreferences')], "{$component}.json");
|
||||
|
||||
$json = $fileroot->getChild($contextpath)->getContent();
|
||||
$this->assertRegExp("/$text.*$text.*$text/is", $json);
|
||||
$this->assertMatchesRegularExpression("/$text.*$text.*$text/is", $json);
|
||||
|
||||
$expanded = json_decode($json);
|
||||
$this->assertTrue(isset($expanded->$text));
|
||||
@@ -1080,7 +1080,7 @@ class moodle_content_writer_test extends advanced_testcase {
|
||||
$this->assertEquals($expectedpath, $contextpath);
|
||||
|
||||
$json = $fileroot->getChild($contextpath)->getContent();
|
||||
$this->assertRegExp("/$text/", $json);
|
||||
$this->assertMatchesRegularExpression("/$text/", $json);
|
||||
|
||||
$expanded = json_decode($json);
|
||||
$this->assertEquals($data, $expanded);
|
||||
@@ -1112,7 +1112,7 @@ class moodle_content_writer_test extends advanced_testcase {
|
||||
$this->assertEquals($expectedpath, $contextpath);
|
||||
|
||||
$json = $fileroot->getChild($contextpath)->getContent();
|
||||
$this->assertRegExp("/$text/", $json);
|
||||
$this->assertMatchesRegularExpression("/$text/", $json);
|
||||
|
||||
$expanded = json_decode($json);
|
||||
$this->assertEquals($data, $expanded);
|
||||
@@ -1142,7 +1142,7 @@ class moodle_content_writer_test extends advanced_testcase {
|
||||
$this->assertEquals($expectedpath, $contextpath);
|
||||
|
||||
$json = $fileroot->getChild($contextpath)->getContent();
|
||||
$this->assertRegExp("/$text.*$text.*$text/is", $json);
|
||||
$this->assertMatchesRegularExpression("/$text.*$text.*$text/is", $json);
|
||||
|
||||
$expanded = json_decode($json);
|
||||
$this->assertTrue(isset($expanded->$text));
|
||||
@@ -1180,7 +1180,7 @@ class moodle_content_writer_test extends advanced_testcase {
|
||||
$this->assertEquals($expectedpath, $contextpath);
|
||||
|
||||
$json = $fileroot->getChild($contextpath)->getContent();
|
||||
$this->assertRegExp("/$text.*$text.*$text/is", $json);
|
||||
$this->assertMatchesRegularExpression("/$text.*$text.*$text/is", $json);
|
||||
|
||||
$expanded = json_decode($json);
|
||||
$this->assertTrue(isset($expanded->$text));
|
||||
|
||||
@@ -110,7 +110,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->get_contains_incorrect_expectation(),
|
||||
$this->get_contains_penalty_info_expectation(1.00),
|
||||
$this->get_does_not_contain_total_penalty_expectation());
|
||||
$this->assertRegExp('/B|C/',
|
||||
$this->assertMatchesRegularExpression('/B|C/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
|
||||
// Process a change of answer to the right one, but not sumbitted.
|
||||
@@ -124,7 +124,7 @@ class qbehaviour_adaptive_walkthrough_test extends qbehaviour_walkthrough_test_b
|
||||
$this->get_contains_mc_radio_expectation($rightindex, true, true),
|
||||
$this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, true, false),
|
||||
$this->get_contains_mc_radio_expectation(($rightindex + 2) % 3, true, false));
|
||||
$this->assertRegExp('/B|C/',
|
||||
$this->assertMatchesRegularExpression('/B|C/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
|
||||
// Now submit the right answer.
|
||||
|
||||
@@ -92,7 +92,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou
|
||||
$this->get_contains_incorrect_expectation(),
|
||||
$this->get_does_not_contain_penalty_info_expectation(),
|
||||
$this->get_does_not_contain_total_penalty_expectation());
|
||||
$this->assertRegExp('/B|C/',
|
||||
$this->assertMatchesRegularExpression('/B|C/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
|
||||
// Process a change of answer to the right one, but not sumbitted.
|
||||
@@ -106,7 +106,7 @@ class qbehaviour_adaptivenopenalty_walkthrough_test extends qbehaviour_walkthrou
|
||||
$this->get_contains_mc_radio_expectation($rightindex, true, true),
|
||||
$this->get_contains_mc_radio_expectation(($rightindex + 1) % 3, true, false),
|
||||
$this->get_contains_mc_radio_expectation(($rightindex + 2) % 3, true, false));
|
||||
$this->assertRegExp('/B|C/',
|
||||
$this->assertMatchesRegularExpression('/B|C/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
|
||||
// Now submit the right answer.
|
||||
|
||||
@@ -209,9 +209,9 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes
|
||||
$this->get_contains_incorrect_expectation());
|
||||
$this->assertEquals('A [' . question_cbm::get_short_string(question_cbm::HIGH) . ']',
|
||||
$this->quba->get_right_answer_summary($this->slot));
|
||||
$this->assertRegExp('/' . preg_quote($mc->questiontext, '/') . '/',
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($mc->questiontext, '/') . '/',
|
||||
$this->quba->get_question_summary($this->slot));
|
||||
$this->assertRegExp('/(B|C) \[' . preg_quote(question_cbm::get_short_string(question_cbm::MED), '/') . '\]/',
|
||||
$this->assertMatchesRegularExpression('/(B|C) \[' . preg_quote(question_cbm::get_short_string(question_cbm::MED), '/') . '\]/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
|
||||
// Save the old attempt.
|
||||
@@ -234,7 +234,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes
|
||||
$this->get_does_not_contain_correctness_expectation());
|
||||
$this->assertEquals('A [' . question_cbm::get_short_string(question_cbm::HIGH) . ']',
|
||||
$this->quba->get_right_answer_summary($this->slot));
|
||||
$this->assertRegExp('/' . preg_quote($mc->questiontext, '/') . '/',
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($mc->questiontext, '/') . '/',
|
||||
$this->quba->get_question_summary($this->slot));
|
||||
$this->assertNull($this->quba->get_response_summary($this->slot));
|
||||
|
||||
@@ -249,7 +249,7 @@ class qbehaviour_deferredcbm_walkthrough_test extends qbehaviour_walkthrough_tes
|
||||
$this->get_contains_mc_radio_expectation($rightindex, false, true),
|
||||
$this->get_contains_cbm_radio_expectation(question_cbm::HIGH, false, true),
|
||||
$this->get_contains_correct_expectation());
|
||||
$this->assertRegExp('/(A) \[' . preg_quote(question_cbm::get_short_string(question_cbm::HIGH), '/') . '\]/',
|
||||
$this->assertMatchesRegularExpression('/(A) \[' . preg_quote(question_cbm::get_short_string(question_cbm::HIGH), '/') . '\]/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class qbehaviour_deferredfeedback_walkthrough_test extends qbehaviour_walkthroug
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->assertEquals(get_string('true', 'qtype_truefalse'),
|
||||
$this->quba->get_right_answer_summary($this->slot));
|
||||
$this->assertRegExp('/' . preg_quote($tf->questiontext, '/') . '/',
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($tf->questiontext, '/') . '/',
|
||||
$this->quba->get_question_summary($this->slot));
|
||||
$this->assertNull($this->quba->get_response_summary($this->slot));
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ class qbehaviour_immediatecbm_walkthrough_test extends qbehaviour_walkthrough_te
|
||||
$this->get_does_not_contain_feedback_expectation());
|
||||
$this->assertEquals('A [' . question_cbm::get_short_string(question_cbm::HIGH) . ']',
|
||||
$this->quba->get_right_answer_summary($this->slot));
|
||||
$this->assertRegExp('/' . preg_quote($mc->questiontext, '/') . '/',
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($mc->questiontext, '/') . '/',
|
||||
$this->quba->get_question_summary($this->slot));
|
||||
$this->assertNull($this->quba->get_response_summary($this->slot));
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ class qbehaviour_immediatefeedback_walkthrough_test extends qbehaviour_walkthrou
|
||||
$this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
|
||||
$this->get_contains_mc_radio_expectation(($wrongindex + 1) % 3, false, false),
|
||||
$this->get_contains_incorrect_expectation());
|
||||
$this->assertRegExp('/B|C/',
|
||||
$this->assertMatchesRegularExpression('/B|C/',
|
||||
$this->quba->get_response_summary($this->slot));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ class qbehaviour_missing_test extends advanced_testcase {
|
||||
$this->assertEquals(array('-submit' => '1', 'choice0' => '1'), $step->get_all_data());
|
||||
|
||||
$output = $qa->render(new question_display_options(), '1');
|
||||
$this->assertRegExp('/' . preg_quote($qa->get_question(false)->questiontext, '/') . '/', $output);
|
||||
$this->assertRegExp('/' . preg_quote(
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($qa->get_question(false)->questiontext, '/') . '/', $output);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote(
|
||||
get_string('questionusedunknownmodel', 'qbehaviour_missing'), '/') . '/', $output);
|
||||
$this->assertTag(array('tag'=>'div', 'attributes'=>array('class'=>'warning')), $output);
|
||||
}
|
||||
|
||||
@@ -482,12 +482,12 @@ abstract class question_testcase extends advanced_testcase {
|
||||
public function assert($expectation, $compare, $notused = '') {
|
||||
|
||||
if (get_class($expectation) === 'question_pattern_expectation') {
|
||||
$this->assertRegExp($expectation->pattern, $compare,
|
||||
$this->assertMatchesRegularExpression($expectation->pattern, $compare,
|
||||
'Expected regex ' . $expectation->pattern . ' not found in ' . $compare);
|
||||
return;
|
||||
|
||||
} else if (get_class($expectation) === 'question_no_pattern_expectation') {
|
||||
$this->assertNotRegExp($expectation->pattern, $compare,
|
||||
$this->assertDoesNotMatchRegularExpression($expectation->pattern, $compare,
|
||||
'Unexpected regex ' . $expectation->pattern . ' found in ' . $compare);
|
||||
return;
|
||||
|
||||
|
||||
@@ -90,21 +90,21 @@ class question_attempt_testcase extends advanced_testcase {
|
||||
|
||||
public function test_get_qt_field_name() {
|
||||
$name = $this->qa->get_qt_field_name('test');
|
||||
$this->assertRegExp('/^' . preg_quote($this->qa->get_field_prefix(), '/') . '/', $name);
|
||||
$this->assertRegExp('/_test$/', $name);
|
||||
$this->assertMatchesRegularExpression('/^' . preg_quote($this->qa->get_field_prefix(), '/') . '/', $name);
|
||||
$this->assertMatchesRegularExpression('/_test$/', $name);
|
||||
}
|
||||
|
||||
public function test_get_behaviour_field_name() {
|
||||
$name = $this->qa->get_behaviour_field_name('test');
|
||||
$this->assertRegExp('/^' . preg_quote($this->qa->get_field_prefix(), '/') . '/', $name);
|
||||
$this->assertRegExp('/_-test$/', $name);
|
||||
$this->assertMatchesRegularExpression('/^' . preg_quote($this->qa->get_field_prefix(), '/') . '/', $name);
|
||||
$this->assertMatchesRegularExpression('/_-test$/', $name);
|
||||
}
|
||||
|
||||
public function test_get_field_prefix() {
|
||||
$this->qa->set_slot(7);
|
||||
$name = $this->qa->get_field_prefix();
|
||||
$this->assertRegExp('/' . preg_quote($this->usageid, '/') . '/', $name);
|
||||
$this->assertRegExp('/' . preg_quote($this->qa->get_slot(), '/') . '/', $name);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($this->usageid, '/') . '/', $name);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($this->qa->get_slot(), '/') . '/', $name);
|
||||
}
|
||||
|
||||
public function test_get_submitted_var_not_present_var_returns_null() {
|
||||
|
||||
@@ -169,11 +169,11 @@ class qformat_xml_test extends question_testcase {
|
||||
$exporter = new qformat_xml();
|
||||
$xml = $exporter->writequestion($q);
|
||||
|
||||
$this->assertRegExp('|<hint format=\"moodle_auto_format\">\s*<text>\s*' .
|
||||
$this->assertMatchesRegularExpression('|<hint format=\"moodle_auto_format\">\s*<text>\s*' .
|
||||
'This is the first hint\.\s*</text>\s*</hint>|', $xml);
|
||||
$this->assertNotRegExp('|<shownumcorrect/>|', $xml);
|
||||
$this->assertNotRegExp('|<clearwrong/>|', $xml);
|
||||
$this->assertNotRegExp('|<options>|', $xml);
|
||||
$this->assertDoesNotMatchRegularExpression('|<shownumcorrect/>|', $xml);
|
||||
$this->assertDoesNotMatchRegularExpression('|<clearwrong/>|', $xml);
|
||||
$this->assertDoesNotMatchRegularExpression('|<options>|', $xml);
|
||||
}
|
||||
|
||||
public function test_write_hint_with_parts() {
|
||||
@@ -204,16 +204,16 @@ class qformat_xml_test extends question_testcase {
|
||||
$exporter = new qformat_xml();
|
||||
$xml = $exporter->writequestion($q);
|
||||
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'|<hint format=\"html\">\s*<text>\s*This is the first hint\.\s*</text>|', $xml);
|
||||
$this->assertRegExp(
|
||||
$this->assertMatchesRegularExpression(
|
||||
'|<hint format=\"html\">\s*<text>\s*This is the second hint\.\s*</text>|', $xml);
|
||||
list($ignored, $hint1, $hint2) = explode('<hint', $xml);
|
||||
$this->assertNotRegExp('|<shownumcorrect/>|', $hint1);
|
||||
$this->assertRegExp('|<clearwrong/>|', $hint1);
|
||||
$this->assertRegExp('|<shownumcorrect/>|', $hint2);
|
||||
$this->assertNotRegExp('|<clearwrong/>|', $hint2);
|
||||
$this->assertNotRegExp('|<options>|', $xml);
|
||||
$this->assertDoesNotMatchRegularExpression('|<shownumcorrect/>|', $hint1);
|
||||
$this->assertMatchesRegularExpression('|<clearwrong/>|', $hint1);
|
||||
$this->assertMatchesRegularExpression('|<shownumcorrect/>|', $hint2);
|
||||
$this->assertDoesNotMatchRegularExpression('|<clearwrong/>|', $hint2);
|
||||
$this->assertDoesNotMatchRegularExpression('|<options>|', $xml);
|
||||
}
|
||||
|
||||
public function test_import_hints_no_parts() {
|
||||
|
||||
@@ -46,7 +46,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->currentoutput);
|
||||
|
||||
if ($content) {
|
||||
$this->assertRegExp('/' . preg_quote(s($content), '/') . '/', $this->currentoutput);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote(s($content), '/') . '/', $this->currentoutput);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$needsgrading);
|
||||
$this->check_current_mark(null);
|
||||
$this->render();
|
||||
$this->assertRegExp('/' . preg_quote($response, '/') . '/', $this->currentoutput);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($response, '/') . '/', $this->currentoutput);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($q),
|
||||
$this->get_contains_general_feedback_expectation($q));
|
||||
@@ -176,7 +176,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$needsgrading);
|
||||
$this->check_current_mark(null);
|
||||
$this->render();
|
||||
$this->assertRegExp('/' . preg_quote(s($response), '/') . '/', $this->currentoutput);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote(s($response), '/') . '/', $this->currentoutput);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($q),
|
||||
$this->get_contains_general_feedback_expectation($q));
|
||||
@@ -233,7 +233,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->check_current_state(question_state::$needsgrading);
|
||||
$this->check_current_mark(null);
|
||||
$this->render();
|
||||
$this->assertRegExp('/' . preg_quote(s('Once upon a time there was a little green frog.'), '/') . '/', $this->currentoutput);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote(s('Once upon a time there was a little green frog.'), '/') . '/', $this->currentoutput);
|
||||
$this->check_current_output(
|
||||
$this->get_contains_question_text_expectation($q),
|
||||
$this->get_contains_general_feedback_expectation($q));
|
||||
@@ -435,7 +435,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
// Check the display.
|
||||
$this->load_quba();
|
||||
$this->render();
|
||||
$this->assertRegExp('/I refuse to draw you a picture, so there!/', $this->currentoutput);
|
||||
$this->assertMatchesRegularExpression('/I refuse to draw you a picture, so there!/', $this->currentoutput);
|
||||
}
|
||||
|
||||
public function test_deferred_feedback_plain_attempt_on_last() {
|
||||
@@ -497,7 +497,7 @@ class qtype_essay_walkthrough_testcase extends qbehaviour_walkthrough_test_base
|
||||
$this->load_quba();
|
||||
$this->render();
|
||||
// Test taht no HTML comment has been added to the response.
|
||||
$this->assertRegExp('/Once upon a time there was a frog called Freddy. He lived happily ever after.(?!<!--)/', $this->currentoutput);
|
||||
$this->assertMatchesRegularExpression('/Once upon a time there was a frog called Freddy. He lived happily ever after.(?!<!--)/', $this->currentoutput);
|
||||
// Test for the hash of an empty file area.
|
||||
$this->assertStringNotContainsString('d41d8cd98f00b204e9800998ecf8427e', $this->currentoutput);
|
||||
}
|
||||
|
||||
@@ -140,12 +140,12 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
$match = test_question_maker::make_question('match');
|
||||
$match->start_attempt(new question_attempt_step(), 1);
|
||||
$qsummary = $match->get_question_summary();
|
||||
$this->assertRegExp('/' . preg_quote($match->questiontext, '/') . '/', $qsummary);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($match->questiontext, '/') . '/', $qsummary);
|
||||
foreach ($match->stems as $stem) {
|
||||
$this->assertRegExp('/' . preg_quote($stem, '/') . '/', $qsummary);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($stem, '/') . '/', $qsummary);
|
||||
}
|
||||
foreach ($match->choices as $choice) {
|
||||
$this->assertRegExp('/' . preg_quote($choice, '/') . '/', $qsummary);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($choice, '/') . '/', $qsummary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +155,8 @@ class qtype_match_question_test extends advanced_testcase {
|
||||
|
||||
$summary = $match->summarise_response($match->prepare_simulated_post_data(array('Dog' => 'Amphibian', 'Frog' => 'Mammal')));
|
||||
|
||||
$this->assertRegExp('/Dog -> Amphibian/', $summary);
|
||||
$this->assertRegExp('/Frog -> Mammal/', $summary);
|
||||
$this->assertMatchesRegularExpression('/Dog -> Amphibian/', $summary);
|
||||
$this->assertMatchesRegularExpression('/Frog -> Mammal/', $summary);
|
||||
}
|
||||
|
||||
public function test_classify_response() {
|
||||
|
||||
@@ -105,9 +105,9 @@ class qtype_missing_test extends question_testcase {
|
||||
|
||||
$output = $qa->render(new question_display_options(), '1');
|
||||
|
||||
$this->assertRegExp('/' .
|
||||
$this->assertMatchesRegularExpression('/' .
|
||||
preg_quote($qa->get_question(false)->questiontext, '/') . '/', $output);
|
||||
$this->assertRegExp('/' .
|
||||
$this->assertMatchesRegularExpression('/' .
|
||||
preg_quote(get_string('missingqtypewarning', 'qtype_missingtype'), '/') . '/', $output);
|
||||
$this->assert(new question_contains_tag_with_attribute(
|
||||
'div', 'class', 'warning missingqtypewarning'), $output);
|
||||
|
||||
@@ -378,10 +378,10 @@ class qtype_multianswer_walkthrough_test extends qbehaviour_walkthrough_test_bas
|
||||
$this->get_contains_select_expectation('sub4_answer', $choices, null, true));
|
||||
$this->render();
|
||||
$a = array('mark' => '0.00', 'max' => '1.00');
|
||||
$this->assertNotRegExp('~' . preg_quote(get_string('markoutofmax', 'question', $a), '~') . '~',
|
||||
$this->assertDoesNotMatchRegularExpression('~' . preg_quote(get_string('markoutofmax', 'question', $a), '~') . '~',
|
||||
$this->currentoutput);
|
||||
$a['mark'] = '1.00';
|
||||
$this->assertNotRegExp('~' . preg_quote(get_string('markoutofmax', 'question', $a), '~') . '~',
|
||||
$this->assertDoesNotMatchRegularExpression('~' . preg_quote(get_string('markoutofmax', 'question', $a), '~') . '~',
|
||||
$this->currentoutput);
|
||||
}
|
||||
|
||||
|
||||
@@ -116,9 +116,9 @@ class qtype_multichoice_multi_question_test extends advanced_testcase {
|
||||
|
||||
$qsummary = $mc->get_question_summary();
|
||||
|
||||
$this->assertRegExp('/' . preg_quote($mc->questiontext, '/') . '/', $qsummary);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($mc->questiontext, '/') . '/', $qsummary);
|
||||
foreach ($mc->answers as $answer) {
|
||||
$this->assertRegExp('/' . preg_quote($answer->answer, '/') . '/', $qsummary);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($answer->answer, '/') . '/', $qsummary);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,12 +130,12 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
$question = test_question_maker::make_question('randomsamatch');
|
||||
$question->start_attempt(new question_attempt_step(), 1);
|
||||
$qsummary = $question->get_question_summary();
|
||||
$this->assertRegExp('/' . preg_quote($question->questiontext, '/') . '/', $qsummary);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($question->questiontext, '/') . '/', $qsummary);
|
||||
foreach ($question->stems as $stem) {
|
||||
$this->assertRegExp('/' . preg_quote($stem, '/') . '/', $qsummary);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($stem, '/') . '/', $qsummary);
|
||||
}
|
||||
foreach ($question->choices as $choice) {
|
||||
$this->assertRegExp('/' . preg_quote($choice, '/') . '/', $qsummary);
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($choice, '/') . '/', $qsummary);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ class qtype_randomsamatch_question_test extends advanced_testcase {
|
||||
|
||||
$summary = $question->summarise_response(array('sub0' => 2, 'sub1' => 1));
|
||||
|
||||
$this->assertRegExp('/Dog -> \w+; Frog -> \w+/', $summary);
|
||||
$this->assertMatchesRegularExpression('/Dog -> \w+; Frog -> \w+/', $summary);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ class qtype_truefalse_walkthrough_test extends qbehaviour_walkthrough_test_base
|
||||
get_string('questiontext', 'question')));
|
||||
$this->assertEquals(get_string('false', 'qtype_truefalse'),
|
||||
$this->quba->get_right_answer_summary($this->slot));
|
||||
$this->assertRegExp('/' . preg_quote($tf->questiontext, '/') . '/',
|
||||
$this->assertMatchesRegularExpression('/' . preg_quote($tf->questiontext, '/') . '/',
|
||||
$this->quba->get_question_summary($this->slot));
|
||||
$this->assertNull($this->quba->get_response_summary($this->slot));
|
||||
|
||||
|
||||
@@ -424,13 +424,13 @@ class search_solr_engine_testcase extends advanced_testcase {
|
||||
$result = reset($results);
|
||||
|
||||
$regex = '|'.\search_solr\engine::HIGHLIGHT_START.'message'.\search_solr\engine::HIGHLIGHT_END.'|';
|
||||
$this->assertRegExp($regex, $result->get('content'));
|
||||
$this->assertMatchesRegularExpression($regex, $result->get('content'));
|
||||
|
||||
$searchrenderer = $PAGE->get_renderer('core_search');
|
||||
$exported = $result->export_for_template($searchrenderer);
|
||||
|
||||
$regex = '|<span class="highlight">message</span>|';
|
||||
$this->assertRegExp($regex, $exported['content']);
|
||||
$this->assertMatchesRegularExpression($regex, $exported['content']);
|
||||
}
|
||||
|
||||
public function test_export_file_for_engine() {
|
||||
|
||||
Reference in New Issue
Block a user