From c45d21a39bf50c9791c94a8c6ba3a110e8bccbbf Mon Sep 17 00:00:00 2001 From: Maxime Beaudoin Date: Mon, 14 Mar 2022 14:44:16 -0400 Subject: [PATCH] Moving to Github Action and removing support for old php versions (#54) --- .github/workflows/run-test.yml | 31 ++++++++++++ .github/workflows/static-analysis.yml | 46 ++++++++++++++++++ .github/workflows/style-checker.yml | 32 +++++++++++++ .gitignore | 1 + .scrutinizer.yml | 22 --------- .travis.yml | 20 -------- README.md | 29 ++--------- composer.json | 13 +++-- phpcs.xml | 13 +++++ phpstan-baseline.neon | 17 +++++++ phpstan.neon.dist | 8 ++++ phpunit.xml.dist | 27 ++++------- psalm.baseline.xml | 24 ++++++++++ psalm.xml | 16 +++++++ src/AbstractResponse.php | 48 +++++++++---------- src/Contracts/Response.php | 14 ++++-- src/Laravel/LumenServiceProvider.php | 2 +- src/Laravel/Response.php | 2 +- src/Laravel/ResponseServiceProvider.php | 4 +- src/Serializer/Serializer.php | 18 ++++--- .../Laravel/AddTestingSupportForInclude.php | 9 +++- tests/Laravel/Middleware/ParseIncludeTest.php | 5 +- tests/Laravel/ResponseTest.php | 7 ++- tests/ResponseTest.php | 5 +- tests/Serializer/SerializerTest.php | 12 ++--- 25 files changed, 283 insertions(+), 142 deletions(-) create mode 100644 .github/workflows/run-test.yml create mode 100644 .github/workflows/static-analysis.yml create mode 100644 .github/workflows/style-checker.yml delete mode 100644 .scrutinizer.yml delete mode 100644 .travis.yml create mode 100644 phpcs.xml create mode 100644 phpstan-baseline.neon create mode 100644 phpstan.neon.dist create mode 100644 psalm.baseline.xml create mode 100644 psalm.xml diff --git a/.github/workflows/run-test.yml b/.github/workflows/run-test.yml new file mode 100644 index 0000000..67cb331 --- /dev/null +++ b/.github/workflows/run-test.yml @@ -0,0 +1,31 @@ +name: Api Response Tests + +on: [push, pull_request] + +jobs: + ci: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-20.04] + php: [7.4, 8.0, 8.1] + + name: PHP ${{ matrix.php }} on ${{ matrix.os }} + + steps: + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + tools: phpunit + + - name: Download dependencies + uses: ramsey/composer-install@v2 + + - name: Run Tests + run: composer test -- --coverage-text diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 0000000..243bdc7 --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,46 @@ +on: [ pull_request ] +name: Static analysis + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + extensions: apcu, redis + coverage: none + tools: phpstan:1.4.10 + + - name: Download dependencies + uses: ramsey/composer-install@v1 + + - name: PHPStan + run: phpstan analyze + + psalm: + name: Psalm + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.1 + extensions: apcu, redis + coverage: none + tools: vimeo/psalm:4.22.0 + + - name: Download dependencies + uses: ramsey/composer-install@v1 + + - name: Psalm + run: psalm --no-progress --output-format=github diff --git a/.github/workflows/style-checker.yml b/.github/workflows/style-checker.yml new file mode 100644 index 0000000..9c60110 --- /dev/null +++ b/.github/workflows/style-checker.yml @@ -0,0 +1,32 @@ +name: Api Response Style Checks + +on: [push, pull_request] + +jobs: + style: + runs-on: ubuntu-latest + name: Api Response Style Checks + steps: + + - name: Checkout Code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + + - name: Cache Dependencies + id: composer-cache-style + uses: actions/cache@v2 + with: + path: vendor + key: ubuntu-composer-cache-style-${{ hashFiles('**/composer.lock') }} + restore-keys: ubuntu-php-style + + - name: Install Dependencies + if: steps.composer-cache.outputs.cache-hit != 'true' + run: composer install --prefer-dist --no-progress --no-suggest + + - name: Check Coding Style + run: vendor/bin/phpcs src/ diff --git a/.gitignore b/.gitignore index 9ca88d1..067a1ee 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.idea build vendor composer.lock diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 05e77e1..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,22 +0,0 @@ -filter: - excluded_paths: [tests, vendor] - -checks: - php: - remove_extra_empty_lines: true - remove_php_closing_tag: true - remove_trailing_whitespace: true - fix_use_statements: - remove_unused: true - preserve_multiple: false - preserve_blanklines: true - order_alphabetically: true - fix_php_opening_tag: true - fix_linefeed: true - fix_line_ending: true - fix_identation_4spaces: true - fix_doc_comments: true - -tools: - external_code_coverage: - timeout: 1800 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 20c20b3..0000000 --- a/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: php - -sudo: false - -matrix: - include: - - php: 5.6 - env: COLLECT_COVERAGE=true - - php: 7.0 - - php: 7.1 - - php: 7.2 - -install: - - travis_retry composer install --no-interaction --prefer-source - -script: - - if [[ "$COLLECT_COVERAGE" == "true" ]]; then composer test -- --coverage-text --coverage-clover=coverage.clover; else composer test -- --no-coverage; fi - -after_script: - - if [[ "$COLLECT_COVERAGE" == "true" ]]; then wget https://scrutinizer-ci.com/ocular.phar && php ocular.phar code-coverage:upload --format=php-clover coverage.clover; fi diff --git a/README.md b/README.md index b2a86b4..c30ac20 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,8 @@ [![Latest Version](https://img.shields.io/github/release/ellipsesynergie/api-response.svg?style=flat-square)](https://github.com/ellipsesynergie/api-response/releases) [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE) -[![Build Status](https://img.shields.io/travis/ellipsesynergie/api-response.svg?style=flat-square)](https://travis-ci.org/ellipsesynergie/api-response) -[![Coverage Status](https://img.shields.io/scrutinizer/coverage/g/ellipsesynergie/api-response.svg?style=flat-square)](https://scrutinizer-ci.com/g/ellipsesynergie/api-response/code-structure) -[![Quality Score](https://img.shields.io/scrutinizer/g/ellipsesynergie/api-response.svg?style=flat-square)](https://scrutinizer-ci.com/g/ellipsesynergie/api-response) +![Api Response Tests](https://github.com/ellipsesynergie/api-response/actions/workflows/run-test.yml/badge.svg) [![Total Downloads](https://img.shields.io/packagist/dt/ellipsesynergie/api-response.svg?style=flat-square)](https://packagist.org/packages/ellipsesynergie/api-response) -[![SensioLabsInsight](https://insight.sensiolabs.com/projects/4d91348d-221b-4ee8-97cc-3e26383092c5/mini.png)](https://insight.sensiolabs.com/projects/4d91348d-221b-4ee8-97cc-3e26383092c5) Simple package to handle response properly in your API. This package uses [Fractal](https://github.com/thephpleague/fractal) and is based on [Build APIs You Won't Hate](https://leanpub.com/build-apis-you-wont-hate) book. @@ -21,34 +18,18 @@ $ composer require ellipsesynergie/api-response ## Requirements -The following versions of PHP are supported by this version. +The following versions of PHP are supported by this version: -* PHP 5.6 -* PHP 7.0 -* PHP 7.1 -* PHP 7.2 +>= PHP 7.4 -### Install in Laravel 4 - -Unfortunately, since the release 0.9.0, Laravel 4 is no longer supported because `league/fractal@0.12` no longer support this version. -However, you can use the version `0.8.*` if you need to use it inside Laravel 4. - -### Install in Laravel 5 +### Install in Laravel Add this following service provider to your `config/app.php` file. ```php EllipseSynergie\ApiResponse\Laravel\ResponseServiceProvider::class ``` -### Install in Lumen 5 - -Register this service provider to your `bootstrap/app.php` file. - -```php -$app->register('EllipseSynergie\ApiResponse\Laravel\LumenServiceProvider'); -``` - -### Install in Lumen 5.4+ +### Install in Lumen Because of the request object change ([see reference](https://laravel-news.com/request-object-changes-in-lumen-5-4)) you can no longer access `Request` object properly in Service provider. To be convenient, we have created a middleware to be used for parsing the `include` parameter. diff --git a/composer.json b/composer.json index 87159a7..b498dea 100644 --- a/composer.json +++ b/composer.json @@ -25,10 +25,13 @@ "league/fractal": "~0.20" }, "require-dev": { - "phpunit/phpunit": "~5.0", - "mockery/mockery": "~0.9", - "illuminate/contracts": "~5.0", - "illuminate/http": "~5.0" + "phpunit/phpunit": "~9.0", + "mockery/mockery": "~1.0", + "illuminate/contracts": "~8.0", + "illuminate/http": "~8.0", + "phpstan/phpstan": "^1.4", + "vimeo/psalm": "^4.22", + "squizlabs/php_codesniffer": "^3.6" }, "autoload": { "psr-4": { @@ -38,7 +41,7 @@ }, "extra": { "branch-alias": { - "dev-master": "0.17-dev" + "dev-master": "0.21-dev" } }, "scripts": { diff --git a/phpcs.xml b/phpcs.xml new file mode 100644 index 0000000..ccacb66 --- /dev/null +++ b/phpcs.xml @@ -0,0 +1,13 @@ + + + PSR12 + + + + + + + + + + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..f6ca1c8 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,17 @@ +parameters: + ignoreErrors: + - + message: "#^Function response not found\\.$#" + count: 1 + path: src/Laravel/Response.php + + - + message: "#^Parameter \\#1 \\$message of method EllipseSynergie\\\\ApiResponse\\\\AbstractResponse\\:\\:errorWrongArgs\\(\\) expects string, array given\\.$#" + count: 1 + path: src/Laravel/Response.php + + - + message: "#^Call to static method macro\\(\\) on an unknown class Response\\.$#" + count: 1 + path: src/Laravel/ResponseServiceProvider.php + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..1b34754 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,8 @@ +includes: + - ./phpstan-baseline.neon + +parameters: + level: 5 + reportUnmatchedIgnoredErrors: false + paths: + - src diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d9484e6..bad550e 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -5,21 +5,14 @@ tests/ - - - src/ - - src/Laravel/ResponseServiceProvider.php - src/Laravel/LumenServiceProvider.php - src/Testing/Laravel/AddTestingSupportForInclude.php - - - - - - - - - - + + + ./src + + + src/Laravel/ResponseServiceProvider.php + src/Laravel/LumenServiceProvider.php + src/Testing/Laravel/AddTestingSupportForInclude.php + + diff --git a/psalm.baseline.xml b/psalm.baseline.xml new file mode 100644 index 0000000..be67e30 --- /dev/null +++ b/psalm.baseline.xml @@ -0,0 +1,24 @@ + + + + + $this->app + + + + + $validator->getMessageBag()->toArray() + + + response() + + + + + \Response + + + $this->app + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..1b89baa --- /dev/null +++ b/psalm.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/src/AbstractResponse.php b/src/AbstractResponse.php index 6fdc32a..1511250 100644 --- a/src/AbstractResponse.php +++ b/src/AbstractResponse.php @@ -20,25 +20,16 @@ */ abstract class AbstractResponse implements Response { + public const CODE_WRONG_ARGS = 'GEN-WRONG-ARGS'; + public const CODE_NOT_FOUND = 'GEN-NOT-FOUND'; + public const CODE_INTERNAL_ERROR = 'GEN-INTERNAL-ERROR'; + public const CODE_UNAUTHORIZED = 'GEN-UNAUTHORIZED'; + public const CODE_FORBIDDEN = 'GEN-FORBIDDEN'; + public const CODE_GONE = 'GEN-GONE'; + public const CODE_METHOD_NOT_ALLOWED = 'GEN-METHOD-NOT-ALLOWED'; + public const CODE_UNWILLING_TO_PROCESS = 'GEN-UNWILLING-TO-PROCESS'; + public const CODE_UNPROCESSABLE = 'GEN-UNPROCESSABLE'; - const CODE_WRONG_ARGS = 'GEN-WRONG-ARGS'; - - const CODE_NOT_FOUND = 'GEN-NOT-FOUND'; - - const CODE_INTERNAL_ERROR = 'GEN-INTERNAL-ERROR'; - - const CODE_UNAUTHORIZED = 'GEN-UNAUTHORIZED'; - - const CODE_FORBIDDEN = 'GEN-FORBIDDEN'; - - const CODE_GONE = 'GEN-GONE'; - - const CODE_METHOD_NOT_ALLOWED = 'GEN-METHOD-NOT-ALLOWED'; - - const CODE_UNWILLING_TO_PROCESS = 'GEN-UNWILLING-TO-PROCESS'; - - const CODE_UNPROCESSABLE = 'GEN-UNPROCESSABLE'; - /** * HTTP Status code @@ -99,14 +90,14 @@ public function setStatusCode($statusCode) * @param array $array * @param array $headers * @param int $json_options @link http://php.net/manual/en/function.json-encode.php - * @return + * @return mixed */ abstract public function withArray(array $array, array $headers = [], $json_options = 0); /** * Response for one item * - * @param $data + * @param mixed $data * @param callable|\League\Fractal\TransformerAbstract $transformer * @param string $resourceKey * @param array $meta @@ -129,7 +120,7 @@ public function withItem($data, $transformer, $resourceKey = null, $meta = [], a /** * Response for collection of items * - * @param $data + * @param mixed $data * @param callable|\League\Fractal\TransformerAbstract $transformer * @param string $resourceKey * @param Cursor $cursor @@ -137,8 +128,14 @@ public function withItem($data, $transformer, $resourceKey = null, $meta = [], a * @param array $headers * @return mixed */ - public function withCollection($data, $transformer, $resourceKey = null, Cursor $cursor = null, $meta = [], array $headers = []) - { + public function withCollection( + $data, + $transformer, + $resourceKey = null, + Cursor $cursor = null, + $meta = [], + array $headers = [] + ) { $resource = new Collection($data, $transformer, $resourceKey); foreach ($meta as $metaKey => $metaValue) { @@ -164,7 +161,8 @@ public function withCollection($data, $transformer, $resourceKey = null, Cursor */ public function withError($message, $errorCode, array $headers = []) { - return $this->withArray([ + return $this->withArray( + [ 'error' => [ 'code' => $errorCode, 'http_code' => $this->statusCode, @@ -270,7 +268,7 @@ public function errorUnwillingToProcess($message = 'Server is unwilling to proce { return $this->setStatusCode(431)->withError($message, static::CODE_UNWILLING_TO_PROCESS, $headers); } - + /** * Generates a Response with a 422 HTTP header and a given message. * diff --git a/src/Contracts/Response.php b/src/Contracts/Response.php index 6f7665e..c71ba39 100644 --- a/src/Contracts/Response.php +++ b/src/Contracts/Response.php @@ -49,7 +49,7 @@ public function withArray(array $array, array $headers = [], $json_options = 0); /** * Response for one item * - * @param $data + * @param mixed $data * @param callable|\League\Fractal\TransformerAbstract $transformer * @param string $resourceKey * @param array $meta @@ -61,7 +61,7 @@ public function withItem($data, $transformer, $resourceKey = null, $meta = [], a /** * Response for collection of items * - * @param $data + * @param mixed $data * @param callable|\League\Fractal\TransformerAbstract $transformer * @param string $resourceKey * @param Cursor $cursor @@ -69,7 +69,14 @@ public function withItem($data, $transformer, $resourceKey = null, $meta = [], a * @param array $headers * @return mixed */ - public function withCollection($data, $transformer, $resourceKey = null, Cursor $cursor = null, $meta = [], array $headers = []); + public function withCollection( + $data, + $transformer, + $resourceKey = null, + Cursor $cursor = null, + $meta = [], + array $headers = [] + ); /** * Response for errors @@ -153,4 +160,3 @@ public function errorMethodNotAllowed($message, array $headers = []); */ public function errorUnwillingToProcess($message, array $headers = []); } - diff --git a/src/Laravel/LumenServiceProvider.php b/src/Laravel/LumenServiceProvider.php index 5ced155..55601e7 100644 --- a/src/Laravel/LumenServiceProvider.php +++ b/src/Laravel/LumenServiceProvider.php @@ -23,7 +23,7 @@ class LumenServiceProvider extends ServiceProvider */ public function boot() { - $manager = new Manager; + $manager = new Manager(); // If you have to customize the manager instance, like setting a custom serializer, // I strongly suggest you to create your own service provider and add you manager configuration action here diff --git a/src/Laravel/Response.php b/src/Laravel/Response.php index ab481ad..b984336 100644 --- a/src/Laravel/Response.php +++ b/src/Laravel/Response.php @@ -44,7 +44,7 @@ public function withPaginator(LengthAwarePaginator $paginator, $transformer, $re { $queryParams = array_diff_key($_GET, array_flip(['page'])); $paginator->appends($queryParams); - + $resource = new Collection($paginator->items(), $transformer, $resourceKey); $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); diff --git a/src/Laravel/ResponseServiceProvider.php b/src/Laravel/ResponseServiceProvider.php index c40c443..577e396 100644 --- a/src/Laravel/ResponseServiceProvider.php +++ b/src/Laravel/ResponseServiceProvider.php @@ -45,7 +45,7 @@ protected function getSerializer() */ protected function bootResponse() { - $manager = new Manager; + $manager = new Manager(); // Custom serializer because DataArraySerializer doesn't provide the opportunity to change the resource key $manager->setSerializer($this->getSerializer()); @@ -54,7 +54,7 @@ protected function bootResponse() $includes = $this->app['Illuminate\Http\Request']->get('include'); //If includes is not already a array - if(!is_array($includes)){ + if (!is_array($includes)) { $includes = explode(',', $includes); } diff --git a/src/Serializer/Serializer.php b/src/Serializer/Serializer.php index 690e087..241129e 100644 --- a/src/Serializer/Serializer.php +++ b/src/Serializer/Serializer.php @@ -11,33 +11,37 @@ */ class Serializer extends ArraySerializer { - const RESOURCE_KEY = 'data'; + public const RESOURCE_KEY = 'data'; /** * Serialize a collection. * * @param string $resourceKey - * @param array $data + * @param array $data * * @return array */ public function collection(string $resourceKey, array $data): array { - if (is_null($resourceKey)) $resourceKey = static::RESOURCE_KEY; - return $resourceKey ? [$resourceKey => $data]: $data; + if (empty($resourceKey)) { + $resourceKey = static::RESOURCE_KEY; + } + return $resourceKey ? [$resourceKey => $data] : $data; } /** * Serialize an item. * * @param string $resourceKey - * @param array $data + * @param array $data * * @return array */ public function item(string $resourceKey, array $data): array { - if (is_null($resourceKey)) $resourceKey = static::RESOURCE_KEY; - return $resourceKey ? [$resourceKey => $data]: $data; + if (empty($resourceKey)) { + $resourceKey = static::RESOURCE_KEY; + } + return $resourceKey ? [$resourceKey => $data] : $data; } } diff --git a/src/Testing/Laravel/AddTestingSupportForInclude.php b/src/Testing/Laravel/AddTestingSupportForInclude.php index 6855d90..d99ea41 100644 --- a/src/Testing/Laravel/AddTestingSupportForInclude.php +++ b/src/Testing/Laravel/AddTestingSupportForInclude.php @@ -33,8 +33,13 @@ public function call($method, $uri, $parameters = [], $cookies = [], $files = [] $this->resetPageContext(); $symfonyRequest = SymfonyRequest::create( - $this->currentUri, $method, $parameters, - $cookies, $this->filterFiles($files), array_replace($this->serverVariables, $server), $content + $this->currentUri, + $method, + $parameters, + $cookies, + $this->filterFiles($files), + array_replace($this->serverVariables, $server), + $content ); $request = Request::createFromBase($symfonyRequest); diff --git a/tests/Laravel/Middleware/ParseIncludeTest.php b/tests/Laravel/Middleware/ParseIncludeTest.php index bb085ef..2daec91 100644 --- a/tests/Laravel/Middleware/ParseIncludeTest.php +++ b/tests/Laravel/Middleware/ParseIncludeTest.php @@ -6,8 +6,9 @@ use EllipseSynergie\ApiResponse\Laravel\Response; use Illuminate\Http\Request; use League\Fractal\Manager; +use PHPUnit\Framework\TestCase; -class ParseIncludeTest extends \PHPUnit_Framework_TestCase +class ParseIncludeTest extends TestCase { public function testHandleWorkProperly() { @@ -25,7 +26,7 @@ public function testHandleWorkProperly() }); $includes = $response->getManager()->getRequestedIncludes(); - + $this->assertSame($manager, $response->getManager()); $this->assertSame([ 'foo', diff --git a/tests/Laravel/ResponseTest.php b/tests/Laravel/ResponseTest.php index 16b84d7..ba491ea 100644 --- a/tests/Laravel/ResponseTest.php +++ b/tests/Laravel/ResponseTest.php @@ -4,6 +4,7 @@ use League\Fractal\Manager; use Mockery as m; +use PHPUnit\Framework\TestCase; /** * Class ResponseTest @@ -11,7 +12,7 @@ * @package EllipseSynergie\ApiResponse\Tests\Laravel * @author Maxime Beaudoin */ -class ResponseTest extends \PHPUnit_Framework_TestCase +class ResponseTest extends TestCase { public function testErrorWrongArgsValidator() { @@ -23,6 +24,8 @@ public function testErrorWrongArgsValidator() $response = new ResponseFake(new Manager()); $response->errorWrongArgsValidator($validator); + + $this->assertSame(400, $response->getStatusCode()); } public function testWithPaginatorWorkProperly() @@ -60,7 +63,7 @@ public function testWithPaginatorWorkProperly() ); } - public function tearDown() + public function tearDown(): void { m::close(); } diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index feaf3d6..f16db39 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -6,6 +6,7 @@ use EllipseSynergie\ApiResponse\Tests\ResponseFaker as Response; use League\Fractal\Manager; use League\Fractal\Pagination\Cursor; +use PHPUnit\Framework\TestCase; /** * Class ResponseTest @@ -13,14 +14,14 @@ * @package EllipseSynergie\ApiResponse\Tests * @author Maxime Beaudoin */ -class ResponseTest extends \PHPUnit_Framework_TestCase +class ResponseTest extends TestCase { /** * @var Response */ protected $response; - public function setUp() + public function setUp(): void { $this->response = new Response(new Manager()); } diff --git a/tests/Serializer/SerializerTest.php b/tests/Serializer/SerializerTest.php index 4535ef8..03e68f9 100644 --- a/tests/Serializer/SerializerTest.php +++ b/tests/Serializer/SerializerTest.php @@ -3,20 +3,20 @@ namespace EllipseSynergie\ApiResponse\Tests\Serializer; use EllipseSynergie\ApiResponse\Serializer\Serializer; -use PHPUnit_Framework_TestCase; +use PHPUnit\Framework\TestCase; /** * Class SerializerTest * @package EllipseSynergie\ApiResponse\Tests\Serializer * @author Maxime Beaudoin */ -class SerializerTest extends PHPUnit_Framework_TestCase +class SerializerTest extends TestCase { public function testCollectionWithDefaultResourceKey() { $data = ['foo']; $serializer = new Serializer(); - $result = $serializer->collection(null, $data); + $result = $serializer->collection('', $data); $this->assertSame(['data' => $data], $result); } @@ -34,7 +34,7 @@ public function testCollectionWithOptionalResourceKey() { $data = ['foo']; $serializer = new OptionalKeySerializer(); - $result = $serializer->collection(null, $data); + $result = $serializer->collection('', $data); $this->assertSame($data, $result); @@ -47,7 +47,7 @@ public function testItemWithDefaultResourceKey() { $data = ['foo']; $serializer = new Serializer(); - $result = $serializer->item(null, $data); + $result = $serializer->item('', $data); $this->assertSame(['data' => $data], $result); } @@ -65,7 +65,7 @@ public function testItemWithOptionalResourceKey() { $data = ['foo']; $serializer = new OptionalKeySerializer(); - $result = $serializer->item(null, $data); + $result = $serializer->item('', $data); $this->assertSame($data, $result);