This repository has been archived by the owner on Oct 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
234 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
/composer.lock | ||
/phpunit.xml | ||
/vendor/ | ||
/build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of PHPUnit Good Practices. | ||
* | ||
* (c) Dariusz Rumiński <[email protected]> | ||
* | ||
* This source file is subject to the MIT license that is bundled | ||
* with this source code in the file LICENSE. | ||
*/ | ||
|
||
namespace PHPUnitGoodPractices\Polyfill; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
trait PolyfillTrait6 | ||
{ | ||
public function expectException($exception) | ||
{ | ||
if (\is_callable(['parent', 'expectException'])) { | ||
parent::expectException($exception); | ||
} else { | ||
$this->setExpectedException($exception); | ||
} | ||
} | ||
|
||
public function expectExceptionMessageMatches($regexp) | ||
{ | ||
if (\is_callable(['parent', 'expectExceptionMessageMatches'])) { | ||
parent::expectExceptionMessageMatches($regexp); | ||
|
||
return; | ||
} | ||
|
||
// In some PHPUnit versions just setting an expectation for specific | ||
// expection message won't trigger exception handler. Therefore we need | ||
// to set the expected type, but trying to keep the type. | ||
if (\is_callable(['parent', 'getExpectedException'])) { | ||
$expectedException = parent::getExpectedException(); // This is an @internal method. | ||
} | ||
|
||
if (null === $expectedException) { | ||
$expectedException = \Exception::class; | ||
} | ||
|
||
$this->expectException($expectedException); | ||
|
||
if (\is_callable(['parent', 'expectExceptionMessageRegExp'])) { | ||
// Method available since Release 5.2.0 | ||
$this->expectExceptionMessageRegExp($regexp); | ||
} else { | ||
$this->setExpectedExceptionRegExp($expectedException, $regexp); | ||
} | ||
} | ||
|
||
public static function assertIsArray($actual, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertIsArray'])) { | ||
parent::assertIsArray($actual, $message); | ||
} else { | ||
static::assertInternalType('array', $actual, $message); | ||
} | ||
} | ||
|
||
public static function assertIsString($actual, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertIsString'])) { | ||
parent::assertIsString($actual, $message); | ||
} else { | ||
static::assertInternalType('string', $actual, $message); | ||
} | ||
} | ||
|
||
public static function assertIsBool($actual, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertIsBool'])) { | ||
parent::assertIsBool($actual, $message); | ||
} else { | ||
static::assertInternalType('bool', $actual, $message); | ||
} | ||
} | ||
|
||
public static function assertIsCallable($actual, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertIsCallable'])) { | ||
parent::assertIsCallable($actual, $message); | ||
} else { | ||
static::assertInternalType('callable', $actual, $message); | ||
} | ||
} | ||
|
||
public static function assertIsInt($actual, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertIsInt'])) { | ||
parent::assertIsInt($actual, $message); | ||
} else { | ||
static::assertInternalType('int', $actual, $message); | ||
} | ||
} | ||
|
||
public static function assertMatchesRegularExpression($pattern, $string, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertMatchesRegularExpression'])) { | ||
parent::assertMatchesRegularExpression($pattern, $string, $message); | ||
} else { | ||
static::assertRegExp($pattern, $string, $message); | ||
} | ||
} | ||
|
||
public static function assertStringContainsString($needle, $haystack, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertStringContainsString'])) { | ||
parent::assertStringContainsString($needle, $haystack, $message); | ||
} else { | ||
static::assertContains($needle, $haystack, $message); | ||
} | ||
} | ||
|
||
public static function assertStringNotContainsString($needle, $haystack, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertStringNotContainsString'])) { | ||
parent::assertStringNotContainsString($needle, $haystack, $message); | ||
} else { | ||
static::assertNotContains($needle, $haystack, $message); | ||
} | ||
} | ||
|
||
public static function assertFileDoesNotExist($filename, $message = '') | ||
{ | ||
if (\is_callable(['parent', 'assertFileDoesNotExist'])) { | ||
parent::assertFileDoesNotExist($filename, $message); | ||
} else { | ||
static::assertFileNotExists($filename, $message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters