-
Notifications
You must be signed in to change notification settings - Fork 356
Another attempt to make it work under PHP 5.3 and PHP 8+ #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ff33d72
ac97290
cc3d1cb
861deec
5bb24e3
80bb70e
43c49e7
6530d3f
ebc1243
df08460
9fc4671
f21197f
8436a48
01ec2c9
a9eae67
d31898e
7f8b32f
ab4622d
52640e1
44cc011
c980858
c52483b
872b34c
095ae91
4350562
7b74df3
4083f14
3e00bdb
f911163
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -29,12 +29,14 @@ | |||||
"require": { | ||||||
"php": ">=5.3.3", | ||||||
"marc-mabe/php-enum":"^2.0 || ^3.0 || ^4.0", | ||||||
"icecave/parity": "1.0.0" | ||||||
"icecave/parity": ">=1.0.0" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}, | ||||||
"require-dev": { | ||||||
"friendsofphp/php-cs-fixer": "~2.2.20 || ~2.19.0", | ||||||
"json-schema/json-schema-test-suite": "1.2.0", | ||||||
"phpunit/phpunit": "^4.8.35" | ||||||
"phpunit/phpunit": "^4.8.36 || ^5.7.27 || ^6.5.14 || ^7.5.20 || ^8.5.29 || ^9.5.24", | ||||||
"sanmai/phpunit-legacy-adapter": "^6.4 || ^8.2.1", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a certain bias since I'm the author of this package. In my defense, it is used by several high-profile packages with millions of installs to solve the very this problem. Check out the readme: https://github.com/sanmai/phpunit-legacy-adapter There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should probably not need this I think there should be another way of managing this, if I understand correctly PHPUnit 9 is not compatible with php < 8 right? IMO we should try to run PHPUnit 9 if possible, if not we should take the highest one possible. We can definitely do this inside the CI directly but leave this requirement to 9. |
||||||
"phpspec/prophecy-phpunit": "^1.1 || ^2.0.1" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why this dependency? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IIRC most recent PHPUnit does not depend on this library, where in fact it is used by this library. But I digress: it has been two years; my memory is foggy. |
||||||
}, | ||||||
"extra": { | ||||||
"branch-alias": { | ||||||
|
@@ -69,10 +71,10 @@ | |||||
"bin/validate-json" | ||||||
], | ||||||
"scripts": { | ||||||
"coverage": "phpunit --coverage-text", | ||||||
"coverage": "vendor/bin/phpunit --coverage-text", | ||||||
"style-check": "php-cs-fixer fix --dry-run --verbose --diff", | ||||||
"style-fix": "php-cs-fixer fix --verbose", | ||||||
"test": "phpunit", | ||||||
"testOnly": "phpunit --colors --filter" | ||||||
"test": "vendor/bin/phpunit", | ||||||
"testOnly": "vendor/bin/phpunit --colors --filter" | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ | |
|
||
namespace JsonSchema\Tests\Constraints; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use LegacyPHPUnit\TestCase; | ||
use Prophecy\Argument; | ||
|
||
/** | ||
|
@@ -87,4 +87,22 @@ private function getJsonSchemaDraft04() | |
|
||
return $this->jsonSchemaDraft04; | ||
} | ||
|
||
public function expectExceptionCompat($exception) | ||
{ | ||
if (\is_callable(array('PHPUnit\Framework\TestCase', 'expectException'))) { | ||
parent::expectException($exception); | ||
} else { | ||
$this->setExpectedException($exception); | ||
} | ||
} | ||
|
||
public static function assertIsArrayCompat($actual, $message = '') | ||
{ | ||
if (\is_callable(array('PHPUnit\Framework\TestCase', 'assertIsArray'))) { | ||
parent::assertIsArray($actual, $message); | ||
} else { | ||
static::assertInternalType('array', $actual, $message); | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Target PHP versions do not support traits, therefore we can't use off-the-shelf polyfill. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about replacing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Following the same logic we should use |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,14 @@ | |
namespace JsonSchema\Tests\Entity; | ||
|
||
use JsonSchema\Entity\JsonPointer; | ||
use PHPUnit\Framework\TestCase; | ||
use JsonSchema\Tests\Constraints\VeryBaseTestCase; | ||
|
||
/** | ||
* @package JsonSchema\Tests\Entity | ||
* | ||
* @author Joost Nijhuis <[email protected]> | ||
*/ | ||
class JsonPointerTest extends TestCase | ||
class JsonPointerTest extends VeryBaseTestCase | ||
{ | ||
/** | ||
* @dataProvider getTestData | ||
|
@@ -113,7 +113,7 @@ public function testJsonPointerWithPropertyPaths() | |
|
||
public function testCreateWithInvalidValue() | ||
{ | ||
$this->setExpectedException( | ||
$this->expectExceptionCompat( | ||
'\JsonSchema\Exception\InvalidArgumentException', | ||
'Ref value must be a string' | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to drop this because it leads to installing dependencies broken on PHP 8.1.