From b70efb61ec49a3515e015a478c111da7b2a873e1 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 1 Mar 2017 17:24:33 +0100 Subject: [PATCH 1/7] Updated to the latest test utilities and dropped humbug --- Makefile | 3 - composer.json | 12 +- composer.lock | 928 +++++++---------------------------------------- humbug.json.dist | 12 - 4 files changed, 138 insertions(+), 817 deletions(-) delete mode 100644 humbug.json.dist diff --git a/Makefile b/Makefile index 592211d..caa956c 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,3 @@ unit-coverage: ci-coverage: init composer ci-coverage - -mutation: - composer mutation diff --git a/composer.json b/composer.json index 911dffb..470cc8f 100644 --- a/composer.json +++ b/composer.json @@ -16,7 +16,7 @@ "react/promise": "^2.4" }, "require-dev": { - "api-clients/test-utilities": "^1.0", + "api-clients/test-utilities": "^3.0", "container-interop/container-interop": "^1.1", "guzzlehttp/psr7": "^1.3" }, @@ -54,10 +54,6 @@ "@ensure-installed", "phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml" ], - "mutation": [ - "@ensure-installed", - "if [ `php -m | grep xdebug | wc -l` -gt 0 ]; then humbug --ansi --incremental; fi" - ], "lint-php": [ "@ensure-installed", "parallel-lint --exclude vendor ." @@ -65,14 +61,12 @@ "qa-all": [ "@lint-php", "@cs", - "@unit", - "@mutation" + "@unit" ], "qa-all-coverage": [ "@lint-php", "@cs", - "@unit-coverage", - "@mutation" + "@unit-coverage" ], "qa-windows": [ "@lint-php", diff --git a/composer.lock b/composer.lock index 1f4f2bc..444c9ea 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "content-hash": "bb8aa6bb9df01026ee175883318d570d", + "content-hash": "276db0aba3a29236d8bcc66d34c32346", "packages": [ { "name": "psr/http-message", @@ -103,27 +103,25 @@ "packages-dev": [ { "name": "api-clients/test-utilities", - "version": "1.0.0", + "version": "3.0.1", "source": { "type": "git", "url": "https://github.com/php-api-clients/test-utilities.git", - "reference": "26e92e4c1bb132cd78d247fa210f2bb2308488f8" + "reference": "efab1bb505e04e4b9e3c995393451e0eebb9ba7d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-api-clients/test-utilities/zipball/26e92e4c1bb132cd78d247fa210f2bb2308488f8", - "reference": "26e92e4c1bb132cd78d247fa210f2bb2308488f8", + "url": "https://api.github.com/repos/php-api-clients/test-utilities/zipball/efab1bb505e04e4b9e3c995393451e0eebb9ba7d", + "reference": "efab1bb505e04e4b9e3c995393451e0eebb9ba7d", "shasum": "" }, "require": { "clue/block-react": "^1.1", - "humbug/humbug": "1.0.0-alpha2", "jakub-onderka/php-console-highlighter": "^0.3.2", "jakub-onderka/php-parallel-lint": "^0.9.2", "phake/phake": "^2.3", "php": "^7.0", - "phpspec/prophecy": "^1.6", - "phpunit/phpunit": "^5.6", + "phpunit/phpunit": "^6.0", "squizlabs/php_codesniffer": "^2.6" }, "type": "library", @@ -142,7 +140,7 @@ "email": "ceesjank@gmail.com" } ], - "time": "2016-12-04T22:25:39+00:00" + "time": "2017-02-04T10:56:09+00:00" }, { "name": "clue/block-react", @@ -194,18 +192,21 @@ }, { "name": "container-interop/container-interop", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/container-interop/container-interop.git", - "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e" + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/container-interop/container-interop/zipball/fc08354828f8fd3245f77a66b9e23a6bca48297e", - "reference": "fc08354828f8fd3245f77a66b9e23a6bca48297e", + "url": "https://api.github.com/repos/container-interop/container-interop/zipball/79cbf1341c22ec75643d841642dd5d6acd83bdb8", + "reference": "79cbf1341c22ec75643d841642dd5d6acd83bdb8", "shasum": "" }, + "require": { + "psr/container": "^1.0" + }, "type": "library", "autoload": { "psr-4": { @@ -217,7 +218,8 @@ "MIT" ], "description": "Promoting the interoperability of container objects (DIC, SL, etc.)", - "time": "2014-12-30T15:22:37+00:00" + "homepage": "https://github.com/container-interop/container-interop", + "time": "2017-02-14T19:40:03+00:00" }, { "name": "doctrine/instantiator", @@ -275,16 +277,16 @@ }, { "name": "guzzlehttp/psr7", - "version": "1.3.1", + "version": "1.4.1", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" + "reference": "0d6c7ca039329247e4f0f8f8f6506810e8248855" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/0d6c7ca039329247e4f0f8f8f6506810e8248855", + "reference": "0d6c7ca039329247e4f0f8f8f6506810e8248855", "shasum": "" }, "require": { @@ -320,83 +322,23 @@ "name": "Michael Dowling", "email": "mtdowling@gmail.com", "homepage": "https://github.com/mtdowling" + }, + { + "name": "Tobias Schultze", + "homepage": "https://github.com/Tobion" } ], - "description": "PSR-7 message implementation", + "description": "PSR-7 message implementation that also provides common utility methods", "keywords": [ "http", "message", + "request", + "response", "stream", - "uri" - ], - "time": "2016-06-24T23:00:38+00:00" - }, - { - "name": "humbug/humbug", - "version": "1.0.0-alpha2", - "source": { - "type": "git", - "url": "https://github.com/padraic/humbug.git", - "reference": "06b1c059e432dab8c22c36bc8b6e1ffc7e587c07" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/padraic/humbug/zipball/06b1c059e432dab8c22c36bc8b6e1ffc7e587c07", - "reference": "06b1c059e432dab8c22c36bc8b6e1ffc7e587c07", - "shasum": "" - }, - "require": { - "padraic/phar-updater": "^1.0.0", - "padraic/phpunit-accelerator": "^1.0.2", - "padraic/phpunit-extensions": "^1.0.0", - "php": ">=5.4.0", - "phpunit/phpunit": "^4.5|^5.0", - "sebastian/diff": "^1.1", - "symfony/console": "^2.6|^3.0", - "symfony/event-dispatcher": "^2.6|^3.0", - "symfony/finder": "^2.6|^3.0", - "symfony/process": "^2.6|^3.0" - }, - "require-dev": { - "behat/behat": "^3.0.15", - "mikey179/vfsstream": "^1.4", - "mockery/mockery": "^0.9", - "symfony/filesystem": "^2.6|^3.0" - }, - "bin": [ - "bin/humbug" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Humbug\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - } + "uri", + "url" ], - "description": "Humbug is a Mutation Testing framework for PHP. Whereas Code Coverage can tell you what code your tests are executing, Mutation Testing is intended to help you judge how well your unit tests actually perform and where they could be improved.", - "homepage": "https://github.com/padraic/humbug", - "keywords": [ - "coverage", - "mutation testing", - "testing", - "unit testing" - ], - "time": "2016-08-01T10:27:00+00:00" + "time": "2017-02-27T10:51:17+00:00" }, { "name": "jakub-onderka/php-console-color", @@ -534,16 +476,16 @@ }, { "name": "myclabs/deep-copy", - "version": "1.5.5", + "version": "1.6.0", "source": { "type": "git", "url": "https://github.com/myclabs/DeepCopy.git", - "reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108" + "reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/399c1f9781e222f6eb6cc238796f5200d1b7f108", - "reference": "399c1f9781e222f6eb6cc238796f5200d1b7f108", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/5a5a9fc8025a08d8919be87d6884d5a92520cefe", + "reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe", "shasum": "" }, "require": { @@ -572,221 +514,7 @@ "object", "object graph" ], - "time": "2016-10-31T17:19:45+00:00" - }, - { - "name": "padraic/humbug_get_contents", - "version": "1.0.4", - "source": { - "type": "git", - "url": "https://github.com/padraic/file_get_contents.git", - "reference": "66797199019d0cb4529cb8d29c6f0b4c5085b53a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/padraic/file_get_contents/zipball/66797199019d0cb4529cb8d29c6f0b4c5085b53a", - "reference": "66797199019d0cb4529cb8d29c6f0b4c5085b53a", - "shasum": "" - }, - "require": { - "php": ">=5.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Humbug\\": "src/Humbug/" - }, - "files": [ - "src/function.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - } - ], - "description": "Secure wrapper for accessing HTTPS resources with file_get_contents for PHP 5.3+", - "homepage": "https://github.com/padraic/file_get_contents", - "keywords": [ - "download", - "file_get_contents", - "http", - "https", - "ssl", - "tls" - ], - "time": "2015-04-22T18:45:00+00:00" - }, - { - "name": "padraic/phar-updater", - "version": "1.0.3", - "source": { - "type": "git", - "url": "https://github.com/padraic/phar-updater.git", - "reference": "c17eeb3887dc4269d1b4837dc875d39e9f8149a8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/padraic/phar-updater/zipball/c17eeb3887dc4269d1b4837dc875d39e9f8149a8", - "reference": "c17eeb3887dc4269d1b4837dc875d39e9f8149a8", - "shasum": "" - }, - "require": { - "padraic/humbug_get_contents": "^1.0", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Humbug\\SelfUpdate\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - } - ], - "description": "A thing to make PHAR self-updating easy and secure.", - "keywords": [ - "humbug", - "phar", - "self-update", - "update" - ], - "time": "2016-01-05T23:08:01+00:00" - }, - { - "name": "padraic/phpunit-accelerator", - "version": "v1.0.2", - "source": { - "type": "git", - "url": "https://github.com/padraic/phpunit-accelerator.git", - "reference": "0b3b58e6e9a794eec22df712776058850d5fe0c1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/padraic/phpunit-accelerator/zipball/0b3b58e6e9a794eec22df712776058850d5fe0c1", - "reference": "0b3b58e6e9a794eec22df712776058850d5fe0c1", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/phpunit": ">=3.7" - }, - "replace": { - "mybuilder/phpunit-accelerator": "1.0.x" - }, - "type": "library", - "autoload": { - "psr-4": { - "MyBuilder\\PhpunitAccelerator\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Keyvan Akbary", - "email": "keyvan@mybuilder.com", - "role": "Developer" - }, - { - "name": "Padraic Brady", - "email": "padraic.brady@gmail.com", - "role": "Contributor" - } - ], - "description": "PHPUnit Accelerator: Speeds up PHPUnit by freeing memory after test runs", - "keywords": [ - "accelerator", - "fast", - "free", - "memory", - "phpunit", - "property" - ], - "time": "2015-01-15T21:18:21+00:00" - }, - { - "name": "padraic/phpunit-extensions", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/padraic/phpunit-extensions.git", - "reference": "a6942fa3ada5487e1b9a409c235013a677c2689b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/padraic/phpunit-extensions/zipball/a6942fa3ada5487e1b9a409c235013a677c2689b", - "reference": "a6942fa3ada5487e1b9a409c235013a677c2689b", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "phpunit/phpunit": "^4.0|^5.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-0": { - "Humbug\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - } - ], - "description": "Collection of Listeners to log and manipulate test run order", - "keywords": [ - "extension", - "humbug", - "listener", - "phpunit", - "testing", - "tests" - ], - "time": "2016-01-06T12:16:20+00:00" + "time": "2017-01-26T22:05:40+00:00" }, { "name": "phake/phake", @@ -1057,40 +785,39 @@ }, { "name": "phpunit/php-code-coverage", - "version": "4.0.4", + "version": "5.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "c14196e64a78570034afd0b7a9f3757ba71c2a0a" + "reference": "3f10a2c8eed68b29cbbb54e29cc58cb31b077553" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/c14196e64a78570034afd0b7a9f3757ba71c2a0a", - "reference": "c14196e64a78570034afd0b7a9f3757ba71c2a0a", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/3f10a2c8eed68b29cbbb54e29cc58cb31b077553", + "reference": "3f10a2c8eed68b29cbbb54e29cc58cb31b077553", "shasum": "" }, "require": { - "php": "^5.6 || ^7.0", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "^1.4.2", - "sebastian/code-unit-reverse-lookup": "~1.0", - "sebastian/environment": "^1.3.2 || ^2.0", - "sebastian/version": "~1.0|~2.0" + "php": "^7.0", + "phpunit/php-file-iterator": "^1.3", + "phpunit/php-text-template": "^1.2", + "phpunit/php-token-stream": "^1.4.2 || ^2.0", + "sebastian/code-unit-reverse-lookup": "^1.0", + "sebastian/environment": "^2.0", + "sebastian/version": "^2.0" }, "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "^5.4" + "ext-xdebug": "^2.5", + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-dom": "*", - "ext-xdebug": ">=2.4.0", "ext-xmlwriter": "*" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "4.0.x-dev" + "dev-master": "5.0.x-dev" } }, "autoload": { @@ -1116,7 +843,7 @@ "testing", "xunit" ], - "time": "2016-12-20T15:22:42+00:00" + "time": "2017-02-23T07:27:58+00:00" }, { "name": "phpunit/php-file-iterator", @@ -1208,25 +935,30 @@ }, { "name": "phpunit/php-timer", - "version": "1.0.8", + "version": "1.0.9", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260" + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/38e9124049cf1a164f1e4537caf19c99bf1eb260", - "reference": "38e9124049cf1a164f1e4537caf19c99bf1eb260", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": "^5.3.3 || ^7.0" }, "require-dev": { - "phpunit/phpunit": "~4|~5" + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, "autoload": { "classmap": [ "src/" @@ -1248,20 +980,20 @@ "keywords": [ "timer" ], - "time": "2016-05-12T18:03:57+00:00" + "time": "2017-02-26T11:10:40+00:00" }, { "name": "phpunit/php-token-stream", - "version": "1.4.9", + "version": "1.4.11", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b" + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3b402f65a4cc90abf6e1104e388b896ce209631b", - "reference": "3b402f65a4cc90abf6e1104e388b896ce209631b", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/e03f8f67534427a787e21a385a67ec3ca6978ea7", + "reference": "e03f8f67534427a787e21a385a67ec3ca6978ea7", "shasum": "" }, "require": { @@ -1297,20 +1029,20 @@ "keywords": [ "tokenizer" ], - "time": "2016-11-15T14:06:22+00:00" + "time": "2017-02-27T10:12:30+00:00" }, { "name": "phpunit/phpunit", - "version": "5.7.4", + "version": "6.0.7", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09" + "reference": "4601a46c162eccadffc7d5a6b1f5334df5d99713" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/af91da3f2671006ff5d0628023de3b7ac4d1ef09", - "reference": "af91da3f2671006ff5d0628023de3b7ac4d1ef09", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4601a46c162eccadffc7d5a6b1f5334df5d99713", + "reference": "4601a46c162eccadffc7d5a6b1f5334df5d99713", "shasum": "" }, "require": { @@ -1319,33 +1051,33 @@ "ext-libxml": "*", "ext-mbstring": "*", "ext-xml": "*", - "myclabs/deep-copy": "~1.3", - "php": "^5.6 || ^7.0", + "myclabs/deep-copy": "^1.3", + "php": "^7.0", "phpspec/prophecy": "^1.6.2", - "phpunit/php-code-coverage": "^4.0.3", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", + "phpunit/php-code-coverage": "^5.0", + "phpunit/php-file-iterator": "^1.4", + "phpunit/php-text-template": "^1.2", "phpunit/php-timer": "^1.0.6", - "phpunit/phpunit-mock-objects": "^3.2", - "sebastian/comparator": "~1.2.2", - "sebastian/diff": "~1.2", - "sebastian/environment": "^1.3.4 || ^2.0", - "sebastian/exporter": "~2.0", - "sebastian/global-state": "^1.0 || ^2.0", - "sebastian/object-enumerator": "~2.0", - "sebastian/resource-operations": "~1.0", - "sebastian/version": "~1.0|~2.0", - "symfony/yaml": "~2.1|~3.0" + "phpunit/phpunit-mock-objects": "^4.0", + "sebastian/comparator": "^1.2.4", + "sebastian/diff": "^1.2", + "sebastian/environment": "^2.0", + "sebastian/exporter": "^2.0", + "sebastian/global-state": "^1.1", + "sebastian/object-enumerator": "^2.0", + "sebastian/resource-operations": "^1.0", + "sebastian/version": "^2.0" }, "conflict": { - "phpdocumentor/reflection-docblock": "3.0.2" + "phpdocumentor/reflection-docblock": "3.0.2", + "phpunit/dbunit": "<3.0" }, "require-dev": { "ext-pdo": "*" }, "suggest": { "ext-xdebug": "*", - "phpunit/php-invoker": "~1.1" + "phpunit/php-invoker": "^1.1" }, "bin": [ "phpunit" @@ -1353,7 +1085,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "5.7.x-dev" + "dev-master": "6.0.x-dev" } }, "autoload": { @@ -1379,33 +1111,33 @@ "testing", "xunit" ], - "time": "2016-12-13T16:19:44+00:00" + "time": "2017-02-19T07:25:12+00:00" }, { "name": "phpunit/phpunit-mock-objects", - "version": "3.4.3", + "version": "4.0.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24" + "reference": "3819745c44f3aff9518fd655f320c4535d541af7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", - "reference": "3ab72b65b39b491e0c011e2e09bb2206c2aa8e24", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/3819745c44f3aff9518fd655f320c4535d541af7", + "reference": "3819745c44f3aff9518fd655f320c4535d541af7", "shasum": "" }, "require": { "doctrine/instantiator": "^1.0.2", - "php": "^5.6 || ^7.0", + "php": "^7.0", "phpunit/php-text-template": "^1.2", - "sebastian/exporter": "^1.2 || ^2.0" + "sebastian/exporter": "^2.0" }, "conflict": { - "phpunit/phpunit": "<5.4.0" + "phpunit/phpunit": "<6.0" }, "require-dev": { - "phpunit/phpunit": "^5.4" + "phpunit/phpunit": "^6.0" }, "suggest": { "ext-soap": "*" @@ -1413,7 +1145,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.2.x-dev" + "dev-master": "4.0.x-dev" } }, "autoload": { @@ -1438,20 +1170,20 @@ "mock", "xunit" ], - "time": "2016-12-08T20:27:08+00:00" + "time": "2017-02-02T10:36:38+00:00" }, { - "name": "psr/log", - "version": "1.0.2", + "name": "psr/container", + "version": "1.0.0", "source": { "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" + "url": "https://github.com/php-fig/container.git", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", + "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", + "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", "shasum": "" }, "require": { @@ -1465,7 +1197,7 @@ }, "autoload": { "psr-4": { - "Psr\\Log\\": "Psr/Log/" + "Psr\\Container\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -1478,14 +1210,16 @@ "homepage": "http://www.php-fig.org/" } ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", "keywords": [ - "log", - "psr", - "psr-3" + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" ], - "time": "2016-10-10T12:19:37+00:00" + "time": "2017-02-14T16:28:37+00:00" }, { "name": "react/event-loop", @@ -1533,16 +1267,16 @@ }, { "name": "react/promise-timer", - "version": "v1.1.0", + "version": "v1.1.1", "source": { "type": "git", "url": "https://github.com/reactphp/promise-timer.git", - "reference": "6a46050d801688e08d1a550b97b1f3735505c62a" + "reference": "ddedc67bfd7f579fc83e66ff67e3564b179297dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/6a46050d801688e08d1a550b97b1f3735505c62a", - "reference": "6a46050d801688e08d1a550b97b1f3735505c62a", + "url": "https://api.github.com/repos/reactphp/promise-timer/zipball/ddedc67bfd7f579fc83e66ff67e3564b179297dd", + "reference": "ddedc67bfd7f579fc83e66ff67e3564b179297dd", "shasum": "" }, "require": { @@ -1579,7 +1313,7 @@ "timeout", "timer" ], - "time": "2016-02-29T19:03:45+00:00" + "time": "2016-12-27T08:12:19+00:00" }, { "name": "sebastian/code-unit-reverse-lookup", @@ -1628,16 +1362,16 @@ }, { "name": "sebastian/comparator", - "version": "1.2.2", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f" + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/6a1ed12e8b2409076ab22e3897126211ff8b1f7f", - "reference": "6a1ed12e8b2409076ab22e3897126211ff8b1f7f", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", "shasum": "" }, "require": { @@ -1688,7 +1422,7 @@ "compare", "equality" ], - "time": "2016-11-19T09:18:40+00:00" + "time": "2017-01-29T09:50:25+00:00" }, { "name": "sebastian/diff", @@ -1912,16 +1646,16 @@ }, { "name": "sebastian/object-enumerator", - "version": "2.0.0", + "version": "2.0.1", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/object-enumerator.git", - "reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35" + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", - "reference": "96f8a3f257b69e8128ad74d3a7fd464bcbaa3b35", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", "shasum": "" }, "require": { @@ -1954,7 +1688,7 @@ ], "description": "Traverses array structures and object graphs to enumerate all referenced objects", "homepage": "https://github.com/sebastianbergmann/object-enumerator/", - "time": "2016-11-19T07:35:10+00:00" + "time": "2017-02-18T15:18:39+00:00" }, { "name": "sebastian/recursion-context", @@ -2096,16 +1830,16 @@ }, { "name": "squizlabs/php_codesniffer", - "version": "2.7.1", + "version": "2.8.0", "source": { "type": "git", "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", - "reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f" + "reference": "86dd55a522238211f9f3631e3361703578941d9a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/9b324f3a1132459a7274a0ace2e1b766ba80930f", - "reference": "9b324f3a1132459a7274a0ace2e1b766ba80930f", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/86dd55a522238211f9f3631e3361703578941d9a", + "reference": "86dd55a522238211f9f3631e3361703578941d9a", "shasum": "" }, "require": { @@ -2170,399 +1904,7 @@ "phpcs", "standards" ], - "time": "2016-11-30T04:02:31+00:00" - }, - { - "name": "symfony/console", - "version": "v3.2.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/console.git", - "reference": "d12aa9ca20f4db83ec58410978dab6afcb9d6aaa" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/d12aa9ca20f4db83ec58410978dab6afcb9d6aaa", - "reference": "d12aa9ca20f4db83ec58410978dab6afcb9d6aaa", - "shasum": "" - }, - "require": { - "php": ">=5.5.9", - "symfony/debug": "~2.8|~3.0", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/filesystem": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" - }, - "suggest": { - "psr/log": "For using the console logger", - "symfony/event-dispatcher": "", - "symfony/filesystem": "", - "symfony/process": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Console\\": "" - }, - "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 Console Component", - "homepage": "https://symfony.com", - "time": "2016-12-11T14:34:22+00:00" - }, - { - "name": "symfony/debug", - "version": "v3.2.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "9f923e68d524a3095c5a2ae5fc7220c7cbc12231" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/9f923e68d524a3095c5a2ae5fc7220c7cbc12231", - "reference": "9f923e68d524a3095c5a2ae5fc7220c7cbc12231", - "shasum": "" - }, - "require": { - "php": ">=5.5.9", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" - }, - "require-dev": { - "symfony/class-loader": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "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 Debug Component", - "homepage": "https://symfony.com", - "time": "2016-11-16T22:18:16+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v3.2.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "e8f47a327c2f0fd5aa04fa60af2b693006ed7283" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/e8f47a327c2f0fd5aa04fa60af2b693006ed7283", - "reference": "e8f47a327c2f0fd5aa04fa60af2b693006ed7283", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.8|~3.0", - "symfony/dependency-injection": "~2.8|~3.0", - "symfony/expression-language": "~2.8|~3.0", - "symfony/stopwatch": "~2.8|~3.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "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 EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2016-10-13T06:29:04+00:00" - }, - { - "name": "symfony/finder", - "version": "v3.2.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b", - "reference": "a69cb5d455b4885ca376dc5bb3e1155cc8c08c4b", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Finder\\": "" - }, - "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 Finder Component", - "homepage": "https://symfony.com", - "time": "2016-12-13T09:39:43+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.3.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/e79d363049d1c2128f133a2667e4f4190904f7f4", - "reference": "e79d363049d1c2128f133a2667e4f4190904f7f4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2016-11-14T01:06:16+00:00" - }, - { - "name": "symfony/process", - "version": "v3.2.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "02ea84847aad71be7e32056408bb19f3a616cdd3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/02ea84847aad71be7e32056408bb19f3a616cdd3", - "reference": "02ea84847aad71be7e32056408bb19f3a616cdd3", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "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 Process Component", - "homepage": "https://symfony.com", - "time": "2016-11-24T10:40:28+00:00" - }, - { - "name": "symfony/yaml", - "version": "v3.2.1", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "a7095af4b97a0955f85c8989106c249fa649011f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/a7095af4b97a0955f85c8989106c249fa649011f", - "reference": "a7095af4b97a0955f85c8989106c249fa649011f", - "shasum": "" - }, - "require": { - "php": ">=5.5.9" - }, - "require-dev": { - "symfony/console": "~2.8|~3.0" - }, - "suggest": { - "symfony/console": "For validating YAML files using the lint command" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "3.2-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-12-10T10:07:06+00:00" + "time": "2017-02-02T03:30:00+00:00" }, { "name": "webmozart/assert", diff --git a/humbug.json.dist b/humbug.json.dist deleted file mode 100644 index 1264c49..0000000 --- a/humbug.json.dist +++ /dev/null @@ -1,12 +0,0 @@ -{ - "source": { - "directories": [ - "src" - ] - }, - "timeout": 10, - "logs": { - "text": "humbuglog.txt", - "json": "humbuglog.json" - } -} \ No newline at end of file From 17625e8e13deb2f4db6a1abfb31626f576829bea Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 1 Mar 2017 20:52:13 +0100 Subject: [PATCH 2/7] Added error to the middleware interface --- src/MiddlewareInterface.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/MiddlewareInterface.php b/src/MiddlewareInterface.php index 36f4c53..00ff8ae 100644 --- a/src/MiddlewareInterface.php +++ b/src/MiddlewareInterface.php @@ -5,6 +5,7 @@ use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use React\Promise\CancellablePromiseInterface; +use Throwable; /** * Middleware, when a new request is made an instance specifically for that request is made for each request. @@ -38,4 +39,14 @@ public function pre(RequestInterface $request, array $options = []): Cancellable * @return CancellablePromiseInterface */ public function post(ResponseInterface $response, array $options = []): CancellablePromiseInterface; + + /** + * Transform the throwable into another throwable or exception, + * but never turn it into a successful promise again. + * + * @param Throwable $throwable + * @param array $options + * @return CancellablePromiseInterface + */ + public function error(Throwable $throwable, array $options = []): CancellablePromiseInterface; } From 999f05018c04ac63c9eb6bee6569159a12f4c81e Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 1 Mar 2017 20:54:11 +0100 Subject: [PATCH 3/7] Adjusted for the new test utilities --- tests/Locator/ContainerLocatorTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/Locator/ContainerLocatorTest.php b/tests/Locator/ContainerLocatorTest.php index 8ceb075..e863829 100644 --- a/tests/Locator/ContainerLocatorTest.php +++ b/tests/Locator/ContainerLocatorTest.php @@ -4,9 +4,10 @@ use ApiClients\Foundation\Middleware\Locator\ContainerLocator; use ApiClients\Tests\Foundation\Middleware\DummyMiddleware; +use ApiClients\Tools\TestUtilities\TestCase; use Interop\Container\ContainerInterface; -class ContainerLocatorTest extends \PHPUnit_Framework_TestCase +class ContainerLocatorTest extends TestCase { public function testGetSuccess() { From f65083834943cff40c87396cb1cd407bfe8cb04c Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 1 Mar 2017 20:55:36 +0100 Subject: [PATCH 4/7] Updated appveyor config: https://github.com/php-api-clients/psr7-oauth1/pull/18 --- appveyor.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d51dda0..a7e6cce 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -19,9 +19,13 @@ environment: - dependencies: highest php_ver_target: 7.1 -## Cache composer bits +## Cache composer, chocolatey and php bits cache: - '%LOCALAPPDATA%\Composer\files -> composer.lock' + - composer.phar + - C:\ProgramData\chocolatey\bin -> .appveyor.yml + - C:\ProgramData\chocolatey\lib -> .appveyor.yml + - c:\tools\php -> .appveyor.yml ## Set up environment varriables init: @@ -33,7 +37,7 @@ init: ## Install PHP and composer, and run the appropriate composer command install: - IF EXIST c:\tools\php (SET PHP=0) - - ps: appveyor-retry cinst -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $Env:php_ver_target | Select-Object -first 1) -replace '[php|]','') + - ps: appveyor-retry cinst --params '""/InstallDir:C:\tools\php""' --ignore-checksums -y php --version ((choco search php --exact --all-versions -r | select-string -pattern $env:php_ver_target | sort { [version]($_ -split '\|' | select -last 1) } -Descending | Select-Object -first 1) -replace '[php|]','') - cd c:\tools\php - IF %PHP%==1 copy php.ini-production php.ini /Y - IF %PHP%==1 echo date.timezone="UTC" >> php.ini @@ -52,4 +56,4 @@ install: ## Run the actual test test_script: - cd c:\projects\php-project-workspace - - vendor/bin/phpunit -c phpunit.xml.dist + - vendor/bin/phpunit -c phpunit.xml.dist \ No newline at end of file From 2335ac875ff2d69645ef68dfbe10ecbafc6be11e Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 1 Mar 2017 22:02:59 +0100 Subject: [PATCH 5/7] ErrorTrait --- src/ErrorTrait.php | 21 +++++++++++++++++++++ tests/DummyMiddleware.php | 2 ++ tests/DummyMiddlewareTest.php | 18 +++++++++++++++--- 3 files changed, 38 insertions(+), 3 deletions(-) create mode 100644 src/ErrorTrait.php diff --git a/src/ErrorTrait.php b/src/ErrorTrait.php new file mode 100644 index 0000000..2cbd25c --- /dev/null +++ b/src/ErrorTrait.php @@ -0,0 +1,21 @@ +error($exception), + Factory::create() + ); + } } From f7873e12daf19f0fbb87cd3957b975276ed89fd0 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Wed, 1 Mar 2017 22:14:15 +0100 Subject: [PATCH 6/7] Middleware Runner --- src/MiddlewareRunner.php | 24 ++++++++++++++++++++++++ tests/MiddlewareRunnerTest.php | 16 +++++++++++++--- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/MiddlewareRunner.php b/src/MiddlewareRunner.php index d946b46..854aeae 100644 --- a/src/MiddlewareRunner.php +++ b/src/MiddlewareRunner.php @@ -5,6 +5,8 @@ use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; use React\Promise\CancellablePromiseInterface; +use Throwable; +use function React\Promise\reject; use function React\Promise\resolve; final class MiddlewareRunner @@ -84,4 +86,26 @@ public function post( return $promise; } + + /** + * @param Throwable $throwable + * @return CancellablePromiseInterface + */ + public function error( + Throwable $throwable + ): CancellablePromiseInterface { + + $promise = reject($throwable); + + $this->middlewares = array_reverse($this->middlewares); + + foreach ($this->middlewares as $middleware) { + $errorMiddleware = $middleware; + $promise = $promise->then(null, function (Throwable $throwable) use ($errorMiddleware) { + return reject($errorMiddleware->error($throwable, $this->options)); + }); + } + + return $promise; + } } diff --git a/tests/MiddlewareRunnerTest.php b/tests/MiddlewareRunnerTest.php index 0fc4345..b292be5 100644 --- a/tests/MiddlewareRunnerTest.php +++ b/tests/MiddlewareRunnerTest.php @@ -2,13 +2,15 @@ namespace ApiClients\Tests\Foundation\Middleware; -use ApiClients\Foundation\Middleware\MiddlewareRunner; use ApiClients\Foundation\Middleware\MiddlewareInterface; +use ApiClients\Foundation\Middleware\MiddlewareRunner; use ApiClients\Tools\TestUtilities\TestCase; -use function Clue\React\Block\await; +use Exception; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use Phake; +use function Clue\React\Block\await; +use function React\Promise\reject; use function React\Promise\resolve; class MiddlewareRunnerTest extends TestCase @@ -17,22 +19,26 @@ public function testAll() { $request = new Request('GET', 'https://example.com/'); $response = new Response(200); + $exception = new Exception(); $options = []; $middlewareOne = Phake::mock(MiddlewareInterface::class); Phake::when($middlewareOne)->priority()->thenReturn(1000); Phake::when($middlewareOne)->pre($request, $options)->thenReturn(resolve($request)); Phake::when($middlewareOne)->post($response, $options)->thenReturn(resolve($response)); + Phake::when($middlewareOne)->error($exception, $options)->thenReturn(reject($exception)); $middlewareTwo = Phake::mock(MiddlewareInterface::class); Phake::when($middlewareTwo)->priority()->thenReturn(500); Phake::when($middlewareTwo)->pre($request, $options)->thenReturn(resolve($request)); Phake::when($middlewareTwo)->post($response, $options)->thenReturn(resolve($response)); + Phake::when($middlewareTwo)->error($exception, $options)->thenReturn(reject($exception)); $middlewareThree = Phake::mock(MiddlewareInterface::class); Phake::when($middlewareThree)->priority()->thenReturn(0); Phake::when($middlewareThree)->pre($request, $options)->thenReturn(resolve($request)); Phake::when($middlewareThree)->post($response, $options)->thenReturn(resolve($response)); + Phake::when($middlewareThree)->error($exception, $options)->thenReturn(reject($exception)); $args = [ $options, @@ -44,6 +50,7 @@ public function testAll() $executioner = new MiddlewareRunner(...$args); $executioner->pre($request); $executioner->post($response); + $executioner->error($exception); Phake::inOrder( Phake::verify($middlewareOne)->pre($request, $options), @@ -51,7 +58,10 @@ public function testAll() Phake::verify($middlewareThree)->pre($request, $options), Phake::verify($middlewareThree)->post($response, $options), Phake::verify($middlewareTwo)->post($response, $options), - Phake::verify($middlewareOne)->post($response, $options) + Phake::verify($middlewareOne)->post($response, $options), + Phake::verify($middlewareOne)->error($exception, $options), + Phake::verify($middlewareTwo)->error($exception, $options), + Phake::verify($middlewareThree)->error($exception, $options) ); } } From af3dfcd63cf12c762f70f639393e4baaa6295e08 Mon Sep 17 00:00:00 2001 From: Cees-Jan Kiewiet Date: Fri, 3 Mar 2017 19:53:50 +0100 Subject: [PATCH 7/7] Updated documentation on error handling --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 66fa7be..e9014c4 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ Currently the only provided locator is the `ContainerLocator` which accepts a return resolve($response); })->then(function (ResponseInterface $response) use ($runner) { return $runner->post($response); + })->otherwise(function (Throwable $throwable) use ($runner) { + return reject($runner->error($throwable)); }); ```