Skip to content

Commit

Permalink
Merge pull request #373 from jrchamp/ci/phpunit-fix-warnings
Browse files Browse the repository at this point in the history
Ci/phpunit fix warnings
  • Loading branch information
jrchamp authored Apr 29, 2022
2 parents 0d28e7e + 559f36d commit d68c6e4
Showing 1 changed file with 27 additions and 10 deletions.
37 changes: 27 additions & 10 deletions tests/advanced_passcode_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,23 @@ class advanced_passcode_test extends basic_testcase {
*/
private $zoomdata;

// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod
/**
* Backward compatibility support for PHPUnit 8 (PHP 7.2 and 7.3).
*
* @param string $pattern Regular expression.
* @param string $string String.
* @param string $message Message.
*/
public static function assertMatchesRegularExpression($pattern, $string, $message = ''): void {
// phpcs:enable
if (method_exists('basic_testcase', 'assertMatchesRegularExpression')) {
parent::assertMatchesRegularExpression($pattern, $string, $message);
} else {
parent::assertRegExp($pattern, $string, $message);
}
}

/**
* Setup to ensure that fixtures are loaded.
*/
Expand Down Expand Up @@ -107,8 +124,8 @@ public function test_settings_letter() {

$passcode = zoom_create_default_passcode($this->zoomdata);
$this->assertEquals(strlen($passcode), 6);
$this->assertRegExp('/\d/', $passcode);
$this->assertRegExp('/[a-zA-Z]/', $passcode);
$this->assertMatchesRegularExpression('/\d/', $passcode);
$this->assertMatchesRegularExpression('/[a-zA-Z]/', $passcode);
}

/**
Expand All @@ -125,9 +142,9 @@ public function test_settings_upper_and_lower_letters() {

$passcode = zoom_create_default_passcode($this->zoomdata);
$this->assertEquals(strlen($passcode), 6);
$this->assertRegExp('/\d/', $passcode);
$this->assertRegExp('/[A-Z]/', $passcode);
$this->assertRegExp('/[a-z]/', $passcode);
$this->assertMatchesRegularExpression('/\d/', $passcode);
$this->assertMatchesRegularExpression('/[A-Z]/', $passcode);
$this->assertMatchesRegularExpression('/[a-z]/', $passcode);
}

/**
Expand All @@ -144,8 +161,8 @@ public function test_settings_special_character() {

$passcode = zoom_create_default_passcode($this->zoomdata);
$this->assertEquals(strlen($passcode), 6);
$this->assertRegExp('/\d/', $passcode);
$this->assertRegExp('/[^a-zA-Z\d]/', $passcode);
$this->assertMatchesRegularExpression('/\d/', $passcode);
$this->assertMatchesRegularExpression('/[^a-zA-Z\d]/', $passcode);
}

/**
Expand All @@ -162,9 +179,9 @@ public function test_settings_all() {

$passcode = zoom_create_default_passcode($this->zoomdata);
$this->assertEquals(strlen($passcode), 7);
$this->assertRegExp('/\d/', $passcode);
$this->assertRegExp('/[a-zA-Z]/', $passcode);
$this->assertRegExp('/[^a-zA-Z\d]/', $passcode);
$this->assertMatchesRegularExpression('/\d/', $passcode);
$this->assertMatchesRegularExpression('/[a-zA-Z]/', $passcode);
$this->assertMatchesRegularExpression('/[^a-zA-Z\d]/', $passcode);
}

/**
Expand Down

0 comments on commit d68c6e4

Please sign in to comment.