diff --git a/CHANGELOG.md b/CHANGELOG.md index b16abb0c..9a3dbaca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added +- Add return types in the test suite ([#748](https://github.com/jsonrainbow/json-schema/pull/748)) + ### Fixed - Correct misconfigured mocks in JsonSchema\Tests\Uri\UriRetrieverTest ([#741](https://github.com/jsonrainbow/json-schema/pull/741)) - Fix pugx badges in README ([#742](https://github.com/jsonrainbow/json-schema/pull/742)) diff --git a/tests/ConstraintErrorTest.php b/tests/ConstraintErrorTest.php index 487f7d2a..158f3074 100644 --- a/tests/ConstraintErrorTest.php +++ b/tests/ConstraintErrorTest.php @@ -14,13 +14,13 @@ class ConstraintErrorTest extends TestCase { - public function testGetValidMessage() + public function testGetValidMessage(): void { $e = ConstraintError::ALL_OF(); $this->assertEquals('Failed to match all schemas', $e->getMessage()); } - public function testGetInvalidMessage() + public function testGetInvalidMessage(): void { $e = ConstraintError::MISSING_ERROR(); diff --git a/tests/Constraints/AdditionalPropertiesTest.php b/tests/Constraints/AdditionalPropertiesTest.php index d5db24fb..82b31971 100644 --- a/tests/Constraints/AdditionalPropertiesTest.php +++ b/tests/Constraints/AdditionalPropertiesTest.php @@ -15,7 +15,7 @@ class AdditionalPropertiesTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -114,7 +114,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/ArraysTest.php b/tests/Constraints/ArraysTest.php index 1d4d08bd..4b2eb576 100644 --- a/tests/Constraints/ArraysTest.php +++ b/tests/Constraints/ArraysTest.php @@ -13,7 +13,7 @@ class ArraysTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -120,7 +120,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/BaseTestCase.php b/tests/Constraints/BaseTestCase.php index 21972c58..ba55b461 100644 --- a/tests/Constraints/BaseTestCase.php +++ b/tests/Constraints/BaseTestCase.php @@ -26,7 +26,7 @@ abstract class BaseTestCase extends VeryBaseTestCase /** * @dataProvider getInvalidTests */ - public function testInvalidCases($input, $schema, $checkMode = Constraint::CHECK_MODE_NORMAL, $errors = []) + public function testInvalidCases($input, $schema, $checkMode = Constraint::CHECK_MODE_NORMAL, $errors = []): void { $checkMode = $checkMode === null ? Constraint::CHECK_MODE_NORMAL : $checkMode; if ($this->validateSchema) { @@ -55,7 +55,7 @@ public function testInvalidCases($input, $schema, $checkMode = Constraint::CHECK /** * @dataProvider getInvalidForAssocTests */ - public function testInvalidCasesUsingAssoc($input, $schema, $checkMode = Constraint::CHECK_MODE_TYPE_CAST, $errors = []) + public function testInvalidCasesUsingAssoc($input, $schema, $checkMode = Constraint::CHECK_MODE_TYPE_CAST, $errors = []): void { $checkMode = $checkMode === null ? Constraint::CHECK_MODE_TYPE_CAST : $checkMode; if ($this->validateSchema) { @@ -87,7 +87,7 @@ public function testInvalidCasesUsingAssoc($input, $schema, $checkMode = Constra /** * @dataProvider getValidTests */ - public function testValidCases($input, $schema, $checkMode = Constraint::CHECK_MODE_NORMAL) + public function testValidCases($input, $schema, $checkMode = Constraint::CHECK_MODE_NORMAL): void { if ($this->validateSchema) { $checkMode |= Constraint::CHECK_MODE_VALIDATE_SCHEMA; @@ -109,7 +109,7 @@ public function testValidCases($input, $schema, $checkMode = Constraint::CHECK_M /** * @dataProvider getValidForAssocTests */ - public function testValidCasesUsingAssoc($input, $schema, $checkMode = Constraint::CHECK_MODE_TYPE_CAST) + public function testValidCasesUsingAssoc($input, $schema, $checkMode = Constraint::CHECK_MODE_TYPE_CAST): void { if ($this->validateSchema) { $checkMode |= Constraint::CHECK_MODE_VALIDATE_SCHEMA; @@ -133,28 +133,16 @@ public function testValidCasesUsingAssoc($input, $schema, $checkMode = Constrain $this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true)); } - /** - * @return array[] - */ - abstract public function getValidTests(); + abstract public function getValidTests(): array; - /** - * @return array[] - */ - public function getValidForAssocTests() + public function getValidForAssocTests(): array { return $this->getValidTests(); } - /** - * @return array[] - */ - abstract public function getInvalidTests(); + abstract public function getInvalidTests(): array; - /** - * @return array[] - */ - public function getInvalidForAssocTests() + public function getInvalidForAssocTests(): array { return $this->getInvalidTests(); } diff --git a/tests/Constraints/BasicTypesTest.php b/tests/Constraints/BasicTypesTest.php index c238dba3..01e1f7ba 100644 --- a/tests/Constraints/BasicTypesTest.php +++ b/tests/Constraints/BasicTypesTest.php @@ -14,7 +14,7 @@ class BasicTypesTest extends BaseTestCase protected $schemaSpec = 'http://json-schema.org/draft-03/schema#'; protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -104,7 +104,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/CoerciveTest.php b/tests/Constraints/CoerciveTest.php index 1f8670cf..3c028ba0 100644 --- a/tests/Constraints/CoerciveTest.php +++ b/tests/Constraints/CoerciveTest.php @@ -24,7 +24,7 @@ public function setUp(): void $this->factory->setConfig(Constraint::CHECK_MODE_TYPE_CAST | Constraint::CHECK_MODE_COERCE_TYPES); } - public function dataCoerceCases() + public function dataCoerceCases(): array { // check type conversions $types = [ @@ -190,7 +190,7 @@ public function dataCoerceCases() } /** @dataProvider dataCoerceCases **/ - public function testCoerceCases($schema, $data, $startType, $endType, $endValue, $valid, $extraFlags = 0, $assoc = false) + public function testCoerceCases($schema, $data, $startType, $endType, $endValue, $valid, $extraFlags = 0, $assoc = false): void { $validator = new Validator($this->factory); @@ -232,12 +232,12 @@ public function testCoerceCases($schema, $data, $startType, $endType, $endValue, } /** @dataProvider dataCoerceCases **/ - public function testCoerceCasesUsingAssoc($schema, $data, $startType, $endType, $endValue, $valid, $early = false) + public function testCoerceCasesUsingAssoc($schema, $data, $startType, $endType, $endValue, $valid, $early = false): void { $this->testCoerceCases($schema, $data, $startType, $endType, $endValue, $valid, $early, true); } - public function testCoerceAPI() + public function testCoerceAPI(): void { $input = json_decode('{"propertyOne": "10"}'); $schema = json_decode('{"properties":{"propertyOne":{"type":"number"}}}'); diff --git a/tests/Constraints/ConstTest.php b/tests/Constraints/ConstTest.php index bcd8b966..6b4cfc1f 100644 --- a/tests/Constraints/ConstTest.php +++ b/tests/Constraints/ConstTest.php @@ -14,7 +14,7 @@ class ConstTest extends BaseTestCase protected $schemaSpec = 'http://json-schema.org/draft-06/schema#'; protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -68,7 +68,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/DefaultPropertiesTest.php b/tests/Constraints/DefaultPropertiesTest.php index 95dde8e9..28498352 100644 --- a/tests/Constraints/DefaultPropertiesTest.php +++ b/tests/Constraints/DefaultPropertiesTest.php @@ -16,7 +16,7 @@ class DefaultPropertiesTest extends VeryBaseTestCase { - public function getValidTests() + public function getValidTests(): array { return [ /* @@ -170,7 +170,7 @@ public function getValidTests() /** * @dataProvider getValidTests */ - public function testValidCases($input, $schema, $expectOutput = null, $checkMode = 0) + public function testValidCases($input, $schema, $expectOutput = null, $checkMode = 0): void { if (is_string($input)) { $inputDecoded = json_decode($input); @@ -197,7 +197,7 @@ public function testValidCases($input, $schema, $expectOutput = null, $checkMode /** * @dataProvider getValidTests */ - public function testValidCasesUsingAssoc($input, $schema, $expectOutput = null, $checkMode = 0) + public function testValidCasesUsingAssoc($input, $schema, $expectOutput = null, $checkMode = 0): void { $input = json_decode($input, true); @@ -208,14 +208,14 @@ public function testValidCasesUsingAssoc($input, $schema, $expectOutput = null, /** * @dataProvider getValidTests */ - public function testValidCasesUsingAssocWithoutTypeCast($input, $schema, $expectOutput = null, $checkMode = 0) + public function testValidCasesUsingAssocWithoutTypeCast($input, $schema, $expectOutput = null, $checkMode = 0): void { $input = json_decode($input, true); self::testValidCases($input, $schema, $expectOutput, $checkMode); } - public function testNoModificationViaReferences() + public function testNoModificationViaReferences(): void { $input = json_decode('{}'); $schema = json_decode('{"properties":{"propertyOne":{"default":"valueOne"}}}'); @@ -229,7 +229,7 @@ public function testNoModificationViaReferences() $this->assertEquals('valueOne', $schema->properties->propertyOne->default); } - public function testLeaveBasicTypesAlone() + public function testLeaveBasicTypesAlone(): void { $input = json_decode('"ThisIsAString"'); $schema = json_decode('{"properties": {"propertyOne": {"default": "valueOne"}}}'); diff --git a/tests/Constraints/DependenciesTest.php b/tests/Constraints/DependenciesTest.php index 38483f88..ff3ffb8e 100644 --- a/tests/Constraints/DependenciesTest.php +++ b/tests/Constraints/DependenciesTest.php @@ -14,7 +14,7 @@ class DependenciesTest extends BaseTestCase protected $schemaSpec = 'http://json-schema.org/draft-03/schema#'; protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -80,7 +80,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/DisallowTest.php b/tests/Constraints/DisallowTest.php index 6a61dcea..1fe93f6c 100644 --- a/tests/Constraints/DisallowTest.php +++ b/tests/Constraints/DisallowTest.php @@ -19,7 +19,7 @@ class DisallowTest extends BaseTestCase protected $schemaSpec = 'http://json-schema.org/draft-03/schema#'; protected $validateSchema = false; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -107,7 +107,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/DivisibleByTest.php b/tests/Constraints/DivisibleByTest.php index e08e2b9d..354d6a29 100644 --- a/tests/Constraints/DivisibleByTest.php +++ b/tests/Constraints/DivisibleByTest.php @@ -13,7 +13,7 @@ class DivisibleByTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -55,7 +55,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/EnumTest.php b/tests/Constraints/EnumTest.php index 8b7a7d51..2ff14147 100644 --- a/tests/Constraints/EnumTest.php +++ b/tests/Constraints/EnumTest.php @@ -14,7 +14,7 @@ class EnumTest extends BaseTestCase protected $schemaSpec = 'http://json-schema.org/draft-03/schema#'; protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -94,7 +94,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/ExtendsTest.php b/tests/Constraints/ExtendsTest.php index ee53ed84..286b24b8 100644 --- a/tests/Constraints/ExtendsTest.php +++ b/tests/Constraints/ExtendsTest.php @@ -14,7 +14,7 @@ class ExtendsTest extends BaseTestCase protected $schemaSpec = 'http://json-schema.org/draft-03/schema#'; protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -93,7 +93,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/FactoryTest.php b/tests/Constraints/FactoryTest.php index 451fa94d..f29614ee 100644 --- a/tests/Constraints/FactoryTest.php +++ b/tests/Constraints/FactoryTest.php @@ -53,7 +53,7 @@ protected function setUp(): void * @param string $constraintName * @param string $expectedClass */ - public function testCreateInstanceForConstraintName($constraintName, $expectedClass) + public function testCreateInstanceForConstraintName($constraintName, $expectedClass): void { $constraint = $this->factory->createInstanceFor($constraintName); @@ -61,7 +61,7 @@ public function testCreateInstanceForConstraintName($constraintName, $expectedCl $this->assertInstanceOf('JsonSchema\Constraints\ConstraintInterface', $constraint); } - public function constraintNameProvider() + public function constraintNameProvider(): array { return [ ['array', 'JsonSchema\Constraints\CollectionConstraint'], @@ -83,34 +83,34 @@ public function constraintNameProvider() * * @param string $constraintName */ - public function testExceptionWhenCreateInstanceForInvalidConstraintName($constraintName) + public function testExceptionWhenCreateInstanceForInvalidConstraintName($constraintName): void { $this->expectException('JsonSchema\Exception\InvalidArgumentException'); $this->factory->createInstanceFor($constraintName); } - public function invalidConstraintNameProvider() + public function invalidConstraintNameProvider(): array { return [ ['invalidConstraintName'], ]; } - public function testSetConstraintClassExistsCondition() + public function testSetConstraintClassExistsCondition(): void { $this->expectException(\JsonSchema\Exception\InvalidArgumentException::class); $this->factory->setConstraintClass('string', 'SomeConstraint'); } - public function testSetConstraintClassImplementsCondition() + public function testSetConstraintClassImplementsCondition(): void { $this->expectException(\JsonSchema\Exception\InvalidArgumentException::class); $this->factory->setConstraintClass('string', 'JsonSchema\Tests\Constraints\MyBadConstraint'); } - public function testSetConstraintClassInstance() + public function testSetConstraintClassInstance(): void { $this->factory->setConstraintClass('string', 'JsonSchema\Tests\Constraints\MyStringConstraint'); $constraint = $this->factory->createInstanceFor('string'); @@ -118,7 +118,7 @@ public function testSetConstraintClassInstance() $this->assertInstanceOf('JsonSchema\Constraints\ConstraintInterface', $constraint); } - public function testCheckMode() + public function testCheckMode(): void { $f = new Factory(); diff --git a/tests/Constraints/FormatTest.php b/tests/Constraints/FormatTest.php index bb511607..2d91e5fe 100644 --- a/tests/Constraints/FormatTest.php +++ b/tests/Constraints/FormatTest.php @@ -22,7 +22,7 @@ public function setUp(): void date_default_timezone_set('UTC'); } - public function testNullThing() + public function testNullThing(): void { $validator = new FormatConstraint(); $schema = new \stdClass(); @@ -32,7 +32,7 @@ public function testNullThing() $this->assertEmpty($validator->getErrors()); } - public function testRegex() + public function testRegex(): void { $validator = new FormatConstraint(); $schema = new \stdClass(); @@ -57,7 +57,7 @@ public function testRegex() /** * @dataProvider getValidFormats */ - public function testValidFormat($string, $format) + public function testValidFormat($string, $format): void { $validator = new FormatConstraint(); $schema = new \stdClass(); @@ -70,7 +70,7 @@ public function testValidFormat($string, $format) /** * @dataProvider getInvalidFormats */ - public function testInvalidFormat($string, $format) + public function testInvalidFormat($string, $format): void { $validator = new FormatConstraint(); $schema = new \stdClass(); @@ -83,7 +83,7 @@ public function testInvalidFormat($string, $format) /** * @dataProvider getInvalidFormats */ - public function testDisabledFormat($string, $format) + public function testDisabledFormat($string, $format): void { $factory = new Factory(); $validator = new FormatConstraint($factory); @@ -95,7 +95,7 @@ public function testDisabledFormat($string, $format) $this->assertEmpty($validator->getErrors()); } - public function getValidFormats() + public function getValidFormats(): array { return [ ['2001-01-23', 'date'], @@ -167,7 +167,7 @@ public function getValidFormats() ]; } - public function getInvalidFormats() + public function getInvalidFormats(): array { return [ ['January 1st, 1910', 'date'], @@ -218,7 +218,7 @@ public function getInvalidFormats() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ @@ -236,7 +236,7 @@ public function getValidTests() ]; } - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ diff --git a/tests/Constraints/LongArraysTest.php b/tests/Constraints/LongArraysTest.php index 862b4e3b..8b8c88f0 100644 --- a/tests/Constraints/LongArraysTest.php +++ b/tests/Constraints/LongArraysTest.php @@ -17,7 +17,7 @@ class LongArraysTest extends VeryBaseTestCase { protected $validateSchema = true; - public function testLongStringArray() + public function testLongStringArray(): void { $schema = '{ @@ -45,7 +45,7 @@ public function testLongStringArray() $this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true)); } - public function testLongNumberArray() + public function testLongNumberArray(): void { $schema = '{ @@ -73,7 +73,7 @@ public function testLongNumberArray() $this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true)); } - public function testLongIntegerArray() + public function testLongIntegerArray(): void { $schema = '{ diff --git a/tests/Constraints/MinItemsMaxItemsTest.php b/tests/Constraints/MinItemsMaxItemsTest.php index 477eb609..f07bcd6f 100644 --- a/tests/Constraints/MinItemsMaxItemsTest.php +++ b/tests/Constraints/MinItemsMaxItemsTest.php @@ -13,7 +13,7 @@ class MinItemsMaxItemsTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -41,7 +41,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/MinLengthMaxLengthMultiByteTest.php b/tests/Constraints/MinLengthMaxLengthMultiByteTest.php index 2b8b6ca7..ab6db1a3 100644 --- a/tests/Constraints/MinLengthMaxLengthMultiByteTest.php +++ b/tests/Constraints/MinLengthMaxLengthMultiByteTest.php @@ -20,7 +20,7 @@ protected function setUp(): void } } - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -48,7 +48,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/MinLengthMaxLengthTest.php b/tests/Constraints/MinLengthMaxLengthTest.php index 78d27abb..4832dfd5 100644 --- a/tests/Constraints/MinLengthMaxLengthTest.php +++ b/tests/Constraints/MinLengthMaxLengthTest.php @@ -13,7 +13,7 @@ class MinLengthMaxLengthTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -41,7 +41,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/MinMaxPropertiesTest.php b/tests/Constraints/MinMaxPropertiesTest.php index 763b80e0..bf3a3182 100644 --- a/tests/Constraints/MinMaxPropertiesTest.php +++ b/tests/Constraints/MinMaxPropertiesTest.php @@ -16,7 +16,7 @@ class MinMaxPropertiesTest extends BaseTestCase /** * {@inheritdoc} */ - public function getValidTests() + public function getValidTests(): array { return [ [ @@ -69,7 +69,7 @@ public function getValidTests() /** * {@inheritdoc} */ - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ diff --git a/tests/Constraints/MinimumMaximumTest.php b/tests/Constraints/MinimumMaximumTest.php index ab02bfd0..6f66565b 100644 --- a/tests/Constraints/MinimumMaximumTest.php +++ b/tests/Constraints/MinimumMaximumTest.php @@ -13,7 +13,7 @@ class MinimumMaximumTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -110,7 +110,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/NotTest.php b/tests/Constraints/NotTest.php index 092b2e39..2b6b48e3 100644 --- a/tests/Constraints/NotTest.php +++ b/tests/Constraints/NotTest.php @@ -13,7 +13,7 @@ class NotTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -49,7 +49,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/NumberAndIntegerTypesTest.php b/tests/Constraints/NumberAndIntegerTypesTest.php index 79216a24..78b02110 100644 --- a/tests/Constraints/NumberAndIntegerTypesTest.php +++ b/tests/Constraints/NumberAndIntegerTypesTest.php @@ -13,7 +13,7 @@ class NumberAndIntegerTypesTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -57,7 +57,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/OfPropertiesTest.php b/tests/Constraints/OfPropertiesTest.php index ac31db92..b602c0b4 100644 --- a/tests/Constraints/OfPropertiesTest.php +++ b/tests/Constraints/OfPropertiesTest.php @@ -18,7 +18,7 @@ class OfPropertiesTest extends BaseTestCase { protected $validateSchema = true; - public function getValidTests() + public function getValidTests(): array { return [ [ @@ -56,7 +56,7 @@ public function getValidTests() ]; } - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -232,7 +232,7 @@ public function getInvalidTests() ]; } - public function testNoPrematureAnyOfException() + public function testNoPrematureAnyOfException(): void { $schema = json_decode('{ "type": "object", @@ -252,7 +252,7 @@ public function testNoPrematureAnyOfException() $this->assertTrue($v->isValid()); } - public function testNoPrematureOneOfException() + public function testNoPrematureOneOfException(): void { $schema = json_decode('{ "type": "object", diff --git a/tests/Constraints/PatternPropertiesTest.php b/tests/Constraints/PatternPropertiesTest.php index 0672fb01..526777ef 100644 --- a/tests/Constraints/PatternPropertiesTest.php +++ b/tests/Constraints/PatternPropertiesTest.php @@ -13,7 +13,7 @@ class PatternPropertiesTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ // matches pattern but invalid schema for object @@ -87,7 +87,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/PatternTest.php b/tests/Constraints/PatternTest.php index 3ffd2656..8207c91b 100644 --- a/tests/Constraints/PatternTest.php +++ b/tests/Constraints/PatternTest.php @@ -13,7 +13,7 @@ class PatternTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -51,7 +51,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/PointerTest.php b/tests/Constraints/PointerTest.php index 09bcb755..1623f41b 100644 --- a/tests/Constraints/PointerTest.php +++ b/tests/Constraints/PointerTest.php @@ -16,7 +16,7 @@ class PointerTest extends TestCase { protected $validateSchema = true; - public function testVariousPointers() + public function testVariousPointers(): void { $schema = [ 'type' => 'object', diff --git a/tests/Constraints/ReadOnlyTest.php b/tests/Constraints/ReadOnlyTest.php index 95b98333..3a54fa51 100644 --- a/tests/Constraints/ReadOnlyTest.php +++ b/tests/Constraints/ReadOnlyTest.php @@ -13,7 +13,7 @@ class ReadOnlyTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { //is readonly really required? return [ @@ -29,7 +29,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/RequireTest.php b/tests/Constraints/RequireTest.php index e90489d0..34ca88ca 100644 --- a/tests/Constraints/RequireTest.php +++ b/tests/Constraints/RequireTest.php @@ -13,7 +13,7 @@ class RequireTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -31,7 +31,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/RequiredPropertyTest.php b/tests/Constraints/RequiredPropertyTest.php index d798ceff..2f38c3e5 100644 --- a/tests/Constraints/RequiredPropertyTest.php +++ b/tests/Constraints/RequiredPropertyTest.php @@ -20,7 +20,7 @@ class RequiredPropertyTest extends BaseTestCase protected $schemaSpec = 'http://json-schema.org/draft-03/schema#'; protected $validateSchema = false; - public function testErrorPropertyIsPopulatedForRequiredIfMissingInInput() + public function testErrorPropertyIsPopulatedForRequiredIfMissingInInput(): void { $validator = new UndefinedConstraint(); $document = json_decode( @@ -44,7 +44,7 @@ public function testErrorPropertyIsPopulatedForRequiredIfMissingInInput() $this->assertErrorHasExpectedPropertyValue($error, 'foo'); } - public function testPathErrorPropertyIsPopulatedForRequiredIfMissingInInput() + public function testPathErrorPropertyIsPopulatedForRequiredIfMissingInInput(): void { $validator = new UndefinedConstraint(); $document = json_decode( @@ -77,7 +77,7 @@ public function testPathErrorPropertyIsPopulatedForRequiredIfMissingInInput() $this->assertErrorHasExpectedPropertyValue($error, 'foo[0].bar'); } - public function testErrorPropertyIsPopulatedForRequiredIfEmptyValueInInput() + public function testErrorPropertyIsPopulatedForRequiredIfEmptyValueInInput(): void { $validator = new UndefinedConstraint(); $document = json_decode( @@ -102,7 +102,7 @@ public function testErrorPropertyIsPopulatedForRequiredIfEmptyValueInInput() $this->assertErrorHasExpectedPropertyValue($error, 'foo'); } - protected function assertErrorHasExpectedPropertyValue($error, $propertyValue) + protected function assertErrorHasExpectedPropertyValue($error, $propertyValue): void { if (!(isset($error[0]) && is_array($error[0]) && isset($error[0]['property']))) { $this->fail( @@ -113,7 +113,7 @@ protected function assertErrorHasExpectedPropertyValue($error, $propertyValue) $this->assertEquals($propertyValue, $error[0]['property']); } - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -284,7 +284,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/SchemaValidationTest.php b/tests/Constraints/SchemaValidationTest.php index f158cfe3..65268f49 100644 --- a/tests/Constraints/SchemaValidationTest.php +++ b/tests/Constraints/SchemaValidationTest.php @@ -17,7 +17,7 @@ class SchemaValidationTest extends TestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [// invalid v4 schema (uses v3 require) @@ -44,7 +44,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [// valid v4 schema (uses v4 require) @@ -64,7 +64,7 @@ public function getValidTests() /** * @dataProvider getInvalidTests */ - public function testInvalidCases($schema) + public function testInvalidCases($schema): void { $input = json_decode('{"propertyOne":"valueOne"}'); $schema = json_decode($schema); @@ -85,7 +85,7 @@ public function testInvalidCases($schema) /** * @dataProvider getValidTests */ - public function testValidCases($schema) + public function testValidCases($schema): void { $input = json_decode('{"propertyOne":"valueOne"}'); $schema = json_decode($schema); @@ -100,7 +100,7 @@ public function testValidCases($schema) $this->assertTrue($v->isValid(), 'Validation failed on a valid test case'); } - public function testNonObjectSchema() + public function testNonObjectSchema(): void { $this->expectException('\JsonSchema\Exception\RuntimeException'); $this->expectExceptionMessage('Cannot validate the schema of a non-object'); @@ -108,7 +108,7 @@ public function testNonObjectSchema() $this->testValidCases('"notAnObject"'); } - public function testInvalidSchemaException() + public function testInvalidSchemaException(): void { $this->expectException('\JsonSchema\Exception\InvalidSchemaException'); $this->expectExceptionMessage('Schema did not pass validation'); diff --git a/tests/Constraints/SelfDefinedSchemaTest.php b/tests/Constraints/SelfDefinedSchemaTest.php index 2fcd4906..4ac1b8a7 100644 --- a/tests/Constraints/SelfDefinedSchemaTest.php +++ b/tests/Constraints/SelfDefinedSchemaTest.php @@ -15,7 +15,7 @@ class SelfDefinedSchemaTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -41,7 +41,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ @@ -67,7 +67,7 @@ public function getValidTests() ]; } - public function testInvalidArgumentException() + public function testInvalidArgumentException(): void { $value = json_decode('{}'); $schema = json_decode(''); diff --git a/tests/Constraints/TupleTypingTest.php b/tests/Constraints/TupleTypingTest.php index 52feceb2..f565ae00 100644 --- a/tests/Constraints/TupleTypingTest.php +++ b/tests/Constraints/TupleTypingTest.php @@ -13,7 +13,7 @@ class TupleTypingTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -85,7 +85,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/TypeTest.php b/tests/Constraints/TypeTest.php index 4b30dacb..1590d473 100644 --- a/tests/Constraints/TypeTest.php +++ b/tests/Constraints/TypeTest.php @@ -24,10 +24,8 @@ class TypeTest extends TestCase { /** * @see testIndefiniteArticleForTypeInTypeCheckErrorMessage - * - * @return array */ - public function provideIndefiniteArticlesForTypes() + public function provideIndefiniteArticlesForTypes(): array { return [ ['integer', 'an integer'], @@ -46,7 +44,7 @@ public function provideIndefiniteArticlesForTypes() /** * @dataProvider provideIndefiniteArticlesForTypes */ - public function testIndefiniteArticleForTypeInTypeCheckErrorMessage($type, $wording, $value = null, $label = 'NULL') + public function testIndefiniteArticleForTypeInTypeCheckErrorMessage($type, $wording, $value = null, $label = 'NULL'): void { $constraint = new TypeConstraint(); $constraint->check($value, (object) ['type' => $type]); @@ -56,7 +54,7 @@ public function testIndefiniteArticleForTypeInTypeCheckErrorMessage($type, $word /** * Test uncovered areas of the loose type checker */ - public function testLooseTypeChecking() + public function testLooseTypeChecking(): void { $v = new \stdClass(); $v->property = 'dataOne'; @@ -72,7 +70,7 @@ public function testLooseTypeChecking() * @param string $expected * @param TypeConstraint $actual */ - private function assertTypeConstraintError($expected, TypeConstraint $actual) + private function assertTypeConstraintError($expected, TypeConstraint $actual): void { $actualErrors = $actual->getErrors(); @@ -94,7 +92,7 @@ private function assertTypeConstraintError($expected, TypeConstraint $actual) $this->assertSame($expected, $actualMessage); // the same for the strictness } - public function validNameWordingDataProvider() + public function validNameWordingDataProvider(): array { $wordings = []; @@ -108,7 +106,7 @@ public function validNameWordingDataProvider() /** * @dataProvider validNameWordingDataProvider */ - public function testValidateTypeNameWording($nameWording) + public function testValidateTypeNameWording($nameWording): void { $t = new TypeConstraint(); $r = new \ReflectionObject($t); @@ -119,7 +117,7 @@ public function testValidateTypeNameWording($nameWording) $this->expectNotToPerformAssertions(); } - public function testInvalidateTypeNameWording() + public function testInvalidateTypeNameWording(): void { $t = new TypeConstraint(); $r = new \ReflectionObject($t); @@ -132,7 +130,7 @@ public function testInvalidateTypeNameWording() $m->invoke($t, 'notAValidTypeName'); } - public function testValidateTypeException() + public function testValidateTypeException(): void { $t = new TypeConstraint(); $data = new \stdClass(); diff --git a/tests/Constraints/UnionTypesTest.php b/tests/Constraints/UnionTypesTest.php index 9757b3c2..387848df 100644 --- a/tests/Constraints/UnionTypesTest.php +++ b/tests/Constraints/UnionTypesTest.php @@ -13,7 +13,7 @@ class UnionTypesTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -32,7 +32,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/UnionWithNullValueTest.php b/tests/Constraints/UnionWithNullValueTest.php index ad5ea31e..16d2d8b2 100644 --- a/tests/Constraints/UnionWithNullValueTest.php +++ b/tests/Constraints/UnionWithNullValueTest.php @@ -13,7 +13,7 @@ class UnionWithNullValueTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -32,7 +32,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/UniqueItemsTest.php b/tests/Constraints/UniqueItemsTest.php index 91843f45..7a2444ca 100644 --- a/tests/Constraints/UniqueItemsTest.php +++ b/tests/Constraints/UniqueItemsTest.php @@ -13,7 +13,7 @@ class UniqueItemsTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -61,7 +61,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Constraints/ValidationExceptionTest.php b/tests/Constraints/ValidationExceptionTest.php index 317fc13f..ac6d973d 100644 --- a/tests/Constraints/ValidationExceptionTest.php +++ b/tests/Constraints/ValidationExceptionTest.php @@ -16,7 +16,7 @@ class ValidationExceptionTest extends TestCase { - public function testValidationException() + public function testValidationException(): void { $exception = new ValidationException(); $this->assertInstanceOf('\JsonSchema\Exception\ValidationException', $exception); diff --git a/tests/Constraints/VeryBaseTestCase.php b/tests/Constraints/VeryBaseTestCase.php index f12cba88..a19749a4 100644 --- a/tests/Constraints/VeryBaseTestCase.php +++ b/tests/Constraints/VeryBaseTestCase.php @@ -25,10 +25,8 @@ abstract class VeryBaseTestCase extends TestCase /** * @param object $schema - * - * @return object */ - protected function getUriRetrieverMock($schema) + protected function getUriRetrieverMock($schema): object { $relativeTestsRoot = realpath(__DIR__ . '/../../vendor/json-schema/json-schema-test-suite/remotes'); @@ -60,10 +58,7 @@ protected function getUriRetrieverMock($schema) return $uriRetriever->reveal(); } - /** - * @return object - */ - private function getJsonSchemaDraft03() + private function getJsonSchemaDraft03(): object { if (!$this->jsonSchemaDraft03) { $this->jsonSchemaDraft03 = json_decode( @@ -74,10 +69,7 @@ private function getJsonSchemaDraft03() return $this->jsonSchemaDraft03; } - /** - * @return object - */ - private function getJsonSchemaDraft04() + private function getJsonSchemaDraft04(): object { if (!$this->jsonSchemaDraft04) { $this->jsonSchemaDraft04 = json_decode( diff --git a/tests/Constraints/WrongMessagesFailingTestCaseTest.php b/tests/Constraints/WrongMessagesFailingTestCaseTest.php index aae9b552..e36f57ce 100644 --- a/tests/Constraints/WrongMessagesFailingTestCaseTest.php +++ b/tests/Constraints/WrongMessagesFailingTestCaseTest.php @@ -13,7 +13,7 @@ class WrongMessagesFailingTestCaseTest extends BaseTestCase { protected $validateSchema = true; - public function getInvalidTests() + public function getInvalidTests(): array { return [ [ @@ -32,7 +32,7 @@ public function getInvalidTests() ]; } - public function getValidTests() + public function getValidTests(): array { return [ [ diff --git a/tests/Drafts/BaseDraftTestCase.php b/tests/Drafts/BaseDraftTestCase.php index cd2d4c86..42cfd988 100644 --- a/tests/Drafts/BaseDraftTestCase.php +++ b/tests/Drafts/BaseDraftTestCase.php @@ -12,7 +12,7 @@ abstract class BaseDraftTestCase extends BaseTestCase /** @var string */ protected $relativeTestsRoot = '/../../vendor/json-schema/json-schema-test-suite/tests'; - private function setUpTests($isValid) + private function setUpTests($isValid): array { $filePaths = $this->getFilePaths(); $skippedTests = $this->getSkippedTests(); @@ -46,7 +46,7 @@ private function setUpTests($isValid) /** * {@inheritdoc} */ - public function getInvalidTests() + public function getInvalidTests(): array { return $this->setUpTests(false); } @@ -54,7 +54,7 @@ public function getInvalidTests() /** * {@inheritdoc} */ - public function getValidTests() + public function getValidTests(): array { return $this->setUpTests(true); } @@ -62,12 +62,12 @@ public function getValidTests() /** * @return string[] */ - abstract protected function getFilePaths(); + abstract protected function getFilePaths(): array; /** * @return string[] */ - abstract protected function getSkippedTests(); + abstract protected function getSkippedTests(): array; /** * Generates a readable path to Json Schema Test Suite data set under test @@ -75,10 +75,8 @@ abstract protected function getSkippedTests(); * @param string $filename * @param string $suiteDesc * @param string $testCaseDesc - * - * @return string */ - private function createDataSetPath($filename, $suiteDesc, $testCaseDesc) + private function createDataSetPath($filename, $suiteDesc, $testCaseDesc): string { $separator = ' / '; diff --git a/tests/Drafts/Draft3Test.php b/tests/Drafts/Draft3Test.php index f6cf41ad..42982062 100644 --- a/tests/Drafts/Draft3Test.php +++ b/tests/Drafts/Draft3Test.php @@ -20,7 +20,7 @@ class Draft3Test extends BaseDraftTestCase /** * {@inheritdoc} */ - protected function getFilePaths() + protected function getFilePaths(): array { return [ realpath(__DIR__ . $this->relativeTestsRoot . '/draft3'), @@ -28,7 +28,7 @@ protected function getFilePaths() ]; } - public function getInvalidForAssocTests() + public function getInvalidForAssocTests(): array { $tests = parent::getInvalidForAssocTests(); unset( @@ -39,7 +39,7 @@ public function getInvalidForAssocTests() return $tests; } - public function getValidForAssocTests() + public function getValidForAssocTests(): array { $tests = parent::getValidForAssocTests(); unset( @@ -53,7 +53,7 @@ public function getValidForAssocTests() /** * {@inheritdoc} */ - protected function getSkippedTests() + protected function getSkippedTests(): array { return [ // Optional diff --git a/tests/Drafts/Draft4Test.php b/tests/Drafts/Draft4Test.php index e129ad80..e2b8a602 100644 --- a/tests/Drafts/Draft4Test.php +++ b/tests/Drafts/Draft4Test.php @@ -20,7 +20,7 @@ class Draft4Test extends BaseDraftTestCase /** * {@inheritdoc} */ - protected function getFilePaths() + protected function getFilePaths(): array { return [ realpath(__DIR__ . $this->relativeTestsRoot . '/draft4'), @@ -28,7 +28,7 @@ protected function getFilePaths() ]; } - public function getInvalidForAssocTests() + public function getInvalidForAssocTests(): array { $tests = parent::getInvalidForAssocTests(); unset( @@ -39,7 +39,7 @@ public function getInvalidForAssocTests() return $tests; } - public function getValidForAssocTests() + public function getValidForAssocTests(): array { $tests = parent::getValidForAssocTests(); unset( @@ -53,7 +53,7 @@ public function getValidForAssocTests() /** * {@inheritdoc} */ - protected function getSkippedTests() + protected function getSkippedTests(): array { return [ // Optional diff --git a/tests/Entity/JsonPointerTest.php b/tests/Entity/JsonPointerTest.php index 48203824..f8477b5d 100644 --- a/tests/Entity/JsonPointerTest.php +++ b/tests/Entity/JsonPointerTest.php @@ -34,7 +34,7 @@ public function testJsonPointer( $expectedPropertyPaths, $expectedPropertyPathAsString, $expectedToString - ) { + ): void { $jsonPointer = new JsonPointer($testValue); $this->assertEquals($expectedFileName, $jsonPointer->getFilename()); $this->assertEquals($expectedPropertyPaths, $jsonPointer->getPropertyPaths()); @@ -42,10 +42,7 @@ public function testJsonPointer( $this->assertEquals($expectedToString, (string) $jsonPointer); } - /** - * @return array[] - */ - public function getTestData() + public function getTestData(): array { return [ 'testDataSet_01' => [ @@ -93,7 +90,7 @@ public function getTestData() ]; } - public function testJsonPointerWithPropertyPaths() + public function testJsonPointerWithPropertyPaths(): void { $initial = new JsonPointer('#/definitions/date'); @@ -111,7 +108,7 @@ public function testJsonPointerWithPropertyPaths() $this->assertEquals('#/~0definitions~1general/%25custom%25', $modified->getPropertyPathAsString()); } - public function testCreateWithInvalidValue() + public function testCreateWithInvalidValue(): void { $this->expectException('\JsonSchema\Exception\InvalidArgumentException'); $this->expectExceptionMessage('Ref value must be a string'); diff --git a/tests/Exception/InvalidArgumentExceptionTest.php b/tests/Exception/InvalidArgumentExceptionTest.php index 5715fbac..01243760 100644 --- a/tests/Exception/InvalidArgumentExceptionTest.php +++ b/tests/Exception/InvalidArgumentExceptionTest.php @@ -7,7 +7,7 @@ class InvalidArgumentExceptionTest extends TestCase { - public function testHierarchy() + public function testHierarchy(): void { $exception = new InvalidArgumentException(); self::assertInstanceOf('\InvalidArgumentException', $exception); diff --git a/tests/Exception/InvalidSchemaMediaTypeExceptionTest.php b/tests/Exception/InvalidSchemaMediaTypeExceptionTest.php index 6b12adc6..c3930db9 100644 --- a/tests/Exception/InvalidSchemaMediaTypeExceptionTest.php +++ b/tests/Exception/InvalidSchemaMediaTypeExceptionTest.php @@ -7,7 +7,7 @@ class InvalidSchemaMediaTypeExceptionTest extends TestCase { - public function testHierarchy() + public function testHierarchy(): void { $exception = new InvalidSchemaMediaTypeException(); self::assertInstanceOf('\RuntimeException', $exception); diff --git a/tests/Exception/InvalidSourceUriExceptionTest.php b/tests/Exception/InvalidSourceUriExceptionTest.php index 7cccf817..c7fd48bc 100644 --- a/tests/Exception/InvalidSourceUriExceptionTest.php +++ b/tests/Exception/InvalidSourceUriExceptionTest.php @@ -7,7 +7,7 @@ class InvalidSourceUriExceptionTest extends TestCase { - public function testHierarchy() + public function testHierarchy(): void { $exception = new InvalidSourceUriException(); self::assertInstanceOf('\InvalidArgumentException', $exception); diff --git a/tests/Exception/JsonDecodingExceptionTest.php b/tests/Exception/JsonDecodingExceptionTest.php index 667c6520..468165e4 100644 --- a/tests/Exception/JsonDecodingExceptionTest.php +++ b/tests/Exception/JsonDecodingExceptionTest.php @@ -7,7 +7,7 @@ class JsonDecodingExceptionTest extends TestCase { - public function testHierarchy() + public function testHierarchy(): void { $exception = new JsonDecodingException(); self::assertInstanceOf('\RuntimeException', $exception); diff --git a/tests/Exception/ResourceNotFoundExceptionTest.php b/tests/Exception/ResourceNotFoundExceptionTest.php index 2cde0eec..fe87575c 100644 --- a/tests/Exception/ResourceNotFoundExceptionTest.php +++ b/tests/Exception/ResourceNotFoundExceptionTest.php @@ -7,7 +7,7 @@ class ResourceNotFoundExceptionTest extends TestCase { - public function testHierarchy() + public function testHierarchy(): void { $exception = new ResourceNotFoundException(); self::assertInstanceOf('\RuntimeException', $exception); diff --git a/tests/Exception/RuntimeExceptionTest.php b/tests/Exception/RuntimeExceptionTest.php index 4db22eaa..cf34439b 100644 --- a/tests/Exception/RuntimeExceptionTest.php +++ b/tests/Exception/RuntimeExceptionTest.php @@ -7,7 +7,7 @@ class RuntimeExceptionTest extends TestCase { - public function testHierarchy() + public function testHierarchy(): void { $exception = new RuntimeException(); self::assertInstanceOf('\RuntimeException', $exception); diff --git a/tests/Exception/UnresolvableJsonPointerExceptionTest.php b/tests/Exception/UnresolvableJsonPointerExceptionTest.php index f061d9da..5255c5c5 100644 --- a/tests/Exception/UnresolvableJsonPointerExceptionTest.php +++ b/tests/Exception/UnresolvableJsonPointerExceptionTest.php @@ -7,7 +7,7 @@ class UnresolvableJsonPointerExceptionTest extends TestCase { - public function testHierarchy() + public function testHierarchy(): void { $exception = new UnresolvableJsonPointerException(); self::assertInstanceOf('\InvalidArgumentException', $exception); diff --git a/tests/Exception/UriResolverExceptionTest.php b/tests/Exception/UriResolverExceptionTest.php index eb9af83f..630f30a2 100644 --- a/tests/Exception/UriResolverExceptionTest.php +++ b/tests/Exception/UriResolverExceptionTest.php @@ -7,7 +7,7 @@ class UriResolverExceptionTest extends TestCase { - public function testHierarchy() + public function testHierarchy(): void { $exception = new UriResolverException(); self::assertInstanceOf('\RuntimeException', $exception); diff --git a/tests/Iterators/ObjectIteratorTest.php b/tests/Iterators/ObjectIteratorTest.php index 80b711f3..258a0156 100644 --- a/tests/Iterators/ObjectIteratorTest.php +++ b/tests/Iterators/ObjectIteratorTest.php @@ -35,28 +35,28 @@ public function setUp(): void ]; } - public function testCreate() + public function testCreate(): void { $i = new ObjectIterator($this->testObject); $this->assertInstanceOf('\JsonSchema\Iterator\ObjectIterator', $i); } - public function testInitialState() + public function testInitialState(): void { $i = new ObjectIterator($this->testObject); $this->assertEquals($this->testObject, $i->current()); } - public function testCount() + public function testCount(): void { $i = new ObjectIterator($this->testObject); $this->assertEquals(4, $i->count()); } - public function testKey() + public function testKey(): void { $i = new ObjectIterator($this->testObject); @@ -67,7 +67,7 @@ public function testKey() $this->assertEquals($this->testObject->subTwo->subThree, $i->current()); } - public function testAlwaysObjects() + public function testAlwaysObjects(): void { $i= new ObjectIterator($this->testObject); @@ -76,7 +76,7 @@ public function testAlwaysObjects() } } - public function testReachesAllProperties() + public function testReachesAllProperties(): void { $i = new ObjectIterator($this->testObject); diff --git a/tests/RefTest.php b/tests/RefTest.php index 94f9cf91..3b66d586 100644 --- a/tests/RefTest.php +++ b/tests/RefTest.php @@ -14,7 +14,7 @@ class RefTest extends TestCase { - public function dataRefIgnoresSiblings() + public function dataRefIgnoresSiblings(): array { return [ // #0 check that $ref is resolved and the instance is validated against @@ -62,7 +62,7 @@ public function dataRefIgnoresSiblings() } /** @dataProvider dataRefIgnoresSiblings */ - public function testRefIgnoresSiblings($schema, $document, $isValid, $exception = null) + public function testRefIgnoresSiblings($schema, $document, $isValid, $exception = null): void { $document = json_decode($document); $schema = json_decode($schema); diff --git a/tests/Rfc3339Test.php b/tests/Rfc3339Test.php index 890aa57e..73c1d597 100644 --- a/tests/Rfc3339Test.php +++ b/tests/Rfc3339Test.php @@ -12,7 +12,7 @@ class Rfc3339Test extends TestCase * @param \DateTime|null $expected * @dataProvider provideValidFormats */ - public function testCreateFromValidString($string, \DateTime $expected) + public function testCreateFromValidString($string, \DateTime $expected): void { $actual = Rfc3339::createFromString($string); @@ -24,12 +24,12 @@ public function testCreateFromValidString($string, \DateTime $expected) * @param string $string * @dataProvider provideInvalidFormats */ - public function testCreateFromInvalidString($string) + public function testCreateFromInvalidString($string): void { $this->assertNull(Rfc3339::createFromString($string), sprintf('String "%s" should not be converted to DateTime', $string)); } - public function provideValidFormats() + public function provideValidFormats(): array { return [ [ @@ -63,7 +63,7 @@ public function provideValidFormats() ]; } - public function provideInvalidFormats() + public function provideInvalidFormats(): array { return [ ['1999-1-11T00:00:00Z'], diff --git a/tests/SchemaStorageTest.php b/tests/SchemaStorageTest.php index 8dd7e582..812fe804 100644 --- a/tests/SchemaStorageTest.php +++ b/tests/SchemaStorageTest.php @@ -16,7 +16,7 @@ class SchemaStorageTest extends TestCase { - public function testResolveRef() + public function testResolveRef(): void { $mainSchema = $this->getMainSchema(); $mainSchemaPath = 'http://www.example.com/schema.json'; @@ -32,7 +32,7 @@ public function testResolveRef() ); } - public function testResolveTopRef() + public function testResolveTopRef(): void { $input = json_decode('{"propertyOne":"notANumber"}'); $schema = json_decode('{"$ref":"#/definition","definition":{"properties":{"propertyOne":{"type":"number"}}}}'); @@ -44,7 +44,7 @@ public function testResolveTopRef() /** * @depends testResolveRef */ - public function testSchemaWithLocalAndExternalReferencesWithCircularReference() + public function testSchemaWithLocalAndExternalReferencesWithCircularReference(): void { $mainSchema = $this->getMainSchema(); $schema2 = $this->getSchema2(); @@ -100,7 +100,7 @@ public function testSchemaWithLocalAndExternalReferencesWithCircularReference() ); } - public function testUnresolvableJsonPointExceptionShouldBeThrown() + public function testUnresolvableJsonPointExceptionShouldBeThrown(): void { $this->expectException('JsonSchema\Exception\UnresolvableJsonPointerException'); $this->expectExceptionMessage('File: http://www.example.com/schema.json is found, but could not resolve fragment: #/definitions/car'); @@ -117,7 +117,7 @@ public function testUnresolvableJsonPointExceptionShouldBeThrown() $schemaStorage->resolveRef("$mainSchemaPath#/definitions/car"); } - public function testResolveRefWithNoAssociatedFileName() + public function testResolveRefWithNoAssociatedFileName(): void { $this->expectException('JsonSchema\Exception\UnresolvableJsonPointerException'); $this->expectExceptionMessage("Could not resolve fragment '#': no file is defined"); @@ -126,10 +126,7 @@ public function testResolveRefWithNoAssociatedFileName() $schemaStorage->resolveRef('#'); } - /** - * @return object - */ - private function getMainSchema() + private function getMainSchema(): object { return (object) [ 'version' => 'v1', @@ -188,10 +185,7 @@ private function getMainSchema() ]; } - /** - * @return object - */ - private function getSchema2() + private function getSchema2(): object { return (object) [ 'version' => 'v1', @@ -218,10 +212,7 @@ private function getSchema2() ]; } - /** - * @return object - */ - private function getSchema3() + private function getSchema3(): object { return (object) [ 'version' => 'v1', @@ -243,10 +234,7 @@ private function getSchema3() ]; } - /** - * @return object - */ - private function getInvalidSchema() + private function getInvalidSchema(): object { return (object) [ 'version' => 'v1', @@ -272,21 +260,21 @@ private function getInvalidSchema() ]; } - public function testGetUriRetriever() + public function testGetUriRetriever(): void { $s = new SchemaStorage(); $s->addSchema('http://json-schema.org/draft-04/schema#'); $this->assertInstanceOf('\JsonSchema\Uri\UriRetriever', $s->getUriRetriever()); } - public function testGetUriResolver() + public function testGetUriResolver(): void { $s = new SchemaStorage(); $s->addSchema('http://json-schema.org/draft-04/schema#'); $this->assertInstanceOf('\JsonSchema\Uri\UriResolver', $s->getUriResolver()); } - public function testMetaSchemaFixes() + public function testMetaSchemaFixes(): void { $s = new SchemaStorage(); $s->addSchema('http://json-schema.org/draft-03/schema#'); @@ -299,7 +287,7 @@ public function testMetaSchemaFixes() $this->assertEquals('uri-reference', $draft_04->properties->id->format); } - public function testNoDoubleResolve() + public function testNoDoubleResolve(): void { $schemaOne = json_decode('{"id": "test/schema", "$ref": "../test2/schema2"}'); diff --git a/tests/Uri/Retrievers/CurlTest.php b/tests/Uri/Retrievers/CurlTest.php index bac8c32e..5715773d 100644 --- a/tests/Uri/Retrievers/CurlTest.php +++ b/tests/Uri/Retrievers/CurlTest.php @@ -7,7 +7,7 @@ class CurlTest extends TestCase { - public function testRetrieveFile() + public function testRetrieveFile(): void { $c = new Curl(); $result = $c->retrieve(realpath(__DIR__ . '/../../fixtures/foobar.json')); @@ -15,7 +15,7 @@ public function testRetrieveFile() self::assertStringEqualsFileCanonicalizing(realpath(__DIR__ . '/../../fixtures/foobar.json'), $result); } - public function testRetrieveNonexistantFile() + public function testRetrieveNonexistantFile(): void { $c = new Curl(); @@ -25,7 +25,7 @@ public function testRetrieveNonexistantFile() $c->retrieve(__DIR__ . '/notARealFile'); } - public function testNoContentType() + public function testNoContentType(): void { $c = new Curl(); $result = $c->retrieve(realpath(__DIR__ . '/../../fixtures') . '/foobar-noheader.json'); diff --git a/tests/Uri/Retrievers/FileGetContentsTest.php b/tests/Uri/Retrievers/FileGetContentsTest.php index eab18b2f..57e6c90a 100644 --- a/tests/Uri/Retrievers/FileGetContentsTest.php +++ b/tests/Uri/Retrievers/FileGetContentsTest.php @@ -10,7 +10,7 @@ */ class FileGetContentsTest extends TestCase { - public function testFetchMissingFile() + public function testFetchMissingFile(): void { $res = new FileGetContents(); @@ -19,14 +19,14 @@ public function testFetchMissingFile() $res->retrieve(__DIR__ . '/Fixture/missing.json'); } - public function testFetchFile() + public function testFetchFile(): void { $res = new FileGetContents(); $result = $res->retrieve(__DIR__ . '/../Fixture/child.json'); $this->assertNotEmpty($result); } - public function testContentType() + public function testContentType(): void { $res = new FileGetContents(); @@ -38,7 +38,7 @@ public function testContentType() $this->assertFalse($fetchContentType->invoke($res, ['X-Some-Header: whateverValue'])); } - public function testCanHandleHttp301PermanentRedirect() + public function testCanHandleHttp301PermanentRedirect(): void { $res = new FileGetContents(); diff --git a/tests/Uri/Retrievers/PredefinedArrayTest.php b/tests/Uri/Retrievers/PredefinedArrayTest.php index 7572a88b..c5436506 100644 --- a/tests/Uri/Retrievers/PredefinedArrayTest.php +++ b/tests/Uri/Retrievers/PredefinedArrayTest.php @@ -23,19 +23,19 @@ public function setUp(): void ); } - public function testRetrieve() + public function testRetrieve(): void { $this->assertEquals('THE_PERSON_SCHEMA', $this->retriever->retrieve('http://acme.com/schemas/person#')); $this->assertEquals('THE_ADDRESS_SCHEMA', $this->retriever->retrieve('http://acme.com/schemas/address#')); } - public function testRetrieveNonExistsingSchema() + public function testRetrieveNonExistsingSchema(): void { $this->expectException(\JsonSchema\Exception\ResourceNotFoundException::class); $this->retriever->retrieve('http://acme.com/schemas/plop#'); } - public function testGetContentType() + public function testGetContentType(): void { $this->assertEquals('THE_CONTENT_TYPE', $this->retriever->getContentType()); } diff --git a/tests/Uri/UriResolverTest.php b/tests/Uri/UriResolverTest.php index 98b48a2e..898f360f 100644 --- a/tests/Uri/UriResolverTest.php +++ b/tests/Uri/UriResolverTest.php @@ -14,7 +14,7 @@ public function setUp(): void $this->resolver = new UriResolver(); } - public function testParse() + public function testParse(): void { $this->assertEquals( [ @@ -26,7 +26,7 @@ public function testParse() ); } - public function testParseAnchor() + public function testParseAnchor(): void { $this->assertEquals( [ @@ -40,7 +40,7 @@ public function testParseAnchor() ); } - public function testCombineRelativePathWithBasePath() + public function testCombineRelativePathWithBasePath(): void { $this->assertEquals( '/foo/baz.json', @@ -51,7 +51,7 @@ public function testCombineRelativePathWithBasePath() ); } - public function testCombineRelativePathWithBasePathAbsolute() + public function testCombineRelativePathWithBasePathAbsolute(): void { $this->assertEquals( '/baz/data.json', @@ -62,7 +62,7 @@ public function testCombineRelativePathWithBasePathAbsolute() ); } - public function testCombineRelativePathWithBasePathRelativeSub() + public function testCombineRelativePathWithBasePathRelativeSub(): void { $this->assertEquals( '/foo/baz/data.json', @@ -73,7 +73,7 @@ public function testCombineRelativePathWithBasePathRelativeSub() ); } - public function testCombineRelativePathWithBasePathNoPath() + public function testCombineRelativePathWithBasePathNoPath(): void { //needed for anchor-only urls $this->assertEquals( @@ -85,7 +85,7 @@ public function testCombineRelativePathWithBasePathNoPath() ); } - public function testResolveAbsoluteUri() + public function testResolveAbsoluteUri(): void { $this->assertEquals( 'http://example.org/foo/bar.json', @@ -96,13 +96,13 @@ public function testResolveAbsoluteUri() ); } - public function testResolveRelativeUriNoBase() + public function testResolveRelativeUriNoBase(): void { $this->expectException(\JsonSchema\Exception\UriResolverException::class); $this->resolver->resolve('bar.json', null); } - public function testResolveRelativeUriBaseDir() + public function testResolveRelativeUriBaseDir(): void { $this->assertEquals( 'http://example.org/foo/bar.json', @@ -113,7 +113,7 @@ public function testResolveRelativeUriBaseDir() ); } - public function testResolveRelativeUriBaseFile() + public function testResolveRelativeUriBaseFile(): void { $this->assertEquals( 'http://example.org/foo/bar.json', @@ -124,7 +124,7 @@ public function testResolveRelativeUriBaseFile() ); } - public function testResolveAnchor() + public function testResolveAnchor(): void { $this->assertEquals( 'http://example.org/foo/bar.json#baz', @@ -135,7 +135,7 @@ public function testResolveAnchor() ); } - public function testResolveAnchorWithFile() + public function testResolveAnchorWithFile(): void { $this->assertEquals( 'http://example.org/foo/baz.json#baz', @@ -146,7 +146,7 @@ public function testResolveAnchorWithFile() ); } - public function testResolveAnchorAnchor() + public function testResolveAnchorAnchor(): void { $this->assertEquals( 'http://example.org/foo/bar.json#bazinga', @@ -157,7 +157,7 @@ public function testResolveAnchorAnchor() ); } - public function testResolveEmpty() + public function testResolveEmpty(): void { $this->assertEquals( 'http://example.org/foo/bar.json', @@ -168,7 +168,7 @@ public function testResolveEmpty() ); } - public function testReversable() + public function testReversable(): void { $uri = 'scheme://user:password@authority/path?query#fragment'; $split = $this->resolver->parse($uri); @@ -186,7 +186,7 @@ public function testReversable() $this->assertEquals($uri, $this->resolver->generate($split)); } - public function testRelativeFileAsRoot() + public function testRelativeFileAsRoot(): void { $this->assertEquals( 'file://' . getcwd() . '/src/JsonSchema/Validator.php', @@ -197,7 +197,7 @@ public function testRelativeFileAsRoot() ); } - public function testRelativeDirectoryAsRoot() + public function testRelativeDirectoryAsRoot(): void { $this->assertEquals( 'file://' . getcwd() . '/src/JsonSchema/Validator.php', @@ -208,7 +208,7 @@ public function testRelativeDirectoryAsRoot() ); } - public function testRelativeNonExistentFileAsRoot() + public function testRelativeNonExistentFileAsRoot(): void { $this->assertEquals( 'file://' . getcwd() . '/resolved.file', diff --git a/tests/Uri/UriRetrieverTest.php b/tests/Uri/UriRetrieverTest.php index 94e59bd9..81419269 100644 --- a/tests/Uri/UriRetrieverTest.php +++ b/tests/Uri/UriRetrieverTest.php @@ -50,7 +50,7 @@ private function getRetrieverMock($returnSchema) /** * @dataProvider jsonProvider */ - public function testChildExtendsParentValidTest($childSchema, $parentSchema) + public function testChildExtendsParentValidTest($childSchema, $parentSchema): void { $this->mockRetriever($parentSchema); @@ -65,7 +65,7 @@ public function testChildExtendsParentValidTest($childSchema, $parentSchema) /** * @dataProvider jsonProvider */ - public function testChildExtendsParentInvalidChildTest($childSchema, $parentSchema) + public function testChildExtendsParentInvalidChildTest($childSchema, $parentSchema): void { $this->mockRetriever($parentSchema); @@ -80,7 +80,7 @@ public function testChildExtendsParentInvalidChildTest($childSchema, $parentSche /** * @dataProvider jsonProvider */ - public function testChildExtendsParentInvalidParentTest($childSchema, $parentSchema) + public function testChildExtendsParentInvalidParentTest($childSchema, $parentSchema): void { $this->mockRetriever($parentSchema); @@ -95,7 +95,7 @@ public function testChildExtendsParentInvalidParentTest($childSchema, $parentSch /** * @dataProvider jsonProvider */ - public function testResolveRelativeUri($childSchema, $parentSchema) + public function testResolveRelativeUri($childSchema, $parentSchema): void { self::setParentSchemaExtendsValue($parentSchema, 'grandparent'); $this->mockRetriever($parentSchema); @@ -108,14 +108,14 @@ public function testResolveRelativeUri($childSchema, $parentSchema) $this->assertTrue($this->validator->isValid()); } - private static function setParentSchemaExtendsValue(&$parentSchema, $value) + private static function setParentSchemaExtendsValue(&$parentSchema, $value): void { $parentSchemaDecoded = json_decode($parentSchema, true); $parentSchemaDecoded['extends'] = $value; $parentSchema = json_encode($parentSchemaDecoded); } - public function jsonProvider() + public function jsonProvider(): array { $childSchema = << 'schema' @@ -165,7 +165,7 @@ public function testResolvePointerNoFragment() ); } - public function testResolvePointerFragment() + public function testResolvePointerFragment(): void { $schema = (object) [ 'definitions' => (object) [ @@ -185,7 +185,7 @@ public function testResolvePointerFragment() ); } - public function testResolvePointerFragmentNotFound() + public function testResolvePointerFragmentNotFound(): void { $schema = (object) [ 'definitions' => (object) [ @@ -204,7 +204,7 @@ public function testResolvePointerFragmentNotFound() ); } - public function testResolvePointerFragmentNoArray() + public function testResolvePointerFragmentNoArray(): void { $schema = (object) [ 'definitions' => (object) [ @@ -223,7 +223,7 @@ public function testResolvePointerFragmentNoArray() ); } - public function testResolveExcessLevelUp() + public function testResolveExcessLevelUp(): void { $retriever = new UriRetriever(); @@ -233,7 +233,7 @@ public function testResolveExcessLevelUp() ); } - public function testConfirmMediaTypeAcceptsJsonSchemaType() + public function testConfirmMediaTypeAcceptsJsonSchemaType(): void { $uriRetriever = $this->createMock('JsonSchema\Uri\Retrievers\UriRetrieverInterface'); $retriever = new UriRetriever(); @@ -245,7 +245,7 @@ public function testConfirmMediaTypeAcceptsJsonSchemaType() $this->assertEquals(null, $retriever->confirmMediaType($uriRetriever, null)); } - public function testConfirmMediaTypeAcceptsJsonType() + public function testConfirmMediaTypeAcceptsJsonType(): void { $uriRetriever = $this->createMock('JsonSchema\Uri\Retrievers\UriRetrieverInterface'); $retriever = new UriRetriever(); @@ -257,7 +257,7 @@ public function testConfirmMediaTypeAcceptsJsonType() $this->assertEquals(null, $retriever->confirmMediaType($uriRetriever, null)); } - public function testConfirmMediaTypeThrowsExceptionForUnsupportedTypes() + public function testConfirmMediaTypeThrowsExceptionForUnsupportedTypes(): void { $uriRetriever = $this->createMock('JsonSchema\Uri\Retrievers\UriRetrieverInterface'); $retriever = new UriRetriever(); @@ -270,7 +270,7 @@ public function testConfirmMediaTypeThrowsExceptionForUnsupportedTypes() $retriever->confirmMediaType($uriRetriever, null); } - private function mockRetriever($schema) + private function mockRetriever($schema): void { $retrieverMock = $this->getRetrieverMock($schema); @@ -283,7 +283,7 @@ private function mockRetriever($schema) $retriever->setValue($factory, $retrieverMock); } - public function testTranslations() + public function testTranslations(): void { $retriever = new UriRetriever(); @@ -294,7 +294,7 @@ public function testTranslations() $this->assertEquals($translated, $retriever->translate($uri)); } - public function testPackageURITranslation() + public function testPackageURITranslation(): void { $retriever = new UriRetriever(); $root = sprintf('file://%s/', realpath(__DIR__ . '/../..')); @@ -303,7 +303,7 @@ public function testPackageURITranslation() $this->assertEquals("{$root}foo/bar.json", $uri); } - public function testDefaultDistTranslations() + public function testDefaultDistTranslations(): void { $retriever = new UriRetriever(); $root = sprintf('file://%s/dist/schema/', realpath(__DIR__ . '/../..')); @@ -319,7 +319,7 @@ public function testDefaultDistTranslations() ); } - public function testRetrieveSchemaFromPackage() + public function testRetrieveSchemaFromPackage(): void { $retriever = new UriRetriever(); @@ -331,7 +331,7 @@ public function testRetrieveSchemaFromPackage() $this->assertEquals('454f423bd7edddf0bc77af4130ed9161', md5(json_encode($schema))); } - public function testInvalidContentTypeEndpointsDefault() + public function testInvalidContentTypeEndpointsDefault(): void { $mock = $this->createMock('JsonSchema\Uri\Retrievers\UriRetrieverInterface'); $mock->method('getContentType')->willReturn('Application/X-Fake-Type'); @@ -341,7 +341,7 @@ public function testInvalidContentTypeEndpointsDefault() $this->assertTrue($retriever->confirmMediaType($mock, 'https://json-schema.org/')); } - public function testInvalidContentTypeEndpointsUnknown() + public function testInvalidContentTypeEndpointsUnknown(): void { $mock = $this->createMock('JsonSchema\Uri\Retrievers\UriRetrieverInterface'); $mock->method('getContentType')->willReturn('Application/X-Fake-Type'); @@ -351,7 +351,7 @@ public function testInvalidContentTypeEndpointsUnknown() $retriever->confirmMediaType($mock, 'http://example.com'); } - public function testInvalidContentTypeEndpointsAdded() + public function testInvalidContentTypeEndpointsAdded(): void { $mock = $this->createMock('JsonSchema\Uri\Retrievers\UriRetrieverInterface'); $mock->method('getContentType')->willReturn('Application/X-Fake-Type'); @@ -363,7 +363,7 @@ public function testInvalidContentTypeEndpointsAdded() self::assertTrue($result); } - public function testSchemaCache() + public function testSchemaCache(): void { $retriever = new UriRetriever(); $reflector = new \ReflectionObject($retriever); @@ -382,7 +382,7 @@ public function testSchemaCache() ); } - public function testLoadSchemaJSONDecodingException() + public function testLoadSchemaJSONDecodingException(): void { $retriever = new UriRetriever(); @@ -392,7 +392,7 @@ public function testLoadSchemaJSONDecodingException() $retriever->retrieve('package://tests/fixtures/bad-syntax.json'); } - public function testGenerateURI() + public function testGenerateURI(): void { $retriever = new UriRetriever(); $components = [ @@ -405,7 +405,7 @@ public function testGenerateURI() $this->assertEquals('scheme://authority/path?query#fragment', $retriever->generate($components)); } - public function testResolveHTTP() + public function testResolveHTTP(): void { $retriever = new UriRetriever(); $this->assertEquals( @@ -414,7 +414,7 @@ public function testResolveHTTP() ); } - public function combinedURITests() + public function combinedURITests(): array { return [ ['blue', 'http://example.com/red', 'http://example.com/blue'], @@ -425,13 +425,13 @@ public function combinedURITests() /** * @dataProvider combinedURITests */ - public function testResolveCombinedURI($uri, $baseURI, $combinedURI) + public function testResolveCombinedURI($uri, $baseURI, $combinedURI): void { $retriever = new UriRetriever(); $this->assertEquals($combinedURI, $retriever->resolve($uri, $baseURI)); } - public function testIsValidURI() + public function testIsValidURI(): void { $retriever = new UriRetriever(); $this->assertTrue($retriever->isValid('http://example.com/schema')); diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index eec59a10..26a8069d 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -7,7 +7,7 @@ class ValidatorTest extends TestCase { - public function testValidateWithAssocSchema() + public function testValidateWithAssocSchema(): void { $schema = json_decode('{"properties":{"propertyOne":{"type":"array","items":[{"type":"string"}]}}}', true); $data = json_decode('{"propertyOne":[42]}', true); @@ -18,7 +18,7 @@ public function testValidateWithAssocSchema() $this->assertFalse($validator->isValid(), 'Validation succeeded, but should have failed.'); } - public function testBadAssocSchemaInput() + public function testBadAssocSchemaInput(): void { if (version_compare(phpversion(), '5.5.0', '<')) { $this->markTestSkipped('PHP versions < 5.5.0 trigger an error on json_encode issues'); @@ -35,7 +35,7 @@ public function testBadAssocSchemaInput() $validator->validate($data, $schema); } - public function testDeprecatedCheckDelegatesToValidate() + public function testDeprecatedCheckDelegatesToValidate(): void { $schema = json_decode('{"type":"string"}'); $data = json_decode('42'); @@ -46,7 +46,7 @@ public function testDeprecatedCheckDelegatesToValidate() $this->assertFalse($validator->isValid(), 'Validation succeeded, but should have failed.'); } - public function testDeprecatedCoerceDelegatesToValidate() + public function testDeprecatedCoerceDelegatesToValidate(): void { $schema = json_decode('{"type":"integer"}'); $data = json_decode('"42"');