Skip to content
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

Extend pipeline for newer versions php #744

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b41bb84
ci: Add PHP 8.0 and greater to build matrix
DannyvdSluijs Jul 30, 2024
2d265b8
ci: Remove PHP 5.3 - 7.1 from workflows
DannyvdSluijs Jul 30, 2024
1aeadd7
build: Require minimum PHP 7.2
DannyvdSluijs Jul 30, 2024
58b2b76
build: Upgrade to PHPUnit 8.5
DannyvdSluijs Jul 30, 2024
2a431f2
refactor: Add now required void return types for setup() methods
DannyvdSluijs Jul 30, 2024
1c4f517
build: Include phpspec/prophecy dependency
DannyvdSluijs Aug 2, 2024
e6eac18
refactor: Replace setExpectedException with expectException/expectExc…
DannyvdSluijs Aug 2, 2024
eb41326
refactor: Replace @expectedException annotation for expectException m…
DannyvdSluijs Aug 2, 2024
0753efb
refactor: Replace assertInternalType for assertIsArray
DannyvdSluijs Aug 2, 2024
524853a
refactor: Replace getMock for createMock
DannyvdSluijs Aug 2, 2024
97a5203
test: Improve test assertions
DannyvdSluijs Aug 2, 2024
4e77e27
fix: Solve return type issues with Objectiterator (port of #682)
DannyvdSluijs Aug 2, 2024
db8111b
build: Update icecave/parity to ^3.0 as 1.0 uses deprecated each() me…
DannyvdSluijs Aug 2, 2024
6448d43
style: Correct code style issues
DannyvdSluijs Aug 2, 2024
ac94ea5
fix: Fix deprecation notices found from GHA workflow run
DannyvdSluijs Aug 2, 2024
5224ee9
fix: Add fallback to empty string when null value is passed in UriRes…
DannyvdSluijs Aug 2, 2024
24b343b
test: Verbose output to get a hint why test are being skipped
DannyvdSluijs Aug 2, 2024
8d29172
fix: Correct path for case-sensitive operating systems
DannyvdSluijs Aug 2, 2024
24b5b4f
fix: Correct path for case-sensitive operating systems
DannyvdSluijs Aug 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,20 @@ jobs:
strategy:
matrix:
php-version:
- "5.3"
- "5.4"
- "5.5"
- "5.6"
- "7.0"
- "7.1"
- "7.2"
- "7.3"
- "7.4"
# - "8.0"
- "8.0"
- "8.1"
- "8.2"
- "8.3"
dependencies: [highest]
experimental: [false]
include:
- php-version: "5.3"
- php-version: "7.2"
dependencies: highest
experimental: false
- php-version: "5.3"
- php-version: "7.2"
dependencies: lowest
experimental: false
# - php-version: "8.0"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
php-version:
- "5.3"
- "7.2"
- "latest"

steps:
Expand Down
9 changes: 5 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@
}
],
"require": {
"php": ">=5.3.3",
"php": "^7.2 || ^8.0",
"marc-mabe/php-enum":"^2.0 || ^3.0 || ^4.0",
"icecave/parity": "1.0.0"
"icecave/parity": "^3.0"
},
"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": "^8.5",
"phpspec/prophecy": "^1.19"
},
"extra": {
"branch-alias": {
Expand Down Expand Up @@ -72,7 +73,7 @@
"coverage": "phpunit --coverage-text",
"style-check": "php-cs-fixer fix --dry-run --verbose --diff",
"style-fix": "php-cs-fixer fix --verbose",
"test": "phpunit",
"test": "phpunit --verbose",
"testOnly": "phpunit --colors --filter"
}
}
5 changes: 3 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit backupGlobals="false"
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
bootstrap="vendor/autoload.php"
verbose="true"
>
Expand Down
11 changes: 6 additions & 5 deletions src/JsonSchema/Iterator/ObjectIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function __construct($object)
/**
* {@inheritdoc}
*/
#[\ReturnTypeWillChange]
public function current()
{
$this->initialize();
Expand All @@ -49,7 +50,7 @@ public function current()
/**
* {@inheritdoc}
*/
public function next()
public function next(): void
{
$this->initialize();
$this->position++;
Expand All @@ -58,7 +59,7 @@ public function next()
/**
* {@inheritdoc}
*/
public function key()
public function key(): int
{
$this->initialize();

Expand All @@ -68,7 +69,7 @@ public function key()
/**
* {@inheritdoc}
*/
public function valid()
public function valid(): bool
{
$this->initialize();

Expand All @@ -78,7 +79,7 @@ public function valid()
/**
* {@inheritdoc}
*/
public function rewind()
public function rewind(): void
{
$this->initialize();
$this->position = 0;
Expand All @@ -87,7 +88,7 @@ public function rewind()
/**
* {@inheritdoc}
*/
public function count()
public function count(): int
{
$this->initialize();

Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/Uri/UriResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class UriResolver implements UriResolverInterface
*/
public function parse($uri)
{
preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri, $match);
preg_match('|^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?|', $uri ?: '', $match);

$components = array();
if (5 < count($match)) {
Expand Down
2 changes: 1 addition & 1 deletion src/JsonSchema/Uri/UriRetriever.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function confirmMediaType($uriRetriever, $uri)
}

foreach ($this->allowedInvalidContentTypeEndpoints as $endpoint) {
if (strpos($uri, $endpoint) === 0) {
if (!\is_null($uri) && strpos($uri, $endpoint) === 0) {
return true;
}
}
Expand Down
7 changes: 3 additions & 4 deletions tests/ConstraintErrorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ public function testGetInvalidMessage()
{
$e = ConstraintError::MISSING_ERROR();

$this->setExpectedException(
'\JsonSchema\Exception\InvalidArgumentException',
'Missing error message for missingError'
);
$this->expectException('\JsonSchema\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Missing error message for missingError');

$e->getMessage();
}
}
2 changes: 1 addition & 1 deletion tests/Constraints/CoerciveTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class CoerciveTest extends VeryBaseTestCase
{
protected $factory = null;

public function setUp()
public function setUp(): void
{
$this->factory = new Factory();
$this->factory->setConfig(Constraint::CHECK_MODE_TYPE_CAST | Constraint::CHECK_MODE_COERCE_TYPES);
Expand Down
14 changes: 6 additions & 8 deletions tests/Constraints/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class FactoryTest extends TestCase
*/
protected $factory;

protected function setUp()
protected function setUp(): void
{
$this->factory = new Factory();
}
Expand Down Expand Up @@ -85,7 +85,7 @@ public function constraintNameProvider()
*/
public function testExceptionWhenCreateInstanceForInvalidConstraintName($constraintName)
{
$this->setExpectedException('JsonSchema\Exception\InvalidArgumentException');
$this->expectException('JsonSchema\Exception\InvalidArgumentException');
$this->factory->createInstanceFor($constraintName);
}

Expand All @@ -96,19 +96,17 @@ public function invalidConstraintNameProvider()
);
}

/**
* @expectedException \JsonSchema\Exception\InvalidArgumentException
*/
public function testSetConstraintClassExistsCondition()
{
$this->expectException(\JsonSchema\Exception\InvalidArgumentException::class);

$this->factory->setConstraintClass('string', 'SomeConstraint');
}

/**
* @expectedException \JsonSchema\Exception\InvalidArgumentException
*/
public function testSetConstraintClassImplementsCondition()
{
$this->expectException(\JsonSchema\Exception\InvalidArgumentException::class);

$this->factory->setConstraintClass('string', 'JsonSchema\Tests\Constraints\MyBadConstraint');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Constraints/FormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FormatTest extends BaseTestCase
{
protected $validateSchema = true;

public function setUp()
public function setUp(): void
{
date_default_timezone_set('UTC');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Constraints/MinLengthMaxLengthMultiByteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class MinLengthMaxLengthMultiByteTest extends BaseTestCase
{
protected $validateSchema = true;

protected function setUp()
protected function setUp(): void
{
if (!extension_loaded('mbstring')) {
$this->markTestSkipped('mbstring extension is not available');
Expand Down
13 changes: 5 additions & 8 deletions tests/Constraints/SchemaValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,16 @@ public function testValidCases($schema)

public function testNonObjectSchema()
{
$this->setExpectedException(
'\JsonSchema\Exception\RuntimeException',
'Cannot validate the schema of a non-object'
);
$this->expectException('\JsonSchema\Exception\RuntimeException');
$this->expectExceptionMessage('Cannot validate the schema of a non-object');

$this->testValidCases('"notAnObject"');
}

public function testInvalidSchemaException()
{
$this->setExpectedException(
'\JsonSchema\Exception\InvalidSchemaException',
'Schema did not pass validation'
);
$this->expectException('\JsonSchema\Exception\InvalidSchemaException');
$this->expectExceptionMessage('Schema did not pass validation');

$input = json_decode('{}');
$schema = json_decode('{"properties":{"propertyOne":{"type":"string","required":true}}}');
Expand Down
2 changes: 1 addition & 1 deletion tests/Constraints/SelfDefinedSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testInvalidArgumentException()

$v = new Validator();

$this->setExpectedException('\JsonSchema\Exception\InvalidArgumentException');
$this->expectException('\JsonSchema\Exception\InvalidArgumentException');

$v->validate($value, $schema);
}
Expand Down
17 changes: 8 additions & 9 deletions tests/Constraints/TypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private function assertTypeConstraintError($expected, TypeConstraint $actual)

$actualError = $actualErrors[0];

$this->assertInternalType('array', $actualError, sprintf('Failed to assert that Type error is an array, %s given', gettype($actualError)));
$this->assertIsArray($actualError, sprintf('Failed to assert that Type error is an array, %s given', gettype($actualError)));

$messageKey = 'message';
$this->assertArrayHasKey(
Expand Down Expand Up @@ -116,6 +116,7 @@ public function testValidateTypeNameWording($nameWording)
$m->setAccessible(true);

$m->invoke($t, $nameWording);
$this->expectNotToPerformAssertions();
}

public function testInvalidateTypeNameWording()
Expand All @@ -125,10 +126,9 @@ public function testInvalidateTypeNameWording()
$m = $r->getMethod('validateTypeNameWording');
$m->setAccessible(true);

$this->setExpectedException(
'\UnexpectedValueException',
"No wording for 'notAValidTypeName' available, expected wordings are: [an integer, a number, a boolean, an object, an array, a string, a null]"
);
$this->expectException('\UnexpectedValueException');
$this->expectExceptionMessage("No wording for 'notAValidTypeName' available, expected wordings are: [an integer, a number, a boolean, an object, an array, a string, a null]");

$m->invoke($t, 'notAValidTypeName');
}

Expand All @@ -138,10 +138,9 @@ public function testValidateTypeException()
$data = new \stdClass();
$schema = json_decode('{"type": "notAValidTypeName"}');

$this->setExpectedException(
'JsonSchema\Exception\InvalidArgumentException',
'object is an invalid type for notAValidTypeName'
);
$this->expectException('JsonSchema\Exception\InvalidArgumentException');
$this->expectExceptionMessage('object is an invalid type for notAValidTypeName');

$t->check($data, $schema);
}
}
2 changes: 1 addition & 1 deletion tests/Constraints/ValidationExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testValidationException()
$exception->getMessage()
);

$this->setExpectedException('JsonSchema\Exception\ValidationException');
$this->expectException('JsonSchema\Exception\ValidationException');
throw $exception;
}
}
2 changes: 1 addition & 1 deletion tests/Constraints/VeryBaseTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ abstract class VeryBaseTestCase extends TestCase
*/
protected function getUriRetrieverMock($schema)
{
$relativeTestsRoot = realpath(__DIR__ . '/../../vendor/json-schema/JSON-Schema-Test-Suite/remotes');
$relativeTestsRoot = realpath(__DIR__ . '/../../vendor/json-schema/json-schema-test-suite/remotes');

$jsonSchemaDraft03 = $this->getJsonSchemaDraft03();
$jsonSchemaDraft04 = $this->getJsonSchemaDraft04();
Expand Down
2 changes: 1 addition & 1 deletion tests/Drafts/BaseDraftTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
abstract class BaseDraftTestCase extends BaseTestCase
{
/** @var string */
protected $relativeTestsRoot = '/../../vendor/json-schema/JSON-Schema-Test-Suite/tests';
protected $relativeTestsRoot = '/../../vendor/json-schema/json-schema-test-suite/tests';

private function setUpTests($isValid)
{
Expand Down
7 changes: 3 additions & 4 deletions tests/Entity/JsonPointerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,9 @@ public function testJsonPointerWithPropertyPaths()

public function testCreateWithInvalidValue()
{
$this->setExpectedException(
'\JsonSchema\Exception\InvalidArgumentException',
'Ref value must be a string'
);
$this->expectException('\JsonSchema\Exception\InvalidArgumentException');
$this->expectExceptionMessage('Ref value must be a string');

new JsonPointer(null);
}
}
2 changes: 1 addition & 1 deletion tests/Iterators/ObjectIteratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ObjectIteratorTest extends TestCase
{
protected $testObject;

public function setUp()
public function setUp(): void
{
$this->testObject = (object) array(
'subOne' => (object) array(
Expand Down
2 changes: 1 addition & 1 deletion tests/RefTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function testRefIgnoresSiblings($schema, $document, $isValid, $exception

$v = new Validator();
if ($exception) {
$this->setExpectedException($exception);
$this->expectException($exception);
}

$v->validate($document, $schema);
Expand Down
Loading