Skip to content

Commit

Permalink
Closes #3957
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Nov 25, 2019
1 parent cb5d93b commit dfee47c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
1 change: 1 addition & 0 deletions ChangeLog-9.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes of the PHPUnit 9.0 release series are documented in this fil
* Implemented [#3495](https://github.com/sebastianbergmann/phpunit/issues/3495): Remove `assertArraySubset()`
* Implemented [#3523](https://github.com/sebastianbergmann/phpunit/issues/3523): Remove the `setUseErrorHandler()` method
* Implemented [#3951](https://github.com/sebastianbergmann/phpunit/issues/3951): Remove optional parameters of `assertFileEquals()` etc.
* Implemented [#3957](https://github.com/sebastianbergmann/phpunit/issues/3957): Remove `expectExceptionMessageRegExp()`

[9.0.0]: https://github.com/sebastianbergmann/phpunit/compare/8.5...master

16 changes: 4 additions & 12 deletions src/Framework/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -500,14 +500,6 @@ public function expectExceptionMessageMatches(string $regularExpression): void
$this->expectedExceptionMessageRegExp = $regularExpression;
}

/**
* @deprecated Use expectExceptionMessageMatches() instead
*/
public function expectExceptionMessageRegExp(string $regularExpression): void
{
$this->expectExceptionMessageMatches($regularExpression);
}

/**
* Sets up an expectation for an exception to be raised by the code under test.
* Information for expected exception class, expected exception message, and
Expand Down Expand Up @@ -537,7 +529,7 @@ public function expectDeprecationMessage(string $message): void

public function expectDeprecationMessageMatches(string $regularExpression): void
{
$this->expectExceptionMessageRegExp($regularExpression);
$this->expectExceptionMessageMatches($regularExpression);
}

public function expectNotice(): void
Expand All @@ -552,7 +544,7 @@ public function expectNoticeMessage(string $message): void

public function expectNoticeMessageMatches(string $regularExpression): void
{
$this->expectExceptionMessageRegExp($regularExpression);
$this->expectExceptionMessageMatches($regularExpression);
}

public function expectWarning(): void
Expand All @@ -567,7 +559,7 @@ public function expectWarningMessage(string $message): void

public function expectWarningMessageMatches(string $regularExpression): void
{
$this->expectExceptionMessageRegExp($regularExpression);
$this->expectExceptionMessageMatches($regularExpression);
}

public function expectError(): void
Expand All @@ -582,7 +574,7 @@ public function expectErrorMessage(string $message): void

public function expectErrorMessageMatches(string $regularExpression): void
{
$this->expectExceptionMessageRegExp($regularExpression);
$this->expectExceptionMessageMatches($regularExpression);
}

public function getStatus(): int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ final class ExceptionMessageRegExpTest extends TestCase
public function testRegexMessage(): void
{
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/^A polymorphic \w+ message/');
$this->expectExceptionMessageMatches('/^A polymorphic \w+ message/');

throw new \Exception('A polymorphic exception message');
}

public function testRegexMessageExtreme(): void
{
$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('/^a poly[a-z]+ [a-zA-Z0-9_]+ me(s){2}age$/i');
$this->expectExceptionMessageMatches('/^a poly[a-z]+ [a-zA-Z0-9_]+ me(s){2}age$/i');

throw new \Exception('A polymorphic exception message');
}
Expand All @@ -41,7 +41,7 @@ public function testMessageXdebugScreamCompatibility(): void
\ini_set('xdebug.scream', '1');

$this->expectException(\Exception::class);
$this->expectExceptionMessageRegExp('#Screaming preg_match#');
$this->expectExceptionMessageMatches('#Screaming preg_match#');

throw new \Exception('Screaming preg_match');
}
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/Framework/TestCaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,21 +333,21 @@ public function testExceptionWithRegexpMessage(): void
{
$test = new \ThrowExceptionTestCase('test');
$test->expectException(\RuntimeException::class);
$test->expectExceptionMessageRegExp('/runtime .*? occurred/');
$test->expectExceptionMessageMatches('/runtime .*? occurred/');

$result = $test->run();

$this->assertCount(1, $result);
$this->assertTrue($result->wasSuccessful());
}

public function testExpectExceptionMessageRegExpAllowsAccessingExpectedExceptionRegExp(): void
public function testexpectExceptionMessageMatchesAllowsAccessingExpectedExceptionRegExp(): void
{
$messageRegExp = '/runtime .*? occurred/';

$test = new \ThrowExceptionTestCase('test');

$test->expectExceptionMessageRegExp($messageRegExp);
$test->expectExceptionMessageMatches($messageRegExp);

$this->assertSame($messageRegExp, $test->getExpectedExceptionMessageRegExp());
}
Expand All @@ -356,7 +356,7 @@ public function testExceptionWithWrongRegexpMessage(): void
{
$test = new \ThrowExceptionTestCase('test');
$test->expectException(\RuntimeException::class);
$test->expectExceptionMessageRegExp('/logic .*? occurred/');
$test->expectExceptionMessageMatches('/logic .*? occurred/');

$result = $test->run();

Expand All @@ -372,7 +372,7 @@ public function testExceptionWithInvalidRegexpMessage(): void
{
$test = new \ThrowExceptionTestCase('test');
$test->expectException(\RuntimeException::class);
$test->expectExceptionMessageRegExp('#runtime .*? occurred/');
$test->expectExceptionMessageMatches('#runtime .*? occurred/');

$test->run();

Expand Down
4 changes: 2 additions & 2 deletions tests/unit/Util/TestClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,7 @@ public function testTestWithThrowsProperExceptionIfDatasetCannotBeParsed(): void
), VariousDocblockDefinedDataProvider::class);

$this->expectException(Exception::class);
$this->expectExceptionMessageRegExp('/^The data set for the @testWith annotation cannot be parsed:/');
$this->expectExceptionMessageMatches('/^The data set for the @testWith annotation cannot be parsed:/');

$docBlock->getProvidedData();
}
Expand All @@ -1098,7 +1098,7 @@ public function testTestWithThrowsProperExceptionIfMultiLineDatasetCannotBeParse
), VariousDocblockDefinedDataProvider::class);

$this->expectException(Exception::class);
$this->expectExceptionMessageRegExp('/^The data set for the @testWith annotation cannot be parsed:/');
$this->expectExceptionMessageMatches('/^The data set for the @testWith annotation cannot be parsed:/');

$docBlock->getProvidedData();
}
Expand Down

0 comments on commit dfee47c

Please sign in to comment.