From 00ce990bb4005021a590320978650ae5301bbfbc Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Tue, 26 Jul 2022 10:50:56 +0200 Subject: [PATCH 01/23] Add github workflow --- .github/workflows/ci-cd.yaml | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/ci-cd.yaml diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml new file mode 100644 index 0000000..24b7f2a --- /dev/null +++ b/.github/workflows/ci-cd.yaml @@ -0,0 +1,43 @@ +--- +name: CI_CD + +on: [push, pull_request] + +permissions: {} +jobs: + Unit_tests: + runs-on: ${{ matrix.os }} + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + php-version: [ + "5.4", + "5.6", + "7.0", + "7.4", + "8.0", + "8.1", + "8.2" + ] + os: [ubuntu-latest] # , macOS-latest, windows-latest] + steps: + - uses: shivammathur/setup-php@2.21.0 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v2 + - uses: actions/checkout@v3 + - name: Validate composer.json and composer.lock + run: composer validate --strict + # - name: Cache Composer packages + # id: composer-cache + # uses: actions/cache@v3 + # with: + # path: vendor + # key: ${{ matrix.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} + # restore-keys: | + # ${{ matrix.os }}-php-${{ matrix.php-version }}- + - name: Install Dependencies + run: composer install --no-ansi --no-interaction --no-progress + - name: Run test suite + run: vendor/bin/phpunit From f208ec7d82cfa327d5f585724ffb6f36dd89f1fc Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Tue, 26 Jul 2022 11:36:44 +0200 Subject: [PATCH 02/23] update composer --- composer.json | 3 +- composer.lock | 977 -------------------------------------------------- 2 files changed, 1 insertion(+), 979 deletions(-) delete mode 100644 composer.lock diff --git a/composer.json b/composer.json index 067d6e0..b9b32cc 100644 --- a/composer.json +++ b/composer.json @@ -30,8 +30,7 @@ }, "require-dev": { - "symfony/yaml": "~2.0", - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^4.8 || ^5.7 || ^6.5 || ^7.5 || ^8.4 || ^9.3" }, "autoload": { diff --git a/composer.lock b/composer.lock deleted file mode 100644 index aa679b7..0000000 --- a/composer.lock +++ /dev/null @@ -1,977 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "24129bff61e8cfa8b2a82efee5c7069a", - "content-hash": "6251dc24eeaff94cb037569e414a6195", - "packages": [], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14 21:17:01" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2015-02-03 12:10:50" - }, - { - "name": "phpspec/prophecy", - "version": "v1.6.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/3c91bdf81797d725b14cb62906f9a4ce44235972", - "reference": "3c91bdf81797d725b14cb62906f9a4ce44235972", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": "^5.3|^7.0", - "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "phpspec/phpspec": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2016-02-15 07:46:21" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-10-06 15:47:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2015-06-21 13:08:43" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21 13:50:34" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.7", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2015-06-21 08:01:12" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2015-09-15 10:49:45" - }, - { - "name": "phpunit/phpunit", - "version": "4.8.24", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a1066c562c52900a142a0e2bbf0582994671385e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a1066c562c52900a142a0e2bbf0582994671385e", - "reference": "a1066c562c52900a142a0e2bbf0582994671385e", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": ">=1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.1", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.8.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2016-03-14 06:16:08" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2015-10-02 06:51:40" - }, - { - "name": "sebastian/comparator", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2015-07-26 15:48:44" - }, - { - "name": "sebastian/diff", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2015-12-08 07:14:41" - }, - { - "name": "sebastian/environment", - "version": "1.3.5", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf", - "reference": "dc7a29032cf72b54f36dac15a1ca5b3a1b6029bf", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2016-02-26 18:40:46" - }, - { - "name": "sebastian/exporter", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2015-06-21 07:55:53" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-10-12 03:26:01" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11 19:50:13" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21 13:59:46" - }, - { - "name": "symfony/yaml", - "version": "v2.8.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "584e52cb8f788a887553ba82db6caacb1d6260bb" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/584e52cb8f788a887553ba82db6caacb1d6260bb", - "reference": "584e52cb8f788a887553ba82db6caacb1d6260bb", - "shasum": "" - }, - "require": { - "php": ">=5.3.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.8-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Yaml\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2016-03-04 07:54:35" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.3.0", - "ext-curl": "*", - "ext-json": "*", - "lib-curl": ">=7.20.0" - }, - "platform-dev": [] -} From d92835237753f20fa56fe0d69a42547c9734a6fa Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Tue, 26 Jul 2022 13:52:52 +0200 Subject: [PATCH 03/23] Update tests to work on multiple PHP/PHPUnit versions --- .github/workflows/ci-cd.yaml | 2 -- phpunit.xml | 2 +- test/TinifySourceTest.php | 13 +++---------- test/TinifyTest.php | 9 +-------- test/base/test_case_1.php | 12 ++++++++++++ test/base/test_case_2.php | 21 +++++++++++++++++++++ test/bootstrap.php | 21 +++++++++++++++++++++ test/helper.php | 16 ---------------- test/integration.php | 21 +++++++++++---------- 9 files changed, 70 insertions(+), 47 deletions(-) create mode 100644 test/base/test_case_1.php create mode 100644 test/base/test_case_2.php create mode 100644 test/bootstrap.php delete mode 100644 test/helper.php diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 24b7f2a..8c27594 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -14,11 +14,9 @@ jobs: php-version: [ "5.4", "5.6", - "7.0", "7.4", "8.0", "8.1", - "8.2" ] os: [ubuntu-latest] # , macOS-latest, windows-latest] steps: diff --git a/phpunit.xml b/phpunit.xml index 8053190..a313121 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,4 +1,4 @@ - + test diff --git a/test/TinifySourceTest.php b/test/TinifySourceTest.php index 4edacb8..67c8e07 100644 --- a/test/TinifySourceTest.php +++ b/test/TinifySourceTest.php @@ -3,13 +3,6 @@ use Tinify\CurlMock; class TinifySourceTest extends TestCase { - private $dummyFile; - - public function setUp() { - parent::setUp(); - $this->dummyFile = __DIR__ . "/examples/dummy.png"; - } - public function testWithInvalidApiKeyFromFileShouldThrowAccountException() { Tinify\setKey("invalid"); @@ -18,7 +11,7 @@ public function testWithInvalidApiKeyFromFileShouldThrowAccountException() { )); $this->setExpectedException("Tinify\AccountException"); - Tinify\Source::fromFile($this->dummyFile); + Tinify\Source::fromFile(DUMMY_FILE_LOCATION); } public function testWithInvalidApiKeyFromBufferShouldThrowAccountException() { @@ -50,7 +43,7 @@ public function testWithValidApiKeyFromFileShouldReturnSource() { "status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location") )); - $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromFile($this->dummyFile)); + $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromFile(DUMMY_FILE_LOCATION)); } public function testWithValidApiKeyFromFileShouldReturnSourceWithData() { @@ -64,7 +57,7 @@ public function testWithValidApiKeyFromFileShouldReturnSourceWithData() { "status" => 200, "body" => "compressed file" )); - $this->assertSame("compressed file", Tinify\Source::fromFile($this->dummyFile)->toBuffer()); + $this->assertSame("compressed file", Tinify\Source::fromFile(DUMMY_FILE_LOCATION)->toBuffer()); } public function testWithValidApiKeyFromBufferShouldReturnSource() { diff --git a/test/TinifyTest.php b/test/TinifyTest.php index 2a2ed71..e999668 100644 --- a/test/TinifyTest.php +++ b/test/TinifyTest.php @@ -3,13 +3,6 @@ use Tinify\CurlMock; class ClientTest extends TestCase { - private $dummyFile; - - public function setUp() { - parent::setUp(); - $this->dummyFile = __DIR__ . "/examples/dummy.png"; - } - public function testKeyShouldResetClientWithNewKey() { CurlMock::register("https://api.tinify.com/", array("status" => 200)); Tinify\setKey("abcde"); @@ -98,7 +91,7 @@ public function testFromFileShouldReturnSource() { "status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location") )); Tinify\setKey("valid"); - $this->assertInstanceOf("Tinify\Source", Tinify\fromFile($this->dummyFile)); + $this->assertInstanceOf("Tinify\Source", Tinify\fromFile(DUMMY_FILE_LOCATION)); } public function testFromBufferShouldReturnSource() { diff --git a/test/base/test_case_1.php b/test/base/test_case_1.php new file mode 100644 index 0000000..3a2082b --- /dev/null +++ b/test/base/test_case_1.php @@ -0,0 +1,12 @@ += 0) { + require_once("base" . DIRECTORY_SEPARATOR . "test_case_2.php"); + class_alias('TestCase_2', 'TestCase'); +} else { + require_once("base" . DIRECTORY_SEPARATOR . "test_case_1.php"); + class_alias('TestCase_1', 'TestCase'); +} + +define('DUMMY_FILE_LOCATION', dirname(__DIR__) . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'examples' . DIRECTORY_SEPARATOR . 'dummy.png'); diff --git a/test/helper.php b/test/helper.php deleted file mode 100644 index a2536ce..0000000 --- a/test/helper.php +++ /dev/null @@ -1,16 +0,0 @@ -assertLessThan(1500, $size); /* width == 137 */ - $this->assertContains("\0\0\0\x89", $contents); - $this->assertNotContains("Copyright Voormedia", $contents); + $this->assertStringContainsString("\0\0\0\x89", $contents); + $this->assertStringNotContainsString("Copyright Voormedia", $contents); } public function testShouldCompressFromUrl() { @@ -43,8 +44,8 @@ public function testShouldCompressFromUrl() { $this->assertLessThan(1500, $size); /* width == 137 */ - $this->assertContains("\0\0\0\x89", $contents); - $this->assertNotContains("Copyright Voormedia", $contents); + $this->assertStringContainsString("\0\0\0\x89", $contents); + $this->assertStringNotContainsString("Copyright Voormedia", $contents); } public function testShouldResize() { @@ -58,8 +59,8 @@ public function testShouldResize() { $this->assertLessThan(1000, $size); /* width == 50 */ - $this->assertContains("\0\0\0\x32", $contents); - $this->assertNotContains("Copyright Voormedia", $contents); + $this->assertStringContainsString("\0\0\0\x32", $contents); + $this->assertStringNotContainsString("Copyright Voormedia", $contents); } public function testShouldPreserveMetadata() { @@ -73,7 +74,7 @@ public function testShouldPreserveMetadata() { $this->assertLessThan(2000, $size); /* width == 137 */ - $this->assertContains("\0\0\0\x89", $contents); - $this->assertContains("Copyright Voormedia", $contents); + $this->assertStringContainsString("\0\0\0\x89", $contents); + $this->assertStringContainsString("Copyright Voormedia", $contents); } } From 54649b13695387559928d7d66f8f5829220d17ce Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Tue, 26 Jul 2022 15:03:48 +0200 Subject: [PATCH 04/23] CI/CD github workflow --- .github/workflows/ci-cd.yaml | 34 +++++++++++++++++++++++++--------- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 8c27594..179cdc2 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -18,7 +18,7 @@ jobs: "8.0", "8.1", ] - os: [ubuntu-latest] # , macOS-latest, windows-latest] + os: [ubuntu-latest, macOS-latest, windows-latest] steps: - uses: shivammathur/setup-php@2.21.0 with: @@ -27,15 +27,31 @@ jobs: - uses: actions/checkout@v3 - name: Validate composer.json and composer.lock run: composer validate --strict - # - name: Cache Composer packages - # id: composer-cache - # uses: actions/cache@v3 - # with: - # path: vendor - # key: ${{ matrix.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} - # restore-keys: | - # ${{ matrix.os }}-php-${{ matrix.php-version }}- - name: Install Dependencies run: composer install --no-ansi --no-interaction --no-progress - name: Run test suite run: vendor/bin/phpunit + Integration_tests: + runs-on: ${{ matrix.os }} + timeout-minutes: 10 + needs: Unit_tests + strategy: + fail-fast: false + matrix: + php-version: [ + "7.4", + "8.1", + ] + os: [ubuntu-latest, macOS-latest, windows-latest] + steps: + - uses: shivammathur/setup-php@2.21.0 + with: + php-version: ${{ matrix.php-version }} + tools: composer:v2 + - uses: actions/checkout@v3 + - name: Install Dependencies + run: composer install --no-ansi --no-interaction --no-progress + - name: Run test suite + env: + TINIFY_KEY: ${{ secrets.TINIFY_KEY }} + run: vendor/bin/phpunit --no-configuration test/integration.php From e4863978ac1318b70885cd2bc1983b53231440cc Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Wed, 27 Jul 2022 10:21:41 +0200 Subject: [PATCH 05/23] Update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 22d0d82..d769eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ vendor +.phpunit.result.cache +composer.lock From afa9fc688730c3dae9fb7fb1e06cb612735eb0c9 Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Wed, 27 Jul 2022 10:38:51 +0200 Subject: [PATCH 06/23] Add badges to README --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index ac14496..a45f1c5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ -[Build Status](https://travis-ci.org/tinify/tinify-php) +[![MIT License](http://img.shields.io/badge/license-MIT-green.svg) ](https://github.com/tinify/tinify-php/blob/main/LICENSE) +[![CI](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yml) +[![Packagist Version](https://img.shields.io/packagist/v/tinify/tinify)](https://packagist.org/packages/tinify/tinify) +[![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/tinify/tinify)](https://packagist.org/packages/tinify/tinify) # Tinify API client for PHP From ea4f0d713dfc1f9919b4a5094bcd0dab667d845f Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 15 Aug 2022 14:59:42 +0200 Subject: [PATCH 07/23] Update CI/CD badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a45f1c5..8c361f8 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![MIT License](http://img.shields.io/badge/license-MIT-green.svg) ](https://github.com/tinify/tinify-php/blob/main/LICENSE) -[![CI](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yml) +[![CI_CD](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yaml/badge.svg)](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yaml) [![Packagist Version](https://img.shields.io/packagist/v/tinify/tinify)](https://packagist.org/packages/tinify/tinify) [![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/tinify/tinify)](https://packagist.org/packages/tinify/tinify) From 33abdf69c83b0179ef35d44ee37f6c281c518fa7 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 15 Aug 2022 15:06:23 +0200 Subject: [PATCH 08/23] Update CI/CD badge again --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8c361f8..59d5030 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![MIT License](http://img.shields.io/badge/license-MIT-green.svg) ](https://github.com/tinify/tinify-php/blob/main/LICENSE) -[![CI_CD](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yaml/badge.svg)](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yaml) +[![CI_CD](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yaml/badge.svg?branch=master)](https://github.com/tinify/tinify-php/actions/workflows/ci-cd.yaml) [![Packagist Version](https://img.shields.io/packagist/v/tinify/tinify)](https://packagist.org/packages/tinify/tinify) [![Packagist PHP Version Support](https://img.shields.io/packagist/php-v/tinify/tinify)](https://packagist.org/packages/tinify/tinify) From f10dffd285d17a9d80b14d953bd79d5f0152fa29 Mon Sep 17 00:00:00 2001 From: Yekta Turan Date: Thu, 1 Sep 2022 11:54:35 +0200 Subject: [PATCH 09/23] Updated request function not to overwrite request body and created test case. --- lib/Tinify/Client.php | 6 +++--- test/TinifyClientTest.php | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/Tinify/Client.php b/lib/Tinify/Client.php index cc3cce3..80baed0 100644 --- a/lib/Tinify/Client.php +++ b/lib/Tinify/Client.php @@ -110,17 +110,17 @@ function request($method, $url, $body = NULL) { curl_close($request); $headers = self::parseHeaders(substr($response, 0, $headerSize)); - $body = substr($response, $headerSize); + $responseBody = substr($response, $headerSize); if (isset($headers["compression-count"])) { Tinify::setCompressionCount(intval($headers["compression-count"])); } if ($status >= 200 && $status <= 299) { - return (object) array("body" => $body, "headers" => $headers); + return (object) array("body" => $responseBody, "headers" => $headers); } - $details = json_decode($body); + $details = json_decode($responseBody); if (!$details) { $message = sprintf("Error while parsing response: %s (#%d)", PHP_VERSION_ID >= 50500 ? json_last_error_msg() : "Error", diff --git a/test/TinifyClientTest.php b/test/TinifyClientTest.php index 0747b01..8cb6761 100644 --- a/test/TinifyClientTest.php +++ b/test/TinifyClientTest.php @@ -161,6 +161,19 @@ public function testRequestWithServerErrorRepeatedlyShouldThrowServerException() $client->request("get", "/"); } + public function testRequestWithBodyAndServerErrorRepeatedlyShouldThrowServerException() { + CurlMock::register("https://api.tinify.com/", array( + "body" => '{"email":"user@gmail.com"}' + ), array( + "status" => 500, "body" => '{"error":"InternalServerError","message":"Oops!"}' + )); + + $this->setExpectedException("Tinify\ServerException"); + $client = new Tinify\Client("key"); + $response = $client->request("post", "/", array("email"=> "user@gmail.com")); + $this->assertEquals("", $response->body); + } + public function testRequestWithServerErrorRepeatedlyShouldThrowExceptionWithMessage() { CurlMock::register("https://api.tinify.com/", array( "status" => 584, "body" => '{"error":"InternalServerError","message":"Oops!"}' From 6ba7c59f5387910107fbead690b5e5e94a597cd2 Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Tue, 20 Sep 2022 14:00:38 +0200 Subject: [PATCH 10/23] Only run integration tests on push --- .github/workflows/ci-cd.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 179cdc2..b099c92 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -1,5 +1,5 @@ --- -name: CI_CD +name: PHP CI/CD on: [push, pull_request] @@ -32,6 +32,7 @@ jobs: - name: Run test suite run: vendor/bin/phpunit Integration_tests: + if: github.event_name == 'push' runs-on: ${{ matrix.os }} timeout-minutes: 10 needs: Unit_tests From 5e6f233171ea76d46dde1bb1918c08e9b86ca49c Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Wed, 27 Jul 2022 15:34:02 +0200 Subject: [PATCH 11/23] Add transcoding API to client --- lib/Tinify/Source.php | 10 +++++++ test/TinifySourceTest.php | 60 +++++++++++++++++++++++++++++++++++++++ test/integration.php | 11 +++++++ 3 files changed, 81 insertions(+) diff --git a/lib/Tinify/Source.php b/lib/Tinify/Source.php index 01c013f..5c20e9c 100644 --- a/lib/Tinify/Source.php +++ b/lib/Tinify/Source.php @@ -42,6 +42,16 @@ public function store($options) { return new Result($response->headers, $response->body); } + public function transcode($types) { + $commands = array_merge($this->commands, array("type" => $types)); + return new self($this->url, $commands); + } + + public function transform($options) { + $commands = array_merge($this->commands, array("transform" => $options)); + return new self($this->url, $commands); + } + public function result() { $response = Tinify::getClient()->request("get", $this->url, $this->commands); return new Result($response->headers, $response->body); diff --git a/test/TinifySourceTest.php b/test/TinifySourceTest.php index 67c8e07..0833179 100644 --- a/test/TinifySourceTest.php +++ b/test/TinifySourceTest.php @@ -226,6 +226,66 @@ public function testWithValidApiKeyResizeShouldReturnSourceWithData() { $this->assertSame("{\"resize\":{\"width\":400}}", CurlMock::last(CURLOPT_POSTFIELDS)); } + public function testTranscodeShouldReturnSource() { + Tinify\setKey("valid"); + + CurlMock::register("https://api.tinify.com/shrink", array( + "status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location") + )); + + CurlMock::register("https://api.tinify.com/some/location", array( + "status" => 200, "body" => "transcoded file" + )); + + $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromBuffer("png file")->transcode("image/webp")); + $this->assertSame("png file", CurlMock::last(CURLOPT_POSTFIELDS)); + } + + public function testTranscodeShouldReturnSourceWithData() { + Tinify\setKey("valid"); + + CurlMock::register("https://api.tinify.com/shrink", array( + "status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location") + )); + + CurlMock::register("https://api.tinify.com/some/location", array( + "status" => 200, "body" => "transcoded file" + )); + + $this->assertSame("transcoded file", Tinify\Source::fromBuffer("png file")->transcode("image/webp")->toBuffer()); + $this->assertSame("{\"type\":\"image\/webp\"}", CurlMock::last(CURLOPT_POSTFIELDS)); + } + + public function testTransformShouldReturnSource() { + Tinify\setKey("valid"); + + CurlMock::register("https://api.tinify.com/shrink", array( + "status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location") + )); + + CurlMock::register("https://api.tinify.com/some/location", array( + "status" => 200, "body" => "transformed file" + )); + + $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromBuffer("png file")->transform(array("background" => "black"))); + $this->assertSame("png file", CurlMock::last(CURLOPT_POSTFIELDS)); + } + + public function testTransformShouldReturnSourceWithData() { + Tinify\setKey("valid"); + + CurlMock::register("https://api.tinify.com/shrink", array( + "status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location") + )); + + CurlMock::register("https://api.tinify.com/some/location", array( + "status" => 200, "body" => "transformd file" + )); + + $this->assertSame("transformd file", Tinify\Source::fromBuffer("png file")->transform(array("background" => "black"))->toBuffer()); + $this->assertSame("{\"transform\":{\"background\":\"black\"}}", CurlMock::last(CURLOPT_POSTFIELDS)); + } + public function testWithValidApiKeyStoreShouldReturnResultMeta() { Tinify\setKey("valid"); diff --git a/test/integration.php b/test/integration.php index bf780bd..7167315 100644 --- a/test/integration.php +++ b/test/integration.php @@ -77,4 +77,15 @@ public function testShouldPreserveMetadata() { $this->assertStringContainsString("\0\0\0\x89", $contents); $this->assertStringContainsString("Copyright Voormedia", $contents); } + + public function testShouldTranscode() { + $path = tempnam(sys_get_temp_dir(), "tinify-php"); + self::$optimized->transcode(["image/webp"])->toFile($path); + + $size = filesize($path); + $contents = fread(fopen($path, "rb"), $size); + + $this->assertEquals(substr($contents, 0, 4), "RIFF"); + $this->assertEquals(substr($contents, 8, 4), "WEBP"); + } } From 420702fff22172206bc591df9f7650f950f4ded2 Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Wed, 27 Jul 2022 15:34:59 +0200 Subject: [PATCH 12/23] Simplify test names --- test/TinifySourceTest.php | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/test/TinifySourceTest.php b/test/TinifySourceTest.php index 0833179..786bc81 100644 --- a/test/TinifySourceTest.php +++ b/test/TinifySourceTest.php @@ -36,7 +36,7 @@ public function testWithInvalidApiKeyFromUrlShouldThrowAccountException() { Tinify\Source::fromUrl("http://example.com/test.jpg"); } - public function testWithValidApiKeyFromFileShouldReturnSource() { + public function testFromFileShouldReturnSource() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -46,7 +46,7 @@ public function testWithValidApiKeyFromFileShouldReturnSource() { $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromFile(DUMMY_FILE_LOCATION)); } - public function testWithValidApiKeyFromFileShouldReturnSourceWithData() { + public function testFromFileShouldReturnSourceWithData() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -60,7 +60,7 @@ public function testWithValidApiKeyFromFileShouldReturnSourceWithData() { $this->assertSame("compressed file", Tinify\Source::fromFile(DUMMY_FILE_LOCATION)->toBuffer()); } - public function testWithValidApiKeyFromBufferShouldReturnSource() { + public function testFromBufferShouldReturnSource() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -70,7 +70,7 @@ public function testWithValidApiKeyFromBufferShouldReturnSource() { $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromBuffer("png file")); } - public function testWithValidApiKeyFromBufferShouldReturnSourceWithData() { + public function testFromBufferShouldReturnSourceWithData() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -84,17 +84,17 @@ public function testWithValidApiKeyFromBufferShouldReturnSourceWithData() { $this->assertSame("compressed file", Tinify\Source::fromBuffer("png file")->toBuffer()); } - public function testWithValidApiKeyFromUrlShouldReturnSource() { + public function testFromUrlShouldReturnSource() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( "status" => 201, "headers" => array("Location" => "https://api.tinify.com/some/location") )); - $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromUrl("http://example.com/testWithValidApiKey.jpg")); + $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromUrl("http://example.com/test.jpg")); } - public function testWithValidApiKeyFromUrlShouldReturnSourceWithData() { + public function testFromUrlShouldReturnSourceWithData() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -105,10 +105,10 @@ public function testWithValidApiKeyFromUrlShouldReturnSourceWithData() { "status" => 200, "body" => "compressed file" )); - $this->assertSame("compressed file", Tinify\Source::fromUrl("http://example.com/testWithValidApiKey.jpg")->toBuffer()); + $this->assertSame("compressed file", Tinify\Source::fromUrl("http://example.com/test.jpg")->toBuffer()); } - public function testWithValidApiKeyFromUrlShouldThrowExceptionIfRequestIsNotOK() { + public function testFromUrlShouldThrowExceptionIfRequestIsNotOK() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -119,7 +119,7 @@ public function testWithValidApiKeyFromUrlShouldThrowExceptionIfRequestIsNotOK() Tinify\Source::fromUrl("file://wrong"); } - public function testWithValidApiKeyResultShouldReturnResult() { + public function testResultShouldReturnResult() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -134,7 +134,7 @@ public function testWithValidApiKeyResultShouldReturnResult() { $this->assertInstanceOf("Tinify\Result", Tinify\Source::fromBuffer("png file")->result()); } - public function testWithValidApiKeyPreserveShouldReturnSource() { + public function testPreserveShouldReturnSource() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -149,7 +149,7 @@ public function testWithValidApiKeyPreserveShouldReturnSource() { $this->assertSame("png file", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyPreserveShouldReturnSourceWithData() { + public function testPreserveShouldReturnSourceWithData() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -164,7 +164,7 @@ public function testWithValidApiKeyPreserveShouldReturnSourceWithData() { $this->assertSame("{\"preserve\":[\"copyright\",\"location\"]}", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyPreserveShouldReturnSourceWithDataForArray() { + public function testPreserveShouldReturnSourceWithDataForArray() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -179,7 +179,7 @@ public function testWithValidApiKeyPreserveShouldReturnSourceWithDataForArray() $this->assertSame("{\"preserve\":[\"copyright\",\"location\"]}", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyPreserveShouldIncludeOtherOptionsIfSet() { + public function testPreserveShouldIncludeOtherOptionsIfSet() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -196,7 +196,7 @@ public function testWithValidApiKeyPreserveShouldIncludeOtherOptionsIfSet() { $this->assertSame("{\"resize\":{\"width\":400},\"preserve\":[\"copyright\",\"location\"]}", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyResizeShouldReturnSource() { + public function testResizeShouldReturnSource() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -211,7 +211,7 @@ public function testWithValidApiKeyResizeShouldReturnSource() { $this->assertSame("png file", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyResizeShouldReturnSourceWithData() { + public function testResizeShouldReturnSourceWithData() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -286,7 +286,7 @@ public function testTransformShouldReturnSourceWithData() { $this->assertSame("{\"transform\":{\"background\":\"black\"}}", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyStoreShouldReturnResultMeta() { + public function testStoreShouldReturnResultMeta() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -303,7 +303,7 @@ public function testWithValidApiKeyStoreShouldReturnResultMeta() { $this->assertSame("{\"store\":{\"service\":\"s3\",\"aws_secret_access_key\":\"abcde\"}}", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyStoreShouldReturnResultMetaWithLocation() { + public function testStoreShouldReturnResultMetaWithLocation() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -323,7 +323,7 @@ public function testWithValidApiKeyStoreShouldReturnResultMetaWithLocation() { $this->assertSame("{\"store\":{\"service\":\"s3\"}}", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyStoreShouldIncludeOtherOptionsIfSet() { + public function testStoreShouldIncludeOtherOptionsIfSet() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -340,7 +340,7 @@ public function testWithValidApiKeyStoreShouldIncludeOtherOptionsIfSet() { $this->assertSame("{\"resize\":{\"width\":300},\"store\":{\"service\":\"s3\",\"aws_secret_access_key\":\"abcde\"}}", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testWithValidApiKeyToBufferShouldReturnImageData() { + public function testToBufferShouldReturnImageData() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -353,7 +353,7 @@ public function testWithValidApiKeyToBufferShouldReturnImageData() { $this->assertSame("compressed file", Tinify\Source::fromBuffer("png file")->toBuffer()); } - public function testWithValidApiKeyToFileShouldStoreImageData() { + public function testToFileShouldStoreImageData() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( From a0644b5b80b2fe3e9b3ed1ae9e863b4fddaa825d Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Mon, 15 Aug 2022 15:05:15 +0200 Subject: [PATCH 13/23] Update CHANGELOG and bump version --- CHANGES.md | 4 ++++ lib/Tinify.php | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index c0c95e0..3322978 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +## 1.6.0 +* Support to run the unittests on newer versions of PHP (5.5 +) +* Add API methods for transcoding and transformation + ## 1.5.2 * Fail early if version of curl/openssl is too old. diff --git a/lib/Tinify.php b/lib/Tinify.php index 8d44685..f6f9b0c 100644 --- a/lib/Tinify.php +++ b/lib/Tinify.php @@ -2,7 +2,7 @@ namespace Tinify; -const VERSION = "1.5.2"; +const VERSION = "1.6.0"; class Tinify { private static $key = NULL; From b52710696d27bfef9ffc5ead0899d0e33fdf3abf Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Tue, 20 Sep 2022 14:11:32 +0200 Subject: [PATCH 14/23] Change transcode to convert --- lib/Tinify/Source.php | 4 ++-- test/TinifySourceTest.php | 14 +++++++------- test/integration.php | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Tinify/Source.php b/lib/Tinify/Source.php index 5c20e9c..304040a 100644 --- a/lib/Tinify/Source.php +++ b/lib/Tinify/Source.php @@ -42,8 +42,8 @@ public function store($options) { return new Result($response->headers, $response->body); } - public function transcode($types) { - $commands = array_merge($this->commands, array("type" => $types)); + public function convert($options) { + $commands = array_merge($this->commands, array("convert" => $options)); return new self($this->url, $commands); } diff --git a/test/TinifySourceTest.php b/test/TinifySourceTest.php index 786bc81..80c5fd8 100644 --- a/test/TinifySourceTest.php +++ b/test/TinifySourceTest.php @@ -226,7 +226,7 @@ public function testResizeShouldReturnSourceWithData() { $this->assertSame("{\"resize\":{\"width\":400}}", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testTranscodeShouldReturnSource() { + public function testConvertShouldReturnSource() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -234,14 +234,14 @@ public function testTranscodeShouldReturnSource() { )); CurlMock::register("https://api.tinify.com/some/location", array( - "status" => 200, "body" => "transcoded file" + "status" => 200, "body" => "Convertd file" )); - $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromBuffer("png file")->transcode("image/webp")); + $this->assertInstanceOf("Tinify\Source", Tinify\Source::fromBuffer("png file")->Convert(array("type" =>"image/webp"))); $this->assertSame("png file", CurlMock::last(CURLOPT_POSTFIELDS)); } - public function testTranscodeShouldReturnSourceWithData() { + public function testConvertShouldReturnSourceWithData() { Tinify\setKey("valid"); CurlMock::register("https://api.tinify.com/shrink", array( @@ -249,11 +249,11 @@ public function testTranscodeShouldReturnSourceWithData() { )); CurlMock::register("https://api.tinify.com/some/location", array( - "status" => 200, "body" => "transcoded file" + "status" => 200, "body" => "Convertd file" )); - $this->assertSame("transcoded file", Tinify\Source::fromBuffer("png file")->transcode("image/webp")->toBuffer()); - $this->assertSame("{\"type\":\"image\/webp\"}", CurlMock::last(CURLOPT_POSTFIELDS)); + $this->assertSame("Convertd file", Tinify\Source::fromBuffer("png file")->convert(array("type" => "image/webp"))->toBuffer()); + $this->assertSame("{\"convert\":{\"type\":\"image\/webp\"}}", CurlMock::last(CURLOPT_POSTFIELDS)); } public function testTransformShouldReturnSource() { diff --git a/test/integration.php b/test/integration.php index 7167315..32226ac 100644 --- a/test/integration.php +++ b/test/integration.php @@ -78,9 +78,9 @@ public function testShouldPreserveMetadata() { $this->assertStringContainsString("Copyright Voormedia", $contents); } - public function testShouldTranscode() { + public function testShouldConvert() { $path = tempnam(sys_get_temp_dir(), "tinify-php"); - self::$optimized->transcode(["image/webp"])->toFile($path); + self::$optimized->convert(array("type" => ["image/webp"]))->toFile($path); $size = filesize($path); $contents = fread(fopen($path, "rb"), $size); From 2165f0b60c19492852d054510dcefb48a783481a Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Tue, 20 Sep 2022 14:18:59 +0200 Subject: [PATCH 15/23] Add method for returning file extension --- CHANGES.md | 3 ++- lib/Tinify/ResultMeta.php | 8 ++++++++ test/TinifyResultTest.php | 10 ++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 3322978..75d5cc8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ ## 1.6.0 * Support to run the unittests on newer versions of PHP (5.5 +) -* Add API methods for transcoding and transformation +* Add API methods for converting/transcoding and transformation +* Add helper function for returning the compressed file extension ## 1.5.2 * Fail early if version of curl/openssl is too old. diff --git a/lib/Tinify/ResultMeta.php b/lib/Tinify/ResultMeta.php index 337a48f..27aba0e 100644 --- a/lib/Tinify/ResultMeta.php +++ b/lib/Tinify/ResultMeta.php @@ -20,4 +20,12 @@ public function height() { public function location() { return isset($this->meta["location"]) ? $this->meta["location"] : null; } + + public function extension() { + if (isset($this->meta["content-type"])) { + $parts = explode("/", $this->meta["content-type"]); + return end($parts); + } + return null; + } } diff --git a/test/TinifyResultTest.php b/test/TinifyResultTest.php index 81687c5..94e3406 100644 --- a/test/TinifyResultTest.php +++ b/test/TinifyResultTest.php @@ -32,4 +32,14 @@ public function testWithMetaAndDataToBufferShouldReturnImageData() { $result = new Tinify\Result(array(), "image data"); $this->assertSame("image data", $result->toBuffer()); } + + public function testWithMetadataReturnsExtension() { + $result = new Tinify\Result(array("content-type" => "image/png"), "image data"); + $this->assertSame($result->extension(), "png"); + } + + public function testWithoutMetadataReturnsExtensionAsNull() { + $result = new Tinify\ResultMeta(array(), "image data"); + $this->assertSame($result->extension(), null); + } } From 5ee20a3deede3ad8e01244e52d2299be50f575b0 Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Mon, 20 Feb 2023 10:58:25 +0100 Subject: [PATCH 16/23] Update runner from PHP 8.1 to 8.2 --- .github/workflows/ci-cd.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index b099c92..0452f0e 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -16,7 +16,7 @@ jobs: "5.6", "7.4", "8.0", - "8.1", + "8.2", ] os: [ubuntu-latest, macOS-latest, windows-latest] steps: @@ -41,7 +41,7 @@ jobs: matrix: php-version: [ "7.4", - "8.1", + "8.2", ] os: [ubuntu-latest, macOS-latest, windows-latest] steps: From bb68f48d3056654f431a49b61b2f1636e8c30482 Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Mon, 20 Feb 2023 10:59:08 +0100 Subject: [PATCH 17/23] String interpolation fix: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation --- lib/Tinify/Client.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Tinify/Client.php b/lib/Tinify/Client.php index 80baed0..9ec17a3 100644 --- a/lib/Tinify/Client.php +++ b/lib/Tinify/Client.php @@ -28,7 +28,7 @@ function __construct($key, $app_identifier = NULL, $proxy = NULL) { if ($curl["version_number"] < 0x071201) { $version = $curl["version"]; - throw new ClientException("Your curl version ${version} is outdated; please upgrade to 7.18.1 or higher"); + throw new ClientException("Your curl version {$version} is outdated; please upgrade to 7.18.1 or higher"); } $this->options = array( From 1a0623b1b10d49864b01867e7bbe1bb5dc285c1f Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Mon, 20 Feb 2023 11:07:33 +0100 Subject: [PATCH 18/23] Bump version to 1.6.1 --- CHANGES.md | 3 +++ lib/Tinify.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 75d5cc8..ff56a96 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,6 @@ +## 1.6.1 +Fixed string interpolation for php 8.2: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation + ## 1.6.0 * Support to run the unittests on newer versions of PHP (5.5 +) * Add API methods for converting/transcoding and transformation diff --git a/lib/Tinify.php b/lib/Tinify.php index f6f9b0c..3c258f6 100644 --- a/lib/Tinify.php +++ b/lib/Tinify.php @@ -2,7 +2,7 @@ namespace Tinify; -const VERSION = "1.6.0"; +const VERSION = "1.6.1"; class Tinify { private static $key = NULL; From aa9584121a02d4293bec50e5d2712c09508a318c Mon Sep 17 00:00:00 2001 From: momala454 Date: Thu, 23 Jan 2025 11:01:57 +0100 Subject: [PATCH 19/23] Fix php 8.4 deprecation --- lib/Tinify/Client.php | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Tinify/Client.php b/lib/Tinify/Client.php index 9ec17a3..4dc820c 100644 --- a/lib/Tinify/Client.php +++ b/lib/Tinify/Client.php @@ -32,7 +32,6 @@ function __construct($key, $app_identifier = NULL, $proxy = NULL) { } $this->options = array( - CURLOPT_BINARYTRANSFER => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_HEADER => true, CURLOPT_USERPWD => "api:" . $key, From cd9338e475cee7e8f55c77ae7e6c1a86086b1968 Mon Sep 17 00:00:00 2001 From: Remco Date: Mon, 27 Jan 2025 16:22:35 +0100 Subject: [PATCH 20/23] Update PHP runner versions --- .github/workflows/ci-cd.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-cd.yaml b/.github/workflows/ci-cd.yaml index 0452f0e..d0ba89f 100644 --- a/.github/workflows/ci-cd.yaml +++ b/.github/workflows/ci-cd.yaml @@ -16,11 +16,11 @@ jobs: "5.6", "7.4", "8.0", - "8.2", + "8.4", ] os: [ubuntu-latest, macOS-latest, windows-latest] steps: - - uses: shivammathur/setup-php@2.21.0 + - uses: shivammathur/setup-php@2.32.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 @@ -41,11 +41,11 @@ jobs: matrix: php-version: [ "7.4", - "8.2", + "8.4", ] os: [ubuntu-latest, macOS-latest, windows-latest] steps: - - uses: shivammathur/setup-php@2.21.0 + - uses: shivammathur/setup-php@2.32.0 with: php-version: ${{ matrix.php-version }} tools: composer:v2 From 8386ac9b5d4068640ad9756a897ccd162597b8c1 Mon Sep 17 00:00:00 2001 From: Remco Koopmans Date: Mon, 27 Jan 2025 16:34:57 +0100 Subject: [PATCH 21/23] Bump version --- CHANGES.md | 5 ++++- lib/Tinify.php | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index ff56a96..fec117f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ +## 1.6.2 +* Remove deprecated curl constant (https://php.watch/versions/8.4/CURLOPT_BINARYTRANSFER-deprecated) + ## 1.6.1 -Fixed string interpolation for php 8.2: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation +* Fixed string interpolation for php 8.2: https://wiki.php.net/rfc/deprecate_dollar_brace_string_interpolation ## 1.6.0 * Support to run the unittests on newer versions of PHP (5.5 +) diff --git a/lib/Tinify.php b/lib/Tinify.php index 3c258f6..e2a970f 100644 --- a/lib/Tinify.php +++ b/lib/Tinify.php @@ -2,7 +2,7 @@ namespace Tinify; -const VERSION = "1.6.1"; +const VERSION = "1.6.2"; class Tinify { private static $key = NULL; From d71421ecce9e034524eacccb83bae710d8386cbe Mon Sep 17 00:00:00 2001 From: tijmen Date: Sat, 1 Feb 2025 14:04:16 +0100 Subject: [PATCH 22/23] Remove setup --- test/TinifyTest.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/test/TinifyTest.php b/test/TinifyTest.php index 3d3a63f..39348da 100644 --- a/test/TinifyTest.php +++ b/test/TinifyTest.php @@ -3,13 +3,6 @@ use Tinify\CurlMock; class ClientTest extends TestCase { - private $dummyFile; - - public function setUp() { - parent::setUp(); - $this->dummyFile = __DIR__ . "/examples/dummy.png"; - } - public function testGetKeyWithoutKeyShouldReturnNull() { $this->assertSame(NULL, Tinify\getKey()); } From a2117ceb3e1bcc49a9c712ab13f4055f32202606 Mon Sep 17 00:00:00 2001 From: tijmen Date: Tue, 4 Feb 2025 20:56:24 +0100 Subject: [PATCH 23/23] Remove status check --- lib/Tinify/Client.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/Tinify/Client.php b/lib/Tinify/Client.php index f67dc96..7c2bc03 100644 --- a/lib/Tinify/Client.php +++ b/lib/Tinify/Client.php @@ -113,7 +113,7 @@ function request($method, $url, $body = NULL) { $headers = self::parseHeaders(substr($response, 0, $headerSize)); $responseBody = substr($response, $headerSize); - if (isset($headers["compression-count"])) { + if ( isset($headers["compression-count"] ) ) { Tinify::setCompressionCount(intval($headers["compression-count"])); } @@ -124,10 +124,6 @@ function request($method, $url, $body = NULL) { if ( isset( $headers["paying-state"] ) ) { Tinify::setPayingState( $headers["paying-state"] ); } - - if ($status >= 200 && $status <= 299) { - return (object) array("body" => $responseBody, "headers" => $headers); - } $details = json_decode($responseBody); if (!$details) {