Commit ba5b6089 authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

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
parent 309a65a6
......@@ -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);