From f5cf7e0c516972191ccf4bf215ad600345a1b8b7 Mon Sep 17 00:00:00 2001 From: Mathieu Rochette Date: Fri, 10 Nov 2017 17:42:15 +0100 Subject: [PATCH 01/17] override new phpcs rule (#465) --- .php_cs.dist | 1 + 1 file changed, 1 insertion(+) diff --git a/.php_cs.dist b/.php_cs.dist index 6b7d9b92..8a227e64 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -26,6 +26,7 @@ $config 'trailing_comma_in_multiline_array' => false, 'simplified_null_return' => false, 'yoda_style' => null, + 'increment_style' => false, )) ->setFinder($finder) ; From ca697a0b91e33639bfb2852dfce2f8f6da91c2be Mon Sep 17 00:00:00 2001 From: David Porter Date: Sun, 12 Nov 2017 11:38:17 -0600 Subject: [PATCH 02/17] Merge pull request #466 from gabriel-caruso/phpunit Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase --- composer.json | 2 +- tests/Constraints/FactoryTest.php | 2 +- tests/Constraints/PointerTest.php | 3 ++- tests/Constraints/SchemaValidationTest.php | 3 ++- tests/Constraints/TypeTest.php | 3 ++- tests/Constraints/ValidationExceptionTest.php | 3 ++- tests/Constraints/VeryBaseTestCase.php | 3 ++- tests/Entity/JsonPointerTest.php | 3 ++- tests/Exception/InvalidArgumentExceptionTest.php | 3 ++- tests/Exception/InvalidSchemaMediaTypeExceptionTest.php | 3 ++- tests/Exception/InvalidSourceUriExceptionTest.php | 3 ++- tests/Exception/JsonDecodingExceptionTest.php | 3 ++- tests/Exception/ResourceNotFoundExceptionTest.php | 3 ++- tests/Exception/RuntimeExceptionTest.php | 3 ++- tests/Exception/UnresolvableJsonPointerExceptionTest.php | 3 ++- tests/Exception/UriResolverExceptionTest.php | 3 ++- tests/Iterators/ObjectIteratorTest.php | 3 ++- tests/Rfc3339Test.php | 3 ++- tests/SchemaStorageTest.php | 3 ++- tests/Uri/Retrievers/CurlTest.php | 3 ++- tests/Uri/Retrievers/FileGetContentsTest.php | 3 ++- tests/Uri/Retrievers/PredefinedArrayTest.php | 3 ++- tests/Uri/UriResolverTest.php | 3 ++- tests/Uri/UriRetrieverTest.php | 3 ++- tests/ValidatorTest.php | 3 ++- 25 files changed, 48 insertions(+), 25 deletions(-) diff --git a/composer.json b/composer.json index 009c1485..a8864aed 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ "require-dev": { "json-schema/JSON-Schema-Test-Suite": "1.2.0", "friendsofphp/php-cs-fixer": "^2.1", - "phpunit/phpunit": "^4.8.22" + "phpunit/phpunit": "^4.8.35" }, "autoload": { "psr-4": { "JsonSchema\\": "src/JsonSchema/" } diff --git a/tests/Constraints/FactoryTest.php b/tests/Constraints/FactoryTest.php index 4f13bcf6..ac2a91fb 100644 --- a/tests/Constraints/FactoryTest.php +++ b/tests/Constraints/FactoryTest.php @@ -12,7 +12,7 @@ use JsonSchema\Constraints\Constraint; use JsonSchema\Constraints\Factory; use JsonSchema\Entity\JsonPointer; -use PHPUnit_Framework_TestCase as TestCase; +use PHPUnit\Framework\TestCase; /** * Class MyBadConstraint diff --git a/tests/Constraints/PointerTest.php b/tests/Constraints/PointerTest.php index 88e5247d..a8143a6b 100644 --- a/tests/Constraints/PointerTest.php +++ b/tests/Constraints/PointerTest.php @@ -10,8 +10,9 @@ namespace JsonSchema\Tests\Constraints; use JsonSchema\Validator; +use PHPUnit\Framework\TestCase; -class PointerTest extends \PHPUnit_Framework_TestCase +class PointerTest extends TestCase { protected $validateSchema = true; diff --git a/tests/Constraints/SchemaValidationTest.php b/tests/Constraints/SchemaValidationTest.php index 356637ae..85907c5d 100644 --- a/tests/Constraints/SchemaValidationTest.php +++ b/tests/Constraints/SchemaValidationTest.php @@ -11,8 +11,9 @@ use JsonSchema\Constraints\Constraint; use JsonSchema\Validator; +use PHPUnit\Framework\TestCase; -class SchemaValidationTest extends \PHPUnit_Framework_TestCase +class SchemaValidationTest extends TestCase { protected $validateSchema = true; diff --git a/tests/Constraints/TypeTest.php b/tests/Constraints/TypeTest.php index 24138478..0c584307 100644 --- a/tests/Constraints/TypeTest.php +++ b/tests/Constraints/TypeTest.php @@ -11,6 +11,7 @@ use JsonSchema\Constraints\TypeCheck\LooseTypeCheck; use JsonSchema\Constraints\TypeConstraint; +use PHPUnit\Framework\TestCase; /** * Class TypeTest @@ -19,7 +20,7 @@ * * @author hakre */ -class TypeTest extends \PHPUnit_Framework_TestCase +class TypeTest extends TestCase { /** * @see testIndefiniteArticleForTypeInTypeCheckErrorMessage diff --git a/tests/Constraints/ValidationExceptionTest.php b/tests/Constraints/ValidationExceptionTest.php index 6a7076bb..57995769 100644 --- a/tests/Constraints/ValidationExceptionTest.php +++ b/tests/Constraints/ValidationExceptionTest.php @@ -12,8 +12,9 @@ use JsonSchema\Constraints\Constraint; use JsonSchema\Exception\ValidationException; use JsonSchema\Validator; +use PHPUnit\Framework\TestCase; -class ValidationExceptionTest extends \PHPUnit_Framework_TestCase +class ValidationExceptionTest extends TestCase { public function testValidationException() { diff --git a/tests/Constraints/VeryBaseTestCase.php b/tests/Constraints/VeryBaseTestCase.php index 7cc0d1c6..7cd7c06b 100644 --- a/tests/Constraints/VeryBaseTestCase.php +++ b/tests/Constraints/VeryBaseTestCase.php @@ -9,12 +9,13 @@ namespace JsonSchema\Tests\Constraints; +use PHPUnit\Framework\TestCase; use Prophecy\Argument; /** * @package JsonSchema\Tests\Constraints */ -abstract class VeryBaseTestCase extends \PHPUnit_Framework_TestCase +abstract class VeryBaseTestCase extends TestCase { /** @var object */ private $jsonSchemaDraft03; diff --git a/tests/Entity/JsonPointerTest.php b/tests/Entity/JsonPointerTest.php index 65859895..d063d32d 100644 --- a/tests/Entity/JsonPointerTest.php +++ b/tests/Entity/JsonPointerTest.php @@ -10,13 +10,14 @@ namespace JsonSchema\Tests\Entity; use JsonSchema\Entity\JsonPointer; +use PHPUnit\Framework\TestCase; /** * @package JsonSchema\Tests\Entity * * @author Joost Nijhuis */ -class JsonPointerTest extends \PHPUnit_Framework_TestCase +class JsonPointerTest extends TestCase { /** * @dataProvider getTestData diff --git a/tests/Exception/InvalidArgumentExceptionTest.php b/tests/Exception/InvalidArgumentExceptionTest.php index 52456f28..5715fbac 100644 --- a/tests/Exception/InvalidArgumentExceptionTest.php +++ b/tests/Exception/InvalidArgumentExceptionTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Exception; use JsonSchema\Exception\InvalidArgumentException; +use PHPUnit\Framework\TestCase; -class InvalidArgumentExceptionTest extends \PHPUnit_Framework_TestCase +class InvalidArgumentExceptionTest extends TestCase { public function testHierarchy() { diff --git a/tests/Exception/InvalidSchemaMediaTypeExceptionTest.php b/tests/Exception/InvalidSchemaMediaTypeExceptionTest.php index ebebccbd..6b12adc6 100644 --- a/tests/Exception/InvalidSchemaMediaTypeExceptionTest.php +++ b/tests/Exception/InvalidSchemaMediaTypeExceptionTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Exception; use JsonSchema\Exception\InvalidSchemaMediaTypeException; +use PHPUnit\Framework\TestCase; -class InvalidSchemaMediaTypeExceptionTest extends \PHPUnit_Framework_TestCase +class InvalidSchemaMediaTypeExceptionTest extends TestCase { public function testHierarchy() { diff --git a/tests/Exception/InvalidSourceUriExceptionTest.php b/tests/Exception/InvalidSourceUriExceptionTest.php index 676cce37..7cccf817 100644 --- a/tests/Exception/InvalidSourceUriExceptionTest.php +++ b/tests/Exception/InvalidSourceUriExceptionTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Exception; use JsonSchema\Exception\InvalidSourceUriException; +use PHPUnit\Framework\TestCase; -class InvalidSourceUriExceptionTest extends \PHPUnit_Framework_TestCase +class InvalidSourceUriExceptionTest extends TestCase { public function testHierarchy() { diff --git a/tests/Exception/JsonDecodingExceptionTest.php b/tests/Exception/JsonDecodingExceptionTest.php index bd9ccb6f..667c6520 100644 --- a/tests/Exception/JsonDecodingExceptionTest.php +++ b/tests/Exception/JsonDecodingExceptionTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Exception; use JsonSchema\Exception\JsonDecodingException; +use PHPUnit\Framework\TestCase; -class JsonDecodingExceptionTest extends \PHPUnit_Framework_TestCase +class JsonDecodingExceptionTest extends TestCase { public function testHierarchy() { diff --git a/tests/Exception/ResourceNotFoundExceptionTest.php b/tests/Exception/ResourceNotFoundExceptionTest.php index aaeac961..2cde0eec 100644 --- a/tests/Exception/ResourceNotFoundExceptionTest.php +++ b/tests/Exception/ResourceNotFoundExceptionTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Exception; use JsonSchema\Exception\ResourceNotFoundException; +use PHPUnit\Framework\TestCase; -class ResourceNotFoundExceptionTest extends \PHPUnit_Framework_TestCase +class ResourceNotFoundExceptionTest extends TestCase { public function testHierarchy() { diff --git a/tests/Exception/RuntimeExceptionTest.php b/tests/Exception/RuntimeExceptionTest.php index c9800953..4db22eaa 100644 --- a/tests/Exception/RuntimeExceptionTest.php +++ b/tests/Exception/RuntimeExceptionTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Exception; use JsonSchema\Exception\RuntimeException; +use PHPUnit\Framework\TestCase; -class RuntimeExceptionTest extends \PHPUnit_Framework_TestCase +class RuntimeExceptionTest extends TestCase { public function testHierarchy() { diff --git a/tests/Exception/UnresolvableJsonPointerExceptionTest.php b/tests/Exception/UnresolvableJsonPointerExceptionTest.php index 61b40779..f061d9da 100644 --- a/tests/Exception/UnresolvableJsonPointerExceptionTest.php +++ b/tests/Exception/UnresolvableJsonPointerExceptionTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Exception; use JsonSchema\Exception\UnresolvableJsonPointerException; +use PHPUnit\Framework\TestCase; -class UnresolvableJsonPointerExceptionTest extends \PHPUnit_Framework_TestCase +class UnresolvableJsonPointerExceptionTest extends TestCase { public function testHierarchy() { diff --git a/tests/Exception/UriResolverExceptionTest.php b/tests/Exception/UriResolverExceptionTest.php index a9cdef9f..eb9af83f 100644 --- a/tests/Exception/UriResolverExceptionTest.php +++ b/tests/Exception/UriResolverExceptionTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Exception; use JsonSchema\Exception\UriResolverException; +use PHPUnit\Framework\TestCase; -class UriResolverExceptionTest extends \PHPUnit_Framework_TestCase +class UriResolverExceptionTest extends TestCase { public function testHierarchy() { diff --git a/tests/Iterators/ObjectIteratorTest.php b/tests/Iterators/ObjectIteratorTest.php index 703df833..e36d2ea4 100644 --- a/tests/Iterators/ObjectIteratorTest.php +++ b/tests/Iterators/ObjectIteratorTest.php @@ -10,8 +10,9 @@ namespace JsonSchema\Tests\Iterators; use JsonSchema\Iterator\ObjectIterator; +use PHPUnit\Framework\TestCase; -class ObjectIteratorTest extends \PHPUnit_Framework_TestCase +class ObjectIteratorTest extends TestCase { protected $testObject; diff --git a/tests/Rfc3339Test.php b/tests/Rfc3339Test.php index 13294d0a..e489d389 100644 --- a/tests/Rfc3339Test.php +++ b/tests/Rfc3339Test.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests; use JsonSchema\Rfc3339; +use PHPUnit\Framework\TestCase; -class Rfc3339Test extends \PHPUnit_Framework_TestCase +class Rfc3339Test extends TestCase { /** * @param string $string diff --git a/tests/SchemaStorageTest.php b/tests/SchemaStorageTest.php index 2393f29d..17435fe2 100644 --- a/tests/SchemaStorageTest.php +++ b/tests/SchemaStorageTest.php @@ -12,9 +12,10 @@ use JsonSchema\SchemaStorage; use JsonSchema\Uri\UriRetriever; use JsonSchema\Validator; +use PHPUnit\Framework\TestCase; use Prophecy\Argument; -class SchemaStorageTest extends \PHPUnit_Framework_TestCase +class SchemaStorageTest extends TestCase { public function testResolveRef() { diff --git a/tests/Uri/Retrievers/CurlTest.php b/tests/Uri/Retrievers/CurlTest.php index f833b590..550baff1 100644 --- a/tests/Uri/Retrievers/CurlTest.php +++ b/tests/Uri/Retrievers/CurlTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Uri\Retrievers { use JsonSchema\Uri\Retrievers\Curl; + use PHPUnit\Framework\TestCase; - class CurlTest extends \PHPUnit_Framework_TestCase + class CurlTest extends TestCase { public function testRetrieveFile() { diff --git a/tests/Uri/Retrievers/FileGetContentsTest.php b/tests/Uri/Retrievers/FileGetContentsTest.php index d9b06263..0514a7d5 100644 --- a/tests/Uri/Retrievers/FileGetContentsTest.php +++ b/tests/Uri/Retrievers/FileGetContentsTest.php @@ -3,11 +3,12 @@ namespace JsonSchema\Tests\Uri\Retrievers { use JsonSchema\Uri\Retrievers\FileGetContents; + use PHPUnit\Framework\TestCase; /** * @group FileGetContents */ - class FileGetContentsTest extends \PHPUnit_Framework_TestCase + class FileGetContentsTest extends TestCase { /** * @expectedException \JsonSchema\Exception\ResourceNotFoundException diff --git a/tests/Uri/Retrievers/PredefinedArrayTest.php b/tests/Uri/Retrievers/PredefinedArrayTest.php index e92908a2..7684bb1f 100644 --- a/tests/Uri/Retrievers/PredefinedArrayTest.php +++ b/tests/Uri/Retrievers/PredefinedArrayTest.php @@ -3,11 +3,12 @@ namespace JsonSchema\Tests\Uri\Retrievers; use JsonSchema\Uri\Retrievers\PredefinedArray; +use PHPUnit\Framework\TestCase; /** * @group PredefinedArray */ -class PredefinedArrayTest extends \PHPUnit_Framework_TestCase +class PredefinedArrayTest extends TestCase { private $retriever; diff --git a/tests/Uri/UriResolverTest.php b/tests/Uri/UriResolverTest.php index 051c2a58..a353de50 100644 --- a/tests/Uri/UriResolverTest.php +++ b/tests/Uri/UriResolverTest.php @@ -3,8 +3,9 @@ namespace JsonSchema\Tests\Uri; use JsonSchema\Uri\UriResolver; +use PHPUnit\Framework\TestCase; -class UriResolverTest extends \PHPUnit_Framework_TestCase +class UriResolverTest extends TestCase { public function setUp() { diff --git a/tests/Uri/UriRetrieverTest.php b/tests/Uri/UriRetrieverTest.php index f5db5ca1..c27e49c3 100644 --- a/tests/Uri/UriRetrieverTest.php +++ b/tests/Uri/UriRetrieverTest.php @@ -12,11 +12,12 @@ use JsonSchema\Exception\JsonDecodingException; use JsonSchema\Uri\UriRetriever; use JsonSchema\Validator; +use PHPUnit\Framework\TestCase; /** * @group UriRetriever */ -class UriRetrieverTest extends \PHPUnit_Framework_TestCase +class UriRetrieverTest extends TestCase { protected $validator; diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index 73688537..c34954e8 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -4,8 +4,9 @@ use JsonSchema\Constraints\Constraint; use JsonSchema\Validator; +use PHPUnit\Framework\TestCase; -class ValidatorTest extends \PHPUnit_Framework_TestCase +class ValidatorTest extends TestCase { public function testValidateWithAssocSchema() { From e08ea52506d37fab6c743bb661c2016a55c9da3e Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:09:35 -0600 Subject: [PATCH 03/17] Merge pull request #489 from localheinz/fix/unused-parameter Fix: Remove unused parameter --- tests/Uri/UriRetrieverTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Uri/UriRetrieverTest.php b/tests/Uri/UriRetrieverTest.php index c27e49c3..c95fc923 100644 --- a/tests/Uri/UriRetrieverTest.php +++ b/tests/Uri/UriRetrieverTest.php @@ -26,7 +26,7 @@ protected function setUp() $this->validator = new Validator(); } - private function getRetrieverMock($returnSchema, $returnMediaType = Validator::SCHEMA_MEDIA_TYPE) + private function getRetrieverMock($returnSchema) { $jsonSchema = json_decode($returnSchema); From bbff8be2788c37fd916893cf61c8e3a82abd79a4 Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:10:07 -0600 Subject: [PATCH 04/17] Merge pull request #488 from localheinz/fix/unused-method Fix: Remove unused private method --- tests/Constraints/LongArraysTest.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/Constraints/LongArraysTest.php b/tests/Constraints/LongArraysTest.php index 2757b964..c60fd3c7 100644 --- a/tests/Constraints/LongArraysTest.php +++ b/tests/Constraints/LongArraysTest.php @@ -100,11 +100,4 @@ public function testLongIntegerArray() $validator->check($checkValue, $schema); $this->assertTrue($validator->isValid(), print_r($validator->getErrors(), true)); } - - private static function millis() - { - $mt = explode(' ', microtime()); - - return $mt[1] * 1000 + round($mt[0] * 1000); - } } From ce953633635d42fe338e5987e265b1dcfa31cb61 Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:10:44 -0600 Subject: [PATCH 05/17] Merge pull request #479 from localheinz/fix/script Fix: No need to specify path to bin directory --- composer.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composer.json b/composer.json index a8864aed..6e72ab9b 100644 --- a/composer.json +++ b/composer.json @@ -56,10 +56,10 @@ } }, "scripts": { - "test" : "vendor/bin/phpunit", - "testOnly" : "vendor/bin/phpunit --colors --filter", - "coverage" : "vendor/bin/phpunit --coverage-text", - "style-check" : "vendor/bin/php-cs-fixer fix --dry-run --verbose --diff", - "style-fix" : "vendor/bin/php-cs-fixer fix --verbose" + "test" : "phpunit", + "testOnly" : "phpunit --colors --filter", + "coverage" : "phpunit --coverage-text", + "style-check" : "php-cs-fixer fix --dry-run --verbose --diff", + "style-fix" : "php-cs-fixer fix --verbose" } } From 3597e445cd5e0a716e205b9ae1b2a87211cca32a Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:11:54 -0600 Subject: [PATCH 06/17] Merge pull request #487 from localheinz/fix/assertion Fix: Use more appropriate assertions --- tests/Constraints/FormatTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Constraints/FormatTest.php b/tests/Constraints/FormatTest.php index b035aafe..78706c33 100644 --- a/tests/Constraints/FormatTest.php +++ b/tests/Constraints/FormatTest.php @@ -77,7 +77,7 @@ public function testInvalidFormat($string, $format) $schema->format = $format; $validator->check($string, $schema); - $this->assertEquals(1, count($validator->getErrors()), 'Expected 1 error'); + $this->assertCount(1, $validator->getErrors(), 'Expected 1 error'); } /** From 7845aa634cb7179c4032892701a129ddba779ceb Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:12:24 -0600 Subject: [PATCH 07/17] Merge pull request #486 from localheinz/fix/argument Fix: Remove unused argument from method call --- tests/SchemaStorageTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/SchemaStorageTest.php b/tests/SchemaStorageTest.php index 17435fe2..e2221209 100644 --- a/tests/SchemaStorageTest.php +++ b/tests/SchemaStorageTest.php @@ -114,7 +114,7 @@ public function testUnresolvableJsonPointExceptionShouldBeThrown() $uriRetriever = $this->prophesize('JsonSchema\UriRetrieverInterface'); $uriRetriever->retrieve($mainSchemaPath) ->willReturn($mainSchema) - ->shouldBeCalled($mainSchema); + ->shouldBeCalled(); $schemaStorage = new SchemaStorage($uriRetriever->reveal()); $schemaStorage->resolveRef("$mainSchemaPath#/definitions/car"); From 0998cc8b9fa444a55706c7c517abfab34eea4230 Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:12:53 -0600 Subject: [PATCH 08/17] Merge pull request #485 from localheinz/fix/case Fix: Case mismatch --- tests/Constraints/TypeTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Constraints/TypeTest.php b/tests/Constraints/TypeTest.php index 0c584307..ca6bf7cf 100644 --- a/tests/Constraints/TypeTest.php +++ b/tests/Constraints/TypeTest.php @@ -58,7 +58,7 @@ public function testIndefiniteArticleForTypeInTypeCheckErrorMessage($type, $word */ public function testLooseTypeChecking() { - $v = new \StdClass(); + $v = new \stdClass(); $v->property = 'dataOne'; LooseTypeCheck::propertySet($v, 'property', 'dataTwo'); $this->assertEquals('dataTwo', $v->property); @@ -111,7 +111,7 @@ public function testValidateTypeNameWording() public function testValidateTypeException() { $t = new TypeConstraint(); - $data = new \StdClass(); + $data = new \stdClass(); $schema = json_decode('{"type": "notAValidTypeName"}'); $this->setExpectedException( From 8d8ba56e1c0abc1457e62bb8f28808def4e08d50 Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:13:52 -0600 Subject: [PATCH 09/17] Merge pull request #483 from localheinz/fix/indent Fix: Consistently indent with 2 spaces --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 3462c9f3..0e43c5ab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,9 @@ sudo: false language: php cache: - directories: - - $HOME/.composer/cache - - $HOME/.phpcsfixer + directories: + - $HOME/.composer/cache + - $HOME/.phpcsfixer matrix: fast_finish: true From 73ba03d12ebc1c807c01b3962fca7cab9863e4ae Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:14:31 -0600 Subject: [PATCH 10/17] Merge pull request #481 from localheinz/fix/php72 Fix: Add PHP 7.2 to build matrix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0e43c5ab..97244c86 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ matrix: - php: 7.0 env: WITH_COVERAGE=true WITH_PHPCSFIXER=true - php: 7.1 + - php: 7.2 - php: 'nightly' - php: hhvm dist: trusty From f1bca87e1ebef3938ce5199cea6ebe60cebb811d Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:15:02 -0600 Subject: [PATCH 11/17] Merge pull request #480 from localheinz/fix/self-update Fix: No need to update composer itself --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 97244c86..ebf29d24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,6 @@ matrix: before_install: - if [[ "$WITH_COVERAGE" != "true" && "$TRAVIS_PHP_VERSION" != "hhvm" && "$TRAVIS_PHP_VERSION" != "nightly" && "$TRAVIS_PHP_VERSION" != "7.1" ]]; then phpenv config-rm xdebug.ini; fi - - composer selfupdate - if [[ "$TRAVIS_PHP_VERSION" = "hhvm" || "$TRAVIS_PHP_VERSION" = "nightly" ]]; then sed -i '/^.*friendsofphp\/php-cs-fixer.*$/d' composer.json; fi install: From 1a4e3394ab980ce80359961d9e6dc00a6f1918c5 Mon Sep 17 00:00:00 2001 From: David Porter Date: Sat, 30 Dec 2017 23:16:01 -0600 Subject: [PATCH 12/17] Merge pull request #477 from localheinz/fix/unused-import Enhancement: Implicitly enable no_unused_imports fixer --- .php_cs.dist | 1 - src/JsonSchema/Constraints/Constraint.php | 3 --- src/JsonSchema/Constraints/Factory.php | 2 -- src/JsonSchema/Constraints/SchemaConstraint.php | 1 - src/JsonSchema/Validator.php | 2 -- tests/Drafts/Draft3Test.php | 2 -- tests/SchemaStorageTest.php | 1 - tests/ValidatorTest.php | 1 - 8 files changed, 13 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 8a227e64..9486fb58 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -15,7 +15,6 @@ $config 'array_syntax' => array('syntax' => 'long'), 'binary_operator_spaces' => false, 'concat_space' => array('spacing' => 'one'), - 'no_unused_imports' => false, 'no_useless_else' => true, 'no_useless_return' => true, 'ordered_imports' => true, diff --git a/src/JsonSchema/Constraints/Constraint.php b/src/JsonSchema/Constraints/Constraint.php index e50c7d0b..a53130df 100644 --- a/src/JsonSchema/Constraints/Constraint.php +++ b/src/JsonSchema/Constraints/Constraint.php @@ -10,9 +10,6 @@ namespace JsonSchema\Constraints; use JsonSchema\Entity\JsonPointer; -use JsonSchema\SchemaStorage; -use JsonSchema\Uri\UriRetriever; -use JsonSchema\UriRetrieverInterface; /** * The Base Constraints, all Validators should extend this class diff --git a/src/JsonSchema/Constraints/Factory.php b/src/JsonSchema/Constraints/Factory.php index c9296385..4e771c19 100644 --- a/src/JsonSchema/Constraints/Factory.php +++ b/src/JsonSchema/Constraints/Factory.php @@ -9,9 +9,7 @@ namespace JsonSchema\Constraints; -use JsonSchema\Constraints\Constraint; use JsonSchema\Exception\InvalidArgumentException; -use JsonSchema\Exception\InvalidConfigException; use JsonSchema\SchemaStorage; use JsonSchema\SchemaStorageInterface; use JsonSchema\Uri\UriRetriever; diff --git a/src/JsonSchema/Constraints/SchemaConstraint.php b/src/JsonSchema/Constraints/SchemaConstraint.php index eed53956..db665ad3 100644 --- a/src/JsonSchema/Constraints/SchemaConstraint.php +++ b/src/JsonSchema/Constraints/SchemaConstraint.php @@ -13,7 +13,6 @@ use JsonSchema\Exception\InvalidArgumentException; use JsonSchema\Exception\InvalidSchemaException; use JsonSchema\Exception\RuntimeException; -use JsonSchema\SchemaStorage; use JsonSchema\Validator; /** diff --git a/src/JsonSchema/Validator.php b/src/JsonSchema/Validator.php index 0e3b4709..448091cd 100644 --- a/src/JsonSchema/Validator.php +++ b/src/JsonSchema/Validator.php @@ -11,8 +11,6 @@ use JsonSchema\Constraints\BaseConstraint; use JsonSchema\Constraints\Constraint; -use JsonSchema\Exception\InvalidConfigException; -use JsonSchema\SchemaStorage; /** * A JsonSchema Constraint diff --git a/tests/Drafts/Draft3Test.php b/tests/Drafts/Draft3Test.php index 1942a3b1..84d2353f 100644 --- a/tests/Drafts/Draft3Test.php +++ b/tests/Drafts/Draft3Test.php @@ -9,8 +9,6 @@ namespace JsonSchema\Tests\Drafts; -use JsonSchema\Constraints\Constraint; - /** * @package JsonSchema\Tests\Drafts */ diff --git a/tests/SchemaStorageTest.php b/tests/SchemaStorageTest.php index e2221209..0c31e86a 100644 --- a/tests/SchemaStorageTest.php +++ b/tests/SchemaStorageTest.php @@ -13,7 +13,6 @@ use JsonSchema\Uri\UriRetriever; use JsonSchema\Validator; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; class SchemaStorageTest extends TestCase { diff --git a/tests/ValidatorTest.php b/tests/ValidatorTest.php index c34954e8..6ecb4c69 100644 --- a/tests/ValidatorTest.php +++ b/tests/ValidatorTest.php @@ -2,7 +2,6 @@ namespace JsonSchema\Tests; -use JsonSchema\Constraints\Constraint; use JsonSchema\Validator; use PHPUnit\Framework\TestCase; From 41dcfaa7d06f096df312d7f8f3ffeaf298847bc3 Mon Sep 17 00:00:00 2001 From: David Porter Date: Sun, 31 Dec 2017 07:44:59 -0600 Subject: [PATCH 13/17] Merge pull request #478 from localheinz/fix/unused-argument Fix: Remove unused argument --- .php_cs.dist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.php_cs.dist b/.php_cs.dist index 9486fb58..2bbfaa4a 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -1,7 +1,7 @@ in(__DIR__); /* Based on ^2.1 of php-cs-fixer */ From d9ccbbb5d15723dd032c952a62f8bc2c7a2afe3e Mon Sep 17 00:00:00 2001 From: David Porter Date: Sun, 31 Dec 2017 17:43:46 -0600 Subject: [PATCH 14/17] Merge pull request #490 from localheinz/fix/sort Fix: Keep rules sorted in .php_cs.dist --- .php_cs.dist | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.php_cs.dist b/.php_cs.dist index 2bbfaa4a..c4e84b4e 100644 --- a/.php_cs.dist +++ b/.php_cs.dist @@ -15,6 +15,7 @@ $config 'array_syntax' => array('syntax' => 'long'), 'binary_operator_spaces' => false, 'concat_space' => array('spacing' => 'one'), + 'increment_style' => false, 'no_useless_else' => true, 'no_useless_return' => true, 'ordered_imports' => true, @@ -22,10 +23,9 @@ $config 'phpdoc_order' => true, 'phpdoc_summary' => false, 'pre_increment' => false, - 'trailing_comma_in_multiline_array' => false, 'simplified_null_return' => false, + 'trailing_comma_in_multiline_array' => false, 'yoda_style' => null, - 'increment_style' => false, )) ->setFinder($finder) ; From 5550f3c3595ed40cf564f8c76e73c7e93fb3370a Mon Sep 17 00:00:00 2001 From: David Porter Date: Tue, 13 Feb 2018 11:24:53 -0600 Subject: [PATCH 15/17] Merge pull request #494 from erayd/apply-ref-default [BUGFIX] Apply defaults in $ref'ed property / item definitions --- src/JsonSchema/Constraints/UndefinedConstraint.php | 2 ++ tests/Constraints/DefaultPropertiesTest.php | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/JsonSchema/Constraints/UndefinedConstraint.php b/src/JsonSchema/Constraints/UndefinedConstraint.php index c0606ff9..257db155 100644 --- a/src/JsonSchema/Constraints/UndefinedConstraint.php +++ b/src/JsonSchema/Constraints/UndefinedConstraint.php @@ -243,6 +243,7 @@ protected function applyDefaultValues(&$value, $schema, $path) if (isset($schema->properties) && LooseTypeCheck::isObject($value)) { // $value is an object or assoc array, and properties are defined - treat as an object foreach ($schema->properties as $currentProperty => $propertyDefinition) { + $propertyDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($propertyDefinition); if ( !LooseTypeCheck::propertyExists($value, $currentProperty) && property_exists($propertyDefinition, 'default') @@ -266,6 +267,7 @@ protected function applyDefaultValues(&$value, $schema, $path) } // $value is an array, and items are defined - treat as plain array foreach ($items as $currentItem => $itemDefinition) { + $itemDefinition = $this->factory->getSchemaStorage()->resolveRefSchema($itemDefinition); if ( !array_key_exists($currentItem, $value) && property_exists($itemDefinition, 'default') diff --git a/tests/Constraints/DefaultPropertiesTest.php b/tests/Constraints/DefaultPropertiesTest.php index bcf90b2c..cc5eb909 100644 --- a/tests/Constraints/DefaultPropertiesTest.php +++ b/tests/Constraints/DefaultPropertiesTest.php @@ -121,12 +121,12 @@ public function getValidTests() ), array(// #15 infinite recursion via $ref (object) '{}', - '{"properties":{"propertyOne": {"$ref": "#","default": {}}}}', + '{"properties":{"propertyOne": {"$ref": "#","default": "valueOne"}}, "default": {}}', '{"propertyOne":{}}' ), array(// #16 infinite recursion via $ref (array) '[]', - '{"items":[{"$ref":"#","default":[]}]}', + '{"items":[{"$ref":"#","default":"valueOne"}], "default": []}', '[[]]' ), array(// #17 default top value does not overwrite defined null From 842c562f132cb470b78f40355cc0ba1e678cfd96 Mon Sep 17 00:00:00 2001 From: Erayd Date: Wed, 14 Feb 2018 14:53:01 +1300 Subject: [PATCH 16/17] Swap values in tests (in violation of spec) This commit deliberately tests in a way that violates the spec. Versions of this library prior to 6.0.0 allow properties adjacent to $ref to override properties with the same name from the $ref'ed schema. This is explicitly in violation of the spec, but cannot be changed in 5.x.x, as it results in a significant behavioral change that may break end users' application logic. This issue is resolved in 6.0.0, and siblings of $ref are correctly ignored from 6.0.0 onwards. --- tests/Constraints/DefaultPropertiesTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Constraints/DefaultPropertiesTest.php b/tests/Constraints/DefaultPropertiesTest.php index cc5eb909..6cdce8bb 100644 --- a/tests/Constraints/DefaultPropertiesTest.php +++ b/tests/Constraints/DefaultPropertiesTest.php @@ -121,12 +121,12 @@ public function getValidTests() ), array(// #15 infinite recursion via $ref (object) '{}', - '{"properties":{"propertyOne": {"$ref": "#","default": "valueOne"}}, "default": {}}', + '{"properties":{"propertyOne": {"$ref": "#","default": {}}}, "default": "valueOne"}', '{"propertyOne":{}}' ), array(// #16 infinite recursion via $ref (array) '[]', - '{"items":[{"$ref":"#","default":"valueOne"}], "default": []}', + '{"items":[{"$ref":"#","default":[]}], "default": "valueOne"}', '[[]]' ), array(// #17 default top value does not overwrite defined null From abac02d15edec480a022d72fa610d09dda4f018b Mon Sep 17 00:00:00 2001 From: Erayd Date: Thu, 15 Feb 2018 10:00:08 +1300 Subject: [PATCH 17/17] Remove unused class reference --- tests/Constraints/CoerciveTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Constraints/CoerciveTest.php b/tests/Constraints/CoerciveTest.php index e4dd173d..ea8a2842 100644 --- a/tests/Constraints/CoerciveTest.php +++ b/tests/Constraints/CoerciveTest.php @@ -12,7 +12,6 @@ use JsonSchema\Constraints\Constraint; use JsonSchema\Constraints\Factory; use JsonSchema\SchemaStorage; -use JsonSchema\Uri\UriResolver; use JsonSchema\Validator; class CoerciveTest extends BasicTypesTest