diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index 0cffa4f..85836e2 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - php-version: ['7.0', '7.1', '7.2', '7.3', '7.4'] + php-version: ['7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] name: PHP ${{ matrix.php-version }} steps: - uses: actions/checkout@v2 @@ -31,12 +31,4 @@ jobs: if: steps.composer-cache.outputs.cache-hit != 'true' run: composer install --prefer-dist --no-progress --no-suggest - name: Run test suite - run: vendor/bin/phpunit --coverage-clover build/logs/clover.xml - - - name: Upload coverage results to Coveralls - if: matrix.php-version == '7.0' - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - composer require php-coveralls/php-coveralls - vendor/bin/php-coveralls --coverage_clover=build/logs/clover.xml -v + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index 4f38912..865ffaa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ .idea +.phpunit.result.cache vendor composer.lock diff --git a/README.md b/README.md index 28badba..0d87ba2 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,17 @@ # Json Serializer for PHP -[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.txt) -[![Build Status](https://img.shields.io/travis/zumba/json-serializer/master.svg?style=flat-square)](https://travis-ci.org/zumba/json-serializer) -[![Code Coverage](https://img.shields.io/coveralls/zumba/json-serializer/master.svg)](https://coveralls.io/github/zumba/json-serializer) -[![Scrutinizer](https://scrutinizer-ci.com/g/zumba/json-serializer/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/zumba/json-serializer/) +

+ + Software License + + Build Status + + Total Downloads + + + Latest Stable Version + +

This is a library to serialize PHP variables in JSON format. It is similar of the `serialize()` function in PHP, but the output is a string JSON encoded. You can also unserialize the JSON generated by this tool and have you diff --git a/composer.json b/composer.json index 18bea2d..f9b6422 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "jeremeamia/superclosure": "Allow to serialize PHP closures" }, "require-dev": { - "phpunit/phpunit": "6.*" + "phpunit/phpunit": ">=6.0 <10.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml b/phpunit.xml index a709f7f..8e5ecc0 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -6,11 +6,9 @@ convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" - syntaxCheck="true" - strict="true" colors="true"> - + ./tests diff --git a/tests/JsonSerializerTest.php b/tests/JsonSerializerTest.php index d69ced2..0953b1d 100644 --- a/tests/JsonSerializerTest.php +++ b/tests/JsonSerializerTest.php @@ -7,6 +7,7 @@ use stdClass; use SuperClosure\Serializer as ClosureSerializer; use PHPUnit\Framework\TestCase; +use ReflectionProperty; class JsonSerializerTest extends TestCase { @@ -21,11 +22,11 @@ class JsonSerializerTest extends TestCase /** * Test case setup * + * @before * @return void */ - public function setUp() + public function setUpSerializer() { - parent::setUp(); $customObjectSerializerMap['Zumba\\JsonSerializer\\Test\\SupportClasses\\MyType'] = new \Zumba\JsonSerializer\Test\SupportClasses\MyTypeSerializer(); $this->serializer = new JsonSerializer(null, $customObjectSerializerMap); } @@ -226,8 +227,12 @@ public function testUnserializeObjects() $obj = $this->serializer->unserialize($serialized); $this->assertInstanceOf('Zumba\JsonSerializer\Test\SupportClasses\AllVisibilities', $obj); $this->assertInstanceOf('Zumba\JsonSerializer\Test\SupportClasses\EmptyClass', $obj->pub); - $this->assertAttributeSame('protected', 'prot', $obj); - $this->assertAttributeSame('dont tell anyone', 'priv', $obj); + $prop = new ReflectionProperty($obj, 'prot'); + $prop->setAccessible(true); + $this->assertSame('protected', $prop->getValue($obj)); + $prop = new ReflectionProperty($obj, 'priv'); + $prop->setAccessible(true); + $this->assertSame('dont tell anyone', $prop->getValue($obj)); $serialized = '{"instance":{"@type":"Zumba\\\\JsonSerializer\\\\Test\\\\SupportClasses\\\\EmptyClass"}}'; $array = $this->serializer->unserialize($serialized); @@ -235,7 +240,6 @@ public function testUnserializeObjects() $this->assertInstanceOf('Zumba\JsonSerializer\Test\SupportClasses\EmptyClass', $array['instance']); } - /** * Test serialization of objects using the custom serializers * @@ -259,8 +263,8 @@ public function testCustomObjectsUnserializer() $serialized = '{"@type":"Zumba\\\\JsonSerializer\\\\Test\\\\SupportClasses\\\\MyType","fields":"x y"}'; $obj = $this->serializer->unserialize($serialized); $this->assertInstanceOf('Zumba\JsonSerializer\Test\SupportClasses\MyType', $obj); - $this->assertAttributeSame('x', 'field1', $obj); - $this->assertAttributeSame('y', 'field2', $obj); + $this->assertSame('x', $obj->field1); + $this->assertSame('y', $obj->field2); } /**