diff --git a/.gitignore b/.gitignore index 8b6dcab8a..ea32386c1 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ web/js/site.js vendor/.git node_modules/ .DS_Store -web/inc \ No newline at end of file +web/inc +vendor/ \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 68aa0bb13..de7f7fc3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,13 +8,8 @@ matrix: include: - php: 5.6 - php: 7.3 - allow_failures: - - php: 7.3 fast_finish: true before_script: - - composer global require squizlabs/php_codesniffer - - composer global require phpunit/phpunit - - composer global require jakub-onderka/php-parallel-lint - composer install script: -- PATH=$HOME/.composer/vendor/bin:$PATH ./build.sh + - ./build.sh diff --git a/build.sh b/build.sh index 992b56ab9..c89b9b5d0 100755 --- a/build.sh +++ b/build.sh @@ -1,9 +1,9 @@ #!/bin/bash set -e -parallel-lint --exclude vendor . +vendor/bin/parallel-lint --exclude vendor . -phpcs \ +vendor/bin/phpcs \ --standard=psr2 \ --ignore=vendor \ --extensions=php \ @@ -11,5 +11,6 @@ phpcs \ -p \ . -cd tests -phpunit +php vendor/bin/security-checker security:check composer.lock + +vendor/bin/phpunit -c tests/phpunit.xml \ No newline at end of file diff --git a/composer.json b/composer.json index 0eaa5bcc7..d9d0631ec 100644 --- a/composer.json +++ b/composer.json @@ -27,12 +27,19 @@ "slim/slim": "~2.4", "slim/views": "~0.1", "twig/twig": "~1.15", - "symfony/form": "~2.5", - "symfony/validator": "~2.5", - "symfony/security-csrf": "~2.5", - "symfony/twig-bridge": "~2.5", + "symfony/form": "~2.8", + "symfony/validator": "~2.8", + "symfony/security-csrf": "~2.8", + "symfony/twig-bridge": "~2.8", "org_heigl/daterange": "~1.1", "guzzlehttp/guzzle": "^6.2.1", "monolog/monolog": "^1.21" + }, + "require-dev": { + "phpunit/phpunit": "^5.7", + "squizlabs/php_codesniffer": "^3.4", + "jakub-onderka/php-parallel-lint": "^1.0", + "roave/security-advisories": "dev-master", + "sensiolabs/security-checker": "^5.0" } } diff --git a/composer.lock b/composer.lock index 23aa6d11c..a20f271c9 100644 --- a/composer.lock +++ b/composer.lock @@ -1,40 +1,42 @@ { "_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", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "hash": "e522a86bfda5b98e4eeb88cf56e1bc07", - "content-hash": "10678b4fd50e7f605c3908eb2b47a2be", + "content-hash": "9139f1484b534f3a06cf678e25fffcc9", "packages": [ { "name": "guzzlehttp/guzzle", - "version": "6.2.1", + "version": "6.3.3", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427" + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/3f808fba627f2c5b69e2501217bf31af349c1427", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/407b0cb880ace85c9b63c5f9551db498cb2d50ba", + "reference": "407b0cb880ace85c9b63c5f9551db498cb2d50ba", "shasum": "" }, "require": { "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.3.1", + "guzzlehttp/psr7": "^1.4", "php": ">=5.5" }, "require-dev": { "ext-curl": "*", - "phpunit/phpunit": "^4.0", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.4 || ^7.0", "psr/log": "^1.0" }, + "suggest": { + "psr/log": "Required for using the Log middleware" + }, "type": "library", "extra": { "branch-alias": { - "dev-master": "6.2-dev" + "dev-master": "6.3-dev" } }, "autoload": { @@ -67,32 +69,32 @@ "rest", "web service" ], - "time": "2016-07-15 17:22:37" + "time": "2018-04-22T15:46:56+00:00" }, { "name": "guzzlehttp/promises", - "version": "1.0.3", + "version": "v1.3.1", "source": { "type": "git", "url": "https://github.com/guzzle/promises.git", - "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea" + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea", - "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea", + "url": "https://api.github.com/repos/guzzle/promises/zipball/a59da6cf61d80060647ff4d3eb2c03a2bc694646", + "reference": "a59da6cf61d80060647ff4d3eb2c03a2bc694646", "shasum": "" }, "require": { "php": ">=5.5.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "^4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.4-dev" } }, "autoload": { @@ -118,36 +120,37 @@ "keywords": [ "promise" ], - "time": "2015-10-15 22:28:00" + "time": "2016-12-20T10:07:11+00:00" }, { "name": "guzzlehttp/psr7", - "version": "1.3.1", + "version": "1.5.2", "source": { "type": "git", "url": "https://github.com/guzzle/psr7.git", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" + "reference": "9f83dded91781a01c63574e387eaa769be769115" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/9f83dded91781a01c63574e387eaa769be769115", + "reference": "9f83dded91781a01c63574e387eaa769be769115", "shasum": "" }, "require": { "php": ">=5.4.0", - "psr/http-message": "~1.0" + "psr/http-message": "~1.0", + "ralouphie/getallheaders": "^2.0.5" }, "provide": { "psr/http-message-implementation": "1.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~4.8.36 || ^5.7.27 || ^6.5.8" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.5-dev" } }, "autoload": { @@ -167,29 +170,37 @@ "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", + "psr-7", + "request", + "response", "stream", - "uri" + "uri", + "url" ], - "time": "2016-06-24 23:00:38" + "time": "2018-12-04T20:46:45+00:00" }, { "name": "monolog/monolog", - "version": "1.21.0", + "version": "1.24.0", "source": { "type": "git", "url": "https://github.com/Seldaek/monolog.git", - "reference": "f42fbdfd53e306bda545845e4dbfd3e72edb4952" + "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f42fbdfd53e306bda545845e4dbfd3e72edb4952", - "reference": "f42fbdfd53e306bda545845e4dbfd3e72edb4952", + "url": "https://api.github.com/repos/Seldaek/monolog/zipball/bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", + "reference": "bfc9ebb28f97e7a24c45bdc3f0ff482e47bb0266", "shasum": "" }, "require": { @@ -200,7 +211,7 @@ "psr/log-implementation": "1.0.0" }, "require-dev": { - "aws/aws-sdk-php": "^2.4.9", + "aws/aws-sdk-php": "^2.4.9 || ^3.0", "doctrine/couchdb": "~1.0@dev", "graylog2/gelf-php": "~1.0", "jakub-onderka/php-parallel-lint": "0.9", @@ -210,7 +221,7 @@ "phpunit/phpunit-mock-objects": "2.3.0", "ruflin/elastica": ">=0.90 <3.0", "sentry/sentry": "^0.13", - "swiftmailer/swiftmailer": "~5.3" + "swiftmailer/swiftmailer": "^5.3|^6.0" }, "suggest": { "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", @@ -254,20 +265,20 @@ "logging", "psr-3" ], - "time": "2016-07-29 03:23:52" + "time": "2018-11-05T09:00:11+00:00" }, { "name": "org_heigl/daterange", - "version": "1.1.0", + "version": "1.2.0", "source": { "type": "git", "url": "https://github.com/heiglandreas/org.heigl.daterange.git", - "reference": "0e91a092bb8d63b715497796d719b876372050c5" + "reference": "6a6560a74bf161a988d0a7e9636efca94e365103" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/heiglandreas/org.heigl.daterange/zipball/0e91a092bb8d63b715497796d719b876372050c5", - "reference": "0e91a092bb8d63b715497796d719b876372050c5", + "url": "https://api.github.com/repos/heiglandreas/org.heigl.daterange/zipball/6a6560a74bf161a988d0a7e9636efca94e365103", + "reference": "6a6560a74bf161a988d0a7e9636efca94e365103", "shasum": "" }, "require": { @@ -306,25 +317,77 @@ "datetime", "range" ], - "time": "2015-03-08 21:09:01" + "time": "2015-03-12T09:00:46+00:00" + }, + { + "name": "paragonie/random_compat", + "version": "v2.0.18", + "source": { + "type": "git", + "url": "https://github.com/paragonie/random_compat.git", + "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/paragonie/random_compat/zipball/0a58ef6e3146256cc3dc7cc393927bcc7d1b72db", + "reference": "0a58ef6e3146256cc3dc7cc393927bcc7d1b72db", + "shasum": "" + }, + "require": { + "php": ">=5.2.0" + }, + "require-dev": { + "phpunit/phpunit": "4.*|5.*" + }, + "suggest": { + "ext-libsodium": "Provides a modern crypto API that can be used to generate random bytes." + }, + "type": "library", + "autoload": { + "files": [ + "lib/random.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Paragon Initiative Enterprises", + "email": "security@paragonie.com", + "homepage": "https://paragonie.com" + } + ], + "description": "PHP 5.x polyfill for random_bytes() and random_int() from PHP 7", + "keywords": [ + "csprng", + "polyfill", + "pseudorandom", + "random" + ], + "time": "2019-01-03T20:59:08+00:00" }, { "name": "predis/predis", - "version": "v0.8.5", + "version": "v0.8.7", "source": { "type": "git", "url": "https://github.com/nrk/predis.git", - "reference": "5f2eea628eb465d866ad2771927d83769c8f956c" + "reference": "4123fcd85d61354c6c9900db76c9597dbd129bf6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nrk/predis/zipball/5f2eea628eb465d866ad2771927d83769c8f956c", - "reference": "5f2eea628eb465d866ad2771927d83769c8f956c", + "url": "https://api.github.com/repos/nrk/predis/zipball/4123fcd85d61354c6c9900db76c9597dbd129bf6", + "reference": "4123fcd85d61354c6c9900db76c9597dbd129bf6", "shasum": "" }, "require": { "php": ">=5.3.2" }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, "suggest": { "ext-curl": "Allows access to Webdis when paired with phpiredis", "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" @@ -353,20 +416,20 @@ "predis", "redis" ], - "time": "2014-01-16 14:10:29" + "time": "2014-08-01T09:43:10+00:00" }, { "name": "psr/http-message", - "version": "1.0", + "version": "1.0.1", "source": { "type": "git", "url": "https://github.com/php-fig/http-message.git", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", "shasum": "" }, "require": { @@ -394,6 +457,7 @@ } ], "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", "keywords": [ "http", "http-message", @@ -402,20 +466,20 @@ "request", "response" ], - "time": "2015-05-04 20:22:00" + "time": "2016-08-06T14:39:51+00:00" }, { "name": "psr/log", - "version": "1.0.1", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/php-fig/log.git", - "reference": "5277094ed527a1c4477177d102fe4c53551953e0" + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/5277094ed527a1c4477177d102fe4c53551953e0", - "reference": "5277094ed527a1c4477177d102fe4c53551953e0", + "url": "https://api.github.com/repos/php-fig/log/zipball/6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", + "reference": "6c001f1daafa3a3ac1d8ff69ee4db8e799a654dd", "shasum": "" }, "require": { @@ -449,27 +513,68 @@ "psr", "psr-3" ], - "time": "2016-09-19 16:02:08" + "time": "2018-11-20T15:27:04+00:00" + }, + { + "name": "ralouphie/getallheaders", + "version": "2.0.5", + "source": { + "type": "git", + "url": "https://github.com/ralouphie/getallheaders.git", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/ralouphie/getallheaders/zipball/5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "reference": "5601c8a83fbba7ef674a7369456d12f1e0d0eafa", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "~3.7.0", + "satooshi/php-coveralls": ">=1.0" + }, + "type": "library", + "autoload": { + "files": [ + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "time": "2016-02-11T07:05:27+00:00" }, { "name": "slim/slim", - "version": "2.4.3", + "version": "2.6.3", "source": { "type": "git", "url": "https://github.com/slimphp/Slim.git", - "reference": "4906b77a07c7bd6ff1a99aea903e940a2d4fa106" + "reference": "9224ed81ac1c412881e8d762755e3d76ebf580c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slimphp/Slim/zipball/4906b77a07c7bd6ff1a99aea903e940a2d4fa106", - "reference": "4906b77a07c7bd6ff1a99aea903e940a2d4fa106", + "url": "https://api.github.com/repos/slimphp/Slim/zipball/9224ed81ac1c412881e8d762755e3d76ebf580c0", + "reference": "9224ed81ac1c412881e8d762755e3d76ebf580c0", "shasum": "" }, "require": { "php": ">=5.3.0" }, "suggest": { - "ext-mcrypt": "Required for HTTP cookie encryption" + "ext-mcrypt": "Required for HTTP cookie encryption", + "phpseclib/mcrypt_compat": "Polyfil for mcrypt extension" }, "type": "library", "autoload": { @@ -495,21 +600,20 @@ "rest", "router" ], - "time": "2014-04-05 18:33:59" + "time": "2017-01-07T12:21:41+00:00" }, { "name": "slim/views", - "version": "0.1.2", - "target-dir": "Slim/Views", + "version": "0.1.3", "source": { "type": "git", "url": "https://github.com/slimphp/Slim-Views.git", - "reference": "f0a05ea0b654218e40de692ed7cddcad1cf4b828" + "reference": "8561c785e55a39df6cb6f95c3aba3281a60ed5b0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/slimphp/Slim-Views/zipball/f0a05ea0b654218e40de692ed7cddcad1cf4b828", - "reference": "f0a05ea0b654218e40de692ed7cddcad1cf4b828", + "url": "https://api.github.com/repos/slimphp/Slim-Views/zipball/8561c785e55a39df6cb6f95c3aba3281a60ed5b0", + "reference": "8561c785e55a39df6cb6f95c3aba3281a60ed5b0", "shasum": "" }, "require": { @@ -522,8 +626,8 @@ }, "type": "library", "autoload": { - "psr-0": { - "Slim\\Views": "" + "psr-4": { + "Slim\\Views\\": "./" } }, "notification-url": "https://packagist.org/downloads/", @@ -531,15 +635,15 @@ "MIT" ], "authors": [ - { - "name": "Andrew Smith", - "email": "a.smith@silentworks.co.uk", - "homepage": "http://thoughts.silentworks.co.uk/" - }, { "name": "Josh Lockhart", "email": "info@joshlockhart.com", "homepage": "http://www.joshlockhart.com/" + }, + { + "name": "Andrew Smith", + "email": "a.smith@silentworks.co.uk", + "homepage": "http://thoughts.silentworks.co.uk/" } ], "description": "Smarty and Twig View Parser package for the Slim Framework", @@ -549,33 +653,31 @@ "slimphp", "templating" ], - "time": "2014-04-03 16:31:10" + "time": "2014-12-09T23:48:51+00:00" }, { "name": "symfony/event-dispatcher", - "version": "v2.6.6", - "target-dir": "Symfony/Component/EventDispatcher", + "version": "v3.0.9", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284" + "reference": "54da3ff63dec3c9c0e32ec3f95a7d94ef64baa00" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284", - "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/54da3ff63dec3c9c0e32ec3f95a7d94ef64baa00", + "reference": "54da3ff63dec3c9c0e32ec3f95a7d94ef64baa00", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.5.9" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", - "symfony/stopwatch": "~2.3" + "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": "", @@ -584,62 +686,72 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\EventDispatcher\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com", - "time": "2015-03-13 17:37:22" + "homepage": "https://symfony.com", + "time": "2016-07-19T10:44:15+00:00" }, { "name": "symfony/form", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Form", + "version": "v2.8.49", "source": { "type": "git", "url": "https://github.com/symfony/form.git", - "reference": "538647777973535135a65ec71aab43537da57d33" + "reference": "74382a47aa97496d181fbb598822fdfb9e1744e4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/form/zipball/538647777973535135a65ec71aab43537da57d33", - "reference": "538647777973535135a65ec71aab43537da57d33", + "url": "https://api.github.com/repos/symfony/form/zipball/74382a47aa97496d181fbb598822fdfb9e1744e4", + "reference": "74382a47aa97496d181fbb598822fdfb9e1744e4", "shasum": "" }, "require": { - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1", - "symfony/intl": "~2.3", + "php": ">=5.3.9", + "symfony/event-dispatcher": "~2.1|~3.0.0", + "symfony/intl": "~2.7.25|^2.8.18|~3.2.5", "symfony/options-resolver": "~2.6", - "symfony/property-access": "~2.3" + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.0", + "symfony/property-access": "~2.3|~3.0.0" + }, + "conflict": { + "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0", + "symfony/doctrine-bridge": "<2.7", + "symfony/framework-bundle": "<2.7", + "symfony/twig-bridge": "<2.7" }, "require-dev": { "doctrine/collections": "~1.0", - "symfony/http-foundation": "~2.2", - "symfony/http-kernel": "~2.4", - "symfony/phpunit-bridge": "~2.7", - "symfony/security-csrf": "~2.4", - "symfony/translation": "~2.0,>=2.0.5", - "symfony/validator": "~2.6" + "symfony/dependency-injection": "~2.7|~3.0.0", + "symfony/http-foundation": "~2.2|~3.0.0", + "symfony/http-kernel": "~2.4|~3.0.0", + "symfony/security-csrf": "^2.8.31|^3.3.13", + "symfony/translation": "^2.0.5|~3.0.0", + "symfony/validator": "^2.8.18|~3.2.5" }, "suggest": { "symfony/framework-bundle": "For templating with PHP.", @@ -650,53 +762,55 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Form\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony Form Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "homepage": "https://symfony.com", + "time": "2018-12-06T11:12:46+00:00" }, { "name": "symfony/intl", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Intl", + "version": "v3.2.14", "source": { "type": "git", "url": "https://github.com/symfony/intl.git", - "reference": "f6bc51bcce44aadcfa5c3eaaf2e0402ed33b63b1" + "reference": "3fd98dde8e7d1c34c974d65b09e9c32abe88dafe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/intl/zipball/f6bc51bcce44aadcfa5c3eaaf2e0402ed33b63b1", - "reference": "f6bc51bcce44aadcfa5c3eaaf2e0402ed33b63b1", + "url": "https://api.github.com/repos/symfony/intl/zipball/3fd98dde8e7d1c34c974d65b09e9c32abe88dafe", + "reference": "3fd98dde8e7d1c34c974d65b09e9c32abe88dafe", "shasum": "" }, "require": { - "php": ">=5.3.3" + "php": ">=5.5.9", + "symfony/polyfill-intl-icu": "~1.0" }, "require-dev": { - "symfony/filesystem": ">=2.1", - "symfony/phpunit-bridge": "~2.7" + "symfony/filesystem": "~2.8|~3.0" }, "suggest": { "ext-intl": "to use the component with locales other than \"en\"" @@ -704,18 +818,18 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.2-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\Intl\\": "" }, "classmap": [ - "Symfony/Component/Intl/Resources/stubs" + "Resources/stubs" ], - "files": [ - "Symfony/Component/Intl/Resources/stubs/functions.php" + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -723,10 +837,6 @@ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Bernhard Schussek", "email": "bschussek@gmail.com" @@ -738,10 +848,14 @@ { "name": "Igor Wiedler", "email": "igor@wiedler.ch" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "A PHP replacement layer for the C intl extension that includes additional data from the ICU library.", - "homepage": "http://symfony.com", + "homepage": "https://symfony.com", "keywords": [ "i18n", "icu", @@ -750,94 +864,95 @@ "l10n", "localization" ], - "time": "2015-03-30 15:54:10" + "time": "2017-11-16T17:55:54+00:00" }, { "name": "symfony/options-resolver", - "version": "v2.6.6", - "target-dir": "Symfony/Component/OptionsResolver", + "version": "v2.8.49", "source": { "type": "git", "url": "https://github.com/symfony/options-resolver.git", - "reference": "d619503992eea05eb407a6db76e28dc1b7619416" + "reference": "7aaab725bb58f0e18aa12c61bdadd4793ab4c32b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/d619503992eea05eb407a6db76e28dc1b7619416", - "reference": "d619503992eea05eb407a6db76e28dc1b7619416", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/7aaab725bb58f0e18aa12c61bdadd4793ab4c32b", + "reference": "7aaab725bb58f0e18aa12c61bdadd4793ab4c32b", "shasum": "" }, "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "php": ">=5.3.9" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "2.8-dev" } }, "autoload": { - "psr-0": { + "psr-4": { "Symfony\\Component\\OptionsResolver\\": "" - } + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, { "name": "Fabien Potencier", "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], "description": "Symfony OptionsResolver Component", - "homepage": "http://symfony.com", + "homepage": "https://symfony.com", "keywords": [ "config", "configuration", "options" ], - "time": "2015-03-13 17:37:22" + "time": "2018-11-11T11:18:13+00:00" }, { - "name": "symfony/property-access", - "version": "v2.6.6", - "target-dir": "Symfony/Component/PropertyAccess", + "name": "symfony/polyfill-ctype", + "version": "v1.10.0", "source": { "type": "git", - "url": "https://github.com/symfony/property-access.git", - "reference": "b342f127c3ab73dd4069c2104cb76f1a1ef7c7e7" + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-access/zipball/b342f127c3ab73dd4069c2104cb76f1a1ef7c7e7", - "reference": "b342f127c3ab73dd4069c2104cb76f1a1ef7c7e7", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", + "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", "shasum": "" }, "require": { "php": ">=5.3.3" }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" + "suggest": { + "ext-ctype": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "1.9-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\PropertyAccess\\": "" - } + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -846,73 +961,54 @@ "authors": [ { "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "homepage": "https://symfony.com/contributors" }, { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Gert de Pagter", + "email": "backendtea@gmail.com" } ], - "description": "Symfony PropertyAccess Component", - "homepage": "http://symfony.com", + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", "keywords": [ - "access", - "array", - "extraction", - "index", - "injection", - "object", - "property", - "property path", - "reflection" + "compatibility", + "ctype", + "polyfill", + "portable" ], - "time": "2015-03-30 15:54:10" + "time": "2018-08-06T14:22:27+00:00" }, { - "name": "symfony/security-core", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Security/Core", + "name": "symfony/polyfill-intl-icu", + "version": "v1.10.0", "source": { "type": "git", - "url": "https://github.com/symfony/security-core.git", - "reference": "d25c17db741f58c0f615e52006a47f6fb23cd9b3" + "url": "https://github.com/symfony/polyfill-intl-icu.git", + "reference": "f22a90256d577c7ef7efad8df1f0201663d57644" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-core/zipball/d25c17db741f58c0f615e52006a47f6fb23cd9b3", - "reference": "d25c17db741f58c0f615e52006a47f6fb23cd9b3", + "url": "https://api.github.com/repos/symfony/polyfill-intl-icu/zipball/f22a90256d577c7ef7efad8df1f0201663d57644", + "reference": "f22a90256d577c7ef7efad8df1f0201663d57644", "shasum": "" }, "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "ircmaxell/password-compat": "1.0.*", - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/expression-language": "~2.6", - "symfony/http-foundation": "~2.4", - "symfony/phpunit-bridge": "~2.7", - "symfony/translation": "~2.0,>=2.0.5", - "symfony/validator": "~2.5,>=2.5.5" + "php": ">=5.3.3", + "symfony/intl": "~2.3|~3.0|~4.0" }, "suggest": { - "ircmaxell/password-compat": "For using the BCrypt password encoder in PHP <5.5", - "symfony/event-dispatcher": "", - "symfony/expression-language": "For using the expression voter", - "symfony/http-foundation": "", - "symfony/validator": "For using the user password constraint" + "ext-intl": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "1.9-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Security\\Core\\": "" - } + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -920,54 +1016,59 @@ ], "authors": [ { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Security Component - Core Library", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "description": "Symfony polyfill for intl's ICU-related data and classes", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "icu", + "intl", + "polyfill", + "portable", + "shim" + ], + "time": "2018-08-06T14:22:27+00:00" }, { - "name": "symfony/security-csrf", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Security/Csrf", + "name": "symfony/polyfill-mbstring", + "version": "v1.10.0", "source": { "type": "git", - "url": "https://github.com/symfony/security-csrf.git", - "reference": "7cc85bffcb0f3a68cd8be8d2c91da0cc962f152a" + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/security-csrf/zipball/7cc85bffcb0f3a68cd8be8d2c91da0cc962f152a", - "reference": "7cc85bffcb0f3a68cd8be8d2c91da0cc962f152a", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/c79c051f5b3a46be09205c73b80b346e4153e494", + "reference": "c79c051f5b3a46be09205c73b80b346e4153e494", "shasum": "" }, "require": { - "php": ">=5.3.3", - "symfony/security-core": "~2.4" - }, - "require-dev": { - "symfony/http-foundation": "~2.1", - "symfony/phpunit-bridge": "~2.7" + "php": ">=5.3.3" }, "suggest": { - "symfony/http-foundation": "For using the class SessionTokenStorage." + "ext-mbstring": "For best performance" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "1.9-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Security\\Csrf\\": "" - } + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -975,58 +1076,56 @@ ], "authors": [ { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Security Component - CSRF Library", - "homepage": "http://symfony.com", - "time": "2015-02-24 11:52:21" + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T13:07:52+00:00" }, { - "name": "symfony/translation", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Translation", + "name": "symfony/polyfill-php56", + "version": "v1.10.0", "source": { "type": "git", - "url": "https://github.com/symfony/Translation.git", - "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af" + "url": "https://github.com/symfony/polyfill-php56.git", + "reference": "ff208829fe1aa48ab9af356992bb7199fed551af" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/bd939f05cdaca128f4ddbae1b447d6f0203b60af", - "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af", + "url": "https://api.github.com/repos/symfony/polyfill-php56/zipball/ff208829fe1aa48ab9af356992bb7199fed551af", + "reference": "ff208829fe1aa48ab9af356992bb7199fed551af", "shasum": "" }, "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.3,>=2.3.12", - "symfony/intl": "~2.3", - "symfony/phpunit-bridge": "~2.7", - "symfony/yaml": "~2.2" - }, - "suggest": { - "psr/log": "To use logging capability in translator", - "symfony/config": "", - "symfony/yaml": "" + "php": ">=5.3.3", + "symfony/polyfill-util": "~1.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "1.9-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Translation\\": "" - } + "psr-4": { + "Symfony\\Polyfill\\Php56\\": "" + }, + "files": [ + "bootstrap.php" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -1034,229 +1133,2474 @@ ], "authors": [ { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Symfony Translation Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "description": "Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T06:26:08+00:00" }, { - "name": "symfony/twig-bridge", - "version": "v2.6.6", - "target-dir": "Symfony/Bridge/Twig", + "name": "symfony/polyfill-php70", + "version": "v1.10.0", "source": { "type": "git", - "url": "https://github.com/symfony/twig-bridge.git", - "reference": "d9124ca70a859dba282729c309beec24f6aafb18" + "url": "https://github.com/symfony/polyfill-php70.git", + "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/d9124ca70a859dba282729c309beec24f6aafb18", - "reference": "d9124ca70a859dba282729c309beec24f6aafb18", + "url": "https://api.github.com/repos/symfony/polyfill-php70/zipball/6b88000cdd431cd2e940caa2cb569201f3f84224", + "reference": "6b88000cdd431cd2e940caa2cb569201f3f84224", "shasum": "" }, "require": { - "php": ">=5.3.3", - "twig/twig": "~1.13,>=1.13.1" - }, - "require-dev": { - "symfony/console": "~2.4", - "symfony/expression-language": "~2.4", - "symfony/finder": "~2.3", - "symfony/form": "~2.6,>=2.6.6", - "symfony/http-kernel": "~2.3", - "symfony/intl": "~2.3", - "symfony/phpunit-bridge": "~2.7", - "symfony/routing": "~2.2", - "symfony/security": "~2.4", - "symfony/stopwatch": "~2.2", - "symfony/templating": "~2.1", - "symfony/translation": "~2.2", - "symfony/var-dumper": "~2.6", - "symfony/yaml": "~2.0,>=2.0.5" - }, - "suggest": { - "symfony/expression-language": "For using the ExpressionExtension", - "symfony/finder": "", - "symfony/form": "For using the FormExtension", - "symfony/http-kernel": "For using the HttpKernelExtension", - "symfony/routing": "For using the RoutingExtension", - "symfony/security": "For using the SecurityExtension", - "symfony/stopwatch": "For using the StopwatchExtension", - "symfony/templating": "For using the TwigEngine", - "symfony/translation": "For using the TranslationExtension", - "symfony/var-dumper": "For using the DumpExtension", - "symfony/yaml": "For using the YamlExtension" + "paragonie/random_compat": "~1.0|~2.0|~9.99", + "php": ">=5.3.3" }, - "type": "symfony-bridge", + "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "1.9-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Bridge\\Twig\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ + "psr-4": { + "Symfony\\Polyfill\\Php70\\": "" + }, + "files": [ + "bootstrap.php" + ], + "classmap": [ + "Resources/stubs" + ] + }, + "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 backporting some PHP 7.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "time": "2018-09-21T06:26:08+00:00" + }, + { + "name": "symfony/polyfill-util", + "version": "v1.10.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-util.git", + "reference": "3b58903eae668d348a7126f999b0da0f2f93611c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-util/zipball/3b58903eae668d348a7126f999b0da0f2f93611c", + "reference": "3b58903eae668d348a7126f999b0da0f2f93611c", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.9-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Util\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ "MIT" ], "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, { "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony utilities for portability of PHP codes", + "homepage": "https://symfony.com", + "keywords": [ + "compat", + "compatibility", + "polyfill", + "shim" + ], + "time": "2018-09-30T16:36:12+00:00" + }, + { + "name": "symfony/property-access", + "version": "v3.0.9", + "source": { + "type": "git", + "url": "https://github.com/symfony/property-access.git", + "reference": "a4f1a668d0a269a65790f07d9ab2a97dd060fccb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/property-access/zipball/a4f1a668d0a269a65790f07d9ab2a97dd060fccb", + "reference": "a4f1a668d0a269a65790f07d9ab2a97dd060fccb", + "shasum": "" + }, + "require": { + "php": ">=5.5.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\PropertyAccess\\": "" }, + "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 Twig Bridge", - "homepage": "http://symfony.com", - "time": "2015-03-28 16:22:38" + "description": "Symfony PropertyAccess Component", + "homepage": "https://symfony.com", + "keywords": [ + "access", + "array", + "extraction", + "index", + "injection", + "object", + "property", + "property path", + "reflection" + ], + "time": "2016-07-30T07:22:48+00:00" }, { - "name": "symfony/validator", - "version": "v2.6.6", - "target-dir": "Symfony/Component/Validator", + "name": "symfony/security-core", + "version": "v3.4.22", "source": { "type": "git", - "url": "https://github.com/symfony/Validator.git", - "reference": "85d9b42fe71bf88e7a1e5dec2094605dc9fbff28" + "url": "https://github.com/symfony/security-core.git", + "reference": "816ba9bacc8ba5303f250597b2c9af380d9d715b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/85d9b42fe71bf88e7a1e5dec2094605dc9fbff28", - "reference": "85d9b42fe71bf88e7a1e5dec2094605dc9fbff28", + "url": "https://api.github.com/repos/symfony/security-core/zipball/816ba9bacc8ba5303f250597b2c9af380d9d715b", + "reference": "816ba9bacc8ba5303f250597b2c9af380d9d715b", "shasum": "" }, "require": { - "php": ">=5.3.3", - "symfony/translation": "~2.0,>=2.0.5" + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-php56": "~1.0" }, "require-dev": { - "doctrine/annotations": "~1.0", - "doctrine/cache": "~1.0", - "doctrine/common": "~2.3", - "egulias/email-validator": "~1.2,>=1.2.1", - "symfony/config": "~2.2", - "symfony/expression-language": "~2.4", - "symfony/http-foundation": "~2.1", - "symfony/intl": "~2.3", - "symfony/phpunit-bridge": "~2.7", - "symfony/property-access": "~2.3", - "symfony/yaml": "~2.0,>=2.0.5" + "psr/container": "^1.0", + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/expression-language": "~2.8|~3.0|~4.0", + "symfony/http-foundation": "~2.8|~3.0|~4.0", + "symfony/ldap": "~3.1|~4.0", + "symfony/validator": "^3.2.5|~4.0" }, "suggest": { - "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", - "doctrine/cache": "For using the default cached annotation reader and metadata cache.", - "egulias/email-validator": "Strict (RFC compliant) email validation", - "symfony/config": "", - "symfony/expression-language": "For using the 2.4 Expression validator", + "psr/container-implementation": "To instantiate the Security class", + "symfony/event-dispatcher": "", + "symfony/expression-language": "For using the expression voter", "symfony/http-foundation": "", - "symfony/intl": "", - "symfony/property-access": "For using the 2.4 Validator API", - "symfony/yaml": "" + "symfony/ldap": "For using LDAP integration", + "symfony/validator": "For using the user password constraint" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.6-dev" + "dev-master": "3.4-dev" } }, "autoload": { - "psr-0": { - "Symfony\\Component\\Validator\\": "" - } + "psr-4": { + "Symfony\\Component\\Security\\Core\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, { "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Security Component - Core Library", + "homepage": "https://symfony.com", + "time": "2019-01-31T10:03:47+00:00" + }, + { + "name": "symfony/security-csrf", + "version": "v2.8.49", + "source": { + "type": "git", + "url": "https://github.com/symfony/security-csrf.git", + "reference": "91957524d5e01416a2e6ece04667f2060f717a76" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/security-csrf/zipball/91957524d5e01416a2e6ece04667f2060f717a76", + "reference": "91957524d5e01416a2e6ece04667f2060f717a76", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/polyfill-php56": "~1.0", + "symfony/polyfill-php70": "~1.0", + "symfony/security-core": "^2.8.41|^3.3.17" + }, + "conflict": { + "symfony/http-foundation": "<2.7.38|~2.8,<2.8.31|~3.3,<3.3.13" + }, + "require-dev": { + "symfony/http-foundation": "^2.7.38|~3.3.13" + }, + "suggest": { + "symfony/http-foundation": "For using the class SessionTokenStorage." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Security\\Csrf\\": "" }, + "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 Validator Component", - "homepage": "http://symfony.com", - "time": "2015-03-30 15:54:10" + "description": "Symfony Security Component - CSRF Library", + "homepage": "https://symfony.com", + "time": "2018-11-11T11:18:13+00:00" }, { - "name": "twig/twig", - "version": "v1.15.1", + "name": "symfony/translation", + "version": "v3.0.9", "source": { "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed" + "url": "https://github.com/symfony/translation.git", + "reference": "eee6c664853fd0576f21ae25725cfffeafe83f26" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed", - "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed", + "url": "https://api.github.com/repos/symfony/translation/zipball/eee6c664853fd0576f21ae25725cfffeafe83f26", + "reference": "eee6c664853fd0576f21ae25725cfffeafe83f26", "shasum": "" }, "require": { - "php": ">=5.2.4" + "php": ">=5.5.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/config": "<2.8" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.8|~3.0", + "symfony/intl": "~2.8|~3.0", + "symfony/yaml": "~2.8|~3.0" + }, + "suggest": { + "psr/log": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.15-dev" + "dev-master": "3.0-dev" } }, "autoload": { - "psr-0": { - "Twig_": "lib/" - } + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ - "BSD-3-Clause" + "MIT" ], "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" + "email": "fabien@symfony.com" }, { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Translation Component", + "homepage": "https://symfony.com", + "time": "2016-07-30T07:22:48+00:00" + }, + { + "name": "symfony/twig-bridge", + "version": "v2.8.49", + "source": { + "type": "git", + "url": "https://github.com/symfony/twig-bridge.git", + "reference": "ecc1e30d05fa99f25b504e2d6a8684555ae39f7c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/ecc1e30d05fa99f25b504e2d6a8684555ae39f7c", + "reference": "ecc1e30d05fa99f25b504e2d6a8684555ae39f7c", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "twig/twig": "~1.34|~2.4" + }, + "conflict": { + "symfony/form": "<2.8.23" + }, + "require-dev": { + "symfony/asset": "~2.7|~3.0.0", + "symfony/console": "~2.8|~3.0.0", + "symfony/expression-language": "~2.4|~3.0.0", + "symfony/finder": "~2.3|~3.0.0", + "symfony/form": "^2.8.23", + "symfony/http-foundation": "^2.8.29|~3.0.0", + "symfony/http-kernel": "~2.8|~3.0.0", + "symfony/polyfill-intl-icu": "~1.0", + "symfony/routing": "~2.2|~3.0.0", + "symfony/security": "^2.8.31|^3.3.13", + "symfony/security-acl": "~2.6|~3.0.0", + "symfony/stopwatch": "~2.2|~3.0.0", + "symfony/templating": "~2.1|~3.0.0", + "symfony/translation": "~2.7|~3.0.0", + "symfony/var-dumper": "~2.7.16|~2.8.9|~3.0.9", + "symfony/yaml": "^2.0.5|~3.0.0" + }, + "suggest": { + "symfony/asset": "For using the AssetExtension", + "symfony/expression-language": "For using the ExpressionExtension", + "symfony/finder": "", + "symfony/form": "For using the FormExtension", + "symfony/http-kernel": "For using the HttpKernelExtension", + "symfony/routing": "For using the RoutingExtension", + "symfony/security": "For using the SecurityExtension", + "symfony/stopwatch": "For using the StopwatchExtension", + "symfony/templating": "For using the TwigEngine", + "symfony/translation": "For using the TranslationExtension", + "symfony/var-dumper": "For using the DumpExtension", + "symfony/yaml": "For using the YamlExtension" + }, + "type": "symfony-bridge", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Bridge\\Twig\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" }, { - "name": "Twig Team", - "homepage": "https://github.com/fabpot/Twig/graphs/contributors", - "role": "Contributors" + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", - "keywords": [ - "templating" + "description": "Symfony Twig Bridge", + "homepage": "https://symfony.com", + "time": "2018-11-11T11:18:13+00:00" + }, + { + "name": "symfony/validator", + "version": "v2.8.49", + "source": { + "type": "git", + "url": "https://github.com/symfony/validator.git", + "reference": "d5d2090bba3139d8ddb79959fbf516e87238fe3a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/validator/zipball/d5d2090bba3139d8ddb79959fbf516e87238fe3a", + "reference": "d5d2090bba3139d8ddb79959fbf516e87238fe3a", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation": "~2.4|~3.0.0" + }, + "require-dev": { + "doctrine/annotations": "~1.0", + "doctrine/cache": "~1.0", + "egulias/email-validator": "^1.2.1", + "symfony/config": "~2.2|~3.0.0", + "symfony/expression-language": "~2.4|~3.0.0", + "symfony/http-foundation": "~2.3|~3.0.0", + "symfony/intl": "~2.7.25|^2.8.18|~3.2.5", + "symfony/property-access": "~2.3|~3.0.0", + "symfony/yaml": "^2.0.5|~3.0.0" + }, + "suggest": { + "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", + "doctrine/cache": "For using the default cached annotation reader and metadata cache.", + "egulias/email-validator": "Strict (RFC compliant) email validation", + "symfony/config": "", + "symfony/expression-language": "For using the 2.4 Expression validator", + "symfony/http-foundation": "", + "symfony/intl": "", + "symfony/property-access": "For using the 2.4 Validator API", + "symfony/yaml": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Validator\\": "" + }, + "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 Validator Component", + "homepage": "https://symfony.com", + "time": "2018-11-14T14:06:48+00:00" + }, + { + "name": "twig/twig", + "version": "v1.37.1", + "source": { + "type": "git", + "url": "https://github.com/twigphp/Twig.git", + "reference": "66be9366c76cbf23e82e7171d47cbfa54a057a62" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/66be9366c76cbf23e82e7171d47cbfa54a057a62", + "reference": "66be9366c76cbf23e82e7171d47cbfa54a057a62", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "symfony/polyfill-ctype": "^1.8" + }, + "require-dev": { + "psr/container": "^1.0", + "symfony/debug": "^2.7", + "symfony/phpunit-bridge": "^3.4.19|^4.1.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.37-dev" + } + }, + "autoload": { + "psr-0": { + "Twig_": "lib/" + }, + "psr-4": { + "Twig\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" + }, + { + "name": "Armin Ronacher", + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "https://twig.symfony.com/contributors", + "role": "Contributors" + } + ], + "description": "Twig, the flexible, fast, and secure template language for PHP", + "homepage": "https://twig.symfony.com", + "keywords": [ + "templating" + ], + "time": "2019-01-14T14:59:29+00:00" + } + ], + "packages-dev": [ + { + "name": "composer/ca-bundle", + "version": "1.1.4", + "source": { + "type": "git", + "url": "https://github.com/composer/ca-bundle.git", + "reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/ca-bundle/zipball/558f321c52faeb4828c03e7dc0cfe39a09e09a2d", + "reference": "558f321c52faeb4828c03e7dc0cfe39a09e09a2d", + "shasum": "" + }, + "require": { + "ext-openssl": "*", + "ext-pcre": "*", + "php": "^5.3.2 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5", + "psr/log": "^1.0", + "symfony/process": "^2.5 || ^3.0 || ^4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\CaBundle\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jordi Boggiano", + "email": "j.boggiano@seld.be", + "homepage": "http://seld.be" + } + ], + "description": "Lets you find a path to the system CA bundle, and includes a fallback to the Mozilla CA bundle.", + "keywords": [ + "cabundle", + "cacert", + "certificate", + "ssl", + "tls" + ], + "time": "2019-01-28T09:30:10+00:00" + }, + { + "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-14T21:17:01+00:00" + }, + { + "name": "jakub-onderka/php-parallel-lint", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git", + "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/04fbd3f5fb1c83f08724aa58a23db90bd9086ee8", + "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "jakub-onderka/php-console-highlighter": "~0.3", + "nette/tester": "~1.3", + "squizlabs/php_codesniffer": "~2.7" + }, + "suggest": { + "jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool check syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint", + "time": "2018-02-24T15:31:20+00:00" + }, + { + "name": "myclabs/deep-copy", + "version": "1.7.0", + "source": { + "type": "git", + "url": "https://github.com/myclabs/DeepCopy.git", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "reference": "3b8a3a99ba1f6a3952ac2747d989303cbd6b7a3e", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "doctrine/collections": "^1.0", + "doctrine/common": "^2.6", + "phpunit/phpunit": "^4.1" + }, + "type": "library", + "autoload": { + "psr-4": { + "DeepCopy\\": "src/DeepCopy/" + }, + "files": [ + "src/DeepCopy/deep_copy.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "Create deep copies (clones) of your objects", + "keywords": [ + "clone", + "copy", + "duplicate", + "object", + "object graph" + ], + "time": "2017-10-19T19:58:43+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6", + "shasum": "" + }, + "require": { + "php": ">=5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "time": "2017-09-11T18:02:19+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "3.3.2", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bf329f6c1aadea3299f08ee804682b7c45b326a2", + "reference": "bf329f6c1aadea3299f08ee804682b7c45b326a2", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0", + "phpdocumentor/reflection-common": "^1.0.0", + "phpdocumentor/type-resolver": "^0.4.0", + "webmozart/assert": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^4.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "time": "2017-11-10T14:09:06+00:00" + }, + { + "name": "phpdocumentor/type-resolver", + "version": "0.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/TypeResolver.git", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7", + "reference": "9c977708995954784726e25d0cd1dddf4e65b0f7", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0", + "phpdocumentor/reflection-common": "^1.0" + }, + "require-dev": { + "mockery/mockery": "^0.9.4", + "phpunit/phpunit": "^5.2||^4.8.24" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + } + ], + "time": "2017-07-14T14:27:02+00:00" + }, + { + "name": "phpspec/prophecy", + "version": "1.8.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "reference": "4ba436b55987b4bf311cb7c6ba82aa528aac0a06", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.3|^7.0", + "phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0", + "sebastian/comparator": "^1.1|^2.0|^3.0", + "sebastian/recursion-context": "^1.0|^2.0|^3.0" + }, + "require-dev": { + "phpspec/phpspec": "^2.5|^3.2", + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5 || ^7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.8.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": "2018-08-05T17:53:17+00:00" + }, + { + "name": "phpunit/php-code-coverage", + "version": "4.0.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-xmlwriter": "*", + "php": "^5.6 || ^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": "^1.3.2 || ^2.0", + "sebastian/version": "^1.0 || ^2.0" + }, + "require-dev": { + "ext-xdebug": "^2.1.4", + "phpunit/phpunit": "^5.7" + }, + "suggest": { + "ext-xdebug": "^2.5.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.0.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": "2017-04-02T07:44:40+00:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.4.5", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/730b01bc3e867237eaac355e06a36b85dd93a8b4", + "reference": "730b01bc3e867237eaac355e06a36b85dd93a8b4", + "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": "2017-11-27T13:52:08+00:00" + }, + { + "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-21T13:50:34+00:00" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.9", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "reference": "3dcf38ca72b158baf0bc245e9184d3fdffa9c46f", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "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": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2017-02-26T11:10:40+00:00" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.12", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/1ce90ba27c42e4e44e6d8458241466380b51fa16", + "reference": "1ce90ba27c42e4e44e6d8458241466380b51fa16", + "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": "2017-12-04T08:55:13+00:00" + }, + { + "name": "phpunit/phpunit", + "version": "5.7.27", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-libxml": "*", + "ext-mbstring": "*", + "ext-xml": "*", + "myclabs/deep-copy": "~1.3", + "php": "^5.6 || ^7.0", + "phpspec/prophecy": "^1.6.2", + "phpunit/php-code-coverage": "^4.0.4", + "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.4", + "sebastian/diff": "^1.4.3", + "sebastian/environment": "^1.3.4 || ^2.0", + "sebastian/exporter": "~2.0", + "sebastian/global-state": "^1.1", + "sebastian/object-enumerator": "~2.0", + "sebastian/resource-operations": "~1.0", + "sebastian/version": "^1.0.6|^2.0.1", + "symfony/yaml": "~2.1|~3.0|~4.0" + }, + "conflict": { + "phpdocumentor/reflection-docblock": "3.0.2" + }, + "require-dev": { + "ext-pdo": "*" + }, + "suggest": { + "ext-xdebug": "*", + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.7.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": "2018-02-01T05:50:59+00:00" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "3.4.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118", + "reference": "a23b761686d50a560cc56233b9ecf49597cc9118", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": "^5.6 || ^7.0", + "phpunit/php-text-template": "^1.2", + "sebastian/exporter": "^1.2 || ^2.0" + }, + "conflict": { + "phpunit/phpunit": "<5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.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": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2017-06-30T09:13:00+00:00" + }, + { + "name": "roave/security-advisories", + "version": "dev-master", + "source": { + "type": "git", + "url": "https://github.com/Roave/SecurityAdvisories.git", + "reference": "e1b9176e35e8a4521c8b9720f4b5601d5caa68c5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Roave/SecurityAdvisories/zipball/e1b9176e35e8a4521c8b9720f4b5601d5caa68c5", + "reference": "e1b9176e35e8a4521c8b9720f4b5601d5caa68c5", + "shasum": "" + }, + "conflict": { + "3f/pygmentize": "<1.2", + "adodb/adodb-php": "<5.20.12", + "alterphp/easyadmin-extension-bundle": ">=1.2,<1.2.11|>=1.3,<1.3.1", + "amphp/artax": "<1.0.6|>=2,<2.0.6", + "amphp/http": "<1.0.1", + "api-platform/core": ">=2.2,<2.2.10|>=2.3,<2.3.6", + "asymmetricrypt/asymmetricrypt": ">=0,<9.9.99", + "aws/aws-sdk-php": ">=3,<3.2.1", + "brightlocal/phpwhois": "<=4.2.5", + "bugsnag/bugsnag-laravel": ">=2,<2.0.2", + "cakephp/cakephp": ">=1.3,<1.3.18|>=2,<2.4.99|>=2.5,<2.5.99|>=2.6,<2.6.12|>=2.7,<2.7.6|>=3,<3.0.15|>=3.1,<3.1.4|>=3.4,<3.4.14|>=3.5,<3.5.17|>=3.6,<3.6.4", + "cart2quote/module-quotation": ">=4.1.6,<=4.4.5|>=5,<5.4.4", + "cartalyst/sentry": "<=2.1.6", + "codeigniter/framework": "<=3.0.6", + "composer/composer": "<=1.0.0-alpha11", + "contao-components/mediaelement": ">=2.14.2,<2.21.1", + "contao/core": ">=2,<3.5.35", + "contao/core-bundle": ">=4,<4.4.18|>=4.5,<4.5.8", + "contao/listing-bundle": ">=4,<4.4.8", + "contao/newsletter-bundle": ">=4,<4.1", + "david-garcia/phpwhois": "<=4.3.1", + "doctrine/annotations": ">=1,<1.2.7", + "doctrine/cache": ">=1,<1.3.2|>=1.4,<1.4.2", + "doctrine/common": ">=2,<2.4.3|>=2.5,<2.5.1", + "doctrine/dbal": ">=2,<2.0.8|>=2.1,<2.1.2", + "doctrine/doctrine-bundle": "<1.5.2", + "doctrine/doctrine-module": "<=0.7.1", + "doctrine/mongodb-odm": ">=1,<1.0.2", + "doctrine/mongodb-odm-bundle": ">=2,<3.0.1", + "doctrine/orm": ">=2,<2.4.8|>=2.5,<2.5.1", + "dompdf/dompdf": ">=0.6,<0.6.2", + "drupal/core": ">=7,<7.62|>=8,<8.6.6", + "drupal/drupal": ">=7,<7.62|>=8,<8.6.6", + "erusev/parsedown": "<1.7", + "ezsystems/ezpublish-kernel": ">=5.3,<5.3.12.1|>=5.4,<5.4.13.1|>=6,<6.7.9.1|>=6.8,<6.13.5.1|>=7,<7.2.4.1|>=7.3,<7.3.2.1", + "ezsystems/ezpublish-legacy": ">=5.3,<5.3.12.6|>=5.4,<5.4.12.3|>=2011,<2017.12.4.3|>=2018.6,<2018.6.1.4|>=2018.9,<2018.9.1.3", + "ezsystems/repository-forms": ">=2.3,<2.3.2.1", + "ezyang/htmlpurifier": "<4.1.1", + "firebase/php-jwt": "<2", + "fooman/tcpdf": "<6.2.22", + "fossar/tcpdf-parser": "<6.2.22", + "friendsofsymfony/rest-bundle": ">=1.2,<1.2.2", + "friendsofsymfony/user-bundle": ">=1.2,<1.3.5", + "fuel/core": "<1.8.1", + "gree/jose": "<=2.2", + "gregwar/rst": "<1.0.3", + "guzzlehttp/guzzle": ">=6,<6.2.1|>=4.0.0-rc2,<4.2.4|>=5,<5.3.1", + "illuminate/auth": ">=4,<4.0.99|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.10", + "illuminate/cookie": ">=4,<=4.0.11|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.42|>=5.6,<5.6.30", + "illuminate/database": ">=4,<4.0.99|>=4.1,<4.1.29", + "illuminate/encryption": ">=4,<=4.0.11|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.40|>=5.6,<5.6.15", + "ivankristianto/phpwhois": "<=4.3", + "james-heinrich/getid3": "<1.9.9", + "joomla/session": "<1.3.1", + "jsmitty12/phpwhois": "<5.1", + "kazist/phpwhois": "<=4.2.6", + "kreait/firebase-php": ">=3.2,<3.8.1", + "la-haute-societe/tcpdf": "<6.2.22", + "laravel/framework": ">=4,<4.0.99|>=4.1,<=4.1.31|>=4.2,<=4.2.22|>=5,<=5.0.35|>=5.1,<=5.1.46|>=5.2,<=5.2.45|>=5.3,<=5.3.31|>=5.4,<=5.4.36|>=5.5,<5.5.42|>=5.6,<5.6.30", + "laravel/socialite": ">=1,<1.0.99|>=2,<2.0.10", + "league/commonmark": ">=0.15.6,<0.18.1", + "magento/magento1ce": "<1.9.4", + "magento/magento1ee": ">=1.9,<1.14.4", + "magento/product-community-edition": ">=2,<2.2.7", + "monolog/monolog": ">=1.8,<1.12", + "namshi/jose": "<2.2", + "onelogin/php-saml": "<2.10.4", + "openid/php-openid": "<2.3", + "oro/crm": ">=1.7,<1.7.4", + "oro/platform": ">=1.7,<1.7.4", + "padraic/humbug_get_contents": "<1.1.2", + "pagarme/pagarme-php": ">=0,<3", + "paragonie/random_compat": "<2", + "paypal/merchant-sdk-php": "<3.12", + "pear/archive_tar": "<1.4.4", + "phpmailer/phpmailer": ">=5,<5.2.27|>=6,<6.0.6", + "phpoffice/phpexcel": "<=1.8.1", + "phpoffice/phpspreadsheet": "<=1.5", + "phpunit/phpunit": ">=4.8.19,<4.8.28|>=5.0.10,<5.6.3", + "phpwhois/phpwhois": "<=4.2.5", + "phpxmlrpc/extras": "<0.6.1", + "propel/propel": ">=2.0.0-alpha1,<=2.0.0-alpha7", + "propel/propel1": ">=1,<=1.7.1", + "pusher/pusher-php-server": "<2.2.1", + "robrichards/xmlseclibs": ">=1,<3.0.2", + "sabre/dav": ">=1.6,<1.6.99|>=1.7,<1.7.11|>=1.8,<1.8.9", + "sensiolabs/connect": "<4.2.3", + "serluck/phpwhois": "<=4.2.6", + "shopware/shopware": "<5.3.7", + "silverstripe/cms": ">=3,<=3.0.11|>=3.1,<3.1.11", + "silverstripe/forum": "<=0.6.1|>=0.7,<=0.7.3", + "silverstripe/framework": ">=3,<3.3", + "silverstripe/userforms": "<3", + "simple-updates/phpwhois": "<=1", + "simplesamlphp/saml2": "<1.10.6|>=2,<2.3.8|>=3,<3.1.4", + "simplesamlphp/simplesamlphp": "<1.16.3", + "simplesamlphp/simplesamlphp-module-infocard": "<1.0.1", + "slim/slim": "<2.6", + "smarty/smarty": "<3.1.33", + "socalnick/scn-social-auth": "<1.15.2", + "spoonity/tcpdf": "<6.2.22", + "squizlabs/php_codesniffer": ">=1,<2.8.1|>=3,<3.0.1", + "stormpath/sdk": ">=0,<9.9.99", + "swiftmailer/swiftmailer": ">=4,<5.4.5", + "sylius/admin-bundle": ">=1,<1.0.17|>=1.1,<1.1.9|>=1.2,<1.2.2", + "sylius/sylius": ">=1,<1.0.17|>=1.1,<1.1.9|>=1.2,<1.2.2", + "symfony/dependency-injection": ">=2,<2.0.17", + "symfony/form": ">=2.3,<2.3.35|>=2.4,<2.6.12|>=2.7,<2.7.50|>=2.8,<2.8.49|>=3,<3.4.20|>=4,<4.0.15|>=4.1,<4.1.9|>=4.2,<4.2.1", + "symfony/framework-bundle": ">=2,<2.3.18|>=2.4,<2.4.8|>=2.5,<2.5.2", + "symfony/http-foundation": ">=2,<2.7.49|>=2.8,<2.8.44|>=3,<3.3.18|>=3.4,<3.4.14|>=4,<4.0.14|>=4.1,<4.1.3", + "symfony/http-kernel": ">=2,<2.3.29|>=2.4,<2.5.12|>=2.6,<2.6.8", + "symfony/intl": ">=2.7,<2.7.38|>=2.8,<2.8.31|>=3,<3.2.14|>=3.3,<3.3.13", + "symfony/polyfill": ">=1,<1.10", + "symfony/polyfill-php55": ">=1,<1.10", + "symfony/routing": ">=2,<2.0.19", + "symfony/security": ">=2,<2.7.50|>=2.8,<2.8.49|>=3,<3.4.19|>=4,<4.0.15|>=4.1,<4.1.9|>=4.2,<4.2.1", + "symfony/security-bundle": ">=2,<2.7.48|>=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", + "symfony/security-core": ">=2.4,<2.6.13|>=2.7,<2.7.9|>=2.7.30,<2.7.32|>=2.8,<2.8.37|>=3,<3.3.17|>=3.4,<3.4.7|>=4,<4.0.7", + "symfony/security-csrf": ">=2.4,<2.7.48|>=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", + "symfony/security-guard": ">=2.8,<2.8.41|>=3,<3.3.17|>=3.4,<3.4.11|>=4,<4.0.11", + "symfony/security-http": ">=2.3,<2.3.41|>=2.4,<2.7.50|>=2.8,<2.8.49|>=3,<3.4.20|>=4,<4.0.15|>=4.1,<4.1.9|>=4.2,<4.2.1", + "symfony/serializer": ">=2,<2.0.11", + "symfony/symfony": ">=2,<2.7.50|>=2.8,<2.8.49|>=3,<3.4.20|>=4,<4.0.15|>=4.1,<4.1.9|>=4.2,<4.2.1", + "symfony/translation": ">=2,<2.0.17", + "symfony/validator": ">=2,<2.0.24|>=2.1,<2.1.12|>=2.2,<2.2.5|>=2.3,<2.3.3", + "symfony/web-profiler-bundle": ">=2,<2.3.19|>=2.4,<2.4.9|>=2.5,<2.5.4", + "symfony/yaml": ">=2,<2.0.22|>=2.1,<2.1.7", + "tecnickcom/tcpdf": "<6.2.22", + "thelia/backoffice-default-template": ">=2.1,<2.1.2", + "thelia/thelia": ">=2.1,<2.1.2|>=2.1.0-beta1,<2.1.3", + "theonedemon/phpwhois": "<=4.2.5", + "titon/framework": ">=0,<9.9.99", + "truckersmp/phpwhois": "<=4.3.1", + "twig/twig": "<1.20", + "typo3/cms": ">=6.2,<6.2.30|>=7,<7.6.32|>=8,<8.7.23|>=9,<9.5.4", + "typo3/cms-core": ">=8,<8.7.23|>=9,<9.5.4", + "typo3/flow": ">=1,<1.0.4|>=1.1,<1.1.1|>=2,<2.0.1|>=2.3,<2.3.16|>=3,<3.0.10|>=3.1,<3.1.7|>=3.2,<3.2.7|>=3.3,<3.3.5", + "typo3/neos": ">=1.1,<1.1.3|>=1.2,<1.2.13|>=2,<2.0.4", + "ua-parser/uap-php": "<3.8", + "wallabag/tcpdf": "<6.2.22", + "willdurand/js-translation-bundle": "<2.1.1", + "yiisoft/yii": ">=1.1.14,<1.1.15", + "yiisoft/yii2": "<2.0.15", + "yiisoft/yii2-bootstrap": "<2.0.4", + "yiisoft/yii2-dev": "<2.0.15", + "yiisoft/yii2-elasticsearch": "<2.0.5", + "yiisoft/yii2-gii": "<2.0.4", + "yiisoft/yii2-jui": "<2.0.4", + "yiisoft/yii2-redis": "<2.0.8", + "zendframework/zend-cache": ">=2.4,<2.4.8|>=2.5,<2.5.3", + "zendframework/zend-captcha": ">=2,<2.4.9|>=2.5,<2.5.2", + "zendframework/zend-crypt": ">=2,<2.4.9|>=2.5,<2.5.2", + "zendframework/zend-db": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.10|>=2.3,<2.3.5", + "zendframework/zend-diactoros": ">=1,<1.8.4", + "zendframework/zend-feed": ">=1,<2.10.3", + "zendframework/zend-form": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-http": ">=1,<2.8.1", + "zendframework/zend-json": ">=2.1,<2.1.6|>=2.2,<2.2.6", + "zendframework/zend-ldap": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.8|>=2.3,<2.3.3", + "zendframework/zend-mail": ">=2,<2.4.11|>=2.5,<2.7.2", + "zendframework/zend-navigation": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-session": ">=2,<2.0.99|>=2.1,<2.1.99|>=2.2,<2.2.9|>=2.3,<2.3.4", + "zendframework/zend-validator": ">=2.3,<2.3.6", + "zendframework/zend-view": ">=2,<2.2.7|>=2.3,<2.3.1", + "zendframework/zend-xmlrpc": ">=2.1,<2.1.6|>=2.2,<2.2.6", + "zendframework/zendframework": "<2.5.1", + "zendframework/zendframework1": "<1.12.20", + "zendframework/zendopenid": ">=2,<2.0.2", + "zendframework/zendxml": ">=1,<1.0.1", + "zetacomponents/mail": "<1.8.2", + "zf-commons/zfc-user": "<1.2.2", + "zfcampus/zf-apigility-doctrine": ">=1,<1.0.3", + "zfr/zfr-oauth2-server-module": "<0.1.2" + }, + "type": "metapackage", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "role": "maintainer" + } + ], + "description": "Prevents installation of composer packages with known security vulnerabilities: no API, simply require it", + "time": "2019-02-03T13:48:05+00:00" + }, + { + "name": "sebastian/code-unit-reverse-lookup", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/code-unit-reverse-lookup.git", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/code-unit-reverse-lookup/zipball/4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "reference": "4419fcdb5eabb9caa61a27c7a1db532a6b55dd18", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.7 || ^6.0" + }, + "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": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Looks up which function or method a line of code belongs to", + "homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/", + "time": "2017-03-04T06:30:41+00:00" + }, + { + "name": "sebastian/comparator", + "version": "1.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "reference": "2b7424b55f5047b47ac6e5ccb20b2aea4011d9be", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2 || ~2.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" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2017-01-29T09:50:25+00:00" + }, + { + "name": "sebastian/diff", + "version": "1.4.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.0" + }, + "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": "2017-05-22T07:24:03+00:00" + }, + { + "name": "sebastian/environment", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac", + "shasum": "" + }, + "require": { + "php": "^5.6 || ^7.0" + }, + "require-dev": { + "phpunit/phpunit": "^5.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.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-11-26T07:53:53+00:00" + }, + { + "name": "sebastian/exporter", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "reference": "ce474bdd1a34744d7ac5d6aad3a46d48d9bac4c4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "ext-mbstring": "*", + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.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": "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": "2016-11-19T08:54:04+00:00" + }, + { + "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-12T03:26:01+00:00" + }, + { + "name": "sebastian/object-enumerator", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/object-enumerator.git", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/object-enumerator/zipball/1311872ac850040a79c3c058bea3e22d0f09cbb7", + "reference": "1311872ac850040a79c3c058bea3e22d0f09cbb7", + "shasum": "" + }, + "require": { + "php": ">=5.6", + "sebastian/recursion-context": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Traverses array structures and object graphs to enumerate all referenced objects", + "homepage": "https://github.com/sebastianbergmann/object-enumerator/", + "time": "2017-02-18T15:18:39+00:00" + }, + { + "name": "sebastian/recursion-context", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "reference": "2c3ba150cbec723aa057506e73a8d33bdb286c9a", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.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": "2016-11-19T07:33:16+00:00" + }, + { + "name": "sebastian/resource-operations", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/resource-operations.git", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/resource-operations/zipball/ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "reference": "ce990bb21759f94aeafd30209e8cfcdfa8bc3f52", + "shasum": "" + }, + "require": { + "php": ">=5.6.0" + }, + "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": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides a list of PHP built-in functions that operate on resources", + "homepage": "https://www.github.com/sebastianbergmann/resource-operations", + "time": "2015-07-28T20:34:47+00:00" + }, + { + "name": "sebastian/version", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/99732be0ddb3361e16ad77b68ba41efc8e979019", + "reference": "99732be0ddb3361e16ad77b68ba41efc8e979019", + "shasum": "" + }, + "require": { + "php": ">=5.6" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.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": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2016-10-03T07:35:21+00:00" + }, + { + "name": "sensiolabs/security-checker", + "version": "v5.0.3", + "source": { + "type": "git", + "url": "https://github.com/sensiolabs/security-checker.git", + "reference": "46be3f58adac13084497961e10eed9a7fb4d44d1" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sensiolabs/security-checker/zipball/46be3f58adac13084497961e10eed9a7fb4d44d1", + "reference": "46be3f58adac13084497961e10eed9a7fb4d44d1", + "shasum": "" + }, + "require": { + "composer/ca-bundle": "^1.0", + "php": ">=5.5.9", + "symfony/console": "~2.7|~3.0|~4.0" + }, + "bin": [ + "security-checker" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.0-dev" + } + }, + "autoload": { + "psr-4": { + "SensioLabs\\Security\\": "SensioLabs/Security" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien.potencier@gmail.com" + } + ], + "description": "A security checker for your composer.lock", + "time": "2018-12-19T17:14:59+00:00" + }, + { + "name": "squizlabs/php_codesniffer", + "version": "3.4.0", + "source": { + "type": "git", + "url": "https://github.com/squizlabs/PHP_CodeSniffer.git", + "reference": "379deb987e26c7cd103a7b387aea178baec96e48" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/379deb987e26c7cd103a7b387aea178baec96e48", + "reference": "379deb987e26c7cd103a7b387aea178baec96e48", + "shasum": "" + }, + "require": { + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*", + "php": ">=5.4.0" + }, + "require-dev": { + "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0" + }, + "bin": [ + "bin/phpcs", + "bin/phpcbf" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "lead" + } + ], + "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.", + "homepage": "http://www.squizlabs.com/php-codesniffer", + "keywords": [ + "phpcs", + "standards" + ], + "time": "2018-12-19T23:57:18+00:00" + }, + { + "name": "symfony/console", + "version": "v3.4.22", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "069bf3f0e8f871a2169a06e43d9f3f03f355e9be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/069bf3f0e8f871a2169a06e43d9f3f03f355e9be", + "reference": "069bf3f0e8f871a2169a06e43d9f3f03f355e9be", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" + }, + "provide": { + "psr/log-implementation": "1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/lock": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-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": "2019-01-25T10:42:12+00:00" + }, + { + "name": "symfony/debug", + "version": "v3.4.22", + "source": { + "type": "git", + "url": "https://github.com/symfony/debug.git", + "reference": "667a26c4dd6bc75c67f06bc9bcd015bdecc7cbb8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/debug/zipball/667a26c4dd6bc75c67f06bc9bcd015bdecc7cbb8", + "reference": "667a26c4dd6bc75c67f06bc9bcd015bdecc7cbb8", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "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/http-kernel": "~2.8|~3.0|~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-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": "2019-01-25T10:19:25+00:00" + }, + { + "name": "symfony/yaml", + "version": "v3.4.22", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ba11776e9e6c15ad5759a07bffb15899bac75c2d", + "reference": "ba11776e9e6c15ad5759a07bffb15899bac75c2d", + "shasum": "" + }, + "require": { + "php": "^5.5.9|>=7.0.8", + "symfony/polyfill-ctype": "~1.8" + }, + "conflict": { + "symfony/console": "<3.4" + }, + "require-dev": { + "symfony/console": "~3.4|~4.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.4-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": "2019-01-16T10:59:17+00:00" + }, + { + "name": "webmozart/assert", + "version": "1.4.0", + "source": { + "type": "git", + "url": "https://github.com/webmozart/assert.git", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/webmozart/assert/zipball/83e253c8e0be5b0257b881e1827274667c5c17a9", + "reference": "83e253c8e0be5b0257b881e1827274667c5c17a9", + "shasum": "" + }, + "require": { + "php": "^5.3.3 || ^7.0", + "symfony/polyfill-ctype": "^1.8" + }, + "require-dev": { + "phpunit/phpunit": "^4.6", + "sebastian/version": "^1.0.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Webmozart\\Assert\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Bernhard Schussek", + "email": "bschussek@gmail.com" + } + ], + "description": "Assertions to validate method input/output with nice error messages.", + "keywords": [ + "assert", + "check", + "validate" ], - "time": "2014-02-13 10:19:29" + "time": "2018-12-25T11:19:39+00:00" } ], - "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "roave/security-advisories": 20 + }, "prefer-stable": false, "prefer-lowest": false, "platform": [], diff --git a/scripts/jenkinslaunch.sh b/scripts/jenkinslaunch.sh index 8b9ecc47d..344f39808 100755 --- a/scripts/jenkinslaunch.sh +++ b/scripts/jenkinslaunch.sh @@ -34,9 +34,9 @@ mkdir -p $TARGET \ && git archive $LAUNCHREF | tar xC $TARGET \ && (echo $TARGET ; echo $LAUNCHREF) > $TARGET/web/release.txt \ && ln -s $TARGETBASE/config.php $TARGET/config/config.php \ +&& composer install -o --prefer-dist --no-dev --no-progress --working-dir=$TARGET \ && ln -s $TARGET $TARGETBASE/www.new \ && mv -Tf $TARGETBASE/www.new $TARGETBASE/www \ && rm -rf /tmp/joindin-twig-cache/live \ && rm -rf /tmp/joindin-twig-cache/test " - diff --git a/tests/Event/EventEntityTest.php b/tests/Event/EventEntityTest.php index 10d117d9f..6910dec94 100644 --- a/tests/Event/EventEntityTest.php +++ b/tests/Event/EventEntityTest.php @@ -12,7 +12,7 @@ public function setUp() { // Not used at the moment, but it's here for future use when we // want to provide data to the class - $this->eventData = new stdClass($data); + $this->eventData = new stdClass(); $this->eventData->name = "Test event name"; $this->eventData->icon = "Test event icon"; $this->eventData->start_date = "Test event start date"; diff --git a/vendor/autoload.php b/vendor/autoload.php deleted file mode 100644 index dd42561e9..000000000 --- a/vendor/autoload.php +++ /dev/null @@ -1,7 +0,0 @@ - - * Jordi Boggiano - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Composer\Autoload; - -/** - * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. - * - * $loader = new \Composer\Autoload\ClassLoader(); - * - * // register classes with namespaces - * $loader->add('Symfony\Component', __DIR__.'/component'); - * $loader->add('Symfony', __DIR__.'/framework'); - * - * // activate the autoloader - * $loader->register(); - * - * // to enable searching the include path (eg. for PEAR packages) - * $loader->setUseIncludePath(true); - * - * In this example, if you try to use a class in the Symfony\Component - * namespace or one of its children (Symfony\Component\Console for instance), - * the autoloader will first look for the class under the component/ - * directory, and it will then fallback to the framework/ directory if not - * found before giving up. - * - * This class is loosely based on the Symfony UniversalClassLoader. - * - * @author Fabien Potencier - * @author Jordi Boggiano - * @see http://www.php-fig.org/psr/psr-0/ - * @see http://www.php-fig.org/psr/psr-4/ - */ -class ClassLoader -{ - // PSR-4 - private $prefixLengthsPsr4 = array(); - private $prefixDirsPsr4 = array(); - private $fallbackDirsPsr4 = array(); - - // PSR-0 - private $prefixesPsr0 = array(); - private $fallbackDirsPsr0 = array(); - - private $useIncludePath = false; - private $classMap = array(); - - private $classMapAuthoritative = false; - - public function getPrefixes() - { - if (!empty($this->prefixesPsr0)) { - return call_user_func_array('array_merge', $this->prefixesPsr0); - } - - return array(); - } - - public function getPrefixesPsr4() - { - return $this->prefixDirsPsr4; - } - - public function getFallbackDirs() - { - return $this->fallbackDirsPsr0; - } - - public function getFallbackDirsPsr4() - { - return $this->fallbackDirsPsr4; - } - - public function getClassMap() - { - return $this->classMap; - } - - /** - * @param array $classMap Class to filename map - */ - public function addClassMap(array $classMap) - { - if ($this->classMap) { - $this->classMap = array_merge($this->classMap, $classMap); - } else { - $this->classMap = $classMap; - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, either - * appending or prepending to the ones previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - */ - public function add($prefix, $paths, $prepend = false) - { - if (!$prefix) { - if ($prepend) { - $this->fallbackDirsPsr0 = array_merge( - (array) $paths, - $this->fallbackDirsPsr0 - ); - } else { - $this->fallbackDirsPsr0 = array_merge( - $this->fallbackDirsPsr0, - (array) $paths - ); - } - - return; - } - - $first = $prefix[0]; - if (!isset($this->prefixesPsr0[$first][$prefix])) { - $this->prefixesPsr0[$first][$prefix] = (array) $paths; - - return; - } - if ($prepend) { - $this->prefixesPsr0[$first][$prefix] = array_merge( - (array) $paths, - $this->prefixesPsr0[$first][$prefix] - ); - } else { - $this->prefixesPsr0[$first][$prefix] = array_merge( - $this->prefixesPsr0[$first][$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, either - * appending or prepending to the ones previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories - * - * @throws \InvalidArgumentException - */ - public function addPsr4($prefix, $paths, $prepend = false) - { - if (!$prefix) { - // Register directories for the root namespace. - if ($prepend) { - $this->fallbackDirsPsr4 = array_merge( - (array) $paths, - $this->fallbackDirsPsr4 - ); - } else { - $this->fallbackDirsPsr4 = array_merge( - $this->fallbackDirsPsr4, - (array) $paths - ); - } - } elseif (!isset($this->prefixDirsPsr4[$prefix])) { - // Register directories for a new namespace. - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } elseif ($prepend) { - // Prepend directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - (array) $paths, - $this->prefixDirsPsr4[$prefix] - ); - } else { - // Append directories for an already registered namespace. - $this->prefixDirsPsr4[$prefix] = array_merge( - $this->prefixDirsPsr4[$prefix], - (array) $paths - ); - } - } - - /** - * Registers a set of PSR-0 directories for a given prefix, - * replacing any others previously set for this prefix. - * - * @param string $prefix The prefix - * @param array|string $paths The PSR-0 base directories - */ - public function set($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr0 = (array) $paths; - } else { - $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; - } - } - - /** - * Registers a set of PSR-4 directories for a given namespace, - * replacing any others previously set for this namespace. - * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param array|string $paths The PSR-4 base directories - * - * @throws \InvalidArgumentException - */ - public function setPsr4($prefix, $paths) - { - if (!$prefix) { - $this->fallbackDirsPsr4 = (array) $paths; - } else { - $length = strlen($prefix); - if ('\\' !== $prefix[$length - 1]) { - throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); - } - $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; - $this->prefixDirsPsr4[$prefix] = (array) $paths; - } - } - - /** - * Turns on searching the include path for class files. - * - * @param bool $useIncludePath - */ - public function setUseIncludePath($useIncludePath) - { - $this->useIncludePath = $useIncludePath; - } - - /** - * Can be used to check if the autoloader uses the include path to check - * for classes. - * - * @return bool - */ - public function getUseIncludePath() - { - return $this->useIncludePath; - } - - /** - * Turns off searching the prefix and fallback directories for classes - * that have not been registered with the class map. - * - * @param bool $classMapAuthoritative - */ - public function setClassMapAuthoritative($classMapAuthoritative) - { - $this->classMapAuthoritative = $classMapAuthoritative; - } - - /** - * Should class lookup fail if not found in the current class map? - * - * @return bool - */ - public function isClassMapAuthoritative() - { - return $this->classMapAuthoritative; - } - - /** - * Registers this instance as an autoloader. - * - * @param bool $prepend Whether to prepend the autoloader or not - */ - public function register($prepend = false) - { - spl_autoload_register(array($this, 'loadClass'), true, $prepend); - } - - /** - * Unregisters this instance as an autoloader. - */ - public function unregister() - { - spl_autoload_unregister(array($this, 'loadClass')); - } - - /** - * Loads the given class or interface. - * - * @param string $class The name of the class - * @return bool|null True if loaded, null otherwise - */ - public function loadClass($class) - { - if ($file = $this->findFile($class)) { - includeFile($file); - - return true; - } - } - - /** - * Finds the path to the file where the class is defined. - * - * @param string $class The name of the class - * - * @return string|false The path if found, false otherwise - */ - public function findFile($class) - { - // work around for PHP 5.3.0 - 5.3.2 https://bugs.php.net/50731 - if ('\\' == $class[0]) { - $class = substr($class, 1); - } - - // class map lookup - if (isset($this->classMap[$class])) { - return $this->classMap[$class]; - } - if ($this->classMapAuthoritative) { - return false; - } - - $file = $this->findFileWithExtension($class, '.php'); - - // Search for Hack files if we are running on HHVM - if ($file === null && defined('HHVM_VERSION')) { - $file = $this->findFileWithExtension($class, '.hh'); - } - - if ($file === null) { - // Remember that this class does not exist. - return $this->classMap[$class] = false; - } - - return $file; - } - - private function findFileWithExtension($class, $ext) - { - // PSR-4 lookup - $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; - - $first = $class[0]; - if (isset($this->prefixLengthsPsr4[$first])) { - foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) { - if (0 === strpos($class, $prefix)) { - foreach ($this->prefixDirsPsr4[$prefix] as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { - return $file; - } - } - } - } - } - - // PSR-4 fallback dirs - foreach ($this->fallbackDirsPsr4 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { - return $file; - } - } - - // PSR-0 lookup - if (false !== $pos = strrpos($class, '\\')) { - // namespaced class name - $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) - . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); - } else { - // PEAR-like class name - $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; - } - - if (isset($this->prefixesPsr0[$first])) { - foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { - if (0 === strpos($class, $prefix)) { - foreach ($dirs as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - } - } - } - - // PSR-0 fallback dirs - foreach ($this->fallbackDirsPsr0 as $dir) { - if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { - return $file; - } - } - - // PSR-0 include paths. - if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { - return $file; - } - } -} - -/** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - */ -function includeFile($file) -{ - include $file; -} diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE deleted file mode 100644 index 1a2812488..000000000 --- a/vendor/composer/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ - -Copyright (c) 2016 Nils Adermann, Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. - diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php deleted file mode 100644 index d95d9e316..000000000 --- a/vendor/composer/autoload_classmap.php +++ /dev/null @@ -1,13 +0,0 @@ - $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/Collator.php', - 'IntlDateFormatter' => $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/IntlDateFormatter.php', - 'Locale' => $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/Locale.php', - 'NumberFormatter' => $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/NumberFormatter.php', -); diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php deleted file mode 100644 index 74f03d66e..000000000 --- a/vendor/composer/autoload_files.php +++ /dev/null @@ -1,13 +0,0 @@ - $vendorDir . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/functions.php', - 'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php', - 'a0edc8309cc5e1d60e3047b5df6b7052' => $vendorDir . '/guzzlehttp/psr7/src/functions_include.php', - '37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php', -); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php deleted file mode 100644 index ceab4a00f..000000000 --- a/vendor/composer/autoload_namespaces.php +++ /dev/null @@ -1,33 +0,0 @@ - array($baseDir . '/app/src', $baseDir . '/tests'), - 'Twig_' => array($vendorDir . '/twig/twig/lib'), - 'Talk' => array($baseDir . '/app/src', $baseDir . '/tests'), - 'Symfony\\Component\\Validator\\' => array($vendorDir . '/symfony/validator'), - 'Symfony\\Component\\Translation\\' => array($vendorDir . '/symfony/translation'), - 'Symfony\\Component\\Security\\Csrf\\' => array($vendorDir . '/symfony/security-csrf'), - 'Symfony\\Component\\Security\\Core\\' => array($vendorDir . '/symfony/security-core'), - 'Symfony\\Component\\PropertyAccess\\' => array($vendorDir . '/symfony/property-access'), - 'Symfony\\Component\\OptionsResolver\\' => array($vendorDir . '/symfony/options-resolver'), - 'Symfony\\Component\\Intl\\' => array($vendorDir . '/symfony/intl'), - 'Symfony\\Component\\Form\\' => array($vendorDir . '/symfony/form'), - 'Symfony\\Component\\EventDispatcher\\' => array($vendorDir . '/symfony/event-dispatcher'), - 'Symfony\\Bridge\\Twig\\' => array($vendorDir . '/symfony/twig-bridge'), - 'Slim\\Views' => array($vendorDir . '/slim/views'), - 'Slim' => array($vendorDir . '/slim/slim'), - 'Search' => array($baseDir . '/app/src', $baseDir . '/tests'), - 'Predis' => array($vendorDir . '/predis/predis/lib'), - 'Middleware' => array($baseDir . '/app/src', $baseDir . '/tests'), - 'Language' => array($baseDir . '/app/src', $baseDir . '/tests'), - 'Form' => array($baseDir . '/app/src', $baseDir . '/tests'), - 'Event' => array($baseDir . '/app/src', $baseDir . '/tests'), - 'Client' => array($baseDir . '/app/src', $baseDir . '/tests'), - 'Application' => array($baseDir . '/app/src', $baseDir . '/tests'), - 'Apikey' => array($baseDir . '/app/src', $baseDir . '/tests'), -); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php deleted file mode 100644 index f1013f985..000000000 --- a/vendor/composer/autoload_psr4.php +++ /dev/null @@ -1,17 +0,0 @@ - array($vendorDir . '/psr/log/Psr/Log'), - 'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-message/src'), - 'Org_Heigl\\DateRange\\' => array($vendorDir . '/org_heigl/daterange/src'), - 'Org_Heigl\\DateRangeTest\\' => array($vendorDir . '/org_heigl/daterange/tests'), - 'Monolog\\' => array($vendorDir . '/monolog/monolog/src/Monolog'), - 'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'), - 'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'), - 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), -); diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php deleted file mode 100644 index c7dcd8a3a..000000000 --- a/vendor/composer/autoload_real.php +++ /dev/null @@ -1,59 +0,0 @@ - $path) { - $loader->set($namespace, $path); - } - - $map = require __DIR__ . '/autoload_psr4.php'; - foreach ($map as $namespace => $path) { - $loader->setPsr4($namespace, $path); - } - - $classMap = require __DIR__ . '/autoload_classmap.php'; - if ($classMap) { - $loader->addClassMap($classMap); - } - - $loader->register(true); - - $includeFiles = require __DIR__ . '/autoload_files.php'; - foreach ($includeFiles as $fileIdentifier => $file) { - composerRequireea939503be411f5478ca4976fabdaa0c($fileIdentifier, $file); - } - - return $loader; - } -} - -function composerRequireea939503be411f5478ca4976fabdaa0c($fileIdentifier, $file) -{ - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - require $file; - - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - } -} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php deleted file mode 100644 index b3d1a41c3..000000000 --- a/vendor/composer/autoload_static.php +++ /dev/null @@ -1,217 +0,0 @@ - __DIR__ . '/..' . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/functions.php', - 'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php', - 'a0edc8309cc5e1d60e3047b5df6b7052' => __DIR__ . '/..' . '/guzzlehttp/psr7/src/functions_include.php', - '37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php', - ); - - public static $prefixLengthsPsr4 = array ( - 'P' => - array ( - 'Psr\\Log\\' => 8, - 'Psr\\Http\\Message\\' => 17, - ), - 'O' => - array ( - 'Org_Heigl\\DateRange\\' => 20, - 'Org_Heigl\\DateRangeTest\\' => 24, - ), - 'M' => - array ( - 'Monolog\\' => 8, - ), - 'G' => - array ( - 'GuzzleHttp\\Psr7\\' => 16, - 'GuzzleHttp\\Promise\\' => 19, - 'GuzzleHttp\\' => 11, - ), - ); - - public static $prefixDirsPsr4 = array ( - 'Psr\\Log\\' => - array ( - 0 => __DIR__ . '/..' . '/psr/log/Psr/Log', - ), - 'Psr\\Http\\Message\\' => - array ( - 0 => __DIR__ . '/..' . '/psr/http-message/src', - ), - 'Org_Heigl\\DateRange\\' => - array ( - 0 => __DIR__ . '/..' . '/org_heigl/daterange/src', - ), - 'Org_Heigl\\DateRangeTest\\' => - array ( - 0 => __DIR__ . '/..' . '/org_heigl/daterange/tests', - ), - 'Monolog\\' => - array ( - 0 => __DIR__ . '/..' . '/monolog/monolog/src/Monolog', - ), - 'GuzzleHttp\\Psr7\\' => - array ( - 0 => __DIR__ . '/..' . '/guzzlehttp/psr7/src', - ), - 'GuzzleHttp\\Promise\\' => - array ( - 0 => __DIR__ . '/..' . '/guzzlehttp/promises/src', - ), - 'GuzzleHttp\\' => - array ( - 0 => __DIR__ . '/..' . '/guzzlehttp/guzzle/src', - ), - ); - - public static $prefixesPsr0 = array ( - 'U' => - array ( - 'User' => - array ( - 0 => __DIR__ . '/../..' . '/app/src', - 1 => __DIR__ . '/../..' . '/tests', - ), - ), - 'T' => - array ( - 'Twig_' => - array ( - 0 => __DIR__ . '/..' . '/twig/twig/lib', - ), - 'Talk' => - array ( - 0 => __DIR__ . '/../..' . '/app/src', - 1 => __DIR__ . '/../..' . '/tests', - ), - ), - 'S' => - array ( - 'Symfony\\Component\\Validator\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/validator', - ), - 'Symfony\\Component\\Translation\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/translation', - ), - 'Symfony\\Component\\Security\\Csrf\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/security-csrf', - ), - 'Symfony\\Component\\Security\\Core\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/security-core', - ), - 'Symfony\\Component\\PropertyAccess\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/property-access', - ), - 'Symfony\\Component\\OptionsResolver\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/options-resolver', - ), - 'Symfony\\Component\\Intl\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/intl', - ), - 'Symfony\\Component\\Form\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/form', - ), - 'Symfony\\Component\\EventDispatcher\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/event-dispatcher', - ), - 'Symfony\\Bridge\\Twig\\' => - array ( - 0 => __DIR__ . '/..' . '/symfony/twig-bridge', - ), - 'Slim\\Views' => - array ( - 0 => __DIR__ . '/..' . '/slim/views', - ), - 'Slim' => - array ( - 0 => __DIR__ . '/..' . '/slim/slim', - ), - 'Search' => - array ( - 0 => __DIR__ . '/../..' . '/app/src', - 1 => __DIR__ . '/../..' . '/tests', - ), - ), - 'P' => - array ( - 'Predis' => - array ( - 0 => __DIR__ . '/..' . '/predis/predis/lib', - ), - ), - 'M' => - array ( - 'Middleware' => - array ( - 0 => __DIR__ . '/../..' . '/app/src', - 1 => __DIR__ . '/../..' . '/tests', - ), - ), - 'L' => - array ( - 'Language' => - array ( - 0 => __DIR__ . '/../..' . '/app/src', - 1 => __DIR__ . '/../..' . '/tests', - ), - ), - 'F' => - array ( - 'Form' => - array ( - 0 => __DIR__ . '/../..' . '/app/src', - 1 => __DIR__ . '/../..' . '/tests', - ), - ), - 'E' => - array ( - 'Event' => - array ( - 0 => __DIR__ . '/../..' . '/app/src', - 1 => __DIR__ . '/../..' . '/tests', - ), - ), - 'A' => - array ( - 'Application' => - array ( - 0 => __DIR__ . '/../..' . '/app/src', - 1 => __DIR__ . '/../..' . '/tests', - ), - ), - ); - - public static $classMap = array ( - 'Collator' => __DIR__ . '/..' . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/Collator.php', - 'IntlDateFormatter' => __DIR__ . '/..' . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/IntlDateFormatter.php', - 'Locale' => __DIR__ . '/..' . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/Locale.php', - 'NumberFormatter' => __DIR__ . '/..' . '/symfony/intl/Symfony/Component/Intl/Resources/stubs/NumberFormatter.php', - ); - - public static function getInitializer(ClassLoader $loader) - { - return \Closure::bind(function () use ($loader) { - $loader->prefixLengthsPsr4 = ComposerStaticInitea939503be411f5478ca4976fabdaa0c::$prefixLengthsPsr4; - $loader->prefixDirsPsr4 = ComposerStaticInitea939503be411f5478ca4976fabdaa0c::$prefixDirsPsr4; - $loader->prefixesPsr0 = ComposerStaticInitea939503be411f5478ca4976fabdaa0c::$prefixesPsr0; - $loader->classMap = ComposerStaticInitea939503be411f5478ca4976fabdaa0c::$classMap; - - }, null, ClassLoader::class); - } -} diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json deleted file mode 100644 index b1dc168bb..000000000 --- a/vendor/composer/installed.json +++ /dev/null @@ -1,1289 +0,0 @@ -[ - { - "name": "predis/predis", - "version": "v0.8.5", - "version_normalized": "0.8.5.0", - "source": { - "type": "git", - "url": "https://github.com/nrk/predis.git", - "reference": "5f2eea628eb465d866ad2771927d83769c8f956c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/nrk/predis/zipball/5f2eea628eb465d866ad2771927d83769c8f956c", - "reference": "5f2eea628eb465d866ad2771927d83769c8f956c", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "suggest": { - "ext-curl": "Allows access to Webdis when paired with phpiredis", - "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol" - }, - "time": "2014-01-16 14:10:29", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Predis": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Daniele Alessandri", - "email": "suppakilla@gmail.com", - "homepage": "http://clorophilla.net" - } - ], - "description": "Flexible and feature-complete PHP client library for Redis", - "homepage": "http://github.com/nrk/predis", - "keywords": [ - "nosql", - "predis", - "redis" - ] - }, - { - "name": "slim/slim", - "version": "2.4.3", - "version_normalized": "2.4.3.0", - "source": { - "type": "git", - "url": "https://github.com/slimphp/Slim.git", - "reference": "4906b77a07c7bd6ff1a99aea903e940a2d4fa106" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/slimphp/Slim/zipball/4906b77a07c7bd6ff1a99aea903e940a2d4fa106", - "reference": "4906b77a07c7bd6ff1a99aea903e940a2d4fa106", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "suggest": { - "ext-mcrypt": "Required for HTTP cookie encryption" - }, - "time": "2014-04-05 18:33:59", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Slim": "." - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Josh Lockhart", - "email": "info@joshlockhart.com", - "homepage": "http://www.joshlockhart.com/" - } - ], - "description": "Slim Framework, a PHP micro framework", - "homepage": "http://github.com/codeguy/Slim", - "keywords": [ - "microframework", - "rest", - "router" - ] - }, - { - "name": "slim/views", - "version": "0.1.2", - "version_normalized": "0.1.2.0", - "target-dir": "Slim/Views", - "source": { - "type": "git", - "url": "https://github.com/slimphp/Slim-Views.git", - "reference": "f0a05ea0b654218e40de692ed7cddcad1cf4b828" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/slimphp/Slim-Views/zipball/f0a05ea0b654218e40de692ed7cddcad1cf4b828", - "reference": "f0a05ea0b654218e40de692ed7cddcad1cf4b828", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "slim/slim": ">=2.4.0" - }, - "suggest": { - "smarty/smarty": "Smarty templating system", - "twig/twig": "Twig templating system" - }, - "time": "2014-04-03 16:31:10", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-0": { - "Slim\\Views": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Andrew Smith", - "email": "a.smith@silentworks.co.uk", - "homepage": "http://thoughts.silentworks.co.uk/" - }, - { - "name": "Josh Lockhart", - "email": "info@joshlockhart.com", - "homepage": "http://www.joshlockhart.com/" - } - ], - "description": "Smarty and Twig View Parser package for the Slim Framework", - "homepage": "http://github.com/codeguy/Slim-Views", - "keywords": [ - "extensions", - "slimphp", - "templating" - ] - }, - { - "name": "twig/twig", - "version": "v1.15.1", - "version_normalized": "1.15.1.0", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed", - "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed", - "shasum": "" - }, - "require": { - "php": ">=5.2.4" - }, - "time": "2014-02-13 10:19:29", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.15-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Twig_": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "https://github.com/fabpot/Twig/graphs/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "http://twig.sensiolabs.org", - "keywords": [ - "templating" - ] - }, - { - "name": "org_heigl/daterange", - "version": "1.1.0", - "version_normalized": "1.1.0.0", - "source": { - "type": "git", - "url": "https://github.com/heiglandreas/org.heigl.daterange.git", - "reference": "0e91a092bb8d63b715497796d719b876372050c5" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/heiglandreas/org.heigl.daterange/zipball/0e91a092bb8d63b715497796d719b876372050c5", - "reference": "0e91a092bb8d63b715497796d719b876372050c5", - "shasum": "" - }, - "require": { - "php": ">=5.5" - }, - "require-dev": { - "codeclimate/php-test-reporter": "dev-master", - "mockery/mockery": "~0.9", - "phpunit/phpunit": "~4.7@dev", - "squizlabs/php_codesniffer": "~2.0@dev" - }, - "time": "2015-03-08 21:09:01", - "type": "library", - "installation-source": "dist", - "autoload": { - "psr-4": { - "Org_Heigl\\DateRange\\": "src/", - "Org_Heigl\\DateRangeTest\\": "tests/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Andreas Heigl", - "email": "andreas@heigl.org", - "homepage": "http://andreas.heigl.org", - "role": "Developer" - } - ], - "description": "Provides a way to display dateranges", - "homepage": "http://github.com/heiglandreas/daterange", - "keywords": [ - "date", - "daterange", - "datetime", - "range" - ] - }, - { - "name": "symfony/property-access", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/PropertyAccess", - "source": { - "type": "git", - "url": "https://github.com/symfony/property-access.git", - "reference": "b342f127c3ab73dd4069c2104cb76f1a1ef7c7e7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/property-access/zipball/b342f127c3ab73dd4069c2104cb76f1a1ef7c7e7", - "reference": "b342f127c3ab73dd4069c2104cb76f1a1ef7c7e7", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "time": "2015-03-30 15:54:10", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\PropertyAccess\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony PropertyAccess Component", - "homepage": "http://symfony.com", - "keywords": [ - "access", - "array", - "extraction", - "index", - "injection", - "object", - "property", - "property path", - "reflection" - ] - }, - { - "name": "symfony/options-resolver", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/OptionsResolver", - "source": { - "type": "git", - "url": "https://github.com/symfony/options-resolver.git", - "reference": "d619503992eea05eb407a6db76e28dc1b7619416" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/options-resolver/zipball/d619503992eea05eb407a6db76e28dc1b7619416", - "reference": "d619503992eea05eb407a6db76e28dc1b7619416", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "time": "2015-03-13 17:37:22", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\OptionsResolver\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony OptionsResolver Component", - "homepage": "http://symfony.com", - "keywords": [ - "config", - "configuration", - "options" - ] - }, - { - "name": "symfony/intl", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/Intl", - "source": { - "type": "git", - "url": "https://github.com/symfony/intl.git", - "reference": "f6bc51bcce44aadcfa5c3eaaf2e0402ed33b63b1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/intl/zipball/f6bc51bcce44aadcfa5c3eaaf2e0402ed33b63b1", - "reference": "f6bc51bcce44aadcfa5c3eaaf2e0402ed33b63b1", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/filesystem": ">=2.1", - "symfony/phpunit-bridge": "~2.7" - }, - "suggest": { - "ext-intl": "to use the component with locales other than \"en\"" - }, - "time": "2015-03-30 15:54:10", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Intl\\": "" - }, - "classmap": [ - "Symfony/Component/Intl/Resources/stubs" - ], - "files": [ - "Symfony/Component/Intl/Resources/stubs/functions.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - }, - { - "name": "Eriksen Costa", - "email": "eriksen.costa@infranology.com.br" - }, - { - "name": "Igor Wiedler", - "email": "igor@wiedler.ch" - } - ], - "description": "A PHP replacement layer for the C intl extension that includes additional data from the ICU library.", - "homepage": "http://symfony.com", - "keywords": [ - "i18n", - "icu", - "internationalization", - "intl", - "l10n", - "localization" - ] - }, - { - "name": "symfony/event-dispatcher", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/EventDispatcher", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/70f7c8478739ad21e3deef0d977b38c77f1fb284", - "reference": "70f7c8478739ad21e3deef0d977b38c77f1fb284", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.0,>=2.0.5", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/phpunit-bridge": "~2.7", - "symfony/stopwatch": "~2.3" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "time": "2015-03-13 17:37:22", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\EventDispatcher\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/form", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/Form", - "source": { - "type": "git", - "url": "https://github.com/symfony/form.git", - "reference": "538647777973535135a65ec71aab43537da57d33" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/form/zipball/538647777973535135a65ec71aab43537da57d33", - "reference": "538647777973535135a65ec71aab43537da57d33", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1", - "symfony/intl": "~2.3", - "symfony/options-resolver": "~2.6", - "symfony/property-access": "~2.3" - }, - "require-dev": { - "doctrine/collections": "~1.0", - "symfony/http-foundation": "~2.2", - "symfony/http-kernel": "~2.4", - "symfony/phpunit-bridge": "~2.7", - "symfony/security-csrf": "~2.4", - "symfony/translation": "~2.0,>=2.0.5", - "symfony/validator": "~2.6" - }, - "suggest": { - "symfony/framework-bundle": "For templating with PHP.", - "symfony/security-csrf": "For protecting forms against CSRF attacks.", - "symfony/twig-bridge": "For templating with Twig.", - "symfony/validator": "For form validation." - }, - "time": "2015-03-30 15:54:10", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Form\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Form Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/translation", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/Translation", - "source": { - "type": "git", - "url": "https://github.com/symfony/Translation.git", - "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/bd939f05cdaca128f4ddbae1b447d6f0203b60af", - "reference": "bd939f05cdaca128f4ddbae1b447d6f0203b60af", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~2.3,>=2.3.12", - "symfony/intl": "~2.3", - "symfony/phpunit-bridge": "~2.7", - "symfony/yaml": "~2.2" - }, - "suggest": { - "psr/log": "To use logging capability in translator", - "symfony/config": "", - "symfony/yaml": "" - }, - "time": "2015-03-30 15:54:10", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Translation\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Translation Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/validator", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/Validator", - "source": { - "type": "git", - "url": "https://github.com/symfony/Validator.git", - "reference": "85d9b42fe71bf88e7a1e5dec2094605dc9fbff28" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/Validator/zipball/85d9b42fe71bf88e7a1e5dec2094605dc9fbff28", - "reference": "85d9b42fe71bf88e7a1e5dec2094605dc9fbff28", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/translation": "~2.0,>=2.0.5" - }, - "require-dev": { - "doctrine/annotations": "~1.0", - "doctrine/cache": "~1.0", - "doctrine/common": "~2.3", - "egulias/email-validator": "~1.2,>=1.2.1", - "symfony/config": "~2.2", - "symfony/expression-language": "~2.4", - "symfony/http-foundation": "~2.1", - "symfony/intl": "~2.3", - "symfony/phpunit-bridge": "~2.7", - "symfony/property-access": "~2.3", - "symfony/yaml": "~2.0,>=2.0.5" - }, - "suggest": { - "doctrine/annotations": "For using the annotation mapping. You will also need doctrine/cache.", - "doctrine/cache": "For using the default cached annotation reader and metadata cache.", - "egulias/email-validator": "Strict (RFC compliant) email validation", - "symfony/config": "", - "symfony/expression-language": "For using the 2.4 Expression validator", - "symfony/http-foundation": "", - "symfony/intl": "", - "symfony/property-access": "For using the 2.4 Validator API", - "symfony/yaml": "" - }, - "time": "2015-03-30 15:54:10", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Validator\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Validator Component", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/security-core", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/Security/Core", - "source": { - "type": "git", - "url": "https://github.com/symfony/security-core.git", - "reference": "d25c17db741f58c0f615e52006a47f6fb23cd9b3" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/security-core/zipball/d25c17db741f58c0f615e52006a47f6fb23cd9b3", - "reference": "d25c17db741f58c0f615e52006a47f6fb23cd9b3", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "ircmaxell/password-compat": "1.0.*", - "psr/log": "~1.0", - "symfony/event-dispatcher": "~2.1", - "symfony/expression-language": "~2.6", - "symfony/http-foundation": "~2.4", - "symfony/phpunit-bridge": "~2.7", - "symfony/translation": "~2.0,>=2.0.5", - "symfony/validator": "~2.5,>=2.5.5" - }, - "suggest": { - "ircmaxell/password-compat": "For using the BCrypt password encoder in PHP <5.5", - "symfony/event-dispatcher": "", - "symfony/expression-language": "For using the expression voter", - "symfony/http-foundation": "", - "symfony/validator": "For using the user password constraint" - }, - "time": "2015-03-30 15:54:10", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Security\\Core\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Security Component - Core Library", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/security-csrf", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Component/Security/Csrf", - "source": { - "type": "git", - "url": "https://github.com/symfony/security-csrf.git", - "reference": "7cc85bffcb0f3a68cd8be8d2c91da0cc962f152a" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/security-csrf/zipball/7cc85bffcb0f3a68cd8be8d2c91da0cc962f152a", - "reference": "7cc85bffcb0f3a68cd8be8d2c91da0cc962f152a", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "symfony/security-core": "~2.4" - }, - "require-dev": { - "symfony/http-foundation": "~2.1", - "symfony/phpunit-bridge": "~2.7" - }, - "suggest": { - "symfony/http-foundation": "For using the class SessionTokenStorage." - }, - "time": "2015-02-24 11:52:21", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Component\\Security\\Csrf\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Security Component - CSRF Library", - "homepage": "http://symfony.com" - }, - { - "name": "symfony/twig-bridge", - "version": "v2.6.6", - "version_normalized": "2.6.6.0", - "target-dir": "Symfony/Bridge/Twig", - "source": { - "type": "git", - "url": "https://github.com/symfony/twig-bridge.git", - "reference": "d9124ca70a859dba282729c309beec24f6aafb18" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/twig-bridge/zipball/d9124ca70a859dba282729c309beec24f6aafb18", - "reference": "d9124ca70a859dba282729c309beec24f6aafb18", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "twig/twig": "~1.13,>=1.13.1" - }, - "require-dev": { - "symfony/console": "~2.4", - "symfony/expression-language": "~2.4", - "symfony/finder": "~2.3", - "symfony/form": "~2.6,>=2.6.6", - "symfony/http-kernel": "~2.3", - "symfony/intl": "~2.3", - "symfony/phpunit-bridge": "~2.7", - "symfony/routing": "~2.2", - "symfony/security": "~2.4", - "symfony/stopwatch": "~2.2", - "symfony/templating": "~2.1", - "symfony/translation": "~2.2", - "symfony/var-dumper": "~2.6", - "symfony/yaml": "~2.0,>=2.0.5" - }, - "suggest": { - "symfony/expression-language": "For using the ExpressionExtension", - "symfony/finder": "", - "symfony/form": "For using the FormExtension", - "symfony/http-kernel": "For using the HttpKernelExtension", - "symfony/routing": "For using the RoutingExtension", - "symfony/security": "For using the SecurityExtension", - "symfony/stopwatch": "For using the StopwatchExtension", - "symfony/templating": "For using the TwigEngine", - "symfony/translation": "For using the TranslationExtension", - "symfony/var-dumper": "For using the DumpExtension", - "symfony/yaml": "For using the YamlExtension" - }, - "time": "2015-03-28 16:22:38", - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Symfony\\Bridge\\Twig\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - }, - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "Symfony Twig Bridge", - "homepage": "http://symfony.com" - }, - { - "name": "guzzlehttp/promises", - "version": "1.0.3", - "version_normalized": "1.0.3.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/promises.git", - "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea", - "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea", - "shasum": "" - }, - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "time": "2015-10-15 22:28:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle promises library", - "keywords": [ - "promise" - ] - }, - { - "name": "psr/http-message", - "version": "1.0", - "version_normalized": "1.0.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", - "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2015-05-04 20:22:00", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ] - }, - { - "name": "guzzlehttp/psr7", - "version": "1.3.1", - "version_normalized": "1.3.1.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/psr7.git", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/psr7/zipball/5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "reference": "5c6447c9df362e8f8093bda8f5d8873fe5c7f65b", - "shasum": "" - }, - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "time": "2016-06-24 23:00:38", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": [ - "src/functions_include.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "PSR-7 message implementation", - "keywords": [ - "http", - "message", - "stream", - "uri" - ] - }, - { - "name": "guzzlehttp/guzzle", - "version": "6.2.1", - "version_normalized": "6.2.1.0", - "source": { - "type": "git", - "url": "https://github.com/guzzle/guzzle.git", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/3f808fba627f2c5b69e2501217bf31af349c1427", - "reference": "3f808fba627f2c5b69e2501217bf31af349c1427", - "shasum": "" - }, - "require": { - "guzzlehttp/promises": "^1.0", - "guzzlehttp/psr7": "^1.3.1", - "php": ">=5.5" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.0", - "psr/log": "^1.0" - }, - "time": "2016-07-15 17:22:37", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "6.2-dev" - } - }, - "installation-source": "dist", - "autoload": { - "files": [ - "src/functions_include.php" - ], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "description": "Guzzle is a PHP HTTP client library", - "homepage": "http://guzzlephp.org/", - "keywords": [ - "client", - "curl", - "framework", - "http", - "http client", - "rest", - "web service" - ] - }, - { - "name": "psr/log", - "version": "1.0.1", - "version_normalized": "1.0.1.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "5277094ed527a1c4477177d102fe4c53551953e0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/5277094ed527a1c4477177d102fe4c53551953e0", - "reference": "5277094ed527a1c4477177d102fe4c53551953e0", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "time": "2016-09-19 16:02:08", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ] - }, - { - "name": "monolog/monolog", - "version": "1.21.0", - "version_normalized": "1.21.0.0", - "source": { - "type": "git", - "url": "https://github.com/Seldaek/monolog.git", - "reference": "f42fbdfd53e306bda545845e4dbfd3e72edb4952" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/Seldaek/monolog/zipball/f42fbdfd53e306bda545845e4dbfd3e72edb4952", - "reference": "f42fbdfd53e306bda545845e4dbfd3e72edb4952", - "shasum": "" - }, - "require": { - "php": ">=5.3.0", - "psr/log": "~1.0" - }, - "provide": { - "psr/log-implementation": "1.0.0" - }, - "require-dev": { - "aws/aws-sdk-php": "^2.4.9", - "doctrine/couchdb": "~1.0@dev", - "graylog2/gelf-php": "~1.0", - "jakub-onderka/php-parallel-lint": "0.9", - "php-amqplib/php-amqplib": "~2.4", - "php-console/php-console": "^3.1.3", - "phpunit/phpunit": "~4.5", - "phpunit/phpunit-mock-objects": "2.3.0", - "ruflin/elastica": ">=0.90 <3.0", - "sentry/sentry": "^0.13", - "swiftmailer/swiftmailer": "~5.3" - }, - "suggest": { - "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", - "doctrine/couchdb": "Allow sending log messages to a CouchDB server", - "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", - "ext-mongo": "Allow sending log messages to a MongoDB server", - "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", - "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", - "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", - "php-console/php-console": "Allow sending log messages to Google Chrome", - "rollbar/rollbar": "Allow sending log messages to Rollbar", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server", - "sentry/sentry": "Allow sending log messages to a Sentry server" - }, - "time": "2016-07-29 03:23:52", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Monolog\\": "src/Monolog" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "description": "Sends your logs to files, sockets, inboxes, databases and various web services", - "homepage": "http://github.com/Seldaek/monolog", - "keywords": [ - "log", - "logging", - "psr-3" - ] - } -] diff --git a/vendor/guzzlehttp/guzzle/.travis.yml b/vendor/guzzlehttp/guzzle/.travis.yml deleted file mode 100644 index a4cd64ccd..000000000 --- a/vendor/guzzlehttp/guzzle/.travis.yml +++ /dev/null @@ -1,41 +0,0 @@ -language: php - -sudo: false - -php: - - 5.5 - - 5.6 - - 7.0 - - hhvm - -before_script: - - curl --version - - composer self-update - - composer install --no-interaction --prefer-source --dev - - ~/.nvm/nvm.sh install v0.6.14 - - ~/.nvm/nvm.sh run v0.6.14 - - '[ "$TRAVIS_PHP_VERSION" != "7.0" ] || echo "xdebug.overload_var_dump = 1" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini' - -script: make test - -matrix: - allow_failures: - - php: hhvm - fast_finish: true - -before_deploy: - - rvm 1.9.3 do gem install mime-types -v 2.6.2 - - make package - -deploy: - provider: releases - api_key: - secure: UpypqlYgsU68QT/x40YzhHXvzWjFwCNo9d+G8KAdm7U9+blFfcWhV1aMdzugvPMl6woXgvJj7qHq5tAL4v6oswCORhpSBfLgOQVFaica5LiHsvWlAedOhxGmnJqMTwuepjBCxXhs3+I8Kof1n4oUL9gKytXjOVCX/f7XU1HiinU= - file: - - build/artifacts/guzzle.phar - - build/artifacts/guzzle.zip - on: - repo: guzzle/guzzle - tags: true - all_branches: true - php: 5.5 diff --git a/vendor/guzzlehttp/guzzle/CHANGELOG.md b/vendor/guzzlehttp/guzzle/CHANGELOG.md deleted file mode 100644 index affddab49..000000000 --- a/vendor/guzzlehttp/guzzle/CHANGELOG.md +++ /dev/null @@ -1,1232 +0,0 @@ -# CHANGELOG - -## 6.2.1 - 2016-07-18 - -* Address HTTP_PROXY security vulnerability, CVE-2016-5385: - https://httpoxy.org/ -* Fixing timeout bug with StreamHandler: - https://github.com/guzzle/guzzle/pull/1488 -* Only read up to `Content-Length` in PHP StreamHandler to avoid timeouts when - a server does not honor `Connection: close`. -* Ignore URI fragment when sending requests. - -## 6.2.0 - 2016-03-21 - -* Feature: added `GuzzleHttp\json_encode` and `GuzzleHttp\json_decode`. - https://github.com/guzzle/guzzle/pull/1389 -* Bug fix: Fix sleep calculation when waiting for delayed requests. - https://github.com/guzzle/guzzle/pull/1324 -* Feature: More flexible history containers. - https://github.com/guzzle/guzzle/pull/1373 -* Bug fix: defer sink stream opening in StreamHandler. - https://github.com/guzzle/guzzle/pull/1377 -* Bug fix: do not attempt to escape cookie values. - https://github.com/guzzle/guzzle/pull/1406 -* Feature: report original content encoding and length on decoded responses. - https://github.com/guzzle/guzzle/pull/1409 -* Bug fix: rewind seekable request bodies before dispatching to cURL. - https://github.com/guzzle/guzzle/pull/1422 -* Bug fix: provide an empty string to `http_build_query` for HHVM workaround. - https://github.com/guzzle/guzzle/pull/1367 - -## 6.1.1 - 2015-11-22 - -* Bug fix: Proxy::wrapSync() now correctly proxies to the appropriate handler - https://github.com/guzzle/guzzle/commit/911bcbc8b434adce64e223a6d1d14e9a8f63e4e4 -* Feature: HandlerStack is now more generic. - https://github.com/guzzle/guzzle/commit/f2102941331cda544745eedd97fc8fd46e1ee33e -* Bug fix: setting verify to false in the StreamHandler now disables peer - verification. https://github.com/guzzle/guzzle/issues/1256 -* Feature: Middleware now uses an exception factory, including more error - context. https://github.com/guzzle/guzzle/pull/1282 -* Feature: better support for disabled functions. - https://github.com/guzzle/guzzle/pull/1287 -* Bug fix: fixed regression where MockHandler was not using `sink`. - https://github.com/guzzle/guzzle/pull/1292 - -## 6.1.0 - 2015-09-08 - -* Feature: Added the `on_stats` request option to provide access to transfer - statistics for requests. https://github.com/guzzle/guzzle/pull/1202 -* Feature: Added the ability to persist session cookies in CookieJars. - https://github.com/guzzle/guzzle/pull/1195 -* Feature: Some compatibility updates for Google APP Engine - https://github.com/guzzle/guzzle/pull/1216 -* Feature: Added support for NO_PROXY to prevent the use of a proxy based on - a simple set of rules. https://github.com/guzzle/guzzle/pull/1197 -* Feature: Cookies can now contain square brackets. - https://github.com/guzzle/guzzle/pull/1237 -* Bug fix: Now correctly parsing `=` inside of quotes in Cookies. - https://github.com/guzzle/guzzle/pull/1232 -* Bug fix: Cusotm cURL options now correctly override curl options of the - same name. https://github.com/guzzle/guzzle/pull/1221 -* Bug fix: Content-Type header is now added when using an explicitly provided - multipart body. https://github.com/guzzle/guzzle/pull/1218 -* Bug fix: Now ignoring Set-Cookie headers that have no name. -* Bug fix: Reason phrase is no longer cast to an int in some cases in the - cURL handler. https://github.com/guzzle/guzzle/pull/1187 -* Bug fix: Remove the Authorization header when redirecting if the Host - header changes. https://github.com/guzzle/guzzle/pull/1207 -* Bug fix: Cookie path matching fixes - https://github.com/guzzle/guzzle/issues/1129 -* Bug fix: Fixing the cURL `body_as_string` setting - https://github.com/guzzle/guzzle/pull/1201 -* Bug fix: quotes are no longer stripped when parsing cookies. - https://github.com/guzzle/guzzle/issues/1172 -* Bug fix: `form_params` and `query` now always uses the `&` separator. - https://github.com/guzzle/guzzle/pull/1163 -* Bug fix: Adding a Content-Length to PHP stream wrapper requests if not set. - https://github.com/guzzle/guzzle/pull/1189 - -## 6.0.2 - 2015-07-04 - -* Fixed a memory leak in the curl handlers in which references to callbacks - were not being removed by `curl_reset`. -* Cookies are now extracted properly before redirects. -* Cookies now allow more character ranges. -* Decoded Content-Encoding responses are now modified to correctly reflect - their state if the encoding was automatically removed by a handler. This - means that the `Content-Encoding` header may be removed an the - `Content-Length` modified to reflect the message size after removing the - encoding. -* Added a more explicit error message when trying to use `form_params` and - `multipart` in the same request. -* Several fixes for HHVM support. -* Functions are now conditionally required using an additional level of - indirection to help with global Composer installations. - -## 6.0.1 - 2015-05-27 - -* Fixed a bug with serializing the `query` request option where the `&` - separator was missing. -* Added a better error message for when `body` is provided as an array. Please - use `form_params` or `multipart` instead. -* Various doc fixes. - -## 6.0.0 - 2015-05-26 - -* See the UPGRADING.md document for more information. -* Added `multipart` and `form_params` request options. -* Added `synchronous` request option. -* Added the `on_headers` request option. -* Fixed `expect` handling. -* No longer adding default middlewares in the client ctor. These need to be - present on the provided handler in order to work. -* Requests are no longer initiated when sending async requests with the - CurlMultiHandler. This prevents unexpected recursion from requests completing - while ticking the cURL loop. -* Removed the semantics of setting `default` to `true`. This is no longer - required now that the cURL loop is not ticked for async requests. -* Added request and response logging middleware. -* No longer allowing self signed certificates when using the StreamHandler. -* Ensuring that `sink` is valid if saving to a file. -* Request exceptions now include a "handler context" which provides handler - specific contextual information. -* Added `GuzzleHttp\RequestOptions` to allow request options to be applied - using constants. -* `$maxHandles` has been removed from CurlMultiHandler. -* `MultipartPostBody` is now part of the `guzzlehttp/psr7` package. - -## 5.3.0 - 2015-05-19 - -* Mock now supports `save_to` -* Marked `AbstractRequestEvent::getTransaction()` as public. -* Fixed a bug in which multiple headers using different casing would overwrite - previous headers in the associative array. -* Added `Utils::getDefaultHandler()` -* Marked `GuzzleHttp\Client::getDefaultUserAgent` as deprecated. -* URL scheme is now always lowercased. - -## 6.0.0-beta.1 - -* Requires PHP >= 5.5 -* Updated to use PSR-7 - * Requires immutable messages, which basically means an event based system - owned by a request instance is no longer possible. - * Utilizing the [Guzzle PSR-7 package](https://github.com/guzzle/psr7). - * Removed the dependency on `guzzlehttp/streams`. These stream abstractions - are available in the `guzzlehttp/psr7` package under the `GuzzleHttp\Psr7` - namespace. -* Added middleware and handler system - * Replaced the Guzzle event and subscriber system with a middleware system. - * No longer depends on RingPHP, but rather places the HTTP handlers directly - in Guzzle, operating on PSR-7 messages. - * Retry logic is now encapsulated in `GuzzleHttp\Middleware::retry`, which - means the `guzzlehttp/retry-subscriber` is now obsolete. - * Mocking responses is now handled using `GuzzleHttp\Handler\MockHandler`. -* Asynchronous responses - * No longer supports the `future` request option to send an async request. - Instead, use one of the `*Async` methods of a client (e.g., `requestAsync`, - `getAsync`, etc.). - * Utilizing `GuzzleHttp\Promise` instead of React's promise library to avoid - recursion required by chaining and forwarding react promises. See - https://github.com/guzzle/promises - * Added `requestAsync` and `sendAsync` to send request asynchronously. - * Added magic methods for `getAsync()`, `postAsync()`, etc. to send requests - asynchronously. -* Request options - * POST and form updates - * Added the `form_fields` and `form_files` request options. - * Removed the `GuzzleHttp\Post` namespace. - * The `body` request option no longer accepts an array for POST requests. - * The `exceptions` request option has been deprecated in favor of the - `http_errors` request options. - * The `save_to` request option has been deprecated in favor of `sink` request - option. -* Clients no longer accept an array of URI template string and variables for - URI variables. You will need to expand URI templates before passing them - into a client constructor or request method. -* Client methods `get()`, `post()`, `put()`, `patch()`, `options()`, etc. are - now magic methods that will send synchronous requests. -* Replaced `Utils.php` with plain functions in `functions.php`. -* Removed `GuzzleHttp\Collection`. -* Removed `GuzzleHttp\BatchResults`. Batched pool results are now returned as - an array. -* Removed `GuzzleHttp\Query`. Query string handling is now handled using an - associative array passed into the `query` request option. The query string - is serialized using PHP's `http_build_query`. If you need more control, you - can pass the query string in as a string. -* `GuzzleHttp\QueryParser` has been replaced with the - `GuzzleHttp\Psr7\parse_query`. - -## 5.2.0 - 2015-01-27 - -* Added `AppliesHeadersInterface` to make applying headers to a request based - on the body more generic and not specific to `PostBodyInterface`. -* Reduced the number of stack frames needed to send requests. -* Nested futures are now resolved in the client rather than the RequestFsm -* Finishing state transitions is now handled in the RequestFsm rather than the - RingBridge. -* Added a guard in the Pool class to not use recursion for request retries. - -## 5.1.0 - 2014-12-19 - -* Pool class no longer uses recursion when a request is intercepted. -* The size of a Pool can now be dynamically adjusted using a callback. - See https://github.com/guzzle/guzzle/pull/943. -* Setting a request option to `null` when creating a request with a client will - ensure that the option is not set. This allows you to overwrite default - request options on a per-request basis. - See https://github.com/guzzle/guzzle/pull/937. -* Added the ability to limit which protocols are allowed for redirects by - specifying a `protocols` array in the `allow_redirects` request option. -* Nested futures due to retries are now resolved when waiting for synchronous - responses. See https://github.com/guzzle/guzzle/pull/947. -* `"0"` is now an allowed URI path. See - https://github.com/guzzle/guzzle/pull/935. -* `Query` no longer typehints on the `$query` argument in the constructor, - allowing for strings and arrays. -* Exceptions thrown in the `end` event are now correctly wrapped with Guzzle - specific exceptions if necessary. - -## 5.0.3 - 2014-11-03 - -This change updates query strings so that they are treated as un-encoded values -by default where the value represents an un-encoded value to send over the -wire. A Query object then encodes the value before sending over the wire. This -means that even value query string values (e.g., ":") are url encoded. This -makes the Query class match PHP's http_build_query function. However, if you -want to send requests over the wire using valid query string characters that do -not need to be encoded, then you can provide a string to Url::setQuery() and -pass true as the second argument to specify that the query string is a raw -string that should not be parsed or encoded (unless a call to getQuery() is -subsequently made, forcing the query-string to be converted into a Query -object). - -## 5.0.2 - 2014-10-30 - -* Added a trailing `\r\n` to multipart/form-data payloads. See - https://github.com/guzzle/guzzle/pull/871 -* Added a `GuzzleHttp\Pool::send()` convenience method to match the docs. -* Status codes are now returned as integers. See - https://github.com/guzzle/guzzle/issues/881 -* No longer overwriting an existing `application/x-www-form-urlencoded` header - when sending POST requests, allowing for customized headers. See - https://github.com/guzzle/guzzle/issues/877 -* Improved path URL serialization. - - * No longer double percent-encoding characters in the path or query string if - they are already encoded. - * Now properly encoding the supplied path to a URL object, instead of only - encoding ' ' and '?'. - * Note: This has been changed in 5.0.3 to now encode query string values by - default unless the `rawString` argument is provided when setting the query - string on a URL: Now allowing many more characters to be present in the - query string without being percent encoded. See http://tools.ietf.org/html/rfc3986#appendix-A - -## 5.0.1 - 2014-10-16 - -Bugfix release. - -* Fixed an issue where connection errors still returned response object in - error and end events event though the response is unusable. This has been - corrected so that a response is not returned in the `getResponse` method of - these events if the response did not complete. https://github.com/guzzle/guzzle/issues/867 -* Fixed an issue where transfer statistics were not being populated in the - RingBridge. https://github.com/guzzle/guzzle/issues/866 - -## 5.0.0 - 2014-10-12 - -Adding support for non-blocking responses and some minor API cleanup. - -### New Features - -* Added support for non-blocking responses based on `guzzlehttp/guzzle-ring`. -* Added a public API for creating a default HTTP adapter. -* Updated the redirect plugin to be non-blocking so that redirects are sent - concurrently. Other plugins like this can now be updated to be non-blocking. -* Added a "progress" event so that you can get upload and download progress - events. -* Added `GuzzleHttp\Pool` which implements FutureInterface and transfers - requests concurrently using a capped pool size as efficiently as possible. -* Added `hasListeners()` to EmitterInterface. -* Removed `GuzzleHttp\ClientInterface::sendAll` and marked - `GuzzleHttp\Client::sendAll` as deprecated (it's still there, just not the - recommended way). - -### Breaking changes - -The breaking changes in this release are relatively minor. The biggest thing to -look out for is that request and response objects no longer implement fluent -interfaces. - -* Removed the fluent interfaces (i.e., `return $this`) from requests, - responses, `GuzzleHttp\Collection`, `GuzzleHttp\Url`, - `GuzzleHttp\Query`, `GuzzleHttp\Post\PostBody`, and - `GuzzleHttp\Cookie\SetCookie`. This blog post provides a good outline of - why I did this: http://ocramius.github.io/blog/fluent-interfaces-are-evil/. - This also makes the Guzzle message interfaces compatible with the current - PSR-7 message proposal. -* Removed "functions.php", so that Guzzle is truly PSR-4 compliant. Except - for the HTTP request functions from function.php, these functions are now - implemented in `GuzzleHttp\Utils` using camelCase. `GuzzleHttp\json_decode` - moved to `GuzzleHttp\Utils::jsonDecode`. `GuzzleHttp\get_path` moved to - `GuzzleHttp\Utils::getPath`. `GuzzleHttp\set_path` moved to - `GuzzleHttp\Utils::setPath`. `GuzzleHttp\batch` should now be - `GuzzleHttp\Pool::batch`, which returns an `objectStorage`. Using functions.php - caused problems for many users: they aren't PSR-4 compliant, require an - explicit include, and needed an if-guard to ensure that the functions are not - declared multiple times. -* Rewrote adapter layer. - * Removing all classes from `GuzzleHttp\Adapter`, these are now - implemented as callables that are stored in `GuzzleHttp\Ring\Client`. - * Removed the concept of "parallel adapters". Sending requests serially or - concurrently is now handled using a single adapter. - * Moved `GuzzleHttp\Adapter\Transaction` to `GuzzleHttp\Transaction`. The - Transaction object now exposes the request, response, and client as public - properties. The getters and setters have been removed. -* Removed the "headers" event. This event was only useful for changing the - body a response once the headers of the response were known. You can implement - a similar behavior in a number of ways. One example might be to use a - FnStream that has access to the transaction being sent. For example, when the - first byte is written, you could check if the response headers match your - expectations, and if so, change the actual stream body that is being - written to. -* Removed the `asArray` parameter from - `GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header - value as an array, then use the newly added `getHeaderAsArray()` method of - `MessageInterface`. This change makes the Guzzle interfaces compatible with - the PSR-7 interfaces. -* `GuzzleHttp\Message\MessageFactory` no longer allows subclasses to add - custom request options using double-dispatch (this was an implementation - detail). Instead, you should now provide an associative array to the - constructor which is a mapping of the request option name mapping to a - function that applies the option value to a request. -* Removed the concept of "throwImmediately" from exceptions and error events. - This control mechanism was used to stop a transfer of concurrent requests - from completing. This can now be handled by throwing the exception or by - cancelling a pool of requests or each outstanding future request individually. -* Updated to "GuzzleHttp\Streams" 3.0. - * `GuzzleHttp\Stream\StreamInterface::getContents()` no longer accepts a - `maxLen` parameter. This update makes the Guzzle streams project - compatible with the current PSR-7 proposal. - * `GuzzleHttp\Stream\Stream::__construct`, - `GuzzleHttp\Stream\Stream::factory`, and - `GuzzleHttp\Stream\Utils::create` no longer accept a size in the second - argument. They now accept an associative array of options, including the - "size" key and "metadata" key which can be used to provide custom metadata. - -## 4.2.2 - 2014-09-08 - -* Fixed a memory leak in the CurlAdapter when reusing cURL handles. -* No longer using `request_fulluri` in stream adapter proxies. -* Relative redirects are now based on the last response, not the first response. - -## 4.2.1 - 2014-08-19 - -* Ensuring that the StreamAdapter does not always add a Content-Type header -* Adding automated github releases with a phar and zip - -## 4.2.0 - 2014-08-17 - -* Now merging in default options using a case-insensitive comparison. - Closes https://github.com/guzzle/guzzle/issues/767 -* Added the ability to automatically decode `Content-Encoding` response bodies - using the `decode_content` request option. This is set to `true` by default - to decode the response body if it comes over the wire with a - `Content-Encoding`. Set this value to `false` to disable decoding the - response content, and pass a string to provide a request `Accept-Encoding` - header and turn on automatic response decoding. This feature now allows you - to pass an `Accept-Encoding` header in the headers of a request but still - disable automatic response decoding. - Closes https://github.com/guzzle/guzzle/issues/764 -* Added the ability to throw an exception immediately when transferring - requests in parallel. Closes https://github.com/guzzle/guzzle/issues/760 -* Updating guzzlehttp/streams dependency to ~2.1 -* No longer utilizing the now deprecated namespaced methods from the stream - package. - -## 4.1.8 - 2014-08-14 - -* Fixed an issue in the CurlFactory that caused setting the `stream=false` - request option to throw an exception. - See: https://github.com/guzzle/guzzle/issues/769 -* TransactionIterator now calls rewind on the inner iterator. - See: https://github.com/guzzle/guzzle/pull/765 -* You can now set the `Content-Type` header to `multipart/form-data` - when creating POST requests to force multipart bodies. - See https://github.com/guzzle/guzzle/issues/768 - -## 4.1.7 - 2014-08-07 - -* Fixed an error in the HistoryPlugin that caused the same request and response - to be logged multiple times when an HTTP protocol error occurs. -* Ensuring that cURL does not add a default Content-Type when no Content-Type - has been supplied by the user. This prevents the adapter layer from modifying - the request that is sent over the wire after any listeners may have already - put the request in a desired state (e.g., signed the request). -* Throwing an exception when you attempt to send requests that have the - "stream" set to true in parallel using the MultiAdapter. -* Only calling curl_multi_select when there are active cURL handles. This was - previously changed and caused performance problems on some systems due to PHP - always selecting until the maximum select timeout. -* Fixed a bug where multipart/form-data POST fields were not correctly - aggregated (e.g., values with "&"). - -## 4.1.6 - 2014-08-03 - -* Added helper methods to make it easier to represent messages as strings, - including getting the start line and getting headers as a string. - -## 4.1.5 - 2014-08-02 - -* Automatically retrying cURL "Connection died, retrying a fresh connect" - errors when possible. -* cURL implementation cleanup -* Allowing multiple event subscriber listeners to be registered per event by - passing an array of arrays of listener configuration. - -## 4.1.4 - 2014-07-22 - -* Fixed a bug that caused multi-part POST requests with more than one field to - serialize incorrectly. -* Paths can now be set to "0" -* `ResponseInterface::xml` now accepts a `libxml_options` option and added a - missing default argument that was required when parsing XML response bodies. -* A `save_to` stream is now created lazily, which means that files are not - created on disk unless a request succeeds. - -## 4.1.3 - 2014-07-15 - -* Various fixes to multipart/form-data POST uploads -* Wrapping function.php in an if-statement to ensure Guzzle can be used - globally and in a Composer install -* Fixed an issue with generating and merging in events to an event array -* POST headers are only applied before sending a request to allow you to change - the query aggregator used before uploading -* Added much more robust query string parsing -* Fixed various parsing and normalization issues with URLs -* Fixing an issue where multi-valued headers were not being utilized correctly - in the StreamAdapter - -## 4.1.2 - 2014-06-18 - -* Added support for sending payloads with GET requests - -## 4.1.1 - 2014-06-08 - -* Fixed an issue related to using custom message factory options in subclasses -* Fixed an issue with nested form fields in a multi-part POST -* Fixed an issue with using the `json` request option for POST requests -* Added `ToArrayInterface` to `GuzzleHttp\Cookie\CookieJar` - -## 4.1.0 - 2014-05-27 - -* Added a `json` request option to easily serialize JSON payloads. -* Added a `GuzzleHttp\json_decode()` wrapper to safely parse JSON. -* Added `setPort()` and `getPort()` to `GuzzleHttp\Message\RequestInterface`. -* Added the ability to provide an emitter to a client in the client constructor. -* Added the ability to persist a cookie session using $_SESSION. -* Added a trait that can be used to add event listeners to an iterator. -* Removed request method constants from RequestInterface. -* Fixed warning when invalid request start-lines are received. -* Updated MessageFactory to work with custom request option methods. -* Updated cacert bundle to latest build. - -4.0.2 (2014-04-16) ------------------- - -* Proxy requests using the StreamAdapter now properly use request_fulluri (#632) -* Added the ability to set scalars as POST fields (#628) - -## 4.0.1 - 2014-04-04 - -* The HTTP status code of a response is now set as the exception code of - RequestException objects. -* 303 redirects will now correctly switch from POST to GET requests. -* The default parallel adapter of a client now correctly uses the MultiAdapter. -* HasDataTrait now initializes the internal data array as an empty array so - that the toArray() method always returns an array. - -## 4.0.0 - 2014-03-29 - -* For more information on the 4.0 transition, see: - http://mtdowling.com/blog/2014/03/15/guzzle-4-rc/ -* For information on changes and upgrading, see: - https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40 -* Added `GuzzleHttp\batch()` as a convenience function for sending requests in - parallel without needing to write asynchronous code. -* Restructured how events are added to `GuzzleHttp\ClientInterface::sendAll()`. - You can now pass a callable or an array of associative arrays where each - associative array contains the "fn", "priority", and "once" keys. - -## 4.0.0.rc-2 - 2014-03-25 - -* Removed `getConfig()` and `setConfig()` from clients to avoid confusion - around whether things like base_url, message_factory, etc. should be able to - be retrieved or modified. -* Added `getDefaultOption()` and `setDefaultOption()` to ClientInterface -* functions.php functions were renamed using snake_case to match PHP idioms -* Added support for `HTTP_PROXY`, `HTTPS_PROXY`, and - `GUZZLE_CURL_SELECT_TIMEOUT` environment variables -* Added the ability to specify custom `sendAll()` event priorities -* Added the ability to specify custom stream context options to the stream - adapter. -* Added a functions.php function for `get_path()` and `set_path()` -* CurlAdapter and MultiAdapter now use a callable to generate curl resources -* MockAdapter now properly reads a body and emits a `headers` event -* Updated Url class to check if a scheme and host are set before adding ":" - and "//". This allows empty Url (e.g., "") to be serialized as "". -* Parsing invalid XML no longer emits warnings -* Curl classes now properly throw AdapterExceptions -* Various performance optimizations -* Streams are created with the faster `Stream\create()` function -* Marked deprecation_proxy() as internal -* Test server is now a collection of static methods on a class - -## 4.0.0-rc.1 - 2014-03-15 - -* See https://github.com/guzzle/guzzle/blob/master/UPGRADING.md#3x-to-40 - -## 3.8.1 - 2014-01-28 - -* Bug: Always using GET requests when redirecting from a 303 response -* Bug: CURLOPT_SSL_VERIFYHOST is now correctly set to false when setting `$certificateAuthority` to false in - `Guzzle\Http\ClientInterface::setSslVerification()` -* Bug: RedirectPlugin now uses strict RFC 3986 compliance when combining a base URL with a relative URL -* Bug: The body of a request can now be set to `"0"` -* Sending PHP stream requests no longer forces `HTTP/1.0` -* Adding more information to ExceptionCollection exceptions so that users have more context, including a stack trace of - each sub-exception -* Updated the `$ref` attribute in service descriptions to merge over any existing parameters of a schema (rather than - clobbering everything). -* Merging URLs will now use the query string object from the relative URL (thus allowing custom query aggregators) -* Query strings are now parsed in a way that they do no convert empty keys with no value to have a dangling `=`. - For example `foo&bar=baz` is now correctly parsed and recognized as `foo&bar=baz` rather than `foo=&bar=baz`. -* Now properly escaping the regular expression delimiter when matching Cookie domains. -* Network access is now disabled when loading XML documents - -## 3.8.0 - 2013-12-05 - -* Added the ability to define a POST name for a file -* JSON response parsing now properly walks additionalProperties -* cURL error code 18 is now retried automatically in the BackoffPlugin -* Fixed a cURL error when URLs contain fragments -* Fixed an issue in the BackoffPlugin retry event where it was trying to access all exceptions as if they were - CurlExceptions -* CURLOPT_PROGRESS function fix for PHP 5.5 (69fcc1e) -* Added the ability for Guzzle to work with older versions of cURL that do not support `CURLOPT_TIMEOUT_MS` -* Fixed a bug that was encountered when parsing empty header parameters -* UriTemplate now has a `setRegex()` method to match the docs -* The `debug` request parameter now checks if it is truthy rather than if it exists -* Setting the `debug` request parameter to true shows verbose cURL output instead of using the LogPlugin -* Added the ability to combine URLs using strict RFC 3986 compliance -* Command objects can now return the validation errors encountered by the command -* Various fixes to cache revalidation (#437 and 29797e5) -* Various fixes to the AsyncPlugin -* Cleaned up build scripts - -## 3.7.4 - 2013-10-02 - -* Bug fix: 0 is now an allowed value in a description parameter that has a default value (#430) -* Bug fix: SchemaFormatter now returns an integer when formatting to a Unix timestamp - (see https://github.com/aws/aws-sdk-php/issues/147) -* Bug fix: Cleaned up and fixed URL dot segment removal to properly resolve internal dots -* Minimum PHP version is now properly specified as 5.3.3 (up from 5.3.2) (#420) -* Updated the bundled cacert.pem (#419) -* OauthPlugin now supports adding authentication to headers or query string (#425) - -## 3.7.3 - 2013-09-08 - -* Added the ability to get the exception associated with a request/command when using `MultiTransferException` and - `CommandTransferException`. -* Setting `additionalParameters` of a response to false is now honored when parsing responses with a service description -* Schemas are only injected into response models when explicitly configured. -* No longer guessing Content-Type based on the path of a request. Content-Type is now only guessed based on the path of - an EntityBody. -* Bug fix: ChunkedIterator can now properly chunk a \Traversable as well as an \Iterator. -* Bug fix: FilterIterator now relies on `\Iterator` instead of `\Traversable`. -* Bug fix: Gracefully handling malformed responses in RequestMediator::writeResponseBody() -* Bug fix: Replaced call to canCache with canCacheRequest in the CallbackCanCacheStrategy of the CachePlugin -* Bug fix: Visiting XML attributes first before visiting XML children when serializing requests -* Bug fix: Properly parsing headers that contain commas contained in quotes -* Bug fix: mimetype guessing based on a filename is now case-insensitive - -## 3.7.2 - 2013-08-02 - -* Bug fix: Properly URL encoding paths when using the PHP-only version of the UriTemplate expander - See https://github.com/guzzle/guzzle/issues/371 -* Bug fix: Cookie domains are now matched correctly according to RFC 6265 - See https://github.com/guzzle/guzzle/issues/377 -* Bug fix: GET parameters are now used when calculating an OAuth signature -* Bug fix: Fixed an issue with cache revalidation where the If-None-Match header was being double quoted -* `Guzzle\Common\AbstractHasDispatcher::dispatch()` now returns the event that was dispatched -* `Guzzle\Http\QueryString::factory()` now guesses the most appropriate query aggregator to used based on the input. - See https://github.com/guzzle/guzzle/issues/379 -* Added a way to add custom domain objects to service description parsing using the `operation.parse_class` event. See - https://github.com/guzzle/guzzle/pull/380 -* cURL multi cleanup and optimizations - -## 3.7.1 - 2013-07-05 - -* Bug fix: Setting default options on a client now works -* Bug fix: Setting options on HEAD requests now works. See #352 -* Bug fix: Moving stream factory before send event to before building the stream. See #353 -* Bug fix: Cookies no longer match on IP addresses per RFC 6265 -* Bug fix: Correctly parsing header parameters that are in `<>` and quotes -* Added `cert` and `ssl_key` as request options -* `Host` header can now diverge from the host part of a URL if the header is set manually -* `Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor` was rewritten to change from using SimpleXML to XMLWriter -* OAuth parameters are only added via the plugin if they aren't already set -* Exceptions are now thrown when a URL cannot be parsed -* Returning `false` if `Guzzle\Http\EntityBody::getContentMd5()` fails -* Not setting a `Content-MD5` on a command if calculating the Content-MD5 fails via the CommandContentMd5Plugin - -## 3.7.0 - 2013-06-10 - -* See UPGRADING.md for more information on how to upgrade. -* Requests now support the ability to specify an array of $options when creating a request to more easily modify a - request. You can pass a 'request.options' configuration setting to a client to apply default request options to - every request created by a client (e.g. default query string variables, headers, curl options, etc.). -* Added a static facade class that allows you to use Guzzle with static methods and mount the class to `\Guzzle`. - See `Guzzle\Http\StaticClient::mount`. -* Added `command.request_options` to `Guzzle\Service\Command\AbstractCommand` to pass request options to requests - created by a command (e.g. custom headers, query string variables, timeout settings, etc.). -* Stream size in `Guzzle\Stream\PhpStreamRequestFactory` will now be set if Content-Length is returned in the - headers of a response -* Added `Guzzle\Common\Collection::setPath($path, $value)` to set a value into an array using a nested key - (e.g. `$collection->setPath('foo/baz/bar', 'test'); echo $collection['foo']['bar']['bar'];`) -* ServiceBuilders now support storing and retrieving arbitrary data -* CachePlugin can now purge all resources for a given URI -* CachePlugin can automatically purge matching cached items when a non-idempotent request is sent to a resource -* CachePlugin now uses the Vary header to determine if a resource is a cache hit -* `Guzzle\Http\Message\Response` now implements `\Serializable` -* Added `Guzzle\Cache\CacheAdapterFactory::fromCache()` to more easily create cache adapters -* `Guzzle\Service\ClientInterface::execute()` now accepts an array, single command, or Traversable -* Fixed a bug in `Guzzle\Http\Message\Header\Link::addLink()` -* Better handling of calculating the size of a stream in `Guzzle\Stream\Stream` using fstat() and caching the size -* `Guzzle\Common\Exception\ExceptionCollection` now creates a more readable exception message -* Fixing BC break: Added back the MonologLogAdapter implementation rather than extending from PsrLog so that older - Symfony users can still use the old version of Monolog. -* Fixing BC break: Added the implementation back in for `Guzzle\Http\Message\AbstractMessage::getTokenizedHeader()`. - Now triggering an E_USER_DEPRECATED warning when used. Use `$message->getHeader()->parseParams()`. -* Several performance improvements to `Guzzle\Common\Collection` -* Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`: - createRequest, head, delete, put, patch, post, options, prepareRequest -* Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()` -* Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface` -* Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to - `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a - resource, string, or EntityBody into the $options parameter to specify the download location of the response. -* Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a - default `array()` -* Added `Guzzle\Stream\StreamInterface::isRepeatable` -* Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use - $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or - $client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))`. -* Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use $client->getConfig()->getPath('request.options/headers')`. -* Removed `Guzzle\Http\ClientInterface::expandTemplate()` -* Removed `Guzzle\Http\ClientInterface::setRequestFactory()` -* Removed `Guzzle\Http\ClientInterface::getCurlMulti()` -* Removed `Guzzle\Http\Message\RequestInterface::canCache` -* Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect` -* Removed `Guzzle\Http\Message\RequestInterface::isRedirect` -* Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods. -* You can now enable E_USER_DEPRECATED warnings to see if you are using a deprecated method by setting - `Guzzle\Common\Version::$emitWarnings` to true. -* Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use - `$request->getResponseBody()->isRepeatable()` instead. -* Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use - `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. -* Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use - `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. -* Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead. -* Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead. -* Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated -* Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. - These will work through Guzzle 4.0 -* Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use [request.options][params]. -* Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client. -* Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use $client->getConfig()->getPath('request.options/headers')`. -* Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use $client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. -* Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8. -* Marked `Guzzle\Common\Collection::inject()` as deprecated. -* Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest');` -* CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a - CacheStorageInterface. These two objects and interface will be removed in a future version. -* Always setting X-cache headers on cached responses -* Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin -* `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface - $request, Response $response);` -* `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);` -* `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);` -* Added `CacheStorageInterface::purge($url)` -* `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin - $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache, - CanCacheStrategyInterface $canCache = null)` -* Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)` - -## 3.6.0 - 2013-05-29 - -* ServiceDescription now implements ToArrayInterface -* Added command.hidden_params to blacklist certain headers from being treated as additionalParameters -* Guzzle can now correctly parse incomplete URLs -* Mixed casing of headers are now forced to be a single consistent casing across all values for that header. -* Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution -* Removed the whole changedHeader() function system of messages because all header changes now go through addHeader(). -* Specific header implementations can be created for complex headers. When a message creates a header, it uses a - HeaderFactory which can map specific headers to specific header classes. There is now a Link header and - CacheControl header implementation. -* Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate -* Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti() -* Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in - Guzzle\Http\Curl\RequestMediator -* Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string. -* Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface -* Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders() -* Removed Guzzle\Parser\ParserRegister::get(). Use getParser() -* Removed Guzzle\Parser\ParserRegister::set(). Use registerParser(). -* All response header helper functions return a string rather than mixing Header objects and strings inconsistently -* Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle - directly via interfaces -* Removed the injecting of a request object onto a response object. The methods to get and set a request still exist - but are a no-op until removed. -* Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a - `Guzzle\Service\Command\ArrayCommandInterface`. -* Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response - on a request while the request is still being transferred -* The ability to case-insensitively search for header values -* Guzzle\Http\Message\Header::hasExactHeader -* Guzzle\Http\Message\Header::raw. Use getAll() -* Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object - instead. -* `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess -* Added the ability to cast Model objects to a string to view debug information. - -## 3.5.0 - 2013-05-13 - -* Bug: Fixed a regression so that request responses are parsed only once per oncomplete event rather than multiple times -* Bug: Better cleanup of one-time events across the board (when an event is meant to fire once, it will now remove - itself from the EventDispatcher) -* Bug: `Guzzle\Log\MessageFormatter` now properly writes "total_time" and "connect_time" values -* Bug: Cloning an EntityEnclosingRequest now clones the EntityBody too -* Bug: Fixed an undefined index error when parsing nested JSON responses with a sentAs parameter that reference a - non-existent key -* Bug: All __call() method arguments are now required (helps with mocking frameworks) -* Deprecating Response::getRequest() and now using a shallow clone of a request object to remove a circular reference - to help with refcount based garbage collection of resources created by sending a request -* Deprecating ZF1 cache and log adapters. These will be removed in the next major version. -* Deprecating `Response::getPreviousResponse()` (method signature still exists, but it'sdeprecated). Use the - HistoryPlugin for a history. -* Added a `responseBody` alias for the `response_body` location -* Refactored internals to no longer rely on Response::getRequest() -* HistoryPlugin can now be cast to a string -* HistoryPlugin now logs transactions rather than requests and responses to more accurately keep track of the requests - and responses that are sent over the wire -* Added `getEffectiveUrl()` and `getRedirectCount()` to Response objects - -## 3.4.3 - 2013-04-30 - -* Bug fix: Fixing bug introduced in 3.4.2 where redirect responses are duplicated on the final redirected response -* Added a check to re-extract the temp cacert bundle from the phar before sending each request - -## 3.4.2 - 2013-04-29 - -* Bug fix: Stream objects now work correctly with "a" and "a+" modes -* Bug fix: Removing `Transfer-Encoding: chunked` header when a Content-Length is present -* Bug fix: AsyncPlugin no longer forces HEAD requests -* Bug fix: DateTime timezones are now properly handled when using the service description schema formatter -* Bug fix: CachePlugin now properly handles stale-if-error directives when a request to the origin server fails -* Setting a response on a request will write to the custom request body from the response body if one is specified -* LogPlugin now writes to php://output when STDERR is undefined -* Added the ability to set multiple POST files for the same key in a single call -* application/x-www-form-urlencoded POSTs now use the utf-8 charset by default -* Added the ability to queue CurlExceptions to the MockPlugin -* Cleaned up how manual responses are queued on requests (removed "queued_response" and now using request.before_send) -* Configuration loading now allows remote files - -## 3.4.1 - 2013-04-16 - -* Large refactoring to how CurlMulti handles work. There is now a proxy that sits in front of a pool of CurlMulti - handles. This greatly simplifies the implementation, fixes a couple bugs, and provides a small performance boost. -* Exceptions are now properly grouped when sending requests in parallel -* Redirects are now properly aggregated when a multi transaction fails -* Redirects now set the response on the original object even in the event of a failure -* Bug fix: Model names are now properly set even when using $refs -* Added support for PHP 5.5's CurlFile to prevent warnings with the deprecated @ syntax -* Added support for oauth_callback in OAuth signatures -* Added support for oauth_verifier in OAuth signatures -* Added support to attempt to retrieve a command first literally, then ucfirst, the with inflection - -## 3.4.0 - 2013-04-11 - -* Bug fix: URLs are now resolved correctly based on http://tools.ietf.org/html/rfc3986#section-5.2. #289 -* Bug fix: Absolute URLs with a path in a service description will now properly override the base URL. #289 -* Bug fix: Parsing a query string with a single PHP array value will now result in an array. #263 -* Bug fix: Better normalization of the User-Agent header to prevent duplicate headers. #264. -* Bug fix: Added `number` type to service descriptions. -* Bug fix: empty parameters are removed from an OAuth signature -* Bug fix: Revalidating a cache entry prefers the Last-Modified over the Date header -* Bug fix: Fixed "array to string" error when validating a union of types in a service description -* Bug fix: Removed code that attempted to determine the size of a stream when data is written to the stream -* Bug fix: Not including an `oauth_token` if the value is null in the OauthPlugin. -* Bug fix: Now correctly aggregating successful requests and failed requests in CurlMulti when a redirect occurs. -* The new default CURLOPT_TIMEOUT setting has been increased to 150 seconds so that Guzzle works on poor connections. -* Added a feature to EntityEnclosingRequest::setBody() that will automatically set the Content-Type of the request if - the Content-Type can be determined based on the entity body or the path of the request. -* Added the ability to overwrite configuration settings in a client when grabbing a throwaway client from a builder. -* Added support for a PSR-3 LogAdapter. -* Added a `command.after_prepare` event -* Added `oauth_callback` parameter to the OauthPlugin -* Added the ability to create a custom stream class when using a stream factory -* Added a CachingEntityBody decorator -* Added support for `additionalParameters` in service descriptions to define how custom parameters are serialized. -* The bundled SSL certificate is now provided in the phar file and extracted when running Guzzle from a phar. -* You can now send any EntityEnclosingRequest with POST fields or POST files and cURL will handle creating bodies -* POST requests using a custom entity body are now treated exactly like PUT requests but with a custom cURL method. This - means that the redirect behavior of POST requests with custom bodies will not be the same as POST requests that use - POST fields or files (the latter is only used when emulating a form POST in the browser). -* Lots of cleanup to CurlHandle::factory and RequestFactory::createRequest - -## 3.3.1 - 2013-03-10 - -* Added the ability to create PHP streaming responses from HTTP requests -* Bug fix: Running any filters when parsing response headers with service descriptions -* Bug fix: OauthPlugin fixes to allow for multi-dimensional array signing, and sorting parameters before signing -* Bug fix: Removed the adding of default empty arrays and false Booleans to responses in order to be consistent across - response location visitors. -* Bug fix: Removed the possibility of creating configuration files with circular dependencies -* RequestFactory::create() now uses the key of a POST file when setting the POST file name -* Added xmlAllowEmpty to serialize an XML body even if no XML specific parameters are set - -## 3.3.0 - 2013-03-03 - -* A large number of performance optimizations have been made -* Bug fix: Added 'wb' as a valid write mode for streams -* Bug fix: `Guzzle\Http\Message\Response::json()` now allows scalar values to be returned -* Bug fix: Fixed bug in `Guzzle\Http\Message\Response` where wrapping quotes were stripped from `getEtag()` -* BC: Removed `Guzzle\Http\Utils` class -* BC: Setting a service description on a client will no longer modify the client's command factories. -* BC: Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using - the 'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io' -* BC: `Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getSteamType()` are no longer converted to - lowercase -* Operation parameter objects are now lazy loaded internally -* Added ErrorResponsePlugin that can throw errors for responses defined in service description operations' errorResponses -* Added support for instantiating responseType=class responseClass classes. Classes must implement - `Guzzle\Service\Command\ResponseClassInterface` -* Added support for additionalProperties for top-level parameters in responseType=model responseClasses. These - additional properties also support locations and can be used to parse JSON responses where the outermost part of the - JSON is an array -* Added support for nested renaming of JSON models (rename sentAs to name) -* CachePlugin - * Added support for stale-if-error so that the CachePlugin can now serve stale content from the cache on error - * Debug headers can now added to cached response in the CachePlugin - -## 3.2.0 - 2013-02-14 - -* CurlMulti is no longer reused globally. A new multi object is created per-client. This helps to isolate clients. -* URLs with no path no longer contain a "/" by default -* Guzzle\Http\QueryString does no longer manages the leading "?". This is now handled in Guzzle\Http\Url. -* BadResponseException no longer includes the full request and response message -* Adding setData() to Guzzle\Service\Description\ServiceDescriptionInterface -* Adding getResponseBody() to Guzzle\Http\Message\RequestInterface -* Various updates to classes to use ServiceDescriptionInterface type hints rather than ServiceDescription -* Header values can now be normalized into distinct values when multiple headers are combined with a comma separated list -* xmlEncoding can now be customized for the XML declaration of a XML service description operation -* Guzzle\Http\QueryString now uses Guzzle\Http\QueryAggregator\QueryAggregatorInterface objects to add custom value - aggregation and no longer uses callbacks -* The URL encoding implementation of Guzzle\Http\QueryString can now be customized -* Bug fix: Filters were not always invoked for array service description parameters -* Bug fix: Redirects now use a target response body rather than a temporary response body -* Bug fix: The default exponential backoff BackoffPlugin was not giving when the request threshold was exceeded -* Bug fix: Guzzle now takes the first found value when grabbing Cache-Control directives - -## 3.1.2 - 2013-01-27 - -* Refactored how operation responses are parsed. Visitors now include a before() method responsible for parsing the - response body. For example, the XmlVisitor now parses the XML response into an array in the before() method. -* Fixed an issue where cURL would not automatically decompress responses when the Accept-Encoding header was sent -* CURLOPT_SSL_VERIFYHOST is never set to 1 because it is deprecated (see 5e0ff2ef20f839e19d1eeb298f90ba3598784444) -* Fixed a bug where redirect responses were not chained correctly using getPreviousResponse() -* Setting default headers on a client after setting the user-agent will not erase the user-agent setting - -## 3.1.1 - 2013-01-20 - -* Adding wildcard support to Guzzle\Common\Collection::getPath() -* Adding alias support to ServiceBuilder configs -* Adding Guzzle\Service\Resource\CompositeResourceIteratorFactory and cleaning up factory interface - -## 3.1.0 - 2013-01-12 - -* BC: CurlException now extends from RequestException rather than BadResponseException -* BC: Renamed Guzzle\Plugin\Cache\CanCacheStrategyInterface::canCache() to canCacheRequest() and added CanCacheResponse() -* Added getData to ServiceDescriptionInterface -* Added context array to RequestInterface::setState() -* Bug: Removing hard dependency on the BackoffPlugin from Guzzle\Http -* Bug: Adding required content-type when JSON request visitor adds JSON to a command -* Bug: Fixing the serialization of a service description with custom data -* Made it easier to deal with exceptions thrown when transferring commands or requests in parallel by providing - an array of successful and failed responses -* Moved getPath from Guzzle\Service\Resource\Model to Guzzle\Common\Collection -* Added Guzzle\Http\IoEmittingEntityBody -* Moved command filtration from validators to location visitors -* Added `extends` attributes to service description parameters -* Added getModels to ServiceDescriptionInterface - -## 3.0.7 - 2012-12-19 - -* Fixing phar detection when forcing a cacert to system if null or true -* Allowing filename to be passed to `Guzzle\Http\Message\Request::setResponseBody()` -* Cleaning up `Guzzle\Common\Collection::inject` method -* Adding a response_body location to service descriptions - -## 3.0.6 - 2012-12-09 - -* CurlMulti performance improvements -* Adding setErrorResponses() to Operation -* composer.json tweaks - -## 3.0.5 - 2012-11-18 - -* Bug: Fixing an infinite recursion bug caused from revalidating with the CachePlugin -* Bug: Response body can now be a string containing "0" -* Bug: Using Guzzle inside of a phar uses system by default but now allows for a custom cacert -* Bug: QueryString::fromString now properly parses query string parameters that contain equal signs -* Added support for XML attributes in service description responses -* DefaultRequestSerializer now supports array URI parameter values for URI template expansion -* Added better mimetype guessing to requests and post files - -## 3.0.4 - 2012-11-11 - -* Bug: Fixed a bug when adding multiple cookies to a request to use the correct glue value -* Bug: Cookies can now be added that have a name, domain, or value set to "0" -* Bug: Using the system cacert bundle when using the Phar -* Added json and xml methods to Response to make it easier to parse JSON and XML response data into data structures -* Enhanced cookie jar de-duplication -* Added the ability to enable strict cookie jars that throw exceptions when invalid cookies are added -* Added setStream to StreamInterface to actually make it possible to implement custom rewind behavior for entity bodies -* Added the ability to create any sort of hash for a stream rather than just an MD5 hash - -## 3.0.3 - 2012-11-04 - -* Implementing redirects in PHP rather than cURL -* Added PECL URI template extension and using as default parser if available -* Bug: Fixed Content-Length parsing of Response factory -* Adding rewind() method to entity bodies and streams. Allows for custom rewinding of non-repeatable streams. -* Adding ToArrayInterface throughout library -* Fixing OauthPlugin to create unique nonce values per request - -## 3.0.2 - 2012-10-25 - -* Magic methods are enabled by default on clients -* Magic methods return the result of a command -* Service clients no longer require a base_url option in the factory -* Bug: Fixed an issue with URI templates where null template variables were being expanded - -## 3.0.1 - 2012-10-22 - -* Models can now be used like regular collection objects by calling filter, map, etc. -* Models no longer require a Parameter structure or initial data in the constructor -* Added a custom AppendIterator to get around a PHP bug with the `\AppendIterator` - -## 3.0.0 - 2012-10-15 - -* Rewrote service description format to be based on Swagger - * Now based on JSON schema - * Added nested input structures and nested response models - * Support for JSON and XML input and output models - * Renamed `commands` to `operations` - * Removed dot class notation - * Removed custom types -* Broke the project into smaller top-level namespaces to be more component friendly -* Removed support for XML configs and descriptions. Use arrays or JSON files. -* Removed the Validation component and Inspector -* Moved all cookie code to Guzzle\Plugin\Cookie -* Magic methods on a Guzzle\Service\Client now return the command un-executed. -* Calling getResult() or getResponse() on a command will lazily execute the command if needed. -* Now shipping with cURL's CA certs and using it by default -* Added previousResponse() method to response objects -* No longer sending Accept and Accept-Encoding headers on every request -* Only sending an Expect header by default when a payload is greater than 1MB -* Added/moved client options: - * curl.blacklist to curl.option.blacklist - * Added ssl.certificate_authority -* Added a Guzzle\Iterator component -* Moved plugins from Guzzle\Http\Plugin to Guzzle\Plugin -* Added a more robust backoff retry strategy (replaced the ExponentialBackoffPlugin) -* Added a more robust caching plugin -* Added setBody to response objects -* Updating LogPlugin to use a more flexible MessageFormatter -* Added a completely revamped build process -* Cleaning up Collection class and removing default values from the get method -* Fixed ZF2 cache adapters - -## 2.8.8 - 2012-10-15 - -* Bug: Fixed a cookie issue that caused dot prefixed domains to not match where popular browsers did - -## 2.8.7 - 2012-09-30 - -* Bug: Fixed config file aliases for JSON includes -* Bug: Fixed cookie bug on a request object by using CookieParser to parse cookies on requests -* Bug: Removing the path to a file when sending a Content-Disposition header on a POST upload -* Bug: Hardening request and response parsing to account for missing parts -* Bug: Fixed PEAR packaging -* Bug: Fixed Request::getInfo -* Bug: Fixed cases where CURLM_CALL_MULTI_PERFORM return codes were causing curl transactions to fail -* Adding the ability for the namespace Iterator factory to look in multiple directories -* Added more getters/setters/removers from service descriptions -* Added the ability to remove POST fields from OAuth signatures -* OAuth plugin now supports 2-legged OAuth - -## 2.8.6 - 2012-09-05 - -* Added the ability to modify and build service descriptions -* Added the use of visitors to apply parameters to locations in service descriptions using the dynamic command -* Added a `json` parameter location -* Now allowing dot notation for classes in the CacheAdapterFactory -* Using the union of two arrays rather than an array_merge when extending service builder services and service params -* Ensuring that a service is a string before doing strpos() checks on it when substituting services for references - in service builder config files. -* Services defined in two different config files that include one another will by default replace the previously - defined service, but you can now create services that extend themselves and merge their settings over the previous -* The JsonLoader now supports aliasing filenames with different filenames. This allows you to alias something like - '_default' with a default JSON configuration file. - -## 2.8.5 - 2012-08-29 - -* Bug: Suppressed empty arrays from URI templates -* Bug: Added the missing $options argument from ServiceDescription::factory to enable caching -* Added support for HTTP responses that do not contain a reason phrase in the start-line -* AbstractCommand commands are now invokable -* Added a way to get the data used when signing an Oauth request before a request is sent - -## 2.8.4 - 2012-08-15 - -* Bug: Custom delay time calculations are no longer ignored in the ExponentialBackoffPlugin -* Added the ability to transfer entity bodies as a string rather than streamed. This gets around curl error 65. Set `body_as_string` in a request's curl options to enable. -* Added a StreamInterface, EntityBodyInterface, and added ftell() to Guzzle\Common\Stream -* Added an AbstractEntityBodyDecorator and a ReadLimitEntityBody decorator to transfer only a subset of a decorated stream -* Stream and EntityBody objects will now return the file position to the previous position after a read required operation (e.g. getContentMd5()) -* Added additional response status codes -* Removed SSL information from the default User-Agent header -* DELETE requests can now send an entity body -* Added an EventDispatcher to the ExponentialBackoffPlugin and added an ExponentialBackoffLogger to log backoff retries -* Added the ability of the MockPlugin to consume mocked request bodies -* LogPlugin now exposes request and response objects in the extras array - -## 2.8.3 - 2012-07-30 - -* Bug: Fixed a case where empty POST requests were sent as GET requests -* Bug: Fixed a bug in ExponentialBackoffPlugin that caused fatal errors when retrying an EntityEnclosingRequest that does not have a body -* Bug: Setting the response body of a request to null after completing a request, not when setting the state of a request to new -* Added multiple inheritance to service description commands -* Added an ApiCommandInterface and added `getParamNames()` and `hasParam()` -* Removed the default 2mb size cutoff from the Md5ValidatorPlugin so that it now defaults to validating everything -* Changed CurlMulti::perform to pass a smaller timeout to CurlMulti::executeHandles - -## 2.8.2 - 2012-07-24 - -* Bug: Query string values set to 0 are no longer dropped from the query string -* Bug: A Collection object is no longer created each time a call is made to `Guzzle\Service\Command\AbstractCommand::getRequestHeaders()` -* Bug: `+` is now treated as an encoded space when parsing query strings -* QueryString and Collection performance improvements -* Allowing dot notation for class paths in filters attribute of a service descriptions - -## 2.8.1 - 2012-07-16 - -* Loosening Event Dispatcher dependency -* POST redirects can now be customized using CURLOPT_POSTREDIR - -## 2.8.0 - 2012-07-15 - -* BC: Guzzle\Http\Query - * Query strings with empty variables will always show an equal sign unless the variable is set to QueryString::BLANK (e.g. ?acl= vs ?acl) - * Changed isEncodingValues() and isEncodingFields() to isUrlEncoding() - * Changed setEncodeValues(bool) and setEncodeFields(bool) to useUrlEncoding(bool) - * Changed the aggregation functions of QueryString to be static methods - * Can now use fromString() with querystrings that have a leading ? -* cURL configuration values can be specified in service descriptions using `curl.` prefixed parameters -* Content-Length is set to 0 before emitting the request.before_send event when sending an empty request body -* Cookies are no longer URL decoded by default -* Bug: URI template variables set to null are no longer expanded - -## 2.7.2 - 2012-07-02 - -* BC: Moving things to get ready for subtree splits. Moving Inflection into Common. Moving Guzzle\Http\Parser to Guzzle\Parser. -* BC: Removing Guzzle\Common\Batch\Batch::count() and replacing it with isEmpty() -* CachePlugin now allows for a custom request parameter function to check if a request can be cached -* Bug fix: CachePlugin now only caches GET and HEAD requests by default -* Bug fix: Using header glue when transferring headers over the wire -* Allowing deeply nested arrays for composite variables in URI templates -* Batch divisors can now return iterators or arrays - -## 2.7.1 - 2012-06-26 - -* Minor patch to update version number in UA string -* Updating build process - -## 2.7.0 - 2012-06-25 - -* BC: Inflection classes moved to Guzzle\Inflection. No longer static methods. Can now inject custom inflectors into classes. -* BC: Removed magic setX methods from commands -* BC: Magic methods mapped to service description commands are now inflected in the command factory rather than the client __call() method -* Verbose cURL options are no longer enabled by default. Set curl.debug to true on a client to enable. -* Bug: Now allowing colons in a response start-line (e.g. HTTP/1.1 503 Service Unavailable: Back-end server is at capacity) -* Guzzle\Service\Resource\ResourceIteratorApplyBatched now internally uses the Guzzle\Common\Batch namespace -* Added Guzzle\Service\Plugin namespace and a PluginCollectionPlugin -* Added the ability to set POST fields and files in a service description -* Guzzle\Http\EntityBody::factory() now accepts objects with a __toString() method -* Adding a command.before_prepare event to clients -* Added BatchClosureTransfer and BatchClosureDivisor -* BatchTransferException now includes references to the batch divisor and transfer strategies -* Fixed some tests so that they pass more reliably -* Added Guzzle\Common\Log\ArrayLogAdapter - -## 2.6.6 - 2012-06-10 - -* BC: Removing Guzzle\Http\Plugin\BatchQueuePlugin -* BC: Removing Guzzle\Service\Command\CommandSet -* Adding generic batching system (replaces the batch queue plugin and command set) -* Updating ZF cache and log adapters and now using ZF's composer repository -* Bug: Setting the name of each ApiParam when creating through an ApiCommand -* Adding result_type, result_doc, deprecated, and doc_url to service descriptions -* Bug: Changed the default cookie header casing back to 'Cookie' - -## 2.6.5 - 2012-06-03 - -* BC: Renaming Guzzle\Http\Message\RequestInterface::getResourceUri() to getResource() -* BC: Removing unused AUTH_BASIC and AUTH_DIGEST constants from -* BC: Guzzle\Http\Cookie is now used to manage Set-Cookie data, not Cookie data -* BC: Renaming methods in the CookieJarInterface -* Moving almost all cookie logic out of the CookiePlugin and into the Cookie or CookieJar implementations -* Making the default glue for HTTP headers ';' instead of ',' -* Adding a removeValue to Guzzle\Http\Message\Header -* Adding getCookies() to request interface. -* Making it easier to add event subscribers to HasDispatcherInterface classes. Can now directly call addSubscriber() - -## 2.6.4 - 2012-05-30 - -* BC: Cleaning up how POST files are stored in EntityEnclosingRequest objects. Adding PostFile class. -* BC: Moving ApiCommand specific functionality from the Inspector and on to the ApiCommand -* Bug: Fixing magic method command calls on clients -* Bug: Email constraint only validates strings -* Bug: Aggregate POST fields when POST files are present in curl handle -* Bug: Fixing default User-Agent header -* Bug: Only appending or prepending parameters in commands if they are specified -* Bug: Not requiring response reason phrases or status codes to match a predefined list of codes -* Allowing the use of dot notation for class namespaces when using instance_of constraint -* Added any_match validation constraint -* Added an AsyncPlugin -* Passing request object to the calculateWait method of the ExponentialBackoffPlugin -* Allowing the result of a command object to be changed -* Parsing location and type sub values when instantiating a service description rather than over and over at runtime - -## 2.6.3 - 2012-05-23 - -* [BC] Guzzle\Common\FromConfigInterface no longer requires any config options. -* [BC] Refactoring how POST files are stored on an EntityEnclosingRequest. They are now separate from POST fields. -* You can now use an array of data when creating PUT request bodies in the request factory. -* Removing the requirement that HTTPS requests needed a Cache-Control: public directive to be cacheable. -* [Http] Adding support for Content-Type in multipart POST uploads per upload -* [Http] Added support for uploading multiple files using the same name (foo[0], foo[1]) -* Adding more POST data operations for easier manipulation of POST data. -* You can now set empty POST fields. -* The body of a request is only shown on EntityEnclosingRequest objects that do not use POST files. -* Split the Guzzle\Service\Inspector::validateConfig method into two methods. One to initialize when a command is created, and one to validate. -* CS updates - -## 2.6.2 - 2012-05-19 - -* [Http] Better handling of nested scope requests in CurlMulti. Requests are now always prepares in the send() method rather than the addRequest() method. - -## 2.6.1 - 2012-05-19 - -* [BC] Removing 'path' support in service descriptions. Use 'uri'. -* [BC] Guzzle\Service\Inspector::parseDocBlock is now protected. Adding getApiParamsForClass() with cache. -* [BC] Removing Guzzle\Common\NullObject. Use https://github.com/mtdowling/NullObject if you need it. -* [BC] Removing Guzzle\Common\XmlElement. -* All commands, both dynamic and concrete, have ApiCommand objects. -* Adding a fix for CurlMulti so that if all of the connections encounter some sort of curl error, then the loop exits. -* Adding checks to EntityEnclosingRequest so that empty POST files and fields are ignored. -* Making the method signature of Guzzle\Service\Builder\ServiceBuilder::factory more flexible. - -## 2.6.0 - 2012-05-15 - -* [BC] Moving Guzzle\Service\Builder to Guzzle\Service\Builder\ServiceBuilder -* [BC] Executing a Command returns the result of the command rather than the command -* [BC] Moving all HTTP parsing logic to Guzzle\Http\Parsers. Allows for faster C implementations if needed. -* [BC] Changing the Guzzle\Http\Message\Response::setProtocol() method to accept a protocol and version in separate args. -* [BC] Moving ResourceIterator* to Guzzle\Service\Resource -* [BC] Completely refactored ResourceIterators to iterate over a cloned command object -* [BC] Moved Guzzle\Http\UriTemplate to Guzzle\Http\Parser\UriTemplate\UriTemplate -* [BC] Guzzle\Guzzle is now deprecated -* Moving Guzzle\Common\Guzzle::inject to Guzzle\Common\Collection::inject -* Adding Guzzle\Version class to give version information about Guzzle -* Adding Guzzle\Http\Utils class to provide getDefaultUserAgent() and getHttpDate() -* Adding Guzzle\Curl\CurlVersion to manage caching curl_version() data -* ServiceDescription and ServiceBuilder are now cacheable using similar configs -* Changing the format of XML and JSON service builder configs. Backwards compatible. -* Cleaned up Cookie parsing -* Trimming the default Guzzle User-Agent header -* Adding a setOnComplete() method to Commands that is called when a command completes -* Keeping track of requests that were mocked in the MockPlugin -* Fixed a caching bug in the CacheAdapterFactory -* Inspector objects can be injected into a Command object -* Refactoring a lot of code and tests to be case insensitive when dealing with headers -* Adding Guzzle\Http\Message\HeaderComparison for easy comparison of HTTP headers using a DSL -* Adding the ability to set global option overrides to service builder configs -* Adding the ability to include other service builder config files from within XML and JSON files -* Moving the parseQuery method out of Url and on to QueryString::fromString() as a static factory method. - -## 2.5.0 - 2012-05-08 - -* Major performance improvements -* [BC] Simplifying Guzzle\Common\Collection. Please check to see if you are using features that are now deprecated. -* [BC] Using a custom validation system that allows a flyweight implementation for much faster validation. No longer using Symfony2 Validation component. -* [BC] No longer supporting "{{ }}" for injecting into command or UriTemplates. Use "{}" -* Added the ability to passed parameters to all requests created by a client -* Added callback functionality to the ExponentialBackoffPlugin -* Using microtime in ExponentialBackoffPlugin to allow more granular backoff strategies. -* Rewinding request stream bodies when retrying requests -* Exception is thrown when JSON response body cannot be decoded -* Added configurable magic method calls to clients and commands. This is off by default. -* Fixed a defect that added a hash to every parsed URL part -* Fixed duplicate none generation for OauthPlugin. -* Emitting an event each time a client is generated by a ServiceBuilder -* Using an ApiParams object instead of a Collection for parameters of an ApiCommand -* cache.* request parameters should be renamed to params.cache.* -* Added the ability to set arbitrary curl options on requests (disable_wire, progress, etc.). See CurlHandle. -* Added the ability to disable type validation of service descriptions -* ServiceDescriptions and ServiceBuilders are now Serializable diff --git a/vendor/guzzlehttp/guzzle/LICENSE b/vendor/guzzlehttp/guzzle/LICENSE deleted file mode 100644 index ea7f07c54..000000000 --- a/vendor/guzzlehttp/guzzle/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011-2016 Michael Dowling, https://github.com/mtdowling - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/guzzlehttp/guzzle/README.md b/vendor/guzzlehttp/guzzle/README.md deleted file mode 100644 index 772b18d0b..000000000 --- a/vendor/guzzlehttp/guzzle/README.md +++ /dev/null @@ -1,90 +0,0 @@ -Guzzle, PHP HTTP client -======================= - -[![Build Status](https://travis-ci.org/guzzle/guzzle.svg?branch=master)](https://travis-ci.org/guzzle/guzzle) - -Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and -trivial to integrate with web services. - -- Simple interface for building query strings, POST requests, streaming large - uploads, streaming large downloads, using HTTP cookies, uploading JSON data, - etc... -- Can send both synchronous and asynchronous requests using the same interface. -- Uses PSR-7 interfaces for requests, responses, and streams. This allows you - to utilize other PSR-7 compatible libraries with Guzzle. -- Abstracts away the underlying HTTP transport, allowing you to write - environment and transport agnostic code; i.e., no hard dependency on cURL, - PHP streams, sockets, or non-blocking event loops. -- Middleware system allows you to augment and compose client behavior. - -```php -$client = new \GuzzleHttp\Client(); -$res = $client->request('GET', 'https://api.github.com/user', [ - 'auth' => ['user', 'pass'] -]); -echo $res->getStatusCode(); -// 200 -echo $res->getHeaderLine('content-type'); -// 'application/json; charset=utf8' -echo $res->getBody(); -// {"type":"User"...' - -// Send an asynchronous request. -$request = new \GuzzleHttp\Psr7\Request('GET', 'http://httpbin.org'); -$promise = $client->sendAsync($request)->then(function ($response) { - echo 'I completed! ' . $response->getBody(); -}); -$promise->wait(); -``` - -## Help and docs - -- [Documentation](http://guzzlephp.org/) -- [stackoverflow](http://stackoverflow.com/questions/tagged/guzzle) -- [Gitter](https://gitter.im/guzzle/guzzle) - - -## Installing Guzzle - -The recommended way to install Guzzle is through -[Composer](http://getcomposer.org). - -```bash -# Install Composer -curl -sS https://getcomposer.org/installer | php -``` - -Next, run the Composer command to install the latest stable version of Guzzle: - -```bash -php composer.phar require guzzlehttp/guzzle -``` - -After installing, you need to require Composer's autoloader: - -```php -require 'vendor/autoload.php'; -``` - -You can then later update Guzzle using composer: - - ```bash -composer.phar update - ``` - - -## Version Guidance - -| Version | Status | Packagist | Namespace | Repo | Docs | PSR-7 | -|---------|-------------|---------------------|--------------|---------------------|---------------------|-------| -| 3.x | EOL | `guzzle/guzzle` | `Guzzle` | [v3][guzzle-3-repo] | [v3][guzzle-3-docs] | No | -| 4.x | EOL | `guzzlehttp/guzzle` | `GuzzleHttp` | N/A | N/A | No | -| 5.x | Maintained | `guzzlehttp/guzzle` | `GuzzleHttp` | [v5][guzzle-5-repo] | [v5][guzzle-5-docs] | No | -| 6.x | Latest | `guzzlehttp/guzzle` | `GuzzleHttp` | [v6][guzzle-6-repo] | [v6][guzzle-6-docs] | Yes | - -[guzzle-3-repo]: https://github.com/guzzle/guzzle3 -[guzzle-5-repo]: https://github.com/guzzle/guzzle/tree/5.3 -[guzzle-6-repo]: https://github.com/guzzle/guzzle -[guzzle-3-docs]: http://guzzle3.readthedocs.org/en/latest/ -[guzzle-5-docs]: http://guzzle.readthedocs.org/en/5.3/ -[guzzle-6-docs]: http://guzzle.readthedocs.org/en/latest/ diff --git a/vendor/guzzlehttp/guzzle/UPGRADING.md b/vendor/guzzlehttp/guzzle/UPGRADING.md deleted file mode 100644 index 9e31ddcce..000000000 --- a/vendor/guzzlehttp/guzzle/UPGRADING.md +++ /dev/null @@ -1,1203 +0,0 @@ -Guzzle Upgrade Guide -==================== - -5.0 to 6.0 ----------- - -Guzzle now uses [PSR-7](http://www.php-fig.org/psr/psr-7/) for HTTP messages. -Due to the fact that these messages are immutable, this prompted a refactoring -of Guzzle to use a middleware based system rather than an event system. Any -HTTP message interaction (e.g., `GuzzleHttp\Message\Request`) need to be -updated to work with the new immutable PSR-7 request and response objects. Any -event listeners or subscribers need to be updated to become middleware -functions that wrap handlers (or are injected into a -`GuzzleHttp\HandlerStack`). - -- Removed `GuzzleHttp\BatchResults` -- Removed `GuzzleHttp\Collection` -- Removed `GuzzleHttp\HasDataTrait` -- Removed `GuzzleHttp\ToArrayInterface` -- The `guzzlehttp/streams` dependency has been removed. Stream functionality - is now present in the `GuzzleHttp\Psr7` namespace provided by the - `guzzlehttp/psr7` package. -- Guzzle no longer uses ReactPHP promises and now uses the - `guzzlehttp/promises` library. We use a custom promise library for three - significant reasons: - 1. React promises (at the time of writing this) are recursive. Promise - chaining and promise resolution will eventually blow the stack. Guzzle - promises are not recursive as they use a sort of trampolining technique. - Note: there has been movement in the React project to modify promises to - no longer utilize recursion. - 2. Guzzle needs to have the ability to synchronously block on a promise to - wait for a result. Guzzle promises allows this functionality (and does - not require the use of recursion). - 3. Because we need to be able to wait on a result, doing so using React - promises requires wrapping react promises with RingPHP futures. This - overhead is no longer needed, reducing stack sizes, reducing complexity, - and improving performance. -- `GuzzleHttp\Mimetypes` has been moved to a function in - `GuzzleHttp\Psr7\mimetype_from_extension` and - `GuzzleHttp\Psr7\mimetype_from_filename`. -- `GuzzleHttp\Query` and `GuzzleHttp\QueryParser` have been removed. Query - strings must now be passed into request objects as strings, or provided to - the `query` request option when creating requests with clients. The `query` - option uses PHP's `http_build_query` to convert an array to a string. If you - need a different serialization technique, you will need to pass the query - string in as a string. There are a couple helper functions that will make - working with query strings easier: `GuzzleHttp\Psr7\parse_query` and - `GuzzleHttp\Psr7\build_query`. -- Guzzle no longer has a dependency on RingPHP. Due to the use of a middleware - system based on PSR-7, using RingPHP and it's middleware system as well adds - more complexity than the benefits it provides. All HTTP handlers that were - present in RingPHP have been modified to work directly with PSR-7 messages - and placed in the `GuzzleHttp\Handler` namespace. This significantly reduces - complexity in Guzzle, removes a dependency, and improves performance. RingPHP - will be maintained for Guzzle 5 support, but will no longer be a part of - Guzzle 6. -- As Guzzle now uses a middleware based systems the event system and RingPHP - integration has been removed. Note: while the event system has been removed, - it is possible to add your own type of event system that is powered by the - middleware system. - - Removed the `Event` namespace. - - Removed the `Subscriber` namespace. - - Removed `Transaction` class - - Removed `RequestFsm` - - Removed `RingBridge` - - `GuzzleHttp\Subscriber\Cookie` is now provided by - `GuzzleHttp\Middleware::cookies` - - `GuzzleHttp\Subscriber\HttpError` is now provided by - `GuzzleHttp\Middleware::httpError` - - `GuzzleHttp\Subscriber\History` is now provided by - `GuzzleHttp\Middleware::history` - - `GuzzleHttp\Subscriber\Mock` is now provided by - `GuzzleHttp\Handler\MockHandler` - - `GuzzleHttp\Subscriber\Prepare` is now provided by - `GuzzleHttp\PrepareBodyMiddleware` - - `GuzzleHttp\Subscriber\Redirect` is now provided by - `GuzzleHttp\RedirectMiddleware` -- Guzzle now uses `Psr\Http\Message\UriInterface` (implements in - `GuzzleHttp\Psr7\Uri`) for URI support. `GuzzleHttp\Url` is now gone. -- Static functions in `GuzzleHttp\Utils` have been moved to namespaced - functions under the `GuzzleHttp` namespace. This requires either a Composer - based autoloader or you to include functions.php. -- `GuzzleHttp\ClientInterface::getDefaultOption` has been renamed to - `GuzzleHttp\ClientInterface::getConfig`. -- `GuzzleHttp\ClientInterface::setDefaultOption` has been removed. -- The `json` and `xml` methods of response objects has been removed. With the - migration to strictly adhering to PSR-7 as the interface for Guzzle messages, - adding methods to message interfaces would actually require Guzzle messages - to extend from PSR-7 messages rather then work with them directly. - -## Migrating to middleware - -The change to PSR-7 unfortunately required significant refactoring to Guzzle -due to the fact that PSR-7 messages are immutable. Guzzle 5 relied on an event -system from plugins. The event system relied on mutability of HTTP messages and -side effects in order to work. With immutable messages, you have to change your -workflow to become more about either returning a value (e.g., functional -middlewares) or setting a value on an object. Guzzle v6 has chosen the -functional middleware approach. - -Instead of using the event system to listen for things like the `before` event, -you now create a stack based middleware function that intercepts a request on -the way in and the promise of the response on the way out. This is a much -simpler and more predictable approach than the event system and works nicely -with PSR-7 middleware. Due to the use of promises, the middleware system is -also asynchronous. - -v5: - -```php -use GuzzleHttp\Event\BeforeEvent; -$client = new GuzzleHttp\Client(); -// Get the emitter and listen to the before event. -$client->getEmitter()->on('before', function (BeforeEvent $e) { - // Guzzle v5 events relied on mutation - $e->getRequest()->setHeader('X-Foo', 'Bar'); -}); -``` - -v6: - -In v6, you can modify the request before it is sent using the `mapRequest` -middleware. The idiomatic way in v6 to modify the request/response lifecycle is -to setup a handler middleware stack up front and inject the handler into a -client. - -```php -use GuzzleHttp\Middleware; -// Create a handler stack that has all of the default middlewares attached -$handler = GuzzleHttp\HandlerStack::create(); -// Push the handler onto the handler stack -$handler->push(Middleware::mapRequest(function (RequestInterface $request) { - // Notice that we have to return a request object - return $request->withHeader('X-Foo', 'Bar'); -}); -// Inject the handler into the client -$client = new GuzzleHttp\Client(['handler' => $handler]); -``` - -## POST Requests - -This version added the [`form_params`](http://guzzle.readthedocs.org/en/latest/request-options.html#form_params) -and `multipart` request options. `form_params` is an associative array of -strings or array of strings and is used to serialize an -`application/x-www-form-urlencoded` POST request. The -[`multipart`](http://guzzle.readthedocs.org/en/latest/request-options.html#multipart) -option is now used to send a multipart/form-data POST request. - -`GuzzleHttp\Post\PostFile` has been removed. Use the `multipart` option to add -POST files to a multipart/form-data request. - -The `body` option no longer accepts an array to send POST requests. Please use -`multipart` or `form_params` instead. - -The `base_url` option has been renamed to `base_uri`. - -4.x to 5.0 ----------- - -## Rewritten Adapter Layer - -Guzzle now uses [RingPHP](http://ringphp.readthedocs.org/en/latest) to send -HTTP requests. The `adapter` option in a `GuzzleHttp\Client` constructor -is still supported, but it has now been renamed to `handler`. Instead of -passing a `GuzzleHttp\Adapter\AdapterInterface`, you must now pass a PHP -`callable` that follows the RingPHP specification. - -## Removed Fluent Interfaces - -[Fluent interfaces were removed](http://ocramius.github.io/blog/fluent-interfaces-are-evil) -from the following classes: - -- `GuzzleHttp\Collection` -- `GuzzleHttp\Url` -- `GuzzleHttp\Query` -- `GuzzleHttp\Post\PostBody` -- `GuzzleHttp\Cookie\SetCookie` - -## Removed functions.php - -Removed "functions.php", so that Guzzle is truly PSR-4 compliant. The following -functions can be used as replacements. - -- `GuzzleHttp\json_decode` -> `GuzzleHttp\Utils::jsonDecode` -- `GuzzleHttp\get_path` -> `GuzzleHttp\Utils::getPath` -- `GuzzleHttp\Utils::setPath` -> `GuzzleHttp\set_path` -- `GuzzleHttp\Pool::batch` -> `GuzzleHttp\batch`. This function is, however, - deprecated in favor of using `GuzzleHttp\Pool::batch()`. - -The "procedural" global client has been removed with no replacement (e.g., -`GuzzleHttp\get()`, `GuzzleHttp\post()`, etc.). Use a `GuzzleHttp\Client` -object as a replacement. - -## `throwImmediately` has been removed - -The concept of "throwImmediately" has been removed from exceptions and error -events. This control mechanism was used to stop a transfer of concurrent -requests from completing. This can now be handled by throwing the exception or -by cancelling a pool of requests or each outstanding future request -individually. - -## headers event has been removed - -Removed the "headers" event. This event was only useful for changing the -body a response once the headers of the response were known. You can implement -a similar behavior in a number of ways. One example might be to use a -FnStream that has access to the transaction being sent. For example, when the -first byte is written, you could check if the response headers match your -expectations, and if so, change the actual stream body that is being -written to. - -## Updates to HTTP Messages - -Removed the `asArray` parameter from -`GuzzleHttp\Message\MessageInterface::getHeader`. If you want to get a header -value as an array, then use the newly added `getHeaderAsArray()` method of -`MessageInterface`. This change makes the Guzzle interfaces compatible with -the PSR-7 interfaces. - -3.x to 4.0 ----------- - -## Overarching changes: - -- Now requires PHP 5.4 or greater. -- No longer requires cURL to send requests. -- Guzzle no longer wraps every exception it throws. Only exceptions that are - recoverable are now wrapped by Guzzle. -- Various namespaces have been removed or renamed. -- No longer requiring the Symfony EventDispatcher. A custom event dispatcher - based on the Symfony EventDispatcher is - now utilized in `GuzzleHttp\Event\EmitterInterface` (resulting in significant - speed and functionality improvements). - -Changes per Guzzle 3.x namespace are described below. - -## Batch - -The `Guzzle\Batch` namespace has been removed. This is best left to -third-parties to implement on top of Guzzle's core HTTP library. - -## Cache - -The `Guzzle\Cache` namespace has been removed. (Todo: No suitable replacement -has been implemented yet, but hoping to utilize a PSR cache interface). - -## Common - -- Removed all of the wrapped exceptions. It's better to use the standard PHP - library for unrecoverable exceptions. -- `FromConfigInterface` has been removed. -- `Guzzle\Common\Version` has been removed. The VERSION constant can be found - at `GuzzleHttp\ClientInterface::VERSION`. - -### Collection - -- `getAll` has been removed. Use `toArray` to convert a collection to an array. -- `inject` has been removed. -- `keySearch` has been removed. -- `getPath` no longer supports wildcard expressions. Use something better like - JMESPath for this. -- `setPath` now supports appending to an existing array via the `[]` notation. - -### Events - -Guzzle no longer requires Symfony's EventDispatcher component. Guzzle now uses -`GuzzleHttp\Event\Emitter`. - -- `Symfony\Component\EventDispatcher\EventDispatcherInterface` is replaced by - `GuzzleHttp\Event\EmitterInterface`. -- `Symfony\Component\EventDispatcher\EventDispatcher` is replaced by - `GuzzleHttp\Event\Emitter`. -- `Symfony\Component\EventDispatcher\Event` is replaced by - `GuzzleHttp\Event\Event`, and Guzzle now has an EventInterface in - `GuzzleHttp\Event\EventInterface`. -- `AbstractHasDispatcher` has moved to a trait, `HasEmitterTrait`, and - `HasDispatcherInterface` has moved to `HasEmitterInterface`. Retrieving the - event emitter of a request, client, etc. now uses the `getEmitter` method - rather than the `getDispatcher` method. - -#### Emitter - -- Use the `once()` method to add a listener that automatically removes itself - the first time it is invoked. -- Use the `listeners()` method to retrieve a list of event listeners rather than - the `getListeners()` method. -- Use `emit()` instead of `dispatch()` to emit an event from an emitter. -- Use `attach()` instead of `addSubscriber()` and `detach()` instead of - `removeSubscriber()`. - -```php -$mock = new Mock(); -// 3.x -$request->getEventDispatcher()->addSubscriber($mock); -$request->getEventDispatcher()->removeSubscriber($mock); -// 4.x -$request->getEmitter()->attach($mock); -$request->getEmitter()->detach($mock); -``` - -Use the `on()` method to add a listener rather than the `addListener()` method. - -```php -// 3.x -$request->getEventDispatcher()->addListener('foo', function (Event $event) { /* ... */ } ); -// 4.x -$request->getEmitter()->on('foo', function (Event $event, $name) { /* ... */ } ); -``` - -## Http - -### General changes - -- The cacert.pem certificate has been moved to `src/cacert.pem`. -- Added the concept of adapters that are used to transfer requests over the - wire. -- Simplified the event system. -- Sending requests in parallel is still possible, but batching is no longer a - concept of the HTTP layer. Instead, you must use the `complete` and `error` - events to asynchronously manage parallel request transfers. -- `Guzzle\Http\Url` has moved to `GuzzleHttp\Url`. -- `Guzzle\Http\QueryString` has moved to `GuzzleHttp\Query`. -- QueryAggregators have been rewritten so that they are simply callable - functions. -- `GuzzleHttp\StaticClient` has been removed. Use the functions provided in - `functions.php` for an easy to use static client instance. -- Exceptions in `GuzzleHttp\Exception` have been updated to all extend from - `GuzzleHttp\Exception\TransferException`. - -### Client - -Calling methods like `get()`, `post()`, `head()`, etc. no longer create and -return a request, but rather creates a request, sends the request, and returns -the response. - -```php -// 3.0 -$request = $client->get('/'); -$response = $request->send(); - -// 4.0 -$response = $client->get('/'); - -// or, to mirror the previous behavior -$request = $client->createRequest('GET', '/'); -$response = $client->send($request); -``` - -`GuzzleHttp\ClientInterface` has changed. - -- The `send` method no longer accepts more than one request. Use `sendAll` to - send multiple requests in parallel. -- `setUserAgent()` has been removed. Use a default request option instead. You - could, for example, do something like: - `$client->setConfig('defaults/headers/User-Agent', 'Foo/Bar ' . $client::getDefaultUserAgent())`. -- `setSslVerification()` has been removed. Use default request options instead, - like `$client->setConfig('defaults/verify', true)`. - -`GuzzleHttp\Client` has changed. - -- The constructor now accepts only an associative array. You can include a - `base_url` string or array to use a URI template as the base URL of a client. - You can also specify a `defaults` key that is an associative array of default - request options. You can pass an `adapter` to use a custom adapter, - `batch_adapter` to use a custom adapter for sending requests in parallel, or - a `message_factory` to change the factory used to create HTTP requests and - responses. -- The client no longer emits a `client.create_request` event. -- Creating requests with a client no longer automatically utilize a URI - template. You must pass an array into a creational method (e.g., - `createRequest`, `get`, `put`, etc.) in order to expand a URI template. - -### Messages - -Messages no longer have references to their counterparts (i.e., a request no -longer has a reference to it's response, and a response no loger has a -reference to its request). This association is now managed through a -`GuzzleHttp\Adapter\TransactionInterface` object. You can get references to -these transaction objects using request events that are emitted over the -lifecycle of a request. - -#### Requests with a body - -- `GuzzleHttp\Message\EntityEnclosingRequest` and - `GuzzleHttp\Message\EntityEnclosingRequestInterface` have been removed. The - separation between requests that contain a body and requests that do not - contain a body has been removed, and now `GuzzleHttp\Message\RequestInterface` - handles both use cases. -- Any method that previously accepts a `GuzzleHttp\Response` object now accept a - `GuzzleHttp\Message\ResponseInterface`. -- `GuzzleHttp\Message\RequestFactoryInterface` has been renamed to - `GuzzleHttp\Message\MessageFactoryInterface`. This interface is used to create - both requests and responses and is implemented in - `GuzzleHttp\Message\MessageFactory`. -- POST field and file methods have been removed from the request object. You - must now use the methods made available to `GuzzleHttp\Post\PostBodyInterface` - to control the format of a POST body. Requests that are created using a - standard `GuzzleHttp\Message\MessageFactoryInterface` will automatically use - a `GuzzleHttp\Post\PostBody` body if the body was passed as an array or if - the method is POST and no body is provided. - -```php -$request = $client->createRequest('POST', '/'); -$request->getBody()->setField('foo', 'bar'); -$request->getBody()->addFile(new PostFile('file_key', fopen('/path/to/content', 'r'))); -``` - -#### Headers - -- `GuzzleHttp\Message\Header` has been removed. Header values are now simply - represented by an array of values or as a string. Header values are returned - as a string by default when retrieving a header value from a message. You can - pass an optional argument of `true` to retrieve a header value as an array - of strings instead of a single concatenated string. -- `GuzzleHttp\PostFile` and `GuzzleHttp\PostFileInterface` have been moved to - `GuzzleHttp\Post`. This interface has been simplified and now allows the - addition of arbitrary headers. -- Custom headers like `GuzzleHttp\Message\Header\Link` have been removed. Most - of the custom headers are now handled separately in specific - subscribers/plugins, and `GuzzleHttp\Message\HeaderValues::parseParams()` has - been updated to properly handle headers that contain parameters (like the - `Link` header). - -#### Responses - -- `GuzzleHttp\Message\Response::getInfo()` and - `GuzzleHttp\Message\Response::setInfo()` have been removed. Use the event - system to retrieve this type of information. -- `GuzzleHttp\Message\Response::getRawHeaders()` has been removed. -- `GuzzleHttp\Message\Response::getMessage()` has been removed. -- `GuzzleHttp\Message\Response::calculateAge()` and other cache specific - methods have moved to the CacheSubscriber. -- Header specific helper functions like `getContentMd5()` have been removed. - Just use `getHeader('Content-MD5')` instead. -- `GuzzleHttp\Message\Response::setRequest()` and - `GuzzleHttp\Message\Response::getRequest()` have been removed. Use the event - system to work with request and response objects as a transaction. -- `GuzzleHttp\Message\Response::getRedirectCount()` has been removed. Use the - Redirect subscriber instead. -- `GuzzleHttp\Message\Response::isSuccessful()` and other related methods have - been removed. Use `getStatusCode()` instead. - -#### Streaming responses - -Streaming requests can now be created by a client directly, returning a -`GuzzleHttp\Message\ResponseInterface` object that contains a body stream -referencing an open PHP HTTP stream. - -```php -// 3.0 -use Guzzle\Stream\PhpStreamRequestFactory; -$request = $client->get('/'); -$factory = new PhpStreamRequestFactory(); -$stream = $factory->fromRequest($request); -$data = $stream->read(1024); - -// 4.0 -$response = $client->get('/', ['stream' => true]); -// Read some data off of the stream in the response body -$data = $response->getBody()->read(1024); -``` - -#### Redirects - -The `configureRedirects()` method has been removed in favor of a -`allow_redirects` request option. - -```php -// Standard redirects with a default of a max of 5 redirects -$request = $client->createRequest('GET', '/', ['allow_redirects' => true]); - -// Strict redirects with a custom number of redirects -$request = $client->createRequest('GET', '/', [ - 'allow_redirects' => ['max' => 5, 'strict' => true] -]); -``` - -#### EntityBody - -EntityBody interfaces and classes have been removed or moved to -`GuzzleHttp\Stream`. All classes and interfaces that once required -`GuzzleHttp\EntityBodyInterface` now require -`GuzzleHttp\Stream\StreamInterface`. Creating a new body for a request no -longer uses `GuzzleHttp\EntityBody::factory` but now uses -`GuzzleHttp\Stream\Stream::factory` or even better: -`GuzzleHttp\Stream\create()`. - -- `Guzzle\Http\EntityBodyInterface` is now `GuzzleHttp\Stream\StreamInterface` -- `Guzzle\Http\EntityBody` is now `GuzzleHttp\Stream\Stream` -- `Guzzle\Http\CachingEntityBody` is now `GuzzleHttp\Stream\CachingStream` -- `Guzzle\Http\ReadLimitEntityBody` is now `GuzzleHttp\Stream\LimitStream` -- `Guzzle\Http\IoEmittyinEntityBody` has been removed. - -#### Request lifecycle events - -Requests previously submitted a large number of requests. The number of events -emitted over the lifecycle of a request has been significantly reduced to make -it easier to understand how to extend the behavior of a request. All events -emitted during the lifecycle of a request now emit a custom -`GuzzleHttp\Event\EventInterface` object that contains context providing -methods and a way in which to modify the transaction at that specific point in -time (e.g., intercept the request and set a response on the transaction). - -- `request.before_send` has been renamed to `before` and now emits a - `GuzzleHttp\Event\BeforeEvent` -- `request.complete` has been renamed to `complete` and now emits a - `GuzzleHttp\Event\CompleteEvent`. -- `request.sent` has been removed. Use `complete`. -- `request.success` has been removed. Use `complete`. -- `error` is now an event that emits a `GuzzleHttp\Event\ErrorEvent`. -- `request.exception` has been removed. Use `error`. -- `request.receive.status_line` has been removed. -- `curl.callback.progress` has been removed. Use a custom `StreamInterface` to - maintain a status update. -- `curl.callback.write` has been removed. Use a custom `StreamInterface` to - intercept writes. -- `curl.callback.read` has been removed. Use a custom `StreamInterface` to - intercept reads. - -`headers` is a new event that is emitted after the response headers of a -request have been received before the body of the response is downloaded. This -event emits a `GuzzleHttp\Event\HeadersEvent`. - -You can intercept a request and inject a response using the `intercept()` event -of a `GuzzleHttp\Event\BeforeEvent`, `GuzzleHttp\Event\CompleteEvent`, and -`GuzzleHttp\Event\ErrorEvent` event. - -See: http://docs.guzzlephp.org/en/latest/events.html - -## Inflection - -The `Guzzle\Inflection` namespace has been removed. This is not a core concern -of Guzzle. - -## Iterator - -The `Guzzle\Iterator` namespace has been removed. - -- `Guzzle\Iterator\AppendIterator`, `Guzzle\Iterator\ChunkedIterator`, and - `Guzzle\Iterator\MethodProxyIterator` are nice, but not a core requirement of - Guzzle itself. -- `Guzzle\Iterator\FilterIterator` is no longer needed because an equivalent - class is shipped with PHP 5.4. -- `Guzzle\Iterator\MapIterator` is not really needed when using PHP 5.5 because - it's easier to just wrap an iterator in a generator that maps values. - -For a replacement of these iterators, see https://github.com/nikic/iter - -## Log - -The LogPlugin has moved to https://github.com/guzzle/log-subscriber. The -`Guzzle\Log` namespace has been removed. Guzzle now relies on -`Psr\Log\LoggerInterface` for all logging. The MessageFormatter class has been -moved to `GuzzleHttp\Subscriber\Log\Formatter`. - -## Parser - -The `Guzzle\Parser` namespace has been removed. This was previously used to -make it possible to plug in custom parsers for cookies, messages, URI -templates, and URLs; however, this level of complexity is not needed in Guzzle -so it has been removed. - -- Cookie: Cookie parsing logic has been moved to - `GuzzleHttp\Cookie\SetCookie::fromString`. -- Message: Message parsing logic for both requests and responses has been moved - to `GuzzleHttp\Message\MessageFactory::fromMessage`. Message parsing is only - used in debugging or deserializing messages, so it doesn't make sense for - Guzzle as a library to add this level of complexity to parsing messages. -- UriTemplate: URI template parsing has been moved to - `GuzzleHttp\UriTemplate`. The Guzzle library will automatically use the PECL - URI template library if it is installed. -- Url: URL parsing is now performed in `GuzzleHttp\Url::fromString` (previously - it was `Guzzle\Http\Url::factory()`). If custom URL parsing is necessary, - then developers are free to subclass `GuzzleHttp\Url`. - -## Plugin - -The `Guzzle\Plugin` namespace has been renamed to `GuzzleHttp\Subscriber`. -Several plugins are shipping with the core Guzzle library under this namespace. - -- `GuzzleHttp\Subscriber\Cookie`: Replaces the old CookiePlugin. Cookie jar - code has moved to `GuzzleHttp\Cookie`. -- `GuzzleHttp\Subscriber\History`: Replaces the old HistoryPlugin. -- `GuzzleHttp\Subscriber\HttpError`: Throws errors when a bad HTTP response is - received. -- `GuzzleHttp\Subscriber\Mock`: Replaces the old MockPlugin. -- `GuzzleHttp\Subscriber\Prepare`: Prepares the body of a request just before - sending. This subscriber is attached to all requests by default. -- `GuzzleHttp\Subscriber\Redirect`: Replaces the RedirectPlugin. - -The following plugins have been removed (third-parties are free to re-implement -these if needed): - -- `GuzzleHttp\Plugin\Async` has been removed. -- `GuzzleHttp\Plugin\CurlAuth` has been removed. -- `GuzzleHttp\Plugin\ErrorResponse\ErrorResponsePlugin` has been removed. This - functionality should instead be implemented with event listeners that occur - after normal response parsing occurs in the guzzle/command package. - -The following plugins are not part of the core Guzzle package, but are provided -in separate repositories: - -- `Guzzle\Http\Plugin\BackoffPlugin` has been rewritten to be muchs simpler - to build custom retry policies using simple functions rather than various - chained classes. See: https://github.com/guzzle/retry-subscriber -- `Guzzle\Http\Plugin\Cache\CachePlugin` has moved to - https://github.com/guzzle/cache-subscriber -- `Guzzle\Http\Plugin\Log\LogPlugin` has moved to - https://github.com/guzzle/log-subscriber -- `Guzzle\Http\Plugin\Md5\Md5Plugin` has moved to - https://github.com/guzzle/message-integrity-subscriber -- `Guzzle\Http\Plugin\Mock\MockPlugin` has moved to - `GuzzleHttp\Subscriber\MockSubscriber`. -- `Guzzle\Http\Plugin\Oauth\OauthPlugin` has moved to - https://github.com/guzzle/oauth-subscriber - -## Service - -The service description layer of Guzzle has moved into two separate packages: - -- http://github.com/guzzle/command Provides a high level abstraction over web - services by representing web service operations using commands. -- http://github.com/guzzle/guzzle-services Provides an implementation of - guzzle/command that provides request serialization and response parsing using - Guzzle service descriptions. - -## Stream - -Stream have moved to a separate package available at -https://github.com/guzzle/streams. - -`Guzzle\Stream\StreamInterface` has been given a large update to cleanly take -on the responsibilities of `Guzzle\Http\EntityBody` and -`Guzzle\Http\EntityBodyInterface` now that they have been removed. The number -of methods implemented by the `StreamInterface` has been drastically reduced to -allow developers to more easily extend and decorate stream behavior. - -## Removed methods from StreamInterface - -- `getStream` and `setStream` have been removed to better encapsulate streams. -- `getMetadata` and `setMetadata` have been removed in favor of - `GuzzleHttp\Stream\MetadataStreamInterface`. -- `getWrapper`, `getWrapperData`, `getStreamType`, and `getUri` have all been - removed. This data is accessible when - using streams that implement `GuzzleHttp\Stream\MetadataStreamInterface`. -- `rewind` has been removed. Use `seek(0)` for a similar behavior. - -## Renamed methods - -- `detachStream` has been renamed to `detach`. -- `feof` has been renamed to `eof`. -- `ftell` has been renamed to `tell`. -- `readLine` has moved from an instance method to a static class method of - `GuzzleHttp\Stream\Stream`. - -## Metadata streams - -`GuzzleHttp\Stream\MetadataStreamInterface` has been added to denote streams -that contain additional metadata accessible via `getMetadata()`. -`GuzzleHttp\Stream\StreamInterface::getMetadata` and -`GuzzleHttp\Stream\StreamInterface::setMetadata` have been removed. - -## StreamRequestFactory - -The entire concept of the StreamRequestFactory has been removed. The way this -was used in Guzzle 3 broke the actual interface of sending streaming requests -(instead of getting back a Response, you got a StreamInterface). Streeaming -PHP requests are now implemented throught the `GuzzleHttp\Adapter\StreamAdapter`. - -3.6 to 3.7 ----------- - -### Deprecations - -- You can now enable E_USER_DEPRECATED warnings to see if you are using any deprecated methods.: - -```php -\Guzzle\Common\Version::$emitWarnings = true; -``` - -The following APIs and options have been marked as deprecated: - -- Marked `Guzzle\Http\Message\Request::isResponseBodyRepeatable()` as deprecated. Use `$request->getResponseBody()->isRepeatable()` instead. -- Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. -- Marked `Guzzle\Http\Message\Request::canCache()` as deprecated. Use `Guzzle\Plugin\Cache\DefaultCanCacheStrategy->canCacheRequest()` instead. -- Marked `Guzzle\Http\Message\Request::setIsRedirect()` as deprecated. Use the HistoryPlugin instead. -- Marked `Guzzle\Http\Message\Request::isRedirect()` as deprecated. Use the HistoryPlugin instead. -- Marked `Guzzle\Cache\CacheAdapterFactory::factory()` as deprecated -- Marked `Guzzle\Service\Client::enableMagicMethods()` as deprecated. Magic methods can no longer be disabled on a Guzzle\Service\Client. -- Marked `Guzzle\Parser\Url\UrlParser` as deprecated. Just use PHP's `parse_url()` and percent encode your UTF-8. -- Marked `Guzzle\Common\Collection::inject()` as deprecated. -- Marked `Guzzle\Plugin\CurlAuth\CurlAuthPlugin` as deprecated. Use - `$client->getConfig()->setPath('request.options/auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` or - `$client->setDefaultOption('auth', array('user', 'pass', 'Basic|Digest|NTLM|Any'));` - -3.7 introduces `request.options` as a parameter for a client configuration and as an optional argument to all creational -request methods. When paired with a client's configuration settings, these options allow you to specify default settings -for various aspects of a request. Because these options make other previous configuration options redundant, several -configuration options and methods of a client and AbstractCommand have been deprecated. - -- Marked `Guzzle\Service\Client::getDefaultHeaders()` as deprecated. Use `$client->getDefaultOption('headers')`. -- Marked `Guzzle\Service\Client::setDefaultHeaders()` as deprecated. Use `$client->setDefaultOption('headers/{header_name}', 'value')`. -- Marked 'request.params' for `Guzzle\Http\Client` as deprecated. Use `$client->setDefaultOption('params/{param_name}', 'value')` -- Marked 'command.headers', 'command.response_body' and 'command.on_complete' as deprecated for AbstractCommand. These will work through Guzzle 4.0 - - $command = $client->getCommand('foo', array( - 'command.headers' => array('Test' => '123'), - 'command.response_body' => '/path/to/file' - )); - - // Should be changed to: - - $command = $client->getCommand('foo', array( - 'command.request_options' => array( - 'headers' => array('Test' => '123'), - 'save_as' => '/path/to/file' - ) - )); - -### Interface changes - -Additions and changes (you will need to update any implementations or subclasses you may have created): - -- Added an `$options` argument to the end of the following methods of `Guzzle\Http\ClientInterface`: - createRequest, head, delete, put, patch, post, options, prepareRequest -- Added an `$options` argument to the end of `Guzzle\Http\Message\Request\RequestFactoryInterface::createRequest()` -- Added an `applyOptions()` method to `Guzzle\Http\Message\Request\RequestFactoryInterface` -- Changed `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $body = null)` to - `Guzzle\Http\ClientInterface::get($uri = null, $headers = null, $options = array())`. You can still pass in a - resource, string, or EntityBody into the $options parameter to specify the download location of the response. -- Changed `Guzzle\Common\Collection::__construct($data)` to no longer accepts a null value for `$data` but a - default `array()` -- Added `Guzzle\Stream\StreamInterface::isRepeatable` -- Made `Guzzle\Http\Client::expandTemplate` and `getUriTemplate` protected methods. - -The following methods were removed from interfaces. All of these methods are still available in the concrete classes -that implement them, but you should update your code to use alternative methods: - -- Removed `Guzzle\Http\ClientInterface::setDefaultHeaders(). Use - `$client->getConfig()->setPath('request.options/headers/{header_name}', 'value')`. or - `$client->getConfig()->setPath('request.options/headers', array('header_name' => 'value'))` or - `$client->setDefaultOption('headers/{header_name}', 'value')`. or - `$client->setDefaultOption('headers', array('header_name' => 'value'))`. -- Removed `Guzzle\Http\ClientInterface::getDefaultHeaders(). Use `$client->getConfig()->getPath('request.options/headers')`. -- Removed `Guzzle\Http\ClientInterface::expandTemplate()`. This is an implementation detail. -- Removed `Guzzle\Http\ClientInterface::setRequestFactory()`. This is an implementation detail. -- Removed `Guzzle\Http\ClientInterface::getCurlMulti()`. This is a very specific implementation detail. -- Removed `Guzzle\Http\Message\RequestInterface::canCache`. Use the CachePlugin. -- Removed `Guzzle\Http\Message\RequestInterface::setIsRedirect`. Use the HistoryPlugin. -- Removed `Guzzle\Http\Message\RequestInterface::isRedirect`. Use the HistoryPlugin. - -### Cache plugin breaking changes - -- CacheKeyProviderInterface and DefaultCacheKeyProvider are no longer used. All of this logic is handled in a - CacheStorageInterface. These two objects and interface will be removed in a future version. -- Always setting X-cache headers on cached responses -- Default cache TTLs are now handled by the CacheStorageInterface of a CachePlugin -- `CacheStorageInterface::cache($key, Response $response, $ttl = null)` has changed to `cache(RequestInterface - $request, Response $response);` -- `CacheStorageInterface::fetch($key)` has changed to `fetch(RequestInterface $request);` -- `CacheStorageInterface::delete($key)` has changed to `delete(RequestInterface $request);` -- Added `CacheStorageInterface::purge($url)` -- `DefaultRevalidation::__construct(CacheKeyProviderInterface $cacheKey, CacheStorageInterface $cache, CachePlugin - $plugin)` has changed to `DefaultRevalidation::__construct(CacheStorageInterface $cache, - CanCacheStrategyInterface $canCache = null)` -- Added `RevalidationInterface::shouldRevalidate(RequestInterface $request, Response $response)` - -3.5 to 3.6 ----------- - -* Mixed casing of headers are now forced to be a single consistent casing across all values for that header. -* Messages internally use a HeaderCollection object to delegate handling case-insensitive header resolution -* Removed the whole changedHeader() function system of messages because all header changes now go through addHeader(). - For example, setHeader() first removes the header using unset on a HeaderCollection and then calls addHeader(). - Keeping the Host header and URL host in sync is now handled by overriding the addHeader method in Request. -* Specific header implementations can be created for complex headers. When a message creates a header, it uses a - HeaderFactory which can map specific headers to specific header classes. There is now a Link header and - CacheControl header implementation. -* Moved getLinks() from Response to just be used on a Link header object. - -If you previously relied on Guzzle\Http\Message\Header::raw(), then you will need to update your code to use the -HeaderInterface (e.g. toArray(), getAll(), etc.). - -### Interface changes - -* Removed from interface: Guzzle\Http\ClientInterface::setUriTemplate -* Removed from interface: Guzzle\Http\ClientInterface::setCurlMulti() -* Removed Guzzle\Http\Message\Request::receivedRequestHeader() and implemented this functionality in - Guzzle\Http\Curl\RequestMediator -* Removed the optional $asString parameter from MessageInterface::getHeader(). Just cast the header to a string. -* Removed the optional $tryChunkedTransfer option from Guzzle\Http\Message\EntityEnclosingRequestInterface -* Removed the $asObjects argument from Guzzle\Http\Message\MessageInterface::getHeaders() - -### Removed deprecated functions - -* Removed Guzzle\Parser\ParserRegister::get(). Use getParser() -* Removed Guzzle\Parser\ParserRegister::set(). Use registerParser(). - -### Deprecations - -* The ability to case-insensitively search for header values -* Guzzle\Http\Message\Header::hasExactHeader -* Guzzle\Http\Message\Header::raw. Use getAll() -* Deprecated cache control specific methods on Guzzle\Http\Message\AbstractMessage. Use the CacheControl header object - instead. - -### Other changes - -* All response header helper functions return a string rather than mixing Header objects and strings inconsistently -* Removed cURL blacklist support. This is no longer necessary now that Expect, Accept, etc. are managed by Guzzle - directly via interfaces -* Removed the injecting of a request object onto a response object. The methods to get and set a request still exist - but are a no-op until removed. -* Most classes that used to require a `Guzzle\Service\Command\CommandInterface` typehint now request a - `Guzzle\Service\Command\ArrayCommandInterface`. -* Added `Guzzle\Http\Message\RequestInterface::startResponse()` to the RequestInterface to handle injecting a response - on a request while the request is still being transferred -* `Guzzle\Service\Command\CommandInterface` now extends from ToArrayInterface and ArrayAccess - -3.3 to 3.4 ----------- - -Base URLs of a client now follow the rules of http://tools.ietf.org/html/rfc3986#section-5.2.2 when merging URLs. - -3.2 to 3.3 ----------- - -### Response::getEtag() quote stripping removed - -`Guzzle\Http\Message\Response::getEtag()` no longer strips quotes around the ETag response header - -### Removed `Guzzle\Http\Utils` - -The `Guzzle\Http\Utils` class was removed. This class was only used for testing. - -### Stream wrapper and type - -`Guzzle\Stream\Stream::getWrapper()` and `Guzzle\Stream\Stream::getStreamType()` are no longer converted to lowercase. - -### curl.emit_io became emit_io - -Emitting IO events from a RequestMediator is now a parameter that must be set in a request's curl options using the -'emit_io' key. This was previously set under a request's parameters using 'curl.emit_io' - -3.1 to 3.2 ----------- - -### CurlMulti is no longer reused globally - -Before 3.2, the same CurlMulti object was reused globally for each client. This can cause issue where plugins added -to a single client can pollute requests dispatched from other clients. - -If you still wish to reuse the same CurlMulti object with each client, then you can add a listener to the -ServiceBuilder's `service_builder.create_client` event to inject a custom CurlMulti object into each client as it is -created. - -```php -$multi = new Guzzle\Http\Curl\CurlMulti(); -$builder = Guzzle\Service\Builder\ServiceBuilder::factory('/path/to/config.json'); -$builder->addListener('service_builder.create_client', function ($event) use ($multi) { - $event['client']->setCurlMulti($multi); -} -}); -``` - -### No default path - -URLs no longer have a default path value of '/' if no path was specified. - -Before: - -```php -$request = $client->get('http://www.foo.com'); -echo $request->getUrl(); -// >> http://www.foo.com/ -``` - -After: - -```php -$request = $client->get('http://www.foo.com'); -echo $request->getUrl(); -// >> http://www.foo.com -``` - -### Less verbose BadResponseException - -The exception message for `Guzzle\Http\Exception\BadResponseException` no longer contains the full HTTP request and -response information. You can, however, get access to the request and response object by calling `getRequest()` or -`getResponse()` on the exception object. - -### Query parameter aggregation - -Multi-valued query parameters are no longer aggregated using a callback function. `Guzzle\Http\Query` now has a -setAggregator() method that accepts a `Guzzle\Http\QueryAggregator\QueryAggregatorInterface` object. This object is -responsible for handling the aggregation of multi-valued query string variables into a flattened hash. - -2.8 to 3.x ----------- - -### Guzzle\Service\Inspector - -Change `\Guzzle\Service\Inspector::fromConfig` to `\Guzzle\Common\Collection::fromConfig` - -**Before** - -```php -use Guzzle\Service\Inspector; - -class YourClient extends \Guzzle\Service\Client -{ - public static function factory($config = array()) - { - $default = array(); - $required = array('base_url', 'username', 'api_key'); - $config = Inspector::fromConfig($config, $default, $required); - - $client = new self( - $config->get('base_url'), - $config->get('username'), - $config->get('api_key') - ); - $client->setConfig($config); - - $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); - - return $client; - } -``` - -**After** - -```php -use Guzzle\Common\Collection; - -class YourClient extends \Guzzle\Service\Client -{ - public static function factory($config = array()) - { - $default = array(); - $required = array('base_url', 'username', 'api_key'); - $config = Collection::fromConfig($config, $default, $required); - - $client = new self( - $config->get('base_url'), - $config->get('username'), - $config->get('api_key') - ); - $client->setConfig($config); - - $client->setDescription(ServiceDescription::factory(__DIR__ . DIRECTORY_SEPARATOR . 'client.json')); - - return $client; - } -``` - -### Convert XML Service Descriptions to JSON - -**Before** - -```xml - - - - - - Get a list of groups - - - Uses a search query to get a list of groups - - - - Create a group - - - - - Delete a group by ID - - - - - - - Update a group - - - - - - -``` - -**After** - -```json -{ - "name": "Zendesk REST API v2", - "apiVersion": "2012-12-31", - "description":"Provides access to Zendesk views, groups, tickets, ticket fields, and users", - "operations": { - "list_groups": { - "httpMethod":"GET", - "uri": "groups.json", - "summary": "Get a list of groups" - }, - "search_groups":{ - "httpMethod":"GET", - "uri": "search.json?query=\"{query} type:group\"", - "summary": "Uses a search query to get a list of groups", - "parameters":{ - "query":{ - "location": "uri", - "description":"Zendesk Search Query", - "type": "string", - "required": true - } - } - }, - "create_group": { - "httpMethod":"POST", - "uri": "groups.json", - "summary": "Create a group", - "parameters":{ - "data": { - "type": "array", - "location": "body", - "description":"Group JSON", - "filters": "json_encode", - "required": true - }, - "Content-Type":{ - "type": "string", - "location":"header", - "static": "application/json" - } - } - }, - "delete_group": { - "httpMethod":"DELETE", - "uri": "groups/{id}.json", - "summary": "Delete a group", - "parameters":{ - "id":{ - "location": "uri", - "description":"Group to delete by ID", - "type": "integer", - "required": true - } - } - }, - "get_group": { - "httpMethod":"GET", - "uri": "groups/{id}.json", - "summary": "Get a ticket", - "parameters":{ - "id":{ - "location": "uri", - "description":"Group to get by ID", - "type": "integer", - "required": true - } - } - }, - "update_group": { - "httpMethod":"PUT", - "uri": "groups/{id}.json", - "summary": "Update a group", - "parameters":{ - "id": { - "location": "uri", - "description":"Group to update by ID", - "type": "integer", - "required": true - }, - "data": { - "type": "array", - "location": "body", - "description":"Group JSON", - "filters": "json_encode", - "required": true - }, - "Content-Type":{ - "type": "string", - "location":"header", - "static": "application/json" - } - } - } -} -``` - -### Guzzle\Service\Description\ServiceDescription - -Commands are now called Operations - -**Before** - -```php -use Guzzle\Service\Description\ServiceDescription; - -$sd = new ServiceDescription(); -$sd->getCommands(); // @returns ApiCommandInterface[] -$sd->hasCommand($name); -$sd->getCommand($name); // @returns ApiCommandInterface|null -$sd->addCommand($command); // @param ApiCommandInterface $command -``` - -**After** - -```php -use Guzzle\Service\Description\ServiceDescription; - -$sd = new ServiceDescription(); -$sd->getOperations(); // @returns OperationInterface[] -$sd->hasOperation($name); -$sd->getOperation($name); // @returns OperationInterface|null -$sd->addOperation($operation); // @param OperationInterface $operation -``` - -### Guzzle\Common\Inflection\Inflector - -Namespace is now `Guzzle\Inflection\Inflector` - -### Guzzle\Http\Plugin - -Namespace is now `Guzzle\Plugin`. Many other changes occur within this namespace and are detailed in their own sections below. - -### Guzzle\Http\Plugin\LogPlugin and Guzzle\Common\Log - -Now `Guzzle\Plugin\Log\LogPlugin` and `Guzzle\Log` respectively. - -**Before** - -```php -use Guzzle\Common\Log\ClosureLogAdapter; -use Guzzle\Http\Plugin\LogPlugin; - -/** @var \Guzzle\Http\Client */ -$client; - -// $verbosity is an integer indicating desired message verbosity level -$client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $verbosity = LogPlugin::LOG_VERBOSE); -``` - -**After** - -```php -use Guzzle\Log\ClosureLogAdapter; -use Guzzle\Log\MessageFormatter; -use Guzzle\Plugin\Log\LogPlugin; - -/** @var \Guzzle\Http\Client */ -$client; - -// $format is a string indicating desired message format -- @see MessageFormatter -$client->addSubscriber(new LogPlugin(new ClosureLogAdapter(function($m) { echo $m; }, $format = MessageFormatter::DEBUG_FORMAT); -``` - -### Guzzle\Http\Plugin\CurlAuthPlugin - -Now `Guzzle\Plugin\CurlAuth\CurlAuthPlugin`. - -### Guzzle\Http\Plugin\ExponentialBackoffPlugin - -Now `Guzzle\Plugin\Backoff\BackoffPlugin`, and other changes. - -**Before** - -```php -use Guzzle\Http\Plugin\ExponentialBackoffPlugin; - -$backoffPlugin = new ExponentialBackoffPlugin($maxRetries, array_merge( - ExponentialBackoffPlugin::getDefaultFailureCodes(), array(429) - )); - -$client->addSubscriber($backoffPlugin); -``` - -**After** - -```php -use Guzzle\Plugin\Backoff\BackoffPlugin; -use Guzzle\Plugin\Backoff\HttpBackoffStrategy; - -// Use convenient factory method instead -- see implementation for ideas of what -// you can do with chaining backoff strategies -$backoffPlugin = BackoffPlugin::getExponentialBackoff($maxRetries, array_merge( - HttpBackoffStrategy::getDefaultFailureCodes(), array(429) - )); -$client->addSubscriber($backoffPlugin); -``` - -### Known Issues - -#### [BUG] Accept-Encoding header behavior changed unintentionally. - -(See #217) (Fixed in 09daeb8c666fb44499a0646d655a8ae36456575e) - -In version 2.8 setting the `Accept-Encoding` header would set the CURLOPT_ENCODING option, which permitted cURL to -properly handle gzip/deflate compressed responses from the server. In versions affected by this bug this does not happen. -See issue #217 for a workaround, or use a version containing the fix. diff --git a/vendor/guzzlehttp/guzzle/composer.json b/vendor/guzzlehttp/guzzle/composer.json deleted file mode 100644 index 218c24736..000000000 --- a/vendor/guzzlehttp/guzzle/composer.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "guzzlehttp/guzzle", - "type": "library", - "description": "Guzzle is a PHP HTTP client library", - "keywords": ["framework", "http", "rest", "web service", "curl", "client", "HTTP client"], - "homepage": "http://guzzlephp.org/", - "license": "MIT", - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "require": { - "php": ">=5.5", - "guzzlehttp/psr7": "^1.3.1", - "guzzlehttp/promises": "^1.0" - }, - "require-dev": { - "ext-curl": "*", - "phpunit/phpunit": "^4.0", - "psr/log": "^1.0" - }, - "autoload": { - "files": ["src/functions_include.php"], - "psr-4": { - "GuzzleHttp\\": "src/" - } - }, - "autoload-dev": { - "psr-4": { - "GuzzleHttp\\Tests\\": "tests/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "6.2-dev" - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Client.php b/vendor/guzzlehttp/guzzle/src/Client.php deleted file mode 100644 index 6089c1869..000000000 --- a/vendor/guzzlehttp/guzzle/src/Client.php +++ /dev/null @@ -1,408 +0,0 @@ - 'http://www.foo.com/1.0/', - * 'timeout' => 0, - * 'allow_redirects' => false, - * 'proxy' => '192.168.16.1:10' - * ]); - * - * Client configuration settings include the following options: - * - * - handler: (callable) Function that transfers HTTP requests over the - * wire. The function is called with a Psr7\Http\Message\RequestInterface - * and array of transfer options, and must return a - * GuzzleHttp\Promise\PromiseInterface that is fulfilled with a - * Psr7\Http\Message\ResponseInterface on success. "handler" is a - * constructor only option that cannot be overridden in per/request - * options. If no handler is provided, a default handler will be created - * that enables all of the request options below by attaching all of the - * default middleware to the handler. - * - base_uri: (string|UriInterface) Base URI of the client that is merged - * into relative URIs. Can be a string or instance of UriInterface. - * - **: any request option - * - * @param array $config Client configuration settings. - * - * @see \GuzzleHttp\RequestOptions for a list of available request options. - */ - public function __construct(array $config = []) - { - if (!isset($config['handler'])) { - $config['handler'] = HandlerStack::create(); - } - - // Convert the base_uri to a UriInterface - if (isset($config['base_uri'])) { - $config['base_uri'] = Psr7\uri_for($config['base_uri']); - } - - $this->configureDefaults($config); - } - - public function __call($method, $args) - { - if (count($args) < 1) { - throw new \InvalidArgumentException('Magic request methods require a URI and optional options array'); - } - - $uri = $args[0]; - $opts = isset($args[1]) ? $args[1] : []; - - return substr($method, -5) === 'Async' - ? $this->requestAsync(substr($method, 0, -5), $uri, $opts) - : $this->request($method, $uri, $opts); - } - - public function sendAsync(RequestInterface $request, array $options = []) - { - // Merge the base URI into the request URI if needed. - $options = $this->prepareDefaults($options); - - return $this->transfer( - $request->withUri($this->buildUri($request->getUri(), $options), $request->hasHeader('Host')), - $options - ); - } - - public function send(RequestInterface $request, array $options = []) - { - $options[RequestOptions::SYNCHRONOUS] = true; - return $this->sendAsync($request, $options)->wait(); - } - - public function requestAsync($method, $uri = '', array $options = []) - { - $options = $this->prepareDefaults($options); - // Remove request modifying parameter because it can be done up-front. - $headers = isset($options['headers']) ? $options['headers'] : []; - $body = isset($options['body']) ? $options['body'] : null; - $version = isset($options['version']) ? $options['version'] : '1.1'; - // Merge the URI into the base URI. - $uri = $this->buildUri($uri, $options); - if (is_array($body)) { - $this->invalidBody(); - } - $request = new Psr7\Request($method, $uri, $headers, $body, $version); - // Remove the option so that they are not doubly-applied. - unset($options['headers'], $options['body'], $options['version']); - - return $this->transfer($request, $options); - } - - public function request($method, $uri = '', array $options = []) - { - $options[RequestOptions::SYNCHRONOUS] = true; - return $this->requestAsync($method, $uri, $options)->wait(); - } - - public function getConfig($option = null) - { - return $option === null - ? $this->config - : (isset($this->config[$option]) ? $this->config[$option] : null); - } - - private function buildUri($uri, array $config) - { - // for BC we accept null which would otherwise fail in uri_for - $uri = Psr7\uri_for($uri === null ? '' : $uri); - - if (isset($config['base_uri'])) { - $uri = Psr7\Uri::resolve(Psr7\uri_for($config['base_uri']), $uri); - } - - return $uri->getScheme() === '' ? $uri->withScheme('http') : $uri; - } - - /** - * Configures the default options for a client. - * - * @param array $config - */ - private function configureDefaults(array $config) - { - $defaults = [ - 'allow_redirects' => RedirectMiddleware::$defaultSettings, - 'http_errors' => true, - 'decode_content' => true, - 'verify' => true, - 'cookies' => false - ]; - - // Use the standard Linux HTTP_PROXY and HTTPS_PROXY if set. - - // We can only trust the HTTP_PROXY environment variable in a CLI - // process due to the fact that PHP has no reliable mechanism to - // get environment variables that start with "HTTP_". - if (php_sapi_name() == 'cli' && getenv('HTTP_PROXY')) { - $defaults['proxy']['http'] = getenv('HTTP_PROXY'); - } - - if ($proxy = getenv('HTTPS_PROXY')) { - $defaults['proxy']['https'] = $proxy; - } - - if ($noProxy = getenv('NO_PROXY')) { - $cleanedNoProxy = str_replace(' ', '', $noProxy); - $defaults['proxy']['no'] = explode(',', $cleanedNoProxy); - } - - $this->config = $config + $defaults; - - if (!empty($config['cookies']) && $config['cookies'] === true) { - $this->config['cookies'] = new CookieJar(); - } - - // Add the default user-agent header. - if (!isset($this->config['headers'])) { - $this->config['headers'] = ['User-Agent' => default_user_agent()]; - } else { - // Add the User-Agent header if one was not already set. - foreach (array_keys($this->config['headers']) as $name) { - if (strtolower($name) === 'user-agent') { - return; - } - } - $this->config['headers']['User-Agent'] = default_user_agent(); - } - } - - /** - * Merges default options into the array. - * - * @param array $options Options to modify by reference - * - * @return array - */ - private function prepareDefaults($options) - { - $defaults = $this->config; - - if (!empty($defaults['headers'])) { - // Default headers are only added if they are not present. - $defaults['_conditional'] = $defaults['headers']; - unset($defaults['headers']); - } - - // Special handling for headers is required as they are added as - // conditional headers and as headers passed to a request ctor. - if (array_key_exists('headers', $options)) { - // Allows default headers to be unset. - if ($options['headers'] === null) { - $defaults['_conditional'] = null; - unset($options['headers']); - } elseif (!is_array($options['headers'])) { - throw new \InvalidArgumentException('headers must be an array'); - } - } - - // Shallow merge defaults underneath options. - $result = $options + $defaults; - - // Remove null values. - foreach ($result as $k => $v) { - if ($v === null) { - unset($result[$k]); - } - } - - return $result; - } - - /** - * Transfers the given request and applies request options. - * - * The URI of the request is not modified and the request options are used - * as-is without merging in default options. - * - * @param RequestInterface $request - * @param array $options - * - * @return Promise\PromiseInterface - */ - private function transfer(RequestInterface $request, array $options) - { - // save_to -> sink - if (isset($options['save_to'])) { - $options['sink'] = $options['save_to']; - unset($options['save_to']); - } - - // exceptions -> http_errors - if (isset($options['exceptions'])) { - $options['http_errors'] = $options['exceptions']; - unset($options['exceptions']); - } - - $request = $this->applyOptions($request, $options); - $handler = $options['handler']; - - try { - return Promise\promise_for($handler($request, $options)); - } catch (\Exception $e) { - return Promise\rejection_for($e); - } - } - - /** - * Applies the array of request options to a request. - * - * @param RequestInterface $request - * @param array $options - * - * @return RequestInterface - */ - private function applyOptions(RequestInterface $request, array &$options) - { - $modify = []; - - if (isset($options['form_params'])) { - if (isset($options['multipart'])) { - throw new \InvalidArgumentException('You cannot use ' - . 'form_params and multipart at the same time. Use the ' - . 'form_params option if you want to send application/' - . 'x-www-form-urlencoded requests, and the multipart ' - . 'option to send multipart/form-data requests.'); - } - $options['body'] = http_build_query($options['form_params'], '', '&'); - unset($options['form_params']); - $options['_conditional']['Content-Type'] = 'application/x-www-form-urlencoded'; - } - - if (isset($options['multipart'])) { - $options['body'] = new Psr7\MultipartStream($options['multipart']); - unset($options['multipart']); - } - - if (isset($options['json'])) { - $options['body'] = \GuzzleHttp\json_encode($options['json']); - unset($options['json']); - $options['_conditional']['Content-Type'] = 'application/json'; - } - - if (!empty($options['decode_content']) - && $options['decode_content'] !== true - ) { - $modify['set_headers']['Accept-Encoding'] = $options['decode_content']; - } - - if (isset($options['headers'])) { - if (isset($modify['set_headers'])) { - $modify['set_headers'] = $options['headers'] + $modify['set_headers']; - } else { - $modify['set_headers'] = $options['headers']; - } - unset($options['headers']); - } - - if (isset($options['body'])) { - if (is_array($options['body'])) { - $this->invalidBody(); - } - $modify['body'] = Psr7\stream_for($options['body']); - unset($options['body']); - } - - if (!empty($options['auth']) && is_array($options['auth'])) { - $value = $options['auth']; - $type = isset($value[2]) ? strtolower($value[2]) : 'basic'; - switch ($type) { - case 'basic': - $modify['set_headers']['Authorization'] = 'Basic ' - . base64_encode("$value[0]:$value[1]"); - break; - case 'digest': - // @todo: Do not rely on curl - $options['curl'][CURLOPT_HTTPAUTH] = CURLAUTH_DIGEST; - $options['curl'][CURLOPT_USERPWD] = "$value[0]:$value[1]"; - break; - } - } - - if (isset($options['query'])) { - $value = $options['query']; - if (is_array($value)) { - $value = http_build_query($value, null, '&', PHP_QUERY_RFC3986); - } - if (!is_string($value)) { - throw new \InvalidArgumentException('query must be a string or array'); - } - $modify['query'] = $value; - unset($options['query']); - } - - // Ensure that sink is not an invalid value. - if (isset($options['sink'])) { - // TODO: Add more sink validation? - if (is_bool($options['sink'])) { - throw new \InvalidArgumentException('sink must not be a boolean'); - } - } - - $request = Psr7\modify_request($request, $modify); - if ($request->getBody() instanceof Psr7\MultipartStream) { - // Use a multipart/form-data POST if a Content-Type is not set. - $options['_conditional']['Content-Type'] = 'multipart/form-data; boundary=' - . $request->getBody()->getBoundary(); - } - - // Merge in conditional headers if they are not present. - if (isset($options['_conditional'])) { - // Build up the changes so it's in a single clone of the message. - $modify = []; - foreach ($options['_conditional'] as $k => $v) { - if (!$request->hasHeader($k)) { - $modify['set_headers'][$k] = $v; - } - } - $request = Psr7\modify_request($request, $modify); - // Don't pass this internal value along to middleware/handlers. - unset($options['_conditional']); - } - - return $request; - } - - private function invalidBody() - { - throw new \InvalidArgumentException('Passing in the "body" request ' - . 'option as an array to send a POST request has been deprecated. ' - . 'Please use the "form_params" request option to send a ' - . 'application/x-www-form-urlencoded request, or a the "multipart" ' - . 'request option to send a multipart/form-data request.'); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/ClientInterface.php b/vendor/guzzlehttp/guzzle/src/ClientInterface.php deleted file mode 100644 index 5a67b66bf..000000000 --- a/vendor/guzzlehttp/guzzle/src/ClientInterface.php +++ /dev/null @@ -1,84 +0,0 @@ -strictMode = $strictMode; - - foreach ($cookieArray as $cookie) { - if (!($cookie instanceof SetCookie)) { - $cookie = new SetCookie($cookie); - } - $this->setCookie($cookie); - } - } - - /** - * Create a new Cookie jar from an associative array and domain. - * - * @param array $cookies Cookies to create the jar from - * @param string $domain Domain to set the cookies to - * - * @return self - */ - public static function fromArray(array $cookies, $domain) - { - $cookieJar = new self(); - foreach ($cookies as $name => $value) { - $cookieJar->setCookie(new SetCookie([ - 'Domain' => $domain, - 'Name' => $name, - 'Value' => $value, - 'Discard' => true - ])); - } - - return $cookieJar; - } - - /** - * @deprecated - */ - public static function getCookieValue($value) - { - return $value; - } - - /** - * Evaluate if this cookie should be persisted to storage - * that survives between requests. - * - * @param SetCookie $cookie Being evaluated. - * @param bool $allowSessionCookies If we should persist session cookies - * @return bool - */ - public static function shouldPersist( - SetCookie $cookie, - $allowSessionCookies = false - ) { - if ($cookie->getExpires() || $allowSessionCookies) { - if (!$cookie->getDiscard()) { - return true; - } - } - - return false; - } - - public function toArray() - { - return array_map(function (SetCookie $cookie) { - return $cookie->toArray(); - }, $this->getIterator()->getArrayCopy()); - } - - public function clear($domain = null, $path = null, $name = null) - { - if (!$domain) { - $this->cookies = []; - return; - } elseif (!$path) { - $this->cookies = array_filter( - $this->cookies, - function (SetCookie $cookie) use ($path, $domain) { - return !$cookie->matchesDomain($domain); - } - ); - } elseif (!$name) { - $this->cookies = array_filter( - $this->cookies, - function (SetCookie $cookie) use ($path, $domain) { - return !($cookie->matchesPath($path) && - $cookie->matchesDomain($domain)); - } - ); - } else { - $this->cookies = array_filter( - $this->cookies, - function (SetCookie $cookie) use ($path, $domain, $name) { - return !($cookie->getName() == $name && - $cookie->matchesPath($path) && - $cookie->matchesDomain($domain)); - } - ); - } - } - - public function clearSessionCookies() - { - $this->cookies = array_filter( - $this->cookies, - function (SetCookie $cookie) { - return !$cookie->getDiscard() && $cookie->getExpires(); - } - ); - } - - public function setCookie(SetCookie $cookie) - { - // If the name string is empty (but not 0), ignore the set-cookie - // string entirely. - $name = $cookie->getName(); - if (!$name && $name !== '0') { - return false; - } - - // Only allow cookies with set and valid domain, name, value - $result = $cookie->validate(); - if ($result !== true) { - if ($this->strictMode) { - throw new \RuntimeException('Invalid cookie: ' . $result); - } else { - $this->removeCookieIfEmpty($cookie); - return false; - } - } - - // Resolve conflicts with previously set cookies - foreach ($this->cookies as $i => $c) { - - // Two cookies are identical, when their path, and domain are - // identical. - if ($c->getPath() != $cookie->getPath() || - $c->getDomain() != $cookie->getDomain() || - $c->getName() != $cookie->getName() - ) { - continue; - } - - // The previously set cookie is a discard cookie and this one is - // not so allow the new cookie to be set - if (!$cookie->getDiscard() && $c->getDiscard()) { - unset($this->cookies[$i]); - continue; - } - - // If the new cookie's expiration is further into the future, then - // replace the old cookie - if ($cookie->getExpires() > $c->getExpires()) { - unset($this->cookies[$i]); - continue; - } - - // If the value has changed, we better change it - if ($cookie->getValue() !== $c->getValue()) { - unset($this->cookies[$i]); - continue; - } - - // The cookie exists, so no need to continue - return false; - } - - $this->cookies[] = $cookie; - - return true; - } - - public function count() - { - return count($this->cookies); - } - - public function getIterator() - { - return new \ArrayIterator(array_values($this->cookies)); - } - - public function extractCookies( - RequestInterface $request, - ResponseInterface $response - ) { - if ($cookieHeader = $response->getHeader('Set-Cookie')) { - foreach ($cookieHeader as $cookie) { - $sc = SetCookie::fromString($cookie); - if (!$sc->getDomain()) { - $sc->setDomain($request->getUri()->getHost()); - } - $this->setCookie($sc); - } - } - } - - public function withCookieHeader(RequestInterface $request) - { - $values = []; - $uri = $request->getUri(); - $scheme = $uri->getScheme(); - $host = $uri->getHost(); - $path = $uri->getPath() ?: '/'; - - foreach ($this->cookies as $cookie) { - if ($cookie->matchesPath($path) && - $cookie->matchesDomain($host) && - !$cookie->isExpired() && - (!$cookie->getSecure() || $scheme === 'https') - ) { - $values[] = $cookie->getName() . '=' - . $cookie->getValue(); - } - } - - return $values - ? $request->withHeader('Cookie', implode('; ', $values)) - : $request; - } - - /** - * If a cookie already exists and the server asks to set it again with a - * null value, the cookie must be deleted. - * - * @param SetCookie $cookie - */ - private function removeCookieIfEmpty(SetCookie $cookie) - { - $cookieValue = $cookie->getValue(); - if ($cookieValue === null || $cookieValue === '') { - $this->clear( - $cookie->getDomain(), - $cookie->getPath(), - $cookie->getName() - ); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php b/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php deleted file mode 100644 index 2cf298a86..000000000 --- a/vendor/guzzlehttp/guzzle/src/Cookie/CookieJarInterface.php +++ /dev/null @@ -1,84 +0,0 @@ -filename = $cookieFile; - $this->storeSessionCookies = $storeSessionCookies; - - if (file_exists($cookieFile)) { - $this->load($cookieFile); - } - } - - /** - * Saves the file when shutting down - */ - public function __destruct() - { - $this->save($this->filename); - } - - /** - * Saves the cookies to a file. - * - * @param string $filename File to save - * @throws \RuntimeException if the file cannot be found or created - */ - public function save($filename) - { - $json = []; - foreach ($this as $cookie) { - /** @var SetCookie $cookie */ - if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) { - $json[] = $cookie->toArray(); - } - } - - $jsonStr = \GuzzleHttp\json_encode($json); - if (false === file_put_contents($filename, $jsonStr)) { - throw new \RuntimeException("Unable to save file {$filename}"); - } - } - - /** - * Load cookies from a JSON formatted file. - * - * Old cookies are kept unless overwritten by newly loaded ones. - * - * @param string $filename Cookie file to load. - * @throws \RuntimeException if the file cannot be loaded. - */ - public function load($filename) - { - $json = file_get_contents($filename); - if (false === $json) { - throw new \RuntimeException("Unable to load file {$filename}"); - } elseif ($json === '') { - return; - } - - $data = \GuzzleHttp\json_decode($json, true); - if (is_array($data)) { - foreach (json_decode($json, true) as $cookie) { - $this->setCookie(new SetCookie($cookie)); - } - } elseif (strlen($data)) { - throw new \RuntimeException("Invalid cookie file: {$filename}"); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php b/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php deleted file mode 100644 index e4bfafd4f..000000000 --- a/vendor/guzzlehttp/guzzle/src/Cookie/SessionCookieJar.php +++ /dev/null @@ -1,71 +0,0 @@ -sessionKey = $sessionKey; - $this->storeSessionCookies = $storeSessionCookies; - $this->load(); - } - - /** - * Saves cookies to session when shutting down - */ - public function __destruct() - { - $this->save(); - } - - /** - * Save cookies to the client session - */ - public function save() - { - $json = []; - foreach ($this as $cookie) { - /** @var SetCookie $cookie */ - if (CookieJar::shouldPersist($cookie, $this->storeSessionCookies)) { - $json[] = $cookie->toArray(); - } - } - - $_SESSION[$this->sessionKey] = json_encode($json); - } - - /** - * Load the contents of the client session into the data array - */ - protected function load() - { - if (!isset($_SESSION[$this->sessionKey])) { - return; - } - $data = json_decode($_SESSION[$this->sessionKey], true); - if (is_array($data)) { - foreach ($data as $cookie) { - $this->setCookie(new SetCookie($cookie)); - } - } elseif (strlen($data)) { - throw new \RuntimeException("Invalid cookie data"); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php b/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php deleted file mode 100644 index c911e2a3f..000000000 --- a/vendor/guzzlehttp/guzzle/src/Cookie/SetCookie.php +++ /dev/null @@ -1,404 +0,0 @@ - null, - 'Value' => null, - 'Domain' => null, - 'Path' => '/', - 'Max-Age' => null, - 'Expires' => null, - 'Secure' => false, - 'Discard' => false, - 'HttpOnly' => false - ]; - - /** @var array Cookie data */ - private $data; - - /** - * Create a new SetCookie object from a string - * - * @param string $cookie Set-Cookie header string - * - * @return self - */ - public static function fromString($cookie) - { - // Create the default return array - $data = self::$defaults; - // Explode the cookie string using a series of semicolons - $pieces = array_filter(array_map('trim', explode(';', $cookie))); - // The name of the cookie (first kvp) must include an equal sign. - if (empty($pieces) || !strpos($pieces[0], '=')) { - return new self($data); - } - - // Add the cookie pieces into the parsed data array - foreach ($pieces as $part) { - - $cookieParts = explode('=', $part, 2); - $key = trim($cookieParts[0]); - $value = isset($cookieParts[1]) - ? trim($cookieParts[1], " \n\r\t\0\x0B") - : true; - - // Only check for non-cookies when cookies have been found - if (empty($data['Name'])) { - $data['Name'] = $key; - $data['Value'] = $value; - } else { - foreach (array_keys(self::$defaults) as $search) { - if (!strcasecmp($search, $key)) { - $data[$search] = $value; - continue 2; - } - } - $data[$key] = $value; - } - } - - return new self($data); - } - - /** - * @param array $data Array of cookie data provided by a Cookie parser - */ - public function __construct(array $data = []) - { - $this->data = array_replace(self::$defaults, $data); - // Extract the Expires value and turn it into a UNIX timestamp if needed - if (!$this->getExpires() && $this->getMaxAge()) { - // Calculate the Expires date - $this->setExpires(time() + $this->getMaxAge()); - } elseif ($this->getExpires() && !is_numeric($this->getExpires())) { - $this->setExpires($this->getExpires()); - } - } - - public function __toString() - { - $str = $this->data['Name'] . '=' . $this->data['Value'] . '; '; - foreach ($this->data as $k => $v) { - if ($k !== 'Name' && $k !== 'Value' && $v !== null && $v !== false) { - if ($k === 'Expires') { - $str .= 'Expires=' . gmdate('D, d M Y H:i:s \G\M\T', $v) . '; '; - } else { - $str .= ($v === true ? $k : "{$k}={$v}") . '; '; - } - } - } - - return rtrim($str, '; '); - } - - public function toArray() - { - return $this->data; - } - - /** - * Get the cookie name - * - * @return string - */ - public function getName() - { - return $this->data['Name']; - } - - /** - * Set the cookie name - * - * @param string $name Cookie name - */ - public function setName($name) - { - $this->data['Name'] = $name; - } - - /** - * Get the cookie value - * - * @return string - */ - public function getValue() - { - return $this->data['Value']; - } - - /** - * Set the cookie value - * - * @param string $value Cookie value - */ - public function setValue($value) - { - $this->data['Value'] = $value; - } - - /** - * Get the domain - * - * @return string|null - */ - public function getDomain() - { - return $this->data['Domain']; - } - - /** - * Set the domain of the cookie - * - * @param string $domain - */ - public function setDomain($domain) - { - $this->data['Domain'] = $domain; - } - - /** - * Get the path - * - * @return string - */ - public function getPath() - { - return $this->data['Path']; - } - - /** - * Set the path of the cookie - * - * @param string $path Path of the cookie - */ - public function setPath($path) - { - $this->data['Path'] = $path; - } - - /** - * Maximum lifetime of the cookie in seconds - * - * @return int|null - */ - public function getMaxAge() - { - return $this->data['Max-Age']; - } - - /** - * Set the max-age of the cookie - * - * @param int $maxAge Max age of the cookie in seconds - */ - public function setMaxAge($maxAge) - { - $this->data['Max-Age'] = $maxAge; - } - - /** - * The UNIX timestamp when the cookie Expires - * - * @return mixed - */ - public function getExpires() - { - return $this->data['Expires']; - } - - /** - * Set the unix timestamp for which the cookie will expire - * - * @param int $timestamp Unix timestamp - */ - public function setExpires($timestamp) - { - $this->data['Expires'] = is_numeric($timestamp) - ? (int) $timestamp - : strtotime($timestamp); - } - - /** - * Get whether or not this is a secure cookie - * - * @return null|bool - */ - public function getSecure() - { - return $this->data['Secure']; - } - - /** - * Set whether or not the cookie is secure - * - * @param bool $secure Set to true or false if secure - */ - public function setSecure($secure) - { - $this->data['Secure'] = $secure; - } - - /** - * Get whether or not this is a session cookie - * - * @return null|bool - */ - public function getDiscard() - { - return $this->data['Discard']; - } - - /** - * Set whether or not this is a session cookie - * - * @param bool $discard Set to true or false if this is a session cookie - */ - public function setDiscard($discard) - { - $this->data['Discard'] = $discard; - } - - /** - * Get whether or not this is an HTTP only cookie - * - * @return bool - */ - public function getHttpOnly() - { - return $this->data['HttpOnly']; - } - - /** - * Set whether or not this is an HTTP only cookie - * - * @param bool $httpOnly Set to true or false if this is HTTP only - */ - public function setHttpOnly($httpOnly) - { - $this->data['HttpOnly'] = $httpOnly; - } - - /** - * Check if the cookie matches a path value. - * - * A request-path path-matches a given cookie-path if at least one of - * the following conditions holds: - * - * - The cookie-path and the request-path are identical. - * - The cookie-path is a prefix of the request-path, and the last - * character of the cookie-path is %x2F ("/"). - * - The cookie-path is a prefix of the request-path, and the first - * character of the request-path that is not included in the cookie- - * path is a %x2F ("/") character. - * - * @param string $requestPath Path to check against - * - * @return bool - */ - public function matchesPath($requestPath) - { - $cookiePath = $this->getPath(); - - // Match on exact matches or when path is the default empty "/" - if ($cookiePath === '/' || $cookiePath == $requestPath) { - return true; - } - - // Ensure that the cookie-path is a prefix of the request path. - if (0 !== strpos($requestPath, $cookiePath)) { - return false; - } - - // Match if the last character of the cookie-path is "/" - if (substr($cookiePath, -1, 1) === '/') { - return true; - } - - // Match if the first character not included in cookie path is "/" - return substr($requestPath, strlen($cookiePath), 1) === '/'; - } - - /** - * Check if the cookie matches a domain value - * - * @param string $domain Domain to check against - * - * @return bool - */ - public function matchesDomain($domain) - { - // Remove the leading '.' as per spec in RFC 6265. - // http://tools.ietf.org/html/rfc6265#section-5.2.3 - $cookieDomain = ltrim($this->getDomain(), '.'); - - // Domain not set or exact match. - if (!$cookieDomain || !strcasecmp($domain, $cookieDomain)) { - return true; - } - - // Matching the subdomain according to RFC 6265. - // http://tools.ietf.org/html/rfc6265#section-5.1.3 - if (filter_var($domain, FILTER_VALIDATE_IP)) { - return false; - } - - return (bool) preg_match('/\.' . preg_quote($cookieDomain) . '$/', $domain); - } - - /** - * Check if the cookie is expired - * - * @return bool - */ - public function isExpired() - { - return $this->getExpires() && time() > $this->getExpires(); - } - - /** - * Check if the cookie is valid according to RFC 6265 - * - * @return bool|string Returns true if valid or an error message if invalid - */ - public function validate() - { - // Names must not be empty, but can be 0 - $name = $this->getName(); - if (empty($name) && !is_numeric($name)) { - return 'The cookie name must not be empty'; - } - - // Check if any of the invalid characters are present in the cookie name - if (preg_match( - '/[\x00-\x20\x22\x28-\x29\x2c\x2f\x3a-\x40\x5c\x7b\x7d\x7f]/', - $name) - ) { - return 'Cookie name must not contain invalid characters: ASCII ' - . 'Control characters (0-31;127), space, tab and the ' - . 'following characters: ()<>@,;:\"/?={}'; - } - - // Value must not be empty, but can be 0 - $value = $this->getValue(); - if (empty($value) && !is_numeric($value)) { - return 'The cookie value must not be empty'; - } - - // Domains must not be empty, but can be 0 - // A "0" is not a valid internet domain, but may be used as server name - // in a private network. - $domain = $this->getDomain(); - if (empty($domain) && !is_numeric($domain)) { - return 'The cookie domain must not be empty'; - } - - return true; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php b/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php deleted file mode 100644 index fd78431ea..000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/BadResponseException.php +++ /dev/null @@ -1,7 +0,0 @@ -getStatusCode() - : 0; - parent::__construct($message, $code, $previous); - $this->request = $request; - $this->response = $response; - $this->handlerContext = $handlerContext; - } - - /** - * Wrap non-RequestExceptions with a RequestException - * - * @param RequestInterface $request - * @param \Exception $e - * - * @return RequestException - */ - public static function wrapException(RequestInterface $request, \Exception $e) - { - return $e instanceof RequestException - ? $e - : new RequestException($e->getMessage(), $request, null, $e); - } - - /** - * Factory method to create a new exception with a normalized error message - * - * @param RequestInterface $request Request - * @param ResponseInterface $response Response received - * @param \Exception $previous Previous exception - * @param array $ctx Optional handler context. - * - * @return self - */ - public static function create( - RequestInterface $request, - ResponseInterface $response = null, - \Exception $previous = null, - array $ctx = [] - ) { - if (!$response) { - return new self( - 'Error completing request', - $request, - null, - $previous, - $ctx - ); - } - - $level = (int) floor($response->getStatusCode() / 100); - if ($level === 4) { - $label = 'Client error'; - $className = __NAMESPACE__ . '\\ClientException'; - } elseif ($level === 5) { - $label = 'Server error'; - $className = __NAMESPACE__ . '\\ServerException'; - } else { - $label = 'Unsuccessful request'; - $className = __CLASS__; - } - - // Server Error: `GET /` resulted in a `404 Not Found` response: - // ... (truncated) - $message = sprintf( - '%s: `%s` resulted in a `%s` response', - $label, - $request->getMethod() . ' ' . $request->getUri(), - $response->getStatusCode() . ' ' . $response->getReasonPhrase() - ); - - $summary = static::getResponseBodySummary($response); - - if ($summary !== null) { - $message .= ":\n{$summary}\n"; - } - - return new $className($message, $request, $response, $previous, $ctx); - } - - /** - * Get a short summary of the response - * - * Will return `null` if the response is not printable. - * - * @param ResponseInterface $response - * - * @return string|null - */ - public static function getResponseBodySummary(ResponseInterface $response) - { - $body = $response->getBody(); - - if (!$body->isSeekable()) { - return null; - } - - $size = $body->getSize(); - $summary = $body->read(120); - $body->rewind(); - - if ($size > 120) { - $summary .= ' (truncated...)'; - } - - // Matches any printable character, including unicode characters: - // letters, marks, numbers, punctuation, spacing, and separators. - if (preg_match('/[^\pL\pM\pN\pP\pS\pZ\n\r\t]/', $summary)) { - return null; - } - - return $summary; - } - - /** - * Get the request that caused the exception - * - * @return RequestInterface - */ - public function getRequest() - { - return $this->request; - } - - /** - * Get the associated response - * - * @return ResponseInterface|null - */ - public function getResponse() - { - return $this->response; - } - - /** - * Check if a response was received - * - * @return bool - */ - public function hasResponse() - { - return $this->response !== null; - } - - /** - * Get contextual information about the error from the underlying handler. - * - * The contents of this array will vary depending on which handler you are - * using. It may also be just an empty array. Relying on this data will - * couple you to a specific handler, but can give more debug information - * when needed. - * - * @return array - */ - public function getHandlerContext() - { - return $this->handlerContext; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php b/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php deleted file mode 100644 index a77c28926..000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/SeekException.php +++ /dev/null @@ -1,27 +0,0 @@ -stream = $stream; - $msg = $msg ?: 'Could not seek the stream to position ' . $pos; - parent::__construct($msg); - } - - /** - * @return StreamInterface - */ - public function getStream() - { - return $this->stream; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php b/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php deleted file mode 100644 index 7cdd34086..000000000 --- a/vendor/guzzlehttp/guzzle/src/Exception/ServerException.php +++ /dev/null @@ -1,7 +0,0 @@ -maxHandles = $maxHandles; - } - - public function create(RequestInterface $request, array $options) - { - if (isset($options['curl']['body_as_string'])) { - $options['_body_as_string'] = $options['curl']['body_as_string']; - unset($options['curl']['body_as_string']); - } - - $easy = new EasyHandle; - $easy->request = $request; - $easy->options = $options; - $conf = $this->getDefaultConf($easy); - $this->applyMethod($easy, $conf); - $this->applyHandlerOptions($easy, $conf); - $this->applyHeaders($easy, $conf); - unset($conf['_headers']); - - // Add handler options from the request configuration options - if (isset($options['curl'])) { - $conf = array_replace($conf, $options['curl']); - } - - $conf[CURLOPT_HEADERFUNCTION] = $this->createHeaderFn($easy); - $easy->handle = $this->handles - ? array_pop($this->handles) - : curl_init(); - curl_setopt_array($easy->handle, $conf); - - return $easy; - } - - public function release(EasyHandle $easy) - { - $resource = $easy->handle; - unset($easy->handle); - - if (count($this->handles) >= $this->maxHandles) { - curl_close($resource); - } else { - // Remove all callback functions as they can hold onto references - // and are not cleaned up by curl_reset. Using curl_setopt_array - // does not work for some reason, so removing each one - // individually. - curl_setopt($resource, CURLOPT_HEADERFUNCTION, null); - curl_setopt($resource, CURLOPT_READFUNCTION, null); - curl_setopt($resource, CURLOPT_WRITEFUNCTION, null); - curl_setopt($resource, CURLOPT_PROGRESSFUNCTION, null); - curl_reset($resource); - $this->handles[] = $resource; - } - } - - /** - * Completes a cURL transaction, either returning a response promise or a - * rejected promise. - * - * @param callable $handler - * @param EasyHandle $easy - * @param CurlFactoryInterface $factory Dictates how the handle is released - * - * @return \GuzzleHttp\Promise\PromiseInterface - */ - public static function finish( - callable $handler, - EasyHandle $easy, - CurlFactoryInterface $factory - ) { - if (isset($easy->options['on_stats'])) { - self::invokeStats($easy); - } - - if (!$easy->response || $easy->errno) { - return self::finishError($handler, $easy, $factory); - } - - // Return the response if it is present and there is no error. - $factory->release($easy); - - // Rewind the body of the response if possible. - $body = $easy->response->getBody(); - if ($body->isSeekable()) { - $body->rewind(); - } - - return new FulfilledPromise($easy->response); - } - - private static function invokeStats(EasyHandle $easy) - { - $curlStats = curl_getinfo($easy->handle); - $stats = new TransferStats( - $easy->request, - $easy->response, - $curlStats['total_time'], - $easy->errno, - $curlStats - ); - call_user_func($easy->options['on_stats'], $stats); - } - - private static function finishError( - callable $handler, - EasyHandle $easy, - CurlFactoryInterface $factory - ) { - // Get error information and release the handle to the factory. - $ctx = [ - 'errno' => $easy->errno, - 'error' => curl_error($easy->handle), - ] + curl_getinfo($easy->handle); - $factory->release($easy); - - // Retry when nothing is present or when curl failed to rewind. - if (empty($easy->options['_err_message']) - && (!$easy->errno || $easy->errno == 65) - ) { - return self::retryFailedRewind($handler, $easy, $ctx); - } - - return self::createRejection($easy, $ctx); - } - - private static function createRejection(EasyHandle $easy, array $ctx) - { - static $connectionErrors = [ - CURLE_OPERATION_TIMEOUTED => true, - CURLE_COULDNT_RESOLVE_HOST => true, - CURLE_COULDNT_CONNECT => true, - CURLE_SSL_CONNECT_ERROR => true, - CURLE_GOT_NOTHING => true, - ]; - - // If an exception was encountered during the onHeaders event, then - // return a rejected promise that wraps that exception. - if ($easy->onHeadersException) { - return new RejectedPromise( - new RequestException( - 'An error was encountered during the on_headers event', - $easy->request, - $easy->response, - $easy->onHeadersException, - $ctx - ) - ); - } - - $message = sprintf( - 'cURL error %s: %s (%s)', - $ctx['errno'], - $ctx['error'], - 'see http://curl.haxx.se/libcurl/c/libcurl-errors.html' - ); - - // Create a connection exception if it was a specific error code. - $error = isset($connectionErrors[$easy->errno]) - ? new ConnectException($message, $easy->request, null, $ctx) - : new RequestException($message, $easy->request, $easy->response, null, $ctx); - - return new RejectedPromise($error); - } - - private function getDefaultConf(EasyHandle $easy) - { - $conf = [ - '_headers' => $easy->request->getHeaders(), - CURLOPT_CUSTOMREQUEST => $easy->request->getMethod(), - CURLOPT_URL => (string) $easy->request->getUri()->withFragment(''), - CURLOPT_RETURNTRANSFER => false, - CURLOPT_HEADER => false, - CURLOPT_CONNECTTIMEOUT => 150, - ]; - - if (defined('CURLOPT_PROTOCOLS')) { - $conf[CURLOPT_PROTOCOLS] = CURLPROTO_HTTP | CURLPROTO_HTTPS; - } - - $version = $easy->request->getProtocolVersion(); - if ($version == 1.1) { - $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_1; - } elseif ($version == 2.0) { - $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_2_0; - } else { - $conf[CURLOPT_HTTP_VERSION] = CURL_HTTP_VERSION_1_0; - } - - return $conf; - } - - private function applyMethod(EasyHandle $easy, array &$conf) - { - $body = $easy->request->getBody(); - $size = $body->getSize(); - - if ($size === null || $size > 0) { - $this->applyBody($easy->request, $easy->options, $conf); - return; - } - - $method = $easy->request->getMethod(); - if ($method === 'PUT' || $method === 'POST') { - // See http://tools.ietf.org/html/rfc7230#section-3.3.2 - if (!$easy->request->hasHeader('Content-Length')) { - $conf[CURLOPT_HTTPHEADER][] = 'Content-Length: 0'; - } - } elseif ($method === 'HEAD') { - $conf[CURLOPT_NOBODY] = true; - unset( - $conf[CURLOPT_WRITEFUNCTION], - $conf[CURLOPT_READFUNCTION], - $conf[CURLOPT_FILE], - $conf[CURLOPT_INFILE] - ); - } - } - - private function applyBody(RequestInterface $request, array $options, array &$conf) - { - $size = $request->hasHeader('Content-Length') - ? (int) $request->getHeaderLine('Content-Length') - : null; - - // Send the body as a string if the size is less than 1MB OR if the - // [curl][body_as_string] request value is set. - if (($size !== null && $size < 1000000) || - !empty($options['_body_as_string']) - ) { - $conf[CURLOPT_POSTFIELDS] = (string) $request->getBody(); - // Don't duplicate the Content-Length header - $this->removeHeader('Content-Length', $conf); - $this->removeHeader('Transfer-Encoding', $conf); - } else { - $conf[CURLOPT_UPLOAD] = true; - if ($size !== null) { - $conf[CURLOPT_INFILESIZE] = $size; - $this->removeHeader('Content-Length', $conf); - } - $body = $request->getBody(); - if ($body->isSeekable()) { - $body->rewind(); - } - $conf[CURLOPT_READFUNCTION] = function ($ch, $fd, $length) use ($body) { - return $body->read($length); - }; - } - - // If the Expect header is not present, prevent curl from adding it - if (!$request->hasHeader('Expect')) { - $conf[CURLOPT_HTTPHEADER][] = 'Expect:'; - } - - // cURL sometimes adds a content-type by default. Prevent this. - if (!$request->hasHeader('Content-Type')) { - $conf[CURLOPT_HTTPHEADER][] = 'Content-Type:'; - } - } - - private function applyHeaders(EasyHandle $easy, array &$conf) - { - foreach ($conf['_headers'] as $name => $values) { - foreach ($values as $value) { - $conf[CURLOPT_HTTPHEADER][] = "$name: $value"; - } - } - - // Remove the Accept header if one was not set - if (!$easy->request->hasHeader('Accept')) { - $conf[CURLOPT_HTTPHEADER][] = 'Accept:'; - } - } - - /** - * Remove a header from the options array. - * - * @param string $name Case-insensitive header to remove - * @param array $options Array of options to modify - */ - private function removeHeader($name, array &$options) - { - foreach (array_keys($options['_headers']) as $key) { - if (!strcasecmp($key, $name)) { - unset($options['_headers'][$key]); - return; - } - } - } - - private function applyHandlerOptions(EasyHandle $easy, array &$conf) - { - $options = $easy->options; - if (isset($options['verify'])) { - if ($options['verify'] === false) { - unset($conf[CURLOPT_CAINFO]); - $conf[CURLOPT_SSL_VERIFYHOST] = 0; - $conf[CURLOPT_SSL_VERIFYPEER] = false; - } else { - $conf[CURLOPT_SSL_VERIFYHOST] = 2; - $conf[CURLOPT_SSL_VERIFYPEER] = true; - if (is_string($options['verify'])) { - $conf[CURLOPT_CAINFO] = $options['verify']; - if (!file_exists($options['verify'])) { - throw new \InvalidArgumentException( - "SSL CA bundle not found: {$options['verify']}" - ); - } - } - } - } - - if (!empty($options['decode_content'])) { - $accept = $easy->request->getHeaderLine('Accept-Encoding'); - if ($accept) { - $conf[CURLOPT_ENCODING] = $accept; - } else { - $conf[CURLOPT_ENCODING] = ''; - // Don't let curl send the header over the wire - $conf[CURLOPT_HTTPHEADER][] = 'Accept-Encoding:'; - } - } - - if (isset($options['sink'])) { - $sink = $options['sink']; - if (!is_string($sink)) { - $sink = \GuzzleHttp\Psr7\stream_for($sink); - } elseif (!is_dir(dirname($sink))) { - // Ensure that the directory exists before failing in curl. - throw new \RuntimeException(sprintf( - 'Directory %s does not exist for sink value of %s', - dirname($sink), - $sink - )); - } else { - $sink = new LazyOpenStream($sink, 'w+'); - } - $easy->sink = $sink; - $conf[CURLOPT_WRITEFUNCTION] = function ($ch, $write) use ($sink) { - return $sink->write($write); - }; - } else { - // Use a default temp stream if no sink was set. - $conf[CURLOPT_FILE] = fopen('php://temp', 'w+'); - $easy->sink = Psr7\stream_for($conf[CURLOPT_FILE]); - } - - if (isset($options['timeout'])) { - $conf[CURLOPT_TIMEOUT_MS] = $options['timeout'] * 1000; - } - - if (isset($options['connect_timeout'])) { - $conf[CURLOPT_CONNECTTIMEOUT_MS] = $options['connect_timeout'] * 1000; - } - - if (isset($options['proxy'])) { - if (!is_array($options['proxy'])) { - $conf[CURLOPT_PROXY] = $options['proxy']; - } else { - $scheme = $easy->request->getUri()->getScheme(); - if (isset($options['proxy'][$scheme])) { - $host = $easy->request->getUri()->getHost(); - if (!isset($options['proxy']['no']) || - !\GuzzleHttp\is_host_in_noproxy($host, $options['proxy']['no']) - ) { - $conf[CURLOPT_PROXY] = $options['proxy'][$scheme]; - } - } - } - } - - if (isset($options['cert'])) { - $cert = $options['cert']; - if (is_array($cert)) { - $conf[CURLOPT_SSLCERTPASSWD] = $cert[1]; - $cert = $cert[0]; - } - if (!file_exists($cert)) { - throw new \InvalidArgumentException( - "SSL certificate not found: {$cert}" - ); - } - $conf[CURLOPT_SSLCERT] = $cert; - } - - if (isset($options['ssl_key'])) { - $sslKey = $options['ssl_key']; - if (is_array($sslKey)) { - $conf[CURLOPT_SSLKEYPASSWD] = $sslKey[1]; - $sslKey = $sslKey[0]; - } - if (!file_exists($sslKey)) { - throw new \InvalidArgumentException( - "SSL private key not found: {$sslKey}" - ); - } - $conf[CURLOPT_SSLKEY] = $sslKey; - } - - if (isset($options['progress'])) { - $progress = $options['progress']; - if (!is_callable($progress)) { - throw new \InvalidArgumentException( - 'progress client option must be callable' - ); - } - $conf[CURLOPT_NOPROGRESS] = false; - $conf[CURLOPT_PROGRESSFUNCTION] = function () use ($progress) { - $args = func_get_args(); - // PHP 5.5 pushed the handle onto the start of the args - if (is_resource($args[0])) { - array_shift($args); - } - call_user_func_array($progress, $args); - }; - } - - if (!empty($options['debug'])) { - $conf[CURLOPT_STDERR] = \GuzzleHttp\debug_resource($options['debug']); - $conf[CURLOPT_VERBOSE] = true; - } - } - - /** - * This function ensures that a response was set on a transaction. If one - * was not set, then the request is retried if possible. This error - * typically means you are sending a payload, curl encountered a - * "Connection died, retrying a fresh connect" error, tried to rewind the - * stream, and then encountered a "necessary data rewind wasn't possible" - * error, causing the request to be sent through curl_multi_info_read() - * without an error status. - */ - private static function retryFailedRewind( - callable $handler, - EasyHandle $easy, - array $ctx - ) { - try { - // Only rewind if the body has been read from. - $body = $easy->request->getBody(); - if ($body->tell() > 0) { - $body->rewind(); - } - } catch (\RuntimeException $e) { - $ctx['error'] = 'The connection unexpectedly failed without ' - . 'providing an error. The request would have been retried, ' - . 'but attempting to rewind the request body failed. ' - . 'Exception: ' . $e; - return self::createRejection($easy, $ctx); - } - - // Retry no more than 3 times before giving up. - if (!isset($easy->options['_curl_retries'])) { - $easy->options['_curl_retries'] = 1; - } elseif ($easy->options['_curl_retries'] == 2) { - $ctx['error'] = 'The cURL request was retried 3 times ' - . 'and did not succeed. The most likely reason for the failure ' - . 'is that cURL was unable to rewind the body of the request ' - . 'and subsequent retries resulted in the same error. Turn on ' - . 'the debug option to see what went wrong. See ' - . 'https://bugs.php.net/bug.php?id=47204 for more information.'; - return self::createRejection($easy, $ctx); - } else { - $easy->options['_curl_retries']++; - } - - return $handler($easy->request, $easy->options); - } - - private function createHeaderFn(EasyHandle $easy) - { - if (isset($easy->options['on_headers'])) { - $onHeaders = $easy->options['on_headers']; - - if (!is_callable($onHeaders)) { - throw new \InvalidArgumentException('on_headers must be callable'); - } - } else { - $onHeaders = null; - } - - return function ($ch, $h) use ( - $onHeaders, - $easy, - &$startingResponse - ) { - $value = trim($h); - if ($value === '') { - $startingResponse = true; - $easy->createResponse(); - if ($onHeaders !== null) { - try { - $onHeaders($easy->response); - } catch (\Exception $e) { - // Associate the exception with the handle and trigger - // a curl header write error by returning 0. - $easy->onHeadersException = $e; - return -1; - } - } - } elseif ($startingResponse) { - $startingResponse = false; - $easy->headers = [$value]; - } else { - $easy->headers[] = $value; - } - return strlen($h); - }; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php deleted file mode 100644 index b0fc23685..000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlFactoryInterface.php +++ /dev/null @@ -1,27 +0,0 @@ -factory = isset($options['handle_factory']) - ? $options['handle_factory'] - : new CurlFactory(3); - } - - public function __invoke(RequestInterface $request, array $options) - { - if (isset($options['delay'])) { - usleep($options['delay'] * 1000); - } - - $easy = $this->factory->create($request, $options); - curl_exec($easy->handle); - $easy->errno = curl_errno($easy->handle); - - return CurlFactory::finish($this, $easy, $this->factory); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php deleted file mode 100644 index 945d06ee4..000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/CurlMultiHandler.php +++ /dev/null @@ -1,197 +0,0 @@ -factory = isset($options['handle_factory']) - ? $options['handle_factory'] : new CurlFactory(50); - $this->selectTimeout = isset($options['select_timeout']) - ? $options['select_timeout'] : 1; - } - - public function __get($name) - { - if ($name === '_mh') { - return $this->_mh = curl_multi_init(); - } - - throw new \BadMethodCallException(); - } - - public function __destruct() - { - if (isset($this->_mh)) { - curl_multi_close($this->_mh); - unset($this->_mh); - } - } - - public function __invoke(RequestInterface $request, array $options) - { - $easy = $this->factory->create($request, $options); - $id = (int) $easy->handle; - - $promise = new Promise( - [$this, 'execute'], - function () use ($id) { return $this->cancel($id); } - ); - - $this->addRequest(['easy' => $easy, 'deferred' => $promise]); - - return $promise; - } - - /** - * Ticks the curl event loop. - */ - public function tick() - { - // Add any delayed handles if needed. - if ($this->delays) { - $currentTime = microtime(true); - foreach ($this->delays as $id => $delay) { - if ($currentTime >= $delay) { - unset($this->delays[$id]); - curl_multi_add_handle( - $this->_mh, - $this->handles[$id]['easy']->handle - ); - } - } - } - - // Step through the task queue which may add additional requests. - P\queue()->run(); - - if ($this->active && - curl_multi_select($this->_mh, $this->selectTimeout) === -1 - ) { - // Perform a usleep if a select returns -1. - // See: https://bugs.php.net/bug.php?id=61141 - usleep(250); - } - - while (curl_multi_exec($this->_mh, $this->active) === CURLM_CALL_MULTI_PERFORM); - - $this->processMessages(); - } - - /** - * Runs until all outstanding connections have completed. - */ - public function execute() - { - $queue = P\queue(); - - while ($this->handles || !$queue->isEmpty()) { - // If there are no transfers, then sleep for the next delay - if (!$this->active && $this->delays) { - usleep($this->timeToNext()); - } - $this->tick(); - } - } - - private function addRequest(array $entry) - { - $easy = $entry['easy']; - $id = (int) $easy->handle; - $this->handles[$id] = $entry; - if (empty($easy->options['delay'])) { - curl_multi_add_handle($this->_mh, $easy->handle); - } else { - $this->delays[$id] = microtime(true) + ($easy->options['delay'] / 1000); - } - } - - /** - * Cancels a handle from sending and removes references to it. - * - * @param int $id Handle ID to cancel and remove. - * - * @return bool True on success, false on failure. - */ - private function cancel($id) - { - // Cannot cancel if it has been processed. - if (!isset($this->handles[$id])) { - return false; - } - - $handle = $this->handles[$id]['easy']->handle; - unset($this->delays[$id], $this->handles[$id]); - curl_multi_remove_handle($this->_mh, $handle); - curl_close($handle); - - return true; - } - - private function processMessages() - { - while ($done = curl_multi_info_read($this->_mh)) { - $id = (int) $done['handle']; - curl_multi_remove_handle($this->_mh, $done['handle']); - - if (!isset($this->handles[$id])) { - // Probably was cancelled. - continue; - } - - $entry = $this->handles[$id]; - unset($this->handles[$id], $this->delays[$id]); - $entry['easy']->errno = $done['result']; - $entry['deferred']->resolve( - CurlFactory::finish( - $this, - $entry['easy'], - $this->factory - ) - ); - } - } - - private function timeToNext() - { - $currentTime = microtime(true); - $nextTime = PHP_INT_MAX; - foreach ($this->delays as $time) { - if ($time < $nextTime) { - $nextTime = $time; - } - } - - return max(0, $nextTime - $currentTime) * 1000000; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php b/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php deleted file mode 100644 index 7754e9111..000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/EasyHandle.php +++ /dev/null @@ -1,92 +0,0 @@ -headers)) { - throw new \RuntimeException('No headers have been received'); - } - - // HTTP-version SP status-code SP reason-phrase - $startLine = explode(' ', array_shift($this->headers), 3); - $headers = \GuzzleHttp\headers_from_lines($this->headers); - $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers); - - if (!empty($this->options['decode_content']) - && isset($normalizedKeys['content-encoding']) - ) { - $headers['x-encoded-content-encoding'] - = $headers[$normalizedKeys['content-encoding']]; - unset($headers[$normalizedKeys['content-encoding']]); - if (isset($normalizedKeys['content-length'])) { - $headers['x-encoded-content-length'] - = $headers[$normalizedKeys['content-length']]; - - $bodyLength = (int) $this->sink->getSize(); - if ($bodyLength) { - $headers[$normalizedKeys['content-length']] = $bodyLength; - } else { - unset($headers[$normalizedKeys['content-length']]); - } - } - } - - // Attach a response to the easy handle with the parsed headers. - $this->response = new Response( - $startLine[1], - $headers, - $this->sink, - substr($startLine[0], 5), - isset($startLine[2]) ? (string) $startLine[2] : null - ); - } - - public function __get($name) - { - $msg = $name === 'handle' - ? 'The EasyHandle has been released' - : 'Invalid property: ' . $name; - throw new \BadMethodCallException($msg); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php b/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php deleted file mode 100644 index 7bbe7354c..000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/MockHandler.php +++ /dev/null @@ -1,176 +0,0 @@ -onFulfilled = $onFulfilled; - $this->onRejected = $onRejected; - - if ($queue) { - call_user_func_array([$this, 'append'], $queue); - } - } - - public function __invoke(RequestInterface $request, array $options) - { - if (!$this->queue) { - throw new \OutOfBoundsException('Mock queue is empty'); - } - - if (isset($options['delay'])) { - usleep($options['delay'] * 1000); - } - - $this->lastRequest = $request; - $this->lastOptions = $options; - $response = array_shift($this->queue); - - if (is_callable($response)) { - $response = call_user_func($response, $request, $options); - } - - $response = $response instanceof \Exception - ? new RejectedPromise($response) - : \GuzzleHttp\Promise\promise_for($response); - - return $response->then( - function ($value) use ($request, $options) { - $this->invokeStats($request, $options, $value); - if ($this->onFulfilled) { - call_user_func($this->onFulfilled, $value); - } - if (isset($options['sink'])) { - $contents = (string) $value->getBody(); - $sink = $options['sink']; - - if (is_resource($sink)) { - fwrite($sink, $contents); - } elseif (is_string($sink)) { - file_put_contents($sink, $contents); - } elseif ($sink instanceof \Psr\Http\Message\StreamInterface) { - $sink->write($contents); - } - } - - return $value; - }, - function ($reason) use ($request, $options) { - $this->invokeStats($request, $options, null, $reason); - if ($this->onRejected) { - call_user_func($this->onRejected, $reason); - } - return new RejectedPromise($reason); - } - ); - } - - /** - * Adds one or more variadic requests, exceptions, callables, or promises - * to the queue. - */ - public function append() - { - foreach (func_get_args() as $value) { - if ($value instanceof ResponseInterface - || $value instanceof \Exception - || $value instanceof PromiseInterface - || is_callable($value) - ) { - $this->queue[] = $value; - } else { - throw new \InvalidArgumentException('Expected a response or ' - . 'exception. Found ' . \GuzzleHttp\describe_type($value)); - } - } - } - - /** - * Get the last received request. - * - * @return RequestInterface - */ - public function getLastRequest() - { - return $this->lastRequest; - } - - /** - * Get the last received request options. - * - * @return RequestInterface - */ - public function getLastOptions() - { - return $this->lastOptions; - } - - /** - * Returns the number of remaining items in the queue. - * - * @return int - */ - public function count() - { - return count($this->queue); - } - - private function invokeStats( - RequestInterface $request, - array $options, - ResponseInterface $response = null, - $reason = null - ) { - if (isset($options['on_stats'])) { - $stats = new TransferStats($request, $response, 0, $reason); - call_user_func($options['on_stats'], $stats); - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php b/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php deleted file mode 100644 index f8b00be0b..000000000 --- a/vendor/guzzlehttp/guzzle/src/Handler/Proxy.php +++ /dev/null @@ -1,55 +0,0 @@ -withoutHeader('Expect'); - - // Append a content-length header if body size is zero to match - // cURL's behavior. - if (0 === $request->getBody()->getSize()) { - $request = $request->withHeader('Content-Length', 0); - } - - return $this->createResponse( - $request, - $options, - $this->createStream($request, $options), - $startTime - ); - } catch (\InvalidArgumentException $e) { - throw $e; - } catch (\Exception $e) { - // Determine if the error was a networking error. - $message = $e->getMessage(); - // This list can probably get more comprehensive. - if (strpos($message, 'getaddrinfo') // DNS lookup failed - || strpos($message, 'Connection refused') - || strpos($message, "couldn't connect to host") // error on HHVM - ) { - $e = new ConnectException($e->getMessage(), $request, $e); - } - $e = RequestException::wrapException($request, $e); - $this->invokeStats($options, $request, $startTime, null, $e); - - return new RejectedPromise($e); - } - } - - private function invokeStats( - array $options, - RequestInterface $request, - $startTime, - ResponseInterface $response = null, - $error = null - ) { - if (isset($options['on_stats'])) { - $stats = new TransferStats( - $request, - $response, - microtime(true) - $startTime, - $error, - [] - ); - call_user_func($options['on_stats'], $stats); - } - } - - private function createResponse( - RequestInterface $request, - array $options, - $stream, - $startTime - ) { - $hdrs = $this->lastHeaders; - $this->lastHeaders = []; - $parts = explode(' ', array_shift($hdrs), 3); - $ver = explode('/', $parts[0])[1]; - $status = $parts[1]; - $reason = isset($parts[2]) ? $parts[2] : null; - $headers = \GuzzleHttp\headers_from_lines($hdrs); - list ($stream, $headers) = $this->checkDecode($options, $headers, $stream); - $stream = Psr7\stream_for($stream); - $sink = $stream; - - if (strcasecmp('HEAD', $request->getMethod())) { - $sink = $this->createSink($stream, $options); - } - - $response = new Psr7\Response($status, $headers, $sink, $ver, $reason); - - if (isset($options['on_headers'])) { - try { - $options['on_headers']($response); - } catch (\Exception $e) { - $msg = 'An error was encountered during the on_headers event'; - $ex = new RequestException($msg, $request, $response, $e); - return new RejectedPromise($ex); - } - } - - // Do not drain when the request is a HEAD request because they have - // no body. - if ($sink !== $stream) { - $this->drain( - $stream, - $sink, - $response->getHeaderLine('Content-Length') - ); - } - - $this->invokeStats($options, $request, $startTime, $response, null); - - return new FulfilledPromise($response); - } - - private function createSink(StreamInterface $stream, array $options) - { - if (!empty($options['stream'])) { - return $stream; - } - - $sink = isset($options['sink']) - ? $options['sink'] - : fopen('php://temp', 'r+'); - - return is_string($sink) - ? new Psr7\LazyOpenStream($sink, 'w+') - : Psr7\stream_for($sink); - } - - private function checkDecode(array $options, array $headers, $stream) - { - // Automatically decode responses when instructed. - if (!empty($options['decode_content'])) { - $normalizedKeys = \GuzzleHttp\normalize_header_keys($headers); - if (isset($normalizedKeys['content-encoding'])) { - $encoding = $headers[$normalizedKeys['content-encoding']]; - if ($encoding[0] === 'gzip' || $encoding[0] === 'deflate') { - $stream = new Psr7\InflateStream( - Psr7\stream_for($stream) - ); - $headers['x-encoded-content-encoding'] - = $headers[$normalizedKeys['content-encoding']]; - // Remove content-encoding header - unset($headers[$normalizedKeys['content-encoding']]); - // Fix content-length header - if (isset($normalizedKeys['content-length'])) { - $headers['x-encoded-content-length'] - = $headers[$normalizedKeys['content-length']]; - - $length = (int) $stream->getSize(); - if ($length === 0) { - unset($headers[$normalizedKeys['content-length']]); - } else { - $headers[$normalizedKeys['content-length']] = [$length]; - } - } - } - } - } - - return [$stream, $headers]; - } - - /** - * Drains the source stream into the "sink" client option. - * - * @param StreamInterface $source - * @param StreamInterface $sink - * @param string $contentLength Header specifying the amount of - * data to read. - * - * @return StreamInterface - * @throws \RuntimeException when the sink option is invalid. - */ - private function drain( - StreamInterface $source, - StreamInterface $sink, - $contentLength - ) { - // If a content-length header is provided, then stop reading once - // that number of bytes has been read. This can prevent infinitely - // reading from a stream when dealing with servers that do not honor - // Connection: Close headers. - Psr7\copy_to_stream( - $source, - $sink, - strlen($contentLength) > 0 ? (int) $contentLength : -1 - ); - - $sink->seek(0); - $source->close(); - - return $sink; - } - - /** - * Create a resource and check to ensure it was created successfully - * - * @param callable $callback Callable that returns stream resource - * - * @return resource - * @throws \RuntimeException on error - */ - private function createResource(callable $callback) - { - $errors = null; - set_error_handler(function ($_, $msg, $file, $line) use (&$errors) { - $errors[] = [ - 'message' => $msg, - 'file' => $file, - 'line' => $line - ]; - return true; - }); - - $resource = $callback(); - restore_error_handler(); - - if (!$resource) { - $message = 'Error creating resource: '; - foreach ($errors as $err) { - foreach ($err as $key => $value) { - $message .= "[$key] $value" . PHP_EOL; - } - } - throw new \RuntimeException(trim($message)); - } - - return $resource; - } - - private function createStream(RequestInterface $request, array $options) - { - static $methods; - if (!$methods) { - $methods = array_flip(get_class_methods(__CLASS__)); - } - - // HTTP/1.1 streams using the PHP stream wrapper require a - // Connection: close header - if ($request->getProtocolVersion() == '1.1' - && !$request->hasHeader('Connection') - ) { - $request = $request->withHeader('Connection', 'close'); - } - - // Ensure SSL is verified by default - if (!isset($options['verify'])) { - $options['verify'] = true; - } - - $params = []; - $context = $this->getDefaultContext($request, $options); - - if (isset($options['on_headers']) && !is_callable($options['on_headers'])) { - throw new \InvalidArgumentException('on_headers must be callable'); - } - - if (!empty($options)) { - foreach ($options as $key => $value) { - $method = "add_{$key}"; - if (isset($methods[$method])) { - $this->{$method}($request, $context, $value, $params); - } - } - } - - if (isset($options['stream_context'])) { - if (!is_array($options['stream_context'])) { - throw new \InvalidArgumentException('stream_context must be an array'); - } - $context = array_replace_recursive( - $context, - $options['stream_context'] - ); - } - - $context = $this->createResource( - function () use ($context, $params) { - return stream_context_create($context, $params); - } - ); - - return $this->createResource( - function () use ($request, &$http_response_header, $context) { - $resource = fopen((string) $request->getUri()->withFragment(''), 'r', null, $context); - $this->lastHeaders = $http_response_header; - return $resource; - } - ); - } - - private function getDefaultContext(RequestInterface $request) - { - $headers = ''; - foreach ($request->getHeaders() as $name => $value) { - foreach ($value as $val) { - $headers .= "$name: $val\r\n"; - } - } - - $context = [ - 'http' => [ - 'method' => $request->getMethod(), - 'header' => $headers, - 'protocol_version' => $request->getProtocolVersion(), - 'ignore_errors' => true, - 'follow_location' => 0, - ], - ]; - - $body = (string) $request->getBody(); - - if (!empty($body)) { - $context['http']['content'] = $body; - // Prevent the HTTP handler from adding a Content-Type header. - if (!$request->hasHeader('Content-Type')) { - $context['http']['header'] .= "Content-Type:\r\n"; - } - } - - $context['http']['header'] = rtrim($context['http']['header']); - - return $context; - } - - private function add_proxy(RequestInterface $request, &$options, $value, &$params) - { - if (!is_array($value)) { - $options['http']['proxy'] = $value; - } else { - $scheme = $request->getUri()->getScheme(); - if (isset($value[$scheme])) { - if (!isset($value['no']) - || !\GuzzleHttp\is_host_in_noproxy( - $request->getUri()->getHost(), - $value['no'] - ) - ) { - $options['http']['proxy'] = $value[$scheme]; - } - } - } - } - - private function add_timeout(RequestInterface $request, &$options, $value, &$params) - { - if ($value > 0) { - $options['http']['timeout'] = $value; - } - } - - private function add_verify(RequestInterface $request, &$options, $value, &$params) - { - if ($value === true) { - // PHP 5.6 or greater will find the system cert by default. When - // < 5.6, use the Guzzle bundled cacert. - if (PHP_VERSION_ID < 50600) { - $options['ssl']['cafile'] = \GuzzleHttp\default_ca_bundle(); - } - } elseif (is_string($value)) { - $options['ssl']['cafile'] = $value; - if (!file_exists($value)) { - throw new \RuntimeException("SSL CA bundle not found: $value"); - } - } elseif ($value === false) { - $options['ssl']['verify_peer'] = false; - $options['ssl']['verify_peer_name'] = false; - return; - } else { - throw new \InvalidArgumentException('Invalid verify request option'); - } - - $options['ssl']['verify_peer'] = true; - $options['ssl']['verify_peer_name'] = true; - $options['ssl']['allow_self_signed'] = false; - } - - private function add_cert(RequestInterface $request, &$options, $value, &$params) - { - if (is_array($value)) { - $options['ssl']['passphrase'] = $value[1]; - $value = $value[0]; - } - - if (!file_exists($value)) { - throw new \RuntimeException("SSL certificate not found: {$value}"); - } - - $options['ssl']['local_cert'] = $value; - } - - private function add_progress(RequestInterface $request, &$options, $value, &$params) - { - $this->addNotification( - $params, - function ($code, $a, $b, $c, $transferred, $total) use ($value) { - if ($code == STREAM_NOTIFY_PROGRESS) { - $value($total, $transferred, null, null); - } - } - ); - } - - private function add_debug(RequestInterface $request, &$options, $value, &$params) - { - if ($value === false) { - return; - } - - static $map = [ - STREAM_NOTIFY_CONNECT => 'CONNECT', - STREAM_NOTIFY_AUTH_REQUIRED => 'AUTH_REQUIRED', - STREAM_NOTIFY_AUTH_RESULT => 'AUTH_RESULT', - STREAM_NOTIFY_MIME_TYPE_IS => 'MIME_TYPE_IS', - STREAM_NOTIFY_FILE_SIZE_IS => 'FILE_SIZE_IS', - STREAM_NOTIFY_REDIRECTED => 'REDIRECTED', - STREAM_NOTIFY_PROGRESS => 'PROGRESS', - STREAM_NOTIFY_FAILURE => 'FAILURE', - STREAM_NOTIFY_COMPLETED => 'COMPLETED', - STREAM_NOTIFY_RESOLVE => 'RESOLVE', - ]; - static $args = ['severity', 'message', 'message_code', - 'bytes_transferred', 'bytes_max']; - - $value = \GuzzleHttp\debug_resource($value); - $ident = $request->getMethod() . ' ' . $request->getUri()->withFragment(''); - $this->addNotification( - $params, - function () use ($ident, $value, $map, $args) { - $passed = func_get_args(); - $code = array_shift($passed); - fprintf($value, '<%s> [%s] ', $ident, $map[$code]); - foreach (array_filter($passed) as $i => $v) { - fwrite($value, $args[$i] . ': "' . $v . '" '); - } - fwrite($value, "\n"); - } - ); - } - - private function addNotification(array &$params, callable $notify) - { - // Wrap the existing function if needed. - if (!isset($params['notification'])) { - $params['notification'] = $notify; - } else { - $params['notification'] = $this->callArray([ - $params['notification'], - $notify - ]); - } - } - - private function callArray(array $functions) - { - return function () use ($functions) { - $args = func_get_args(); - foreach ($functions as $fn) { - call_user_func_array($fn, $args); - } - }; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/HandlerStack.php b/vendor/guzzlehttp/guzzle/src/HandlerStack.php deleted file mode 100644 index a72e38a53..000000000 --- a/vendor/guzzlehttp/guzzle/src/HandlerStack.php +++ /dev/null @@ -1,273 +0,0 @@ -push(Middleware::httpErrors(), 'http_errors'); - $stack->push(Middleware::redirect(), 'allow_redirects'); - $stack->push(Middleware::cookies(), 'cookies'); - $stack->push(Middleware::prepareBody(), 'prepare_body'); - - return $stack; - } - - /** - * @param callable $handler Underlying HTTP handler. - */ - public function __construct(callable $handler = null) - { - $this->handler = $handler; - } - - /** - * Invokes the handler stack as a composed handler - * - * @param RequestInterface $request - * @param array $options - */ - public function __invoke(RequestInterface $request, array $options) - { - $handler = $this->resolve(); - - return $handler($request, $options); - } - - /** - * Dumps a string representation of the stack. - * - * @return string - */ - public function __toString() - { - $depth = 0; - $stack = []; - if ($this->handler) { - $stack[] = "0) Handler: " . $this->debugCallable($this->handler); - } - - $result = ''; - foreach (array_reverse($this->stack) as $tuple) { - $depth++; - $str = "{$depth}) Name: '{$tuple[1]}', "; - $str .= "Function: " . $this->debugCallable($tuple[0]); - $result = "> {$str}\n{$result}"; - $stack[] = $str; - } - - foreach (array_keys($stack) as $k) { - $result .= "< {$stack[$k]}\n"; - } - - return $result; - } - - /** - * Set the HTTP handler that actually returns a promise. - * - * @param callable $handler Accepts a request and array of options and - * returns a Promise. - */ - public function setHandler(callable $handler) - { - $this->handler = $handler; - $this->cached = null; - } - - /** - * Returns true if the builder has a handler. - * - * @return bool - */ - public function hasHandler() - { - return (bool) $this->handler; - } - - /** - * Unshift a middleware to the bottom of the stack. - * - * @param callable $middleware Middleware function - * @param string $name Name to register for this middleware. - */ - public function unshift(callable $middleware, $name = null) - { - array_unshift($this->stack, [$middleware, $name]); - $this->cached = null; - } - - /** - * Push a middleware to the top of the stack. - * - * @param callable $middleware Middleware function - * @param string $name Name to register for this middleware. - */ - public function push(callable $middleware, $name = '') - { - $this->stack[] = [$middleware, $name]; - $this->cached = null; - } - - /** - * Add a middleware before another middleware by name. - * - * @param string $findName Middleware to find - * @param callable $middleware Middleware function - * @param string $withName Name to register for this middleware. - */ - public function before($findName, callable $middleware, $withName = '') - { - $this->splice($findName, $withName, $middleware, true); - } - - /** - * Add a middleware after another middleware by name. - * - * @param string $findName Middleware to find - * @param callable $middleware Middleware function - * @param string $withName Name to register for this middleware. - */ - public function after($findName, callable $middleware, $withName = '') - { - $this->splice($findName, $withName, $middleware, false); - } - - /** - * Remove a middleware by instance or name from the stack. - * - * @param callable|string $remove Middleware to remove by instance or name. - */ - public function remove($remove) - { - $this->cached = null; - $idx = is_callable($remove) ? 0 : 1; - $this->stack = array_values(array_filter( - $this->stack, - function ($tuple) use ($idx, $remove) { - return $tuple[$idx] !== $remove; - } - )); - } - - /** - * Compose the middleware and handler into a single callable function. - * - * @return callable - */ - public function resolve() - { - if (!$this->cached) { - if (!($prev = $this->handler)) { - throw new \LogicException('No handler has been specified'); - } - - foreach (array_reverse($this->stack) as $fn) { - $prev = $fn[0]($prev); - } - - $this->cached = $prev; - } - - return $this->cached; - } - - /** - * @param $name - * @return int - */ - private function findByName($name) - { - foreach ($this->stack as $k => $v) { - if ($v[1] === $name) { - return $k; - } - } - - throw new \InvalidArgumentException("Middleware not found: $name"); - } - - /** - * Splices a function into the middleware list at a specific position. - * - * @param $findName - * @param $withName - * @param callable $middleware - * @param $before - */ - private function splice($findName, $withName, callable $middleware, $before) - { - $this->cached = null; - $idx = $this->findByName($findName); - $tuple = [$middleware, $withName]; - - if ($before) { - if ($idx === 0) { - array_unshift($this->stack, $tuple); - } else { - $replacement = [$tuple, $this->stack[$idx]]; - array_splice($this->stack, $idx, 1, $replacement); - } - } elseif ($idx === count($this->stack) - 1) { - $this->stack[] = $tuple; - } else { - $replacement = [$this->stack[$idx], $tuple]; - array_splice($this->stack, $idx, 1, $replacement); - } - } - - /** - * Provides a debug string for a given callable. - * - * @param array|callable $fn Function to write as a string. - * - * @return string - */ - private function debugCallable($fn) - { - if (is_string($fn)) { - return "callable({$fn})"; - } - - if (is_array($fn)) { - return is_string($fn[0]) - ? "callable({$fn[0]}::{$fn[1]})" - : "callable(['" . get_class($fn[0]) . "', '{$fn[1]}'])"; - } - - return 'callable(' . spl_object_hash($fn) . ')'; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php b/vendor/guzzlehttp/guzzle/src/MessageFormatter.php deleted file mode 100644 index 6b090a977..000000000 --- a/vendor/guzzlehttp/guzzle/src/MessageFormatter.php +++ /dev/null @@ -1,182 +0,0 @@ ->>>>>>>\n{request}\n<<<<<<<<\n{response}\n--------\n{error}"; - const SHORT = '[{ts}] "{method} {target} HTTP/{version}" {code}'; - - /** @var string Template used to format log messages */ - private $template; - - /** - * @param string $template Log message template - */ - public function __construct($template = self::CLF) - { - $this->template = $template ?: self::CLF; - } - - /** - * Returns a formatted message string. - * - * @param RequestInterface $request Request that was sent - * @param ResponseInterface $response Response that was received - * @param \Exception $error Exception that was received - * - * @return string - */ - public function format( - RequestInterface $request, - ResponseInterface $response = null, - \Exception $error = null - ) { - $cache = []; - - return preg_replace_callback( - '/{\s*([A-Za-z_\-\.0-9]+)\s*}/', - function (array $matches) use ($request, $response, $error, &$cache) { - - if (isset($cache[$matches[1]])) { - return $cache[$matches[1]]; - } - - $result = ''; - switch ($matches[1]) { - case 'request': - $result = Psr7\str($request); - break; - case 'response': - $result = $response ? Psr7\str($response) : ''; - break; - case 'req_headers': - $result = trim($request->getMethod() - . ' ' . $request->getRequestTarget()) - . ' HTTP/' . $request->getProtocolVersion() . "\r\n" - . $this->headers($request); - break; - case 'res_headers': - $result = $response ? - sprintf( - 'HTTP/%s %d %s', - $response->getProtocolVersion(), - $response->getStatusCode(), - $response->getReasonPhrase() - ) . "\r\n" . $this->headers($response) - : 'NULL'; - break; - case 'req_body': - $result = $request->getBody(); - break; - case 'res_body': - $result = $response ? $response->getBody() : 'NULL'; - break; - case 'ts': - case 'date_iso_8601': - $result = gmdate('c'); - break; - case 'date_common_log': - $result = date('d/M/Y:H:i:s O'); - break; - case 'method': - $result = $request->getMethod(); - break; - case 'version': - $result = $request->getProtocolVersion(); - break; - case 'uri': - case 'url': - $result = $request->getUri(); - break; - case 'target': - $result = $request->getRequestTarget(); - break; - case 'req_version': - $result = $request->getProtocolVersion(); - break; - case 'res_version': - $result = $response - ? $response->getProtocolVersion() - : 'NULL'; - break; - case 'host': - $result = $request->getHeaderLine('Host'); - break; - case 'hostname': - $result = gethostname(); - break; - case 'code': - $result = $response ? $response->getStatusCode() : 'NULL'; - break; - case 'phrase': - $result = $response ? $response->getReasonPhrase() : 'NULL'; - break; - case 'error': - $result = $error ? $error->getMessage() : 'NULL'; - break; - default: - // handle prefixed dynamic headers - if (strpos($matches[1], 'req_header_') === 0) { - $result = $request->getHeaderLine(substr($matches[1], 11)); - } elseif (strpos($matches[1], 'res_header_') === 0) { - $result = $response - ? $response->getHeaderLine(substr($matches[1], 11)) - : 'NULL'; - } - } - - $cache[$matches[1]] = $result; - return $result; - }, - $this->template - ); - } - - private function headers(MessageInterface $message) - { - $result = ''; - foreach ($message->getHeaders() as $name => $values) { - $result .= $name . ': ' . implode(', ', $values) . "\r\n"; - } - - return trim($result); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Middleware.php b/vendor/guzzlehttp/guzzle/src/Middleware.php deleted file mode 100644 index 449ab4bf0..000000000 --- a/vendor/guzzlehttp/guzzle/src/Middleware.php +++ /dev/null @@ -1,254 +0,0 @@ -withCookieHeader($request); - return $handler($request, $options) - ->then(function ($response) use ($cookieJar, $request) { - $cookieJar->extractCookies($request, $response); - return $response; - } - ); - }; - }; - } - - /** - * Middleware that throws exceptions for 4xx or 5xx responses when the - * "http_error" request option is set to true. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function httpErrors() - { - return function (callable $handler) { - return function ($request, array $options) use ($handler) { - if (empty($options['http_errors'])) { - return $handler($request, $options); - } - return $handler($request, $options)->then( - function (ResponseInterface $response) use ($request, $handler) { - $code = $response->getStatusCode(); - if ($code < 400) { - return $response; - } - throw RequestException::create($request, $response); - } - ); - }; - }; - } - - /** - * Middleware that pushes history data to an ArrayAccess container. - * - * @param array $container Container to hold the history (by reference). - * - * @return callable Returns a function that accepts the next handler. - * @throws \InvalidArgumentException if container is not an array or ArrayAccess. - */ - public static function history(&$container) - { - if (!is_array($container) && !$container instanceof \ArrayAccess) { - throw new \InvalidArgumentException('history container must be an array or object implementing ArrayAccess'); - } - - return function (callable $handler) use (&$container) { - return function ($request, array $options) use ($handler, &$container) { - return $handler($request, $options)->then( - function ($value) use ($request, &$container, $options) { - $container[] = [ - 'request' => $request, - 'response' => $value, - 'error' => null, - 'options' => $options - ]; - return $value; - }, - function ($reason) use ($request, &$container, $options) { - $container[] = [ - 'request' => $request, - 'response' => null, - 'error' => $reason, - 'options' => $options - ]; - return new RejectedPromise($reason); - } - ); - }; - }; - } - - /** - * Middleware that invokes a callback before and after sending a request. - * - * The provided listener cannot modify or alter the response. It simply - * "taps" into the chain to be notified before returning the promise. The - * before listener accepts a request and options array, and the after - * listener accepts a request, options array, and response promise. - * - * @param callable $before Function to invoke before forwarding the request. - * @param callable $after Function invoked after forwarding. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function tap(callable $before = null, callable $after = null) - { - return function (callable $handler) use ($before, $after) { - return function ($request, array $options) use ($handler, $before, $after) { - if ($before) { - $before($request, $options); - } - $response = $handler($request, $options); - if ($after) { - $after($request, $options, $response); - } - return $response; - }; - }; - } - - /** - * Middleware that handles request redirects. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function redirect() - { - return function (callable $handler) { - return new RedirectMiddleware($handler); - }; - } - - /** - * Middleware that retries requests based on the boolean result of - * invoking the provided "decider" function. - * - * If no delay function is provided, a simple implementation of exponential - * backoff will be utilized. - * - * @param callable $decider Function that accepts the number of retries, - * a request, [response], and [exception] and - * returns true if the request is to be retried. - * @param callable $delay Function that accepts the number of retries and - * returns the number of milliseconds to delay. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function retry(callable $decider, callable $delay = null) - { - return function (callable $handler) use ($decider, $delay) { - return new RetryMiddleware($decider, $handler, $delay); - }; - } - - /** - * Middleware that logs requests, responses, and errors using a message - * formatter. - * - * @param LoggerInterface $logger Logs messages. - * @param MessageFormatter $formatter Formatter used to create message strings. - * @param string $logLevel Level at which to log requests. - * - * @return callable Returns a function that accepts the next handler. - */ - public static function log(LoggerInterface $logger, MessageFormatter $formatter, $logLevel = LogLevel::INFO) - { - return function (callable $handler) use ($logger, $formatter, $logLevel) { - return function ($request, array $options) use ($handler, $logger, $formatter, $logLevel) { - return $handler($request, $options)->then( - function ($response) use ($logger, $request, $formatter, $logLevel) { - $message = $formatter->format($request, $response); - $logger->log($logLevel, $message); - return $response; - }, - function ($reason) use ($logger, $request, $formatter) { - $response = $reason instanceof RequestException - ? $reason->getResponse() - : null; - $message = $formatter->format($request, $response, $reason); - $logger->notice($message); - return \GuzzleHttp\Promise\rejection_for($reason); - } - ); - }; - }; - } - - /** - * This middleware adds a default content-type if possible, a default - * content-length or transfer-encoding header, and the expect header. - * - * @return callable - */ - public static function prepareBody() - { - return function (callable $handler) { - return new PrepareBodyMiddleware($handler); - }; - } - - /** - * Middleware that applies a map function to the request before passing to - * the next handler. - * - * @param callable $fn Function that accepts a RequestInterface and returns - * a RequestInterface. - * @return callable - */ - public static function mapRequest(callable $fn) - { - return function (callable $handler) use ($fn) { - return function ($request, array $options) use ($handler, $fn) { - return $handler($fn($request), $options); - }; - }; - } - - /** - * Middleware that applies a map function to the resolved promise's - * response. - * - * @param callable $fn Function that accepts a ResponseInterface and - * returns a ResponseInterface. - * @return callable - */ - public static function mapResponse(callable $fn) - { - return function (callable $handler) use ($fn) { - return function ($request, array $options) use ($handler, $fn) { - return $handler($request, $options)->then($fn); - }; - }; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/Pool.php b/vendor/guzzlehttp/guzzle/src/Pool.php deleted file mode 100644 index 8f1be33cd..000000000 --- a/vendor/guzzlehttp/guzzle/src/Pool.php +++ /dev/null @@ -1,123 +0,0 @@ - $rfn) { - if ($rfn instanceof RequestInterface) { - yield $key => $client->sendAsync($rfn, $opts); - } elseif (is_callable($rfn)) { - yield $key => $rfn($opts); - } else { - throw new \InvalidArgumentException('Each value yielded by ' - . 'the iterator must be a Psr7\Http\Message\RequestInterface ' - . 'or a callable that returns a promise that fulfills ' - . 'with a Psr7\Message\Http\ResponseInterface object.'); - } - } - }; - - $this->each = new EachPromise($requests(), $config); - } - - public function promise() - { - return $this->each->promise(); - } - - /** - * Sends multiple requests concurrently and returns an array of responses - * and exceptions that uses the same ordering as the provided requests. - * - * IMPORTANT: This method keeps every request and response in memory, and - * as such, is NOT recommended when sending a large number or an - * indeterminate number of requests concurrently. - * - * @param ClientInterface $client Client used to send the requests - * @param array|\Iterator $requests Requests to send concurrently. - * @param array $options Passes through the options available in - * {@see GuzzleHttp\Pool::__construct} - * - * @return array Returns an array containing the response or an exception - * in the same order that the requests were sent. - * @throws \InvalidArgumentException if the event format is incorrect. - */ - public static function batch( - ClientInterface $client, - $requests, - array $options = [] - ) { - $res = []; - self::cmpCallback($options, 'fulfilled', $res); - self::cmpCallback($options, 'rejected', $res); - $pool = new static($client, $requests, $options); - $pool->promise()->wait(); - ksort($res); - - return $res; - } - - private static function cmpCallback(array &$options, $name, array &$results) - { - if (!isset($options[$name])) { - $options[$name] = function ($v, $k) use (&$results) { - $results[$k] = $v; - }; - } else { - $currentFn = $options[$name]; - $options[$name] = function ($v, $k) use (&$results, $currentFn) { - $currentFn($v, $k); - $results[$k] = $v; - }; - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php b/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php deleted file mode 100644 index e6d176b61..000000000 --- a/vendor/guzzlehttp/guzzle/src/PrepareBodyMiddleware.php +++ /dev/null @@ -1,112 +0,0 @@ - true, 'HEAD' => true]; - - /** - * @param callable $nextHandler Next handler to invoke. - */ - public function __construct(callable $nextHandler) - { - $this->nextHandler = $nextHandler; - } - - /** - * @param RequestInterface $request - * @param array $options - * - * @return PromiseInterface - */ - public function __invoke(RequestInterface $request, array $options) - { - $fn = $this->nextHandler; - - // Don't do anything if the request has no body. - if (isset(self::$skipMethods[$request->getMethod()]) - || $request->getBody()->getSize() === 0 - ) { - return $fn($request, $options); - } - - $modify = []; - - // Add a default content-type if possible. - if (!$request->hasHeader('Content-Type')) { - if ($uri = $request->getBody()->getMetadata('uri')) { - if ($type = Psr7\mimetype_from_filename($uri)) { - $modify['set_headers']['Content-Type'] = $type; - } - } - } - - // Add a default content-length or transfer-encoding header. - if (!isset(self::$skipMethods[$request->getMethod()]) - && !$request->hasHeader('Content-Length') - && !$request->hasHeader('Transfer-Encoding') - ) { - $size = $request->getBody()->getSize(); - if ($size !== null) { - $modify['set_headers']['Content-Length'] = $size; - } else { - $modify['set_headers']['Transfer-Encoding'] = 'chunked'; - } - } - - // Add the expect header if needed. - $this->addExpectHeader($request, $options, $modify); - - return $fn(Psr7\modify_request($request, $modify), $options); - } - - private function addExpectHeader( - RequestInterface $request, - array $options, - array &$modify - ) { - // Determine if the Expect header should be used - if ($request->hasHeader('Expect')) { - return; - } - - $expect = isset($options['expect']) ? $options['expect'] : null; - - // Return if disabled or if you're not using HTTP/1.1 or HTTP/2.0 - if ($expect === false || $request->getProtocolVersion() < 1.1) { - return; - } - - // The expect header is unconditionally enabled - if ($expect === true) { - $modify['set_headers']['Expect'] = '100-Continue'; - return; - } - - // By default, send the expect header when the payload is > 1mb - if ($expect === null) { - $expect = 1048576; - } - - // Always add if the body cannot be rewound, the size cannot be - // determined, or the size is greater than the cutoff threshold - $body = $request->getBody(); - $size = $body->getSize(); - - if ($size === null || $size >= (int) $expect || !$body->isSeekable()) { - $modify['set_headers']['Expect'] = '100-Continue'; - } - } -} diff --git a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php b/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php deleted file mode 100644 index dbe8b87e5..000000000 --- a/vendor/guzzlehttp/guzzle/src/RedirectMiddleware.php +++ /dev/null @@ -1,231 +0,0 @@ - 5, - 'protocols' => ['http', 'https'], - 'strict' => false, - 'referer' => false, - 'track_redirects' => false, - ]; - - /** @var callable */ - private $nextHandler; - - /** - * @param callable $nextHandler Next handler to invoke. - */ - public function __construct(callable $nextHandler) - { - $this->nextHandler = $nextHandler; - } - - /** - * @param RequestInterface $request - * @param array $options - * - * @return PromiseInterface - */ - public function __invoke(RequestInterface $request, array $options) - { - $fn = $this->nextHandler; - - if (empty($options['allow_redirects'])) { - return $fn($request, $options); - } - - if ($options['allow_redirects'] === true) { - $options['allow_redirects'] = self::$defaultSettings; - } elseif (!is_array($options['allow_redirects'])) { - throw new \InvalidArgumentException('allow_redirects must be true, false, or array'); - } else { - // Merge the default settings with the provided settings - $options['allow_redirects'] += self::$defaultSettings; - } - - if (empty($options['allow_redirects']['max'])) { - return $fn($request, $options); - } - - return $fn($request, $options) - ->then(function (ResponseInterface $response) use ($request, $options) { - return $this->checkRedirect($request, $options, $response); - }); - } - - /** - * @param RequestInterface $request - * @param array $options - * @param ResponseInterface|PromiseInterface $response - * - * @return ResponseInterface|PromiseInterface - */ - public function checkRedirect( - RequestInterface $request, - array $options, - ResponseInterface $response - ) { - if (substr($response->getStatusCode(), 0, 1) != '3' - || !$response->hasHeader('Location') - ) { - return $response; - } - - $this->guardMax($request, $options); - $nextRequest = $this->modifyRequest($request, $options, $response); - - if (isset($options['allow_redirects']['on_redirect'])) { - call_user_func( - $options['allow_redirects']['on_redirect'], - $request, - $response, - $nextRequest->getUri() - ); - } - - /** @var PromiseInterface|ResponseInterface $promise */ - $promise = $this($nextRequest, $options); - - // Add headers to be able to track history of redirects. - if (!empty($options['allow_redirects']['track_redirects'])) { - return $this->withTracking( - $promise, - (string) $nextRequest->getUri() - ); - } - - return $promise; - } - - private function withTracking(PromiseInterface $promise, $uri) - { - return $promise->then( - function (ResponseInterface $response) use ($uri) { - // Note that we are pushing to the front of the list as this - // would be an earlier response than what is currently present - // in the history header. - $header = $response->getHeader(self::HISTORY_HEADER); - array_unshift($header, $uri); - return $response->withHeader(self::HISTORY_HEADER, $header); - } - ); - } - - private function guardMax(RequestInterface $request, array &$options) - { - $current = isset($options['__redirect_count']) - ? $options['__redirect_count'] - : 0; - $options['__redirect_count'] = $current + 1; - $max = $options['allow_redirects']['max']; - - if ($options['__redirect_count'] > $max) { - throw new TooManyRedirectsException( - "Will not follow more than {$max} redirects", - $request - ); - } - } - - /** - * @param RequestInterface $request - * @param array $options - * @param ResponseInterface $response - * - * @return RequestInterface - */ - public function modifyRequest( - RequestInterface $request, - array $options, - ResponseInterface $response - ) { - // Request modifications to apply. - $modify = []; - $protocols = $options['allow_redirects']['protocols']; - - // Use a GET request if this is an entity enclosing request and we are - // not forcing RFC compliance, but rather emulating what all browsers - // would do. - $statusCode = $response->getStatusCode(); - if ($statusCode == 303 || - ($statusCode <= 302 && $request->getBody() && !$options['allow_redirects']['strict']) - ) { - $modify['method'] = 'GET'; - $modify['body'] = ''; - } - - $modify['uri'] = $this->redirectUri($request, $response, $protocols); - Psr7\rewind_body($request); - - // Add the Referer header if it is told to do so and only - // add the header if we are not redirecting from https to http. - if ($options['allow_redirects']['referer'] - && $modify['uri']->getScheme() === $request->getUri()->getScheme() - ) { - $uri = $request->getUri()->withUserInfo('', ''); - $modify['set_headers']['Referer'] = (string) $uri; - } else { - $modify['remove_headers'][] = 'Referer'; - } - - // Remove Authorization header if host is different. - if ($request->getUri()->getHost() !== $modify['uri']->getHost()) { - $modify['remove_headers'][] = 'Authorization'; - } - - return Psr7\modify_request($request, $modify); - } - - /** - * Set the appropriate URL on the request based on the location header - * - * @param RequestInterface $request - * @param ResponseInterface $response - * @param array $protocols - * - * @return UriInterface - */ - private function redirectUri( - RequestInterface $request, - ResponseInterface $response, - array $protocols - ) { - $location = Psr7\Uri::resolve( - $request->getUri(), - $response->getHeaderLine('Location') - ); - - // Ensure that the redirect URI is allowed based on the protocols. - if (!in_array($location->getScheme(), $protocols)) { - throw new BadResponseException( - sprintf( - 'Redirect URI, %s, does not use one of the allowed redirect protocols: %s', - $location, - implode(', ', $protocols) - ), - $request, - $response - ); - } - - return $location; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/RequestOptions.php b/vendor/guzzlehttp/guzzle/src/RequestOptions.php deleted file mode 100644 index 3af2f368a..000000000 --- a/vendor/guzzlehttp/guzzle/src/RequestOptions.php +++ /dev/null @@ -1,244 +0,0 @@ -decider = $decider; - $this->nextHandler = $nextHandler; - $this->delay = $delay ?: __CLASS__ . '::exponentialDelay'; - } - - /** - * Default exponential backoff delay function. - * - * @param $retries - * - * @return int - */ - public static function exponentialDelay($retries) - { - return (int) pow(2, $retries - 1); - } - - /** - * @param RequestInterface $request - * @param array $options - * - * @return PromiseInterface - */ - public function __invoke(RequestInterface $request, array $options) - { - if (!isset($options['retries'])) { - $options['retries'] = 0; - } - - $fn = $this->nextHandler; - return $fn($request, $options) - ->then( - $this->onFulfilled($request, $options), - $this->onRejected($request, $options) - ); - } - - private function onFulfilled(RequestInterface $req, array $options) - { - return function ($value) use ($req, $options) { - if (!call_user_func( - $this->decider, - $options['retries'], - $req, - $value, - null - )) { - return $value; - } - return $this->doRetry($req, $options); - }; - } - - private function onRejected(RequestInterface $req, array $options) - { - return function ($reason) use ($req, $options) { - if (!call_user_func( - $this->decider, - $options['retries'], - $req, - null, - $reason - )) { - return new RejectedPromise($reason); - } - return $this->doRetry($req, $options); - }; - } - - private function doRetry(RequestInterface $request, array $options) - { - $options['delay'] = call_user_func($this->delay, ++$options['retries']); - - return $this($request, $options); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/TransferStats.php b/vendor/guzzlehttp/guzzle/src/TransferStats.php deleted file mode 100644 index 15f717e1e..000000000 --- a/vendor/guzzlehttp/guzzle/src/TransferStats.php +++ /dev/null @@ -1,126 +0,0 @@ -request = $request; - $this->response = $response; - $this->transferTime = $transferTime; - $this->handlerErrorData = $handlerErrorData; - $this->handlerStats = $handlerStats; - } - - /** - * @return RequestInterface - */ - public function getRequest() - { - return $this->request; - } - - /** - * Returns the response that was received (if any). - * - * @return ResponseInterface|null - */ - public function getResponse() - { - return $this->response; - } - - /** - * Returns true if a response was received. - * - * @return bool - */ - public function hasResponse() - { - return $this->response !== null; - } - - /** - * Gets handler specific error data. - * - * This might be an exception, a integer representing an error code, or - * anything else. Relying on this value assumes that you know what handler - * you are using. - * - * @return mixed - */ - public function getHandlerErrorData() - { - return $this->handlerErrorData; - } - - /** - * Get the effective URI the request was sent to. - * - * @return UriInterface - */ - public function getEffectiveUri() - { - return $this->request->getUri(); - } - - /** - * Get the estimated time the request was being transferred by the handler. - * - * @return float Time in seconds. - */ - public function getTransferTime() - { - return $this->transferTime; - } - - /** - * Gets an array of all of the handler specific transfer data. - * - * @return array - */ - public function getHandlerStats() - { - return $this->handlerStats; - } - - /** - * Get a specific handler statistic from the handler by name. - * - * @param string $stat Handler specific transfer stat to retrieve. - * - * @return mixed|null - */ - public function getHandlerStat($stat) - { - return isset($this->handlerStats[$stat]) - ? $this->handlerStats[$stat] - : null; - } -} diff --git a/vendor/guzzlehttp/guzzle/src/UriTemplate.php b/vendor/guzzlehttp/guzzle/src/UriTemplate.php deleted file mode 100644 index 0b1623eca..000000000 --- a/vendor/guzzlehttp/guzzle/src/UriTemplate.php +++ /dev/null @@ -1,241 +0,0 @@ - ['prefix' => '', 'joiner' => ',', 'query' => false], - '+' => ['prefix' => '', 'joiner' => ',', 'query' => false], - '#' => ['prefix' => '#', 'joiner' => ',', 'query' => false], - '.' => ['prefix' => '.', 'joiner' => '.', 'query' => false], - '/' => ['prefix' => '/', 'joiner' => '/', 'query' => false], - ';' => ['prefix' => ';', 'joiner' => ';', 'query' => true], - '?' => ['prefix' => '?', 'joiner' => '&', 'query' => true], - '&' => ['prefix' => '&', 'joiner' => '&', 'query' => true] - ]; - - /** @var array Delimiters */ - private static $delims = [':', '/', '?', '#', '[', ']', '@', '!', '$', - '&', '\'', '(', ')', '*', '+', ',', ';', '=']; - - /** @var array Percent encoded delimiters */ - private static $delimsPct = ['%3A', '%2F', '%3F', '%23', '%5B', '%5D', - '%40', '%21', '%24', '%26', '%27', '%28', '%29', '%2A', '%2B', '%2C', - '%3B', '%3D']; - - public function expand($template, array $variables) - { - if (false === strpos($template, '{')) { - return $template; - } - - $this->template = $template; - $this->variables = $variables; - - return preg_replace_callback( - '/\{([^\}]+)\}/', - [$this, 'expandMatch'], - $this->template - ); - } - - /** - * Parse an expression into parts - * - * @param string $expression Expression to parse - * - * @return array Returns an associative array of parts - */ - private function parseExpression($expression) - { - $result = []; - - if (isset(self::$operatorHash[$expression[0]])) { - $result['operator'] = $expression[0]; - $expression = substr($expression, 1); - } else { - $result['operator'] = ''; - } - - foreach (explode(',', $expression) as $value) { - $value = trim($value); - $varspec = []; - if ($colonPos = strpos($value, ':')) { - $varspec['value'] = substr($value, 0, $colonPos); - $varspec['modifier'] = ':'; - $varspec['position'] = (int) substr($value, $colonPos + 1); - } elseif (substr($value, -1) === '*') { - $varspec['modifier'] = '*'; - $varspec['value'] = substr($value, 0, -1); - } else { - $varspec['value'] = (string) $value; - $varspec['modifier'] = ''; - } - $result['values'][] = $varspec; - } - - return $result; - } - - /** - * Process an expansion - * - * @param array $matches Matches met in the preg_replace_callback - * - * @return string Returns the replacement string - */ - private function expandMatch(array $matches) - { - static $rfc1738to3986 = ['+' => '%20', '%7e' => '~']; - - $replacements = []; - $parsed = self::parseExpression($matches[1]); - $prefix = self::$operatorHash[$parsed['operator']]['prefix']; - $joiner = self::$operatorHash[$parsed['operator']]['joiner']; - $useQuery = self::$operatorHash[$parsed['operator']]['query']; - - foreach ($parsed['values'] as $value) { - - if (!isset($this->variables[$value['value']])) { - continue; - } - - $variable = $this->variables[$value['value']]; - $actuallyUseQuery = $useQuery; - $expanded = ''; - - if (is_array($variable)) { - - $isAssoc = $this->isAssoc($variable); - $kvp = []; - foreach ($variable as $key => $var) { - - if ($isAssoc) { - $key = rawurlencode($key); - $isNestedArray = is_array($var); - } else { - $isNestedArray = false; - } - - if (!$isNestedArray) { - $var = rawurlencode($var); - if ($parsed['operator'] === '+' || - $parsed['operator'] === '#' - ) { - $var = $this->decodeReserved($var); - } - } - - if ($value['modifier'] === '*') { - if ($isAssoc) { - if ($isNestedArray) { - // Nested arrays must allow for deeply nested - // structures. - $var = strtr( - http_build_query([$key => $var]), - $rfc1738to3986 - ); - } else { - $var = $key . '=' . $var; - } - } elseif ($key > 0 && $actuallyUseQuery) { - $var = $value['value'] . '=' . $var; - } - } - - $kvp[$key] = $var; - } - - if (empty($variable)) { - $actuallyUseQuery = false; - } elseif ($value['modifier'] === '*') { - $expanded = implode($joiner, $kvp); - if ($isAssoc) { - // Don't prepend the value name when using the explode - // modifier with an associative array. - $actuallyUseQuery = false; - } - } else { - if ($isAssoc) { - // When an associative array is encountered and the - // explode modifier is not set, then the result must be - // a comma separated list of keys followed by their - // respective values. - foreach ($kvp as $k => &$v) { - $v = $k . ',' . $v; - } - } - $expanded = implode(',', $kvp); - } - - } else { - if ($value['modifier'] === ':') { - $variable = substr($variable, 0, $value['position']); - } - $expanded = rawurlencode($variable); - if ($parsed['operator'] === '+' || $parsed['operator'] === '#') { - $expanded = $this->decodeReserved($expanded); - } - } - - if ($actuallyUseQuery) { - if (!$expanded && $joiner !== '&') { - $expanded = $value['value']; - } else { - $expanded = $value['value'] . '=' . $expanded; - } - } - - $replacements[] = $expanded; - } - - $ret = implode($joiner, $replacements); - if ($ret && $prefix) { - return $prefix . $ret; - } - - return $ret; - } - - /** - * Determines if an array is associative. - * - * This makes the assumption that input arrays are sequences or hashes. - * This assumption is a tradeoff for accuracy in favor of speed, but it - * should work in almost every case where input is supplied for a URI - * template. - * - * @param array $array Array to check - * - * @return bool - */ - private function isAssoc(array $array) - { - return $array && array_keys($array)[0] !== 0; - } - - /** - * Removes percent encoding on reserved characters (used with + and # - * modifiers). - * - * @param string $string String to fix - * - * @return string - */ - private function decodeReserved($string) - { - return str_replace(self::$delimsPct, self::$delims, $string); - } -} diff --git a/vendor/guzzlehttp/guzzle/src/functions.php b/vendor/guzzlehttp/guzzle/src/functions.php deleted file mode 100644 index 85cf9c641..000000000 --- a/vendor/guzzlehttp/guzzle/src/functions.php +++ /dev/null @@ -1,329 +0,0 @@ -expand($template, $variables); -} - -/** - * Debug function used to describe the provided value type and class. - * - * @param mixed $input - * - * @return string Returns a string containing the type of the variable and - * if a class is provided, the class name. - */ -function describe_type($input) -{ - switch (gettype($input)) { - case 'object': - return 'object(' . get_class($input) . ')'; - case 'array': - return 'array(' . count($input) . ')'; - default: - ob_start(); - var_dump($input); - // normalize float vs double - return str_replace('double(', 'float(', rtrim(ob_get_clean())); - } -} - -/** - * Parses an array of header lines into an associative array of headers. - * - * @param array $lines Header lines array of strings in the following - * format: "Name: Value" - * @return array - */ -function headers_from_lines($lines) -{ - $headers = []; - - foreach ($lines as $line) { - $parts = explode(':', $line, 2); - $headers[trim($parts[0])][] = isset($parts[1]) - ? trim($parts[1]) - : null; - } - - return $headers; -} - -/** - * Returns a debug stream based on the provided variable. - * - * @param mixed $value Optional value - * - * @return resource - */ -function debug_resource($value = null) -{ - if (is_resource($value)) { - return $value; - } elseif (defined('STDOUT')) { - return STDOUT; - } - - return fopen('php://output', 'w'); -} - -/** - * Chooses and creates a default handler to use based on the environment. - * - * The returned handler is not wrapped by any default middlewares. - * - * @throws \RuntimeException if no viable Handler is available. - * @return callable Returns the best handler for the given system. - */ -function choose_handler() -{ - $handler = null; - if (function_exists('curl_multi_exec') && function_exists('curl_exec')) { - $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler()); - } elseif (function_exists('curl_exec')) { - $handler = new CurlHandler(); - } elseif (function_exists('curl_multi_exec')) { - $handler = new CurlMultiHandler(); - } - - if (ini_get('allow_url_fopen')) { - $handler = $handler - ? Proxy::wrapStreaming($handler, new StreamHandler()) - : new StreamHandler(); - } elseif (!$handler) { - throw new \RuntimeException('GuzzleHttp requires cURL, the ' - . 'allow_url_fopen ini setting, or a custom HTTP handler.'); - } - - return $handler; -} - -/** - * Get the default User-Agent string to use with Guzzle - * - * @return string - */ -function default_user_agent() -{ - static $defaultAgent = ''; - - if (!$defaultAgent) { - $defaultAgent = 'GuzzleHttp/' . Client::VERSION; - if (extension_loaded('curl') && function_exists('curl_version')) { - $defaultAgent .= ' curl/' . \curl_version()['version']; - } - $defaultAgent .= ' PHP/' . PHP_VERSION; - } - - return $defaultAgent; -} - -/** - * Returns the default cacert bundle for the current system. - * - * First, the openssl.cafile and curl.cainfo php.ini settings are checked. - * If those settings are not configured, then the common locations for - * bundles found on Red Hat, CentOS, Fedora, Ubuntu, Debian, FreeBSD, OS X - * and Windows are checked. If any of these file locations are found on - * disk, they will be utilized. - * - * Note: the result of this function is cached for subsequent calls. - * - * @return string - * @throws \RuntimeException if no bundle can be found. - */ -function default_ca_bundle() -{ - static $cached = null; - static $cafiles = [ - // Red Hat, CentOS, Fedora (provided by the ca-certificates package) - '/etc/pki/tls/certs/ca-bundle.crt', - // Ubuntu, Debian (provided by the ca-certificates package) - '/etc/ssl/certs/ca-certificates.crt', - // FreeBSD (provided by the ca_root_nss package) - '/usr/local/share/certs/ca-root-nss.crt', - // OS X provided by homebrew (using the default path) - '/usr/local/etc/openssl/cert.pem', - // Google app engine - '/etc/ca-certificates.crt', - // Windows? - 'C:\\windows\\system32\\curl-ca-bundle.crt', - 'C:\\windows\\curl-ca-bundle.crt', - ]; - - if ($cached) { - return $cached; - } - - if ($ca = ini_get('openssl.cafile')) { - return $cached = $ca; - } - - if ($ca = ini_get('curl.cainfo')) { - return $cached = $ca; - } - - foreach ($cafiles as $filename) { - if (file_exists($filename)) { - return $cached = $filename; - } - } - - throw new \RuntimeException(<<< EOT -No system CA bundle could be found in any of the the common system locations. -PHP versions earlier than 5.6 are not properly configured to use the system's -CA bundle by default. In order to verify peer certificates, you will need to -supply the path on disk to a certificate bundle to the 'verify' request -option: http://docs.guzzlephp.org/en/latest/clients.html#verify. If you do not -need a specific certificate bundle, then Mozilla provides a commonly used CA -bundle which can be downloaded here (provided by the maintainer of cURL): -https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt. Once -you have a CA bundle available on disk, you can set the 'openssl.cafile' PHP -ini setting to point to the path to the file, allowing you to omit the 'verify' -request option. See http://curl.haxx.se/docs/sslcerts.html for more -information. -EOT - ); -} - -/** - * Creates an associative array of lowercase header names to the actual - * header casing. - * - * @param array $headers - * - * @return array - */ -function normalize_header_keys(array $headers) -{ - $result = []; - foreach (array_keys($headers) as $key) { - $result[strtolower($key)] = $key; - } - - return $result; -} - -/** - * Returns true if the provided host matches any of the no proxy areas. - * - * This method will strip a port from the host if it is present. Each pattern - * can be matched with an exact match (e.g., "foo.com" == "foo.com") or a - * partial match: (e.g., "foo.com" == "baz.foo.com" and ".foo.com" == - * "baz.foo.com", but ".foo.com" != "foo.com"). - * - * Areas are matched in the following cases: - * 1. "*" (without quotes) always matches any hosts. - * 2. An exact match. - * 3. The area starts with "." and the area is the last part of the host. e.g. - * '.mit.edu' will match any host that ends with '.mit.edu'. - * - * @param string $host Host to check against the patterns. - * @param array $noProxyArray An array of host patterns. - * - * @return bool - */ -function is_host_in_noproxy($host, array $noProxyArray) -{ - if (strlen($host) === 0) { - throw new \InvalidArgumentException('Empty host provided'); - } - - // Strip port if present. - if (strpos($host, ':')) { - $host = explode($host, ':', 2)[0]; - } - - foreach ($noProxyArray as $area) { - // Always match on wildcards. - if ($area === '*') { - return true; - } elseif (empty($area)) { - // Don't match on empty values. - continue; - } elseif ($area === $host) { - // Exact matches. - return true; - } else { - // Special match if the area when prefixed with ".". Remove any - // existing leading "." and add a new leading ".". - $area = '.' . ltrim($area, '.'); - if (substr($host, -(strlen($area))) === $area) { - return true; - } - } - } - - return false; -} - -/** - * Wrapper for json_decode that throws when an error occurs. - * - * @param string $json JSON data to parse - * @param bool $assoc When true, returned objects will be converted - * into associative arrays. - * @param int $depth User specified recursion depth. - * @param int $options Bitmask of JSON decode options. - * - * @return mixed - * @throws \InvalidArgumentException if the JSON cannot be decoded. - * @link http://www.php.net/manual/en/function.json-decode.php - */ -function json_decode($json, $assoc = false, $depth = 512, $options = 0) -{ - $data = \json_decode($json, $assoc, $depth, $options); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException( - 'json_decode error: ' . json_last_error_msg()); - } - - return $data; -} - -/** - * Wrapper for JSON encoding that throws when an error occurs. - * - * @param mixed $value The value being encoded - * @param int $options JSON encode option bitmask - * @param int $depth Set the maximum depth. Must be greater than zero. - * - * @return string - * @throws \InvalidArgumentException if the JSON cannot be encoded. - * @link http://www.php.net/manual/en/function.json-encode.php - */ -function json_encode($value, $options = 0, $depth = 512) -{ - $json = \json_encode($value, $options, $depth); - if (JSON_ERROR_NONE !== json_last_error()) { - throw new \InvalidArgumentException( - 'json_encode error: ' . json_last_error_msg()); - } - - return $json; -} diff --git a/vendor/guzzlehttp/guzzle/src/functions_include.php b/vendor/guzzlehttp/guzzle/src/functions_include.php deleted file mode 100644 index a93393acc..000000000 --- a/vendor/guzzlehttp/guzzle/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ - - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/guzzlehttp/promises/Makefile b/vendor/guzzlehttp/promises/Makefile deleted file mode 100644 index 8d5b3ef95..000000000 --- a/vendor/guzzlehttp/promises/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -all: clean test - -test: - vendor/bin/phpunit - -coverage: - vendor/bin/phpunit --coverage-html=artifacts/coverage - -view-coverage: - open artifacts/coverage/index.html - -clean: - rm -rf artifacts/* diff --git a/vendor/guzzlehttp/promises/README.md b/vendor/guzzlehttp/promises/README.md deleted file mode 100644 index c6780abd2..000000000 --- a/vendor/guzzlehttp/promises/README.md +++ /dev/null @@ -1,501 +0,0 @@ -# Guzzle Promises - -[Promises/A+](https://promisesaplus.com/) implementation that handles promise -chaining and resolution iteratively, allowing for "infinite" promise chaining -while keeping the stack size constant. Read [this blog post](https://blog.domenic.me/youre-missing-the-point-of-promises/) -for a general introduction to promises. - -- [Features](#features) -- [Quick start](#quick-start) -- [Synchronous wait](#synchronous-wait) -- [Cancellation](#cancellation) -- [API](#api) - - [Promise](#promise) - - [FulfilledPromise](#fulfilledpromise) - - [RejectedPromise](#rejectedpromise) -- [Promise interop](#promise-interop) -- [Implementation notes](#implementation-notes) - - -# Features - -- [Promises/A+](https://promisesaplus.com/) implementation. -- Promise resolution and chaining is handled iteratively, allowing for - "infinite" promise chaining. -- Promises have a synchronous `wait` method. -- Promises can be cancelled. -- Works with any object that has a `then` function. -- C# style async/await coroutine promises using - `GuzzleHttp\Promise\coroutine()`. - - -# Quick start - -A *promise* represents the eventual result of an asynchronous operation. The -primary way of interacting with a promise is through its `then` method, which -registers callbacks to receive either a promise's eventual value or the reason -why the promise cannot be fulfilled. - - -## Callbacks - -Callbacks are registered with the `then` method by providing an optional -`$onFulfilled` followed by an optional `$onRejected` function. - - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$promise->then( - // $onFulfilled - function ($value) { - echo 'The promise was fulfilled.'; - }, - // $onRejected - function ($reason) { - echo 'The promise was rejected.'; - } -); -``` - -*Resolving* a promise means that you either fulfill a promise with a *value* or -reject a promise with a *reason*. Resolving a promises triggers callbacks -registered with the promises's `then` method. These callbacks are triggered -only once and in the order in which they were added. - - -## Resolving a promise - -Promises are fulfilled using the `resolve($value)` method. Resolving a promise -with any value other than a `GuzzleHttp\Promise\RejectedPromise` will trigger -all of the onFulfilled callbacks (resolving a promise with a rejected promise -will reject the promise and trigger the `$onRejected` callbacks). - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$promise - ->then(function ($value) { - // Return a value and don't break the chain - return "Hello, " . $value; - }) - // This then is executed after the first then and receives the value - // returned from the first then. - ->then(function ($value) { - echo $value; - }); - -// Resolving the promise triggers the $onFulfilled callbacks and outputs -// "Hello, reader". -$promise->resolve('reader.'); -``` - - -## Promise forwarding - -Promises can be chained one after the other. Each then in the chain is a new -promise. The return value of of a promise is what's forwarded to the next -promise in the chain. Returning a promise in a `then` callback will cause the -subsequent promises in the chain to only be fulfilled when the returned promise -has been fulfilled. The next promise in the chain will be invoked with the -resolved value of the promise. - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$nextPromise = new Promise(); - -$promise - ->then(function ($value) use ($nextPromise) { - echo $value; - return $nextPromise; - }) - ->then(function ($value) { - echo $value; - }); - -// Triggers the first callback and outputs "A" -$promise->resolve('A'); -// Triggers the second callback and outputs "B" -$nextPromise->resolve('B'); -``` - -## Promise rejection - -When a promise is rejected, the `$onRejected` callbacks are invoked with the -rejection reason. - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$promise->then(null, function ($reason) { - echo $reason; -}); - -$promise->reject('Error!'); -// Outputs "Error!" -``` - -## Rejection forwarding - -If an exception is thrown in an `$onRejected` callback, subsequent -`$onRejected` callbacks are invoked with the thrown exception as the reason. - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise(); -$promise->then(null, function ($reason) { - throw new \Exception($reason); -})->then(null, function ($reason) { - assert($reason->getMessage() === 'Error!'); -}); - -$promise->reject('Error!'); -``` - -You can also forward a rejection down the promise chain by returning a -`GuzzleHttp\Promise\RejectedPromise` in either an `$onFulfilled` or -`$onRejected` callback. - -```php -use GuzzleHttp\Promise\Promise; -use GuzzleHttp\Promise\RejectedPromise; - -$promise = new Promise(); -$promise->then(null, function ($reason) { - return new RejectedPromise($reason); -})->then(null, function ($reason) { - assert($reason === 'Error!'); -}); - -$promise->reject('Error!'); -``` - -If an exception is not thrown in a `$onRejected` callback and the callback -does not return a rejected promise, downstream `$onFulfilled` callbacks are -invoked using the value returned from the `$onRejected` callback. - -```php -use GuzzleHttp\Promise\Promise; -use GuzzleHttp\Promise\RejectedPromise; - -$promise = new Promise(); -$promise - ->then(null, function ($reason) { - return "It's ok"; - }) - ->then(function ($value) { - assert($value === "It's ok"); - }); - -$promise->reject('Error!'); -``` - -# Synchronous wait - -You can synchronously force promises to complete using a promise's `wait` -method. When creating a promise, you can provide a wait function that is used -to synchronously force a promise to complete. When a wait function is invoked -it is expected to deliver a value to the promise or reject the promise. If the -wait function does not deliver a value, then an exception is thrown. The wait -function provided to a promise constructor is invoked when the `wait` function -of the promise is called. - -```php -$promise = new Promise(function () use (&$promise) { - $promise->deliver('foo'); -}); - -// Calling wait will return the value of the promise. -echo $promise->wait(); // outputs "foo" -``` - -If an exception is encountered while invoking the wait function of a promise, -the promise is rejected with the exception and the exception is thrown. - -```php -$promise = new Promise(function () use (&$promise) { - throw new \Exception('foo'); -}); - -$promise->wait(); // throws the exception. -``` - -Calling `wait` on a promise that has been fulfilled will not trigger the wait -function. It will simply return the previously delivered value. - -```php -$promise = new Promise(function () { die('this is not called!'); }); -$promise->deliver('foo'); -echo $promise->wait(); // outputs "foo" -``` - -Calling `wait` on a promise that has been rejected will throw an exception. If -the rejection reason is an instance of `\Exception` the reason is thrown. -Otherwise, a `GuzzleHttp\Promise\RejectionException` is thrown and the reason -can be obtained by calling the `getReason` method of the exception. - -```php -$promise = new Promise(); -$promise->reject('foo'); -$promise->wait(); -``` - -> PHP Fatal error: Uncaught exception 'GuzzleHttp\Promise\RejectionException' with message 'The promise was rejected with value: foo' - - -## Unwrapping a promise - -When synchronously waiting on a promise, you are joining the state of the -promise into the current state of execution (i.e., return the value of the -promise if it was fulfilled or throw an exception if it was rejected). This is -called "unwrapping" the promise. Waiting on a promise will by default unwrap -the promise state. - -You can force a promise to resolve and *not* unwrap the state of the promise -by passing `false` to the first argument of the `wait` function: - -```php -$promise = new Promise(); -$promise->reject('foo'); -// This will not throw an exception. It simply ensures the promise has -// been resolved. -$promise->wait(false); -``` - -When unwrapping a promise, the delivered value of the promise will be waited -upon until the unwrapped value is not a promise. This means that if you resolve -promise A with a promise B and unwrap promise A, the value returned by the -wait function will be the value delivered to promise B. - -**Note**: when you do not unwrap the promise, no value is returned. - - -# Cancellation - -You can cancel a promise that has not yet been fulfilled using the `cancel()` -method of a promise. When creating a promise you can provide an optional -cancel function that when invoked cancels the action of computing a resolution -of the promise. - - -# API - - -## Promise - -When creating a promise object, you can provide an optional `$waitFn` and -`$cancelFn`. `$waitFn` is a function that is invoked with no arguments and is -expected to resolve the promise. `$cancelFn` is a function with no arguments -that is expected to cancel the computation of a promise. It is invoked when the -`cancel()` method of a promise is called. - -```php -use GuzzleHttp\Promise\Promise; - -$promise = new Promise( - function () use (&$promise) { - $promise->resolve('waited'); - }, - function () { - // do something that will cancel the promise computation (e.g., close - // a socket, cancel a database query, etc...) - } -); - -assert('waited' === $promise->wait()); -``` - -A promise has the following methods: - -- `then(callable $onFulfilled, callable $onRejected) : PromiseInterface` - - Creates a new promise that is fulfilled or rejected when the promise is - resolved. - -- `wait($unwrap = true) : mixed` - - Synchronously waits on the promise to complete. - - `$unwrap` controls whether or not the value of the promise is returned for a - fulfilled promise or if an exception is thrown if the promise is rejected. - This is set to `true` by default. - -- `cancel()` - - Attempts to cancel the promise if possible. The promise being cancelled and - the parent most ancestor that has not yet been resolved will also be - cancelled. Any promises waiting on the cancelled promise to resolve will also - be cancelled. - -- `getState() : string` - - Returns the state of the promise. One of `pending`, `fulfilled`, or - `rejected`. - -- `resolve($value)` - - Fulfills the promise with the given `$value`. - -- `reject($reason)` - - Rejects the promise with the given `$reason`. - - -## FulfilledPromise - -A fulfilled promise can be created to represent a promise that has been -fulfilled. - -```php -use GuzzleHttp\Promise\FulfilledPromise; - -$promise = new FulfilledPromise('value'); - -// Fulfilled callbacks are immediately invoked. -$promise->then(function ($value) { - echo $value; -}); -``` - - -## RejectedPromise - -A rejected promise can be created to represent a promise that has been -rejected. - -```php -use GuzzleHttp\Promise\RejectedPromise; - -$promise = new RejectedPromise('Error'); - -// Rejected callbacks are immediately invoked. -$promise->then(null, function ($reason) { - echo $reason; -}); -``` - - -# Promise interop - -This library works with foreign promises that have a `then` method. This means -you can use Guzzle promises with [React promises](https://github.com/reactphp/promise) -for example. When a foreign promise is returned inside of a then method -callback, promise resolution will occur recursively. - -```php -// Create a React promise -$deferred = new React\Promise\Deferred(); -$reactPromise = $deferred->promise(); - -// Create a Guzzle promise that is fulfilled with a React promise. -$guzzlePromise = new \GuzzleHttp\Promise\Promise(); -$guzzlePromise->then(function ($value) use ($reactPromise) { - // Do something something with the value... - // Return the React promise - return $reactPromise; -}); -``` - -Please note that wait and cancel chaining is no longer possible when forwarding -a foreign promise. You will need to wrap a third-party promise with a Guzzle -promise in order to utilize wait and cancel functions with foreign promises. - - -## Event Loop Integration - -In order to keep the stack size constant, Guzzle promises are resolved -asynchronously using a task queue. When waiting on promises synchronously, the -task queue will be automatically run to ensure that the blocking promise and -any forwarded promises are resolved. When using promises asynchronously in an -event loop, you will need to run the task queue on each tick of the loop. If -you do not run the task queue, then promises will not be resolved. - -You can run the task queue using the `run()` method of the global task queue -instance. - -```php -// Get the global task queue -$queue = \GuzzleHttp\Promise\queue(); -$queue->run(); -``` - -For example, you could use Guzzle promises with React using a periodic timer: - -```php -$loop = React\EventLoop\Factory::create(); -$loop->addPeriodicTimer(0, [$queue, 'run']); -``` - -*TODO*: Perhaps adding a `futureTick()` on each tick would be faster? - - -# Implementation notes - - -## Promise resolution and chaining is handled iteratively - -By shuffling pending handlers from one owner to another, promises are -resolved iteratively, allowing for "infinite" then chaining. - -```php -then(function ($v) { - // The stack size remains constant (a good thing) - echo xdebug_get_stack_depth() . ', '; - return $v + 1; - }); -} - -$parent->resolve(0); -var_dump($p->wait()); // int(1000) - -``` - -When a promise is fulfilled or rejected with a non-promise value, the promise -then takes ownership of the handlers of each child promise and delivers values -down the chain without using recursion. - -When a promise is resolved with another promise, the original promise transfers -all of its pending handlers to the new promise. When the new promise is -eventually resolved, all of the pending handlers are delivered the forwarded -value. - - -## A promise is the deferred. - -Some promise libraries implement promises using a deferred object to represent -a computation and a promise object to represent the delivery of the result of -the computation. This is a nice separation of computation and delivery because -consumers of the promise cannot modify the value that will be eventually -delivered. - -One side effect of being able to implement promise resolution and chaining -iteratively is that you need to be able for one promise to reach into the state -of another promise to shuffle around ownership of handlers. In order to achieve -this without making the handlers of a promise publicly mutable, a promise is -also the deferred value, allowing promises of the same parent class to reach -into and modify the private properties of promises of the same type. While this -does allow consumers of the value to modify the resolution or rejection of the -deferred, it is a small price to pay for keeping the stack size constant. - -```php -$promise = new Promise(); -$promise->then(function ($value) { echo $value; }); -// The promise is the deferred value, so you can deliver a value to it. -$promise->deliver('foo'); -// prints "foo" -``` diff --git a/vendor/guzzlehttp/promises/composer.json b/vendor/guzzlehttp/promises/composer.json deleted file mode 100644 index f13844b63..000000000 --- a/vendor/guzzlehttp/promises/composer.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "guzzlehttp/promises", - "type": "library", - "description": "Guzzle promises library", - "keywords": ["promise"], - "license": "MIT", - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "require": { - "php": ">=5.5.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Promise\\": "src/" - }, - "files": ["src/functions_include.php"] - }, - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - } -} diff --git a/vendor/guzzlehttp/promises/phpunit.xml.dist b/vendor/guzzlehttp/promises/phpunit.xml.dist deleted file mode 100644 index 500cd53a0..000000000 --- a/vendor/guzzlehttp/promises/phpunit.xml.dist +++ /dev/null @@ -1,17 +0,0 @@ - - - - - tests - - - - - src - - src/ - - - - diff --git a/vendor/guzzlehttp/promises/src/AggregateException.php b/vendor/guzzlehttp/promises/src/AggregateException.php deleted file mode 100644 index 6a5690c37..000000000 --- a/vendor/guzzlehttp/promises/src/AggregateException.php +++ /dev/null @@ -1,16 +0,0 @@ -iterable = iter_for($iterable); - - if (isset($config['concurrency'])) { - $this->concurrency = $config['concurrency']; - } - - if (isset($config['fulfilled'])) { - $this->onFulfilled = $config['fulfilled']; - } - - if (isset($config['rejected'])) { - $this->onRejected = $config['rejected']; - } - } - - public function promise() - { - if ($this->aggregate) { - return $this->aggregate; - } - - try { - $this->createPromise(); - $this->iterable->rewind(); - $this->refillPending(); - } catch (\Exception $e) { - $this->aggregate->reject($e); - } - - return $this->aggregate; - } - - private function createPromise() - { - $this->aggregate = new Promise(function () { - reset($this->pending); - if (empty($this->pending) && !$this->iterable->valid()) { - $this->aggregate->resolve(null); - return; - } - - // Consume a potentially fluctuating list of promises while - // ensuring that indexes are maintained (precluding array_shift). - while ($promise = current($this->pending)) { - next($this->pending); - $promise->wait(); - if ($this->aggregate->getState() !== PromiseInterface::PENDING) { - return; - } - } - }); - - // Clear the references when the promise is resolved. - $clearFn = function () { - $this->iterable = $this->concurrency = $this->pending = null; - $this->onFulfilled = $this->onRejected = null; - }; - - $this->aggregate->then($clearFn, $clearFn); - } - - private function refillPending() - { - if (!$this->concurrency) { - // Add all pending promises. - while ($this->addPending() && $this->advanceIterator()); - return; - } - - // Add only up to N pending promises. - $concurrency = is_callable($this->concurrency) - ? call_user_func($this->concurrency, count($this->pending)) - : $this->concurrency; - $concurrency = max($concurrency - count($this->pending), 0); - // Concurrency may be set to 0 to disallow new promises. - if (!$concurrency) { - return; - } - // Add the first pending promise. - $this->addPending(); - // Note this is special handling for concurrency=1 so that we do - // not advance the iterator after adding the first promise. This - // helps work around issues with generators that might not have the - // next value to yield until promise callbacks are called. - while (--$concurrency - && $this->advanceIterator() - && $this->addPending()); - } - - private function addPending() - { - if (!$this->iterable || !$this->iterable->valid()) { - return false; - } - - $promise = promise_for($this->iterable->current()); - $idx = $this->iterable->key(); - - $this->pending[$idx] = $promise->then( - function ($value) use ($idx) { - if ($this->onFulfilled) { - call_user_func( - $this->onFulfilled, $value, $idx, $this->aggregate - ); - } - $this->step($idx); - }, - function ($reason) use ($idx) { - if ($this->onRejected) { - call_user_func( - $this->onRejected, $reason, $idx, $this->aggregate - ); - } - $this->step($idx); - } - ); - - return true; - } - - private function advanceIterator() - { - try { - $this->iterable->next(); - return true; - } catch (\Exception $e) { - $this->aggregate->reject($e); - return false; - } - } - - private function step($idx) - { - // If the promise was already resolved, then ignore this step. - if ($this->aggregate->getState() !== PromiseInterface::PENDING) { - return; - } - - unset($this->pending[$idx]); - $this->advanceIterator(); - - if (!$this->checkIfFinished()) { - // Add more pending promises if possible. - $this->refillPending(); - } - } - - private function checkIfFinished() - { - if (!$this->pending && !$this->iterable->valid()) { - // Resolve the promise if there's nothing left to do. - $this->aggregate->resolve(null); - return true; - } - - return false; - } -} diff --git a/vendor/guzzlehttp/promises/src/FulfilledPromise.php b/vendor/guzzlehttp/promises/src/FulfilledPromise.php deleted file mode 100644 index 559629653..000000000 --- a/vendor/guzzlehttp/promises/src/FulfilledPromise.php +++ /dev/null @@ -1,80 +0,0 @@ -value = $value; - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null - ) { - // Return itself if there is no onFulfilled function. - if (!$onFulfilled) { - return $this; - } - - $queue = queue(); - $p = new Promise([$queue, 'run']); - $value = $this->value; - $queue->add(static function () use ($p, $value, $onFulfilled) { - if ($p->getState() === self::PENDING) { - try { - $p->resolve($onFulfilled($value)); - } catch (\Exception $e) { - $p->reject($e); - } - } - }); - - return $p; - } - - public function otherwise(callable $onRejected) - { - return $this->then(null, $onRejected); - } - - public function wait($unwrap = true, $defaultDelivery = null) - { - return $unwrap ? $this->value : null; - } - - public function getState() - { - return self::FULFILLED; - } - - public function resolve($value) - { - if ($value !== $this->value) { - throw new \LogicException("Cannot resolve a fulfilled promise"); - } - } - - public function reject($reason) - { - throw new \LogicException("Cannot reject a fulfilled promise"); - } - - public function cancel() - { - // pass - } -} diff --git a/vendor/guzzlehttp/promises/src/Promise.php b/vendor/guzzlehttp/promises/src/Promise.php deleted file mode 100644 index c2cf969da..000000000 --- a/vendor/guzzlehttp/promises/src/Promise.php +++ /dev/null @@ -1,268 +0,0 @@ -waitFn = $waitFn; - $this->cancelFn = $cancelFn; - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null - ) { - if ($this->state === self::PENDING) { - $p = new Promise(null, [$this, 'cancel']); - $this->handlers[] = [$p, $onFulfilled, $onRejected]; - $p->waitList = $this->waitList; - $p->waitList[] = $this; - return $p; - } - - // Return a fulfilled promise and immediately invoke any callbacks. - if ($this->state === self::FULFILLED) { - return $onFulfilled - ? promise_for($this->result)->then($onFulfilled) - : promise_for($this->result); - } - - // It's either cancelled or rejected, so return a rejected promise - // and immediately invoke any callbacks. - $rejection = rejection_for($this->result); - return $onRejected ? $rejection->then(null, $onRejected) : $rejection; - } - - public function otherwise(callable $onRejected) - { - return $this->then(null, $onRejected); - } - - public function wait($unwrap = true) - { - $this->waitIfPending(); - - if (!$unwrap) { - return null; - } - - if ($this->result instanceof PromiseInterface) { - return $this->result->wait($unwrap); - } elseif ($this->state === self::FULFILLED) { - return $this->result; - } else { - // It's rejected so "unwrap" and throw an exception. - throw exception_for($this->result); - } - } - - public function getState() - { - return $this->state; - } - - public function cancel() - { - if ($this->state !== self::PENDING) { - return; - } - - $this->waitFn = $this->waitList = null; - - if ($this->cancelFn) { - $fn = $this->cancelFn; - $this->cancelFn = null; - try { - $fn(); - } catch (\Exception $e) { - $this->reject($e); - } - } - - // Reject the promise only if it wasn't rejected in a then callback. - if ($this->state === self::PENDING) { - $this->reject(new CancellationException('Promise has been cancelled')); - } - } - - public function resolve($value) - { - $this->settle(self::FULFILLED, $value); - } - - public function reject($reason) - { - $this->settle(self::REJECTED, $reason); - } - - private function settle($state, $value) - { - if ($this->state !== self::PENDING) { - // Ignore calls with the same resolution. - if ($state === $this->state && $value === $this->result) { - return; - } - throw $this->state === $state - ? new \LogicException("The promise is already {$state}.") - : new \LogicException("Cannot change a {$this->state} promise to {$state}"); - } - - if ($value === $this) { - throw new \LogicException('Cannot fulfill or reject a promise with itself'); - } - - // Clear out the state of the promise but stash the handlers. - $this->state = $state; - $this->result = $value; - $handlers = $this->handlers; - $this->handlers = null; - $this->waitList = $this->waitFn = null; - $this->cancelFn = null; - - if (!$handlers) { - return; - } - - // If the value was not a settled promise or a thenable, then resolve - // it in the task queue using the correct ID. - if (!method_exists($value, 'then')) { - $id = $state === self::FULFILLED ? 1 : 2; - // It's a success, so resolve the handlers in the queue. - queue()->add(static function () use ($id, $value, $handlers) { - foreach ($handlers as $handler) { - self::callHandler($id, $value, $handler); - } - }); - } elseif ($value instanceof Promise - && $value->getState() === self::PENDING - ) { - // We can just merge our handlers onto the next promise. - $value->handlers = array_merge($value->handlers, $handlers); - } else { - // Resolve the handlers when the forwarded promise is resolved. - $value->then( - static function ($value) use ($handlers) { - foreach ($handlers as $handler) { - self::callHandler(1, $value, $handler); - } - }, - static function ($reason) use ($handlers) { - foreach ($handlers as $handler) { - self::callHandler(2, $reason, $handler); - } - } - ); - } - } - - /** - * Call a stack of handlers using a specific callback index and value. - * - * @param int $index 1 (resolve) or 2 (reject). - * @param mixed $value Value to pass to the callback. - * @param array $handler Array of handler data (promise and callbacks). - * - * @return array Returns the next group to resolve. - */ - private static function callHandler($index, $value, array $handler) - { - /** @var PromiseInterface $promise */ - $promise = $handler[0]; - - // The promise may have been cancelled or resolved before placing - // this thunk in the queue. - if ($promise->getState() !== self::PENDING) { - return; - } - - try { - if (isset($handler[$index])) { - $promise->resolve($handler[$index]($value)); - } elseif ($index === 1) { - // Forward resolution values as-is. - $promise->resolve($value); - } else { - // Forward rejections down the chain. - $promise->reject($value); - } - } catch (\Exception $reason) { - $promise->reject($reason); - } - } - - private function waitIfPending() - { - if ($this->state !== self::PENDING) { - return; - } elseif ($this->waitFn) { - $this->invokeWaitFn(); - } elseif ($this->waitList) { - $this->invokeWaitList(); - } else { - // If there's not wait function, then reject the promise. - $this->reject('Cannot wait on a promise that has ' - . 'no internal wait function. You must provide a wait ' - . 'function when constructing the promise to be able to ' - . 'wait on a promise.'); - } - - queue()->run(); - - if ($this->state === self::PENDING) { - $this->reject('Invoking the wait callback did not resolve the promise'); - } - } - - private function invokeWaitFn() - { - try { - $wfn = $this->waitFn; - $this->waitFn = null; - $wfn(true); - } catch (\Exception $reason) { - if ($this->state === self::PENDING) { - // The promise has not been resolved yet, so reject the promise - // with the exception. - $this->reject($reason); - } else { - // The promise was already resolved, so there's a problem in - // the application. - throw $reason; - } - } - } - - private function invokeWaitList() - { - $waitList = $this->waitList; - $this->waitList = null; - - foreach ($waitList as $result) { - descend: - $result->waitIfPending(); - if ($result->result instanceof Promise) { - $result = $result->result; - goto descend; - } - } - } -} diff --git a/vendor/guzzlehttp/promises/src/PromiseInterface.php b/vendor/guzzlehttp/promises/src/PromiseInterface.php deleted file mode 100644 index 8f5f4b99b..000000000 --- a/vendor/guzzlehttp/promises/src/PromiseInterface.php +++ /dev/null @@ -1,93 +0,0 @@ -reason = $reason; - } - - public function then( - callable $onFulfilled = null, - callable $onRejected = null - ) { - // If there's no onRejected callback then just return self. - if (!$onRejected) { - return $this; - } - - $queue = queue(); - $reason = $this->reason; - $p = new Promise([$queue, 'run']); - $queue->add(static function () use ($p, $reason, $onRejected) { - if ($p->getState() === self::PENDING) { - try { - // Return a resolved promise if onRejected does not throw. - $p->resolve($onRejected($reason)); - } catch (\Exception $e) { - // onRejected threw, so return a rejected promise. - $p->reject($e); - } - } - }); - - return $p; - } - - public function otherwise(callable $onRejected) - { - return $this->then(null, $onRejected); - } - - public function wait($unwrap = true, $defaultDelivery = null) - { - if ($unwrap) { - throw exception_for($this->reason); - } - } - - public function getState() - { - return self::REJECTED; - } - - public function resolve($value) - { - throw new \LogicException("Cannot resolve a rejected promise"); - } - - public function reject($reason) - { - if ($reason !== $this->reason) { - throw new \LogicException("Cannot reject a rejected promise"); - } - } - - public function cancel() - { - // pass - } -} diff --git a/vendor/guzzlehttp/promises/src/RejectionException.php b/vendor/guzzlehttp/promises/src/RejectionException.php deleted file mode 100644 index 07c1136da..000000000 --- a/vendor/guzzlehttp/promises/src/RejectionException.php +++ /dev/null @@ -1,47 +0,0 @@ -reason = $reason; - - $message = 'The promise was rejected'; - - if ($description) { - $message .= ' with reason: ' . $description; - } elseif (is_string($reason) - || (is_object($reason) && method_exists($reason, '__toString')) - ) { - $message .= ' with reason: ' . $this->reason; - } elseif ($reason instanceof \JsonSerializable) { - $message .= ' with reason: ' - . json_encode($this->reason, JSON_PRETTY_PRINT); - } - - parent::__construct($message); - } - - /** - * Returns the rejection reason. - * - * @return mixed - */ - public function getReason() - { - return $this->reason; - } -} diff --git a/vendor/guzzlehttp/promises/src/TaskQueue.php b/vendor/guzzlehttp/promises/src/TaskQueue.php deleted file mode 100644 index 502636313..000000000 --- a/vendor/guzzlehttp/promises/src/TaskQueue.php +++ /dev/null @@ -1,79 +0,0 @@ -run(); - */ -class TaskQueue -{ - private $enableShutdown = true; - private $queue = []; - - public function __construct($withShutdown = true) - { - if ($withShutdown) { - register_shutdown_function(function () { - if ($this->enableShutdown) { - // Only run the tasks if an E_ERROR didn't occur. - $err = error_get_last(); - if (!$err || ($err['type'] ^ E_ERROR)) { - $this->run(); - } - } - }); - } - } - - /** - * Returns true if the queue is empty. - * - * @return bool - */ - public function isEmpty() - { - return !$this->queue; - } - - /** - * Adds a task to the queue that will be executed the next time run is - * called. - * - * @param callable $task - */ - public function add(callable $task) - { - $this->queue[] = $task; - } - - /** - * Execute all of the pending task in the queue. - */ - public function run() - { - while ($task = array_shift($this->queue)) { - $task(); - } - } - - /** - * The task queue will be run and exhausted by default when the process - * exits IFF the exit is not the result of a PHP E_ERROR error. - * - * You can disable running the automatic shutdown of the queue by calling - * this function. If you disable the task queue shutdown process, then you - * MUST either run the task queue (as a result of running your event loop - * or manually using the run() method) or wait on each outstanding promise. - * - * Note: This shutdown will occur before any destructors are triggered. - */ - public function disableShutdown() - { - $this->enableShutdown = false; - } -} diff --git a/vendor/guzzlehttp/promises/src/functions.php b/vendor/guzzlehttp/promises/src/functions.php deleted file mode 100644 index 89c656911..000000000 --- a/vendor/guzzlehttp/promises/src/functions.php +++ /dev/null @@ -1,495 +0,0 @@ - - * while ($eventLoop->isRunning()) { - * GuzzleHttp\Promise\queue()->run(); - * } - * - * - * @return TaskQueue - */ -function queue() -{ - static $queue; - - if (!$queue) { - $queue = new TaskQueue(); - } - - return $queue; -} - -/** - * Adds a function to run in the task queue when it is next `run()` and returns - * a promise that is fulfilled or rejected with the result. - * - * @param callable $task Task function to run. - * - * @return PromiseInterface - */ -function task(callable $task) -{ - $queue = queue(); - $promise = new Promise([$queue, 'run']); - $queue->add(function () use ($task, $promise) { - try { - $promise->resolve($task()); - } catch (\Exception $e) { - $promise->reject($e); - } - }); - - return $promise; -} - -/** - * Creates a promise for a value if the value is not a promise. - * - * @param mixed $value Promise or value. - * - * @return PromiseInterface - */ -function promise_for($value) -{ - if ($value instanceof PromiseInterface) { - return $value; - } - - // Return a Guzzle promise that shadows the given promise. - if (method_exists($value, 'then')) { - $wfn = method_exists($value, 'wait') ? [$value, 'wait'] : null; - $cfn = method_exists($value, 'cancel') ? [$value, 'cancel'] : null; - $promise = new Promise($wfn, $cfn); - $value->then([$promise, 'resolve'], [$promise, 'reject']); - return $promise; - } - - return new FulfilledPromise($value); -} - -/** - * Creates a rejected promise for a reason if the reason is not a promise. If - * the provided reason is a promise, then it is returned as-is. - * - * @param mixed $reason Promise or reason. - * - * @return PromiseInterface - */ -function rejection_for($reason) -{ - if ($reason instanceof PromiseInterface) { - return $reason; - } - - return new RejectedPromise($reason); -} - -/** - * Create an exception for a rejected promise value. - * - * @param mixed $reason - * - * @return \Exception - */ -function exception_for($reason) -{ - return $reason instanceof \Exception - ? $reason - : new RejectionException($reason); -} - -/** - * Returns an iterator for the given value. - * - * @param mixed $value - * - * @return \Iterator - */ -function iter_for($value) -{ - if ($value instanceof \Iterator) { - return $value; - } elseif (is_array($value)) { - return new \ArrayIterator($value); - } else { - return new \ArrayIterator([$value]); - } -} - -/** - * Synchronously waits on a promise to resolve and returns an inspection state - * array. - * - * Returns a state associative array containing a "state" key mapping to a - * valid promise state. If the state of the promise is "fulfilled", the array - * will contain a "value" key mapping to the fulfilled value of the promise. If - * the promise is rejected, the array will contain a "reason" key mapping to - * the rejection reason of the promise. - * - * @param PromiseInterface $promise Promise or value. - * - * @return array - */ -function inspect(PromiseInterface $promise) -{ - try { - return [ - 'state' => PromiseInterface::FULFILLED, - 'value' => $promise->wait() - ]; - } catch (RejectionException $e) { - return ['state' => 'rejected', 'reason' => $e->getReason()]; - } catch (\Exception $e) { - return ['state' => 'rejected', 'reason' => $e]; - } -} - -/** - * Waits on all of the provided promises, but does not unwrap rejected promises - * as thrown exception. - * - * Returns an array of inspection state arrays. - * - * @param PromiseInterface[] $promises Traversable of promises to wait upon. - * - * @return array - * @see GuzzleHttp\Promise\inspect for the inspection state array format. - */ -function inspect_all($promises) -{ - $results = []; - foreach ($promises as $key => $promise) { - $results[$key] = inspect($promise); - } - - return $results; -} - -/** - * Waits on all of the provided promises and returns the fulfilled values. - * - * Returns an array that contains the value of each promise (in the same order - * the promises were provided). An exception is thrown if any of the promises - * are rejected. - * - * @param mixed $promises Iterable of PromiseInterface objects to wait on. - * - * @return array - * @throws \Exception on error - */ -function unwrap($promises) -{ - $results = []; - foreach ($promises as $key => $promise) { - $results[$key] = $promise->wait(); - } - - return $results; -} - -/** - * Given an array of promises, return a promise that is fulfilled when all the - * items in the array are fulfilled. - * - * The promise's fulfillment value is an array with fulfillment values at - * respective positions to the original array. If any promise in the array - * rejects, the returned promise is rejected with the rejection reason. - * - * @param mixed $promises Promises or values. - * - * @return Promise - */ -function all($promises) -{ - $results = []; - return each( - $promises, - function ($value, $idx) use (&$results) { - $results[$idx] = $value; - }, - function ($reason, $idx, Promise $aggregate) { - $aggregate->reject($reason); - } - )->then(function () use (&$results) { - ksort($results); - return $results; - }); -} - -/** - * Initiate a competitive race between multiple promises or values (values will - * become immediately fulfilled promises). - * - * When count amount of promises have been fulfilled, the returned promise is - * fulfilled with an array that contains the fulfillment values of the winners - * in order of resolution. - * - * This prommise is rejected with a {@see GuzzleHttp\Promise\AggregateException} - * if the number of fulfilled promises is less than the desired $count. - * - * @param int $count Total number of promises. - * @param mixed $promises Promises or values. - * - * @return Promise - */ -function some($count, $promises) -{ - $results = []; - $rejections = []; - - return each( - $promises, - function ($value, $idx, PromiseInterface $p) use (&$results, $count) { - if ($p->getState() !== PromiseInterface::PENDING) { - return; - } - $results[$idx] = $value; - if (count($results) >= $count) { - $p->resolve(null); - } - }, - function ($reason) use (&$rejections) { - $rejections[] = $reason; - } - )->then( - function () use (&$results, &$rejections, $count) { - if (count($results) !== $count) { - throw new AggregateException( - 'Not enough promises to fulfill count', - $rejections - ); - } - ksort($results); - return array_values($results); - } - ); -} - -/** - * Like some(), with 1 as count. However, if the promise fulfills, the - * fulfillment value is not an array of 1 but the value directly. - * - * @param mixed $promises Promises or values. - * - * @return PromiseInterface - */ -function any($promises) -{ - return some(1, $promises)->then(function ($values) { return $values[0]; }); -} - -/** - * Returns a promise that is fulfilled when all of the provided promises have - * been fulfilled or rejected. - * - * The returned promise is fulfilled with an array of inspection state arrays. - * - * @param mixed $promises Promises or values. - * - * @return Promise - * @see GuzzleHttp\Promise\inspect for the inspection state array format. - */ -function settle($promises) -{ - $results = []; - - return each( - $promises, - function ($value, $idx) use (&$results) { - $results[$idx] = ['state' => 'fulfilled', 'value' => $value]; - }, - function ($reason, $idx) use (&$results) { - $results[$idx] = ['state' => 'rejected', 'reason' => $reason]; - } - )->then(function () use (&$results) { - ksort($results); - return $results; - }); -} - -/** - * Given an iterator that yields promises or values, returns a promise that is - * fulfilled with a null value when the iterator has been consumed or the - * aggregate promise has been fulfilled or rejected. - * - * $onFulfilled is a function that accepts the fulfilled value, iterator - * index, and the aggregate promise. The callback can invoke any necessary side - * effects and choose to resolve or reject the aggregate promise if needed. - * - * $onRejected is a function that accepts the rejection reason, iterator - * index, and the aggregate promise. The callback can invoke any necessary side - * effects and choose to resolve or reject the aggregate promise if needed. - * - * @param mixed $iterable Iterator or array to iterate over. - * @param callable $onFulfilled - * @param callable $onRejected - * - * @return Promise - */ -function each( - $iterable, - callable $onFulfilled = null, - callable $onRejected = null -) { - return (new EachPromise($iterable, [ - 'fulfilled' => $onFulfilled, - 'rejected' => $onRejected - ]))->promise(); -} - -/** - * Like each, but only allows a certain number of outstanding promises at any - * given time. - * - * $concurrency may be an integer or a function that accepts the number of - * pending promises and returns a numeric concurrency limit value to allow for - * dynamic a concurrency size. - * - * @param mixed $iterable - * @param int|callable $concurrency - * @param callable $onFulfilled - * @param callable $onRejected - * - * @return mixed - */ -function each_limit( - $iterable, - $concurrency, - callable $onFulfilled = null, - callable $onRejected = null -) { - return (new EachPromise($iterable, [ - 'fulfilled' => $onFulfilled, - 'rejected' => $onRejected, - 'concurrency' => $concurrency - ]))->promise(); -} - -/** - * Like each_limit, but ensures that no promise in the given $iterable argument - * is rejected. If any promise is rejected, then the aggregate promise is - * rejected with the encountered rejection. - * - * @param mixed $iterable - * @param int|callable $concurrency - * @param callable $onFulfilled - * - * @return mixed - */ -function each_limit_all( - $iterable, - $concurrency, - callable $onFulfilled = null -) { - return each_limit( - $iterable, - $concurrency, - $onFulfilled, - function ($reason, $idx, PromiseInterface $aggregate) { - $aggregate->reject($reason); - } - ); -} - -/** - * Returns true if a promise is fulfilled. - * - * @param PromiseInterface $promise - * - * @return bool - */ -function is_fulfilled(PromiseInterface $promise) -{ - return $promise->getState() === PromiseInterface::FULFILLED; -} - -/** - * Returns true if a promise is rejected. - * - * @param PromiseInterface $promise - * - * @return bool - */ -function is_rejected(PromiseInterface $promise) -{ - return $promise->getState() === PromiseInterface::REJECTED; -} - -/** - * Returns true if a promise is fulfilled or rejected. - * - * @param PromiseInterface $promise - * - * @return bool - */ -function is_settled(PromiseInterface $promise) -{ - return $promise->getState() !== PromiseInterface::PENDING; -} - -/** - * Creates a promise that is resolved using a generator that yields values or - * promises (somewhat similar to C#'s async keyword). - * - * When called, the coroutine function will start an instance of the generator - * and returns a promise that is fulfilled with its final yielded value. - * - * Control is returned back to the generator when the yielded promise settles. - * This can lead to less verbose code when doing lots of sequential async calls - * with minimal processing in between. - * - * use GuzzleHttp\Promise; - * - * function createPromise($value) { - * return new Promise\FulfilledPromise($value); - * } - * - * $promise = Promise\coroutine(function () { - * $value = (yield createPromise('a')); - * try { - * $value = (yield createPromise($value . 'b')); - * } catch (\Exception $e) { - * // The promise was rejected. - * } - * yield $value . 'c'; - * }); - * - * // Outputs "abc" - * $promise->then(function ($v) { echo $v; }); - * - * @param callable $generatorFn Generator function to wrap into a promise. - * - * @return Promise - * @link https://github.com/petkaantonov/bluebird/blob/master/API.md#generators inspiration - */ -function coroutine(callable $generatorFn) -{ - $generator = $generatorFn(); - return __next_coroutine($generator->current(), $generator)->then(); -} - -/** @internal */ -function __next_coroutine($yielded, \Generator $generator) -{ - return promise_for($yielded)->then( - function ($value) use ($generator) { - $nextYield = $generator->send($value); - return $generator->valid() - ? __next_coroutine($nextYield, $generator) - : $value; - }, - function ($reason) use ($generator) { - $nextYield = $generator->throw(exception_for($reason)); - // The throw was caught, so keep iterating on the coroutine - return __next_coroutine($nextYield, $generator); - } - ); -} diff --git a/vendor/guzzlehttp/promises/src/functions_include.php b/vendor/guzzlehttp/promises/src/functions_include.php deleted file mode 100644 index 34cd1710a..000000000 --- a/vendor/guzzlehttp/promises/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ -assertContains('foo', $e->getMessage()); - $this->assertEquals(['baz', 'bar'], $e->getReason()); - } -} diff --git a/vendor/guzzlehttp/promises/tests/EachPromiseTest.php b/vendor/guzzlehttp/promises/tests/EachPromiseTest.php deleted file mode 100644 index 0a0a851da..000000000 --- a/vendor/guzzlehttp/promises/tests/EachPromiseTest.php +++ /dev/null @@ -1,294 +0,0 @@ - 100]); - $this->assertSame($each->promise(), $each->promise()); - } - - public function testInvokesAllPromises() - { - $promises = [new Promise(), new Promise(), new Promise()]; - $called = []; - $each = new EachPromise($promises, [ - 'fulfilled' => function ($value) use (&$called) { - $called[] = $value; - } - ]); - $p = $each->promise(); - $promises[0]->resolve('a'); - $promises[1]->resolve('c'); - $promises[2]->resolve('b'); - P\queue()->run(); - $this->assertEquals(['a', 'c', 'b'], $called); - $this->assertEquals(PromiseInterface::FULFILLED, $p->getState()); - } - - public function testIsWaitable() - { - $a = new Promise(function () use (&$a) { $a->resolve('a'); }); - $b = new Promise(function () use (&$b) { $b->resolve('b'); }); - $called = []; - $each = new EachPromise([$a, $b], [ - 'fulfilled' => function ($value) use (&$called) { $called[] = $value; } - ]); - $p = $each->promise(); - $this->assertNull($p->wait()); - $this->assertEquals(PromiseInterface::FULFILLED, $p->getState()); - $this->assertEquals(['a', 'b'], $called); - } - - public function testCanResolveBeforeConsumingAll() - { - $called = 0; - $a = new Promise(function () use (&$a) { $a->resolve('a'); }); - $b = new Promise(function () { $this->fail(); }); - $each = new EachPromise([$a, $b], [ - 'fulfilled' => function ($value, $idx, Promise $aggregate) use (&$called) { - $this->assertSame($idx, 0); - $this->assertEquals('a', $value); - $aggregate->resolve(null); - $called++; - }, - 'rejected' => function (\Exception $reason) { - $this->fail($reason->getMessage()); - } - ]); - $p = $each->promise(); - $p->wait(); - $this->assertNull($p->wait()); - $this->assertEquals(1, $called); - $this->assertEquals(PromiseInterface::FULFILLED, $a->getState()); - $this->assertEquals(PromiseInterface::PENDING, $b->getState()); - // Resolving $b has no effect on the aggregate promise. - $b->resolve('foo'); - $this->assertEquals(1, $called); - } - - public function testLimitsPendingPromises() - { - $pending = [new Promise(), new Promise(), new Promise(), new Promise()]; - $promises = new \ArrayIterator($pending); - $each = new EachPromise($promises, ['concurrency' => 2]); - $p = $each->promise(); - $this->assertCount(2, $this->readAttribute($each, 'pending')); - $pending[0]->resolve('a'); - $this->assertCount(2, $this->readAttribute($each, 'pending')); - $this->assertTrue($promises->valid()); - $pending[1]->resolve('b'); - P\queue()->run(); - $this->assertCount(2, $this->readAttribute($each, 'pending')); - $this->assertTrue($promises->valid()); - $promises[2]->resolve('c'); - P\queue()->run(); - $this->assertCount(1, $this->readAttribute($each, 'pending')); - $this->assertEquals(PromiseInterface::PENDING, $p->getState()); - $promises[3]->resolve('d'); - P\queue()->run(); - $this->assertNull($this->readAttribute($each, 'pending')); - $this->assertEquals(PromiseInterface::FULFILLED, $p->getState()); - $this->assertFalse($promises->valid()); - } - - public function testDynamicallyLimitsPendingPromises() - { - $calls = []; - $pendingFn = function ($count) use (&$calls) { - $calls[] = $count; - return 2; - }; - $pending = [new Promise(), new Promise(), new Promise(), new Promise()]; - $promises = new \ArrayIterator($pending); - $each = new EachPromise($promises, ['concurrency' => $pendingFn]); - $p = $each->promise(); - $this->assertCount(2, $this->readAttribute($each, 'pending')); - $pending[0]->resolve('a'); - $this->assertCount(2, $this->readAttribute($each, 'pending')); - $this->assertTrue($promises->valid()); - $pending[1]->resolve('b'); - $this->assertCount(2, $this->readAttribute($each, 'pending')); - P\queue()->run(); - $this->assertTrue($promises->valid()); - $promises[2]->resolve('c'); - P\queue()->run(); - $this->assertCount(1, $this->readAttribute($each, 'pending')); - $this->assertEquals(PromiseInterface::PENDING, $p->getState()); - $promises[3]->resolve('d'); - P\queue()->run(); - $this->assertNull($this->readAttribute($each, 'pending')); - $this->assertEquals(PromiseInterface::FULFILLED, $p->getState()); - $this->assertEquals([0, 1, 1, 1], $calls); - $this->assertFalse($promises->valid()); - } - - public function testClearsReferencesWhenResolved() - { - $called = false; - $a = new Promise(function () use (&$a, &$called) { - $a->resolve('a'); - $called = true; - }); - $each = new EachPromise([$a], [ - 'concurrency' => function () { return 1; }, - 'fulfilled' => function () {}, - 'rejected' => function () {} - ]); - $each->promise()->wait(); - $this->assertNull($this->readAttribute($each, 'onFulfilled')); - $this->assertNull($this->readAttribute($each, 'onRejected')); - $this->assertNull($this->readAttribute($each, 'iterable')); - $this->assertNull($this->readAttribute($each, 'pending')); - $this->assertNull($this->readAttribute($each, 'concurrency')); - $this->assertTrue($called); - } - - public function testCanBeCancelled() - { - $this->markTestIncomplete(); - } - - public function testFulfillsImmediatelyWhenGivenAnEmptyIterator() - { - $each = new EachPromise(new \ArrayIterator([])); - $result = $each->promise()->wait(); - } - - public function testDoesNotBlowStackWithFulfilledPromises() - { - $pending = []; - for ($i = 0; $i < 100; $i++) { - $pending[] = new FulfilledPromise($i); - } - $values = []; - $each = new EachPromise($pending, [ - 'fulfilled' => function ($value) use (&$values) { - $values[] = $value; - } - ]); - $called = false; - $each->promise()->then(function () use (&$called) { - $called = true; - }); - $this->assertFalse($called); - P\queue()->run(); - $this->assertTrue($called); - $this->assertEquals(range(0, 99), $values); - } - - public function testDoesNotBlowStackWithRejectedPromises() - { - $pending = []; - for ($i = 0; $i < 100; $i++) { - $pending[] = new RejectedPromise($i); - } - $values = []; - $each = new EachPromise($pending, [ - 'rejected' => function ($value) use (&$values) { - $values[] = $value; - } - ]); - $called = false; - $each->promise()->then( - function () use (&$called) { $called = true; }, - function () { $this->fail('Should not have rejected.'); } - ); - $this->assertFalse($called); - P\queue()->run(); - $this->assertTrue($called); - $this->assertEquals(range(0, 99), $values); - } - - public function testReturnsPromiseForWhatever() - { - $called = []; - $arr = ['a', 'b']; - $each = new EachPromise($arr, [ - 'fulfilled' => function ($v) use (&$called) { $called[] = $v; } - ]); - $p = $each->promise(); - $this->assertNull($p->wait()); - $this->assertEquals(['a', 'b'], $called); - } - - public function testRejectsAggregateWhenNextThrows() - { - $iter = function () { - yield 'a'; - throw new \Exception('Failure'); - }; - $each = new EachPromise($iter()); - $p = $each->promise(); - $e = null; - $received = null; - $p->then(null, function ($reason) use (&$e) { $e = $reason; }); - P\queue()->run(); - $this->assertInstanceOf('Exception', $e); - $this->assertEquals('Failure', $e->getMessage()); - } - - public function testDoesNotCallNextOnIteratorUntilNeededWhenWaiting() - { - $results = []; - $values = [10]; - $remaining = 9; - $iter = function () use (&$values) { - while ($value = array_pop($values)) { - yield $value; - } - }; - $each = new EachPromise($iter(), [ - 'concurrency' => 1, - 'fulfilled' => function ($r) use (&$results, &$values, &$remaining) { - $results[] = $r; - if ($remaining > 0) { - $values[] = $remaining--; - } - } - ]); - $each->promise()->wait(); - $this->assertEquals(range(10, 1), $results); - } - - public function testDoesNotCallNextOnIteratorUntilNeededWhenAsync() - { - $firstPromise = new Promise(); - $pending = [$firstPromise]; - $values = [$firstPromise]; - $results = []; - $remaining = 9; - $iter = function () use (&$values) { - while ($value = array_pop($values)) { - yield $value; - } - }; - $each = new EachPromise($iter(), [ - 'concurrency' => 1, - 'fulfilled' => function ($r) use (&$results, &$values, &$remaining, &$pending) { - $results[] = $r; - if ($remaining-- > 0) { - $pending[] = $values[] = new Promise(); - } - } - ]); - $i = 0; - $each->promise(); - while ($promise = array_pop($pending)) { - $promise->resolve($i++); - P\queue()->run(); - } - $this->assertEquals(range(0, 9), $results); - } -} diff --git a/vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php b/vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php deleted file mode 100644 index 554c15070..000000000 --- a/vendor/guzzlehttp/promises/tests/FulfilledPromiseTest.php +++ /dev/null @@ -1,108 +0,0 @@ -assertEquals('fulfilled', $p->getState()); - $this->assertEquals('foo', $p->wait(true)); - } - - public function testCannotCancel() - { - $p = new FulfilledPromise('foo'); - $this->assertEquals('fulfilled', $p->getState()); - $p->cancel(); - $this->assertEquals('foo', $p->wait()); - } - - /** - * @expectedException \LogicException - * @exepctedExceptionMessage Cannot resolve a fulfilled promise - */ - public function testCannotResolve() - { - $p = new FulfilledPromise('foo'); - $p->resolve('bar'); - } - - /** - * @expectedException \LogicException - * @exepctedExceptionMessage Cannot reject a fulfilled promise - */ - public function testCannotReject() - { - $p = new FulfilledPromise('foo'); - $p->reject('bar'); - } - - public function testCanResolveWithSameValue() - { - $p = new FulfilledPromise('foo'); - $p->resolve('foo'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testCannotResolveWithPromise() - { - new FulfilledPromise(new Promise()); - } - - public function testReturnsSelfWhenNoOnFulfilled() - { - $p = new FulfilledPromise('a'); - $this->assertSame($p, $p->then()); - } - - public function testAsynchronouslyInvokesOnFulfilled() - { - $p = new FulfilledPromise('a'); - $r = null; - $f = function ($d) use (&$r) { $r = $d; }; - $p2 = $p->then($f); - $this->assertNotSame($p, $p2); - $this->assertNull($r); - \GuzzleHttp\Promise\queue()->run(); - $this->assertEquals('a', $r); - } - - public function testReturnsNewRejectedWhenOnFulfilledFails() - { - $p = new FulfilledPromise('a'); - $f = function () { throw new \Exception('b'); }; - $p2 = $p->then($f); - $this->assertNotSame($p, $p2); - try { - $p2->wait(); - $this->fail(); - } catch (\Exception $e) { - $this->assertEquals('b', $e->getMessage()); - } - } - - public function testOtherwiseIsSugarForRejections() - { - $c = null; - $p = new FulfilledPromise('foo'); - $p->otherwise(function ($v) use (&$c) { $c = $v; }); - $this->assertNull($c); - } - - public function testDoesNotTryToFulfillTwiceDuringTrampoline() - { - $fp = new FulfilledPromise('a'); - $t1 = $fp->then(function ($v) { return $v . ' b'; }); - $t1->resolve('why!'); - $this->assertEquals('why!', $t1->wait()); - } -} diff --git a/vendor/guzzlehttp/promises/tests/NotPromiseInstance.php b/vendor/guzzlehttp/promises/tests/NotPromiseInstance.php deleted file mode 100644 index 6288aa88a..000000000 --- a/vendor/guzzlehttp/promises/tests/NotPromiseInstance.php +++ /dev/null @@ -1,50 +0,0 @@ -nextPromise = new Promise(); - } - - public function then(callable $res = null, callable $rej = null) - { - return $this->nextPromise->then($res, $rej); - } - - public function otherwise(callable $onRejected) - { - return $this->then($onRejected); - } - - public function resolve($value) - { - $this->nextPromise->resolve($value); - } - - public function reject($reason) - { - $this->nextPromise->reject($reason); - } - - public function wait($unwrap = true, $defaultResolution = null) - { - - } - - public function cancel() - { - - } - - public function getState() - { - return $this->nextPromise->getState(); - } -} diff --git a/vendor/guzzlehttp/promises/tests/PromiseTest.php b/vendor/guzzlehttp/promises/tests/PromiseTest.php deleted file mode 100644 index 946c62724..000000000 --- a/vendor/guzzlehttp/promises/tests/PromiseTest.php +++ /dev/null @@ -1,579 +0,0 @@ -resolve('foo'); - $p->resolve('bar'); - $this->assertEquals('foo', $p->wait()); - } - - public function testCanResolveWithSameValue() - { - $p = new Promise(); - $p->resolve('foo'); - $p->resolve('foo'); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Cannot change a fulfilled promise to rejected - */ - public function testCannotRejectNonPendingPromise() - { - $p = new Promise(); - $p->resolve('foo'); - $p->reject('bar'); - $this->assertEquals('foo', $p->wait()); - } - - public function testCanRejectWithSameValue() - { - $p = new Promise(); - $p->reject('foo'); - $p->reject('foo'); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Cannot change a fulfilled promise to rejected - */ - public function testCannotRejectResolveWithSameValue() - { - $p = new Promise(); - $p->resolve('foo'); - $p->reject('foo'); - } - - public function testInvokesWaitFunction() - { - $p = new Promise(function () use (&$p) { $p->resolve('10'); }); - $this->assertEquals('10', $p->wait()); - } - - /** - * @expectedException \GuzzleHttp\Promise\RejectionException - */ - public function testRejectsAndThrowsWhenWaitFailsToResolve() - { - $p = new Promise(function () {}); - $p->wait(); - } - - /** - * @expectedException \GuzzleHttp\Promise\RejectionException - * @expectedExceptionMessage The promise was rejected with reason: foo - */ - public function testThrowsWhenUnwrapIsRejectedWithNonException() - { - $p = new Promise(function () use (&$p) { $p->reject('foo'); }); - $p->wait(); - } - - /** - * @expectedException \UnexpectedValueException - * @expectedExceptionMessage foo - */ - public function testThrowsWhenUnwrapIsRejectedWithException() - { - $e = new \UnexpectedValueException('foo'); - $p = new Promise(function () use (&$p, $e) { $p->reject($e); }); - $p->wait(); - } - - public function testDoesNotUnwrapExceptionsWhenDisabled() - { - $p = new Promise(function () use (&$p) { $p->reject('foo'); }); - $this->assertEquals('pending', $p->getState()); - $p->wait(false); - $this->assertEquals('rejected', $p->getState()); - } - - public function testRejectsSelfWhenWaitThrows() - { - $e = new \UnexpectedValueException('foo'); - $p = new Promise(function () use ($e) { throw $e; }); - try { - $p->wait(); - $this->fail(); - } catch (\UnexpectedValueException $e) { - $this->assertEquals('rejected', $p->getState()); - } - } - - public function testWaitsOnNestedPromises() - { - $p = new Promise(function () use (&$p) { $p->resolve('_'); }); - $p2 = new Promise(function () use (&$p2) { $p2->resolve('foo'); }); - $p3 = $p->then(function () use ($p2) { return $p2; }); - $this->assertSame('foo', $p3->wait()); - } - - /** - * @expectedException \GuzzleHttp\Promise\RejectionException - */ - public function testThrowsWhenWaitingOnPromiseWithNoWaitFunction() - { - $p = new Promise(); - $p->wait(); - } - - public function testThrowsWaitExceptionAfterPromiseIsResolved() - { - $p = new Promise(function () use (&$p) { - $p->reject('Foo!'); - throw new \Exception('Bar?'); - }); - - try { - $p->wait(); - $this->fail(); - } catch (\Exception $e) { - $this->assertEquals('Bar?', $e->getMessage()); - } - } - - public function testGetsActualWaitValueFromThen() - { - $p = new Promise(function () use (&$p) { $p->reject('Foo!'); }); - $p2 = $p->then(null, function ($reason) { - return new RejectedPromise([$reason]); - }); - - try { - $p2->wait(); - $this->fail('Should have thrown'); - } catch (RejectionException $e) { - $this->assertEquals(['Foo!'], $e->getReason()); - } - } - - public function testWaitBehaviorIsBasedOnLastPromiseInChain() - { - $p3 = new Promise(function () use (&$p3) { $p3->resolve('Whoop'); }); - $p2 = new Promise(function () use (&$p2, $p3) { $p2->reject($p3); }); - $p = new Promise(function () use (&$p, $p2) { $p->reject($p2); }); - $this->assertEquals('Whoop', $p->wait()); - } - - public function testCannotCancelNonPending() - { - $p = new Promise(); - $p->resolve('foo'); - $p->cancel(); - $this->assertEquals('fulfilled', $p->getState()); - } - - /** - * @expectedException \GuzzleHttp\Promise\CancellationException - */ - public function testCancelsPromiseWhenNoCancelFunction() - { - $p = new Promise(); - $p->cancel(); - $this->assertEquals('rejected', $p->getState()); - $p->wait(); - } - - public function testCancelsPromiseWithCancelFunction() - { - $called = false; - $p = new Promise(null, function () use (&$called) { $called = true; }); - $p->cancel(); - $this->assertEquals('rejected', $p->getState()); - $this->assertTrue($called); - } - - public function testCancelsUppermostPendingPromise() - { - $called = false; - $p1 = new Promise(null, function () use (&$called) { $called = true; }); - $p2 = $p1->then(function () {}); - $p3 = $p2->then(function () {}); - $p4 = $p3->then(function () {}); - $p3->cancel(); - $this->assertEquals('rejected', $p1->getState()); - $this->assertEquals('rejected', $p2->getState()); - $this->assertEquals('rejected', $p3->getState()); - $this->assertEquals('pending', $p4->getState()); - $this->assertTrue($called); - - try { - $p3->wait(); - $this->fail(); - } catch (CancellationException $e) { - $this->assertContains('cancelled', $e->getMessage()); - } - - try { - $p4->wait(); - $this->fail(); - } catch (CancellationException $e) { - $this->assertContains('cancelled', $e->getMessage()); - } - - $this->assertEquals('rejected', $p4->getState()); - } - - public function testCancelsChildPromises() - { - $called1 = $called2 = $called3 = false; - $p1 = new Promise(null, function () use (&$called1) { $called1 = true; }); - $p2 = new Promise(null, function () use (&$called2) { $called2 = true; }); - $p3 = new Promise(null, function () use (&$called3) { $called3 = true; }); - $p4 = $p2->then(function () use ($p3) { return $p3; }); - $p5 = $p4->then(function () { $this->fail(); }); - $p4->cancel(); - $this->assertEquals('pending', $p1->getState()); - $this->assertEquals('rejected', $p2->getState()); - $this->assertEquals('rejected', $p4->getState()); - $this->assertEquals('pending', $p5->getState()); - $this->assertFalse($called1); - $this->assertTrue($called2); - $this->assertFalse($called3); - } - - public function testRejectsPromiseWhenCancelFails() - { - $called = false; - $p = new Promise(null, function () use (&$called) { - $called = true; - throw new \Exception('e'); - }); - $p->cancel(); - $this->assertEquals('rejected', $p->getState()); - $this->assertTrue($called); - try { - $p->wait(); - $this->fail(); - } catch (\Exception $e) { - $this->assertEquals('e', $e->getMessage()); - } - } - - public function testCreatesPromiseWhenFulfilledAfterThen() - { - $p = new Promise(); - $carry = null; - $p2 = $p->then(function ($v) use (&$carry) { $carry = $v; }); - $this->assertNotSame($p, $p2); - $p->resolve('foo'); - P\queue()->run(); - - $this->assertEquals('foo', $carry); - } - - public function testCreatesPromiseWhenFulfilledBeforeThen() - { - $p = new Promise(); - $p->resolve('foo'); - $carry = null; - $p2 = $p->then(function ($v) use (&$carry) { $carry = $v; }); - $this->assertNotSame($p, $p2); - $this->assertNull($carry); - \GuzzleHttp\Promise\queue()->run(); - $this->assertEquals('foo', $carry); - } - - public function testCreatesPromiseWhenFulfilledWithNoCallback() - { - $p = new Promise(); - $p->resolve('foo'); - $p2 = $p->then(); - $this->assertNotSame($p, $p2); - $this->assertInstanceOf('GuzzleHttp\Promise\FulfilledPromise', $p2); - } - - public function testCreatesPromiseWhenRejectedAfterThen() - { - $p = new Promise(); - $carry = null; - $p2 = $p->then(null, function ($v) use (&$carry) { $carry = $v; }); - $this->assertNotSame($p, $p2); - $p->reject('foo'); - P\queue()->run(); - $this->assertEquals('foo', $carry); - } - - public function testCreatesPromiseWhenRejectedBeforeThen() - { - $p = new Promise(); - $p->reject('foo'); - $carry = null; - $p2 = $p->then(null, function ($v) use (&$carry) { $carry = $v; }); - $this->assertNotSame($p, $p2); - $this->assertNull($carry); - P\queue()->run(); - $this->assertEquals('foo', $carry); - } - - public function testCreatesPromiseWhenRejectedWithNoCallback() - { - $p = new Promise(); - $p->reject('foo'); - $p2 = $p->then(); - $this->assertNotSame($p, $p2); - $this->assertInstanceOf('GuzzleHttp\Promise\RejectedPromise', $p2); - } - - public function testInvokesWaitFnsForThens() - { - $p = new Promise(function () use (&$p) { $p->resolve('a'); }); - $p2 = $p - ->then(function ($v) { return $v . '-1-'; }) - ->then(function ($v) { return $v . '2'; }); - $this->assertEquals('a-1-2', $p2->wait()); - } - - public function testStacksThenWaitFunctions() - { - $p1 = new Promise(function () use (&$p1) { $p1->resolve('a'); }); - $p2 = new Promise(function () use (&$p2) { $p2->resolve('b'); }); - $p3 = new Promise(function () use (&$p3) { $p3->resolve('c'); }); - $p4 = $p1 - ->then(function () use ($p2) { return $p2; }) - ->then(function () use ($p3) { return $p3; }); - $this->assertEquals('c', $p4->wait()); - } - - public function testForwardsFulfilledDownChainBetweenGaps() - { - $p = new Promise(); - $r = $r2 = null; - $p->then(null, null) - ->then(function ($v) use (&$r) { $r = $v; return $v . '2'; }) - ->then(function ($v) use (&$r2) { $r2 = $v; }); - $p->resolve('foo'); - P\queue()->run(); - $this->assertEquals('foo', $r); - $this->assertEquals('foo2', $r2); - } - - public function testForwardsRejectedPromisesDownChainBetweenGaps() - { - $p = new Promise(); - $r = $r2 = null; - $p->then(null, null) - ->then(null, function ($v) use (&$r) { $r = $v; return $v . '2'; }) - ->then(function ($v) use (&$r2) { $r2 = $v; }); - $p->reject('foo'); - P\queue()->run(); - $this->assertEquals('foo', $r); - $this->assertEquals('foo2', $r2); - } - - public function testForwardsThrownPromisesDownChainBetweenGaps() - { - $e = new \Exception(); - $p = new Promise(); - $r = $r2 = null; - $p->then(null, null) - ->then(null, function ($v) use (&$r, $e) { - $r = $v; - throw $e; - }) - ->then( - null, - function ($v) use (&$r2) { $r2 = $v; } - ); - $p->reject('foo'); - P\queue()->run(); - $this->assertEquals('foo', $r); - $this->assertSame($e, $r2); - } - - public function testForwardsReturnedRejectedPromisesDownChainBetweenGaps() - { - $p = new Promise(); - $rejected = new RejectedPromise('bar'); - $r = $r2 = null; - $p->then(null, null) - ->then(null, function ($v) use (&$r, $rejected) { - $r = $v; - return $rejected; - }) - ->then( - null, - function ($v) use (&$r2) { $r2 = $v; } - ); - $p->reject('foo'); - P\queue()->run(); - $this->assertEquals('foo', $r); - $this->assertEquals('bar', $r2); - try { - $p->wait(); - } catch (RejectionException $e) { - $this->assertEquals('foo', $e->getReason()); - } - } - - public function testForwardsHandlersToNextPromise() - { - $p = new Promise(); - $p2 = new Promise(); - $resolved = null; - $p - ->then(function ($v) use ($p2) { return $p2; }) - ->then(function ($value) use (&$resolved) { $resolved = $value; }); - $p->resolve('a'); - $p2->resolve('b'); - P\queue()->run(); - $this->assertEquals('b', $resolved); - } - - public function testRemovesReferenceFromChildWhenParentWaitedUpon() - { - $r = null; - $p = new Promise(function () use (&$p) { $p->resolve('a'); }); - $p2 = new Promise(function () use (&$p2) { $p2->resolve('b'); }); - $pb = $p->then( - function ($v) use ($p2, &$r) { - $r = $v; - return $p2; - }) - ->then(function ($v) { return $v . '.'; }); - $this->assertEquals('a', $p->wait()); - $this->assertEquals('b', $p2->wait()); - $this->assertEquals('b.', $pb->wait()); - $this->assertEquals('a', $r); - } - - public function testForwardsHandlersWhenFulfilledPromiseIsReturned() - { - $res = []; - $p = new Promise(); - $p2 = new Promise(); - $p2->resolve('foo'); - $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; }); - // $res is A:foo - $p - ->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; }) - ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; }); - $p->resolve('a'); - $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; }); - P\queue()->run(); - $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res); - } - - public function testForwardsHandlersWhenRejectedPromiseIsReturned() - { - $res = []; - $p = new Promise(); - $p2 = new Promise(); - $p2->reject('foo'); - $p2->then(null, function ($v) use (&$res) { $res[] = 'A:' . $v; }); - $p->then(null, function () use ($p2, &$res) { $res[] = 'B'; return $p2; }) - ->then(null, function ($v) use (&$res) { $res[] = 'C:' . $v; }); - $p->reject('a'); - $p->then(null, function ($v) use (&$res) { $res[] = 'D:' . $v; }); - P\queue()->run(); - $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res); - } - - public function testDoesNotForwardRejectedPromise() - { - $res = []; - $p = new Promise(); - $p2 = new Promise(); - $p2->cancel(); - $p2->then(function ($v) use (&$res) { $res[] = "B:$v"; return $v; }); - $p->then(function ($v) use ($p2, &$res) { $res[] = "B:$v"; return $p2; }) - ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; }); - $p->resolve('a'); - $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; }); - P\queue()->run(); - $this->assertEquals(['B:a', 'D:a'], $res); - } - - public function testRecursivelyForwardsWhenOnlyThennable() - { - $res = []; - $p = new Promise(); - $p2 = new Thennable(); - $p2->resolve('foo'); - $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; }); - $p->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; }) - ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; }); - $p->resolve('a'); - $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; }); - P\queue()->run(); - $this->assertEquals(['A:foo', 'B', 'D:a', 'C:foo'], $res); - } - - public function testRecursivelyForwardsWhenNotInstanceOfPromise() - { - $res = []; - $p = new Promise(); - $p2 = new NotPromiseInstance(); - $p2->then(function ($v) use (&$res) { $res[] = 'A:' . $v; }); - $p->then(function () use ($p2, &$res) { $res[] = 'B'; return $p2; }) - ->then(function ($v) use (&$res) { $res[] = 'C:' . $v; }); - $p->resolve('a'); - $p->then(function ($v) use (&$res) { $res[] = 'D:' . $v; }); - P\queue()->run(); - $this->assertEquals(['B', 'D:a'], $res); - $p2->resolve('foo'); - P\queue()->run(); - $this->assertEquals(['B', 'D:a', 'A:foo', 'C:foo'], $res); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Cannot fulfill or reject a promise with itself - */ - public function testCannotResolveWithSelf() - { - $p = new Promise(); - $p->resolve($p); - } - - /** - * @expectedException \LogicException - * @expectedExceptionMessage Cannot fulfill or reject a promise with itself - */ - public function testCannotRejectWithSelf() - { - $p = new Promise(); - $p->reject($p); - } - - public function testDoesNotBlowStackWhenWaitingOnNestedThens() - { - $inner = new Promise(function () use (&$inner) { $inner->resolve(0); }); - $prev = $inner; - for ($i = 1; $i < 100; $i++) { - $prev = $prev->then(function ($i) { return $i + 1; }); - } - - $parent = new Promise(function () use (&$parent, $prev) { - $parent->resolve($prev); - }); - - $this->assertEquals(99, $parent->wait()); - } - - public function testOtherwiseIsSugarForRejections() - { - $p = new Promise(); - $p->reject('foo'); - $p->otherwise(function ($v) use (&$c) { $c = $v; }); - P\queue()->run(); - $this->assertEquals($c, 'foo'); - } -} diff --git a/vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php b/vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php deleted file mode 100644 index 60f926e92..000000000 --- a/vendor/guzzlehttp/promises/tests/RejectedPromiseTest.php +++ /dev/null @@ -1,143 +0,0 @@ -assertEquals('rejected', $p->getState()); - try { - $p->wait(true); - $this->fail(); - } catch (\Exception $e) { - $this->assertEquals('rejected', $p->getState()); - $this->assertContains('foo', $e->getMessage()); - } - } - - public function testCannotCancel() - { - $p = new RejectedPromise('foo'); - $p->cancel(); - $this->assertEquals('rejected', $p->getState()); - } - - /** - * @expectedException \LogicException - * @exepctedExceptionMessage Cannot resolve a rejected promise - */ - public function testCannotResolve() - { - $p = new RejectedPromise('foo'); - $p->resolve('bar'); - } - - /** - * @expectedException \LogicException - * @exepctedExceptionMessage Cannot reject a rejected promise - */ - public function testCannotReject() - { - $p = new RejectedPromise('foo'); - $p->reject('bar'); - } - - public function testCanRejectWithSameValue() - { - $p = new RejectedPromise('foo'); - $p->reject('foo'); - } - - public function testThrowsSpecificException() - { - $e = new \Exception(); - $p = new RejectedPromise($e); - try { - $p->wait(true); - $this->fail(); - } catch (\Exception $e2) { - $this->assertSame($e, $e2); - } - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testCannotResolveWithPromise() - { - new RejectedPromise(new Promise()); - } - - public function testReturnsSelfWhenNoOnReject() - { - $p = new RejectedPromise('a'); - $this->assertSame($p, $p->then()); - } - - public function testInvokesOnRejectedAsynchronously() - { - $p = new RejectedPromise('a'); - $r = null; - $f = function ($reason) use (&$r) { $r = $reason; }; - $p->then(null, $f); - $this->assertNull($r); - \GuzzleHttp\Promise\queue()->run(); - $this->assertEquals('a', $r); - } - - public function testReturnsNewRejectedWhenOnRejectedFails() - { - $p = new RejectedPromise('a'); - $f = function () { throw new \Exception('b'); }; - $p2 = $p->then(null, $f); - $this->assertNotSame($p, $p2); - try { - $p2->wait(); - $this->fail(); - } catch (\Exception $e) { - $this->assertEquals('b', $e->getMessage()); - } - } - - public function testWaitingIsNoOp() - { - $p = new RejectedPromise('a'); - $p->wait(false); - } - - public function testOtherwiseIsSugarForRejections() - { - $p = new RejectedPromise('foo'); - $p->otherwise(function ($v) use (&$c) { $c = $v; }); - \GuzzleHttp\Promise\queue()->run(); - $this->assertSame('foo', $c); - } - - public function testCanResolveThenWithSuccess() - { - $actual = null; - $p = new RejectedPromise('foo'); - $p->otherwise(function ($v) { - return $v . ' bar'; - })->then(function ($v) use (&$actual) { - $actual = $v; - }); - \GuzzleHttp\Promise\queue()->run(); - $this->assertEquals('foo bar', $actual); - } - - public function testDoesNotTryToRejectTwiceDuringTrampoline() - { - $fp = new RejectedPromise('a'); - $t1 = $fp->then(null, function ($v) { return $v . ' b'; }); - $t1->resolve('why!'); - $this->assertEquals('why!', $t1->wait()); - } -} diff --git a/vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php b/vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php deleted file mode 100644 index 36c6a88c5..000000000 --- a/vendor/guzzlehttp/promises/tests/RejectionExceptionTest.php +++ /dev/null @@ -1,47 +0,0 @@ -message = $message; - } - - public function __toString() - { - return $this->message; - } -} - -class Thing2 implements \JsonSerializable -{ - public function jsonSerialize() - { - return '{}'; - } -} - -/** - * @covers GuzzleHttp\Promise\RejectionException - */ -class RejectionExceptionTest extends \PHPUnit_Framework_TestCase -{ - public function testCanGetReasonFromException() - { - $thing = new Thing1('foo'); - $e = new RejectionException($thing); - - $this->assertSame($thing, $e->getReason()); - $this->assertEquals('The promise was rejected with reason: foo', $e->getMessage()); - } - - public function testCanGetReasonMessageFromJson() - { - $reason = new Thing2(); - $e = new RejectionException($reason); - $this->assertContains("{}", $e->getMessage()); - } -} diff --git a/vendor/guzzlehttp/promises/tests/TaskQueueTest.php b/vendor/guzzlehttp/promises/tests/TaskQueueTest.php deleted file mode 100644 index 845b26352..000000000 --- a/vendor/guzzlehttp/promises/tests/TaskQueueTest.php +++ /dev/null @@ -1,31 +0,0 @@ -assertTrue($tq->isEmpty()); - } - - public function testKnowsIfFull() - { - $tq = new TaskQueue(false); - $tq->add(function () {}); - $this->assertFalse($tq->isEmpty()); - } - - public function testExecutesTasksInOrder() - { - $tq = new TaskQueue(false); - $called = []; - $tq->add(function () use (&$called) { $called[] = 'a'; }); - $tq->add(function () use (&$called) { $called[] = 'b'; }); - $tq->add(function () use (&$called) { $called[] = 'c'; }); - $tq->run(); - $this->assertEquals(['a', 'b', 'c'], $called); - } -} diff --git a/vendor/guzzlehttp/promises/tests/Thennable.php b/vendor/guzzlehttp/promises/tests/Thennable.php deleted file mode 100644 index 398954d7d..000000000 --- a/vendor/guzzlehttp/promises/tests/Thennable.php +++ /dev/null @@ -1,24 +0,0 @@ -nextPromise = new Promise(); - } - - public function then(callable $res = null, callable $rej = null) - { - return $this->nextPromise->then($res, $rej); - } - - public function resolve($value) - { - $this->nextPromise->resolve($value); - } -} diff --git a/vendor/guzzlehttp/promises/tests/bootstrap.php b/vendor/guzzlehttp/promises/tests/bootstrap.php deleted file mode 100644 index a63d264bf..000000000 --- a/vendor/guzzlehttp/promises/tests/bootstrap.php +++ /dev/null @@ -1,4 +0,0 @@ -assertInstanceOf('GuzzleHttp\Promise\FulfilledPromise', $p); - } - - public function testReturnsPromiseForPromise() - { - $p = new Promise(); - $this->assertSame($p, \GuzzleHttp\Promise\promise_for($p)); - } - - public function testReturnsPromiseForThennable() - { - $p = new Thennable(); - $wrapped = \GuzzleHttp\Promise\promise_for($p); - $this->assertNotSame($p, $wrapped); - $this->assertInstanceOf('GuzzleHttp\Promise\PromiseInterface', $wrapped); - $p->resolve('foo'); - P\queue()->run(); - $this->assertEquals('foo', $wrapped->wait()); - } - - public function testReturnsRejection() - { - $p = \GuzzleHttp\Promise\rejection_for('fail'); - $this->assertInstanceOf('GuzzleHttp\Promise\RejectedPromise', $p); - $this->assertEquals('fail', $this->readAttribute($p, 'reason')); - } - - public function testReturnsPromisesAsIsInRejectionFor() - { - $a = new Promise(); - $b = \GuzzleHttp\Promise\rejection_for($a); - $this->assertSame($a, $b); - } - - public function testWaitsOnAllPromisesIntoArray() - { - $e = new \Exception(); - $a = new Promise(function () use (&$a) { $a->resolve('a'); }); - $b = new Promise(function () use (&$b) { $b->reject('b'); }); - $c = new Promise(function () use (&$c, $e) { $c->reject($e); }); - $results = \GuzzleHttp\Promise\inspect_all([$a, $b, $c]); - $this->assertEquals([ - ['state' => 'fulfilled', 'value' => 'a'], - ['state' => 'rejected', 'reason' => 'b'], - ['state' => 'rejected', 'reason' => $e] - ], $results); - } - - /** - * @expectedException \GuzzleHttp\Promise\RejectionException - */ - public function testUnwrapsPromisesWithNoDefaultAndFailure() - { - $promises = [new FulfilledPromise('a'), new Promise()]; - \GuzzleHttp\Promise\unwrap($promises); - } - - public function testUnwrapsPromisesWithNoDefault() - { - $promises = [new FulfilledPromise('a')]; - $this->assertEquals(['a'], \GuzzleHttp\Promise\unwrap($promises)); - } - - public function testUnwrapsPromisesWithKeys() - { - $promises = [ - 'foo' => new FulfilledPromise('a'), - 'bar' => new FulfilledPromise('b'), - ]; - $this->assertEquals([ - 'foo' => 'a', - 'bar' => 'b' - ], \GuzzleHttp\Promise\unwrap($promises)); - } - - public function testAllAggregatesSortedArray() - { - $a = new Promise(); - $b = new Promise(); - $c = new Promise(); - $d = \GuzzleHttp\Promise\all([$a, $b, $c]); - $b->resolve('b'); - $a->resolve('a'); - $c->resolve('c'); - $d->then( - function ($value) use (&$result) { $result = $value; }, - function ($reason) use (&$result) { $result = $reason; } - ); - P\queue()->run(); - $this->assertEquals(['a', 'b', 'c'], $result); - } - - public function testAllThrowsWhenAnyRejected() - { - $a = new Promise(); - $b = new Promise(); - $c = new Promise(); - $d = \GuzzleHttp\Promise\all([$a, $b, $c]); - $b->resolve('b'); - $a->reject('fail'); - $c->resolve('c'); - $d->then( - function ($value) use (&$result) { $result = $value; }, - function ($reason) use (&$result) { $result = $reason; } - ); - P\queue()->run(); - $this->assertEquals('fail', $result); - } - - public function testSomeAggregatesSortedArrayWithMax() - { - $a = new Promise(); - $b = new Promise(); - $c = new Promise(); - $d = \GuzzleHttp\Promise\some(2, [$a, $b, $c]); - $b->resolve('b'); - $c->resolve('c'); - $a->resolve('a'); - $d->then(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals(['b', 'c'], $result); - } - - public function testSomeRejectsWhenTooManyRejections() - { - $a = new Promise(); - $b = new Promise(); - $d = \GuzzleHttp\Promise\some(2, [$a, $b]); - $a->reject('bad'); - $b->resolve('good'); - P\queue()->run(); - $this->assertEquals($a::REJECTED, $d->getState()); - $d->then(null, function ($reason) use (&$called) { - $called = $reason; - }); - P\queue()->run(); - $this->assertInstanceOf('GuzzleHttp\Promise\AggregateException', $called); - $this->assertContains('bad', $called->getReason()); - } - - public function testCanWaitUntilSomeCountIsSatisfied() - { - $a = new Promise(function () use (&$a) { $a->resolve('a'); }); - $b = new Promise(function () use (&$b) { $b->resolve('b'); }); - $c = new Promise(function () use (&$c) { $c->resolve('c'); }); - $d = \GuzzleHttp\Promise\some(2, [$a, $b, $c]); - $this->assertEquals(['a', 'b'], $d->wait()); - } - - /** - * @expectedException \GuzzleHttp\Promise\AggregateException - * @expectedExceptionMessage Not enough promises to fulfill count - */ - public function testThrowsIfImpossibleToWaitForSomeCount() - { - $a = new Promise(function () use (&$a) { $a->resolve('a'); }); - $d = \GuzzleHttp\Promise\some(2, [$a]); - $d->wait(); - } - - /** - * @expectedException \GuzzleHttp\Promise\AggregateException - * @expectedExceptionMessage Not enough promises to fulfill count - */ - public function testThrowsIfResolvedWithoutCountTotalResults() - { - $a = new Promise(); - $b = new Promise(); - $d = \GuzzleHttp\Promise\some(3, [$a, $b]); - $a->resolve('a'); - $b->resolve('b'); - $d->wait(); - } - - public function testAnyReturnsFirstMatch() - { - $a = new Promise(); - $b = new Promise(); - $c = \GuzzleHttp\Promise\any([$a, $b]); - $b->resolve('b'); - $a->resolve('a'); - //P\queue()->run(); - //$this->assertEquals('fulfilled', $c->getState()); - $c->then(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals('b', $result); - } - - public function testSettleFulfillsWithFulfilledAndRejected() - { - $a = new Promise(); - $b = new Promise(); - $c = new Promise(); - $d = \GuzzleHttp\Promise\settle([$a, $b, $c]); - $b->resolve('b'); - $c->resolve('c'); - $a->reject('a'); - P\queue()->run(); - $this->assertEquals('fulfilled', $d->getState()); - $d->then(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals([ - ['state' => 'rejected', 'reason' => 'a'], - ['state' => 'fulfilled', 'value' => 'b'], - ['state' => 'fulfilled', 'value' => 'c'] - ], $result); - } - - public function testCanInspectFulfilledPromise() - { - $p = new FulfilledPromise('foo'); - $this->assertEquals([ - 'state' => 'fulfilled', - 'value' => 'foo' - ], \GuzzleHttp\Promise\inspect($p)); - } - - public function testCanInspectRejectedPromise() - { - $p = new RejectedPromise('foo'); - $this->assertEquals([ - 'state' => 'rejected', - 'reason' => 'foo' - ], \GuzzleHttp\Promise\inspect($p)); - } - - public function testCanInspectRejectedPromiseWithNormalException() - { - $e = new \Exception('foo'); - $p = new RejectedPromise($e); - $this->assertEquals([ - 'state' => 'rejected', - 'reason' => $e - ], \GuzzleHttp\Promise\inspect($p)); - } - - public function testCallsEachLimit() - { - $p = new Promise(); - $aggregate = \GuzzleHttp\Promise\each_limit($p, 2); - $p->resolve('a'); - P\queue()->run(); - $this->assertEquals($p::FULFILLED, $aggregate->getState()); - } - - public function testEachLimitAllRejectsOnFailure() - { - $p = [new FulfilledPromise('a'), new RejectedPromise('b')]; - $aggregate = \GuzzleHttp\Promise\each_limit_all($p, 2); - P\queue()->run(); - $this->assertEquals(P\PromiseInterface::REJECTED, $aggregate->getState()); - $result = \GuzzleHttp\Promise\inspect($aggregate); - $this->assertEquals('b', $result['reason']); - } - - public function testIterForReturnsIterator() - { - $iter = new \ArrayIterator(); - $this->assertSame($iter, \GuzzleHttp\Promise\iter_for($iter)); - } - - public function testKnowsIfFulfilled() - { - $p = new FulfilledPromise(null); - $this->assertTrue(P\is_fulfilled($p)); - $this->assertFalse(P\is_rejected($p)); - } - - public function testKnowsIfRejected() - { - $p = new RejectedPromise(null); - $this->assertTrue(P\is_rejected($p)); - $this->assertFalse(P\is_fulfilled($p)); - } - - public function testKnowsIfSettled() - { - $p = new RejectedPromise(null); - $this->assertTrue(P\is_settled($p)); - $p = new Promise(); - $this->assertFalse(P\is_settled($p)); - } - - public function testReturnsTrampoline() - { - $this->assertInstanceOf('GuzzleHttp\Promise\TaskQueue', P\queue()); - $this->assertSame(P\queue(), P\queue()); - } - - public function testCanScheduleThunk() - { - $tramp = P\queue(); - $promise = P\task(function () { return 'Hi!'; }); - $c = null; - $promise->then(function ($v) use (&$c) { $c = $v; }); - $this->assertNull($c); - $tramp->run(); - $this->assertEquals('Hi!', $c); - } - - public function testCanScheduleThunkWithRejection() - { - $tramp = P\queue(); - $promise = P\task(function () { throw new \Exception('Hi!'); }); - $c = null; - $promise->otherwise(function ($v) use (&$c) { $c = $v; }); - $this->assertNull($c); - $tramp->run(); - $this->assertEquals('Hi!', $c->getMessage()); - } - - public function testCanScheduleThunkWithWait() - { - $tramp = P\queue(); - $promise = P\task(function () { return 'a'; }); - $this->assertEquals('a', $promise->wait()); - $tramp->run(); - } - - public function testYieldsFromCoroutine() - { - $promise = P\coroutine(function () { - $value = (yield new P\FulfilledPromise('a')); - yield $value . 'b'; - }); - $promise->then(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals('ab', $result); - } - - public function testCanCatchExceptionsInCoroutine() - { - $promise = P\coroutine(function () { - try { - yield new P\RejectedPromise('a'); - $this->fail('Should have thrown into the coroutine!'); - } catch (P\RejectionException $e) { - $value = (yield new P\FulfilledPromise($e->getReason())); - yield $value . 'b'; - } - }); - $promise->then(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals(P\PromiseInterface::FULFILLED, $promise->getState()); - $this->assertEquals('ab', $result); - } - - public function testRejectsParentExceptionWhenException() - { - $promise = P\coroutine(function () { - yield new P\FulfilledPromise(0); - throw new \Exception('a'); - }); - $promise->then( - function () { $this->fail(); }, - function ($reason) use (&$result) { $result = $reason; } - ); - P\queue()->run(); - $this->assertInstanceOf('Exception', $result); - $this->assertEquals('a', $result->getMessage()); - } - - public function testCanRejectFromRejectionCallback() - { - $promise = P\coroutine(function () { - yield new P\FulfilledPromise(0); - yield new P\RejectedPromise('no!'); - }); - $promise->then( - function () { $this->fail(); }, - function ($reason) use (&$result) { $result = $reason; } - ); - P\queue()->run(); - $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $result); - $this->assertEquals('no!', $result->getReason()); - } - - public function testCanAsyncReject() - { - $rej = new P\Promise(); - $promise = P\coroutine(function () use ($rej) { - yield new P\FulfilledPromise(0); - yield $rej; - }); - $promise->then( - function () { $this->fail(); }, - function ($reason) use (&$result) { $result = $reason; } - ); - $rej->reject('no!'); - P\queue()->run(); - $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $result); - $this->assertEquals('no!', $result->getReason()); - } - - public function testCanCatchAndThrowOtherException() - { - $promise = P\coroutine(function () { - try { - yield new P\RejectedPromise('a'); - $this->fail('Should have thrown into the coroutine!'); - } catch (P\RejectionException $e) { - throw new \Exception('foo'); - } - }); - $promise->otherwise(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals(P\PromiseInterface::REJECTED, $promise->getState()); - $this->assertContains('foo', $result->getMessage()); - } - - public function testCanCatchAndYieldOtherException() - { - $promise = P\coroutine(function () { - try { - yield new P\RejectedPromise('a'); - $this->fail('Should have thrown into the coroutine!'); - } catch (P\RejectionException $e) { - yield new P\RejectedPromise('foo'); - } - }); - $promise->otherwise(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals(P\PromiseInterface::REJECTED, $promise->getState()); - $this->assertContains('foo', $result->getMessage()); - } - - public function createLotsOfSynchronousPromise() - { - return P\coroutine(function () { - $value = 0; - for ($i = 0; $i < 1000; $i++) { - $value = (yield new P\FulfilledPromise($i)); - } - yield $value; - }); - } - - public function testLotsOfSynchronousDoesNotBlowStack() - { - $promise = $this->createLotsOfSynchronousPromise(); - $promise->then(function ($v) use (&$r) { $r = $v; }); - P\queue()->run(); - $this->assertEquals(999, $r); - } - - public function testLotsOfSynchronousWaitDoesNotBlowStack() - { - $promise = $this->createLotsOfSynchronousPromise(); - $promise->then(function ($v) use (&$r) { $r = $v; }); - $this->assertEquals(999, $promise->wait()); - $this->assertEquals(999, $r); - } - - private function createLotsOfFlappingPromise() - { - return P\coroutine(function () { - $value = 0; - for ($i = 0; $i < 1000; $i++) { - try { - if ($i % 2) { - $value = (yield new P\FulfilledPromise($i)); - } else { - $value = (yield new P\RejectedPromise($i)); - } - } catch (\Exception $e) { - $value = (yield new P\FulfilledPromise($i)); - } - } - yield $value; - }); - } - - public function testLotsOfTryCatchingDoesNotBlowStack() - { - $promise = $this->createLotsOfFlappingPromise(); - $promise->then(function ($v) use (&$r) { $r = $v; }); - P\queue()->run(); - $this->assertEquals(999, $r); - } - - public function testLotsOfTryCatchingWaitingDoesNotBlowStack() - { - $promise = $this->createLotsOfFlappingPromise(); - $promise->then(function ($v) use (&$r) { $r = $v; }); - $this->assertEquals(999, $promise->wait()); - $this->assertEquals(999, $r); - } - - public function testAsyncPromisesWithCorrectlyYieldedValues() - { - $promises = [ - new P\Promise(), - new P\Promise(), - new P\Promise() - ]; - - $promise = P\coroutine(function () use ($promises) { - $value = null; - $this->assertEquals('skip', (yield new P\FulfilledPromise('skip'))); - foreach ($promises as $idx => $p) { - $value = (yield $p); - $this->assertEquals($value, $idx); - $this->assertEquals('skip', (yield new P\FulfilledPromise('skip'))); - } - $this->assertEquals('skip', (yield new P\FulfilledPromise('skip'))); - yield $value; - }); - - $promises[0]->resolve(0); - $promises[1]->resolve(1); - $promises[2]->resolve(2); - - $promise->then(function ($v) use (&$r) { $r = $v; }); - P\queue()->run(); - $this->assertEquals(2, $r); - } - - public function testYieldFinalWaitablePromise() - { - $p1 = new P\Promise(function () use (&$p1) { - $p1->resolve('skip me'); - }); - $p2 = new P\Promise(function () use (&$p2) { - $p2->resolve('hello!'); - }); - $co = P\coroutine(function() use ($p1, $p2) { - yield $p1; - yield $p2; - }); - P\queue()->run(); - $this->assertEquals('hello!', $co->wait()); - } - - public function testCanYieldFinalPendingPromise() - { - $p1 = new P\Promise(); - $p2 = new P\Promise(); - $co = P\coroutine(function() use ($p1, $p2) { - yield $p1; - yield $p2; - }); - $p1->resolve('a'); - $p2->resolve('b'); - $co->then(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals('b', $result); - } - - public function testCanNestYieldsAndFailures() - { - $p1 = new P\Promise(); - $p2 = new P\Promise(); - $p3 = new P\Promise(); - $p4 = new P\Promise(); - $p5 = new P\Promise(); - $co = P\coroutine(function() use ($p1, $p2, $p3, $p4, $p5) { - try { - yield $p1; - } catch (\Exception $e) { - yield $p2; - try { - yield $p3; - yield $p4; - } catch (\Exception $e) { - yield $p5; - } - } - }); - $p1->reject('a'); - $p2->resolve('b'); - $p3->resolve('c'); - $p4->reject('d'); - $p5->resolve('e'); - $co->then(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals('e', $result); - } - - public function testCanYieldErrorsAndSuccessesWithoutRecursion() - { - $promises = []; - for ($i = 0; $i < 20; $i++) { - $promises[] = new P\Promise(); - } - - $co = P\coroutine(function() use ($promises) { - for ($i = 0; $i < 20; $i += 4) { - try { - yield $promises[$i]; - yield $promises[$i + 1]; - } catch (\Exception $e) { - yield $promises[$i + 2]; - yield $promises[$i + 3]; - } - } - }); - - for ($i = 0; $i < 20; $i += 4) { - $promises[$i]->resolve($i); - $promises[$i + 1]->reject($i + 1); - $promises[$i + 2]->resolve($i + 2); - $promises[$i + 3]->resolve($i + 3); - } - - $co->then(function ($value) use (&$result) { $result = $value; }); - P\queue()->run(); - $this->assertEquals('19', $result); - } - - public function testCanWaitOnPromiseAfterFulfilled() - { - $f = function () { - static $i = 0; - $i++; - return $p = new P\Promise(function () use (&$p, $i) { - $p->resolve($i . '-bar'); - }); - }; - - $promises = []; - for ($i = 0; $i < 20; $i++) { - $promises[] = $f(); - } - - $p = P\coroutine(function () use ($promises) { - yield new P\FulfilledPromise('foo!'); - foreach ($promises as $promise) { - yield $promise; - } - }); - - $this->assertEquals('20-bar', $p->wait()); - } - - public function testCanWaitOnErroredPromises() - { - $p1 = new P\Promise(function () use (&$p1) { $p1->reject('a'); }); - $p2 = new P\Promise(function () use (&$p2) { $p2->resolve('b'); }); - $p3 = new P\Promise(function () use (&$p3) { $p3->resolve('c'); }); - $p4 = new P\Promise(function () use (&$p4) { $p4->reject('d'); }); - $p5 = new P\Promise(function () use (&$p5) { $p5->resolve('e'); }); - $p6 = new P\Promise(function () use (&$p6) { $p6->reject('f'); }); - - $co = P\coroutine(function() use ($p1, $p2, $p3, $p4, $p5, $p6) { - try { - yield $p1; - } catch (\Exception $e) { - yield $p2; - try { - yield $p3; - yield $p4; - } catch (\Exception $e) { - yield $p5; - yield $p6; - } - } - }); - - $res = P\inspect($co); - $this->assertEquals('f', $res['reason']); - } - - public function testCoroutineOtherwiseIntegrationTest() - { - $a = new P\Promise(); - $b = new P\Promise(); - $promise = P\coroutine(function () use ($a, $b) { - // Execute the pool of commands concurrently, and process errors. - yield $a; - yield $b; - })->otherwise(function (\Exception $e) { - // Throw errors from the operations as a specific Multipart error. - throw new \OutOfBoundsException('a', 0, $e); - }); - $a->resolve('a'); - $b->reject('b'); - $reason = P\inspect($promise)['reason']; - $this->assertInstanceOf('OutOfBoundsException', $reason); - $this->assertInstanceOf('GuzzleHttp\Promise\RejectionException', $reason->getPrevious()); - } -} diff --git a/vendor/guzzlehttp/psr7/.gitignore b/vendor/guzzlehttp/psr7/.gitignore deleted file mode 100644 index 83ec41e24..000000000 --- a/vendor/guzzlehttp/psr7/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -phpunit.xml -composer.phar -composer.lock -composer-test.lock -vendor/ -build/artifacts/ -artifacts/ -docs/_build -docs/*.pyc -.idea -.DS_STORE diff --git a/vendor/guzzlehttp/psr7/.travis.yml b/vendor/guzzlehttp/psr7/.travis.yml deleted file mode 100644 index b88f8da27..000000000 --- a/vendor/guzzlehttp/psr7/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: php - -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - hhvm - -sudo: false - -install: - - travis_retry composer install --no-interaction --prefer-source - -script: make test - -matrix: - allow_failures: - - php: hhvm - fast_finish: true diff --git a/vendor/guzzlehttp/psr7/CHANGELOG.md b/vendor/guzzlehttp/psr7/CHANGELOG.md deleted file mode 100644 index 0771a9aca..000000000 --- a/vendor/guzzlehttp/psr7/CHANGELOG.md +++ /dev/null @@ -1,70 +0,0 @@ -# CHANGELOG - -## 1.3.1 - 2016-06-25 - -* Fix `Uri::__toString` for network path references, e.g. `//example.org`. -* Fix missing lowercase normalization for host. -* Fix handling of URI components in case they are `'0'` in a lot of places, - e.g. as a user info password. -* Fix `Uri::withAddedHeader` to correctly merge headers with different case. -* Fix trimming of header values in `Uri::withAddedHeader`. Header values may - be surrounded by whitespace which should be ignored according to RFC 7230 - Section 3.2.4. This does not apply to header names. -* Fix `Uri::withAddedHeader` with an array of header values. -* Fix `Uri::resolve` when base path has no slash and handling of fragment. -* Fix handling of encoding in `Uri::with(out)QueryValue` so one can pass the - key/value both in encoded as well as decoded form to those methods. This is - consistent with withPath, withQuery etc. -* Fix `ServerRequest::withoutAttribute` when attribute value is null. - -## 1.3.0 - 2016-04-13 - -* Added remaining interfaces needed for full PSR7 compatibility - (ServerRequestInterface, UploadedFileInterface, etc.). -* Added support for stream_for from scalars. -* Can now extend Uri. -* Fixed a bug in validating request methods by making it more permissive. - -## 1.2.3 - 2016-02-18 - -* Fixed support in `GuzzleHttp\Psr7\CachingStream` for seeking forward on remote - streams, which can sometimes return fewer bytes than requested with `fread`. -* Fixed handling of gzipped responses with FNAME headers. - -## 1.2.2 - 2016-01-22 - -* Added support for URIs without any authority. -* Added support for HTTP 451 'Unavailable For Legal Reasons.' -* Added support for using '0' as a filename. -* Added support for including non-standard ports in Host headers. - -## 1.2.1 - 2015-11-02 - -* Now supporting negative offsets when seeking to SEEK_END. - -## 1.2.0 - 2015-08-15 - -* Body as `"0"` is now properly added to a response. -* Now allowing forward seeking in CachingStream. -* Now properly parsing HTTP requests that contain proxy targets in - `parse_request`. -* functions.php is now conditionally required. -* user-info is no longer dropped when resolving URIs. - -## 1.1.0 - 2015-06-24 - -* URIs can now be relative. -* `multipart/form-data` headers are now overridden case-insensitively. -* URI paths no longer encode the following characters because they are allowed - in URIs: "(", ")", "*", "!", "'" -* A port is no longer added to a URI when the scheme is missing and no port is - present. - -## 1.0.0 - 2015-05-19 - -Initial release. - -Currently unsupported: - -- `Psr\Http\Message\ServerRequestInterface` -- `Psr\Http\Message\UploadedFileInterface` diff --git a/vendor/guzzlehttp/psr7/LICENSE b/vendor/guzzlehttp/psr7/LICENSE deleted file mode 100644 index 581d95f92..000000000 --- a/vendor/guzzlehttp/psr7/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2015 Michael Dowling, https://github.com/mtdowling - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/guzzlehttp/psr7/Makefile b/vendor/guzzlehttp/psr7/Makefile deleted file mode 100644 index 8b00b43e6..000000000 --- a/vendor/guzzlehttp/psr7/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -all: clean test - -test: - vendor/bin/phpunit $(TEST) - -coverage: - vendor/bin/phpunit --coverage-html=artifacts/coverage $(TEST) - -view-coverage: - open artifacts/coverage/index.html - -check-tag: - $(if $(TAG),,$(error TAG is not defined. Pass via "make tag TAG=4.2.1")) - -tag: check-tag - @echo Tagging $(TAG) - chag update $(TAG) - git commit -a -m '$(TAG) release' - chag tag - @echo "Release has been created. Push using 'make release'" - @echo "Changes made in the release commit" - git diff HEAD~1 HEAD - -release: check-tag - git push origin master - git push origin $(TAG) - -clean: - rm -rf artifacts/* diff --git a/vendor/guzzlehttp/psr7/README.md b/vendor/guzzlehttp/psr7/README.md deleted file mode 100644 index 2642164ff..000000000 --- a/vendor/guzzlehttp/psr7/README.md +++ /dev/null @@ -1,569 +0,0 @@ -# PSR-7 Message Implementation - -This repository contains a full [PSR-7](http://www.php-fig.org/psr/psr-7/) -message implementation, several stream decorators, and some helpful -functionality like query string parsing. - - -[![Build Status](https://travis-ci.org/guzzle/psr7.svg?branch=master)](https://travis-ci.org/guzzle/psr7) - - -# Stream implementation - -This package comes with a number of stream implementations and stream -decorators. - - -## AppendStream - -`GuzzleHttp\Psr7\AppendStream` - -Reads from multiple streams, one after the other. - -```php -use GuzzleHttp\Psr7; - -$a = Psr7\stream_for('abc, '); -$b = Psr7\stream_for('123.'); -$composed = new Psr7\AppendStream([$a, $b]); - -$composed->addStream(Psr7\stream_for(' Above all listen to me')); - -echo $composed; // abc, 123. Above all listen to me. -``` - - -## BufferStream - -`GuzzleHttp\Psr7\BufferStream` - -Provides a buffer stream that can be written to fill a buffer, and read -from to remove bytes from the buffer. - -This stream returns a "hwm" metadata value that tells upstream consumers -what the configured high water mark of the stream is, or the maximum -preferred size of the buffer. - -```php -use GuzzleHttp\Psr7; - -// When more than 1024 bytes are in the buffer, it will begin returning -// false to writes. This is an indication that writers should slow down. -$buffer = new Psr7\BufferStream(1024); -``` - - -## CachingStream - -The CachingStream is used to allow seeking over previously read bytes on -non-seekable streams. This can be useful when transferring a non-seekable -entity body fails due to needing to rewind the stream (for example, resulting -from a redirect). Data that is read from the remote stream will be buffered in -a PHP temp stream so that previously read bytes are cached first in memory, -then on disk. - -```php -use GuzzleHttp\Psr7; - -$original = Psr7\stream_for(fopen('http://www.google.com', 'r')); -$stream = new Psr7\CachingStream($original); - -$stream->read(1024); -echo $stream->tell(); -// 1024 - -$stream->seek(0); -echo $stream->tell(); -// 0 -``` - - -## DroppingStream - -`GuzzleHttp\Psr7\DroppingStream` - -Stream decorator that begins dropping data once the size of the underlying -stream becomes too full. - -```php -use GuzzleHttp\Psr7; - -// Create an empty stream -$stream = Psr7\stream_for(); - -// Start dropping data when the stream has more than 10 bytes -$dropping = new Psr7\DroppingStream($stream, 10); - -$dropping->write('01234567890123456789'); -echo $stream; // 0123456789 -``` - - -## FnStream - -`GuzzleHttp\Psr7\FnStream` - -Compose stream implementations based on a hash of functions. - -Allows for easy testing and extension of a provided stream without needing -to create a concrete class for a simple extension point. - -```php - -use GuzzleHttp\Psr7; - -$stream = Psr7\stream_for('hi'); -$fnStream = Psr7\FnStream::decorate($stream, [ - 'rewind' => function () use ($stream) { - echo 'About to rewind - '; - $stream->rewind(); - echo 'rewound!'; - } -]); - -$fnStream->rewind(); -// Outputs: About to rewind - rewound! -``` - - -## InflateStream - -`GuzzleHttp\Psr7\InflateStream` - -Uses PHP's zlib.inflate filter to inflate deflate or gzipped content. - -This stream decorator skips the first 10 bytes of the given stream to remove -the gzip header, converts the provided stream to a PHP stream resource, -then appends the zlib.inflate filter. The stream is then converted back -to a Guzzle stream resource to be used as a Guzzle stream. - - -## LazyOpenStream - -`GuzzleHttp\Psr7\LazyOpenStream` - -Lazily reads or writes to a file that is opened only after an IO operation -take place on the stream. - -```php -use GuzzleHttp\Psr7; - -$stream = new Psr7\LazyOpenStream('/path/to/file', 'r'); -// The file has not yet been opened... - -echo $stream->read(10); -// The file is opened and read from only when needed. -``` - - -## LimitStream - -`GuzzleHttp\Psr7\LimitStream` - -LimitStream can be used to read a subset or slice of an existing stream object. -This can be useful for breaking a large file into smaller pieces to be sent in -chunks (e.g. Amazon S3's multipart upload API). - -```php -use GuzzleHttp\Psr7; - -$original = Psr7\stream_for(fopen('/tmp/test.txt', 'r+')); -echo $original->getSize(); -// >>> 1048576 - -// Limit the size of the body to 1024 bytes and start reading from byte 2048 -$stream = new Psr7\LimitStream($original, 1024, 2048); -echo $stream->getSize(); -// >>> 1024 -echo $stream->tell(); -// >>> 0 -``` - - -## MultipartStream - -`GuzzleHttp\Psr7\MultipartStream` - -Stream that when read returns bytes for a streaming multipart or -multipart/form-data stream. - - -## NoSeekStream - -`GuzzleHttp\Psr7\NoSeekStream` - -NoSeekStream wraps a stream and does not allow seeking. - -```php -use GuzzleHttp\Psr7; - -$original = Psr7\stream_for('foo'); -$noSeek = new Psr7\NoSeekStream($original); - -echo $noSeek->read(3); -// foo -var_export($noSeek->isSeekable()); -// false -$noSeek->seek(0); -var_export($noSeek->read(3)); -// NULL -``` - - -## PumpStream - -`GuzzleHttp\Psr7\PumpStream` - -Provides a read only stream that pumps data from a PHP callable. - -When invoking the provided callable, the PumpStream will pass the amount of -data requested to read to the callable. The callable can choose to ignore -this value and return fewer or more bytes than requested. Any extra data -returned by the provided callable is buffered internally until drained using -the read() function of the PumpStream. The provided callable MUST return -false when there is no more data to read. - - -## Implementing stream decorators - -Creating a stream decorator is very easy thanks to the -`GuzzleHttp\Psr7\StreamDecoratorTrait`. This trait provides methods that -implement `Psr\Http\Message\StreamInterface` by proxying to an underlying -stream. Just `use` the `StreamDecoratorTrait` and implement your custom -methods. - -For example, let's say we wanted to call a specific function each time the last -byte is read from a stream. This could be implemented by overriding the -`read()` method. - -```php -use Psr\Http\Message\StreamInterface; -use GuzzleHttp\Psr7\StreamDecoratorTrait; - -class EofCallbackStream implements StreamInterface -{ - use StreamDecoratorTrait; - - private $callback; - - public function __construct(StreamInterface $stream, callable $cb) - { - $this->stream = $stream; - $this->callback = $cb; - } - - public function read($length) - { - $result = $this->stream->read($length); - - // Invoke the callback when EOF is hit. - if ($this->eof()) { - call_user_func($this->callback); - } - - return $result; - } -} -``` - -This decorator could be added to any existing stream and used like so: - -```php -use GuzzleHttp\Psr7; - -$original = Psr7\stream_for('foo'); - -$eofStream = new EofCallbackStream($original, function () { - echo 'EOF!'; -}); - -$eofStream->read(2); -$eofStream->read(1); -// echoes "EOF!" -$eofStream->seek(0); -$eofStream->read(3); -// echoes "EOF!" -``` - - -## PHP StreamWrapper - -You can use the `GuzzleHttp\Psr7\StreamWrapper` class if you need to use a -PSR-7 stream as a PHP stream resource. - -Use the `GuzzleHttp\Psr7\StreamWrapper::getResource()` method to create a PHP -stream from a PSR-7 stream. - -```php -use GuzzleHttp\Psr7\StreamWrapper; - -$stream = GuzzleHttp\Psr7\stream_for('hello!'); -$resource = StreamWrapper::getResource($stream); -echo fread($resource, 6); // outputs hello! -``` - - -# Function API - -There are various functions available under the `GuzzleHttp\Psr7` namespace. - - -## `function str` - -`function str(MessageInterface $message)` - -Returns the string representation of an HTTP message. - -```php -$request = new GuzzleHttp\Psr7\Request('GET', 'http://example.com'); -echo GuzzleHttp\Psr7\str($request); -``` - - -## `function uri_for` - -`function uri_for($uri)` - -This function accepts a string or `Psr\Http\Message\UriInterface` and returns a -UriInterface for the given value. If the value is already a `UriInterface`, it -is returned as-is. - -```php -$uri = GuzzleHttp\Psr7\uri_for('http://example.com'); -assert($uri === GuzzleHttp\Psr7\uri_for($uri)); -``` - - -## `function stream_for` - -`function stream_for($resource = '', array $options = [])` - -Create a new stream based on the input type. - -Options is an associative array that can contain the following keys: - -* - metadata: Array of custom metadata. -* - size: Size of the stream. - -This method accepts the following `$resource` types: - -- `Psr\Http\Message\StreamInterface`: Returns the value as-is. -- `string`: Creates a stream object that uses the given string as the contents. -- `resource`: Creates a stream object that wraps the given PHP stream resource. -- `Iterator`: If the provided value implements `Iterator`, then a read-only - stream object will be created that wraps the given iterable. Each time the - stream is read from, data from the iterator will fill a buffer and will be - continuously called until the buffer is equal to the requested read size. - Subsequent read calls will first read from the buffer and then call `next` - on the underlying iterator until it is exhausted. -- `object` with `__toString()`: If the object has the `__toString()` method, - the object will be cast to a string and then a stream will be returned that - uses the string value. -- `NULL`: When `null` is passed, an empty stream object is returned. -- `callable` When a callable is passed, a read-only stream object will be - created that invokes the given callable. The callable is invoked with the - number of suggested bytes to read. The callable can return any number of - bytes, but MUST return `false` when there is no more data to return. The - stream object that wraps the callable will invoke the callable until the - number of requested bytes are available. Any additional bytes will be - buffered and used in subsequent reads. - -```php -$stream = GuzzleHttp\Psr7\stream_for('foo'); -$stream = GuzzleHttp\Psr7\stream_for(fopen('/path/to/file', 'r')); - -$generator function ($bytes) { - for ($i = 0; $i < $bytes; $i++) { - yield ' '; - } -} - -$stream = GuzzleHttp\Psr7\stream_for($generator(100)); -``` - - -## `function parse_header` - -`function parse_header($header)` - -Parse an array of header values containing ";" separated data into an array of -associative arrays representing the header key value pair data of the header. -When a parameter does not contain a value, but just contains a key, this -function will inject a key with a '' string value. - - -## `function normalize_header` - -`function normalize_header($header)` - -Converts an array of header values that may contain comma separated headers -into an array of headers with no comma separated values. - - -## `function modify_request` - -`function modify_request(RequestInterface $request, array $changes)` - -Clone and modify a request with the given changes. This method is useful for -reducing the number of clones needed to mutate a message. - -The changes can be one of: - -- method: (string) Changes the HTTP method. -- set_headers: (array) Sets the given headers. -- remove_headers: (array) Remove the given headers. -- body: (mixed) Sets the given body. -- uri: (UriInterface) Set the URI. -- query: (string) Set the query string value of the URI. -- version: (string) Set the protocol version. - - -## `function rewind_body` - -`function rewind_body(MessageInterface $message)` - -Attempts to rewind a message body and throws an exception on failure. The body -of the message will only be rewound if a call to `tell()` returns a value other -than `0`. - - -## `function try_fopen` - -`function try_fopen($filename, $mode)` - -Safely opens a PHP stream resource using a filename. - -When fopen fails, PHP normally raises a warning. This function adds an error -handler that checks for errors and throws an exception instead. - - -## `function copy_to_string` - -`function copy_to_string(StreamInterface $stream, $maxLen = -1)` - -Copy the contents of a stream into a string until the given number of bytes -have been read. - - -## `function copy_to_stream` - -`function copy_to_stream(StreamInterface $source, StreamInterface $dest, $maxLen = -1)` - -Copy the contents of a stream into another stream until the given number of -bytes have been read. - - -## `function hash` - -`function hash(StreamInterface $stream, $algo, $rawOutput = false)` - -Calculate a hash of a Stream. This method reads the entire stream to calculate -a rolling hash (based on PHP's hash_init functions). - - -## `function readline` - -`function readline(StreamInterface $stream, $maxLength = null)` - -Read a line from the stream up to the maximum allowed buffer length. - - -## `function parse_request` - -`function parse_request($message)` - -Parses a request message string into a request object. - - -## `function parse_response` - -`function parse_response($message)` - -Parses a response message string into a response object. - - -## `function parse_query` - -`function parse_query($str, $urlEncoding = true)` - -Parse a query string into an associative array. - -If multiple values are found for the same key, the value of that key value pair -will become an array. This function does not parse nested PHP style arrays into -an associative array (e.g., `foo[a]=1&foo[b]=2` will be parsed into -`['foo[a]' => '1', 'foo[b]' => '2']`). - - -## `function build_query` - -`function build_query(array $params, $encoding = PHP_QUERY_RFC3986)` - -Build a query string from an array of key value pairs. - -This function can use the return value of parse_query() to build a query string. -This function does not modify the provided keys when an array is encountered -(like http_build_query would). - - -## `function mimetype_from_filename` - -`function mimetype_from_filename($filename)` - -Determines the mimetype of a file by looking at its extension. - - -## `function mimetype_from_extension` - -`function mimetype_from_extension($extension)` - -Maps a file extensions to a mimetype. - - -# Static URI methods - -The `GuzzleHttp\Psr7\Uri` class has several static methods to manipulate URIs. - - -## `GuzzleHttp\Psr7\Uri::removeDotSegments` - -`public static function removeDotSegments(string $path): string` - -Removes dot segments from a path and returns the new path. - -See http://tools.ietf.org/html/rfc3986#section-5.2.4 - - -## `GuzzleHttp\Psr7\Uri::resolve` - -`public static function resolve(UriInterface $base, $rel): UriInterface` - -Resolve a base URI with a relative URI and return a new URI. - -See http://tools.ietf.org/html/rfc3986#section-5 - - -## `GuzzleHttp\Psr7\Uri::withQueryValue` - -`public static function withQueryValue(UriInterface $uri, $key, $value): UriInterface` - -Create a new URI with a specific query string value. - -Any existing query string values that exactly match the provided key are -removed and replaced with the given key value pair. - - -## `GuzzleHttp\Psr7\Uri::withoutQueryValue` - -`public static function withoutQueryValue(UriInterface $uri, $key): UriInterface` - -Create a new URI with a specific query string value removed. - -Any existing query string values that exactly match the provided key are -removed. - - -## `GuzzleHttp\Psr7\Uri::fromParts` - -`public static function fromParts(array $parts): UriInterface` - -Create a `GuzzleHttp\Psr7\Uri` object from a hash of `parse_url` parts. diff --git a/vendor/guzzlehttp/psr7/composer.json b/vendor/guzzlehttp/psr7/composer.json deleted file mode 100644 index fdfb97bdd..000000000 --- a/vendor/guzzlehttp/psr7/composer.json +++ /dev/null @@ -1,35 +0,0 @@ -{ - "name": "guzzlehttp/psr7", - "type": "library", - "description": "PSR-7 message implementation", - "keywords": ["message", "stream", "http", "uri"], - "license": "MIT", - "authors": [ - { - "name": "Michael Dowling", - "email": "mtdowling@gmail.com", - "homepage": "https://github.com/mtdowling" - } - ], - "require": { - "php": ">=5.4.0", - "psr/http-message": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "provide": { - "psr/http-message-implementation": "1.0" - }, - "autoload": { - "psr-4": { - "GuzzleHttp\\Psr7\\": "src/" - }, - "files": ["src/functions_include.php"] - }, - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - } -} diff --git a/vendor/guzzlehttp/psr7/phpunit.xml.dist b/vendor/guzzlehttp/psr7/phpunit.xml.dist deleted file mode 100644 index 500cd53a0..000000000 --- a/vendor/guzzlehttp/psr7/phpunit.xml.dist +++ /dev/null @@ -1,17 +0,0 @@ - - - - - tests - - - - - src - - src/ - - - - diff --git a/vendor/guzzlehttp/psr7/src/AppendStream.php b/vendor/guzzlehttp/psr7/src/AppendStream.php deleted file mode 100644 index 23039fd79..000000000 --- a/vendor/guzzlehttp/psr7/src/AppendStream.php +++ /dev/null @@ -1,233 +0,0 @@ -addStream($stream); - } - } - - public function __toString() - { - try { - $this->rewind(); - return $this->getContents(); - } catch (\Exception $e) { - return ''; - } - } - - /** - * Add a stream to the AppendStream - * - * @param StreamInterface $stream Stream to append. Must be readable. - * - * @throws \InvalidArgumentException if the stream is not readable - */ - public function addStream(StreamInterface $stream) - { - if (!$stream->isReadable()) { - throw new \InvalidArgumentException('Each stream must be readable'); - } - - // The stream is only seekable if all streams are seekable - if (!$stream->isSeekable()) { - $this->seekable = false; - } - - $this->streams[] = $stream; - } - - public function getContents() - { - return copy_to_string($this); - } - - /** - * Closes each attached stream. - * - * {@inheritdoc} - */ - public function close() - { - $this->pos = $this->current = 0; - - foreach ($this->streams as $stream) { - $stream->close(); - } - - $this->streams = []; - } - - /** - * Detaches each attached stream - * - * {@inheritdoc} - */ - public function detach() - { - $this->close(); - $this->detached = true; - } - - public function tell() - { - return $this->pos; - } - - /** - * Tries to calculate the size by adding the size of each stream. - * - * If any of the streams do not return a valid number, then the size of the - * append stream cannot be determined and null is returned. - * - * {@inheritdoc} - */ - public function getSize() - { - $size = 0; - - foreach ($this->streams as $stream) { - $s = $stream->getSize(); - if ($s === null) { - return null; - } - $size += $s; - } - - return $size; - } - - public function eof() - { - return !$this->streams || - ($this->current >= count($this->streams) - 1 && - $this->streams[$this->current]->eof()); - } - - public function rewind() - { - $this->seek(0); - } - - /** - * Attempts to seek to the given position. Only supports SEEK_SET. - * - * {@inheritdoc} - */ - public function seek($offset, $whence = SEEK_SET) - { - if (!$this->seekable) { - throw new \RuntimeException('This AppendStream is not seekable'); - } elseif ($whence !== SEEK_SET) { - throw new \RuntimeException('The AppendStream can only seek with SEEK_SET'); - } - - $this->pos = $this->current = 0; - - // Rewind each stream - foreach ($this->streams as $i => $stream) { - try { - $stream->rewind(); - } catch (\Exception $e) { - throw new \RuntimeException('Unable to seek stream ' - . $i . ' of the AppendStream', 0, $e); - } - } - - // Seek to the actual position by reading from each stream - while ($this->pos < $offset && !$this->eof()) { - $result = $this->read(min(8096, $offset - $this->pos)); - if ($result === '') { - break; - } - } - } - - /** - * Reads from all of the appended streams until the length is met or EOF. - * - * {@inheritdoc} - */ - public function read($length) - { - $buffer = ''; - $total = count($this->streams) - 1; - $remaining = $length; - $progressToNext = false; - - while ($remaining > 0) { - - // Progress to the next stream if needed. - if ($progressToNext || $this->streams[$this->current]->eof()) { - $progressToNext = false; - if ($this->current === $total) { - break; - } - $this->current++; - } - - $result = $this->streams[$this->current]->read($remaining); - - // Using a loose comparison here to match on '', false, and null - if ($result == null) { - $progressToNext = true; - continue; - } - - $buffer .= $result; - $remaining = $length - strlen($buffer); - } - - $this->pos += strlen($buffer); - - return $buffer; - } - - public function isReadable() - { - return true; - } - - public function isWritable() - { - return false; - } - - public function isSeekable() - { - return $this->seekable; - } - - public function write($string) - { - throw new \RuntimeException('Cannot write to an AppendStream'); - } - - public function getMetadata($key = null) - { - return $key ? null : []; - } -} diff --git a/vendor/guzzlehttp/psr7/src/BufferStream.php b/vendor/guzzlehttp/psr7/src/BufferStream.php deleted file mode 100644 index af4d4c227..000000000 --- a/vendor/guzzlehttp/psr7/src/BufferStream.php +++ /dev/null @@ -1,137 +0,0 @@ -hwm = $hwm; - } - - public function __toString() - { - return $this->getContents(); - } - - public function getContents() - { - $buffer = $this->buffer; - $this->buffer = ''; - - return $buffer; - } - - public function close() - { - $this->buffer = ''; - } - - public function detach() - { - $this->close(); - } - - public function getSize() - { - return strlen($this->buffer); - } - - public function isReadable() - { - return true; - } - - public function isWritable() - { - return true; - } - - public function isSeekable() - { - return false; - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - throw new \RuntimeException('Cannot seek a BufferStream'); - } - - public function eof() - { - return strlen($this->buffer) === 0; - } - - public function tell() - { - throw new \RuntimeException('Cannot determine the position of a BufferStream'); - } - - /** - * Reads data from the buffer. - */ - public function read($length) - { - $currentLength = strlen($this->buffer); - - if ($length >= $currentLength) { - // No need to slice the buffer because we don't have enough data. - $result = $this->buffer; - $this->buffer = ''; - } else { - // Slice up the result to provide a subset of the buffer. - $result = substr($this->buffer, 0, $length); - $this->buffer = substr($this->buffer, $length); - } - - return $result; - } - - /** - * Writes data to the buffer. - */ - public function write($string) - { - $this->buffer .= $string; - - // TODO: What should happen here? - if (strlen($this->buffer) >= $this->hwm) { - return false; - } - - return strlen($string); - } - - public function getMetadata($key = null) - { - if ($key == 'hwm') { - return $this->hwm; - } - - return $key ? null : []; - } -} diff --git a/vendor/guzzlehttp/psr7/src/CachingStream.php b/vendor/guzzlehttp/psr7/src/CachingStream.php deleted file mode 100644 index ed68f0861..000000000 --- a/vendor/guzzlehttp/psr7/src/CachingStream.php +++ /dev/null @@ -1,138 +0,0 @@ -remoteStream = $stream; - $this->stream = $target ?: new Stream(fopen('php://temp', 'r+')); - } - - public function getSize() - { - return max($this->stream->getSize(), $this->remoteStream->getSize()); - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - if ($whence == SEEK_SET) { - $byte = $offset; - } elseif ($whence == SEEK_CUR) { - $byte = $offset + $this->tell(); - } elseif ($whence == SEEK_END) { - $size = $this->remoteStream->getSize(); - if ($size === null) { - $size = $this->cacheEntireStream(); - } - $byte = $size + $offset; - } else { - throw new \InvalidArgumentException('Invalid whence'); - } - - $diff = $byte - $this->stream->getSize(); - - if ($diff > 0) { - // Read the remoteStream until we have read in at least the amount - // of bytes requested, or we reach the end of the file. - while ($diff > 0 && !$this->remoteStream->eof()) { - $this->read($diff); - $diff = $byte - $this->stream->getSize(); - } - } else { - // We can just do a normal seek since we've already seen this byte. - $this->stream->seek($byte); - } - } - - public function read($length) - { - // Perform a regular read on any previously read data from the buffer - $data = $this->stream->read($length); - $remaining = $length - strlen($data); - - // More data was requested so read from the remote stream - if ($remaining) { - // If data was written to the buffer in a position that would have - // been filled from the remote stream, then we must skip bytes on - // the remote stream to emulate overwriting bytes from that - // position. This mimics the behavior of other PHP stream wrappers. - $remoteData = $this->remoteStream->read( - $remaining + $this->skipReadBytes - ); - - if ($this->skipReadBytes) { - $len = strlen($remoteData); - $remoteData = substr($remoteData, $this->skipReadBytes); - $this->skipReadBytes = max(0, $this->skipReadBytes - $len); - } - - $data .= $remoteData; - $this->stream->write($remoteData); - } - - return $data; - } - - public function write($string) - { - // When appending to the end of the currently read stream, you'll want - // to skip bytes from being read from the remote stream to emulate - // other stream wrappers. Basically replacing bytes of data of a fixed - // length. - $overflow = (strlen($string) + $this->tell()) - $this->remoteStream->tell(); - if ($overflow > 0) { - $this->skipReadBytes += $overflow; - } - - return $this->stream->write($string); - } - - public function eof() - { - return $this->stream->eof() && $this->remoteStream->eof(); - } - - /** - * Close both the remote stream and buffer stream - */ - public function close() - { - $this->remoteStream->close() && $this->stream->close(); - } - - private function cacheEntireStream() - { - $target = new FnStream(['write' => 'strlen']); - copy_to_stream($this, $target); - - return $this->tell(); - } -} diff --git a/vendor/guzzlehttp/psr7/src/DroppingStream.php b/vendor/guzzlehttp/psr7/src/DroppingStream.php deleted file mode 100644 index 8935c80d7..000000000 --- a/vendor/guzzlehttp/psr7/src/DroppingStream.php +++ /dev/null @@ -1,42 +0,0 @@ -stream = $stream; - $this->maxLength = $maxLength; - } - - public function write($string) - { - $diff = $this->maxLength - $this->stream->getSize(); - - // Begin returning 0 when the underlying stream is too large. - if ($diff <= 0) { - return 0; - } - - // Write the stream or a subset of the stream if needed. - if (strlen($string) < $diff) { - return $this->stream->write($string); - } - - return $this->stream->write(substr($string, 0, $diff)); - } -} diff --git a/vendor/guzzlehttp/psr7/src/FnStream.php b/vendor/guzzlehttp/psr7/src/FnStream.php deleted file mode 100644 index cc9b4453f..000000000 --- a/vendor/guzzlehttp/psr7/src/FnStream.php +++ /dev/null @@ -1,149 +0,0 @@ -methods = $methods; - - // Create the functions on the class - foreach ($methods as $name => $fn) { - $this->{'_fn_' . $name} = $fn; - } - } - - /** - * Lazily determine which methods are not implemented. - * @throws \BadMethodCallException - */ - public function __get($name) - { - throw new \BadMethodCallException(str_replace('_fn_', '', $name) - . '() is not implemented in the FnStream'); - } - - /** - * The close method is called on the underlying stream only if possible. - */ - public function __destruct() - { - if (isset($this->_fn_close)) { - call_user_func($this->_fn_close); - } - } - - /** - * Adds custom functionality to an underlying stream by intercepting - * specific method calls. - * - * @param StreamInterface $stream Stream to decorate - * @param array $methods Hash of method name to a closure - * - * @return FnStream - */ - public static function decorate(StreamInterface $stream, array $methods) - { - // If any of the required methods were not provided, then simply - // proxy to the decorated stream. - foreach (array_diff(self::$slots, array_keys($methods)) as $diff) { - $methods[$diff] = [$stream, $diff]; - } - - return new self($methods); - } - - public function __toString() - { - return call_user_func($this->_fn___toString); - } - - public function close() - { - return call_user_func($this->_fn_close); - } - - public function detach() - { - return call_user_func($this->_fn_detach); - } - - public function getSize() - { - return call_user_func($this->_fn_getSize); - } - - public function tell() - { - return call_user_func($this->_fn_tell); - } - - public function eof() - { - return call_user_func($this->_fn_eof); - } - - public function isSeekable() - { - return call_user_func($this->_fn_isSeekable); - } - - public function rewind() - { - call_user_func($this->_fn_rewind); - } - - public function seek($offset, $whence = SEEK_SET) - { - call_user_func($this->_fn_seek, $offset, $whence); - } - - public function isWritable() - { - return call_user_func($this->_fn_isWritable); - } - - public function write($string) - { - return call_user_func($this->_fn_write, $string); - } - - public function isReadable() - { - return call_user_func($this->_fn_isReadable); - } - - public function read($length) - { - return call_user_func($this->_fn_read, $length); - } - - public function getContents() - { - return call_user_func($this->_fn_getContents); - } - - public function getMetadata($key = null) - { - return call_user_func($this->_fn_getMetadata, $key); - } -} diff --git a/vendor/guzzlehttp/psr7/src/InflateStream.php b/vendor/guzzlehttp/psr7/src/InflateStream.php deleted file mode 100644 index 0051d3fec..000000000 --- a/vendor/guzzlehttp/psr7/src/InflateStream.php +++ /dev/null @@ -1,52 +0,0 @@ -read(10); - $filenameHeaderLength = $this->getLengthOfPossibleFilenameHeader($stream, $header); - // Skip the header, that is 10 + length of filename + 1 (nil) bytes - $stream = new LimitStream($stream, -1, 10 + $filenameHeaderLength); - $resource = StreamWrapper::getResource($stream); - stream_filter_append($resource, 'zlib.inflate', STREAM_FILTER_READ); - $this->stream = new Stream($resource); - } - - /** - * @param StreamInterface $stream - * @param $header - * @return int - */ - private function getLengthOfPossibleFilenameHeader(StreamInterface $stream, $header) - { - $filename_header_length = 0; - - if (substr(bin2hex($header), 6, 2) === '08') { - // we have a filename, read until nil - $filename_header_length = 1; - while ($stream->read(1) !== chr(0)) { - $filename_header_length++; - } - } - - return $filename_header_length; - } -} diff --git a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php b/vendor/guzzlehttp/psr7/src/LazyOpenStream.php deleted file mode 100644 index 02cec3af4..000000000 --- a/vendor/guzzlehttp/psr7/src/LazyOpenStream.php +++ /dev/null @@ -1,39 +0,0 @@ -filename = $filename; - $this->mode = $mode; - } - - /** - * Creates the underlying stream lazily when required. - * - * @return StreamInterface - */ - protected function createStream() - { - return stream_for(try_fopen($this->filename, $this->mode)); - } -} diff --git a/vendor/guzzlehttp/psr7/src/LimitStream.php b/vendor/guzzlehttp/psr7/src/LimitStream.php deleted file mode 100644 index 7f2298bcb..000000000 --- a/vendor/guzzlehttp/psr7/src/LimitStream.php +++ /dev/null @@ -1,155 +0,0 @@ -stream = $stream; - $this->setLimit($limit); - $this->setOffset($offset); - } - - public function eof() - { - // Always return true if the underlying stream is EOF - if ($this->stream->eof()) { - return true; - } - - // No limit and the underlying stream is not at EOF - if ($this->limit == -1) { - return false; - } - - return $this->stream->tell() >= $this->offset + $this->limit; - } - - /** - * Returns the size of the limited subset of data - * {@inheritdoc} - */ - public function getSize() - { - if (null === ($length = $this->stream->getSize())) { - return null; - } elseif ($this->limit == -1) { - return $length - $this->offset; - } else { - return min($this->limit, $length - $this->offset); - } - } - - /** - * Allow for a bounded seek on the read limited stream - * {@inheritdoc} - */ - public function seek($offset, $whence = SEEK_SET) - { - if ($whence !== SEEK_SET || $offset < 0) { - throw new \RuntimeException(sprintf( - 'Cannot seek to offset % with whence %s', - $offset, - $whence - )); - } - - $offset += $this->offset; - - if ($this->limit !== -1) { - if ($offset > $this->offset + $this->limit) { - $offset = $this->offset + $this->limit; - } - } - - $this->stream->seek($offset); - } - - /** - * Give a relative tell() - * {@inheritdoc} - */ - public function tell() - { - return $this->stream->tell() - $this->offset; - } - - /** - * Set the offset to start limiting from - * - * @param int $offset Offset to seek to and begin byte limiting from - * - * @throws \RuntimeException if the stream cannot be seeked. - */ - public function setOffset($offset) - { - $current = $this->stream->tell(); - - if ($current !== $offset) { - // If the stream cannot seek to the offset position, then read to it - if ($this->stream->isSeekable()) { - $this->stream->seek($offset); - } elseif ($current > $offset) { - throw new \RuntimeException("Could not seek to stream offset $offset"); - } else { - $this->stream->read($offset - $current); - } - } - - $this->offset = $offset; - } - - /** - * Set the limit of bytes that the decorator allows to be read from the - * stream. - * - * @param int $limit Number of bytes to allow to be read from the stream. - * Use -1 for no limit. - */ - public function setLimit($limit) - { - $this->limit = $limit; - } - - public function read($length) - { - if ($this->limit == -1) { - return $this->stream->read($length); - } - - // Check if the current position is less than the total allowed - // bytes + original offset - $remaining = ($this->offset + $this->limit) - $this->stream->tell(); - if ($remaining > 0) { - // Only return the amount of requested data, ensuring that the byte - // limit is not exceeded - return $this->stream->read(min($remaining, $length)); - } - - return ''; - } -} diff --git a/vendor/guzzlehttp/psr7/src/MessageTrait.php b/vendor/guzzlehttp/psr7/src/MessageTrait.php deleted file mode 100644 index 1e4da649a..000000000 --- a/vendor/guzzlehttp/psr7/src/MessageTrait.php +++ /dev/null @@ -1,183 +0,0 @@ - array of values */ - private $headers = []; - - /** @var array Map of lowercase header name => original name at registration */ - private $headerNames = []; - - /** @var string */ - private $protocol = '1.1'; - - /** @var StreamInterface */ - private $stream; - - public function getProtocolVersion() - { - return $this->protocol; - } - - public function withProtocolVersion($version) - { - if ($this->protocol === $version) { - return $this; - } - - $new = clone $this; - $new->protocol = $version; - return $new; - } - - public function getHeaders() - { - return $this->headers; - } - - public function hasHeader($header) - { - return isset($this->headerNames[strtolower($header)]); - } - - public function getHeader($header) - { - $header = strtolower($header); - - if (!isset($this->headerNames[$header])) { - return []; - } - - $header = $this->headerNames[$header]; - - return $this->headers[$header]; - } - - public function getHeaderLine($header) - { - return implode(', ', $this->getHeader($header)); - } - - public function withHeader($header, $value) - { - if (!is_array($value)) { - $value = [$value]; - } - - $value = $this->trimHeaderValues($value); - $normalized = strtolower($header); - - $new = clone $this; - if (isset($new->headerNames[$normalized])) { - unset($new->headers[$new->headerNames[$normalized]]); - } - $new->headerNames[$normalized] = $header; - $new->headers[$header] = $value; - - return $new; - } - - public function withAddedHeader($header, $value) - { - if (!is_array($value)) { - $value = [$value]; - } - - $value = $this->trimHeaderValues($value); - $normalized = strtolower($header); - - $new = clone $this; - if (isset($new->headerNames[$normalized])) { - $header = $this->headerNames[$normalized]; - $new->headers[$header] = array_merge($this->headers[$header], $value); - } else { - $new->headerNames[$normalized] = $header; - $new->headers[$header] = $value; - } - - return $new; - } - - public function withoutHeader($header) - { - $normalized = strtolower($header); - - if (!isset($this->headerNames[$normalized])) { - return $this; - } - - $header = $this->headerNames[$normalized]; - - $new = clone $this; - unset($new->headers[$header], $new->headerNames[$normalized]); - - return $new; - } - - public function getBody() - { - if (!$this->stream) { - $this->stream = stream_for(''); - } - - return $this->stream; - } - - public function withBody(StreamInterface $body) - { - if ($body === $this->stream) { - return $this; - } - - $new = clone $this; - $new->stream = $body; - return $new; - } - - private function setHeaders(array $headers) - { - $this->headerNames = $this->headers = []; - foreach ($headers as $header => $value) { - if (!is_array($value)) { - $value = [$value]; - } - - $value = $this->trimHeaderValues($value); - $normalized = strtolower($header); - if (isset($this->headerNames[$normalized])) { - $header = $this->headerNames[$normalized]; - $this->headers[$header] = array_merge($this->headers[$header], $value); - } else { - $this->headerNames[$normalized] = $header; - $this->headers[$header] = $value; - } - } - } - - /** - * Trims whitespace from the header values. - * - * Spaces and tabs ought to be excluded by parsers when extracting the field value from a header field. - * - * header-field = field-name ":" OWS field-value OWS - * OWS = *( SP / HTAB ) - * - * @param string[] $values Header values - * - * @return string[] Trimmed header values - * - * @see https://tools.ietf.org/html/rfc7230#section-3.2.4 - */ - private function trimHeaderValues(array $values) - { - return array_map(function ($value) { - return trim($value, " \t"); - }, $values); - } -} diff --git a/vendor/guzzlehttp/psr7/src/MultipartStream.php b/vendor/guzzlehttp/psr7/src/MultipartStream.php deleted file mode 100644 index 2988fcba0..000000000 --- a/vendor/guzzlehttp/psr7/src/MultipartStream.php +++ /dev/null @@ -1,153 +0,0 @@ -boundary = $boundary ?: uniqid(); - $this->stream = $this->createStream($elements); - } - - /** - * Get the boundary - * - * @return string - */ - public function getBoundary() - { - return $this->boundary; - } - - public function isWritable() - { - return false; - } - - /** - * Get the headers needed before transferring the content of a POST file - */ - private function getHeaders(array $headers) - { - $str = ''; - foreach ($headers as $key => $value) { - $str .= "{$key}: {$value}\r\n"; - } - - return "--{$this->boundary}\r\n" . trim($str) . "\r\n\r\n"; - } - - /** - * Create the aggregate stream that will be used to upload the POST data - */ - protected function createStream(array $elements) - { - $stream = new AppendStream(); - - foreach ($elements as $element) { - $this->addElement($stream, $element); - } - - // Add the trailing boundary with CRLF - $stream->addStream(stream_for("--{$this->boundary}--\r\n")); - - return $stream; - } - - private function addElement(AppendStream $stream, array $element) - { - foreach (['contents', 'name'] as $key) { - if (!array_key_exists($key, $element)) { - throw new \InvalidArgumentException("A '{$key}' key is required"); - } - } - - $element['contents'] = stream_for($element['contents']); - - if (empty($element['filename'])) { - $uri = $element['contents']->getMetadata('uri'); - if (substr($uri, 0, 6) !== 'php://') { - $element['filename'] = $uri; - } - } - - list($body, $headers) = $this->createElement( - $element['name'], - $element['contents'], - isset($element['filename']) ? $element['filename'] : null, - isset($element['headers']) ? $element['headers'] : [] - ); - - $stream->addStream(stream_for($this->getHeaders($headers))); - $stream->addStream($body); - $stream->addStream(stream_for("\r\n")); - } - - /** - * @return array - */ - private function createElement($name, $stream, $filename, array $headers) - { - // Set a default content-disposition header if one was no provided - $disposition = $this->getHeader($headers, 'content-disposition'); - if (!$disposition) { - $headers['Content-Disposition'] = ($filename === '0' || $filename) - ? sprintf('form-data; name="%s"; filename="%s"', - $name, - basename($filename)) - : "form-data; name=\"{$name}\""; - } - - // Set a default content-length header if one was no provided - $length = $this->getHeader($headers, 'content-length'); - if (!$length) { - if ($length = $stream->getSize()) { - $headers['Content-Length'] = (string) $length; - } - } - - // Set a default Content-Type if one was not supplied - $type = $this->getHeader($headers, 'content-type'); - if (!$type && ($filename === '0' || $filename)) { - if ($type = mimetype_from_filename($filename)) { - $headers['Content-Type'] = $type; - } - } - - return [$stream, $headers]; - } - - private function getHeader(array $headers, $key) - { - $lowercaseHeader = strtolower($key); - foreach ($headers as $k => $v) { - if (strtolower($k) === $lowercaseHeader) { - return $v; - } - } - - return null; - } -} diff --git a/vendor/guzzlehttp/psr7/src/NoSeekStream.php b/vendor/guzzlehttp/psr7/src/NoSeekStream.php deleted file mode 100644 index 233221805..000000000 --- a/vendor/guzzlehttp/psr7/src/NoSeekStream.php +++ /dev/null @@ -1,22 +0,0 @@ -source = $source; - $this->size = isset($options['size']) ? $options['size'] : null; - $this->metadata = isset($options['metadata']) ? $options['metadata'] : []; - $this->buffer = new BufferStream(); - } - - public function __toString() - { - try { - return copy_to_string($this); - } catch (\Exception $e) { - return ''; - } - } - - public function close() - { - $this->detach(); - } - - public function detach() - { - $this->tellPos = false; - $this->source = null; - } - - public function getSize() - { - return $this->size; - } - - public function tell() - { - return $this->tellPos; - } - - public function eof() - { - return !$this->source; - } - - public function isSeekable() - { - return false; - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - throw new \RuntimeException('Cannot seek a PumpStream'); - } - - public function isWritable() - { - return false; - } - - public function write($string) - { - throw new \RuntimeException('Cannot write to a PumpStream'); - } - - public function isReadable() - { - return true; - } - - public function read($length) - { - $data = $this->buffer->read($length); - $readLen = strlen($data); - $this->tellPos += $readLen; - $remaining = $length - $readLen; - - if ($remaining) { - $this->pump($remaining); - $data .= $this->buffer->read($remaining); - $this->tellPos += strlen($data) - $readLen; - } - - return $data; - } - - public function getContents() - { - $result = ''; - while (!$this->eof()) { - $result .= $this->read(1000000); - } - - return $result; - } - - public function getMetadata($key = null) - { - if (!$key) { - return $this->metadata; - } - - return isset($this->metadata[$key]) ? $this->metadata[$key] : null; - } - - private function pump($length) - { - if ($this->source) { - do { - $data = call_user_func($this->source, $length); - if ($data === false || $data === null) { - $this->source = null; - return; - } - $this->buffer->write($data); - $length -= strlen($data); - } while ($length > 0); - } - } -} diff --git a/vendor/guzzlehttp/psr7/src/Request.php b/vendor/guzzlehttp/psr7/src/Request.php deleted file mode 100644 index 4a3db6ece..000000000 --- a/vendor/guzzlehttp/psr7/src/Request.php +++ /dev/null @@ -1,142 +0,0 @@ -method = strtoupper($method); - $this->uri = $uri; - $this->setHeaders($headers); - $this->protocol = $version; - - if (!$this->hasHeader('Host')) { - $this->updateHostFromUri(); - } - - if ($body !== '' && $body !== null) { - $this->stream = stream_for($body); - } - } - - public function getRequestTarget() - { - if ($this->requestTarget !== null) { - return $this->requestTarget; - } - - $target = $this->uri->getPath(); - if ($target == '') { - $target = '/'; - } - if ($this->uri->getQuery() != '') { - $target .= '?' . $this->uri->getQuery(); - } - - return $target; - } - - public function withRequestTarget($requestTarget) - { - if (preg_match('#\s#', $requestTarget)) { - throw new InvalidArgumentException( - 'Invalid request target provided; cannot contain whitespace' - ); - } - - $new = clone $this; - $new->requestTarget = $requestTarget; - return $new; - } - - public function getMethod() - { - return $this->method; - } - - public function withMethod($method) - { - $new = clone $this; - $new->method = strtoupper($method); - return $new; - } - - public function getUri() - { - return $this->uri; - } - - public function withUri(UriInterface $uri, $preserveHost = false) - { - if ($uri === $this->uri) { - return $this; - } - - $new = clone $this; - $new->uri = $uri; - - if (!$preserveHost) { - $new->updateHostFromUri(); - } - - return $new; - } - - private function updateHostFromUri() - { - $host = $this->uri->getHost(); - - if ($host == '') { - return; - } - - if (($port = $this->uri->getPort()) !== null) { - $host .= ':' . $port; - } - - if (isset($this->headerNames['host'])) { - $header = $this->headerNames['host']; - } else { - $header = 'Host'; - $this->headerNames['host'] = 'Host'; - } - // Ensure Host is the first header. - // See: http://tools.ietf.org/html/rfc7230#section-5.4 - $this->headers = [$header => [$host]] + $this->headers; - } -} diff --git a/vendor/guzzlehttp/psr7/src/Response.php b/vendor/guzzlehttp/psr7/src/Response.php deleted file mode 100644 index 841ff0200..000000000 --- a/vendor/guzzlehttp/psr7/src/Response.php +++ /dev/null @@ -1,131 +0,0 @@ - 'Continue', - 101 => 'Switching Protocols', - 102 => 'Processing', - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - 207 => 'Multi-status', - 208 => 'Already Reported', - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 306 => 'Switch Proxy', - 307 => 'Temporary Redirect', - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Time-out', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Large', - 415 => 'Unsupported Media Type', - 416 => 'Requested range not satisfiable', - 417 => 'Expectation Failed', - 418 => 'I\'m a teapot', - 422 => 'Unprocessable Entity', - 423 => 'Locked', - 424 => 'Failed Dependency', - 425 => 'Unordered Collection', - 426 => 'Upgrade Required', - 428 => 'Precondition Required', - 429 => 'Too Many Requests', - 431 => 'Request Header Fields Too Large', - 451 => 'Unavailable For Legal Reasons', - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Time-out', - 505 => 'HTTP Version not supported', - 506 => 'Variant Also Negotiates', - 507 => 'Insufficient Storage', - 508 => 'Loop Detected', - 511 => 'Network Authentication Required', - ]; - - /** @var string */ - private $reasonPhrase = ''; - - /** @var int */ - private $statusCode = 200; - - /** - * @param int $status Status code - * @param array $headers Response headers - * @param string|null|resource|StreamInterface $body Response body - * @param string $version Protocol version - * @param string|null $reason Reason phrase (when empty a default will be used based on the status code) - */ - public function __construct( - $status = 200, - array $headers = [], - $body = null, - $version = '1.1', - $reason = null - ) { - $this->statusCode = (int) $status; - - if ($body !== '' && $body !== null) { - $this->stream = stream_for($body); - } - - $this->setHeaders($headers); - if ($reason == '' && isset(self::$phrases[$this->statusCode])) { - $this->reasonPhrase = self::$phrases[$status]; - } else { - $this->reasonPhrase = (string) $reason; - } - - $this->protocol = $version; - } - - public function getStatusCode() - { - return $this->statusCode; - } - - public function getReasonPhrase() - { - return $this->reasonPhrase; - } - - public function withStatus($code, $reasonPhrase = '') - { - $new = clone $this; - $new->statusCode = (int) $code; - if ($reasonPhrase == '' && isset(self::$phrases[$new->statusCode])) { - $reasonPhrase = self::$phrases[$new->statusCode]; - } - $new->reasonPhrase = $reasonPhrase; - return $new; - } -} diff --git a/vendor/guzzlehttp/psr7/src/ServerRequest.php b/vendor/guzzlehttp/psr7/src/ServerRequest.php deleted file mode 100644 index a6a47bec4..000000000 --- a/vendor/guzzlehttp/psr7/src/ServerRequest.php +++ /dev/null @@ -1,346 +0,0 @@ -serverParams = $serverParams; - - parent::__construct($method, $uri, $headers, $body, $version); - } - - /** - * Return an UploadedFile instance array. - * - * @param array $files A array which respect $_FILES structure - * @throws InvalidArgumentException for unrecognized values - * @return array - */ - public static function normalizeFiles(array $files) - { - $normalized = []; - - foreach ($files as $key => $value) { - if ($value instanceof UploadedFileInterface) { - $normalized[$key] = $value; - } elseif (is_array($value) && isset($value['tmp_name'])) { - $normalized[$key] = self::createUploadedFileFromSpec($value); - } elseif (is_array($value)) { - $normalized[$key] = self::normalizeFiles($value); - continue; - } else { - throw new InvalidArgumentException('Invalid value in files specification'); - } - } - - return $normalized; - } - - /** - * Create and return an UploadedFile instance from a $_FILES specification. - * - * If the specification represents an array of values, this method will - * delegate to normalizeNestedFileSpec() and return that return value. - * - * @param array $value $_FILES struct - * @return array|UploadedFileInterface - */ - private static function createUploadedFileFromSpec(array $value) - { - if (is_array($value['tmp_name'])) { - return self::normalizeNestedFileSpec($value); - } - - return new UploadedFile( - $value['tmp_name'], - (int) $value['size'], - (int) $value['error'], - $value['name'], - $value['type'] - ); - } - - /** - * Normalize an array of file specifications. - * - * Loops through all nested files and returns a normalized array of - * UploadedFileInterface instances. - * - * @param array $files - * @return UploadedFileInterface[] - */ - private static function normalizeNestedFileSpec(array $files = []) - { - $normalizedFiles = []; - - foreach (array_keys($files['tmp_name']) as $key) { - $spec = [ - 'tmp_name' => $files['tmp_name'][$key], - 'size' => $files['size'][$key], - 'error' => $files['error'][$key], - 'name' => $files['name'][$key], - 'type' => $files['type'][$key], - ]; - $normalizedFiles[$key] = self::createUploadedFileFromSpec($spec); - } - - return $normalizedFiles; - } - - /** - * Return a ServerRequest populated with superglobals: - * $_GET - * $_POST - * $_COOKIE - * $_FILES - * $_SERVER - * - * @return ServerRequestInterface - */ - public static function fromGlobals() - { - $method = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET'; - $headers = function_exists('getallheaders') ? getallheaders() : []; - $uri = self::getUriFromGlobals(); - $body = new LazyOpenStream('php://input', 'r+'); - $protocol = isset($_SERVER['SERVER_PROTOCOL']) ? str_replace('HTTP/', '', $_SERVER['SERVER_PROTOCOL']) : '1.1'; - - $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $_SERVER); - - return $serverRequest - ->withCookieParams($_COOKIE) - ->withQueryParams($_GET) - ->withParsedBody($_POST) - ->withUploadedFiles(self::normalizeFiles($_FILES)); - } - - /** - * Get a Uri populated with values from $_SERVER. - * - * @return UriInterface - */ - public static function getUriFromGlobals() { - $uri = new Uri(''); - - if (isset($_SERVER['HTTPS'])) { - $uri = $uri->withScheme($_SERVER['HTTPS'] == 'on' ? 'https' : 'http'); - } - - if (isset($_SERVER['HTTP_HOST'])) { - $uri = $uri->withHost($_SERVER['HTTP_HOST']); - } elseif (isset($_SERVER['SERVER_NAME'])) { - $uri = $uri->withHost($_SERVER['SERVER_NAME']); - } - - if (isset($_SERVER['SERVER_PORT'])) { - $uri = $uri->withPort($_SERVER['SERVER_PORT']); - } - - if (isset($_SERVER['REQUEST_URI'])) { - $uri = $uri->withPath(current(explode('?', $_SERVER['REQUEST_URI']))); - } - - if (isset($_SERVER['QUERY_STRING'])) { - $uri = $uri->withQuery($_SERVER['QUERY_STRING']); - } - - return $uri; - } - - - /** - * {@inheritdoc} - */ - public function getServerParams() - { - return $this->serverParams; - } - - /** - * {@inheritdoc} - */ - public function getUploadedFiles() - { - return $this->uploadedFiles; - } - - /** - * {@inheritdoc} - */ - public function withUploadedFiles(array $uploadedFiles) - { - $new = clone $this; - $new->uploadedFiles = $uploadedFiles; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getCookieParams() - { - return $this->cookieParams; - } - - /** - * {@inheritdoc} - */ - public function withCookieParams(array $cookies) - { - $new = clone $this; - $new->cookieParams = $cookies; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getQueryParams() - { - return $this->queryParams; - } - - /** - * {@inheritdoc} - */ - public function withQueryParams(array $query) - { - $new = clone $this; - $new->queryParams = $query; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getParsedBody() - { - return $this->parsedBody; - } - - /** - * {@inheritdoc} - */ - public function withParsedBody($data) - { - $new = clone $this; - $new->parsedBody = $data; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * {@inheritdoc} - */ - public function getAttribute($attribute, $default = null) - { - if (false === array_key_exists($attribute, $this->attributes)) { - return $default; - } - - return $this->attributes[$attribute]; - } - - /** - * {@inheritdoc} - */ - public function withAttribute($attribute, $value) - { - $new = clone $this; - $new->attributes[$attribute] = $value; - - return $new; - } - - /** - * {@inheritdoc} - */ - public function withoutAttribute($attribute) - { - if (false === array_key_exists($attribute, $this->attributes)) { - return $this; - } - - $new = clone $this; - unset($new->attributes[$attribute]); - - return $new; - } -} diff --git a/vendor/guzzlehttp/psr7/src/Stream.php b/vendor/guzzlehttp/psr7/src/Stream.php deleted file mode 100644 index 214af151c..000000000 --- a/vendor/guzzlehttp/psr7/src/Stream.php +++ /dev/null @@ -1,245 +0,0 @@ - [ - 'r' => true, 'w+' => true, 'r+' => true, 'x+' => true, 'c+' => true, - 'rb' => true, 'w+b' => true, 'r+b' => true, 'x+b' => true, - 'c+b' => true, 'rt' => true, 'w+t' => true, 'r+t' => true, - 'x+t' => true, 'c+t' => true, 'a+' => true - ], - 'write' => [ - 'w' => true, 'w+' => true, 'rw' => true, 'r+' => true, 'x+' => true, - 'c+' => true, 'wb' => true, 'w+b' => true, 'r+b' => true, - 'x+b' => true, 'c+b' => true, 'w+t' => true, 'r+t' => true, - 'x+t' => true, 'c+t' => true, 'a' => true, 'a+' => true - ] - ]; - - /** - * This constructor accepts an associative array of options. - * - * - size: (int) If a read stream would otherwise have an indeterminate - * size, but the size is known due to foreknowledge, then you can - * provide that size, in bytes. - * - metadata: (array) Any additional metadata to return when the metadata - * of the stream is accessed. - * - * @param resource $stream Stream resource to wrap. - * @param array $options Associative array of options. - * - * @throws \InvalidArgumentException if the stream is not a stream resource - */ - public function __construct($stream, $options = []) - { - if (!is_resource($stream)) { - throw new \InvalidArgumentException('Stream must be a resource'); - } - - if (isset($options['size'])) { - $this->size = $options['size']; - } - - $this->customMetadata = isset($options['metadata']) - ? $options['metadata'] - : []; - - $this->stream = $stream; - $meta = stream_get_meta_data($this->stream); - $this->seekable = $meta['seekable']; - $this->readable = isset(self::$readWriteHash['read'][$meta['mode']]); - $this->writable = isset(self::$readWriteHash['write'][$meta['mode']]); - $this->uri = $this->getMetadata('uri'); - } - - public function __get($name) - { - if ($name == 'stream') { - throw new \RuntimeException('The stream is detached'); - } - - throw new \BadMethodCallException('No value for ' . $name); - } - - /** - * Closes the stream when the destructed - */ - public function __destruct() - { - $this->close(); - } - - public function __toString() - { - try { - $this->seek(0); - return (string) stream_get_contents($this->stream); - } catch (\Exception $e) { - return ''; - } - } - - public function getContents() - { - $contents = stream_get_contents($this->stream); - - if ($contents === false) { - throw new \RuntimeException('Unable to read stream contents'); - } - - return $contents; - } - - public function close() - { - if (isset($this->stream)) { - if (is_resource($this->stream)) { - fclose($this->stream); - } - $this->detach(); - } - } - - public function detach() - { - if (!isset($this->stream)) { - return null; - } - - $result = $this->stream; - unset($this->stream); - $this->size = $this->uri = null; - $this->readable = $this->writable = $this->seekable = false; - - return $result; - } - - public function getSize() - { - if ($this->size !== null) { - return $this->size; - } - - if (!isset($this->stream)) { - return null; - } - - // Clear the stat cache if the stream has a URI - if ($this->uri) { - clearstatcache(true, $this->uri); - } - - $stats = fstat($this->stream); - if (isset($stats['size'])) { - $this->size = $stats['size']; - return $this->size; - } - - return null; - } - - public function isReadable() - { - return $this->readable; - } - - public function isWritable() - { - return $this->writable; - } - - public function isSeekable() - { - return $this->seekable; - } - - public function eof() - { - return !$this->stream || feof($this->stream); - } - - public function tell() - { - $result = ftell($this->stream); - - if ($result === false) { - throw new \RuntimeException('Unable to determine stream position'); - } - - return $result; - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - if (!$this->seekable) { - throw new \RuntimeException('Stream is not seekable'); - } elseif (fseek($this->stream, $offset, $whence) === -1) { - throw new \RuntimeException('Unable to seek to stream position ' - . $offset . ' with whence ' . var_export($whence, true)); - } - } - - public function read($length) - { - if (!$this->readable) { - throw new \RuntimeException('Cannot read from non-readable stream'); - } - - return fread($this->stream, $length); - } - - public function write($string) - { - if (!$this->writable) { - throw new \RuntimeException('Cannot write to a non-writable stream'); - } - - // We can't know the size after writing anything - $this->size = null; - $result = fwrite($this->stream, $string); - - if ($result === false) { - throw new \RuntimeException('Unable to write to stream'); - } - - return $result; - } - - public function getMetadata($key = null) - { - if (!isset($this->stream)) { - return $key ? null : []; - } elseif (!$key) { - return $this->customMetadata + stream_get_meta_data($this->stream); - } elseif (isset($this->customMetadata[$key])) { - return $this->customMetadata[$key]; - } - - $meta = stream_get_meta_data($this->stream); - - return isset($meta[$key]) ? $meta[$key] : null; - } -} diff --git a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php b/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php deleted file mode 100644 index daec6f52e..000000000 --- a/vendor/guzzlehttp/psr7/src/StreamDecoratorTrait.php +++ /dev/null @@ -1,149 +0,0 @@ -stream = $stream; - } - - /** - * Magic method used to create a new stream if streams are not added in - * the constructor of a decorator (e.g., LazyOpenStream). - * - * @param string $name Name of the property (allows "stream" only). - * - * @return StreamInterface - */ - public function __get($name) - { - if ($name == 'stream') { - $this->stream = $this->createStream(); - return $this->stream; - } - - throw new \UnexpectedValueException("$name not found on class"); - } - - public function __toString() - { - try { - if ($this->isSeekable()) { - $this->seek(0); - } - return $this->getContents(); - } catch (\Exception $e) { - // Really, PHP? https://bugs.php.net/bug.php?id=53648 - trigger_error('StreamDecorator::__toString exception: ' - . (string) $e, E_USER_ERROR); - return ''; - } - } - - public function getContents() - { - return copy_to_string($this); - } - - /** - * Allow decorators to implement custom methods - * - * @param string $method Missing method name - * @param array $args Method arguments - * - * @return mixed - */ - public function __call($method, array $args) - { - $result = call_user_func_array([$this->stream, $method], $args); - - // Always return the wrapped object if the result is a return $this - return $result === $this->stream ? $this : $result; - } - - public function close() - { - $this->stream->close(); - } - - public function getMetadata($key = null) - { - return $this->stream->getMetadata($key); - } - - public function detach() - { - return $this->stream->detach(); - } - - public function getSize() - { - return $this->stream->getSize(); - } - - public function eof() - { - return $this->stream->eof(); - } - - public function tell() - { - return $this->stream->tell(); - } - - public function isReadable() - { - return $this->stream->isReadable(); - } - - public function isWritable() - { - return $this->stream->isWritable(); - } - - public function isSeekable() - { - return $this->stream->isSeekable(); - } - - public function rewind() - { - $this->seek(0); - } - - public function seek($offset, $whence = SEEK_SET) - { - $this->stream->seek($offset, $whence); - } - - public function read($length) - { - return $this->stream->read($length); - } - - public function write($string) - { - return $this->stream->write($string); - } - - /** - * Implement in subclasses to dynamically create streams when requested. - * - * @return StreamInterface - * @throws \BadMethodCallException - */ - protected function createStream() - { - throw new \BadMethodCallException('Not implemented'); - } -} diff --git a/vendor/guzzlehttp/psr7/src/StreamWrapper.php b/vendor/guzzlehttp/psr7/src/StreamWrapper.php deleted file mode 100644 index cf7b2232e..000000000 --- a/vendor/guzzlehttp/psr7/src/StreamWrapper.php +++ /dev/null @@ -1,121 +0,0 @@ -isReadable()) { - $mode = $stream->isWritable() ? 'r+' : 'r'; - } elseif ($stream->isWritable()) { - $mode = 'w'; - } else { - throw new \InvalidArgumentException('The stream must be readable, ' - . 'writable, or both.'); - } - - return fopen('guzzle://stream', $mode, null, stream_context_create([ - 'guzzle' => ['stream' => $stream] - ])); - } - - /** - * Registers the stream wrapper if needed - */ - public static function register() - { - if (!in_array('guzzle', stream_get_wrappers())) { - stream_wrapper_register('guzzle', __CLASS__); - } - } - - public function stream_open($path, $mode, $options, &$opened_path) - { - $options = stream_context_get_options($this->context); - - if (!isset($options['guzzle']['stream'])) { - return false; - } - - $this->mode = $mode; - $this->stream = $options['guzzle']['stream']; - - return true; - } - - public function stream_read($count) - { - return $this->stream->read($count); - } - - public function stream_write($data) - { - return (int) $this->stream->write($data); - } - - public function stream_tell() - { - return $this->stream->tell(); - } - - public function stream_eof() - { - return $this->stream->eof(); - } - - public function stream_seek($offset, $whence) - { - $this->stream->seek($offset, $whence); - - return true; - } - - public function stream_stat() - { - static $modeMap = [ - 'r' => 33060, - 'r+' => 33206, - 'w' => 33188 - ]; - - return [ - 'dev' => 0, - 'ino' => 0, - 'mode' => $modeMap[$this->mode], - 'nlink' => 0, - 'uid' => 0, - 'gid' => 0, - 'rdev' => 0, - 'size' => $this->stream->getSize() ?: 0, - 'atime' => 0, - 'mtime' => 0, - 'ctime' => 0, - 'blksize' => 0, - 'blocks' => 0 - ]; - } -} diff --git a/vendor/guzzlehttp/psr7/src/UploadedFile.php b/vendor/guzzlehttp/psr7/src/UploadedFile.php deleted file mode 100644 index e62bd5c80..000000000 --- a/vendor/guzzlehttp/psr7/src/UploadedFile.php +++ /dev/null @@ -1,316 +0,0 @@ -setError($errorStatus); - $this->setSize($size); - $this->setClientFilename($clientFilename); - $this->setClientMediaType($clientMediaType); - - if ($this->isOk()) { - $this->setStreamOrFile($streamOrFile); - } - } - - /** - * Depending on the value set file or stream variable - * - * @param mixed $streamOrFile - * @throws InvalidArgumentException - */ - private function setStreamOrFile($streamOrFile) - { - if (is_string($streamOrFile)) { - $this->file = $streamOrFile; - } elseif (is_resource($streamOrFile)) { - $this->stream = new Stream($streamOrFile); - } elseif ($streamOrFile instanceof StreamInterface) { - $this->stream = $streamOrFile; - } else { - throw new InvalidArgumentException( - 'Invalid stream or file provided for UploadedFile' - ); - } - } - - /** - * @param int $error - * @throws InvalidArgumentException - */ - private function setError($error) - { - if (false === is_int($error)) { - throw new InvalidArgumentException( - 'Upload file error status must be an integer' - ); - } - - if (false === in_array($error, UploadedFile::$errors)) { - throw new InvalidArgumentException( - 'Invalid error status for UploadedFile' - ); - } - - $this->error = $error; - } - - /** - * @param int $size - * @throws InvalidArgumentException - */ - private function setSize($size) - { - if (false === is_int($size)) { - throw new InvalidArgumentException( - 'Upload file size must be an integer' - ); - } - - $this->size = $size; - } - - /** - * @param mixed $param - * @return boolean - */ - private function isStringOrNull($param) - { - return in_array(gettype($param), ['string', 'NULL']); - } - - /** - * @param mixed $param - * @return boolean - */ - private function isStringNotEmpty($param) - { - return is_string($param) && false === empty($param); - } - - /** - * @param string|null $clientFilename - * @throws InvalidArgumentException - */ - private function setClientFilename($clientFilename) - { - if (false === $this->isStringOrNull($clientFilename)) { - throw new InvalidArgumentException( - 'Upload file client filename must be a string or null' - ); - } - - $this->clientFilename = $clientFilename; - } - - /** - * @param string|null $clientMediaType - * @throws InvalidArgumentException - */ - private function setClientMediaType($clientMediaType) - { - if (false === $this->isStringOrNull($clientMediaType)) { - throw new InvalidArgumentException( - 'Upload file client media type must be a string or null' - ); - } - - $this->clientMediaType = $clientMediaType; - } - - /** - * Return true if there is no upload error - * - * @return boolean - */ - private function isOk() - { - return $this->error === UPLOAD_ERR_OK; - } - - /** - * @return boolean - */ - public function isMoved() - { - return $this->moved; - } - - /** - * @throws RuntimeException if is moved or not ok - */ - private function validateActive() - { - if (false === $this->isOk()) { - throw new RuntimeException('Cannot retrieve stream due to upload error'); - } - - if ($this->isMoved()) { - throw new RuntimeException('Cannot retrieve stream after it has already been moved'); - } - } - - /** - * {@inheritdoc} - * @throws RuntimeException if the upload was not successful. - */ - public function getStream() - { - $this->validateActive(); - - if ($this->stream instanceof StreamInterface) { - return $this->stream; - } - - return new LazyOpenStream($this->file, 'r+'); - } - - /** - * {@inheritdoc} - * - * @see http://php.net/is_uploaded_file - * @see http://php.net/move_uploaded_file - * @param string $targetPath Path to which to move the uploaded file. - * @throws RuntimeException if the upload was not successful. - * @throws InvalidArgumentException if the $path specified is invalid. - * @throws RuntimeException on any error during the move operation, or on - * the second or subsequent call to the method. - */ - public function moveTo($targetPath) - { - $this->validateActive(); - - if (false === $this->isStringNotEmpty($targetPath)) { - throw new InvalidArgumentException( - 'Invalid path provided for move operation; must be a non-empty string' - ); - } - - if ($this->file) { - $this->moved = php_sapi_name() == 'cli' - ? rename($this->file, $targetPath) - : move_uploaded_file($this->file, $targetPath); - } else { - copy_to_stream( - $this->getStream(), - new LazyOpenStream($targetPath, 'w') - ); - - $this->moved = true; - } - - if (false === $this->moved) { - throw new RuntimeException( - sprintf('Uploaded file could not be moved to %s', $targetPath) - ); - } - } - - /** - * {@inheritdoc} - * - * @return int|null The file size in bytes or null if unknown. - */ - public function getSize() - { - return $this->size; - } - - /** - * {@inheritdoc} - * - * @see http://php.net/manual/en/features.file-upload.errors.php - * @return int One of PHP's UPLOAD_ERR_XXX constants. - */ - public function getError() - { - return $this->error; - } - - /** - * {@inheritdoc} - * - * @return string|null The filename sent by the client or null if none - * was provided. - */ - public function getClientFilename() - { - return $this->clientFilename; - } - - /** - * {@inheritdoc} - */ - public function getClientMediaType() - { - return $this->clientMediaType; - } -} diff --git a/vendor/guzzlehttp/psr7/src/Uri.php b/vendor/guzzlehttp/psr7/src/Uri.php deleted file mode 100644 index 44a1e9d49..000000000 --- a/vendor/guzzlehttp/psr7/src/Uri.php +++ /dev/null @@ -1,602 +0,0 @@ - 80, - 'https' => 443, - ]; - - private static $charUnreserved = 'a-zA-Z0-9_\-\.~'; - private static $charSubDelims = '!\$&\'\(\)\*\+,;='; - private static $replaceQuery = ['=' => '%3D', '&' => '%26']; - - /** @var string Uri scheme. */ - private $scheme = ''; - - /** @var string Uri user info. */ - private $userInfo = ''; - - /** @var string Uri host. */ - private $host = ''; - - /** @var int|null Uri port. */ - private $port; - - /** @var string Uri path. */ - private $path = ''; - - /** @var string Uri query string. */ - private $query = ''; - - /** @var string Uri fragment. */ - private $fragment = ''; - - /** - * @param string $uri URI to parse - */ - public function __construct($uri = '') - { - if ($uri != '') { - $parts = parse_url($uri); - if ($parts === false) { - throw new \InvalidArgumentException("Unable to parse URI: $uri"); - } - $this->applyParts($parts); - } - } - - public function __toString() - { - return self::createUriString( - $this->scheme, - $this->getAuthority(), - $this->path, - $this->query, - $this->fragment - ); - } - - /** - * Removes dot segments from a path and returns the new path. - * - * @param string $path - * - * @return string - * @link http://tools.ietf.org/html/rfc3986#section-5.2.4 - */ - public static function removeDotSegments($path) - { - static $noopPaths = ['' => true, '/' => true, '*' => true]; - static $ignoreSegments = ['.' => true, '..' => true]; - - if (isset($noopPaths[$path])) { - return $path; - } - - $results = []; - $segments = explode('/', $path); - foreach ($segments as $segment) { - if ($segment === '..') { - array_pop($results); - } elseif (!isset($ignoreSegments[$segment])) { - $results[] = $segment; - } - } - - $newPath = implode('/', $results); - // Add the leading slash if necessary - if (substr($path, 0, 1) === '/' && - substr($newPath, 0, 1) !== '/' - ) { - $newPath = '/' . $newPath; - } - - // Add the trailing slash if necessary - if ($newPath !== '/' && isset($ignoreSegments[end($segments)])) { - $newPath .= '/'; - } - - return $newPath; - } - - /** - * Resolve a base URI with a relative URI and return a new URI. - * - * @param UriInterface $base Base URI - * @param string|UriInterface $rel Relative URI - * - * @return UriInterface - * @link http://tools.ietf.org/html/rfc3986#section-5.2 - */ - public static function resolve(UriInterface $base, $rel) - { - if (!($rel instanceof UriInterface)) { - $rel = new self($rel); - } - - if ((string) $rel === '') { - // we can simply return the same base URI instance for this same-document reference - return $base; - } - - if ($rel->getScheme() != '') { - return $rel->withPath(self::removeDotSegments($rel->getPath())); - } - - if ($rel->getAuthority() != '') { - $targetAuthority = $rel->getAuthority(); - $targetPath = self::removeDotSegments($rel->getPath()); - $targetQuery = $rel->getQuery(); - } else { - $targetAuthority = $base->getAuthority(); - if ($rel->getPath() === '') { - $targetPath = $base->getPath(); - $targetQuery = $rel->getQuery() != '' ? $rel->getQuery() : $base->getQuery(); - } else { - if ($rel->getPath()[0] === '/') { - $targetPath = $rel->getPath(); - } else { - if ($targetAuthority != '' && $base->getPath() === '') { - $targetPath = '/' . $rel->getPath(); - } else { - $lastSlashPos = strrpos($base->getPath(), '/'); - if ($lastSlashPos === false) { - $targetPath = $rel->getPath(); - } else { - $targetPath = substr($base->getPath(), 0, $lastSlashPos + 1) . $rel->getPath(); - } - } - } - $targetPath = self::removeDotSegments($targetPath); - $targetQuery = $rel->getQuery(); - } - } - - return new self(self::createUriString( - $base->getScheme(), - $targetAuthority, - $targetPath, - $targetQuery, - $rel->getFragment() - )); - } - - /** - * Create a new URI with a specific query string value removed. - * - * Any existing query string values that exactly match the provided key are - * removed. - * - * @param UriInterface $uri URI to use as a base. - * @param string $key Query string key to remove. - * - * @return UriInterface - */ - public static function withoutQueryValue(UriInterface $uri, $key) - { - $current = $uri->getQuery(); - if ($current == '') { - return $uri; - } - - $decodedKey = rawurldecode($key); - $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { - return rawurldecode(explode('=', $part)[0]) !== $decodedKey; - }); - - return $uri->withQuery(implode('&', $result)); - } - - /** - * Create a new URI with a specific query string value. - * - * Any existing query string values that exactly match the provided key are - * removed and replaced with the given key value pair. - * - * A value of null will set the query string key without a value, e.g. "key" - * instead of "key=value". - * - * @param UriInterface $uri URI to use as a base. - * @param string $key Key to set. - * @param string|null $value Value to set - * - * @return UriInterface - */ - public static function withQueryValue(UriInterface $uri, $key, $value) - { - $current = $uri->getQuery(); - - if ($current == '') { - $result = []; - } else { - $decodedKey = rawurldecode($key); - $result = array_filter(explode('&', $current), function ($part) use ($decodedKey) { - return rawurldecode(explode('=', $part)[0]) !== $decodedKey; - }); - } - - // Query string separators ("=", "&") within the key or value need to be encoded - // (while preventing double-encoding) before setting the query string. All other - // chars that need percent-encoding will be encoded by withQuery(). - $key = strtr($key, self::$replaceQuery); - - if ($value !== null) { - $result[] = $key . '=' . strtr($value, self::$replaceQuery); - } else { - $result[] = $key; - } - - return $uri->withQuery(implode('&', $result)); - } - - /** - * Create a URI from a hash of parse_url parts. - * - * @param array $parts - * - * @return self - */ - public static function fromParts(array $parts) - { - $uri = new self(); - $uri->applyParts($parts); - return $uri; - } - - public function getScheme() - { - return $this->scheme; - } - - public function getAuthority() - { - if ($this->host == '') { - return ''; - } - - $authority = $this->host; - if ($this->userInfo != '') { - $authority = $this->userInfo . '@' . $authority; - } - - if ($this->port !== null) { - $authority .= ':' . $this->port; - } - - return $authority; - } - - public function getUserInfo() - { - return $this->userInfo; - } - - public function getHost() - { - return $this->host; - } - - public function getPort() - { - return $this->port; - } - - public function getPath() - { - return $this->path; - } - - public function getQuery() - { - return $this->query; - } - - public function getFragment() - { - return $this->fragment; - } - - public function withScheme($scheme) - { - $scheme = $this->filterScheme($scheme); - - if ($this->scheme === $scheme) { - return $this; - } - - $new = clone $this; - $new->scheme = $scheme; - $new->port = $new->filterPort($new->port); - return $new; - } - - public function withUserInfo($user, $password = null) - { - $info = $user; - if ($password != '') { - $info .= ':' . $password; - } - - if ($this->userInfo === $info) { - return $this; - } - - $new = clone $this; - $new->userInfo = $info; - return $new; - } - - public function withHost($host) - { - $host = $this->filterHost($host); - - if ($this->host === $host) { - return $this; - } - - $new = clone $this; - $new->host = $host; - return $new; - } - - public function withPort($port) - { - $port = $this->filterPort($port); - - if ($this->port === $port) { - return $this; - } - - $new = clone $this; - $new->port = $port; - return $new; - } - - public function withPath($path) - { - $path = $this->filterPath($path); - - if ($this->path === $path) { - return $this; - } - - $new = clone $this; - $new->path = $path; - return $new; - } - - public function withQuery($query) - { - $query = $this->filterQueryAndFragment($query); - - if ($this->query === $query) { - return $this; - } - - $new = clone $this; - $new->query = $query; - return $new; - } - - public function withFragment($fragment) - { - $fragment = $this->filterQueryAndFragment($fragment); - - if ($this->fragment === $fragment) { - return $this; - } - - $new = clone $this; - $new->fragment = $fragment; - return $new; - } - - /** - * Apply parse_url parts to a URI. - * - * @param array $parts Array of parse_url parts to apply. - */ - private function applyParts(array $parts) - { - $this->scheme = isset($parts['scheme']) - ? $this->filterScheme($parts['scheme']) - : ''; - $this->userInfo = isset($parts['user']) ? $parts['user'] : ''; - $this->host = isset($parts['host']) - ? $this->filterHost($parts['host']) - : ''; - $this->port = isset($parts['port']) - ? $this->filterPort($parts['port']) - : null; - $this->path = isset($parts['path']) - ? $this->filterPath($parts['path']) - : ''; - $this->query = isset($parts['query']) - ? $this->filterQueryAndFragment($parts['query']) - : ''; - $this->fragment = isset($parts['fragment']) - ? $this->filterQueryAndFragment($parts['fragment']) - : ''; - if (isset($parts['pass'])) { - $this->userInfo .= ':' . $parts['pass']; - } - } - - /** - * Create a URI string from its various parts - * - * @param string $scheme - * @param string $authority - * @param string $path - * @param string $query - * @param string $fragment - * @return string - */ - private static function createUriString($scheme, $authority, $path, $query, $fragment) - { - $uri = ''; - - if ($scheme != '') { - $uri .= $scheme . ':'; - } - - if ($authority != '') { - $uri .= '//' . $authority; - } - - if ($path != '') { - if ($path[0] !== '/') { - if ($authority != '') { - // If the path is rootless and an authority is present, the path MUST be prefixed by "/" - $path = '/' . $path; - } - } elseif (isset($path[1]) && $path[1] === '/') { - if ($authority == '') { - // If the path is starting with more than one "/" and no authority is present, the - // starting slashes MUST be reduced to one. - $path = '/' . ltrim($path, '/'); - } - } - - $uri .= $path; - } - - if ($query != '') { - $uri .= '?' . $query; - } - - if ($fragment != '') { - $uri .= '#' . $fragment; - } - - return $uri; - } - - /** - * Is a given port non-standard for the current scheme? - * - * @param string $scheme - * @param int $port - * - * @return bool - */ - private static function isNonStandardPort($scheme, $port) - { - return !isset(self::$schemes[$scheme]) || $port !== self::$schemes[$scheme]; - } - - /** - * @param string $scheme - * - * @return string - * - * @throws \InvalidArgumentException If the scheme is invalid. - */ - private function filterScheme($scheme) - { - if (!is_string($scheme)) { - throw new \InvalidArgumentException('Scheme must be a string'); - } - - return strtolower($scheme); - } - - /** - * @param string $host - * - * @return string - * - * @throws \InvalidArgumentException If the host is invalid. - */ - private function filterHost($host) - { - if (!is_string($host)) { - throw new \InvalidArgumentException('Host must be a string'); - } - - return strtolower($host); - } - - /** - * @param int|null $port - * - * @return int|null - * - * @throws \InvalidArgumentException If the port is invalid. - */ - private function filterPort($port) - { - if ($port === null) { - return null; - } - - $port = (int) $port; - if (1 > $port || 0xffff < $port) { - throw new \InvalidArgumentException( - sprintf('Invalid port: %d. Must be between 1 and 65535', $port) - ); - } - - return self::isNonStandardPort($this->scheme, $port) ? $port : null; - } - - /** - * Filters the path of a URI - * - * @param string $path - * - * @return string - * - * @throws \InvalidArgumentException If the path is invalid. - */ - private function filterPath($path) - { - if (!is_string($path)) { - throw new \InvalidArgumentException('Path must be a string'); - } - - return preg_replace_callback( - '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/', - [$this, 'rawurlencodeMatchZero'], - $path - ); - } - - /** - * Filters the query string or fragment of a URI. - * - * @param string $str - * - * @return string - * - * @throws \InvalidArgumentException If the query or fragment is invalid. - */ - private function filterQueryAndFragment($str) - { - if (!is_string($str)) { - throw new \InvalidArgumentException('Query and fragment must be a string'); - } - - return preg_replace_callback( - '/(?:[^' . self::$charUnreserved . self::$charSubDelims . '%:@\/\?]++|%(?![A-Fa-f0-9]{2}))/', - [$this, 'rawurlencodeMatchZero'], - $str - ); - } - - private function rawurlencodeMatchZero(array $match) - { - return rawurlencode($match[0]); - } -} diff --git a/vendor/guzzlehttp/psr7/src/functions.php b/vendor/guzzlehttp/psr7/src/functions.php deleted file mode 100644 index 96bf92611..000000000 --- a/vendor/guzzlehttp/psr7/src/functions.php +++ /dev/null @@ -1,826 +0,0 @@ -getMethod() . ' ' - . $message->getRequestTarget()) - . ' HTTP/' . $message->getProtocolVersion(); - if (!$message->hasHeader('host')) { - $msg .= "\r\nHost: " . $message->getUri()->getHost(); - } - } elseif ($message instanceof ResponseInterface) { - $msg = 'HTTP/' . $message->getProtocolVersion() . ' ' - . $message->getStatusCode() . ' ' - . $message->getReasonPhrase(); - } else { - throw new \InvalidArgumentException('Unknown message type'); - } - - foreach ($message->getHeaders() as $name => $values) { - $msg .= "\r\n{$name}: " . implode(', ', $values); - } - - return "{$msg}\r\n\r\n" . $message->getBody(); -} - -/** - * Returns a UriInterface for the given value. - * - * This function accepts a string or {@see Psr\Http\Message\UriInterface} and - * returns a UriInterface for the given value. If the value is already a - * `UriInterface`, it is returned as-is. - * - * @param string|UriInterface $uri - * - * @return UriInterface - * @throws \InvalidArgumentException - */ -function uri_for($uri) -{ - if ($uri instanceof UriInterface) { - return $uri; - } elseif (is_string($uri)) { - return new Uri($uri); - } - - throw new \InvalidArgumentException('URI must be a string or UriInterface'); -} - -/** - * Create a new stream based on the input type. - * - * Options is an associative array that can contain the following keys: - * - metadata: Array of custom metadata. - * - size: Size of the stream. - * - * @param resource|string|null|int|float|bool|StreamInterface|callable $resource Entity body data - * @param array $options Additional options - * - * @return Stream - * @throws \InvalidArgumentException if the $resource arg is not valid. - */ -function stream_for($resource = '', array $options = []) -{ - if (is_scalar($resource)) { - $stream = fopen('php://temp', 'r+'); - if ($resource !== '') { - fwrite($stream, $resource); - fseek($stream, 0); - } - return new Stream($stream, $options); - } - - switch (gettype($resource)) { - case 'resource': - return new Stream($resource, $options); - case 'object': - if ($resource instanceof StreamInterface) { - return $resource; - } elseif ($resource instanceof \Iterator) { - return new PumpStream(function () use ($resource) { - if (!$resource->valid()) { - return false; - } - $result = $resource->current(); - $resource->next(); - return $result; - }, $options); - } elseif (method_exists($resource, '__toString')) { - return stream_for((string) $resource, $options); - } - break; - case 'NULL': - return new Stream(fopen('php://temp', 'r+'), $options); - } - - if (is_callable($resource)) { - return new PumpStream($resource, $options); - } - - throw new \InvalidArgumentException('Invalid resource type: ' . gettype($resource)); -} - -/** - * Parse an array of header values containing ";" separated data into an - * array of associative arrays representing the header key value pair - * data of the header. When a parameter does not contain a value, but just - * contains a key, this function will inject a key with a '' string value. - * - * @param string|array $header Header to parse into components. - * - * @return array Returns the parsed header values. - */ -function parse_header($header) -{ - static $trimmed = "\"' \n\t\r"; - $params = $matches = []; - - foreach (normalize_header($header) as $val) { - $part = []; - foreach (preg_split('/;(?=([^"]*"[^"]*")*[^"]*$)/', $val) as $kvp) { - if (preg_match_all('/<[^>]+>|[^=]+/', $kvp, $matches)) { - $m = $matches[0]; - if (isset($m[1])) { - $part[trim($m[0], $trimmed)] = trim($m[1], $trimmed); - } else { - $part[] = trim($m[0], $trimmed); - } - } - } - if ($part) { - $params[] = $part; - } - } - - return $params; -} - -/** - * Converts an array of header values that may contain comma separated - * headers into an array of headers with no comma separated values. - * - * @param string|array $header Header to normalize. - * - * @return array Returns the normalized header field values. - */ -function normalize_header($header) -{ - if (!is_array($header)) { - return array_map('trim', explode(',', $header)); - } - - $result = []; - foreach ($header as $value) { - foreach ((array) $value as $v) { - if (strpos($v, ',') === false) { - $result[] = $v; - continue; - } - foreach (preg_split('/,(?=([^"]*"[^"]*")*[^"]*$)/', $v) as $vv) { - $result[] = trim($vv); - } - } - } - - return $result; -} - -/** - * Clone and modify a request with the given changes. - * - * The changes can be one of: - * - method: (string) Changes the HTTP method. - * - set_headers: (array) Sets the given headers. - * - remove_headers: (array) Remove the given headers. - * - body: (mixed) Sets the given body. - * - uri: (UriInterface) Set the URI. - * - query: (string) Set the query string value of the URI. - * - version: (string) Set the protocol version. - * - * @param RequestInterface $request Request to clone and modify. - * @param array $changes Changes to apply. - * - * @return RequestInterface - */ -function modify_request(RequestInterface $request, array $changes) -{ - if (!$changes) { - return $request; - } - - $headers = $request->getHeaders(); - - if (!isset($changes['uri'])) { - $uri = $request->getUri(); - } else { - // Remove the host header if one is on the URI - if ($host = $changes['uri']->getHost()) { - $changes['set_headers']['Host'] = $host; - - if ($port = $changes['uri']->getPort()) { - $standardPorts = ['http' => 80, 'https' => 443]; - $scheme = $changes['uri']->getScheme(); - if (isset($standardPorts[$scheme]) && $port != $standardPorts[$scheme]) { - $changes['set_headers']['Host'] .= ':'.$port; - } - } - } - $uri = $changes['uri']; - } - - if (!empty($changes['remove_headers'])) { - $headers = _caseless_remove($changes['remove_headers'], $headers); - } - - if (!empty($changes['set_headers'])) { - $headers = _caseless_remove(array_keys($changes['set_headers']), $headers); - $headers = $changes['set_headers'] + $headers; - } - - if (isset($changes['query'])) { - $uri = $uri->withQuery($changes['query']); - } - - if ($request instanceof ServerRequestInterface) { - return new ServerRequest( - isset($changes['method']) ? $changes['method'] : $request->getMethod(), - $uri, - $headers, - isset($changes['body']) ? $changes['body'] : $request->getBody(), - isset($changes['version']) - ? $changes['version'] - : $request->getProtocolVersion(), - $request->getServerParams() - ); - } - - return new Request( - isset($changes['method']) ? $changes['method'] : $request->getMethod(), - $uri, - $headers, - isset($changes['body']) ? $changes['body'] : $request->getBody(), - isset($changes['version']) - ? $changes['version'] - : $request->getProtocolVersion() - ); -} - -/** - * Attempts to rewind a message body and throws an exception on failure. - * - * The body of the message will only be rewound if a call to `tell()` returns a - * value other than `0`. - * - * @param MessageInterface $message Message to rewind - * - * @throws \RuntimeException - */ -function rewind_body(MessageInterface $message) -{ - $body = $message->getBody(); - - if ($body->tell()) { - $body->rewind(); - } -} - -/** - * Safely opens a PHP stream resource using a filename. - * - * When fopen fails, PHP normally raises a warning. This function adds an - * error handler that checks for errors and throws an exception instead. - * - * @param string $filename File to open - * @param string $mode Mode used to open the file - * - * @return resource - * @throws \RuntimeException if the file cannot be opened - */ -function try_fopen($filename, $mode) -{ - $ex = null; - set_error_handler(function () use ($filename, $mode, &$ex) { - $ex = new \RuntimeException(sprintf( - 'Unable to open %s using mode %s: %s', - $filename, - $mode, - func_get_args()[1] - )); - }); - - $handle = fopen($filename, $mode); - restore_error_handler(); - - if ($ex) { - /** @var $ex \RuntimeException */ - throw $ex; - } - - return $handle; -} - -/** - * Copy the contents of a stream into a string until the given number of - * bytes have been read. - * - * @param StreamInterface $stream Stream to read - * @param int $maxLen Maximum number of bytes to read. Pass -1 - * to read the entire stream. - * @return string - * @throws \RuntimeException on error. - */ -function copy_to_string(StreamInterface $stream, $maxLen = -1) -{ - $buffer = ''; - - if ($maxLen === -1) { - while (!$stream->eof()) { - $buf = $stream->read(1048576); - // Using a loose equality here to match on '' and false. - if ($buf == null) { - break; - } - $buffer .= $buf; - } - return $buffer; - } - - $len = 0; - while (!$stream->eof() && $len < $maxLen) { - $buf = $stream->read($maxLen - $len); - // Using a loose equality here to match on '' and false. - if ($buf == null) { - break; - } - $buffer .= $buf; - $len = strlen($buffer); - } - - return $buffer; -} - -/** - * Copy the contents of a stream into another stream until the given number - * of bytes have been read. - * - * @param StreamInterface $source Stream to read from - * @param StreamInterface $dest Stream to write to - * @param int $maxLen Maximum number of bytes to read. Pass -1 - * to read the entire stream. - * - * @throws \RuntimeException on error. - */ -function copy_to_stream( - StreamInterface $source, - StreamInterface $dest, - $maxLen = -1 -) { - if ($maxLen === -1) { - while (!$source->eof()) { - if (!$dest->write($source->read(1048576))) { - break; - } - } - return; - } - - $bytes = 0; - while (!$source->eof()) { - $buf = $source->read($maxLen - $bytes); - if (!($len = strlen($buf))) { - break; - } - $bytes += $len; - $dest->write($buf); - if ($bytes == $maxLen) { - break; - } - } -} - -/** - * Calculate a hash of a Stream - * - * @param StreamInterface $stream Stream to calculate the hash for - * @param string $algo Hash algorithm (e.g. md5, crc32, etc) - * @param bool $rawOutput Whether or not to use raw output - * - * @return string Returns the hash of the stream - * @throws \RuntimeException on error. - */ -function hash( - StreamInterface $stream, - $algo, - $rawOutput = false -) { - $pos = $stream->tell(); - - if ($pos > 0) { - $stream->rewind(); - } - - $ctx = hash_init($algo); - while (!$stream->eof()) { - hash_update($ctx, $stream->read(1048576)); - } - - $out = hash_final($ctx, (bool) $rawOutput); - $stream->seek($pos); - - return $out; -} - -/** - * Read a line from the stream up to the maximum allowed buffer length - * - * @param StreamInterface $stream Stream to read from - * @param int $maxLength Maximum buffer length - * - * @return string|bool - */ -function readline(StreamInterface $stream, $maxLength = null) -{ - $buffer = ''; - $size = 0; - - while (!$stream->eof()) { - // Using a loose equality here to match on '' and false. - if (null == ($byte = $stream->read(1))) { - return $buffer; - } - $buffer .= $byte; - // Break when a new line is found or the max length - 1 is reached - if ($byte === "\n" || ++$size === $maxLength - 1) { - break; - } - } - - return $buffer; -} - -/** - * Parses a request message string into a request object. - * - * @param string $message Request message string. - * - * @return Request - */ -function parse_request($message) -{ - $data = _parse_message($message); - $matches = []; - if (!preg_match('/^[\S]+\s+([a-zA-Z]+:\/\/|\/).*/', $data['start-line'], $matches)) { - throw new \InvalidArgumentException('Invalid request string'); - } - $parts = explode(' ', $data['start-line'], 3); - $version = isset($parts[2]) ? explode('/', $parts[2])[1] : '1.1'; - - $request = new Request( - $parts[0], - $matches[1] === '/' ? _parse_request_uri($parts[1], $data['headers']) : $parts[1], - $data['headers'], - $data['body'], - $version - ); - - return $matches[1] === '/' ? $request : $request->withRequestTarget($parts[1]); -} - -/** - * Parses a response message string into a response object. - * - * @param string $message Response message string. - * - * @return Response - */ -function parse_response($message) -{ - $data = _parse_message($message); - if (!preg_match('/^HTTP\/.* [0-9]{3} .*/', $data['start-line'])) { - throw new \InvalidArgumentException('Invalid response string'); - } - $parts = explode(' ', $data['start-line'], 3); - - return new Response( - $parts[1], - $data['headers'], - $data['body'], - explode('/', $parts[0])[1], - isset($parts[2]) ? $parts[2] : null - ); -} - -/** - * Parse a query string into an associative array. - * - * If multiple values are found for the same key, the value of that key - * value pair will become an array. This function does not parse nested - * PHP style arrays into an associative array (e.g., foo[a]=1&foo[b]=2 will - * be parsed into ['foo[a]' => '1', 'foo[b]' => '2']). - * - * @param string $str Query string to parse - * @param bool|string $urlEncoding How the query string is encoded - * - * @return array - */ -function parse_query($str, $urlEncoding = true) -{ - $result = []; - - if ($str === '') { - return $result; - } - - if ($urlEncoding === true) { - $decoder = function ($value) { - return rawurldecode(str_replace('+', ' ', $value)); - }; - } elseif ($urlEncoding == PHP_QUERY_RFC3986) { - $decoder = 'rawurldecode'; - } elseif ($urlEncoding == PHP_QUERY_RFC1738) { - $decoder = 'urldecode'; - } else { - $decoder = function ($str) { return $str; }; - } - - foreach (explode('&', $str) as $kvp) { - $parts = explode('=', $kvp, 2); - $key = $decoder($parts[0]); - $value = isset($parts[1]) ? $decoder($parts[1]) : null; - if (!isset($result[$key])) { - $result[$key] = $value; - } else { - if (!is_array($result[$key])) { - $result[$key] = [$result[$key]]; - } - $result[$key][] = $value; - } - } - - return $result; -} - -/** - * Build a query string from an array of key value pairs. - * - * This function can use the return value of parse_query() to build a query - * string. This function does not modify the provided keys when an array is - * encountered (like http_build_query would). - * - * @param array $params Query string parameters. - * @param int|false $encoding Set to false to not encode, PHP_QUERY_RFC3986 - * to encode using RFC3986, or PHP_QUERY_RFC1738 - * to encode using RFC1738. - * @return string - */ -function build_query(array $params, $encoding = PHP_QUERY_RFC3986) -{ - if (!$params) { - return ''; - } - - if ($encoding === false) { - $encoder = function ($str) { return $str; }; - } elseif ($encoding === PHP_QUERY_RFC3986) { - $encoder = 'rawurlencode'; - } elseif ($encoding === PHP_QUERY_RFC1738) { - $encoder = 'urlencode'; - } else { - throw new \InvalidArgumentException('Invalid type'); - } - - $qs = ''; - foreach ($params as $k => $v) { - $k = $encoder($k); - if (!is_array($v)) { - $qs .= $k; - if ($v !== null) { - $qs .= '=' . $encoder($v); - } - $qs .= '&'; - } else { - foreach ($v as $vv) { - $qs .= $k; - if ($vv !== null) { - $qs .= '=' . $encoder($vv); - } - $qs .= '&'; - } - } - } - - return $qs ? (string) substr($qs, 0, -1) : ''; -} - -/** - * Determines the mimetype of a file by looking at its extension. - * - * @param $filename - * - * @return null|string - */ -function mimetype_from_filename($filename) -{ - return mimetype_from_extension(pathinfo($filename, PATHINFO_EXTENSION)); -} - -/** - * Maps a file extensions to a mimetype. - * - * @param $extension string The file extension. - * - * @return string|null - * @link http://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x/conf/mime.types - */ -function mimetype_from_extension($extension) -{ - static $mimetypes = [ - '7z' => 'application/x-7z-compressed', - 'aac' => 'audio/x-aac', - 'ai' => 'application/postscript', - 'aif' => 'audio/x-aiff', - 'asc' => 'text/plain', - 'asf' => 'video/x-ms-asf', - 'atom' => 'application/atom+xml', - 'avi' => 'video/x-msvideo', - 'bmp' => 'image/bmp', - 'bz2' => 'application/x-bzip2', - 'cer' => 'application/pkix-cert', - 'crl' => 'application/pkix-crl', - 'crt' => 'application/x-x509-ca-cert', - 'css' => 'text/css', - 'csv' => 'text/csv', - 'cu' => 'application/cu-seeme', - 'deb' => 'application/x-debian-package', - 'doc' => 'application/msword', - 'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', - 'dvi' => 'application/x-dvi', - 'eot' => 'application/vnd.ms-fontobject', - 'eps' => 'application/postscript', - 'epub' => 'application/epub+zip', - 'etx' => 'text/x-setext', - 'flac' => 'audio/flac', - 'flv' => 'video/x-flv', - 'gif' => 'image/gif', - 'gz' => 'application/gzip', - 'htm' => 'text/html', - 'html' => 'text/html', - 'ico' => 'image/x-icon', - 'ics' => 'text/calendar', - 'ini' => 'text/plain', - 'iso' => 'application/x-iso9660-image', - 'jar' => 'application/java-archive', - 'jpe' => 'image/jpeg', - 'jpeg' => 'image/jpeg', - 'jpg' => 'image/jpeg', - 'js' => 'text/javascript', - 'json' => 'application/json', - 'latex' => 'application/x-latex', - 'log' => 'text/plain', - 'm4a' => 'audio/mp4', - 'm4v' => 'video/mp4', - 'mid' => 'audio/midi', - 'midi' => 'audio/midi', - 'mov' => 'video/quicktime', - 'mp3' => 'audio/mpeg', - 'mp4' => 'video/mp4', - 'mp4a' => 'audio/mp4', - 'mp4v' => 'video/mp4', - 'mpe' => 'video/mpeg', - 'mpeg' => 'video/mpeg', - 'mpg' => 'video/mpeg', - 'mpg4' => 'video/mp4', - 'oga' => 'audio/ogg', - 'ogg' => 'audio/ogg', - 'ogv' => 'video/ogg', - 'ogx' => 'application/ogg', - 'pbm' => 'image/x-portable-bitmap', - 'pdf' => 'application/pdf', - 'pgm' => 'image/x-portable-graymap', - 'png' => 'image/png', - 'pnm' => 'image/x-portable-anymap', - 'ppm' => 'image/x-portable-pixmap', - 'ppt' => 'application/vnd.ms-powerpoint', - 'pptx' => 'application/vnd.openxmlformats-officedocument.presentationml.presentation', - 'ps' => 'application/postscript', - 'qt' => 'video/quicktime', - 'rar' => 'application/x-rar-compressed', - 'ras' => 'image/x-cmu-raster', - 'rss' => 'application/rss+xml', - 'rtf' => 'application/rtf', - 'sgm' => 'text/sgml', - 'sgml' => 'text/sgml', - 'svg' => 'image/svg+xml', - 'swf' => 'application/x-shockwave-flash', - 'tar' => 'application/x-tar', - 'tif' => 'image/tiff', - 'tiff' => 'image/tiff', - 'torrent' => 'application/x-bittorrent', - 'ttf' => 'application/x-font-ttf', - 'txt' => 'text/plain', - 'wav' => 'audio/x-wav', - 'webm' => 'video/webm', - 'wma' => 'audio/x-ms-wma', - 'wmv' => 'video/x-ms-wmv', - 'woff' => 'application/x-font-woff', - 'wsdl' => 'application/wsdl+xml', - 'xbm' => 'image/x-xbitmap', - 'xls' => 'application/vnd.ms-excel', - 'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', - 'xml' => 'application/xml', - 'xpm' => 'image/x-xpixmap', - 'xwd' => 'image/x-xwindowdump', - 'yaml' => 'text/yaml', - 'yml' => 'text/yaml', - 'zip' => 'application/zip', - ]; - - $extension = strtolower($extension); - - return isset($mimetypes[$extension]) - ? $mimetypes[$extension] - : null; -} - -/** - * Parses an HTTP message into an associative array. - * - * The array contains the "start-line" key containing the start line of - * the message, "headers" key containing an associative array of header - * array values, and a "body" key containing the body of the message. - * - * @param string $message HTTP request or response to parse. - * - * @return array - * @internal - */ -function _parse_message($message) -{ - if (!$message) { - throw new \InvalidArgumentException('Invalid message'); - } - - // Iterate over each line in the message, accounting for line endings - $lines = preg_split('/(\\r?\\n)/', $message, -1, PREG_SPLIT_DELIM_CAPTURE); - $result = ['start-line' => array_shift($lines), 'headers' => [], 'body' => '']; - array_shift($lines); - - for ($i = 0, $totalLines = count($lines); $i < $totalLines; $i += 2) { - $line = $lines[$i]; - // If two line breaks were encountered, then this is the end of body - if (empty($line)) { - if ($i < $totalLines - 1) { - $result['body'] = implode('', array_slice($lines, $i + 2)); - } - break; - } - if (strpos($line, ':')) { - $parts = explode(':', $line, 2); - $key = trim($parts[0]); - $value = isset($parts[1]) ? trim($parts[1]) : ''; - $result['headers'][$key][] = $value; - } - } - - return $result; -} - -/** - * Constructs a URI for an HTTP request message. - * - * @param string $path Path from the start-line - * @param array $headers Array of headers (each value an array). - * - * @return string - * @internal - */ -function _parse_request_uri($path, array $headers) -{ - $hostKey = array_filter(array_keys($headers), function ($k) { - return strtolower($k) === 'host'; - }); - - // If no host is found, then a full URI cannot be constructed. - if (!$hostKey) { - return $path; - } - - $host = $headers[reset($hostKey)][0]; - $scheme = substr($host, -4) === ':443' ? 'https' : 'http'; - - return $scheme . '://' . $host . '/' . ltrim($path, '/'); -} - -/** @internal */ -function _caseless_remove($keys, array $data) -{ - $result = []; - - foreach ($keys as &$key) { - $key = strtolower($key); - } - - foreach ($data as $k => $v) { - if (!in_array(strtolower($k), $keys)) { - $result[$k] = $v; - } - } - - return $result; -} diff --git a/vendor/guzzlehttp/psr7/src/functions_include.php b/vendor/guzzlehttp/psr7/src/functions_include.php deleted file mode 100644 index 96a4a83a0..000000000 --- a/vendor/guzzlehttp/psr7/src/functions_include.php +++ /dev/null @@ -1,6 +0,0 @@ -getMockBuilder('Psr\Http\Message\StreamInterface') - ->setMethods(['isReadable']) - ->getMockForAbstractClass(); - $s->expects($this->once()) - ->method('isReadable') - ->will($this->returnValue(false)); - $a->addStream($s); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage The AppendStream can only seek with SEEK_SET - */ - public function testValidatesSeekType() - { - $a = new AppendStream(); - $a->seek(100, SEEK_CUR); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Unable to seek stream 0 of the AppendStream - */ - public function testTriesToRewindOnSeek() - { - $a = new AppendStream(); - $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface') - ->setMethods(['isReadable', 'rewind', 'isSeekable']) - ->getMockForAbstractClass(); - $s->expects($this->once()) - ->method('isReadable') - ->will($this->returnValue(true)); - $s->expects($this->once()) - ->method('isSeekable') - ->will($this->returnValue(true)); - $s->expects($this->once()) - ->method('rewind') - ->will($this->throwException(new \RuntimeException())); - $a->addStream($s); - $a->seek(10); - } - - public function testSeeksToPositionByReading() - { - $a = new AppendStream([ - Psr7\stream_for('foo'), - Psr7\stream_for('bar'), - Psr7\stream_for('baz'), - ]); - - $a->seek(3); - $this->assertEquals(3, $a->tell()); - $this->assertEquals('bar', $a->read(3)); - - $a->seek(6); - $this->assertEquals(6, $a->tell()); - $this->assertEquals('baz', $a->read(3)); - } - - public function testDetachesEachStream() - { - $s1 = Psr7\stream_for('foo'); - $s2 = Psr7\stream_for('bar'); - $a = new AppendStream([$s1, $s2]); - $this->assertSame('foobar', (string) $a); - $a->detach(); - $this->assertSame('', (string) $a); - $this->assertSame(0, $a->getSize()); - } - - public function testClosesEachStream() - { - $s1 = Psr7\stream_for('foo'); - $a = new AppendStream([$s1]); - $a->close(); - $this->assertSame('', (string) $a); - } - - /** - * @expectedExceptionMessage Cannot write to an AppendStream - * @expectedException \RuntimeException - */ - public function testIsNotWritable() - { - $a = new AppendStream([Psr7\stream_for('foo')]); - $this->assertFalse($a->isWritable()); - $this->assertTrue($a->isSeekable()); - $this->assertTrue($a->isReadable()); - $a->write('foo'); - } - - public function testDoesNotNeedStreams() - { - $a = new AppendStream(); - $this->assertEquals('', (string) $a); - } - - public function testCanReadFromMultipleStreams() - { - $a = new AppendStream([ - Psr7\stream_for('foo'), - Psr7\stream_for('bar'), - Psr7\stream_for('baz'), - ]); - $this->assertFalse($a->eof()); - $this->assertSame(0, $a->tell()); - $this->assertEquals('foo', $a->read(3)); - $this->assertEquals('bar', $a->read(3)); - $this->assertEquals('baz', $a->read(3)); - $this->assertSame('', $a->read(1)); - $this->assertTrue($a->eof()); - $this->assertSame(9, $a->tell()); - $this->assertEquals('foobarbaz', (string) $a); - } - - public function testCanDetermineSizeFromMultipleStreams() - { - $a = new AppendStream([ - Psr7\stream_for('foo'), - Psr7\stream_for('bar') - ]); - $this->assertEquals(6, $a->getSize()); - - $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface') - ->setMethods(['isSeekable', 'isReadable']) - ->getMockForAbstractClass(); - $s->expects($this->once()) - ->method('isSeekable') - ->will($this->returnValue(null)); - $s->expects($this->once()) - ->method('isReadable') - ->will($this->returnValue(true)); - $a->addStream($s); - $this->assertNull($a->getSize()); - } - - public function testCatchesExceptionsWhenCastingToString() - { - $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface') - ->setMethods(['isSeekable', 'read', 'isReadable', 'eof']) - ->getMockForAbstractClass(); - $s->expects($this->once()) - ->method('isSeekable') - ->will($this->returnValue(true)); - $s->expects($this->once()) - ->method('read') - ->will($this->throwException(new \RuntimeException('foo'))); - $s->expects($this->once()) - ->method('isReadable') - ->will($this->returnValue(true)); - $s->expects($this->any()) - ->method('eof') - ->will($this->returnValue(false)); - $a = new AppendStream([$s]); - $this->assertFalse($a->eof()); - $this->assertSame('', (string) $a); - } - - public function testCanDetach() - { - $s = new AppendStream(); - $s->detach(); - } - - public function testReturnsEmptyMetadata() - { - $s = new AppendStream(); - $this->assertEquals([], $s->getMetadata()); - $this->assertNull($s->getMetadata('foo')); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php b/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php deleted file mode 100644 index 0a635d467..000000000 --- a/vendor/guzzlehttp/psr7/tests/BufferStreamTest.php +++ /dev/null @@ -1,63 +0,0 @@ -assertTrue($b->isReadable()); - $this->assertTrue($b->isWritable()); - $this->assertFalse($b->isSeekable()); - $this->assertEquals(null, $b->getMetadata('foo')); - $this->assertEquals(10, $b->getMetadata('hwm')); - $this->assertEquals([], $b->getMetadata()); - } - - public function testRemovesReadDataFromBuffer() - { - $b = new BufferStream(); - $this->assertEquals(3, $b->write('foo')); - $this->assertEquals(3, $b->getSize()); - $this->assertFalse($b->eof()); - $this->assertEquals('foo', $b->read(10)); - $this->assertTrue($b->eof()); - $this->assertEquals('', $b->read(10)); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Cannot determine the position of a BufferStream - */ - public function testCanCastToStringOrGetContents() - { - $b = new BufferStream(); - $b->write('foo'); - $b->write('baz'); - $this->assertEquals('foo', $b->read(3)); - $b->write('bar'); - $this->assertEquals('bazbar', (string) $b); - $b->tell(); - } - - public function testDetachClearsBuffer() - { - $b = new BufferStream(); - $b->write('foo'); - $b->detach(); - $this->assertTrue($b->eof()); - $this->assertEquals(3, $b->write('abc')); - $this->assertEquals('abc', $b->read(10)); - } - - public function testExceedingHighwaterMarkReturnsFalseButStillBuffers() - { - $b = new BufferStream(5); - $this->assertEquals(3, $b->write('hi ')); - $this->assertFalse($b->write('hello')); - $this->assertEquals('hi hello', (string) $b); - $this->assertEquals(4, $b->write('test')); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php b/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php deleted file mode 100644 index 60a263673..000000000 --- a/vendor/guzzlehttp/psr7/tests/CachingStreamTest.php +++ /dev/null @@ -1,193 +0,0 @@ -decorated = Psr7\stream_for('testing'); - $this->body = new CachingStream($this->decorated); - } - - public function tearDown() - { - $this->decorated->close(); - $this->body->close(); - } - - public function testUsesRemoteSizeIfPossible() - { - $body = Psr7\stream_for('test'); - $caching = new CachingStream($body); - $this->assertEquals(4, $caching->getSize()); - } - - public function testReadsUntilCachedToByte() - { - $this->body->seek(5); - $this->assertEquals('n', $this->body->read(1)); - $this->body->seek(0); - $this->assertEquals('t', $this->body->read(1)); - } - - public function testCanSeekNearEndWithSeekEnd() - { - $baseStream = Psr7\stream_for(implode('', range('a', 'z'))); - $cached = new CachingStream($baseStream); - $cached->seek(-1, SEEK_END); - $this->assertEquals(25, $baseStream->tell()); - $this->assertEquals('z', $cached->read(1)); - $this->assertEquals(26, $cached->getSize()); - } - - public function testCanSeekToEndWithSeekEnd() - { - $baseStream = Psr7\stream_for(implode('', range('a', 'z'))); - $cached = new CachingStream($baseStream); - $cached->seek(0, SEEK_END); - $this->assertEquals(26, $baseStream->tell()); - $this->assertEquals('', $cached->read(1)); - $this->assertEquals(26, $cached->getSize()); - } - - public function testCanUseSeekEndWithUnknownSize() - { - $baseStream = Psr7\stream_for('testing'); - $decorated = Psr7\FnStream::decorate($baseStream, [ - 'getSize' => function () { return null; } - ]); - $cached = new CachingStream($decorated); - $cached->seek(-1, SEEK_END); - $this->assertEquals('g', $cached->read(1)); - } - - public function testRewindUsesSeek() - { - $a = Psr7\stream_for('foo'); - $d = $this->getMockBuilder('GuzzleHttp\Psr7\CachingStream') - ->setMethods(array('seek')) - ->setConstructorArgs(array($a)) - ->getMock(); - $d->expects($this->once()) - ->method('seek') - ->with(0) - ->will($this->returnValue(true)); - $d->seek(0); - } - - public function testCanSeekToReadBytes() - { - $this->assertEquals('te', $this->body->read(2)); - $this->body->seek(0); - $this->assertEquals('test', $this->body->read(4)); - $this->assertEquals(4, $this->body->tell()); - $this->body->seek(2); - $this->assertEquals(2, $this->body->tell()); - $this->body->seek(2, SEEK_CUR); - $this->assertEquals(4, $this->body->tell()); - $this->assertEquals('ing', $this->body->read(3)); - } - - public function testCanSeekToReadBytesWithPartialBodyReturned() - { - $stream = fopen('php://temp', 'r+'); - fwrite($stream, 'testing'); - fseek($stream, 0); - - $this->decorated = $this->getMockBuilder('\GuzzleHttp\Psr7\Stream') - ->setConstructorArgs([$stream]) - ->setMethods(['read']) - ->getMock(); - - $this->decorated->expects($this->exactly(2)) - ->method('read') - ->willReturnCallback(function($length) use ($stream){ - return fread($stream, 2); - }); - - $this->body = new CachingStream($this->decorated); - - $this->assertEquals(0, $this->body->tell()); - $this->body->seek(4, SEEK_SET); - $this->assertEquals(4, $this->body->tell()); - - $this->body->seek(0); - $this->assertEquals('test', $this->body->read(4)); - } - - public function testWritesToBufferStream() - { - $this->body->read(2); - $this->body->write('hi'); - $this->body->seek(0); - $this->assertEquals('tehiing', (string) $this->body); - } - - public function testSkipsOverwrittenBytes() - { - $decorated = Psr7\stream_for( - implode("\n", array_map(function ($n) { - return str_pad($n, 4, '0', STR_PAD_LEFT); - }, range(0, 25))) - ); - - $body = new CachingStream($decorated); - - $this->assertEquals("0000\n", Psr7\readline($body)); - $this->assertEquals("0001\n", Psr7\readline($body)); - // Write over part of the body yet to be read, so skip some bytes - $this->assertEquals(5, $body->write("TEST\n")); - $this->assertEquals(5, $this->readAttribute($body, 'skipReadBytes')); - // Read, which skips bytes, then reads - $this->assertEquals("0003\n", Psr7\readline($body)); - $this->assertEquals(0, $this->readAttribute($body, 'skipReadBytes')); - $this->assertEquals("0004\n", Psr7\readline($body)); - $this->assertEquals("0005\n", Psr7\readline($body)); - - // Overwrite part of the cached body (so don't skip any bytes) - $body->seek(5); - $this->assertEquals(5, $body->write("ABCD\n")); - $this->assertEquals(0, $this->readAttribute($body, 'skipReadBytes')); - $this->assertEquals("TEST\n", Psr7\readline($body)); - $this->assertEquals("0003\n", Psr7\readline($body)); - $this->assertEquals("0004\n", Psr7\readline($body)); - $this->assertEquals("0005\n", Psr7\readline($body)); - $this->assertEquals("0006\n", Psr7\readline($body)); - $this->assertEquals(5, $body->write("1234\n")); - $this->assertEquals(5, $this->readAttribute($body, 'skipReadBytes')); - - // Seek to 0 and ensure the overwritten bit is replaced - $body->seek(0); - $this->assertEquals("0000\nABCD\nTEST\n0003\n0004\n0005\n0006\n1234\n0008\n0009\n", $body->read(50)); - - // Ensure that casting it to a string does not include the bit that was overwritten - $this->assertContains("0000\nABCD\nTEST\n0003\n0004\n0005\n0006\n1234\n0008\n0009\n", (string) $body); - } - - public function testClosesBothStreams() - { - $s = fopen('php://temp', 'r'); - $a = Psr7\stream_for($s); - $d = new CachingStream($a); - $d->close(); - $this->assertFalse(is_resource($s)); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testEnsuresValidWhence() - { - $this->body->seek(10, -123456); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php b/vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php deleted file mode 100644 index 915b21523..000000000 --- a/vendor/guzzlehttp/psr7/tests/DroppingStreamTest.php +++ /dev/null @@ -1,26 +0,0 @@ -assertEquals(3, $drop->write('hel')); - $this->assertEquals(2, $drop->write('lo')); - $this->assertEquals(5, $drop->getSize()); - $this->assertEquals('hello', $drop->read(5)); - $this->assertEquals(0, $drop->getSize()); - $drop->write('12345678910'); - $this->assertEquals(5, $stream->getSize()); - $this->assertEquals(5, $drop->getSize()); - $this->assertEquals('12345', (string) $drop); - $this->assertEquals(0, $drop->getSize()); - $drop->write('hello'); - $this->assertSame(0, $drop->write('test')); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/FnStreamTest.php b/vendor/guzzlehttp/psr7/tests/FnStreamTest.php deleted file mode 100644 index 66ae90a04..000000000 --- a/vendor/guzzlehttp/psr7/tests/FnStreamTest.php +++ /dev/null @@ -1,90 +0,0 @@ -seek(1); - } - - public function testProxiesToFunction() - { - $s = new FnStream([ - 'read' => function ($len) { - $this->assertEquals(3, $len); - return 'foo'; - } - ]); - - $this->assertEquals('foo', $s->read(3)); - } - - public function testCanCloseOnDestruct() - { - $called = false; - $s = new FnStream([ - 'close' => function () use (&$called) { - $called = true; - } - ]); - unset($s); - $this->assertTrue($called); - } - - public function testDoesNotRequireClose() - { - $s = new FnStream([]); - unset($s); - } - - public function testDecoratesStream() - { - $a = Psr7\stream_for('foo'); - $b = FnStream::decorate($a, []); - $this->assertEquals(3, $b->getSize()); - $this->assertEquals($b->isWritable(), true); - $this->assertEquals($b->isReadable(), true); - $this->assertEquals($b->isSeekable(), true); - $this->assertEquals($b->read(3), 'foo'); - $this->assertEquals($b->tell(), 3); - $this->assertEquals($a->tell(), 3); - $this->assertSame('', $a->read(1)); - $this->assertEquals($b->eof(), true); - $this->assertEquals($a->eof(), true); - $b->seek(0); - $this->assertEquals('foo', (string) $b); - $b->seek(0); - $this->assertEquals('foo', $b->getContents()); - $this->assertEquals($a->getMetadata(), $b->getMetadata()); - $b->seek(0, SEEK_END); - $b->write('bar'); - $this->assertEquals('foobar', (string) $b); - $this->assertInternalType('resource', $b->detach()); - $b->close(); - } - - public function testDecoratesWithCustomizations() - { - $called = false; - $a = Psr7\stream_for('foo'); - $b = FnStream::decorate($a, [ - 'read' => function ($len) use (&$called, $a) { - $called = true; - return $a->read($len); - } - ]); - $this->assertEquals('foo', $b->read(3)); - $this->assertTrue($called); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/FunctionsTest.php b/vendor/guzzlehttp/psr7/tests/FunctionsTest.php deleted file mode 100644 index 664f5e88c..000000000 --- a/vendor/guzzlehttp/psr7/tests/FunctionsTest.php +++ /dev/null @@ -1,619 +0,0 @@ -assertEquals('foobaz', Psr7\copy_to_string($s)); - $s->seek(0); - $this->assertEquals('foo', Psr7\copy_to_string($s, 3)); - $this->assertEquals('baz', Psr7\copy_to_string($s, 3)); - $this->assertEquals('', Psr7\copy_to_string($s)); - } - - public function testCopiesToStringStopsWhenReadFails() - { - $s1 = Psr7\stream_for('foobaz'); - $s1 = FnStream::decorate($s1, [ - 'read' => function () { return ''; } - ]); - $result = Psr7\copy_to_string($s1); - $this->assertEquals('', $result); - } - - public function testCopiesToStream() - { - $s1 = Psr7\stream_for('foobaz'); - $s2 = Psr7\stream_for(''); - Psr7\copy_to_stream($s1, $s2); - $this->assertEquals('foobaz', (string) $s2); - $s2 = Psr7\stream_for(''); - $s1->seek(0); - Psr7\copy_to_stream($s1, $s2, 3); - $this->assertEquals('foo', (string) $s2); - Psr7\copy_to_stream($s1, $s2, 3); - $this->assertEquals('foobaz', (string) $s2); - } - - public function testStopsCopyToStreamWhenWriteFails() - { - $s1 = Psr7\stream_for('foobaz'); - $s2 = Psr7\stream_for(''); - $s2 = FnStream::decorate($s2, ['write' => function () { return 0; }]); - Psr7\copy_to_stream($s1, $s2); - $this->assertEquals('', (string) $s2); - } - - public function testStopsCopyToSteamWhenWriteFailsWithMaxLen() - { - $s1 = Psr7\stream_for('foobaz'); - $s2 = Psr7\stream_for(''); - $s2 = FnStream::decorate($s2, ['write' => function () { return 0; }]); - Psr7\copy_to_stream($s1, $s2, 10); - $this->assertEquals('', (string) $s2); - } - - public function testStopsCopyToSteamWhenReadFailsWithMaxLen() - { - $s1 = Psr7\stream_for('foobaz'); - $s1 = FnStream::decorate($s1, ['read' => function () { return ''; }]); - $s2 = Psr7\stream_for(''); - Psr7\copy_to_stream($s1, $s2, 10); - $this->assertEquals('', (string) $s2); - } - - public function testReadsLines() - { - $s = Psr7\stream_for("foo\nbaz\nbar"); - $this->assertEquals("foo\n", Psr7\readline($s)); - $this->assertEquals("baz\n", Psr7\readline($s)); - $this->assertEquals("bar", Psr7\readline($s)); - } - - public function testReadsLinesUpToMaxLength() - { - $s = Psr7\stream_for("12345\n"); - $this->assertEquals("123", Psr7\readline($s, 4)); - $this->assertEquals("45\n", Psr7\readline($s)); - } - - public function testReadsLineUntilFalseReturnedFromRead() - { - $s = $this->getMockBuilder('GuzzleHttp\Psr7\Stream') - ->setMethods(['read', 'eof']) - ->disableOriginalConstructor() - ->getMock(); - $s->expects($this->exactly(2)) - ->method('read') - ->will($this->returnCallback(function () { - static $c = false; - if ($c) { - return false; - } - $c = true; - return 'h'; - })); - $s->expects($this->exactly(2)) - ->method('eof') - ->will($this->returnValue(false)); - $this->assertEquals("h", Psr7\readline($s)); - } - - public function testCalculatesHash() - { - $s = Psr7\stream_for('foobazbar'); - $this->assertEquals(md5('foobazbar'), Psr7\hash($s, 'md5')); - } - - /** - * @expectedException \RuntimeException - */ - public function testCalculatesHashThrowsWhenSeekFails() - { - $s = new NoSeekStream(Psr7\stream_for('foobazbar')); - $s->read(2); - Psr7\hash($s, 'md5'); - } - - public function testCalculatesHashSeeksToOriginalPosition() - { - $s = Psr7\stream_for('foobazbar'); - $s->seek(4); - $this->assertEquals(md5('foobazbar'), Psr7\hash($s, 'md5')); - $this->assertEquals(4, $s->tell()); - } - - public function testOpensFilesSuccessfully() - { - $r = Psr7\try_fopen(__FILE__, 'r'); - $this->assertInternalType('resource', $r); - fclose($r); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Unable to open /path/to/does/not/exist using mode r - */ - public function testThrowsExceptionNotWarning() - { - Psr7\try_fopen('/path/to/does/not/exist', 'r'); - } - - public function parseQueryProvider() - { - return [ - // Does not need to parse when the string is empty - ['', []], - // Can parse mult-values items - ['q=a&q=b', ['q' => ['a', 'b']]], - // Can parse multi-valued items that use numeric indices - ['q[0]=a&q[1]=b', ['q[0]' => 'a', 'q[1]' => 'b']], - // Can parse duplicates and does not include numeric indices - ['q[]=a&q[]=b', ['q[]' => ['a', 'b']]], - // Ensures that the value of "q" is an array even though one value - ['q[]=a', ['q[]' => 'a']], - // Does not modify "." to "_" like PHP's parse_str() - ['q.a=a&q.b=b', ['q.a' => 'a', 'q.b' => 'b']], - // Can decode %20 to " " - ['q%20a=a%20b', ['q a' => 'a b']], - // Can parse funky strings with no values by assigning each to null - ['q&a', ['q' => null, 'a' => null]], - // Does not strip trailing equal signs - ['data=abc=', ['data' => 'abc=']], - // Can store duplicates without affecting other values - ['foo=a&foo=b&?µ=c', ['foo' => ['a', 'b'], '?µ' => 'c']], - // Sets value to null when no "=" is present - ['foo', ['foo' => null]], - // Preserves "0" keys. - ['0', ['0' => null]], - // Sets the value to an empty string when "=" is present - ['0=', ['0' => '']], - // Preserves falsey keys - ['var=0', ['var' => '0']], - ['a[b][c]=1&a[b][c]=2', ['a[b][c]' => ['1', '2']]], - ['a[b]=c&a[d]=e', ['a[b]' => 'c', 'a[d]' => 'e']], - // Ensure it doesn't leave things behind with repeated values - // Can parse mult-values items - ['q=a&q=b&q=c', ['q' => ['a', 'b', 'c']]], - ]; - } - - /** - * @dataProvider parseQueryProvider - */ - public function testParsesQueries($input, $output) - { - $result = Psr7\parse_query($input); - $this->assertSame($output, $result); - } - - public function testDoesNotDecode() - { - $str = 'foo%20=bar'; - $data = Psr7\parse_query($str, false); - $this->assertEquals(['foo%20' => 'bar'], $data); - } - - /** - * @dataProvider parseQueryProvider - */ - public function testParsesAndBuildsQueries($input, $output) - { - $result = Psr7\parse_query($input, false); - $this->assertSame($input, Psr7\build_query($result, false)); - } - - public function testEncodesWithRfc1738() - { - $str = Psr7\build_query(['foo bar' => 'baz+'], PHP_QUERY_RFC1738); - $this->assertEquals('foo+bar=baz%2B', $str); - } - - public function testEncodesWithRfc3986() - { - $str = Psr7\build_query(['foo bar' => 'baz+'], PHP_QUERY_RFC3986); - $this->assertEquals('foo%20bar=baz%2B', $str); - } - - public function testDoesNotEncode() - { - $str = Psr7\build_query(['foo bar' => 'baz+'], false); - $this->assertEquals('foo bar=baz+', $str); - } - - public function testCanControlDecodingType() - { - $result = Psr7\parse_query('var=foo+bar', PHP_QUERY_RFC3986); - $this->assertEquals('foo+bar', $result['var']); - $result = Psr7\parse_query('var=foo+bar', PHP_QUERY_RFC1738); - $this->assertEquals('foo bar', $result['var']); - } - - public function testParsesRequestMessages() - { - $req = "GET /abc HTTP/1.0\r\nHost: foo.com\r\nFoo: Bar\r\nBaz: Bam\r\nBaz: Qux\r\n\r\nTest"; - $request = Psr7\parse_request($req); - $this->assertEquals('GET', $request->getMethod()); - $this->assertEquals('/abc', $request->getRequestTarget()); - $this->assertEquals('1.0', $request->getProtocolVersion()); - $this->assertEquals('foo.com', $request->getHeaderLine('Host')); - $this->assertEquals('Bar', $request->getHeaderLine('Foo')); - $this->assertEquals('Bam, Qux', $request->getHeaderLine('Baz')); - $this->assertEquals('Test', (string) $request->getBody()); - $this->assertEquals('http://foo.com/abc', (string) $request->getUri()); - } - - public function testParsesRequestMessagesWithHttpsScheme() - { - $req = "PUT /abc?baz=bar HTTP/1.1\r\nHost: foo.com:443\r\n\r\n"; - $request = Psr7\parse_request($req); - $this->assertEquals('PUT', $request->getMethod()); - $this->assertEquals('/abc?baz=bar', $request->getRequestTarget()); - $this->assertEquals('1.1', $request->getProtocolVersion()); - $this->assertEquals('foo.com:443', $request->getHeaderLine('Host')); - $this->assertEquals('', (string) $request->getBody()); - $this->assertEquals('https://foo.com/abc?baz=bar', (string) $request->getUri()); - } - - public function testParsesRequestMessagesWithUriWhenHostIsNotFirst() - { - $req = "PUT / HTTP/1.1\r\nFoo: Bar\r\nHost: foo.com\r\n\r\n"; - $request = Psr7\parse_request($req); - $this->assertEquals('PUT', $request->getMethod()); - $this->assertEquals('/', $request->getRequestTarget()); - $this->assertEquals('http://foo.com/', (string) $request->getUri()); - } - - public function testParsesRequestMessagesWithFullUri() - { - $req = "GET https://www.google.com:443/search?q=foobar HTTP/1.1\r\nHost: www.google.com\r\n\r\n"; - $request = Psr7\parse_request($req); - $this->assertEquals('GET', $request->getMethod()); - $this->assertEquals('https://www.google.com:443/search?q=foobar', $request->getRequestTarget()); - $this->assertEquals('1.1', $request->getProtocolVersion()); - $this->assertEquals('www.google.com', $request->getHeaderLine('Host')); - $this->assertEquals('', (string) $request->getBody()); - $this->assertEquals('https://www.google.com/search?q=foobar', (string) $request->getUri()); - } - - public function testParsesRequestMessagesWithCustomMethod() - { - $req = "GET_DATA / HTTP/1.1\r\nFoo: Bar\r\nHost: foo.com\r\n\r\n"; - $request = Psr7\parse_request($req); - $this->assertEquals('GET_DATA', $request->getMethod()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testValidatesRequestMessages() - { - Psr7\parse_request("HTTP/1.1 200 OK\r\n\r\n"); - } - - public function testParsesResponseMessages() - { - $res = "HTTP/1.0 200 OK\r\nFoo: Bar\r\nBaz: Bam\r\nBaz: Qux\r\n\r\nTest"; - $response = Psr7\parse_response($res); - $this->assertEquals(200, $response->getStatusCode()); - $this->assertEquals('OK', $response->getReasonPhrase()); - $this->assertEquals('1.0', $response->getProtocolVersion()); - $this->assertEquals('Bar', $response->getHeaderLine('Foo')); - $this->assertEquals('Bam, Qux', $response->getHeaderLine('Baz')); - $this->assertEquals('Test', (string) $response->getBody()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testValidatesResponseMessages() - { - Psr7\parse_response("GET / HTTP/1.1\r\n\r\n"); - } - - public function testDetermineMimetype() - { - $this->assertNull(Psr7\mimetype_from_extension('not-a-real-extension')); - $this->assertEquals( - 'application/json', - Psr7\mimetype_from_extension('json') - ); - $this->assertEquals( - 'image/jpeg', - Psr7\mimetype_from_filename('/tmp/images/IMG034821.JPEG') - ); - } - - public function testCreatesUriForValue() - { - $this->assertInstanceOf('GuzzleHttp\Psr7\Uri', Psr7\uri_for('/foo')); - $this->assertInstanceOf( - 'GuzzleHttp\Psr7\Uri', - Psr7\uri_for(new Psr7\Uri('/foo')) - ); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testValidatesUri() - { - Psr7\uri_for([]); - } - - public function testKeepsPositionOfResource() - { - $h = fopen(__FILE__, 'r'); - fseek($h, 10); - $stream = Psr7\stream_for($h); - $this->assertEquals(10, $stream->tell()); - $stream->close(); - } - - public function testCreatesWithFactory() - { - $stream = Psr7\stream_for('foo'); - $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $stream); - $this->assertEquals('foo', $stream->getContents()); - $stream->close(); - } - - public function testFactoryCreatesFromEmptyString() - { - $s = Psr7\stream_for(); - $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s); - } - - public function testFactoryCreatesFromNull() - { - $s = Psr7\stream_for(null); - $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s); - } - - public function testFactoryCreatesFromResource() - { - $r = fopen(__FILE__, 'r'); - $s = Psr7\stream_for($r); - $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s); - $this->assertSame(file_get_contents(__FILE__), (string) $s); - } - - public function testFactoryCreatesFromObjectWithToString() - { - $r = new HasToString(); - $s = Psr7\stream_for($r); - $this->assertInstanceOf('GuzzleHttp\Psr7\Stream', $s); - $this->assertEquals('foo', (string) $s); - } - - public function testCreatePassesThrough() - { - $s = Psr7\stream_for('foo'); - $this->assertSame($s, Psr7\stream_for($s)); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testThrowsExceptionForUnknown() - { - Psr7\stream_for(new \stdClass()); - } - - public function testReturnsCustomMetadata() - { - $s = Psr7\stream_for('foo', ['metadata' => ['hwm' => 3]]); - $this->assertEquals(3, $s->getMetadata('hwm')); - $this->assertArrayHasKey('hwm', $s->getMetadata()); - } - - public function testCanSetSize() - { - $s = Psr7\stream_for('', ['size' => 10]); - $this->assertEquals(10, $s->getSize()); - } - - public function testCanCreateIteratorBasedStream() - { - $a = new \ArrayIterator(['foo', 'bar', '123']); - $p = Psr7\stream_for($a); - $this->assertInstanceOf('GuzzleHttp\Psr7\PumpStream', $p); - $this->assertEquals('foo', $p->read(3)); - $this->assertFalse($p->eof()); - $this->assertEquals('b', $p->read(1)); - $this->assertEquals('a', $p->read(1)); - $this->assertEquals('r12', $p->read(3)); - $this->assertFalse($p->eof()); - $this->assertEquals('3', $p->getContents()); - $this->assertTrue($p->eof()); - $this->assertEquals(9, $p->tell()); - } - - public function testConvertsRequestsToStrings() - { - $request = new Psr7\Request('PUT', 'http://foo.com/hi?123', [ - 'Baz' => 'bar', - 'Qux' => 'ipsum' - ], 'hello', '1.0'); - $this->assertEquals( - "PUT /hi?123 HTTP/1.0\r\nHost: foo.com\r\nBaz: bar\r\nQux: ipsum\r\n\r\nhello", - Psr7\str($request) - ); - } - - public function testConvertsResponsesToStrings() - { - $response = new Psr7\Response(200, [ - 'Baz' => 'bar', - 'Qux' => 'ipsum' - ], 'hello', '1.0', 'FOO'); - $this->assertEquals( - "HTTP/1.0 200 FOO\r\nBaz: bar\r\nQux: ipsum\r\n\r\nhello", - Psr7\str($response) - ); - } - - public function parseParamsProvider() - { - $res1 = array( - array( - '', - 'rel' => 'front', - 'type' => 'image/jpeg', - ), - array( - '', - 'rel' => 'back', - 'type' => 'image/jpeg', - ), - ); - return array( - array( - '; rel="front"; type="image/jpeg", ; rel=back; type="image/jpeg"', - $res1 - ), - array( - '; rel="front"; type="image/jpeg",; rel=back; type="image/jpeg"', - $res1 - ), - array( - 'foo="baz"; bar=123, boo, test="123", foobar="foo;bar"', - array( - array('foo' => 'baz', 'bar' => '123'), - array('boo'), - array('test' => '123'), - array('foobar' => 'foo;bar') - ) - ), - array( - '; rel="side"; type="image/jpeg",; rel=side; type="image/jpeg"', - array( - array('', 'rel' => 'side', 'type' => 'image/jpeg'), - array('', 'rel' => 'side', 'type' => 'image/jpeg') - ) - ), - array( - '', - array() - ) - ); - } - /** - * @dataProvider parseParamsProvider - */ - public function testParseParams($header, $result) - { - $this->assertEquals($result, Psr7\parse_header($header)); - } - - public function testParsesArrayHeaders() - { - $header = ['a, b', 'c', 'd, e']; - $this->assertEquals(['a', 'b', 'c', 'd', 'e'], Psr7\normalize_header($header)); - } - - public function testRewindsBody() - { - $body = Psr7\stream_for('abc'); - $res = new Psr7\Response(200, [], $body); - Psr7\rewind_body($res); - $this->assertEquals(0, $body->tell()); - $body->rewind(1); - Psr7\rewind_body($res); - $this->assertEquals(0, $body->tell()); - } - - /** - * @expectedException \RuntimeException - */ - public function testThrowsWhenBodyCannotBeRewound() - { - $body = Psr7\stream_for('abc'); - $body->read(1); - $body = FnStream::decorate($body, [ - 'rewind' => function () { throw new \RuntimeException('a'); } - ]); - $res = new Psr7\Response(200, [], $body); - Psr7\rewind_body($res); - } - - public function testCanModifyRequestWithUri() - { - $r1 = new Psr7\Request('GET', 'http://foo.com'); - $r2 = Psr7\modify_request($r1, [ - 'uri' => new Psr7\Uri('http://www.foo.com') - ]); - $this->assertEquals('http://www.foo.com', (string) $r2->getUri()); - $this->assertEquals('www.foo.com', (string) $r2->getHeaderLine('host')); - } - - public function testCanModifyRequestWithUriAndPort() - { - $r1 = new Psr7\Request('GET', 'http://foo.com:8000'); - $r2 = Psr7\modify_request($r1, [ - 'uri' => new Psr7\Uri('http://www.foo.com:8000') - ]); - $this->assertEquals('http://www.foo.com:8000', (string) $r2->getUri()); - $this->assertEquals('www.foo.com:8000', (string) $r2->getHeaderLine('host')); - } - - public function testCanModifyRequestWithCaseInsensitiveHeader() - { - $r1 = new Psr7\Request('GET', 'http://foo.com', ['User-Agent' => 'foo']); - $r2 = Psr7\modify_request($r1, ['set_headers' => ['User-agent' => 'bar']]); - $this->assertEquals('bar', $r2->getHeaderLine('User-Agent')); - $this->assertEquals('bar', $r2->getHeaderLine('User-agent')); - } - - public function testReturnsAsIsWhenNoChanges() - { - $r1 = new Psr7\Request('GET', 'http://foo.com'); - $r2 = Psr7\modify_request($r1, []); - $this->assertTrue($r2 instanceof Psr7\Request); - - $r1 = new Psr7\ServerRequest('GET', 'http://foo.com'); - $r2 = Psr7\modify_request($r1, []); - $this->assertTrue($r2 instanceof \Psr\Http\Message\ServerRequestInterface); - } - - public function testReturnsUriAsIsWhenNoChanges() - { - $r1 = new Psr7\Request('GET', 'http://foo.com'); - $r2 = Psr7\modify_request($r1, ['set_headers' => ['foo' => 'bar']]); - $this->assertNotSame($r1, $r2); - $this->assertEquals('bar', $r2->getHeaderLine('foo')); - } - - public function testRemovesHeadersFromMessage() - { - $r1 = new Psr7\Request('GET', 'http://foo.com', ['foo' => 'bar']); - $r2 = Psr7\modify_request($r1, ['remove_headers' => ['foo']]); - $this->assertNotSame($r1, $r2); - $this->assertFalse($r2->hasHeader('foo')); - } - - public function testAddsQueryToUri() - { - $r1 = new Psr7\Request('GET', 'http://foo.com'); - $r2 = Psr7\modify_request($r1, ['query' => 'foo=bar']); - $this->assertNotSame($r1, $r2); - $this->assertEquals('foo=bar', $r2->getUri()->getQuery()); - } - - public function testModifyRequestKeepInstanceOfRequest() - { - $r1 = new Psr7\Request('GET', 'http://foo.com'); - $r2 = Psr7\modify_request($r1, ['remove_headers' => ['non-existent']]); - $this->assertTrue($r2 instanceof Psr7\Request); - - $r1 = new Psr7\ServerRequest('GET', 'http://foo.com'); - $r2 = Psr7\modify_request($r1, ['remove_headers' => ['non-existent']]); - $this->assertTrue($r2 instanceof \Psr\Http\Message\ServerRequestInterface); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php b/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php deleted file mode 100644 index 0e4b58603..000000000 --- a/vendor/guzzlehttp/psr7/tests/InflateStreamTest.php +++ /dev/null @@ -1,39 +0,0 @@ -assertEquals('test', (string) $b); - } - - public function testInflatesStreamsWithFilename() - { - $content = $this->getGzipStringWithFilename('test'); - $a = Psr7\stream_for($content); - $b = new InflateStream($a); - $this->assertEquals('test', (string) $b); - } - - private function getGzipStringWithFilename($original_string) - { - $gzipped = bin2hex(gzencode($original_string)); - - $header = substr($gzipped, 0, 20); - // set FNAME flag - $header[6]=0; - $header[7]=8; - // make a dummy filename - $filename = "64756d6d7900"; - $rest = substr($gzipped, 20); - - return hex2bin($header . $filename . $rest); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php b/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php deleted file mode 100644 index fdef1423d..000000000 --- a/vendor/guzzlehttp/psr7/tests/LazyOpenStreamTest.php +++ /dev/null @@ -1,64 +0,0 @@ -fname = tempnam('/tmp', 'tfile'); - - if (file_exists($this->fname)) { - unlink($this->fname); - } - } - - public function tearDown() - { - if (file_exists($this->fname)) { - unlink($this->fname); - } - } - - public function testOpensLazily() - { - $l = new LazyOpenStream($this->fname, 'w+'); - $l->write('foo'); - $this->assertInternalType('array', $l->getMetadata()); - $this->assertFileExists($this->fname); - $this->assertEquals('foo', file_get_contents($this->fname)); - $this->assertEquals('foo', (string) $l); - } - - public function testProxiesToFile() - { - file_put_contents($this->fname, 'foo'); - $l = new LazyOpenStream($this->fname, 'r'); - $this->assertEquals('foo', $l->read(4)); - $this->assertTrue($l->eof()); - $this->assertEquals(3, $l->tell()); - $this->assertTrue($l->isReadable()); - $this->assertTrue($l->isSeekable()); - $this->assertFalse($l->isWritable()); - $l->seek(1); - $this->assertEquals('oo', $l->getContents()); - $this->assertEquals('foo', (string) $l); - $this->assertEquals(3, $l->getSize()); - $this->assertInternalType('array', $l->getMetadata()); - $l->close(); - } - - public function testDetachesUnderlyingStream() - { - file_put_contents($this->fname, 'foo'); - $l = new LazyOpenStream($this->fname, 'r'); - $r = $l->detach(); - $this->assertInternalType('resource', $r); - fseek($r, 0); - $this->assertEquals('foo', stream_get_contents($r)); - fclose($r); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/LimitStreamTest.php b/vendor/guzzlehttp/psr7/tests/LimitStreamTest.php deleted file mode 100644 index 2198b7a9b..000000000 --- a/vendor/guzzlehttp/psr7/tests/LimitStreamTest.php +++ /dev/null @@ -1,166 +0,0 @@ -decorated = Psr7\stream_for(fopen(__FILE__, 'r')); - $this->body = new LimitStream($this->decorated, 10, 3); - } - - public function testReturnsSubset() - { - $body = new LimitStream(Psr7\stream_for('foo'), -1, 1); - $this->assertEquals('oo', (string) $body); - $this->assertTrue($body->eof()); - $body->seek(0); - $this->assertFalse($body->eof()); - $this->assertEquals('oo', $body->read(100)); - $this->assertSame('', $body->read(1)); - $this->assertTrue($body->eof()); - } - - public function testReturnsSubsetWhenCastToString() - { - $body = Psr7\stream_for('foo_baz_bar'); - $limited = new LimitStream($body, 3, 4); - $this->assertEquals('baz', (string) $limited); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Unable to seek to stream position 10 with whence 0 - */ - public function testEnsuresPositionCanBeekSeekedTo() - { - new LimitStream(Psr7\stream_for(''), 0, 10); - } - - public function testReturnsSubsetOfEmptyBodyWhenCastToString() - { - $body = Psr7\stream_for('01234567891234'); - $limited = new LimitStream($body, 0, 10); - $this->assertEquals('', (string) $limited); - } - - public function testReturnsSpecificSubsetOBodyWhenCastToString() - { - $body = Psr7\stream_for('0123456789abcdef'); - $limited = new LimitStream($body, 3, 10); - $this->assertEquals('abc', (string) $limited); - } - - public function testSeeksWhenConstructed() - { - $this->assertEquals(0, $this->body->tell()); - $this->assertEquals(3, $this->decorated->tell()); - } - - public function testAllowsBoundedSeek() - { - $this->body->seek(100); - $this->assertEquals(10, $this->body->tell()); - $this->assertEquals(13, $this->decorated->tell()); - $this->body->seek(0); - $this->assertEquals(0, $this->body->tell()); - $this->assertEquals(3, $this->decorated->tell()); - try { - $this->body->seek(-10); - $this->fail(); - } catch (\RuntimeException $e) {} - $this->assertEquals(0, $this->body->tell()); - $this->assertEquals(3, $this->decorated->tell()); - $this->body->seek(5); - $this->assertEquals(5, $this->body->tell()); - $this->assertEquals(8, $this->decorated->tell()); - // Fail - try { - $this->body->seek(1000, SEEK_END); - $this->fail(); - } catch (\RuntimeException $e) {} - } - - public function testReadsOnlySubsetOfData() - { - $data = $this->body->read(100); - $this->assertEquals(10, strlen($data)); - $this->assertSame('', $this->body->read(1000)); - - $this->body->setOffset(10); - $newData = $this->body->read(100); - $this->assertEquals(10, strlen($newData)); - $this->assertNotSame($data, $newData); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Could not seek to stream offset 2 - */ - public function testThrowsWhenCurrentGreaterThanOffsetSeek() - { - $a = Psr7\stream_for('foo_bar'); - $b = new NoSeekStream($a); - $c = new LimitStream($b); - $a->getContents(); - $c->setOffset(2); - } - - public function testCanGetContentsWithoutSeeking() - { - $a = Psr7\stream_for('foo_bar'); - $b = new NoSeekStream($a); - $c = new LimitStream($b); - $this->assertEquals('foo_bar', $c->getContents()); - } - - public function testClaimsConsumedWhenReadLimitIsReached() - { - $this->assertFalse($this->body->eof()); - $this->body->read(1000); - $this->assertTrue($this->body->eof()); - } - - public function testContentLengthIsBounded() - { - $this->assertEquals(10, $this->body->getSize()); - } - - public function testGetContentsIsBasedOnSubset() - { - $body = new LimitStream(Psr7\stream_for('foobazbar'), 3, 3); - $this->assertEquals('baz', $body->getContents()); - } - - public function testReturnsNullIfSizeCannotBeDetermined() - { - $a = new FnStream([ - 'getSize' => function () { return null; }, - 'tell' => function () { return 0; }, - ]); - $b = new LimitStream($a); - $this->assertNull($b->getSize()); - } - - public function testLengthLessOffsetWhenNoLimitSize() - { - $a = Psr7\stream_for('foo_bar'); - $b = new LimitStream($a, -1, 4); - $this->assertEquals(3, $b->getSize()); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php b/vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php deleted file mode 100644 index a509261ed..000000000 --- a/vendor/guzzlehttp/psr7/tests/MultipartStreamTest.php +++ /dev/null @@ -1,242 +0,0 @@ -assertNotEmpty($b->getBoundary()); - } - - public function testCanProvideBoundary() - { - $b = new MultipartStream([], 'foo'); - $this->assertEquals('foo', $b->getBoundary()); - } - - public function testIsNotWritable() - { - $b = new MultipartStream(); - $this->assertFalse($b->isWritable()); - } - - public function testCanCreateEmptyStream() - { - $b = new MultipartStream(); - $boundary = $b->getBoundary(); - $this->assertSame("--{$boundary}--\r\n", $b->getContents()); - $this->assertSame(strlen($boundary) + 6, $b->getSize()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testValidatesFilesArrayElement() - { - new MultipartStream([['foo' => 'bar']]); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testEnsuresFileHasName() - { - new MultipartStream([['contents' => 'bar']]); - } - - public function testSerializesFields() - { - $b = new MultipartStream([ - [ - 'name' => 'foo', - 'contents' => 'bar' - ], - [ - 'name' => 'baz', - 'contents' => 'bam' - ] - ], 'boundary'); - $this->assertEquals( - "--boundary\r\nContent-Disposition: form-data; name=\"foo\"\r\nContent-Length: 3\r\n\r\n" - . "bar\r\n--boundary\r\nContent-Disposition: form-data; name=\"baz\"\r\nContent-Length: 3" - . "\r\n\r\nbam\r\n--boundary--\r\n", (string) $b); - } - - public function testSerializesNonStringFields() - { - $b = new MultipartStream([ - [ - 'name' => 'int', - 'contents' => (int) 1 - ], - [ - 'name' => 'bool', - 'contents' => (boolean) false - ], - [ - 'name' => 'bool2', - 'contents' => (boolean) true - ], - [ - 'name' => 'float', - 'contents' => (float) 1.1 - ] - ], 'boundary'); - $this->assertEquals( - "--boundary\r\nContent-Disposition: form-data; name=\"int\"\r\nContent-Length: 1\r\n\r\n" - . "1\r\n--boundary\r\nContent-Disposition: form-data; name=\"bool\"\r\n\r\n\r\n--boundary" - . "\r\nContent-Disposition: form-data; name=\"bool2\"\r\nContent-Length: 1\r\n\r\n" - . "1\r\n--boundary\r\nContent-Disposition: form-data; name=\"float\"\r\nContent-Length: 3" - . "\r\n\r\n1.1\r\n--boundary--\r\n", (string) $b); - } - - public function testSerializesFiles() - { - $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [ - 'getMetadata' => function () { - return '/foo/bar.txt'; - } - ]); - - $f2 = Psr7\FnStream::decorate(Psr7\stream_for('baz'), [ - 'getMetadata' => function () { - return '/foo/baz.jpg'; - } - ]); - - $f3 = Psr7\FnStream::decorate(Psr7\stream_for('bar'), [ - 'getMetadata' => function () { - return '/foo/bar.gif'; - } - ]); - - $b = new MultipartStream([ - [ - 'name' => 'foo', - 'contents' => $f1 - ], - [ - 'name' => 'qux', - 'contents' => $f2 - ], - [ - 'name' => 'qux', - 'contents' => $f3 - ], - ], 'boundary'); - - $expected = <<assertEquals($expected, str_replace("\r", '', $b)); - } - - public function testSerializesFilesWithCustomHeaders() - { - $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [ - 'getMetadata' => function () { - return '/foo/bar.txt'; - } - ]); - - $b = new MultipartStream([ - [ - 'name' => 'foo', - 'contents' => $f1, - 'headers' => [ - 'x-foo' => 'bar', - 'content-disposition' => 'custom' - ] - ] - ], 'boundary'); - - $expected = <<assertEquals($expected, str_replace("\r", '', $b)); - } - - public function testSerializesFilesWithCustomHeadersAndMultipleValues() - { - $f1 = Psr7\FnStream::decorate(Psr7\stream_for('foo'), [ - 'getMetadata' => function () { - return '/foo/bar.txt'; - } - ]); - - $f2 = Psr7\FnStream::decorate(Psr7\stream_for('baz'), [ - 'getMetadata' => function () { - return '/foo/baz.jpg'; - } - ]); - - $b = new MultipartStream([ - [ - 'name' => 'foo', - 'contents' => $f1, - 'headers' => [ - 'x-foo' => 'bar', - 'content-disposition' => 'custom' - ] - ], - [ - 'name' => 'foo', - 'contents' => $f2, - 'headers' => ['cOntenT-Type' => 'custom'], - ] - ], 'boundary'); - - $expected = <<assertEquals($expected, str_replace("\r", '', $b)); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php b/vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php deleted file mode 100644 index a309317bd..000000000 --- a/vendor/guzzlehttp/psr7/tests/NoSeekStreamTest.php +++ /dev/null @@ -1,40 +0,0 @@ -getMockBuilder('Psr\Http\Message\StreamInterface') - ->setMethods(['isSeekable', 'seek']) - ->getMockForAbstractClass(); - $s->expects($this->never())->method('seek'); - $s->expects($this->never())->method('isSeekable'); - $wrapped = new NoSeekStream($s); - $this->assertFalse($wrapped->isSeekable()); - $wrapped->seek(2); - } - - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage Cannot write to a non-writable stream - */ - public function testHandlesClose() - { - $s = Psr7\stream_for('foo'); - $wrapped = new NoSeekStream($s); - $wrapped->close(); - $wrapped->write('foo'); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php b/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php deleted file mode 100644 index 7358bb6e0..000000000 --- a/vendor/guzzlehttp/psr7/tests/PumpStreamTest.php +++ /dev/null @@ -1,72 +0,0 @@ - ['foo' => 'bar'], - 'size' => 100 - ]); - - $this->assertEquals('bar', $p->getMetadata('foo')); - $this->assertEquals(['foo' => 'bar'], $p->getMetadata()); - $this->assertEquals(100, $p->getSize()); - } - - public function testCanReadFromCallable() - { - $p = Psr7\stream_for(function ($size) { - return 'a'; - }); - $this->assertEquals('a', $p->read(1)); - $this->assertEquals(1, $p->tell()); - $this->assertEquals('aaaaa', $p->read(5)); - $this->assertEquals(6, $p->tell()); - } - - public function testStoresExcessDataInBuffer() - { - $called = []; - $p = Psr7\stream_for(function ($size) use (&$called) { - $called[] = $size; - return 'abcdef'; - }); - $this->assertEquals('a', $p->read(1)); - $this->assertEquals('b', $p->read(1)); - $this->assertEquals('cdef', $p->read(4)); - $this->assertEquals('abcdefabc', $p->read(9)); - $this->assertEquals([1, 9, 3], $called); - } - - public function testInifiniteStreamWrappedInLimitStream() - { - $p = Psr7\stream_for(function () { return 'a'; }); - $s = new LimitStream($p, 5); - $this->assertEquals('aaaaa', (string) $s); - } - - public function testDescribesCapabilities() - { - $p = Psr7\stream_for(function () {}); - $this->assertTrue($p->isReadable()); - $this->assertFalse($p->isSeekable()); - $this->assertFalse($p->isWritable()); - $this->assertNull($p->getSize()); - $this->assertEquals('', $p->getContents()); - $this->assertEquals('', (string) $p); - $p->close(); - $this->assertEquals('', $p->read(10)); - $this->assertTrue($p->eof()); - - try { - $this->assertFalse($p->write('aa')); - $this->fail(); - } catch (\RuntimeException $e) {} - } -} diff --git a/vendor/guzzlehttp/psr7/tests/RequestTest.php b/vendor/guzzlehttp/psr7/tests/RequestTest.php deleted file mode 100644 index c55504330..000000000 --- a/vendor/guzzlehttp/psr7/tests/RequestTest.php +++ /dev/null @@ -1,195 +0,0 @@ -assertEquals('/', (string) $r->getUri()); - } - - public function testRequestUriMayBeUri() - { - $uri = new Uri('/'); - $r = new Request('GET', $uri); - $this->assertSame($uri, $r->getUri()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testValidateRequestUri() - { - new Request('GET', '///'); - } - - public function testCanConstructWithBody() - { - $r = new Request('GET', '/', [], 'baz'); - $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody()); - $this->assertEquals('baz', (string) $r->getBody()); - } - - public function testNullBody() - { - $r = new Request('GET', '/', [], null); - $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody()); - $this->assertSame('', (string) $r->getBody()); - } - - public function testFalseyBody() - { - $r = new Request('GET', '/', [], '0'); - $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody()); - $this->assertSame('0', (string) $r->getBody()); - } - - public function testConstructorDoesNotReadStreamBody() - { - $streamIsRead = false; - $body = Psr7\FnStream::decorate(Psr7\stream_for(''), [ - '__toString' => function () use (&$streamIsRead) { - $streamIsRead = true; - return ''; - } - ]); - - $r = new Request('GET', '/', [], $body); - $this->assertFalse($streamIsRead); - $this->assertSame($body, $r->getBody()); - } - - public function testCapitalizesMethod() - { - $r = new Request('get', '/'); - $this->assertEquals('GET', $r->getMethod()); - } - - public function testCapitalizesWithMethod() - { - $r = new Request('GET', '/'); - $this->assertEquals('PUT', $r->withMethod('put')->getMethod()); - } - - public function testWithUri() - { - $r1 = new Request('GET', '/'); - $u1 = $r1->getUri(); - $u2 = new Uri('http://www.example.com'); - $r2 = $r1->withUri($u2); - $this->assertNotSame($r1, $r2); - $this->assertSame($u2, $r2->getUri()); - $this->assertSame($u1, $r1->getUri()); - } - - public function testSameInstanceWhenSameUri() - { - $r1 = new Request('GET', 'http://foo.com'); - $r2 = $r1->withUri($r1->getUri()); - $this->assertSame($r1, $r2); - } - - public function testWithRequestTarget() - { - $r1 = new Request('GET', '/'); - $r2 = $r1->withRequestTarget('*'); - $this->assertEquals('*', $r2->getRequestTarget()); - $this->assertEquals('/', $r1->getRequestTarget()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testRequestTargetDoesNotAllowSpaces() - { - $r1 = new Request('GET', '/'); - $r1->withRequestTarget('/foo bar'); - } - - public function testRequestTargetDefaultsToSlash() - { - $r1 = new Request('GET', ''); - $this->assertEquals('/', $r1->getRequestTarget()); - $r2 = new Request('GET', '*'); - $this->assertEquals('*', $r2->getRequestTarget()); - $r3 = new Request('GET', 'http://foo.com/bar baz/'); - $this->assertEquals('/bar%20baz/', $r3->getRequestTarget()); - } - - public function testBuildsRequestTarget() - { - $r1 = new Request('GET', 'http://foo.com/baz?bar=bam'); - $this->assertEquals('/baz?bar=bam', $r1->getRequestTarget()); - } - - public function testBuildsRequestTargetWithFalseyQuery() - { - $r1 = new Request('GET', 'http://foo.com/baz?0'); - $this->assertEquals('/baz?0', $r1->getRequestTarget()); - } - - public function testHostIsAddedFirst() - { - $r = new Request('GET', 'http://foo.com/baz?bar=bam', ['Foo' => 'Bar']); - $this->assertEquals([ - 'Host' => ['foo.com'], - 'Foo' => ['Bar'] - ], $r->getHeaders()); - } - - public function testCanGetHeaderAsCsv() - { - $r = new Request('GET', 'http://foo.com/baz?bar=bam', [ - 'Foo' => ['a', 'b', 'c'] - ]); - $this->assertEquals('a, b, c', $r->getHeaderLine('Foo')); - $this->assertEquals('', $r->getHeaderLine('Bar')); - } - - public function testHostIsNotOverwrittenWhenPreservingHost() - { - $r = new Request('GET', 'http://foo.com/baz?bar=bam', ['Host' => 'a.com']); - $this->assertEquals(['Host' => ['a.com']], $r->getHeaders()); - $r2 = $r->withUri(new Uri('http://www.foo.com/bar'), true); - $this->assertEquals('a.com', $r2->getHeaderLine('Host')); - } - - public function testOverridesHostWithUri() - { - $r = new Request('GET', 'http://foo.com/baz?bar=bam'); - $this->assertEquals(['Host' => ['foo.com']], $r->getHeaders()); - $r2 = $r->withUri(new Uri('http://www.baz.com/bar')); - $this->assertEquals('www.baz.com', $r2->getHeaderLine('Host')); - } - - public function testAggregatesHeaders() - { - $r = new Request('GET', '', [ - 'ZOO' => 'zoobar', - 'zoo' => ['foobar', 'zoobar'] - ]); - $this->assertEquals(['ZOO' => ['zoobar', 'foobar', 'zoobar']], $r->getHeaders()); - $this->assertEquals('zoobar, foobar, zoobar', $r->getHeaderLine('zoo')); - } - - public function testAddsPortToHeader() - { - $r = new Request('GET', 'http://foo.com:8124/bar'); - $this->assertEquals('foo.com:8124', $r->getHeaderLine('host')); - } - - public function testAddsPortToHeaderAndReplacePreviousPort() - { - $r = new Request('GET', 'http://foo.com:8124/bar'); - $r = $r->withUri(new Uri('http://foo.com:8125/bar')); - $this->assertEquals('foo.com:8125', $r->getHeaderLine('host')); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/ResponseTest.php b/vendor/guzzlehttp/psr7/tests/ResponseTest.php deleted file mode 100644 index ae01fe12c..000000000 --- a/vendor/guzzlehttp/psr7/tests/ResponseTest.php +++ /dev/null @@ -1,252 +0,0 @@ -assertSame(200, $r->getStatusCode()); - $this->assertSame('1.1', $r->getProtocolVersion()); - $this->assertSame('OK', $r->getReasonPhrase()); - $this->assertSame([], $r->getHeaders()); - $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody()); - $this->assertSame('', (string) $r->getBody()); - } - - public function testCanConstructWithStatusCode() - { - $r = new Response(404); - $this->assertSame(404, $r->getStatusCode()); - $this->assertSame('Not Found', $r->getReasonPhrase()); - } - - public function testConstructorDoesNotReadStreamBody() - { - $streamIsRead = false; - $body = Psr7\FnStream::decorate(Psr7\stream_for(''), [ - '__toString' => function () use (&$streamIsRead) { - $streamIsRead = true; - return ''; - } - ]); - - $r = new Response(200, [], $body); - $this->assertFalse($streamIsRead); - $this->assertSame($body, $r->getBody()); - } - - public function testStatusCanBeNumericString() - { - $r = new Response('404'); - $r2 = $r->withStatus('201'); - $this->assertSame(404, $r->getStatusCode()); - $this->assertSame('Not Found', $r->getReasonPhrase()); - $this->assertSame(201, $r2->getStatusCode()); - $this->assertSame('Created', $r2->getReasonPhrase()); - } - - public function testCanConstructWithHeaders() - { - $r = new Response(200, ['Foo' => 'Bar']); - $this->assertSame(['Foo' => ['Bar']], $r->getHeaders()); - $this->assertSame('Bar', $r->getHeaderLine('Foo')); - $this->assertSame(['Bar'], $r->getHeader('Foo')); - } - - public function testCanConstructWithHeadersAsArray() - { - $r = new Response(200, [ - 'Foo' => ['baz', 'bar'] - ]); - $this->assertSame(['Foo' => ['baz', 'bar']], $r->getHeaders()); - $this->assertSame('baz, bar', $r->getHeaderLine('Foo')); - $this->assertSame(['baz', 'bar'], $r->getHeader('Foo')); - } - - public function testCanConstructWithBody() - { - $r = new Response(200, [], 'baz'); - $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody()); - $this->assertSame('baz', (string) $r->getBody()); - } - - public function testNullBody() - { - $r = new Response(200, [], null); - $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody()); - $this->assertSame('', (string) $r->getBody()); - } - - public function testFalseyBody() - { - $r = new Response(200, [], '0'); - $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody()); - $this->assertSame('0', (string) $r->getBody()); - } - - public function testCanConstructWithReason() - { - $r = new Response(200, [], null, '1.1', 'bar'); - $this->assertSame('bar', $r->getReasonPhrase()); - - $r = new Response(200, [], null, '1.1', '0'); - $this->assertSame('0', $r->getReasonPhrase(), 'Falsey reason works'); - } - - public function testCanConstructWithProtocolVersion() - { - $r = new Response(200, [], null, '1000'); - $this->assertSame('1000', $r->getProtocolVersion()); - } - - public function testWithStatusCodeAndNoReason() - { - $r = (new Response())->withStatus(201); - $this->assertSame(201, $r->getStatusCode()); - $this->assertSame('Created', $r->getReasonPhrase()); - } - - public function testWithStatusCodeAndReason() - { - $r = (new Response())->withStatus(201, 'Foo'); - $this->assertSame(201, $r->getStatusCode()); - $this->assertSame('Foo', $r->getReasonPhrase()); - - $r = (new Response())->withStatus(201, '0'); - $this->assertSame(201, $r->getStatusCode()); - $this->assertSame('0', $r->getReasonPhrase(), 'Falsey reason works'); - } - - public function testWithProtocolVersion() - { - $r = (new Response())->withProtocolVersion('1000'); - $this->assertSame('1000', $r->getProtocolVersion()); - } - - public function testSameInstanceWhenSameProtocol() - { - $r = new Response(); - $this->assertSame($r, $r->withProtocolVersion('1.1')); - } - - public function testWithBody() - { - $b = Psr7\stream_for('0'); - $r = (new Response())->withBody($b); - $this->assertInstanceOf('Psr\Http\Message\StreamInterface', $r->getBody()); - $this->assertSame('0', (string) $r->getBody()); - } - - public function testSameInstanceWhenSameBody() - { - $r = new Response(); - $b = $r->getBody(); - $this->assertSame($r, $r->withBody($b)); - } - - public function testWithHeader() - { - $r = new Response(200, ['Foo' => 'Bar']); - $r2 = $r->withHeader('baZ', 'Bam'); - $this->assertSame(['Foo' => ['Bar']], $r->getHeaders()); - $this->assertSame(['Foo' => ['Bar'], 'baZ' => ['Bam']], $r2->getHeaders()); - $this->assertSame('Bam', $r2->getHeaderLine('baz')); - $this->assertSame(['Bam'], $r2->getHeader('baz')); - } - - public function testWithHeaderAsArray() - { - $r = new Response(200, ['Foo' => 'Bar']); - $r2 = $r->withHeader('baZ', ['Bam', 'Bar']); - $this->assertSame(['Foo' => ['Bar']], $r->getHeaders()); - $this->assertSame(['Foo' => ['Bar'], 'baZ' => ['Bam', 'Bar']], $r2->getHeaders()); - $this->assertSame('Bam, Bar', $r2->getHeaderLine('baz')); - $this->assertSame(['Bam', 'Bar'], $r2->getHeader('baz')); - } - - public function testWithHeaderReplacesDifferentCase() - { - $r = new Response(200, ['Foo' => 'Bar']); - $r2 = $r->withHeader('foO', 'Bam'); - $this->assertSame(['Foo' => ['Bar']], $r->getHeaders()); - $this->assertSame(['foO' => ['Bam']], $r2->getHeaders()); - $this->assertSame('Bam', $r2->getHeaderLine('foo')); - $this->assertSame(['Bam'], $r2->getHeader('foo')); - } - - public function testWithAddedHeader() - { - $r = new Response(200, ['Foo' => 'Bar']); - $r2 = $r->withAddedHeader('foO', 'Baz'); - $this->assertSame(['Foo' => ['Bar']], $r->getHeaders()); - $this->assertSame(['Foo' => ['Bar', 'Baz']], $r2->getHeaders()); - $this->assertSame('Bar, Baz', $r2->getHeaderLine('foo')); - $this->assertSame(['Bar', 'Baz'], $r2->getHeader('foo')); - } - - public function testWithAddedHeaderAsArray() - { - $r = new Response(200, ['Foo' => 'Bar']); - $r2 = $r->withAddedHeader('foO', ['Baz', 'Bam']); - $this->assertSame(['Foo' => ['Bar']], $r->getHeaders()); - $this->assertSame(['Foo' => ['Bar', 'Baz', 'Bam']], $r2->getHeaders()); - $this->assertSame('Bar, Baz, Bam', $r2->getHeaderLine('foo')); - $this->assertSame(['Bar', 'Baz', 'Bam'], $r2->getHeader('foo')); - } - - public function testWithAddedHeaderThatDoesNotExist() - { - $r = new Response(200, ['Foo' => 'Bar']); - $r2 = $r->withAddedHeader('nEw', 'Baz'); - $this->assertSame(['Foo' => ['Bar']], $r->getHeaders()); - $this->assertSame(['Foo' => ['Bar'], 'nEw' => ['Baz']], $r2->getHeaders()); - $this->assertSame('Baz', $r2->getHeaderLine('new')); - $this->assertSame(['Baz'], $r2->getHeader('new')); - } - - public function testWithoutHeaderThatExists() - { - $r = new Response(200, ['Foo' => 'Bar', 'Baz' => 'Bam']); - $r2 = $r->withoutHeader('foO'); - $this->assertTrue($r->hasHeader('foo')); - $this->assertSame(['Foo' => ['Bar'], 'Baz' => ['Bam']], $r->getHeaders()); - $this->assertFalse($r2->hasHeader('foo')); - $this->assertSame(['Baz' => ['Bam']], $r2->getHeaders()); - } - - public function testWithoutHeaderThatDoesNotExist() - { - $r = new Response(200, ['Baz' => 'Bam']); - $r2 = $r->withoutHeader('foO'); - $this->assertSame($r, $r2); - $this->assertFalse($r2->hasHeader('foo')); - $this->assertSame(['Baz' => ['Bam']], $r2->getHeaders()); - } - - public function testSameInstanceWhenRemovingMissingHeader() - { - $r = new Response(); - $this->assertSame($r, $r->withoutHeader('foo')); - } - - public function testHeaderValuesAreTrimmed() - { - $r1 = new Response(200, ['OWS' => " \t \tFoo\t \t "]); - $r2 = (new Response())->withHeader('OWS', " \t \tFoo\t \t "); - $r3 = (new Response())->withAddedHeader('OWS', " \t \tFoo\t \t ");; - - foreach ([$r1, $r2, $r3] as $r) { - $this->assertSame(['OWS' => ['Foo']], $r->getHeaders()); - $this->assertSame('Foo', $r->getHeaderLine('OWS')); - $this->assertSame(['Foo'], $r->getHeader('OWS')); - } - } -} diff --git a/vendor/guzzlehttp/psr7/tests/ServerRequestTest.php b/vendor/guzzlehttp/psr7/tests/ServerRequestTest.php deleted file mode 100644 index f1727d0f2..000000000 --- a/vendor/guzzlehttp/psr7/tests/ServerRequestTest.php +++ /dev/null @@ -1,532 +0,0 @@ - [ - [ - 'file' => [ - 'name' => 'MyFile.txt', - 'type' => 'text/plain', - 'tmp_name' => '/tmp/php/php1h4j1o', - 'error' => '0', - 'size' => '123' - ] - ], - [ - 'file' => new UploadedFile( - '/tmp/php/php1h4j1o', - 123, - UPLOAD_ERR_OK, - 'MyFile.txt', - 'text/plain' - ) - ] - ], - 'Empty file' => [ - [ - 'image_file' => [ - 'name' => '', - 'type' => '', - 'tmp_name' => '', - 'error' => '4', - 'size' => '0' - ] - ], - [ - 'image_file' => new UploadedFile( - '', - 0, - UPLOAD_ERR_NO_FILE, - '', - '' - ) - ] - ], - 'Already Converted' => [ - [ - 'file' => new UploadedFile( - '/tmp/php/php1h4j1o', - 123, - UPLOAD_ERR_OK, - 'MyFile.txt', - 'text/plain' - ) - ], - [ - 'file' => new UploadedFile( - '/tmp/php/php1h4j1o', - 123, - UPLOAD_ERR_OK, - 'MyFile.txt', - 'text/plain' - ) - ] - ], - 'Already Converted array' => [ - [ - 'file' => [ - new UploadedFile( - '/tmp/php/php1h4j1o', - 123, - UPLOAD_ERR_OK, - 'MyFile.txt', - 'text/plain' - ), - new UploadedFile( - '', - 0, - UPLOAD_ERR_NO_FILE, - '', - '' - ) - ], - ], - [ - 'file' => [ - new UploadedFile( - '/tmp/php/php1h4j1o', - 123, - UPLOAD_ERR_OK, - 'MyFile.txt', - 'text/plain' - ), - new UploadedFile( - '', - 0, - UPLOAD_ERR_NO_FILE, - '', - '' - ) - ], - ] - ], - 'Multiple files' => [ - [ - 'text_file' => [ - 'name' => 'MyFile.txt', - 'type' => 'text/plain', - 'tmp_name' => '/tmp/php/php1h4j1o', - 'error' => '0', - 'size' => '123' - ], - 'image_file' => [ - 'name' => '', - 'type' => '', - 'tmp_name' => '', - 'error' => '4', - 'size' => '0' - ] - ], - [ - 'text_file' => new UploadedFile( - '/tmp/php/php1h4j1o', - 123, - UPLOAD_ERR_OK, - 'MyFile.txt', - 'text/plain' - ), - 'image_file' => new UploadedFile( - '', - 0, - UPLOAD_ERR_NO_FILE, - '', - '' - ) - ] - ], - 'Nested files' => [ - [ - 'file' => [ - 'name' => [ - 0 => 'MyFile.txt', - 1 => 'Image.png', - ], - 'type' => [ - 0 => 'text/plain', - 1 => 'image/png', - ], - 'tmp_name' => [ - 0 => '/tmp/php/hp9hskjhf', - 1 => '/tmp/php/php1h4j1o', - ], - 'error' => [ - 0 => '0', - 1 => '0', - ], - 'size' => [ - 0 => '123', - 1 => '7349', - ], - ], - 'nested' => [ - 'name' => [ - 'other' => 'Flag.txt', - 'test' => [ - 0 => 'Stuff.txt', - 1 => '', - ], - ], - 'type' => [ - 'other' => 'text/plain', - 'test' => [ - 0 => 'text/plain', - 1 => '', - ], - ], - 'tmp_name' => [ - 'other' => '/tmp/php/hp9hskjhf', - 'test' => [ - 0 => '/tmp/php/asifu2gp3', - 1 => '', - ], - ], - 'error' => [ - 'other' => '0', - 'test' => [ - 0 => '0', - 1 => '4', - ], - ], - 'size' => [ - 'other' => '421', - 'test' => [ - 0 => '32', - 1 => '0', - ] - ] - ], - ], - [ - 'file' => [ - 0 => new UploadedFile( - '/tmp/php/hp9hskjhf', - 123, - UPLOAD_ERR_OK, - 'MyFile.txt', - 'text/plain' - ), - 1 => new UploadedFile( - '/tmp/php/php1h4j1o', - 7349, - UPLOAD_ERR_OK, - 'Image.png', - 'image/png' - ), - ], - 'nested' => [ - 'other' => new UploadedFile( - '/tmp/php/hp9hskjhf', - 421, - UPLOAD_ERR_OK, - 'Flag.txt', - 'text/plain' - ), - 'test' => [ - 0 => new UploadedFile( - '/tmp/php/asifu2gp3', - 32, - UPLOAD_ERR_OK, - 'Stuff.txt', - 'text/plain' - ), - 1 => new UploadedFile( - '', - 0, - UPLOAD_ERR_NO_FILE, - '', - '' - ), - ] - ] - ] - ] - ]; - } - - /** - * @dataProvider dataNormalizeFiles - */ - public function testNormalizeFiles($files, $expected) - { - $result = ServerRequest::normalizeFiles($files); - - $this->assertEquals($expected, $result); - } - - public function testNormalizeFilesRaisesException() - { - $this->setExpectedException('InvalidArgumentException', 'Invalid value in files specification'); - - ServerRequest::normalizeFiles(['test' => 'something']); - } - - public function dataGetUriFromGlobals() - { - $server = [ - 'PHP_SELF' => '/blog/article.php', - 'GATEWAY_INTERFACE' => 'CGI/1.1', - 'SERVER_ADDR' => 'Server IP: 217.112.82.20', - 'SERVER_NAME' => 'www.blakesimpson.co.uk', - 'SERVER_SOFTWARE' => 'Apache/2.2.15 (Win32) JRun/4.0 PHP/5.2.13', - 'SERVER_PROTOCOL' => 'HTTP/1.0', - 'REQUEST_METHOD' => 'POST', - 'REQUEST_TIME' => 'Request start time: 1280149029', - 'QUERY_STRING' => 'id=10&user=foo', - 'DOCUMENT_ROOT' => '/path/to/your/server/root/', - 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', - 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate', - 'HTTP_ACCEPT_LANGUAGE' => 'en-gb,en;q=0.5', - 'HTTP_CONNECTION' => 'keep-alive', - 'HTTP_HOST' => 'www.blakesimpson.co.uk', - 'HTTP_REFERER' => 'http://previous.url.com', - 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( .NET CLR 3.5.30729)', - 'HTTPS' => '1', - 'REMOTE_ADDR' => '193.60.168.69', - 'REMOTE_HOST' => 'Client server\'s host name', - 'REMOTE_PORT' => '5390', - 'SCRIPT_FILENAME' => '/path/to/this/script.php', - 'SERVER_ADMIN' => 'webmaster@blakesimpson.co.uk', - 'SERVER_PORT' => '80', - 'SERVER_SIGNATURE' => 'Version signature: 5.123', - 'SCRIPT_NAME' => '/blog/article.php', - 'REQUEST_URI' => '/blog/article.php?id=10&user=foo', - ]; - - return [ - 'Normal request' => [ - 'http://www.blakesimpson.co.uk/blog/article.php?id=10&user=foo', - $server, - ], - 'Secure request' => [ - 'https://www.blakesimpson.co.uk/blog/article.php?id=10&user=foo', - array_merge($server, ['HTTPS' => 'on', 'SERVER_PORT' => '443']), - ], - 'HTTP_HOST missing' => [ - 'http://www.blakesimpson.co.uk/blog/article.php?id=10&user=foo', - array_merge($server, ['HTTP_HOST' => null]), - ], - 'No query String' => [ - 'http://www.blakesimpson.co.uk/blog/article.php', - array_merge($server, ['REQUEST_URI' => '/blog/article.php', 'QUERY_STRING' => '']), - ], - 'Different port' => [ - 'http://www.blakesimpson.co.uk:8324/blog/article.php?id=10&user=foo', - array_merge($server, ['SERVER_PORT' => '8324']), - ], - 'Empty server variable' => [ - '', - [], - ], - ]; - } - - /** - * @dataProvider dataGetUriFromGlobals - */ - public function testGetUriFromGlobals($expected, $serverParams) - { - $_SERVER = $serverParams; - - $this->assertEquals(new Uri($expected), ServerRequest::getUriFromGlobals()); - } - - public function testFromGlobals() - { - $_SERVER = [ - 'PHP_SELF' => '/blog/article.php', - 'GATEWAY_INTERFACE' => 'CGI/1.1', - 'SERVER_ADDR' => 'Server IP: 217.112.82.20', - 'SERVER_NAME' => 'www.blakesimpson.co.uk', - 'SERVER_SOFTWARE' => 'Apache/2.2.15 (Win32) JRun/4.0 PHP/5.2.13', - 'SERVER_PROTOCOL' => 'HTTP/1.0', - 'REQUEST_METHOD' => 'POST', - 'REQUEST_TIME' => 'Request start time: 1280149029', - 'QUERY_STRING' => 'id=10&user=foo', - 'DOCUMENT_ROOT' => '/path/to/your/server/root/', - 'HTTP_ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'HTTP_ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', - 'HTTP_ACCEPT_ENCODING' => 'gzip,deflate', - 'HTTP_ACCEPT_LANGUAGE' => 'en-gb,en;q=0.5', - 'HTTP_CONNECTION' => 'keep-alive', - 'HTTP_HOST' => 'www.blakesimpson.co.uk', - 'HTTP_REFERER' => 'http://previous.url.com', - 'HTTP_USER_AGENT' => 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( .NET CLR 3.5.30729)', - 'HTTPS' => '1', - 'REMOTE_ADDR' => '193.60.168.69', - 'REMOTE_HOST' => 'Client server\'s host name', - 'REMOTE_PORT' => '5390', - 'SCRIPT_FILENAME' => '/path/to/this/script.php', - 'SERVER_ADMIN' => 'webmaster@blakesimpson.co.uk', - 'SERVER_PORT' => '80', - 'SERVER_SIGNATURE' => 'Version signature: 5.123', - 'SCRIPT_NAME' => '/blog/article.php', - 'REQUEST_URI' => '/blog/article.php?id=10&user=foo', - ]; - - $_COOKIE = [ - 'logged-in' => 'yes!' - ]; - - $_POST = [ - 'name' => 'Pesho', - 'email' => 'pesho@example.com', - ]; - - $_GET = [ - 'id' => 10, - 'user' => 'foo', - ]; - - $_FILES = [ - 'file' => [ - 'name' => 'MyFile.txt', - 'type' => 'text/plain', - 'tmp_name' => '/tmp/php/php1h4j1o', - 'error' => UPLOAD_ERR_OK, - 'size' => 123, - ] - ]; - - $server = ServerRequest::fromGlobals(); - - $this->assertEquals('POST', $server->getMethod()); - $this->assertEquals(['Host' => ['www.blakesimpson.co.uk']], $server->getHeaders()); - $this->assertEquals('', (string) $server->getBody()); - $this->assertEquals('1.0', $server->getProtocolVersion()); - $this->assertEquals($_COOKIE, $server->getCookieParams()); - $this->assertEquals($_POST, $server->getParsedBody()); - $this->assertEquals($_GET, $server->getQueryParams()); - - $this->assertEquals( - new Uri('http://www.blakesimpson.co.uk/blog/article.php?id=10&user=foo'), - $server->getUri() - ); - - $expectedFiles = [ - 'file' => new UploadedFile( - '/tmp/php/php1h4j1o', - 123, - UPLOAD_ERR_OK, - 'MyFile.txt', - 'text/plain' - ), - ]; - - $this->assertEquals($expectedFiles, $server->getUploadedFiles()); - } - - public function testUploadedFiles() - { - $request1 = new ServerRequest('GET', '/'); - - $files = [ - 'file' => new UploadedFile('test', 123, UPLOAD_ERR_OK) - ]; - - $request2 = $request1->withUploadedFiles($files); - - $this->assertNotSame($request2, $request1); - $this->assertSame([], $request1->getUploadedFiles()); - $this->assertSame($files, $request2->getUploadedFiles()); - } - - public function testServerParams() - { - $params = ['name' => 'value']; - - $request = new ServerRequest('GET', '/', [], null, '1.1', $params); - $this->assertSame($params, $request->getServerParams()); - } - - public function testCookieParams() - { - $request1 = new ServerRequest('GET', '/'); - - $params = ['name' => 'value']; - - $request2 = $request1->withCookieParams($params); - - $this->assertNotSame($request2, $request1); - $this->assertEmpty($request1->getCookieParams()); - $this->assertSame($params, $request2->getCookieParams()); - } - - public function testQueryParams() - { - $request1 = new ServerRequest('GET', '/'); - - $params = ['name' => 'value']; - - $request2 = $request1->withQueryParams($params); - - $this->assertNotSame($request2, $request1); - $this->assertEmpty($request1->getQueryParams()); - $this->assertSame($params, $request2->getQueryParams()); - } - - public function testParsedBody() - { - $request1 = new ServerRequest('GET', '/'); - - $params = ['name' => 'value']; - - $request2 = $request1->withParsedBody($params); - - $this->assertNotSame($request2, $request1); - $this->assertEmpty($request1->getParsedBody()); - $this->assertSame($params, $request2->getParsedBody()); - } - - public function testAttributes() - { - $request1 = new ServerRequest('GET', '/'); - - $request2 = $request1->withAttribute('name', 'value'); - $request3 = $request2->withAttribute('other', 'otherValue'); - $request4 = $request3->withoutAttribute('other'); - $request5 = $request3->withoutAttribute('unknown'); - - $this->assertNotSame($request2, $request1); - $this->assertNotSame($request3, $request2); - $this->assertNotSame($request4, $request3); - $this->assertNotSame($request5, $request4); - - $this->assertEmpty($request1->getAttributes()); - $this->assertEmpty($request1->getAttribute('name')); - $this->assertEquals( - 'something', - $request1->getAttribute('name', 'something'), - 'Should return the default value' - ); - - $this->assertEquals('value', $request2->getAttribute('name')); - $this->assertEquals(['name' => 'value'], $request2->getAttributes()); - $this->assertEquals(['name' => 'value', 'other' => 'otherValue'], $request3->getAttributes()); - $this->assertEquals(['name' => 'value'], $request4->getAttributes()); - } - - public function testNullAttribute() - { - $request = (new ServerRequest('GET', '/'))->withAttribute('name', null); - - $this->assertSame(['name' => null], $request->getAttributes()); - $this->assertNull($request->getAttribute('name', 'different-default')); - - $requestWithoutAttribute = $request->withoutAttribute('name'); - - $this->assertSame([], $requestWithoutAttribute->getAttributes()); - $this->assertSame('different-default', $requestWithoutAttribute->getAttribute('name', 'different-default')); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php b/vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php deleted file mode 100644 index 682079e0c..000000000 --- a/vendor/guzzlehttp/psr7/tests/StreamDecoratorTraitTest.php +++ /dev/null @@ -1,137 +0,0 @@ -c = fopen('php://temp', 'r+'); - fwrite($this->c, 'foo'); - fseek($this->c, 0); - $this->a = Psr7\stream_for($this->c); - $this->b = new Str($this->a); - } - - public function testCatchesExceptionsWhenCastingToString() - { - $s = $this->getMockBuilder('Psr\Http\Message\StreamInterface') - ->setMethods(['read']) - ->getMockForAbstractClass(); - $s->expects($this->once()) - ->method('read') - ->will($this->throwException(new \Exception('foo'))); - $msg = ''; - set_error_handler(function ($errNo, $str) use (&$msg) { $msg = $str; }); - echo new Str($s); - restore_error_handler(); - $this->assertContains('foo', $msg); - } - - public function testToString() - { - $this->assertEquals('foo', (string) $this->b); - } - - public function testHasSize() - { - $this->assertEquals(3, $this->b->getSize()); - } - - public function testReads() - { - $this->assertEquals('foo', $this->b->read(10)); - } - - public function testCheckMethods() - { - $this->assertEquals($this->a->isReadable(), $this->b->isReadable()); - $this->assertEquals($this->a->isWritable(), $this->b->isWritable()); - $this->assertEquals($this->a->isSeekable(), $this->b->isSeekable()); - } - - public function testSeeksAndTells() - { - $this->b->seek(1); - $this->assertEquals(1, $this->a->tell()); - $this->assertEquals(1, $this->b->tell()); - $this->b->seek(0); - $this->assertEquals(0, $this->a->tell()); - $this->assertEquals(0, $this->b->tell()); - $this->b->seek(0, SEEK_END); - $this->assertEquals(3, $this->a->tell()); - $this->assertEquals(3, $this->b->tell()); - } - - public function testGetsContents() - { - $this->assertEquals('foo', $this->b->getContents()); - $this->assertEquals('', $this->b->getContents()); - $this->b->seek(1); - $this->assertEquals('oo', $this->b->getContents(1)); - } - - public function testCloses() - { - $this->b->close(); - $this->assertFalse(is_resource($this->c)); - } - - public function testDetaches() - { - $this->b->detach(); - $this->assertFalse($this->b->isReadable()); - } - - public function testWrapsMetadata() - { - $this->assertSame($this->b->getMetadata(), $this->a->getMetadata()); - $this->assertSame($this->b->getMetadata('uri'), $this->a->getMetadata('uri')); - } - - public function testWrapsWrites() - { - $this->b->seek(0, SEEK_END); - $this->b->write('foo'); - $this->assertEquals('foofoo', (string) $this->a); - } - - /** - * @expectedException \UnexpectedValueException - */ - public function testThrowsWithInvalidGetter() - { - $this->b->foo; - } - - /** - * @expectedException \BadMethodCallException - */ - public function testThrowsWhenGetterNotImplemented() - { - $s = new BadStream(); - $s->stream; - } -} - -class BadStream -{ - use StreamDecoratorTrait; - - public function __construct() {} -} diff --git a/vendor/guzzlehttp/psr7/tests/StreamTest.php b/vendor/guzzlehttp/psr7/tests/StreamTest.php deleted file mode 100644 index 4fe92cc6b..000000000 --- a/vendor/guzzlehttp/psr7/tests/StreamTest.php +++ /dev/null @@ -1,161 +0,0 @@ -assertTrue($stream->isReadable()); - $this->assertTrue($stream->isWritable()); - $this->assertTrue($stream->isSeekable()); - $this->assertEquals('php://temp', $stream->getMetadata('uri')); - $this->assertInternalType('array', $stream->getMetadata()); - $this->assertEquals(4, $stream->getSize()); - $this->assertFalse($stream->eof()); - $stream->close(); - } - - public function testStreamClosesHandleOnDestruct() - { - $handle = fopen('php://temp', 'r'); - $stream = new Stream($handle); - unset($stream); - $this->assertFalse(is_resource($handle)); - } - - public function testConvertsToString() - { - $handle = fopen('php://temp', 'w+'); - fwrite($handle, 'data'); - $stream = new Stream($handle); - $this->assertEquals('data', (string) $stream); - $this->assertEquals('data', (string) $stream); - $stream->close(); - } - - public function testGetsContents() - { - $handle = fopen('php://temp', 'w+'); - fwrite($handle, 'data'); - $stream = new Stream($handle); - $this->assertEquals('', $stream->getContents()); - $stream->seek(0); - $this->assertEquals('data', $stream->getContents()); - $this->assertEquals('', $stream->getContents()); - } - - public function testChecksEof() - { - $handle = fopen('php://temp', 'w+'); - fwrite($handle, 'data'); - $stream = new Stream($handle); - $this->assertFalse($stream->eof()); - $stream->read(4); - $this->assertTrue($stream->eof()); - $stream->close(); - } - - public function testGetSize() - { - $size = filesize(__FILE__); - $handle = fopen(__FILE__, 'r'); - $stream = new Stream($handle); - $this->assertEquals($size, $stream->getSize()); - // Load from cache - $this->assertEquals($size, $stream->getSize()); - $stream->close(); - } - - public function testEnsuresSizeIsConsistent() - { - $h = fopen('php://temp', 'w+'); - $this->assertEquals(3, fwrite($h, 'foo')); - $stream = new Stream($h); - $this->assertEquals(3, $stream->getSize()); - $this->assertEquals(4, $stream->write('test')); - $this->assertEquals(7, $stream->getSize()); - $this->assertEquals(7, $stream->getSize()); - $stream->close(); - } - - public function testProvidesStreamPosition() - { - $handle = fopen('php://temp', 'w+'); - $stream = new Stream($handle); - $this->assertEquals(0, $stream->tell()); - $stream->write('foo'); - $this->assertEquals(3, $stream->tell()); - $stream->seek(1); - $this->assertEquals(1, $stream->tell()); - $this->assertSame(ftell($handle), $stream->tell()); - $stream->close(); - } - - public function testCanDetachStream() - { - $r = fopen('php://temp', 'w+'); - $stream = new Stream($r); - $stream->write('foo'); - $this->assertTrue($stream->isReadable()); - $this->assertSame($r, $stream->detach()); - $stream->detach(); - - $this->assertFalse($stream->isReadable()); - $this->assertFalse($stream->isWritable()); - $this->assertFalse($stream->isSeekable()); - - $throws = function (callable $fn) use ($stream) { - try { - $fn($stream); - $this->fail(); - } catch (\Exception $e) {} - }; - - $throws(function ($stream) { $stream->read(10); }); - $throws(function ($stream) { $stream->write('bar'); }); - $throws(function ($stream) { $stream->seek(10); }); - $throws(function ($stream) { $stream->tell(); }); - $throws(function ($stream) { $stream->eof(); }); - $throws(function ($stream) { $stream->getSize(); }); - $throws(function ($stream) { $stream->getContents(); }); - $this->assertSame('', (string) $stream); - $stream->close(); - } - - public function testCloseClearProperties() - { - $handle = fopen('php://temp', 'r+'); - $stream = new Stream($handle); - $stream->close(); - - $this->assertFalse($stream->isSeekable()); - $this->assertFalse($stream->isReadable()); - $this->assertFalse($stream->isWritable()); - $this->assertNull($stream->getSize()); - $this->assertEmpty($stream->getMetadata()); - } - - public function testDoesNotThrowInToString() - { - $s = \GuzzleHttp\Psr7\stream_for('foo'); - $s = new NoSeekStream($s); - $this->assertEquals('foo', (string) $s); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php b/vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php deleted file mode 100644 index 7183aae8a..000000000 --- a/vendor/guzzlehttp/psr7/tests/StreamWrapperTest.php +++ /dev/null @@ -1,102 +0,0 @@ -assertSame('foo', fread($handle, 3)); - $this->assertSame(3, ftell($handle)); - $this->assertSame(3, fwrite($handle, 'bar')); - $this->assertSame(0, fseek($handle, 0)); - $this->assertSame('foobar', fread($handle, 6)); - $this->assertSame('', fread($handle, 1)); - $this->assertTrue(feof($handle)); - - $stBlksize = defined('PHP_WINDOWS_VERSION_BUILD') ? -1 : 0; - - // This fails on HHVM for some reason - if (!defined('HHVM_VERSION')) { - $this->assertEquals([ - 'dev' => 0, - 'ino' => 0, - 'mode' => 33206, - 'nlink' => 0, - 'uid' => 0, - 'gid' => 0, - 'rdev' => 0, - 'size' => 6, - 'atime' => 0, - 'mtime' => 0, - 'ctime' => 0, - 'blksize' => $stBlksize, - 'blocks' => $stBlksize, - 0 => 0, - 1 => 0, - 2 => 33206, - 3 => 0, - 4 => 0, - 5 => 0, - 6 => 0, - 7 => 6, - 8 => 0, - 9 => 0, - 10 => 0, - 11 => $stBlksize, - 12 => $stBlksize, - ], fstat($handle)); - } - - $this->assertTrue(fclose($handle)); - $this->assertSame('foobar', (string) $stream); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testValidatesStream() - { - $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface') - ->setMethods(['isReadable', 'isWritable']) - ->getMockForAbstractClass(); - $stream->expects($this->once()) - ->method('isReadable') - ->will($this->returnValue(false)); - $stream->expects($this->once()) - ->method('isWritable') - ->will($this->returnValue(false)); - StreamWrapper::getResource($stream); - } - - /** - * @expectedException \PHPUnit_Framework_Error_Warning - */ - public function testReturnsFalseWhenStreamDoesNotExist() - { - fopen('guzzle://foo', 'r'); - } - - public function testCanOpenReadonlyStream() - { - $stream = $this->getMockBuilder('Psr\Http\Message\StreamInterface') - ->setMethods(['isReadable', 'isWritable']) - ->getMockForAbstractClass(); - $stream->expects($this->once()) - ->method('isReadable') - ->will($this->returnValue(false)); - $stream->expects($this->once()) - ->method('isWritable') - ->will($this->returnValue(true)); - $r = StreamWrapper::getResource($stream); - $this->assertInternalType('resource', $r); - fclose($r); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/UploadedFileTest.php b/vendor/guzzlehttp/psr7/tests/UploadedFileTest.php deleted file mode 100644 index 809f7ab40..000000000 --- a/vendor/guzzlehttp/psr7/tests/UploadedFileTest.php +++ /dev/null @@ -1,280 +0,0 @@ -cleanup = []; - } - - public function tearDown() - { - foreach ($this->cleanup as $file) { - if (is_scalar($file) && file_exists($file)) { - unlink($file); - } - } - } - - public function invalidStreams() - { - return [ - 'null' => [null], - 'true' => [true], - 'false' => [false], - 'int' => [1], - 'float' => [1.1], - 'array' => [['filename']], - 'object' => [(object) ['filename']], - ]; - } - - /** - * @dataProvider invalidStreams - */ - public function testRaisesExceptionOnInvalidStreamOrFile($streamOrFile) - { - $this->setExpectedException('InvalidArgumentException'); - - new UploadedFile($streamOrFile, 0, UPLOAD_ERR_OK); - } - - public function invalidSizes() - { - return [ - 'null' => [null], - 'float' => [1.1], - 'array' => [[1]], - 'object' => [(object) [1]], - ]; - } - - /** - * @dataProvider invalidSizes - */ - public function testRaisesExceptionOnInvalidSize($size) - { - $this->setExpectedException('InvalidArgumentException', 'size'); - - new UploadedFile(fopen('php://temp', 'wb+'), $size, UPLOAD_ERR_OK); - } - - public function invalidErrorStatuses() - { - return [ - 'null' => [null], - 'true' => [true], - 'false' => [false], - 'float' => [1.1], - 'string' => ['1'], - 'array' => [[1]], - 'object' => [(object) [1]], - 'negative' => [-1], - 'too-big' => [9], - ]; - } - - /** - * @dataProvider invalidErrorStatuses - */ - public function testRaisesExceptionOnInvalidErrorStatus($status) - { - $this->setExpectedException('InvalidArgumentException', 'status'); - - new UploadedFile(fopen('php://temp', 'wb+'), 0, $status); - } - - public function invalidFilenamesAndMediaTypes() - { - return [ - 'true' => [true], - 'false' => [false], - 'int' => [1], - 'float' => [1.1], - 'array' => [['string']], - 'object' => [(object) ['string']], - ]; - } - - /** - * @dataProvider invalidFilenamesAndMediaTypes - */ - public function testRaisesExceptionOnInvalidClientFilename($filename) - { - $this->setExpectedException('InvalidArgumentException', 'filename'); - - new UploadedFile(fopen('php://temp', 'wb+'), 0, UPLOAD_ERR_OK, $filename); - } - - /** - * @dataProvider invalidFilenamesAndMediaTypes - */ - public function testRaisesExceptionOnInvalidClientMediaType($mediaType) - { - $this->setExpectedException('InvalidArgumentException', 'media type'); - - new UploadedFile(fopen('php://temp', 'wb+'), 0, UPLOAD_ERR_OK, 'foobar.baz', $mediaType); - } - - public function testGetStreamReturnsOriginalStreamObject() - { - $stream = new Stream(fopen('php://temp', 'r')); - $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK); - - $this->assertSame($stream, $upload->getStream()); - } - - public function testGetStreamReturnsWrappedPhpStream() - { - $stream = fopen('php://temp', 'wb+'); - $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK); - $uploadStream = $upload->getStream()->detach(); - - $this->assertSame($stream, $uploadStream); - } - - public function testGetStreamReturnsStreamForFile() - { - $this->cleanup[] = $stream = tempnam(sys_get_temp_dir(), 'stream_file'); - $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK); - $uploadStream = $upload->getStream(); - $r = new ReflectionProperty($uploadStream, 'filename'); - $r->setAccessible(true); - - $this->assertSame($stream, $r->getValue($uploadStream)); - } - - public function testSuccessful() - { - $stream = \GuzzleHttp\Psr7\stream_for('Foo bar!'); - $upload = new UploadedFile($stream, $stream->getSize(), UPLOAD_ERR_OK, 'filename.txt', 'text/plain'); - - $this->assertEquals($stream->getSize(), $upload->getSize()); - $this->assertEquals('filename.txt', $upload->getClientFilename()); - $this->assertEquals('text/plain', $upload->getClientMediaType()); - - $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'successful'); - $upload->moveTo($to); - $this->assertFileExists($to); - $this->assertEquals($stream->__toString(), file_get_contents($to)); - } - - public function invalidMovePaths() - { - return [ - 'null' => [null], - 'true' => [true], - 'false' => [false], - 'int' => [1], - 'float' => [1.1], - 'empty' => [''], - 'array' => [['filename']], - 'object' => [(object) ['filename']], - ]; - } - - /** - * @dataProvider invalidMovePaths - */ - public function testMoveRaisesExceptionForInvalidPath($path) - { - $stream = \GuzzleHttp\Psr7\stream_for('Foo bar!'); - $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK); - - $this->cleanup[] = $path; - - $this->setExpectedException('InvalidArgumentException', 'path'); - $upload->moveTo($path); - } - - public function testMoveCannotBeCalledMoreThanOnce() - { - $stream = \GuzzleHttp\Psr7\stream_for('Foo bar!'); - $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK); - - $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'diac'); - $upload->moveTo($to); - $this->assertTrue(file_exists($to)); - - $this->setExpectedException('RuntimeException', 'moved'); - $upload->moveTo($to); - } - - public function testCannotRetrieveStreamAfterMove() - { - $stream = \GuzzleHttp\Psr7\stream_for('Foo bar!'); - $upload = new UploadedFile($stream, 0, UPLOAD_ERR_OK); - - $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'diac'); - $upload->moveTo($to); - $this->assertFileExists($to); - - $this->setExpectedException('RuntimeException', 'moved'); - $upload->getStream(); - } - - public function nonOkErrorStatus() - { - return [ - 'UPLOAD_ERR_INI_SIZE' => [ UPLOAD_ERR_INI_SIZE ], - 'UPLOAD_ERR_FORM_SIZE' => [ UPLOAD_ERR_FORM_SIZE ], - 'UPLOAD_ERR_PARTIAL' => [ UPLOAD_ERR_PARTIAL ], - 'UPLOAD_ERR_NO_FILE' => [ UPLOAD_ERR_NO_FILE ], - 'UPLOAD_ERR_NO_TMP_DIR' => [ UPLOAD_ERR_NO_TMP_DIR ], - 'UPLOAD_ERR_CANT_WRITE' => [ UPLOAD_ERR_CANT_WRITE ], - 'UPLOAD_ERR_EXTENSION' => [ UPLOAD_ERR_EXTENSION ], - ]; - } - - /** - * @dataProvider nonOkErrorStatus - */ - public function testConstructorDoesNotRaiseExceptionForInvalidStreamWhenErrorStatusPresent($status) - { - $uploadedFile = new UploadedFile('not ok', 0, $status); - $this->assertSame($status, $uploadedFile->getError()); - } - - /** - * @dataProvider nonOkErrorStatus - */ - public function testMoveToRaisesExceptionWhenErrorStatusPresent($status) - { - $uploadedFile = new UploadedFile('not ok', 0, $status); - $this->setExpectedException('RuntimeException', 'upload error'); - $uploadedFile->moveTo(__DIR__ . '/' . uniqid()); - } - - /** - * @dataProvider nonOkErrorStatus - */ - public function testGetStreamRaisesExceptionWhenErrorStatusPresent($status) - { - $uploadedFile = new UploadedFile('not ok', 0, $status); - $this->setExpectedException('RuntimeException', 'upload error'); - $stream = $uploadedFile->getStream(); - } - - public function testMoveToCreatesStreamIfOnlyAFilenameWasProvided() - { - $this->cleanup[] = $from = tempnam(sys_get_temp_dir(), 'copy_from'); - $this->cleanup[] = $to = tempnam(sys_get_temp_dir(), 'copy_to'); - - copy(__FILE__, $from); - - $uploadedFile = new UploadedFile($from, 100, UPLOAD_ERR_OK, basename($from), 'text/plain'); - $uploadedFile->moveTo($to); - - $this->assertFileEquals(__FILE__, $to); - } -} diff --git a/vendor/guzzlehttp/psr7/tests/UriTest.php b/vendor/guzzlehttp/psr7/tests/UriTest.php deleted file mode 100644 index a29d9cc0b..000000000 --- a/vendor/guzzlehttp/psr7/tests/UriTest.php +++ /dev/null @@ -1,573 +0,0 @@ -assertSame('https', $uri->getScheme()); - $this->assertSame('user:pass@example.com:8080', $uri->getAuthority()); - $this->assertSame('user:pass', $uri->getUserInfo()); - $this->assertSame('example.com', $uri->getHost()); - $this->assertSame(8080, $uri->getPort()); - $this->assertSame('/path/123', $uri->getPath()); - $this->assertSame('q=abc', $uri->getQuery()); - $this->assertSame('test', $uri->getFragment()); - $this->assertSame('https://user:pass@example.com:8080/path/123?q=abc#test', (string) $uri); - } - - public function testCanTransformAndRetrievePartsIndividually() - { - $uri = (new Uri()) - ->withScheme('https') - ->withUserInfo('user', 'pass') - ->withHost('example.com') - ->withPort(8080) - ->withPath('/path/123') - ->withQuery('q=abc') - ->withFragment('test'); - - $this->assertSame('https', $uri->getScheme()); - $this->assertSame('user:pass@example.com:8080', $uri->getAuthority()); - $this->assertSame('user:pass', $uri->getUserInfo()); - $this->assertSame('example.com', $uri->getHost()); - $this->assertSame(8080, $uri->getPort()); - $this->assertSame('/path/123', $uri->getPath()); - $this->assertSame('q=abc', $uri->getQuery()); - $this->assertSame('test', $uri->getFragment()); - $this->assertSame('https://user:pass@example.com:8080/path/123?q=abc#test', (string) $uri); - } - - /** - * @dataProvider getValidUris - */ - public function testValidUrisStayValid($input) - { - $uri = new Uri($input); - - $this->assertSame($input, (string) $uri); - } - - /** - * @dataProvider getValidUris - */ - public function testFromParts($input) - { - $uri = Uri::fromParts(parse_url($input)); - - $this->assertSame($input, (string) $uri); - } - - public function getValidUris() - { - return [ - ['urn:path-rootless'], - ['urn:path:with:colon'], - ['urn:/path-absolute'], - ['urn:/'], - // only scheme with empty path - ['urn:'], - // only path - ['/'], - ['relative/'], - ['0'], - // same document reference - [''], - // network path without scheme - ['//example.org'], - ['//example.org/'], - ['//example.org?q#h'], - // only query - ['?q'], - ['?q=abc&foo=bar'], - // only fragment - ['#fragment'], - // dot segments are not removed automatically - ['./foo/../bar'], - ]; - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unable to parse URI - * @dataProvider getInvalidUris - */ - public function testInvalidUrisThrowException($invalidUri) - { - new Uri($invalidUri); - } - - public function getInvalidUris() - { - return [ - // parse_url() requires the host component which makes sense for http(s) - // but not when the scheme is not known or different. So '//' or '///' is - // currently invalid as well but should not according to RFC 3986. - ['http://'], - ['urn://host:with:colon'], // host cannot contain ":" - ]; - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid port: 100000. Must be between 1 and 65535 - */ - public function testPortMustBeValid() - { - (new Uri())->withPort(100000); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Invalid port: 0. Must be between 1 and 65535 - */ - public function testWithPortCannotBeZero() - { - (new Uri())->withPort(0); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unable to parse URI - */ - public function testParseUriPortCannotBeZero() - { - new Uri('//example.com:0'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testSchemeMustHaveCorrectType() - { - (new Uri())->withScheme([]); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testHostMustHaveCorrectType() - { - (new Uri())->withHost([]); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testPathMustHaveCorrectType() - { - (new Uri())->withPath([]); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testQueryMustHaveCorrectType() - { - (new Uri())->withQuery([]); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testFragmentMustHaveCorrectType() - { - (new Uri())->withFragment([]); - } - - public function testCanParseFalseyUriParts() - { - $uri = new Uri('0://0:0@0/0?0#0'); - - $this->assertSame('0', $uri->getScheme()); - $this->assertSame('0:0@0', $uri->getAuthority()); - $this->assertSame('0:0', $uri->getUserInfo()); - $this->assertSame('0', $uri->getHost()); - $this->assertSame('/0', $uri->getPath()); - $this->assertSame('0', $uri->getQuery()); - $this->assertSame('0', $uri->getFragment()); - $this->assertSame('0://0:0@0/0?0#0', (string) $uri); - } - - public function testCanConstructFalseyUriParts() - { - $uri = (new Uri()) - ->withScheme('0') - ->withUserInfo('0', '0') - ->withHost('0') - ->withPath('/0') - ->withQuery('0') - ->withFragment('0'); - - $this->assertSame('0', $uri->getScheme()); - $this->assertSame('0:0@0', $uri->getAuthority()); - $this->assertSame('0:0', $uri->getUserInfo()); - $this->assertSame('0', $uri->getHost()); - $this->assertSame('/0', $uri->getPath()); - $this->assertSame('0', $uri->getQuery()); - $this->assertSame('0', $uri->getFragment()); - $this->assertSame('0://0:0@0/0?0#0', (string) $uri); - } - - /** - * @dataProvider getResolveTestCases - */ - public function testResolvesUris($base, $rel, $expected) - { - $uri = new Uri($base); - $actual = Uri::resolve($uri, $rel); - $this->assertSame($expected, (string) $actual); - } - - public function getResolveTestCases() - { - return [ - [self::RFC3986_BASE, 'g:h', 'g:h'], - [self::RFC3986_BASE, 'g', 'http://a/b/c/g'], - [self::RFC3986_BASE, './g', 'http://a/b/c/g'], - [self::RFC3986_BASE, 'g/', 'http://a/b/c/g/'], - [self::RFC3986_BASE, '/g', 'http://a/g'], - [self::RFC3986_BASE, '//g', 'http://g'], - [self::RFC3986_BASE, '?y', 'http://a/b/c/d;p?y'], - [self::RFC3986_BASE, 'g?y', 'http://a/b/c/g?y'], - [self::RFC3986_BASE, '#s', 'http://a/b/c/d;p?q#s'], - [self::RFC3986_BASE, 'g#s', 'http://a/b/c/g#s'], - [self::RFC3986_BASE, 'g?y#s', 'http://a/b/c/g?y#s'], - [self::RFC3986_BASE, ';x', 'http://a/b/c/;x'], - [self::RFC3986_BASE, 'g;x', 'http://a/b/c/g;x'], - [self::RFC3986_BASE, 'g;x?y#s', 'http://a/b/c/g;x?y#s'], - [self::RFC3986_BASE, '', self::RFC3986_BASE], - [self::RFC3986_BASE, '.', 'http://a/b/c/'], - [self::RFC3986_BASE, './', 'http://a/b/c/'], - [self::RFC3986_BASE, '..', 'http://a/b/'], - [self::RFC3986_BASE, '../', 'http://a/b/'], - [self::RFC3986_BASE, '../g', 'http://a/b/g'], - [self::RFC3986_BASE, '../..', 'http://a/'], - [self::RFC3986_BASE, '../../', 'http://a/'], - [self::RFC3986_BASE, '../../g', 'http://a/g'], - [self::RFC3986_BASE, '../../../g', 'http://a/g'], - [self::RFC3986_BASE, '../../../../g', 'http://a/g'], - [self::RFC3986_BASE, '/./g', 'http://a/g'], - [self::RFC3986_BASE, '/../g', 'http://a/g'], - [self::RFC3986_BASE, 'g.', 'http://a/b/c/g.'], - [self::RFC3986_BASE, '.g', 'http://a/b/c/.g'], - [self::RFC3986_BASE, 'g..', 'http://a/b/c/g..'], - [self::RFC3986_BASE, '..g', 'http://a/b/c/..g'], - [self::RFC3986_BASE, './../g', 'http://a/b/g'], - [self::RFC3986_BASE, 'foo////g', 'http://a/b/c/foo////g'], - [self::RFC3986_BASE, './g/.', 'http://a/b/c/g/'], - [self::RFC3986_BASE, 'g/./h', 'http://a/b/c/g/h'], - [self::RFC3986_BASE, 'g/../h', 'http://a/b/c/h'], - [self::RFC3986_BASE, 'g;x=1/./y', 'http://a/b/c/g;x=1/y'], - [self::RFC3986_BASE, 'g;x=1/../y', 'http://a/b/c/y'], - // dot-segments in the query or fragment - [self::RFC3986_BASE, 'g?y/./x', 'http://a/b/c/g?y/./x'], - [self::RFC3986_BASE, 'g?y/../x', 'http://a/b/c/g?y/../x'], - [self::RFC3986_BASE, 'g#s/./x', 'http://a/b/c/g#s/./x'], - [self::RFC3986_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x'], - [self::RFC3986_BASE, 'g#s/../x', 'http://a/b/c/g#s/../x'], - [self::RFC3986_BASE, '?y#s', 'http://a/b/c/d;p?y#s'], - ['http://a/b/c/d;p?q#s', '?y', 'http://a/b/c/d;p?y'], - ['http://u@a/b/c/d;p?q', '.', 'http://u@a/b/c/'], - ['http://u:p@a/b/c/d;p?q', '.', 'http://u:p@a/b/c/'], - ['http://a/b/c/d/', 'e', 'http://a/b/c/d/e'], - ['urn:no-slash', 'e', 'urn:e'], - // falsey relative parts - [self::RFC3986_BASE, '//0', 'http://0'], - [self::RFC3986_BASE, '0', 'http://a/b/c/0'], - [self::RFC3986_BASE, '?0', 'http://a/b/c/d;p?0'], - [self::RFC3986_BASE, '#0', 'http://a/b/c/d;p?q#0'], - ]; - } - - public function testAddAndRemoveQueryValues() - { - $uri = new Uri(); - $uri = Uri::withQueryValue($uri, 'a', 'b'); - $uri = Uri::withQueryValue($uri, 'c', 'd'); - $uri = Uri::withQueryValue($uri, 'e', null); - $this->assertSame('a=b&c=d&e', $uri->getQuery()); - - $uri = Uri::withoutQueryValue($uri, 'c'); - $this->assertSame('a=b&e', $uri->getQuery()); - $uri = Uri::withoutQueryValue($uri, 'e'); - $this->assertSame('a=b', $uri->getQuery()); - $uri = Uri::withoutQueryValue($uri, 'a'); - $this->assertSame('', $uri->getQuery()); - } - - public function testWithQueryValueReplacesSameKeys() - { - $uri = new Uri(); - $uri = Uri::withQueryValue($uri, 'a', 'b'); - $uri = Uri::withQueryValue($uri, 'c', 'd'); - $uri = Uri::withQueryValue($uri, 'a', 'e'); - $this->assertSame('c=d&a=e', $uri->getQuery()); - } - - public function testWithoutQueryValueRemovesAllSameKeys() - { - $uri = (new Uri())->withQuery('a=b&c=d&a=e'); - $uri = Uri::withoutQueryValue($uri, 'a'); - $this->assertSame('c=d', $uri->getQuery()); - } - - public function testRemoveNonExistingQueryValue() - { - $uri = new Uri(); - $uri = Uri::withQueryValue($uri, 'a', 'b'); - $uri = Uri::withoutQueryValue($uri, 'c'); - $this->assertSame('a=b', $uri->getQuery()); - } - - public function testWithQueryValueHandlesEncoding() - { - $uri = new Uri(); - $uri = Uri::withQueryValue($uri, 'E=mc^2', 'ein&stein'); - $this->assertSame('E%3Dmc%5E2=ein%26stein', $uri->getQuery(), 'Decoded key/value get encoded'); - - $uri = new Uri(); - $uri = Uri::withQueryValue($uri, 'E%3Dmc%5e2', 'ein%26stein'); - $this->assertSame('E%3Dmc%5e2=ein%26stein', $uri->getQuery(), 'Encoded key/value do not get double-encoded'); - } - - public function testWithoutQueryValueHandlesEncoding() - { - // It also tests that the case of the percent-encoding does not matter, - // i.e. both lowercase "%3d" and uppercase "%5E" can be removed. - $uri = (new Uri())->withQuery('E%3dmc%5E2=einstein&foo=bar'); - $uri = Uri::withoutQueryValue($uri, 'E=mc^2'); - $this->assertSame('foo=bar', $uri->getQuery(), 'Handles key in decoded form'); - - $uri = (new Uri())->withQuery('E%3dmc%5E2=einstein&foo=bar'); - $uri = Uri::withoutQueryValue($uri, 'E%3Dmc%5e2'); - $this->assertSame('foo=bar', $uri->getQuery(), 'Handles key in encoded form'); - } - - public function testSchemeIsNormalizedToLowercase() - { - $uri = new Uri('HTTP://example.com'); - - $this->assertSame('http', $uri->getScheme()); - $this->assertSame('http://example.com', (string) $uri); - - $uri = (new Uri('//example.com'))->withScheme('HTTP'); - - $this->assertSame('http', $uri->getScheme()); - $this->assertSame('http://example.com', (string) $uri); - } - - public function testHostIsNormalizedToLowercase() - { - $uri = new Uri('//eXaMpLe.CoM'); - - $this->assertSame('example.com', $uri->getHost()); - $this->assertSame('//example.com', (string) $uri); - - $uri = (new Uri())->withHost('eXaMpLe.CoM'); - - $this->assertSame('example.com', $uri->getHost()); - $this->assertSame('//example.com', (string) $uri); - } - - public function testPortIsNullIfStandardPortForScheme() - { - // HTTPS standard port - $uri = new Uri('https://example.com:443'); - $this->assertNull($uri->getPort()); - $this->assertSame('example.com', $uri->getAuthority()); - - $uri = (new Uri('https://example.com'))->withPort(443); - $this->assertNull($uri->getPort()); - $this->assertSame('example.com', $uri->getAuthority()); - - // HTTP standard port - $uri = new Uri('http://example.com:80'); - $this->assertNull($uri->getPort()); - $this->assertSame('example.com', $uri->getAuthority()); - - $uri = (new Uri('http://example.com'))->withPort(80); - $this->assertNull($uri->getPort()); - $this->assertSame('example.com', $uri->getAuthority()); - } - - public function testPortIsReturnedIfSchemeUnknown() - { - $uri = (new Uri('//example.com'))->withPort(80); - - $this->assertSame(80, $uri->getPort()); - $this->assertSame('example.com:80', $uri->getAuthority()); - } - - public function testStandardPortIsNullIfSchemeChanges() - { - $uri = new Uri('http://example.com:443'); - $this->assertSame('http', $uri->getScheme()); - $this->assertSame(443, $uri->getPort()); - - $uri = $uri->withScheme('https'); - $this->assertNull($uri->getPort()); - } - - public function testPortPassedAsStringIsCastedToInt() - { - $uri = (new Uri('//example.com'))->withPort('8080'); - - $this->assertSame(8080, $uri->getPort(), 'Port is returned as integer'); - $this->assertSame('example.com:8080', $uri->getAuthority()); - } - - public function testPortCanBeRemoved() - { - $uri = (new Uri('http://example.com:8080'))->withPort(null); - - $this->assertNull($uri->getPort()); - $this->assertSame('http://example.com', (string) $uri); - } - - public function testAuthorityWithUserInfoButWithoutHost() - { - $uri = (new Uri())->withUserInfo('user', 'pass'); - - $this->assertSame('user:pass', $uri->getUserInfo()); - $this->assertSame('', $uri->getAuthority()); - } - - public function uriComponentsEncodingProvider() - { - $unreserved = 'a-zA-Z0-9.-_~!$&\'()*+,;=:@'; - - return [ - // Percent encode spaces - ['/pa th?q=va lue#frag ment', '/pa%20th', 'q=va%20lue', 'frag%20ment', '/pa%20th?q=va%20lue#frag%20ment'], - // Percent encode multibyte - ['/€?€#€', '/%E2%82%AC', '%E2%82%AC', '%E2%82%AC', '/%E2%82%AC?%E2%82%AC#%E2%82%AC'], - // Don't encode something that's already encoded - ['/pa%20th?q=va%20lue#frag%20ment', '/pa%20th', 'q=va%20lue', 'frag%20ment', '/pa%20th?q=va%20lue#frag%20ment'], - // Percent encode invalid percent encodings - ['/pa%2-th?q=va%2-lue#frag%2-ment', '/pa%252-th', 'q=va%252-lue', 'frag%252-ment', '/pa%252-th?q=va%252-lue#frag%252-ment'], - // Don't encode path segments - ['/pa/th//two?q=va/lue#frag/ment', '/pa/th//two', 'q=va/lue', 'frag/ment', '/pa/th//two?q=va/lue#frag/ment'], - // Don't encode unreserved chars or sub-delimiters - ["/$unreserved?$unreserved#$unreserved", "/$unreserved", $unreserved, $unreserved, "/$unreserved?$unreserved#$unreserved"], - // Encoded unreserved chars are not decoded - ['/p%61th?q=v%61lue#fr%61gment', '/p%61th', 'q=v%61lue', 'fr%61gment', '/p%61th?q=v%61lue#fr%61gment'], - ]; - } - - /** - * @dataProvider uriComponentsEncodingProvider - */ - public function testUriComponentsGetEncodedProperly($input, $path, $query, $fragment, $output) - { - $uri = new Uri($input); - $this->assertSame($path, $uri->getPath()); - $this->assertSame($query, $uri->getQuery()); - $this->assertSame($fragment, $uri->getFragment()); - $this->assertSame($output, (string) $uri); - } - - public function testWithPathEncodesProperly() - { - $uri = (new Uri())->withPath('/baz?#€/b%61r'); - // Query and fragment delimiters and multibyte chars are encoded. - $this->assertSame('/baz%3F%23%E2%82%AC/b%61r', $uri->getPath()); - $this->assertSame('/baz%3F%23%E2%82%AC/b%61r', (string) $uri); - } - - public function testWithQueryEncodesProperly() - { - $uri = (new Uri())->withQuery('?=#&€=/&b%61r'); - // A query starting with a "?" is valid and must not be magically removed. Otherwise it would be impossible to - // construct such an URI. Also the "?" and "/" does not need to be encoded in the query. - $this->assertSame('?=%23&%E2%82%AC=/&b%61r', $uri->getQuery()); - $this->assertSame('??=%23&%E2%82%AC=/&b%61r', (string) $uri); - } - - public function testWithFragmentEncodesProperly() - { - $uri = (new Uri())->withFragment('#€?/b%61r'); - // A fragment starting with a "#" is valid and must not be magically removed. Otherwise it would be impossible to - // construct such an URI. Also the "?" and "/" does not need to be encoded in the fragment. - $this->assertSame('%23%E2%82%AC?/b%61r', $uri->getFragment()); - $this->assertSame('#%23%E2%82%AC?/b%61r', (string) $uri); - } - - public function testAllowsForRelativeUri() - { - $uri = (new Uri)->withPath('foo'); - $this->assertSame('foo', $uri->getPath()); - $this->assertSame('foo', (string) $uri); - } - - public function testAddsSlashForRelativeUriStringWithHost() - { - // If the path is rootless and an authority is present, the path MUST - // be prefixed by "/". - $uri = (new Uri)->withPath('foo')->withHost('example.com'); - $this->assertSame('foo', $uri->getPath()); - // concatenating a relative path with a host doesn't work: "//example.comfoo" would be wrong - $this->assertSame('//example.com/foo', (string) $uri); - } - - public function testRemoveExtraSlashesWihoutHost() - { - // If the path is starting with more than one "/" and no authority is - // present, the starting slashes MUST be reduced to one. - $uri = (new Uri)->withPath('//foo'); - $this->assertSame('//foo', $uri->getPath()); - // URI "//foo" would be interpreted as network reference and thus change the original path to the host - $this->assertSame('/foo', (string) $uri); - } - - public function testDefaultReturnValuesOfGetters() - { - $uri = new Uri(); - - $this->assertSame('', $uri->getScheme()); - $this->assertSame('', $uri->getAuthority()); - $this->assertSame('', $uri->getUserInfo()); - $this->assertSame('', $uri->getHost()); - $this->assertNull($uri->getPort()); - $this->assertSame('', $uri->getPath()); - $this->assertSame('', $uri->getQuery()); - $this->assertSame('', $uri->getFragment()); - } - - public function testImmutability() - { - $uri = new Uri(); - - $this->assertNotSame($uri, $uri->withScheme('https')); - $this->assertNotSame($uri, $uri->withUserInfo('user', 'pass')); - $this->assertNotSame($uri, $uri->withHost('example.com')); - $this->assertNotSame($uri, $uri->withPort(8080)); - $this->assertNotSame($uri, $uri->withPath('/path/123')); - $this->assertNotSame($uri, $uri->withQuery('q=abc')); - $this->assertNotSame($uri, $uri->withFragment('test')); - } - - public function testExtendingClassesInstantiates() - { - // The non-standard port triggers a cascade of private methods which - // should not use late static binding to access private static members. - // If they do, this will fatal. - $this->assertInstanceOf( - '\GuzzleHttp\Tests\Psr7\ExtendingClassTest', - new ExtendingClassTest('http://h:9/') - ); - } -} - -class ExtendingClassTest extends \GuzzleHttp\Psr7\Uri -{ -} diff --git a/vendor/guzzlehttp/psr7/tests/bootstrap.php b/vendor/guzzlehttp/psr7/tests/bootstrap.php deleted file mode 100644 index 8601dd330..000000000 --- a/vendor/guzzlehttp/psr7/tests/bootstrap.php +++ /dev/null @@ -1,11 +0,0 @@ - - -For the full copyright and license information, please view the LICENSE -file that was distributed with this source code. -EOF; - -$finder = Symfony\CS\Finder::create() - ->files() - ->name('*.php') - ->exclude('Fixtures') - ->in(__DIR__.'/src') - ->in(__DIR__.'/tests') -; - -return Symfony\CS\Config::create() - ->setUsingCache(true) - //->setUsingLinter(false) - ->setRiskyAllowed(true) - ->setRules(array( - '@PSR2' => true, - 'binary_operator_spaces' => true, - 'blank_line_before_return' => true, - 'header_comment' => array('header' => $header), - 'include' => true, - 'long_array_syntax' => true, - 'method_separation' => true, - 'no_blank_lines_after_class_opening' => true, - 'no_blank_lines_after_phpdoc' => true, - 'no_blank_lines_between_uses' => true, - 'no_duplicate_semicolons' => true, - 'no_extra_consecutive_blank_lines' => true, - 'no_leading_import_slash' => true, - 'no_leading_namespace_whitespace' => true, - 'no_trailing_comma_in_singleline_array' => true, - 'no_unused_imports' => true, - 'object_operator_without_whitespace' => true, - 'phpdoc_align' => true, - 'phpdoc_indent' => true, - 'phpdoc_no_access' => true, - 'phpdoc_no_package' => true, - 'phpdoc_order' => true, - 'phpdoc_scalar' => true, - 'phpdoc_trim' => true, - 'phpdoc_type_to_var' => true, - 'psr0' => true, - 'single_blank_line_before_namespace' => true, - 'spaces_cast' => true, - 'standardize_not_equals' => true, - 'ternary_operator_spaces' => true, - 'trailing_comma_in_multiline_array' => true, - 'whitespacy_lines' => true, - )) - ->finder($finder) -; diff --git a/vendor/monolog/monolog/CHANGELOG.mdown b/vendor/monolog/monolog/CHANGELOG.mdown deleted file mode 100644 index 5f81e24f0..000000000 --- a/vendor/monolog/monolog/CHANGELOG.mdown +++ /dev/null @@ -1,317 +0,0 @@ -### 1.21.0 (2016-07-29) - - * Break: Reverted the addition of $context when the ErrorHandler handles regular php errors from 1.20.0 as it was causing issues - * Added support for more formats in RotatingFileHandler::setFilenameFormat as long as they have Y, m and d in order - * Added ability to format the main line of text the SlackHandler sends by explictly setting a formatter on the handler - * Added information about SoapFault instances in NormalizerFormatter - * Added $handleOnlyReportedErrors option on ErrorHandler::registerErrorHandler (default true) to allow logging of all errors no matter the error_reporting level - -### 1.20.0 (2016-07-02) - - * Added FingersCrossedHandler::activate() to manually trigger the handler regardless of the activation policy - * Added StreamHandler::getUrl to retrieve the stream's URL - * Added ability to override addRow/addTitle in HtmlFormatter - * Added the $context to context information when the ErrorHandler handles a regular php error - * Deprecated RotatingFileHandler::setFilenameFormat to only support 3 formats: Y, Y-m and Y-m-d - * Fixed WhatFailureGroupHandler to work with PHP7 throwables - * Fixed a few minor bugs - -### 1.19.0 (2016-04-12) - - * Break: StreamHandler will not close streams automatically that it does not own. If you pass in a stream (not a path/url), then it will not close it for you. You can retrieve those using getStream() if needed - * Added DeduplicationHandler to remove duplicate records from notifications across multiple requests, useful for email or other notifications on errors - * Added ability to use `%message%` and other LineFormatter replacements in the subject line of emails sent with NativeMailHandler and SwiftMailerHandler - * Fixed HipChatHandler handling of long messages - -### 1.18.2 (2016-04-02) - - * Fixed ElasticaFormatter to use more precise dates - * Fixed GelfMessageFormatter sending too long messages - -### 1.18.1 (2016-03-13) - - * Fixed SlackHandler bug where slack dropped messages randomly - * Fixed RedisHandler issue when using with the PHPRedis extension - * Fixed AmqpHandler content-type being incorrectly set when using with the AMQP extension - * Fixed BrowserConsoleHandler regression - -### 1.18.0 (2016-03-01) - - * Added optional reduction of timestamp precision via `Logger->useMicrosecondTimestamps(false)`, disabling it gets you a bit of performance boost but reduces the precision to the second instead of microsecond - * Added possibility to skip some extra stack frames in IntrospectionProcessor if you have some library wrapping Monolog that is always adding frames - * Added `Logger->withName` to clone a logger (keeping all handlers) with a new name - * Added FluentdFormatter for the Fluentd unix socket protocol - * Added HandlerWrapper base class to ease the creation of handler wrappers, just extend it and override as needed - * Added support for replacing context sub-keys using `%context.*%` in LineFormatter - * Added support for `payload` context value in RollbarHandler - * Added setRelease to RavenHandler to describe the application version, sent with every log - * Added support for `fingerprint` context value in RavenHandler - * Fixed JSON encoding errors that would gobble up the whole log record, we now handle those more gracefully by dropping chars as needed - * Fixed write timeouts in SocketHandler and derivatives, set to 10sec by default, lower it with `setWritingTimeout()` - * Fixed PHP7 compatibility with regard to Exception/Throwable handling in a few places - -### 1.17.2 (2015-10-14) - - * Fixed ErrorHandler compatibility with non-Monolog PSR-3 loggers - * Fixed SlackHandler handling to use slack functionalities better - * Fixed SwiftMailerHandler bug when sending multiple emails they all had the same id - * Fixed 5.3 compatibility regression - -### 1.17.1 (2015-08-31) - - * Fixed RollbarHandler triggering PHP notices - -### 1.17.0 (2015-08-30) - - * Added support for `checksum` and `release` context/extra values in RavenHandler - * Added better support for exceptions in RollbarHandler - * Added UidProcessor::getUid - * Added support for showing the resource type in NormalizedFormatter - * Fixed IntrospectionProcessor triggering PHP notices - -### 1.16.0 (2015-08-09) - - * Added IFTTTHandler to notify ifttt.com triggers - * Added Logger::setHandlers() to allow setting/replacing all handlers - * Added $capSize in RedisHandler to cap the log size - * Fixed StreamHandler creation of directory to only trigger when the first log write happens - * Fixed bug in the handling of curl failures - * Fixed duplicate logging of fatal errors when both error and fatal error handlers are registered in monolog's ErrorHandler - * Fixed missing fatal errors records with handlers that need to be closed to flush log records - * Fixed TagProcessor::addTags support for associative arrays - -### 1.15.0 (2015-07-12) - - * Added addTags and setTags methods to change a TagProcessor - * Added automatic creation of directories if they are missing for a StreamHandler to open a log file - * Added retry functionality to Loggly, Cube and Mandrill handlers so they retry up to 5 times in case of network failure - * Fixed process exit code being incorrectly reset to 0 if ErrorHandler::registerExceptionHandler was used - * Fixed HTML/JS escaping in BrowserConsoleHandler - * Fixed JSON encoding errors being silently suppressed (PHP 5.5+ only) - -### 1.14.0 (2015-06-19) - - * Added PHPConsoleHandler to send record to Chrome's PHP Console extension and library - * Added support for objects implementing __toString in the NormalizerFormatter - * Added support for HipChat's v2 API in HipChatHandler - * Added Logger::setTimezone() to initialize the timezone monolog should use in case date.timezone isn't correct for your app - * Added an option to send formatted message instead of the raw record on PushoverHandler via ->useFormattedMessage(true) - * Fixed curl errors being silently suppressed - -### 1.13.1 (2015-03-09) - - * Fixed regression in HipChat requiring a new token to be created - -### 1.13.0 (2015-03-05) - - * Added Registry::hasLogger to check for the presence of a logger instance - * Added context.user support to RavenHandler - * Added HipChat API v2 support in the HipChatHandler - * Added NativeMailerHandler::addParameter to pass params to the mail() process - * Added context data to SlackHandler when $includeContextAndExtra is true - * Added ability to customize the Swift_Message per-email in SwiftMailerHandler - * Fixed SwiftMailerHandler to lazily create message instances if a callback is provided - * Fixed serialization of INF and NaN values in Normalizer and LineFormatter - -### 1.12.0 (2014-12-29) - - * Break: HandlerInterface::isHandling now receives a partial record containing only a level key. This was always the intent and does not break any Monolog handler but is strictly speaking a BC break and you should check if you relied on any other field in your own handlers. - * Added PsrHandler to forward records to another PSR-3 logger - * Added SamplingHandler to wrap around a handler and include only every Nth record - * Added MongoDBFormatter to support better storage with MongoDBHandler (it must be enabled manually for now) - * Added exception codes in the output of most formatters - * Added LineFormatter::includeStacktraces to enable exception stack traces in logs (uses more than one line) - * Added $useShortAttachment to SlackHandler to minify attachment size and $includeExtra to append extra data - * Added $host to HipChatHandler for users of private instances - * Added $transactionName to NewRelicHandler and support for a transaction_name context value - * Fixed MandrillHandler to avoid outputing API call responses - * Fixed some non-standard behaviors in SyslogUdpHandler - -### 1.11.0 (2014-09-30) - - * Break: The NewRelicHandler extra and context data are now prefixed with extra_ and context_ to avoid clashes. Watch out if you have scripts reading those from the API and rely on names - * Added WhatFailureGroupHandler to suppress any exception coming from the wrapped handlers and avoid chain failures if a logging service fails - * Added MandrillHandler to send emails via the Mandrillapp.com API - * Added SlackHandler to log records to a Slack.com account - * Added FleepHookHandler to log records to a Fleep.io account - * Added LogglyHandler::addTag to allow adding tags to an existing handler - * Added $ignoreEmptyContextAndExtra to LineFormatter to avoid empty [] at the end - * Added $useLocking to StreamHandler and RotatingFileHandler to enable flock() while writing - * Added support for PhpAmqpLib in the AmqpHandler - * Added FingersCrossedHandler::clear and BufferHandler::clear to reset them between batches in long running jobs - * Added support for adding extra fields from $_SERVER in the WebProcessor - * Fixed support for non-string values in PrsLogMessageProcessor - * Fixed SwiftMailer messages being sent with the wrong date in long running scripts - * Fixed minor PHP 5.6 compatibility issues - * Fixed BufferHandler::close being called twice - -### 1.10.0 (2014-06-04) - - * Added Logger::getHandlers() and Logger::getProcessors() methods - * Added $passthruLevel argument to FingersCrossedHandler to let it always pass some records through even if the trigger level is not reached - * Added support for extra data in NewRelicHandler - * Added $expandNewlines flag to the ErrorLogHandler to create multiple log entries when a message has multiple lines - -### 1.9.1 (2014-04-24) - - * Fixed regression in RotatingFileHandler file permissions - * Fixed initialization of the BufferHandler to make sure it gets flushed after receiving records - * Fixed ChromePHPHandler and FirePHPHandler's activation strategies to be more conservative - -### 1.9.0 (2014-04-20) - - * Added LogEntriesHandler to send logs to a LogEntries account - * Added $filePermissions to tweak file mode on StreamHandler and RotatingFileHandler - * Added $useFormatting flag to MemoryProcessor to make it send raw data in bytes - * Added support for table formatting in FirePHPHandler via the table context key - * Added a TagProcessor to add tags to records, and support for tags in RavenHandler - * Added $appendNewline flag to the JsonFormatter to enable using it when logging to files - * Added sound support to the PushoverHandler - * Fixed multi-threading support in StreamHandler - * Fixed empty headers issue when ChromePHPHandler received no records - * Fixed default format of the ErrorLogHandler - -### 1.8.0 (2014-03-23) - - * Break: the LineFormatter now strips newlines by default because this was a bug, set $allowInlineLineBreaks to true if you need them - * Added BrowserConsoleHandler to send logs to any browser's console via console.log() injection in the output - * Added FilterHandler to filter records and only allow those of a given list of levels through to the wrapped handler - * Added FlowdockHandler to send logs to a Flowdock account - * Added RollbarHandler to send logs to a Rollbar account - * Added HtmlFormatter to send prettier log emails with colors for each log level - * Added GitProcessor to add the current branch/commit to extra record data - * Added a Monolog\Registry class to allow easier global access to pre-configured loggers - * Added support for the new official graylog2/gelf-php lib for GelfHandler, upgrade if you can by replacing the mlehner/gelf-php requirement - * Added support for HHVM - * Added support for Loggly batch uploads - * Added support for tweaking the content type and encoding in NativeMailerHandler - * Added $skipClassesPartials to tweak the ignored classes in the IntrospectionProcessor - * Fixed batch request support in GelfHandler - -### 1.7.0 (2013-11-14) - - * Added ElasticSearchHandler to send logs to an Elastic Search server - * Added DynamoDbHandler and ScalarFormatter to send logs to Amazon's Dynamo DB - * Added SyslogUdpHandler to send logs to a remote syslogd server - * Added LogglyHandler to send logs to a Loggly account - * Added $level to IntrospectionProcessor so it only adds backtraces when needed - * Added $version to LogstashFormatter to allow using the new v1 Logstash format - * Added $appName to NewRelicHandler - * Added configuration of Pushover notification retries/expiry - * Added $maxColumnWidth to NativeMailerHandler to change the 70 chars default - * Added chainability to most setters for all handlers - * Fixed RavenHandler batch processing so it takes the message from the record with highest priority - * Fixed HipChatHandler batch processing so it sends all messages at once - * Fixed issues with eAccelerator - * Fixed and improved many small things - -### 1.6.0 (2013-07-29) - - * Added HipChatHandler to send logs to a HipChat chat room - * Added ErrorLogHandler to send logs to PHP's error_log function - * Added NewRelicHandler to send logs to NewRelic's service - * Added Monolog\ErrorHandler helper class to register a Logger as exception/error/fatal handler - * Added ChannelLevelActivationStrategy for the FingersCrossedHandler to customize levels by channel - * Added stack traces output when normalizing exceptions (json output & co) - * Added Monolog\Logger::API constant (currently 1) - * Added support for ChromePHP's v4.0 extension - * Added support for message priorities in PushoverHandler, see $highPriorityLevel and $emergencyLevel - * Added support for sending messages to multiple users at once with the PushoverHandler - * Fixed RavenHandler's support for batch sending of messages (when behind a Buffer or FingersCrossedHandler) - * Fixed normalization of Traversables with very large data sets, only the first 1000 items are shown now - * Fixed issue in RotatingFileHandler when an open_basedir restriction is active - * Fixed minor issues in RavenHandler and bumped the API to Raven 0.5.0 - * Fixed SyslogHandler issue when many were used concurrently with different facilities - -### 1.5.0 (2013-04-23) - - * Added ProcessIdProcessor to inject the PID in log records - * Added UidProcessor to inject a unique identifier to all log records of one request/run - * Added support for previous exceptions in the LineFormatter exception serialization - * Added Monolog\Logger::getLevels() to get all available levels - * Fixed ChromePHPHandler so it avoids sending headers larger than Chrome can handle - -### 1.4.1 (2013-04-01) - - * Fixed exception formatting in the LineFormatter to be more minimalistic - * Fixed RavenHandler's handling of context/extra data, requires Raven client >0.1.0 - * Fixed log rotation in RotatingFileHandler to work with long running scripts spanning multiple days - * Fixed WebProcessor array access so it checks for data presence - * Fixed Buffer, Group and FingersCrossed handlers to make use of their processors - -### 1.4.0 (2013-02-13) - - * Added RedisHandler to log to Redis via the Predis library or the phpredis extension - * Added ZendMonitorHandler to log to the Zend Server monitor - * Added the possibility to pass arrays of handlers and processors directly in the Logger constructor - * Added `$useSSL` option to the PushoverHandler which is enabled by default - * Fixed ChromePHPHandler and FirePHPHandler issue when multiple instances are used simultaneously - * Fixed header injection capability in the NativeMailHandler - -### 1.3.1 (2013-01-11) - - * Fixed LogstashFormatter to be usable with stream handlers - * Fixed GelfMessageFormatter levels on Windows - -### 1.3.0 (2013-01-08) - - * Added PSR-3 compliance, the `Monolog\Logger` class is now an instance of `Psr\Log\LoggerInterface` - * Added PsrLogMessageProcessor that you can selectively enable for full PSR-3 compliance - * Added LogstashFormatter (combine with SocketHandler or StreamHandler to send logs to Logstash) - * Added PushoverHandler to send mobile notifications - * Added CouchDBHandler and DoctrineCouchDBHandler - * Added RavenHandler to send data to Sentry servers - * Added support for the new MongoClient class in MongoDBHandler - * Added microsecond precision to log records' timestamps - * Added `$flushOnOverflow` param to BufferHandler to flush by batches instead of losing - the oldest entries - * Fixed normalization of objects with cyclic references - -### 1.2.1 (2012-08-29) - - * Added new $logopts arg to SyslogHandler to provide custom openlog options - * Fixed fatal error in SyslogHandler - -### 1.2.0 (2012-08-18) - - * Added AmqpHandler (for use with AMQP servers) - * Added CubeHandler - * Added NativeMailerHandler::addHeader() to send custom headers in mails - * Added the possibility to specify more than one recipient in NativeMailerHandler - * Added the possibility to specify float timeouts in SocketHandler - * Added NOTICE and EMERGENCY levels to conform with RFC 5424 - * Fixed the log records to use the php default timezone instead of UTC - * Fixed BufferHandler not being flushed properly on PHP fatal errors - * Fixed normalization of exotic resource types - * Fixed the default format of the SyslogHandler to avoid duplicating datetimes in syslog - -### 1.1.0 (2012-04-23) - - * Added Monolog\Logger::isHandling() to check if a handler will - handle the given log level - * Added ChromePHPHandler - * Added MongoDBHandler - * Added GelfHandler (for use with Graylog2 servers) - * Added SocketHandler (for use with syslog-ng for example) - * Added NormalizerFormatter - * Added the possibility to change the activation strategy of the FingersCrossedHandler - * Added possibility to show microseconds in logs - * Added `server` and `referer` to WebProcessor output - -### 1.0.2 (2011-10-24) - - * Fixed bug in IE with large response headers and FirePHPHandler - -### 1.0.1 (2011-08-25) - - * Added MemoryPeakUsageProcessor and MemoryUsageProcessor - * Added Monolog\Logger::getName() to get a logger's channel name - -### 1.0.0 (2011-07-06) - - * Added IntrospectionProcessor to get info from where the logger was called - * Fixed WebProcessor in CLI - -### 1.0.0-RC1 (2011-07-01) - - * Initial release diff --git a/vendor/monolog/monolog/LICENSE b/vendor/monolog/monolog/LICENSE deleted file mode 100644 index 16473219b..000000000 --- a/vendor/monolog/monolog/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2011-2016 Jordi Boggiano - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/monolog/monolog/README.mdown b/vendor/monolog/monolog/README.mdown deleted file mode 100644 index 7d8ade526..000000000 --- a/vendor/monolog/monolog/README.mdown +++ /dev/null @@ -1,95 +0,0 @@ -# Monolog - Logging for PHP [![Build Status](https://img.shields.io/travis/Seldaek/monolog.svg)](https://travis-ci.org/Seldaek/monolog) - -[![Total Downloads](https://img.shields.io/packagist/dt/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog) -[![Latest Stable Version](https://img.shields.io/packagist/v/monolog/monolog.svg)](https://packagist.org/packages/monolog/monolog) -[![Reference Status](https://www.versioneye.com/php/monolog:monolog/reference_badge.svg)](https://www.versioneye.com/php/monolog:monolog/references) - - -Monolog sends your logs to files, sockets, inboxes, databases and various -web services. See the complete list of handlers below. Special handlers -allow you to build advanced logging strategies. - -This library implements the [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) -interface that you can type-hint against in your own libraries to keep -a maximum of interoperability. You can also use it in your applications to -make sure you can always use another compatible logger at a later time. -As of 1.11.0 Monolog public APIs will also accept PSR-3 log levels. -Internally Monolog still uses its own level scheme since it predates PSR-3. - -## Installation - -Install the latest version with - -```bash -$ composer require monolog/monolog -``` - -## Basic Usage - -```php -pushHandler(new StreamHandler('path/to/your.log', Logger::WARNING)); - -// add records to the log -$log->addWarning('Foo'); -$log->addError('Bar'); -``` - -## Documentation - -- [Usage Instructions](doc/01-usage.md) -- [Handlers, Formatters and Processors](doc/02-handlers-formatters-processors.md) -- [Utility classes](doc/03-utilities.md) -- [Extending Monolog](doc/04-extending.md) - -## Third Party Packages - -Third party handlers, formatters and processors are -[listed in the wiki](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages). You -can also add your own there if you publish one. - -## About - -### Requirements - -- Monolog works with PHP 5.3 or above, and is also tested to work with HHVM. - -### Submitting bugs and feature requests - -Bugs and feature request are tracked on [GitHub](https://github.com/Seldaek/monolog/issues) - -### Framework Integrations - -- Frameworks and libraries using [PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) - can be used very easily with Monolog since it implements the interface. -- [Symfony2](http://symfony.com) comes out of the box with Monolog. -- [Silex](http://silex.sensiolabs.org/) comes out of the box with Monolog. -- [Laravel 4 & 5](http://laravel.com/) come out of the box with Monolog. -- [Lumen](http://lumen.laravel.com/) comes out of the box with Monolog. -- [PPI](http://www.ppi.io/) comes out of the box with Monolog. -- [CakePHP](http://cakephp.org/) is usable with Monolog via the [cakephp-monolog](https://github.com/jadb/cakephp-monolog) plugin. -- [Slim](http://www.slimframework.com/) is usable with Monolog via the [Slim-Monolog](https://github.com/Flynsarmy/Slim-Monolog) log writer. -- [XOOPS 2.6](http://xoops.org/) comes out of the box with Monolog. -- [Aura.Web_Project](https://github.com/auraphp/Aura.Web_Project) comes out of the box with Monolog. -- [Nette Framework](http://nette.org/en/) can be used with Monolog via [Kdyby/Monolog](https://github.com/Kdyby/Monolog) extension. -- [Proton Micro Framework](https://github.com/alexbilbie/Proton) comes out of the box with Monolog. - -### Author - -Jordi Boggiano - -
-See also the list of [contributors](https://github.com/Seldaek/monolog/contributors) which participated in this project. - -### License - -Monolog is licensed under the MIT License - see the `LICENSE` file for details - -### Acknowledgements - -This library is heavily inspired by Python's [Logbook](http://packages.python.org/Logbook/) -library, although most concepts have been adjusted to fit to the PHP world. diff --git a/vendor/monolog/monolog/composer.json b/vendor/monolog/monolog/composer.json deleted file mode 100644 index b488c38ba..000000000 --- a/vendor/monolog/monolog/composer.json +++ /dev/null @@ -1,66 +0,0 @@ -{ - "name": "monolog/monolog", - "description": "Sends your logs to files, sockets, inboxes, databases and various web services", - "keywords": ["log", "logging", "psr-3"], - "homepage": "http://github.com/Seldaek/monolog", - "type": "library", - "license": "MIT", - "authors": [ - { - "name": "Jordi Boggiano", - "email": "j.boggiano@seld.be", - "homepage": "http://seld.be" - } - ], - "require": { - "php": ">=5.3.0", - "psr/log": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.5", - "graylog2/gelf-php": "~1.0", - "sentry/sentry": "^0.13", - "ruflin/elastica": ">=0.90 <3.0", - "doctrine/couchdb": "~1.0@dev", - "aws/aws-sdk-php": "^2.4.9", - "php-amqplib/php-amqplib": "~2.4", - "swiftmailer/swiftmailer": "~5.3", - "php-console/php-console": "^3.1.3", - "phpunit/phpunit-mock-objects": "2.3.0", - "jakub-onderka/php-parallel-lint": "0.9" - }, - "_": "phpunit/phpunit-mock-objects required in 2.3.0 due to https://github.com/sebastianbergmann/phpunit-mock-objects/issues/223 - needs hhvm 3.8+ on travis", - "suggest": { - "graylog2/gelf-php": "Allow sending log messages to a GrayLog2 server", - "sentry/sentry": "Allow sending log messages to a Sentry server", - "doctrine/couchdb": "Allow sending log messages to a CouchDB server", - "ruflin/elastica": "Allow sending log messages to an Elastic Search server", - "php-amqplib/php-amqplib": "Allow sending log messages to an AMQP server using php-amqplib", - "ext-amqp": "Allow sending log messages to an AMQP server (1.0+ required)", - "ext-mongo": "Allow sending log messages to a MongoDB server", - "mongodb/mongodb": "Allow sending log messages to a MongoDB server via PHP Driver", - "aws/aws-sdk-php": "Allow sending log messages to AWS services like DynamoDB", - "rollbar/rollbar": "Allow sending log messages to Rollbar", - "php-console/php-console": "Allow sending log messages to Google Chrome" - }, - "autoload": { - "psr-4": {"Monolog\\": "src/Monolog"} - }, - "autoload-dev": { - "psr-4": {"Monolog\\": "tests/Monolog"} - }, - "provide": { - "psr/log-implementation": "1.0.0" - }, - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "scripts": { - "test": [ - "parallel-lint . --exclude vendor", - "phpunit" - ] - } -} diff --git a/vendor/monolog/monolog/doc/01-usage.md b/vendor/monolog/monolog/doc/01-usage.md deleted file mode 100644 index 8e2551f38..000000000 --- a/vendor/monolog/monolog/doc/01-usage.md +++ /dev/null @@ -1,231 +0,0 @@ -# Using Monolog - -- [Installation](#installation) -- [Core Concepts](#core-concepts) -- [Log Levels](#log-levels) -- [Configuring a logger](#configuring-a-logger) -- [Adding extra data in the records](#adding-extra-data-in-the-records) -- [Leveraging channels](#leveraging-channels) -- [Customizing the log format](#customizing-the-log-format) - -## Installation - -Monolog is available on Packagist ([monolog/monolog](http://packagist.org/packages/monolog/monolog)) -and as such installable via [Composer](http://getcomposer.org/). - -```bash -composer require monolog/monolog -``` - -If you do not use Composer, you can grab the code from GitHub, and use any -PSR-0 compatible autoloader (e.g. the [Symfony2 ClassLoader component](https://github.com/symfony/ClassLoader)) -to load Monolog classes. - -## Core Concepts - -Every `Logger` instance has a channel (name) and a stack of handlers. Whenever -you add a record to the logger, it traverses the handler stack. Each handler -decides whether it fully handled the record, and if so, the propagation of the -record ends there. - -This allows for flexible logging setups, for example having a `StreamHandler` at -the bottom of the stack that will log anything to disk, and on top of that add -a `MailHandler` that will send emails only when an error message is logged. -Handlers also have a `$bubble` property which defines whether they block the -record or not if they handled it. In this example, setting the `MailHandler`'s -`$bubble` argument to false means that records handled by the `MailHandler` will -not propagate to the `StreamHandler` anymore. - -You can create many `Logger`s, each defining a channel (e.g.: db, request, -router, ..) and each of them combining various handlers, which can be shared -or not. The channel is reflected in the logs and allows you to easily see or -filter records. - -Each Handler also has a Formatter, a default one with settings that make sense -will be created if you don't set one. The formatters normalize and format -incoming records so that they can be used by the handlers to output useful -information. - -Custom severity levels are not available. Only the eight -[RFC 5424](http://tools.ietf.org/html/rfc5424) levels (debug, info, notice, -warning, error, critical, alert, emergency) are present for basic filtering -purposes, but for sorting and other use cases that would require -flexibility, you should add Processors to the Logger that can add extra -information (tags, user ip, ..) to the records before they are handled. - -## Log Levels - -Monolog supports the logging levels described by [RFC 5424](http://tools.ietf.org/html/rfc5424). - -- **DEBUG** (100): Detailed debug information. - -- **INFO** (200): Interesting events. Examples: User logs in, SQL logs. - -- **NOTICE** (250): Normal but significant events. - -- **WARNING** (300): Exceptional occurrences that are not errors. Examples: - Use of deprecated APIs, poor use of an API, undesirable things that are not - necessarily wrong. - -- **ERROR** (400): Runtime errors that do not require immediate action but - should typically be logged and monitored. - -- **CRITICAL** (500): Critical conditions. Example: Application component - unavailable, unexpected exception. - -- **ALERT** (550): Action must be taken immediately. Example: Entire website - down, database unavailable, etc. This should trigger the SMS alerts and wake - you up. - -- **EMERGENCY** (600): Emergency: system is unusable. - -## Configuring a logger - -Here is a basic setup to log to a file and to firephp on the DEBUG level: - -```php -pushHandler(new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG)); -$logger->pushHandler(new FirePHPHandler()); - -// You can now use your logger -$logger->addInfo('My logger is now ready'); -``` - -Let's explain it. The first step is to create the logger instance which will -be used in your code. The argument is a channel name, which is useful when -you use several loggers (see below for more details about it). - -The logger itself does not know how to handle a record. It delegates it to -some handlers. The code above registers two handlers in the stack to allow -handling records in two different ways. - -Note that the FirePHPHandler is called first as it is added on top of the -stack. This allows you to temporarily add a logger with bubbling disabled if -you want to override other configured loggers. - -> If you use Monolog standalone and are looking for an easy way to -> configure many handlers, the [theorchard/monolog-cascade](https://github.com/theorchard/monolog-cascade) -> can help you build complex logging configs via PHP arrays, yaml or json configs. - -## Adding extra data in the records - -Monolog provides two different ways to add extra informations along the simple -textual message. - -### Using the logging context - -The first way is the context, allowing to pass an array of data along the -record: - -```php -addInfo('Adding a new user', array('username' => 'Seldaek')); -``` - -Simple handlers (like the StreamHandler for instance) will simply format -the array to a string but richer handlers can take advantage of the context -(FirePHP is able to display arrays in pretty way for instance). - -### Using processors - -The second way is to add extra data for all records by using a processor. -Processors can be any callable. They will get the record as parameter and -must return it after having eventually changed the `extra` part of it. Let's -write a processor adding some dummy data in the record: - -```php -pushProcessor(function ($record) { - $record['extra']['dummy'] = 'Hello world!'; - - return $record; -}); -``` - -Monolog provides some built-in processors that can be used in your project. -Look at the [dedicated chapter](https://github.com/Seldaek/monolog/blob/master/doc/02-handlers-formatters-processors.md#processors) for the list. - -> Tip: processors can also be registered on a specific handler instead of - the logger to apply only for this handler. - -## Leveraging channels - -Channels are a great way to identify to which part of the application a record -is related. This is useful in big applications (and is leveraged by -MonologBundle in Symfony2). - -Picture two loggers sharing a handler that writes to a single log file. -Channels would allow you to identify the logger that issued every record. -You can easily grep through the log files filtering this or that channel. - -```php -pushHandler($stream); -$logger->pushHandler($firephp); - -// Create a logger for the security-related stuff with a different channel -$securityLogger = new Logger('security'); -$securityLogger->pushHandler($stream); -$securityLogger->pushHandler($firephp); - -// Or clone the first one to only change the channel -$securityLogger = $logger->withName('security'); -``` - -## Customizing the log format - -In Monolog it's easy to customize the format of the logs written into files, -sockets, mails, databases and other handlers. Most of the handlers use the - -```php -$record['formatted'] -``` - -value to be automatically put into the log device. This value depends on the -formatter settings. You can choose between predefined formatter classes or -write your own (e.g. a multiline text file for human-readable output). - -To configure a predefined formatter class, just set it as the handler's field: - -```php -// the default date format is "Y-m-d H:i:s" -$dateFormat = "Y n j, g:i a"; -// the default output format is "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n" -$output = "%datetime% > %level_name% > %message% %context% %extra%\n"; -// finally, create a formatter -$formatter = new LineFormatter($output, $dateFormat); - -// Create a handler -$stream = new StreamHandler(__DIR__.'/my_app.log', Logger::DEBUG); -$stream->setFormatter($formatter); -// bind it to a logger object -$securityLogger = new Logger('security'); -$securityLogger->pushHandler($stream); -``` - -You may also reuse the same formatter between multiple handlers and share those -handlers between multiple loggers. - -[Handlers, Formatters and Processors](02-handlers-formatters-processors.md) → diff --git a/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md b/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md deleted file mode 100644 index 9170d6df1..000000000 --- a/vendor/monolog/monolog/doc/02-handlers-formatters-processors.md +++ /dev/null @@ -1,155 +0,0 @@ -# Handlers, Formatters and Processors - -- [Handlers](#handlers) - - [Log to files and syslog](#log-to-files-and-syslog) - - [Send alerts and emails](#send-alerts-and-emails) - - [Log specific servers and networked logging](#log-specific-servers-and-networked-logging) - - [Logging in development](#logging-in-development) - - [Log to databases](#log-to-databases) - - [Wrappers / Special Handlers](#wrappers--special-handlers) -- [Formatters](#formatters) -- [Processors](#processors) -- [Third Party Packages](#third-party-packages) - -## Handlers - -### Log to files and syslog - -- _StreamHandler_: Logs records into any PHP stream, use this for log files. -- _RotatingFileHandler_: Logs records to a file and creates one logfile per day. - It will also delete files older than `$maxFiles`. You should use - [logrotate](http://linuxcommand.org/man_pages/logrotate8.html) for high profile - setups though, this is just meant as a quick and dirty solution. -- _SyslogHandler_: Logs records to the syslog. -- _ErrorLogHandler_: Logs records to PHP's - [`error_log()`](http://docs.php.net/manual/en/function.error-log.php) function. - -### Send alerts and emails - -- _NativeMailerHandler_: Sends emails using PHP's - [`mail()`](http://php.net/manual/en/function.mail.php) function. -- _SwiftMailerHandler_: Sends emails using a [`Swift_Mailer`](http://swiftmailer.org/) instance. -- _PushoverHandler_: Sends mobile notifications via the [Pushover](https://www.pushover.net/) API. -- _HipChatHandler_: Logs records to a [HipChat](http://hipchat.com) chat room using its API. -- _FlowdockHandler_: Logs records to a [Flowdock](https://www.flowdock.com/) account. -- _SlackHandler_: Logs records to a [Slack](https://www.slack.com/) account. -- _MandrillHandler_: Sends emails via the Mandrill API using a [`Swift_Message`](http://swiftmailer.org/) instance. -- _FleepHookHandler_: Logs records to a [Fleep](https://fleep.io/) conversation using Webhooks. -- _IFTTTHandler_: Notifies an [IFTTT](https://ifttt.com/maker) trigger with the log channel, level name and message. - -### Log specific servers and networked logging - -- _SocketHandler_: Logs records to [sockets](http://php.net/fsockopen), use this - for UNIX and TCP sockets. See an [example](sockets.md). -- _AmqpHandler_: Logs records to an [amqp](http://www.amqp.org/) compatible - server. Requires the [php-amqp](http://pecl.php.net/package/amqp) extension (1.0+). -- _GelfHandler_: Logs records to a [Graylog2](http://www.graylog2.org) server. -- _CubeHandler_: Logs records to a [Cube](http://square.github.com/cube/) server. -- _RavenHandler_: Logs records to a [Sentry](http://getsentry.com/) server using - [raven](https://packagist.org/packages/raven/raven). -- _ZendMonitorHandler_: Logs records to the Zend Monitor present in Zend Server. -- _NewRelicHandler_: Logs records to a [NewRelic](http://newrelic.com/) application. -- _LogglyHandler_: Logs records to a [Loggly](http://www.loggly.com/) account. -- _RollbarHandler_: Logs records to a [Rollbar](https://rollbar.com/) account. -- _SyslogUdpHandler_: Logs records to a remote [Syslogd](http://www.rsyslog.com/) server. -- _LogEntriesHandler_: Logs records to a [LogEntries](http://logentries.com/) account. - -### Logging in development - -- _FirePHPHandler_: Handler for [FirePHP](http://www.firephp.org/), providing - inline `console` messages within [FireBug](http://getfirebug.com/). -- _ChromePHPHandler_: Handler for [ChromePHP](http://www.chromephp.com/), providing - inline `console` messages within Chrome. -- _BrowserConsoleHandler_: Handler to send logs to browser's Javascript `console` with - no browser extension required. Most browsers supporting `console` API are supported. -- _PHPConsoleHandler_: Handler for [PHP Console](https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef), providing - inline `console` and notification popup messages within Chrome. - -### Log to databases - -- _RedisHandler_: Logs records to a [redis](http://redis.io) server. -- _MongoDBHandler_: Handler to write records in MongoDB via a - [Mongo](http://pecl.php.net/package/mongo) extension connection. -- _CouchDBHandler_: Logs records to a CouchDB server. -- _DoctrineCouchDBHandler_: Logs records to a CouchDB server via the Doctrine CouchDB ODM. -- _ElasticSearchHandler_: Logs records to an Elastic Search server. -- _DynamoDbHandler_: Logs records to a DynamoDB table with the [AWS SDK](https://github.com/aws/aws-sdk-php). - -### Wrappers / Special Handlers - -- _FingersCrossedHandler_: A very interesting wrapper. It takes a logger as - parameter and will accumulate log records of all levels until a record - exceeds the defined severity level. At which point it delivers all records, - including those of lower severity, to the handler it wraps. This means that - until an error actually happens you will not see anything in your logs, but - when it happens you will have the full information, including debug and info - records. This provides you with all the information you need, but only when - you need it. -- _DeduplicationHandler_: Useful if you are sending notifications or emails - when critical errors occur. It takes a logger as parameter and will - accumulate log records of all levels until the end of the request (or - `flush()` is called). At that point it delivers all records to the handler - it wraps, but only if the records are unique over a given time period - (60seconds by default). If the records are duplicates they are simply - discarded. The main use of this is in case of critical failure like if your - database is unreachable for example all your requests will fail and that - can result in a lot of notifications being sent. Adding this handler reduces - the amount of notifications to a manageable level. -- _WhatFailureGroupHandler_: This handler extends the _GroupHandler_ ignoring - exceptions raised by each child handler. This allows you to ignore issues - where a remote tcp connection may have died but you do not want your entire - application to crash and may wish to continue to log to other handlers. -- _BufferHandler_: This handler will buffer all the log records it receives - until `close()` is called at which point it will call `handleBatch()` on the - handler it wraps with all the log messages at once. This is very useful to - send an email with all records at once for example instead of having one mail - for every log record. -- _GroupHandler_: This handler groups other handlers. Every record received is - sent to all the handlers it is configured with. -- _FilterHandler_: This handler only lets records of the given levels through - to the wrapped handler. -- _SamplingHandler_: Wraps around another handler and lets you sample records - if you only want to store some of them. -- _NullHandler_: Any record it can handle will be thrown away. This can be used - to put on top of an existing handler stack to disable it temporarily. -- _PsrHandler_: Can be used to forward log records to an existing PSR-3 logger -- _TestHandler_: Used for testing, it records everything that is sent to it and - has accessors to read out the information. -- _HandlerWrapper_: A simple handler wrapper you can inherit from to create - your own wrappers easily. - -## Formatters - -- _LineFormatter_: Formats a log record into a one-line string. -- _HtmlFormatter_: Used to format log records into a human readable html table, mainly suitable for emails. -- _NormalizerFormatter_: Normalizes objects/resources down to strings so a record can easily be serialized/encoded. -- _ScalarFormatter_: Used to format log records into an associative array of scalar values. -- _JsonFormatter_: Encodes a log record into json. -- _WildfireFormatter_: Used to format log records into the Wildfire/FirePHP protocol, only useful for the FirePHPHandler. -- _ChromePHPFormatter_: Used to format log records into the ChromePHP format, only useful for the ChromePHPHandler. -- _GelfMessageFormatter_: Used to format log records into Gelf message instances, only useful for the GelfHandler. -- _LogstashFormatter_: Used to format log records into [logstash](http://logstash.net/) event json, useful for any handler listed under inputs [here](http://logstash.net/docs/latest). -- _ElasticaFormatter_: Used to format log records into an Elastica\Document object, only useful for the ElasticSearchHandler. -- _LogglyFormatter_: Used to format log records into Loggly messages, only useful for the LogglyHandler. -- _FlowdockFormatter_: Used to format log records into Flowdock messages, only useful for the FlowdockHandler. -- _MongoDBFormatter_: Converts \DateTime instances to \MongoDate and objects recursively to arrays, only useful with the MongoDBHandler. - -## Processors - -- _PsrLogMessageProcessor_: Processes a log record's message according to PSR-3 rules, replacing `{foo}` with the value from `$context['foo']`. -- _IntrospectionProcessor_: Adds the line/file/class/method from which the log call originated. -- _WebProcessor_: Adds the current request URI, request method and client IP to a log record. -- _MemoryUsageProcessor_: Adds the current memory usage to a log record. -- _MemoryPeakUsageProcessor_: Adds the peak memory usage to a log record. -- _ProcessIdProcessor_: Adds the process id to a log record. -- _UidProcessor_: Adds a unique identifier to a log record. -- _GitProcessor_: Adds the current git branch and commit to a log record. -- _TagProcessor_: Adds an array of predefined tags to a log record. - -## Third Party Packages - -Third party handlers, formatters and processors are -[listed in the wiki](https://github.com/Seldaek/monolog/wiki/Third-Party-Packages). You -can also add your own there if you publish one. - -← [Usage](01-usage.md) | [Utility classes](03-utilities.md) → diff --git a/vendor/monolog/monolog/doc/03-utilities.md b/vendor/monolog/monolog/doc/03-utilities.md deleted file mode 100644 index c62aa4161..000000000 --- a/vendor/monolog/monolog/doc/03-utilities.md +++ /dev/null @@ -1,13 +0,0 @@ -# Utilities - -- _Registry_: The `Monolog\Registry` class lets you configure global loggers that you - can then statically access from anywhere. It is not really a best practice but can - help in some older codebases or for ease of use. -- _ErrorHandler_: The `Monolog\ErrorHandler` class allows you to easily register - a Logger instance as an exception handler, error handler or fatal error handler. -- _ErrorLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain log - level is reached. -- _ChannelLevelActivationStrategy_: Activates a FingersCrossedHandler when a certain - log level is reached, depending on which channel received the log record. - -← [Handlers, Formatters and Processors](02-handlers-formatters-processors.md) | [Extending Monolog](04-extending.md) → diff --git a/vendor/monolog/monolog/doc/04-extending.md b/vendor/monolog/monolog/doc/04-extending.md deleted file mode 100644 index ebd9104db..000000000 --- a/vendor/monolog/monolog/doc/04-extending.md +++ /dev/null @@ -1,76 +0,0 @@ -# Extending Monolog - -Monolog is fully extensible, allowing you to adapt your logger to your needs. - -## Writing your own handler - -Monolog provides many built-in handlers. But if the one you need does not -exist, you can write it and use it in your logger. The only requirement is -to implement `Monolog\Handler\HandlerInterface`. - -Let's write a PDOHandler to log records to a database. We will extend the -abstract class provided by Monolog to keep things DRY. - -```php -pdo = $pdo; - parent::__construct($level, $bubble); - } - - protected function write(array $record) - { - if (!$this->initialized) { - $this->initialize(); - } - - $this->statement->execute(array( - 'channel' => $record['channel'], - 'level' => $record['level'], - 'message' => $record['formatted'], - 'time' => $record['datetime']->format('U'), - )); - } - - private function initialize() - { - $this->pdo->exec( - 'CREATE TABLE IF NOT EXISTS monolog ' - .'(channel VARCHAR(255), level INTEGER, message LONGTEXT, time INTEGER UNSIGNED)' - ); - $this->statement = $this->pdo->prepare( - 'INSERT INTO monolog (channel, level, message, time) VALUES (:channel, :level, :message, :time)' - ); - - $this->initialized = true; - } -} -``` - -You can now use this handler in your logger: - -```php -pushHandler(new PDOHandler(new PDO('sqlite:logs.sqlite'))); - -// You can now use your logger -$logger->addInfo('My logger is now ready'); -``` - -The `Monolog\Handler\AbstractProcessingHandler` class provides most of the -logic needed for the handler, including the use of processors and the formatting -of the record (which is why we use ``$record['formatted']`` instead of ``$record['message']``). - -← [Utility classes](03-utilities.md) diff --git a/vendor/monolog/monolog/doc/sockets.md b/vendor/monolog/monolog/doc/sockets.md deleted file mode 100644 index ea9cf0ea7..000000000 --- a/vendor/monolog/monolog/doc/sockets.md +++ /dev/null @@ -1,39 +0,0 @@ -Sockets Handler -=============== - -This handler allows you to write your logs to sockets using [fsockopen](http://php.net/fsockopen) -or [pfsockopen](http://php.net/pfsockopen). - -Persistent sockets are mainly useful in web environments where you gain some performance not closing/opening -the connections between requests. - -You can use a `unix://` prefix to access unix sockets and `udp://` to open UDP sockets instead of the default TCP. - -Basic Example -------------- - -```php -setPersistent(true); - -// Now add the handler -$logger->pushHandler($handler, Logger::DEBUG); - -// You can now use your logger -$logger->addInfo('My logger is now ready'); - -``` - -In this example, using syslog-ng, you should see the log on the log server: - - cweb1 [2012-02-26 00:12:03] my_logger.INFO: My logger is now ready [] [] - diff --git a/vendor/monolog/monolog/phpunit.xml.dist b/vendor/monolog/monolog/phpunit.xml.dist deleted file mode 100644 index 20d82b631..000000000 --- a/vendor/monolog/monolog/phpunit.xml.dist +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - tests/Monolog/ - - - - - - src/Monolog/ - - - - - - - diff --git a/vendor/monolog/monolog/src/Monolog/ErrorHandler.php b/vendor/monolog/monolog/src/Monolog/ErrorHandler.php deleted file mode 100644 index 0152298d1..000000000 --- a/vendor/monolog/monolog/src/Monolog/ErrorHandler.php +++ /dev/null @@ -1,227 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog; - -use Psr\Log\LoggerInterface; -use Psr\Log\LogLevel; -use Monolog\Handler\AbstractHandler; - -/** - * Monolog error handler - * - * A facility to enable logging of runtime errors, exceptions and fatal errors. - * - * Quick setup: ErrorHandler::register($logger); - * - * @author Jordi Boggiano - */ -class ErrorHandler -{ - private $logger; - - private $previousExceptionHandler; - private $uncaughtExceptionLevel; - - private $previousErrorHandler; - private $errorLevelMap; - private $handleOnlyReportedErrors; - - private $hasFatalErrorHandler; - private $fatalLevel; - private $reservedMemory; - private static $fatalErrors = array(E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR, E_USER_ERROR); - - public function __construct(LoggerInterface $logger) - { - $this->logger = $logger; - } - - /** - * Registers a new ErrorHandler for a given Logger - * - * By default it will handle errors, exceptions and fatal errors - * - * @param LoggerInterface $logger - * @param array|false $errorLevelMap an array of E_* constant to LogLevel::* constant mapping, or false to disable error handling - * @param int|false $exceptionLevel a LogLevel::* constant, or false to disable exception handling - * @param int|false $fatalLevel a LogLevel::* constant, or false to disable fatal error handling - * @return ErrorHandler - */ - public static function register(LoggerInterface $logger, $errorLevelMap = array(), $exceptionLevel = null, $fatalLevel = null) - { - $handler = new static($logger); - if ($errorLevelMap !== false) { - $handler->registerErrorHandler($errorLevelMap); - } - if ($exceptionLevel !== false) { - $handler->registerExceptionHandler($exceptionLevel); - } - if ($fatalLevel !== false) { - $handler->registerFatalHandler($fatalLevel); - } - - return $handler; - } - - public function registerExceptionHandler($level = null, $callPrevious = true) - { - $prev = set_exception_handler(array($this, 'handleException')); - $this->uncaughtExceptionLevel = $level; - if ($callPrevious && $prev) { - $this->previousExceptionHandler = $prev; - } - } - - public function registerErrorHandler(array $levelMap = array(), $callPrevious = true, $errorTypes = -1, $handleOnlyReportedErrors = true) - { - $prev = set_error_handler(array($this, 'handleError'), $errorTypes); - $this->errorLevelMap = array_replace($this->defaultErrorLevelMap(), $levelMap); - if ($callPrevious) { - $this->previousErrorHandler = $prev ?: true; - } - - $this->handleOnlyReportedErrors = $handleOnlyReportedErrors; - } - - public function registerFatalHandler($level = null, $reservedMemorySize = 20) - { - register_shutdown_function(array($this, 'handleFatalError')); - - $this->reservedMemory = str_repeat(' ', 1024 * $reservedMemorySize); - $this->fatalLevel = $level; - $this->hasFatalErrorHandler = true; - } - - protected function defaultErrorLevelMap() - { - return array( - E_ERROR => LogLevel::CRITICAL, - E_WARNING => LogLevel::WARNING, - E_PARSE => LogLevel::ALERT, - E_NOTICE => LogLevel::NOTICE, - E_CORE_ERROR => LogLevel::CRITICAL, - E_CORE_WARNING => LogLevel::WARNING, - E_COMPILE_ERROR => LogLevel::ALERT, - E_COMPILE_WARNING => LogLevel::WARNING, - E_USER_ERROR => LogLevel::ERROR, - E_USER_WARNING => LogLevel::WARNING, - E_USER_NOTICE => LogLevel::NOTICE, - E_STRICT => LogLevel::NOTICE, - E_RECOVERABLE_ERROR => LogLevel::ERROR, - E_DEPRECATED => LogLevel::NOTICE, - E_USER_DEPRECATED => LogLevel::NOTICE, - ); - } - - /** - * @private - */ - public function handleException($e) - { - $this->logger->log( - $this->uncaughtExceptionLevel === null ? LogLevel::ERROR : $this->uncaughtExceptionLevel, - sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), - array('exception' => $e) - ); - - if ($this->previousExceptionHandler) { - call_user_func($this->previousExceptionHandler, $e); - } - - exit(255); - } - - /** - * @private - */ - public function handleError($code, $message, $file = '', $line = 0, $context = array()) - { - if ($this->handleOnlyReportedErrors && !(error_reporting() & $code)) { - return; - } - - // fatal error codes are ignored if a fatal error handler is present as well to avoid duplicate log entries - if (!$this->hasFatalErrorHandler || !in_array($code, self::$fatalErrors, true)) { - $level = isset($this->errorLevelMap[$code]) ? $this->errorLevelMap[$code] : LogLevel::CRITICAL; - $this->logger->log($level, self::codeToString($code).': '.$message, array('code' => $code, 'message' => $message, 'file' => $file, 'line' => $line)); - } - - if ($this->previousErrorHandler === true) { - return false; - } elseif ($this->previousErrorHandler) { - return call_user_func($this->previousErrorHandler, $code, $message, $file, $line, $context); - } - } - - /** - * @private - */ - public function handleFatalError() - { - $this->reservedMemory = null; - - $lastError = error_get_last(); - if ($lastError && in_array($lastError['type'], self::$fatalErrors, true)) { - $this->logger->log( - $this->fatalLevel === null ? LogLevel::ALERT : $this->fatalLevel, - 'Fatal Error ('.self::codeToString($lastError['type']).'): '.$lastError['message'], - array('code' => $lastError['type'], 'message' => $lastError['message'], 'file' => $lastError['file'], 'line' => $lastError['line']) - ); - - if ($this->logger instanceof Logger) { - foreach ($this->logger->getHandlers() as $handler) { - if ($handler instanceof AbstractHandler) { - $handler->close(); - } - } - } - } - } - - private static function codeToString($code) - { - switch ($code) { - case E_ERROR: - return 'E_ERROR'; - case E_WARNING: - return 'E_WARNING'; - case E_PARSE: - return 'E_PARSE'; - case E_NOTICE: - return 'E_NOTICE'; - case E_CORE_ERROR: - return 'E_CORE_ERROR'; - case E_CORE_WARNING: - return 'E_CORE_WARNING'; - case E_COMPILE_ERROR: - return 'E_COMPILE_ERROR'; - case E_COMPILE_WARNING: - return 'E_COMPILE_WARNING'; - case E_USER_ERROR: - return 'E_USER_ERROR'; - case E_USER_WARNING: - return 'E_USER_WARNING'; - case E_USER_NOTICE: - return 'E_USER_NOTICE'; - case E_STRICT: - return 'E_STRICT'; - case E_RECOVERABLE_ERROR: - return 'E_RECOVERABLE_ERROR'; - case E_DEPRECATED: - return 'E_DEPRECATED'; - case E_USER_DEPRECATED: - return 'E_USER_DEPRECATED'; - } - - return 'Unknown PHP error'; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php deleted file mode 100644 index 9beda1e76..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/ChromePHPFormatter.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -/** - * Formats a log message according to the ChromePHP array format - * - * @author Christophe Coevoet - */ -class ChromePHPFormatter implements FormatterInterface -{ - /** - * Translates Monolog log levels to Wildfire levels. - */ - private $logLevels = array( - Logger::DEBUG => 'log', - Logger::INFO => 'info', - Logger::NOTICE => 'info', - Logger::WARNING => 'warn', - Logger::ERROR => 'error', - Logger::CRITICAL => 'error', - Logger::ALERT => 'error', - Logger::EMERGENCY => 'error', - ); - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - // Retrieve the line and file if set and remove them from the formatted extra - $backtrace = 'unknown'; - if (isset($record['extra']['file'], $record['extra']['line'])) { - $backtrace = $record['extra']['file'].' : '.$record['extra']['line']; - unset($record['extra']['file'], $record['extra']['line']); - } - - $message = array('message' => $record['message']); - if ($record['context']) { - $message['context'] = $record['context']; - } - if ($record['extra']) { - $message['extra'] = $record['extra']; - } - if (count($message) === 1) { - $message = reset($message); - } - - return array( - $record['channel'], - $message, - $backtrace, - $this->logLevels[$record['level']], - ); - } - - public function formatBatch(array $records) - { - $formatted = array(); - - foreach ($records as $record) { - $formatted[] = $this->format($record); - } - - return $formatted; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php deleted file mode 100644 index 4c556cf17..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/ElasticaFormatter.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Elastica\Document; - -/** - * Format a log message into an Elastica Document - * - * @author Jelle Vink - */ -class ElasticaFormatter extends NormalizerFormatter -{ - /** - * @var string Elastic search index name - */ - protected $index; - - /** - * @var string Elastic search document type - */ - protected $type; - - /** - * @param string $index Elastic Search index name - * @param string $type Elastic Search document type - */ - public function __construct($index, $type) - { - // elasticsearch requires a ISO 8601 format date with optional millisecond precision. - parent::__construct('Y-m-d\TH:i:s.uP'); - - $this->index = $index; - $this->type = $type; - } - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - $record = parent::format($record); - - return $this->getDocument($record); - } - - /** - * Getter index - * @return string - */ - public function getIndex() - { - return $this->index; - } - - /** - * Getter type - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * Convert a log message into an Elastica Document - * - * @param array $record Log message - * @return Document - */ - protected function getDocument($record) - { - $document = new Document(); - $document->setData($record); - $document->setType($this->type); - $document->setIndex($this->index); - - return $document; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php deleted file mode 100644 index 5094af3c7..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/FlowdockFormatter.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * formats the record to be used in the FlowdockHandler - * - * @author Dominik Liebler - */ -class FlowdockFormatter implements FormatterInterface -{ - /** - * @var string - */ - private $source; - - /** - * @var string - */ - private $sourceEmail; - - /** - * @param string $source - * @param string $sourceEmail - */ - public function __construct($source, $sourceEmail) - { - $this->source = $source; - $this->sourceEmail = $sourceEmail; - } - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - $tags = array( - '#logs', - '#' . strtolower($record['level_name']), - '#' . $record['channel'], - ); - - foreach ($record['extra'] as $value) { - $tags[] = '#' . $value; - } - - $subject = sprintf( - 'in %s: %s - %s', - $this->source, - $record['level_name'], - $this->getShortMessage($record['message']) - ); - - $record['flowdock'] = array( - 'source' => $this->source, - 'from_address' => $this->sourceEmail, - 'subject' => $subject, - 'content' => $record['message'], - 'tags' => $tags, - 'project' => $this->source, - ); - - return $record; - } - - /** - * {@inheritdoc} - */ - public function formatBatch(array $records) - { - $formatted = array(); - - foreach ($records as $record) { - $formatted[] = $this->format($record); - } - - return $formatted; - } - - /** - * @param string $message - * - * @return string - */ - public function getShortMessage($message) - { - static $hasMbString; - - if (null === $hasMbString) { - $hasMbString = function_exists('mb_strlen'); - } - - $maxLength = 45; - - if ($hasMbString) { - if (mb_strlen($message, 'UTF-8') > $maxLength) { - $message = mb_substr($message, 0, $maxLength - 4, 'UTF-8') . ' ...'; - } - } else { - if (strlen($message) > $maxLength) { - $message = substr($message, 0, $maxLength - 4) . ' ...'; - } - } - - return $message; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php deleted file mode 100644 index 02632bb56..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/FluentdFormatter.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * Class FluentdFormatter - * - * Serializes a log message to Fluentd unix socket protocol - * - * Fluentd config: - * - * - * type unix - * path /var/run/td-agent/td-agent.sock - * - * - * Monolog setup: - * - * $logger = new Monolog\Logger('fluent.tag'); - * $fluentHandler = new Monolog\Handler\SocketHandler('unix:///var/run/td-agent/td-agent.sock'); - * $fluentHandler->setFormatter(new Monolog\Formatter\FluentdFormatter()); - * $logger->pushHandler($fluentHandler); - * - * @author Andrius Putna - */ -class FluentdFormatter implements FormatterInterface -{ - /** - * @var bool $levelTag should message level be a part of the fluentd tag - */ - protected $levelTag = false; - - public function __construct($levelTag = false) - { - if (!function_exists('json_encode')) { - throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s FluentdUnixFormatter'); - } - - $this->levelTag = (bool) $levelTag; - } - - public function isUsingLevelsInTag() - { - return $this->levelTag; - } - - public function format(array $record) - { - $tag = $record['channel']; - if ($this->levelTag) { - $tag .= '.' . strtolower($record['level_name']); - } - - $message = array( - 'message' => $record['message'], - 'extra' => $record['extra'], - ); - - if (!$this->levelTag) { - $message['level'] = $record['level']; - $message['level_name'] = $record['level_name']; - } - - return json_encode(array($tag, $record['datetime']->getTimestamp(), $message)); - } - - public function formatBatch(array $records) - { - $message = ''; - foreach ($records as $record) { - $message .= $this->format($record); - } - - return $message; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php b/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php deleted file mode 100644 index b5de75111..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/FormatterInterface.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * Interface for formatters - * - * @author Jordi Boggiano - */ -interface FormatterInterface -{ - /** - * Formats a log record. - * - * @param array $record A record to format - * @return mixed The formatted record - */ - public function format(array $record); - - /** - * Formats a set of log records. - * - * @param array $records A set of records to format - * @return mixed The formatted set of records - */ - public function formatBatch(array $records); -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php deleted file mode 100644 index 64e766520..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/GelfMessageFormatter.php +++ /dev/null @@ -1,137 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; -use Gelf\Message; - -/** - * Serializes a log message to GELF - * @see http://www.graylog2.org/about/gelf - * - * @author Matt Lehner - */ -class GelfMessageFormatter extends NormalizerFormatter -{ - const MAX_LENGTH = 32766; - - /** - * @var string the name of the system for the Gelf log message - */ - protected $systemName; - - /** - * @var string a prefix for 'extra' fields from the Monolog record (optional) - */ - protected $extraPrefix; - - /** - * @var string a prefix for 'context' fields from the Monolog record (optional) - */ - protected $contextPrefix; - - /** - * Translates Monolog log levels to Graylog2 log priorities. - */ - private $logLevels = array( - Logger::DEBUG => 7, - Logger::INFO => 6, - Logger::NOTICE => 5, - Logger::WARNING => 4, - Logger::ERROR => 3, - Logger::CRITICAL => 2, - Logger::ALERT => 1, - Logger::EMERGENCY => 0, - ); - - public function __construct($systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_') - { - parent::__construct('U.u'); - - $this->systemName = $systemName ?: gethostname(); - - $this->extraPrefix = $extraPrefix; - $this->contextPrefix = $contextPrefix; - } - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - $record = parent::format($record); - - if (!isset($record['datetime'], $record['message'], $record['level'])) { - throw new \InvalidArgumentException('The record should at least contain datetime, message and level keys, '.var_export($record, true).' given'); - } - - $message = new Message(); - $message - ->setTimestamp($record['datetime']) - ->setShortMessage((string) $record['message']) - ->setHost($this->systemName) - ->setLevel($this->logLevels[$record['level']]); - - // start count with message length + system name length + 200 for padding / metadata - $len = 200 + strlen((string) $record['message']) + strlen($this->systemName); - - if ($len > self::MAX_LENGTH) { - $message->setShortMessage(substr($record['message'], 0, self::MAX_LENGTH - 200)); - - return $message; - } - - if (isset($record['channel'])) { - $message->setFacility($record['channel']); - $len += strlen($record['channel']); - } - if (isset($record['extra']['line'])) { - $message->setLine($record['extra']['line']); - $len += 10; - unset($record['extra']['line']); - } - if (isset($record['extra']['file'])) { - $message->setFile($record['extra']['file']); - $len += strlen($record['extra']['file']); - unset($record['extra']['file']); - } - - foreach ($record['extra'] as $key => $val) { - $val = is_scalar($val) || null === $val ? $val : $this->toJson($val); - $len += strlen($this->extraPrefix . $key . $val); - if ($len > self::MAX_LENGTH) { - $message->setAdditional($this->extraPrefix . $key, substr($val, 0, self::MAX_LENGTH - $len)); - break; - } - $message->setAdditional($this->extraPrefix . $key, $val); - } - - foreach ($record['context'] as $key => $val) { - $val = is_scalar($val) || null === $val ? $val : $this->toJson($val); - $len += strlen($this->contextPrefix . $key . $val); - if ($len > self::MAX_LENGTH) { - $message->setAdditional($this->contextPrefix . $key, substr($val, 0, self::MAX_LENGTH - $len)); - break; - } - $message->setAdditional($this->contextPrefix . $key, $val); - } - - if (null === $message->getFile() && isset($record['context']['exception']['file'])) { - if (preg_match("/^(.+):([0-9]+)$/", $record['context']['exception']['file'], $matches)) { - $message->setFile($matches[1]); - $message->setLine($matches[2]); - } - } - - return $message; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php deleted file mode 100644 index 3eec95f6c..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/HtmlFormatter.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -/** - * Formats incoming records into an HTML table - * - * This is especially useful for html email logging - * - * @author Tiago Brito - */ -class HtmlFormatter extends NormalizerFormatter -{ - /** - * Translates Monolog log levels to html color priorities. - */ - protected $logLevels = array( - Logger::DEBUG => '#cccccc', - Logger::INFO => '#468847', - Logger::NOTICE => '#3a87ad', - Logger::WARNING => '#c09853', - Logger::ERROR => '#f0ad4e', - Logger::CRITICAL => '#FF7708', - Logger::ALERT => '#C12A19', - Logger::EMERGENCY => '#000000', - ); - - /** - * @param string $dateFormat The format of the timestamp: one supported by DateTime::format - */ - public function __construct($dateFormat = null) - { - parent::__construct($dateFormat); - } - - /** - * Creates an HTML table row - * - * @param string $th Row header content - * @param string $td Row standard cell content - * @param bool $escapeTd false if td content must not be html escaped - * @return string - */ - protected function addRow($th, $td = ' ', $escapeTd = true) - { - $th = htmlspecialchars($th, ENT_NOQUOTES, 'UTF-8'); - if ($escapeTd) { - $td = '
'.htmlspecialchars($td, ENT_NOQUOTES, 'UTF-8').'
'; - } - - return "\n$th:\n".$td."\n"; - } - - /** - * Create a HTML h1 tag - * - * @param string $title Text to be in the h1 - * @param int $level Error level - * @return string - */ - protected function addTitle($title, $level) - { - $title = htmlspecialchars($title, ENT_NOQUOTES, 'UTF-8'); - - return '

'.$title.'

'; - } - - /** - * Formats a log record. - * - * @param array $record A record to format - * @return mixed The formatted record - */ - public function format(array $record) - { - $output = $this->addTitle($record['level_name'], $record['level']); - $output .= ''; - - $output .= $this->addRow('Message', (string) $record['message']); - $output .= $this->addRow('Time', $record['datetime']->format($this->dateFormat)); - $output .= $this->addRow('Channel', $record['channel']); - if ($record['context']) { - $embeddedTable = '
'; - foreach ($record['context'] as $key => $value) { - $embeddedTable .= $this->addRow($key, $this->convertToString($value)); - } - $embeddedTable .= '
'; - $output .= $this->addRow('Context', $embeddedTable, false); - } - if ($record['extra']) { - $embeddedTable = ''; - foreach ($record['extra'] as $key => $value) { - $embeddedTable .= $this->addRow($key, $this->convertToString($value)); - } - $embeddedTable .= '
'; - $output .= $this->addRow('Extra', $embeddedTable, false); - } - - return $output.''; - } - - /** - * Formats a set of log records. - * - * @param array $records A set of records to format - * @return mixed The formatted set of records - */ - public function formatBatch(array $records) - { - $message = ''; - foreach ($records as $record) { - $message .= $this->format($record); - } - - return $message; - } - - protected function convertToString($data) - { - if (null === $data || is_scalar($data)) { - return (string) $data; - } - - $data = $this->normalize($data); - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { - return json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); - } - - return str_replace('\\/', '/', json_encode($data)); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php deleted file mode 100644 index a985e2abd..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/JsonFormatter.php +++ /dev/null @@ -1,205 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Exception; - -/** - * Encodes whatever record data is passed to it as json - * - * This can be useful to log to databases or remote APIs - * - * @author Jordi Boggiano - */ -class JsonFormatter extends NormalizerFormatter -{ - const BATCH_MODE_JSON = 1; - const BATCH_MODE_NEWLINES = 2; - - protected $batchMode; - protected $appendNewline; - /** - * @var bool - */ - protected $includeStacktraces = false; - - /** - * @param int $batchMode - */ - public function __construct($batchMode = self::BATCH_MODE_JSON, $appendNewline = true) - { - $this->batchMode = $batchMode; - $this->appendNewline = $appendNewline; - } - - /** - * The batch mode option configures the formatting style for - * multiple records. By default, multiple records will be - * formatted as a JSON-encoded array. However, for - * compatibility with some API endpoints, alternative styles - * are available. - * - * @return int - */ - public function getBatchMode() - { - return $this->batchMode; - } - - /** - * True if newlines are appended to every formatted record - * - * @return bool - */ - public function isAppendingNewlines() - { - return $this->appendNewline; - } - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - return $this->toJson($this->normalize($record), true) . ($this->appendNewline ? "\n" : ''); - } - - /** - * {@inheritdoc} - */ - public function formatBatch(array $records) - { - switch ($this->batchMode) { - case static::BATCH_MODE_NEWLINES: - return $this->formatBatchNewlines($records); - - case static::BATCH_MODE_JSON: - default: - return $this->formatBatchJson($records); - } - } - - /** - * @param bool $include - */ - public function includeStacktraces($include = true) - { - $this->includeStacktraces = $include; - } - - /** - * Return a JSON-encoded array of records. - * - * @param array $records - * @return string - */ - protected function formatBatchJson(array $records) - { - return $this->toJson($this->normalize($records), true); - } - - /** - * Use new lines to separate records instead of a - * JSON-encoded array. - * - * @param array $records - * @return string - */ - protected function formatBatchNewlines(array $records) - { - $instance = $this; - - $oldNewline = $this->appendNewline; - $this->appendNewline = false; - array_walk($records, function (&$value, $key) use ($instance) { - $value = $instance->format($value); - }); - $this->appendNewline = $oldNewline; - - return implode("\n", $records); - } - - /** - * Normalizes given $data. - * - * @param mixed $data - * - * @return mixed - */ - protected function normalize($data) - { - if (is_array($data) || $data instanceof \Traversable) { - $normalized = array(); - - $count = 1; - foreach ($data as $key => $value) { - if ($count++ >= 1000) { - $normalized['...'] = 'Over 1000 items, aborting normalization'; - break; - } - $normalized[$key] = $this->normalize($value); - } - - return $normalized; - } - - if ($data instanceof Exception) { - return $this->normalizeException($data); - } - - return $data; - } - - /** - * Normalizes given exception with or without its own stack trace based on - * `includeStacktraces` property. - * - * @param Exception|Throwable $e - * - * @return array - */ - protected function normalizeException($e) - { - // TODO 2.0 only check for Throwable - if (!$e instanceof Exception && !$e instanceof \Throwable) { - throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.get_class($e)); - } - - $data = array( - 'class' => get_class($e), - 'message' => $e->getMessage(), - 'code' => $e->getCode(), - 'file' => $e->getFile().':'.$e->getLine(), - ); - - if ($this->includeStacktraces) { - $trace = $e->getTrace(); - foreach ($trace as $frame) { - if (isset($frame['file'])) { - $data['trace'][] = $frame['file'].':'.$frame['line']; - } elseif (isset($frame['function']) && $frame['function'] === '{closure}') { - // We should again normalize the frames, because it might contain invalid items - $data['trace'][] = $frame['function']; - } else { - // We should again normalize the frames, because it might contain invalid items - $data['trace'][] = $this->normalize($frame); - } - } - } - - if ($previous = $e->getPrevious()) { - $data['previous'] = $this->normalizeException($previous); - } - - return $data; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php deleted file mode 100644 index 0e62aa356..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/LineFormatter.php +++ /dev/null @@ -1,169 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * Formats incoming records into a one-line string - * - * This is especially useful for logging to files - * - * @author Jordi Boggiano - * @author Christophe Coevoet - */ -class LineFormatter extends NormalizerFormatter -{ - const SIMPLE_FORMAT = "[%datetime%] %channel%.%level_name%: %message% %context% %extra%\n"; - - protected $format; - protected $allowInlineLineBreaks; - protected $ignoreEmptyContextAndExtra; - protected $includeStacktraces; - - /** - * @param string $format The format of the message - * @param string $dateFormat The format of the timestamp: one supported by DateTime::format - * @param bool $allowInlineLineBreaks Whether to allow inline line breaks in log entries - * @param bool $ignoreEmptyContextAndExtra - */ - public function __construct($format = null, $dateFormat = null, $allowInlineLineBreaks = false, $ignoreEmptyContextAndExtra = false) - { - $this->format = $format ?: static::SIMPLE_FORMAT; - $this->allowInlineLineBreaks = $allowInlineLineBreaks; - $this->ignoreEmptyContextAndExtra = $ignoreEmptyContextAndExtra; - parent::__construct($dateFormat); - } - - public function includeStacktraces($include = true) - { - $this->includeStacktraces = $include; - if ($this->includeStacktraces) { - $this->allowInlineLineBreaks = true; - } - } - - public function allowInlineLineBreaks($allow = true) - { - $this->allowInlineLineBreaks = $allow; - } - - public function ignoreEmptyContextAndExtra($ignore = true) - { - $this->ignoreEmptyContextAndExtra = $ignore; - } - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - $vars = parent::format($record); - - $output = $this->format; - - foreach ($vars['extra'] as $var => $val) { - if (false !== strpos($output, '%extra.'.$var.'%')) { - $output = str_replace('%extra.'.$var.'%', $this->stringify($val), $output); - unset($vars['extra'][$var]); - } - } - - foreach ($vars['context'] as $var => $val) { - if (false !== strpos($output, '%context.'.$var.'%')) { - $output = str_replace('%context.'.$var.'%', $this->stringify($val), $output); - unset($vars['context'][$var]); - } - } - - if ($this->ignoreEmptyContextAndExtra) { - if (empty($vars['context'])) { - unset($vars['context']); - $output = str_replace('%context%', '', $output); - } - - if (empty($vars['extra'])) { - unset($vars['extra']); - $output = str_replace('%extra%', '', $output); - } - } - - foreach ($vars as $var => $val) { - if (false !== strpos($output, '%'.$var.'%')) { - $output = str_replace('%'.$var.'%', $this->stringify($val), $output); - } - } - - return $output; - } - - public function formatBatch(array $records) - { - $message = ''; - foreach ($records as $record) { - $message .= $this->format($record); - } - - return $message; - } - - public function stringify($value) - { - return $this->replaceNewlines($this->convertToString($value)); - } - - protected function normalizeException($e) - { - // TODO 2.0 only check for Throwable - if (!$e instanceof \Exception && !$e instanceof \Throwable) { - throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.get_class($e)); - } - - $previousText = ''; - if ($previous = $e->getPrevious()) { - do { - $previousText .= ', '.get_class($previous).'(code: '.$previous->getCode().'): '.$previous->getMessage().' at '.$previous->getFile().':'.$previous->getLine(); - } while ($previous = $previous->getPrevious()); - } - - $str = '[object] ('.get_class($e).'(code: '.$e->getCode().'): '.$e->getMessage().' at '.$e->getFile().':'.$e->getLine().$previousText.')'; - if ($this->includeStacktraces) { - $str .= "\n[stacktrace]\n".$e->getTraceAsString(); - } - - return $str; - } - - protected function convertToString($data) - { - if (null === $data || is_bool($data)) { - return var_export($data, true); - } - - if (is_scalar($data)) { - return (string) $data; - } - - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { - return $this->toJson($data, true); - } - - return str_replace('\\/', '/', @json_encode($data)); - } - - protected function replaceNewlines($str) - { - if ($this->allowInlineLineBreaks) { - return $str; - } - - return str_replace(array("\r\n", "\r", "\n"), ' ', $str); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php deleted file mode 100644 index 401859bba..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/LogglyFormatter.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * Encodes message information into JSON in a format compatible with Loggly. - * - * @author Adam Pancutt - */ -class LogglyFormatter extends JsonFormatter -{ - /** - * Overrides the default batch mode to new lines for compatibility with the - * Loggly bulk API. - * - * @param int $batchMode - */ - public function __construct($batchMode = self::BATCH_MODE_NEWLINES, $appendNewline = false) - { - parent::__construct($batchMode, $appendNewline); - } - - /** - * Appends the 'timestamp' parameter for indexing by Loggly. - * - * @see https://www.loggly.com/docs/automated-parsing/#json - * @see \Monolog\Formatter\JsonFormatter::format() - */ - public function format(array $record) - { - if (isset($record["datetime"]) && ($record["datetime"] instanceof \DateTime)) { - $record["timestamp"] = $record["datetime"]->format("Y-m-d\TH:i:s.uO"); - // TODO 2.0 unset the 'datetime' parameter, retained for BC - } - - return parent::format($record); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php deleted file mode 100644 index 8f83bec04..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/LogstashFormatter.php +++ /dev/null @@ -1,166 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * Serializes a log message to Logstash Event Format - * - * @see http://logstash.net/ - * @see https://github.com/logstash/logstash/blob/master/lib/logstash/event.rb - * - * @author Tim Mower - */ -class LogstashFormatter extends NormalizerFormatter -{ - const V0 = 0; - const V1 = 1; - - /** - * @var string the name of the system for the Logstash log message, used to fill the @source field - */ - protected $systemName; - - /** - * @var string an application name for the Logstash log message, used to fill the @type field - */ - protected $applicationName; - - /** - * @var string a prefix for 'extra' fields from the Monolog record (optional) - */ - protected $extraPrefix; - - /** - * @var string a prefix for 'context' fields from the Monolog record (optional) - */ - protected $contextPrefix; - - /** - * @var int logstash format version to use - */ - protected $version; - - /** - * @param string $applicationName the application that sends the data, used as the "type" field of logstash - * @param string $systemName the system/machine name, used as the "source" field of logstash, defaults to the hostname of the machine - * @param string $extraPrefix prefix for extra keys inside logstash "fields" - * @param string $contextPrefix prefix for context keys inside logstash "fields", defaults to ctxt_ - * @param int $version the logstash format version to use, defaults to 0 - */ - public function __construct($applicationName, $systemName = null, $extraPrefix = null, $contextPrefix = 'ctxt_', $version = self::V0) - { - // logstash requires a ISO 8601 format date with optional millisecond precision. - parent::__construct('Y-m-d\TH:i:s.uP'); - - $this->systemName = $systemName ?: gethostname(); - $this->applicationName = $applicationName; - $this->extraPrefix = $extraPrefix; - $this->contextPrefix = $contextPrefix; - $this->version = $version; - } - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - $record = parent::format($record); - - if ($this->version === self::V1) { - $message = $this->formatV1($record); - } else { - $message = $this->formatV0($record); - } - - return $this->toJson($message) . "\n"; - } - - protected function formatV0(array $record) - { - if (empty($record['datetime'])) { - $record['datetime'] = gmdate('c'); - } - $message = array( - '@timestamp' => $record['datetime'], - '@source' => $this->systemName, - '@fields' => array(), - ); - if (isset($record['message'])) { - $message['@message'] = $record['message']; - } - if (isset($record['channel'])) { - $message['@tags'] = array($record['channel']); - $message['@fields']['channel'] = $record['channel']; - } - if (isset($record['level'])) { - $message['@fields']['level'] = $record['level']; - } - if ($this->applicationName) { - $message['@type'] = $this->applicationName; - } - if (isset($record['extra']['server'])) { - $message['@source_host'] = $record['extra']['server']; - } - if (isset($record['extra']['url'])) { - $message['@source_path'] = $record['extra']['url']; - } - if (!empty($record['extra'])) { - foreach ($record['extra'] as $key => $val) { - $message['@fields'][$this->extraPrefix . $key] = $val; - } - } - if (!empty($record['context'])) { - foreach ($record['context'] as $key => $val) { - $message['@fields'][$this->contextPrefix . $key] = $val; - } - } - - return $message; - } - - protected function formatV1(array $record) - { - if (empty($record['datetime'])) { - $record['datetime'] = gmdate('c'); - } - $message = array( - '@timestamp' => $record['datetime'], - '@version' => 1, - 'host' => $this->systemName, - ); - if (isset($record['message'])) { - $message['message'] = $record['message']; - } - if (isset($record['channel'])) { - $message['type'] = $record['channel']; - $message['channel'] = $record['channel']; - } - if (isset($record['level_name'])) { - $message['level'] = $record['level_name']; - } - if ($this->applicationName) { - $message['type'] = $this->applicationName; - } - if (!empty($record['extra'])) { - foreach ($record['extra'] as $key => $val) { - $message[$this->extraPrefix . $key] = $val; - } - } - if (!empty($record['context'])) { - foreach ($record['context'] as $key => $val) { - $message[$this->contextPrefix . $key] = $val; - } - } - - return $message; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php deleted file mode 100644 index eb067bb72..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/MongoDBFormatter.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * Formats a record for use with the MongoDBHandler. - * - * @author Florian Plattner - */ -class MongoDBFormatter implements FormatterInterface -{ - private $exceptionTraceAsString; - private $maxNestingLevel; - - /** - * @param int $maxNestingLevel 0 means infinite nesting, the $record itself is level 1, $record['context'] is 2 - * @param bool $exceptionTraceAsString set to false to log exception traces as a sub documents instead of strings - */ - public function __construct($maxNestingLevel = 3, $exceptionTraceAsString = true) - { - $this->maxNestingLevel = max($maxNestingLevel, 0); - $this->exceptionTraceAsString = (bool) $exceptionTraceAsString; - } - - /** - * {@inheritDoc} - */ - public function format(array $record) - { - return $this->formatArray($record); - } - - /** - * {@inheritDoc} - */ - public function formatBatch(array $records) - { - foreach ($records as $key => $record) { - $records[$key] = $this->format($record); - } - - return $records; - } - - protected function formatArray(array $record, $nestingLevel = 0) - { - if ($this->maxNestingLevel == 0 || $nestingLevel <= $this->maxNestingLevel) { - foreach ($record as $name => $value) { - if ($value instanceof \DateTime) { - $record[$name] = $this->formatDate($value, $nestingLevel + 1); - } elseif ($value instanceof \Exception) { - $record[$name] = $this->formatException($value, $nestingLevel + 1); - } elseif (is_array($value)) { - $record[$name] = $this->formatArray($value, $nestingLevel + 1); - } elseif (is_object($value)) { - $record[$name] = $this->formatObject($value, $nestingLevel + 1); - } - } - } else { - $record = '[...]'; - } - - return $record; - } - - protected function formatObject($value, $nestingLevel) - { - $objectVars = get_object_vars($value); - $objectVars['class'] = get_class($value); - - return $this->formatArray($objectVars, $nestingLevel); - } - - protected function formatException(\Exception $exception, $nestingLevel) - { - $formattedException = array( - 'class' => get_class($exception), - 'message' => $exception->getMessage(), - 'code' => $exception->getCode(), - 'file' => $exception->getFile() . ':' . $exception->getLine(), - ); - - if ($this->exceptionTraceAsString === true) { - $formattedException['trace'] = $exception->getTraceAsString(); - } else { - $formattedException['trace'] = $exception->getTrace(); - } - - return $this->formatArray($formattedException, $nestingLevel); - } - - protected function formatDate(\DateTime $value, $nestingLevel) - { - return new \MongoDate($value->getTimestamp()); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php deleted file mode 100644 index ab79dbcd5..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/NormalizerFormatter.php +++ /dev/null @@ -1,297 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Exception; - -/** - * Normalizes incoming records to remove objects/resources so it's easier to dump to various targets - * - * @author Jordi Boggiano - */ -class NormalizerFormatter implements FormatterInterface -{ - const SIMPLE_DATE = "Y-m-d H:i:s"; - - protected $dateFormat; - - /** - * @param string $dateFormat The format of the timestamp: one supported by DateTime::format - */ - public function __construct($dateFormat = null) - { - $this->dateFormat = $dateFormat ?: static::SIMPLE_DATE; - if (!function_exists('json_encode')) { - throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s NormalizerFormatter'); - } - } - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - return $this->normalize($record); - } - - /** - * {@inheritdoc} - */ - public function formatBatch(array $records) - { - foreach ($records as $key => $record) { - $records[$key] = $this->format($record); - } - - return $records; - } - - protected function normalize($data) - { - if (null === $data || is_scalar($data)) { - if (is_float($data)) { - if (is_infinite($data)) { - return ($data > 0 ? '' : '-') . 'INF'; - } - if (is_nan($data)) { - return 'NaN'; - } - } - - return $data; - } - - if (is_array($data) || $data instanceof \Traversable) { - $normalized = array(); - - $count = 1; - foreach ($data as $key => $value) { - if ($count++ >= 1000) { - $normalized['...'] = 'Over 1000 items, aborting normalization'; - break; - } - $normalized[$key] = $this->normalize($value); - } - - return $normalized; - } - - if ($data instanceof \DateTime) { - return $data->format($this->dateFormat); - } - - if (is_object($data)) { - // TODO 2.0 only check for Throwable - if ($data instanceof Exception || (PHP_VERSION_ID > 70000 && $data instanceof \Throwable)) { - return $this->normalizeException($data); - } - - // non-serializable objects that implement __toString stringified - if (method_exists($data, '__toString') && !$data instanceof \JsonSerializable) { - $value = $data->__toString(); - } else { - // the rest is json-serialized in some way - $value = $this->toJson($data, true); - } - - return sprintf("[object] (%s: %s)", get_class($data), $value); - } - - if (is_resource($data)) { - return sprintf('[resource] (%s)', get_resource_type($data)); - } - - return '[unknown('.gettype($data).')]'; - } - - protected function normalizeException($e) - { - // TODO 2.0 only check for Throwable - if (!$e instanceof Exception && !$e instanceof \Throwable) { - throw new \InvalidArgumentException('Exception/Throwable expected, got '.gettype($e).' / '.get_class($e)); - } - - $data = array( - 'class' => get_class($e), - 'message' => $e->getMessage(), - 'code' => $e->getCode(), - 'file' => $e->getFile().':'.$e->getLine(), - ); - - if ($e instanceof \SoapFault) { - if (isset($e->faultcode)) { - $data['faultcode'] = $e->faultcode; - } - - if (isset($e->faultactor)) { - $data['faultactor'] = $e->faultactor; - } - - if (isset($e->detail)) { - $data['detail'] = $e->detail; - } - } - - $trace = $e->getTrace(); - foreach ($trace as $frame) { - if (isset($frame['file'])) { - $data['trace'][] = $frame['file'].':'.$frame['line']; - } elseif (isset($frame['function']) && $frame['function'] === '{closure}') { - // We should again normalize the frames, because it might contain invalid items - $data['trace'][] = $frame['function']; - } else { - // We should again normalize the frames, because it might contain invalid items - $data['trace'][] = $this->toJson($this->normalize($frame), true); - } - } - - if ($previous = $e->getPrevious()) { - $data['previous'] = $this->normalizeException($previous); - } - - return $data; - } - - /** - * Return the JSON representation of a value - * - * @param mixed $data - * @param bool $ignoreErrors - * @throws \RuntimeException if encoding fails and errors are not ignored - * @return string - */ - protected function toJson($data, $ignoreErrors = false) - { - // suppress json_encode errors since it's twitchy with some inputs - if ($ignoreErrors) { - return @$this->jsonEncode($data); - } - - $json = $this->jsonEncode($data); - - if ($json === false) { - $json = $this->handleJsonError(json_last_error(), $data); - } - - return $json; - } - - /** - * @param mixed $data - * @return string JSON encoded data or null on failure - */ - private function jsonEncode($data) - { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { - return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); - } - - return json_encode($data); - } - - /** - * Handle a json_encode failure. - * - * If the failure is due to invalid string encoding, try to clean the - * input and encode again. If the second encoding attempt fails, the - * inital error is not encoding related or the input can't be cleaned then - * raise a descriptive exception. - * - * @param int $code return code of json_last_error function - * @param mixed $data data that was meant to be encoded - * @throws \RuntimeException if failure can't be corrected - * @return string JSON encoded data after error correction - */ - private function handleJsonError($code, $data) - { - if ($code !== JSON_ERROR_UTF8) { - $this->throwEncodeError($code, $data); - } - - if (is_string($data)) { - $this->detectAndCleanUtf8($data); - } elseif (is_array($data)) { - array_walk_recursive($data, array($this, 'detectAndCleanUtf8')); - } else { - $this->throwEncodeError($code, $data); - } - - $json = $this->jsonEncode($data); - - if ($json === false) { - $this->throwEncodeError(json_last_error(), $data); - } - - return $json; - } - - /** - * Throws an exception according to a given code with a customized message - * - * @param int $code return code of json_last_error function - * @param mixed $data data that was meant to be encoded - * @throws \RuntimeException - */ - private function throwEncodeError($code, $data) - { - switch ($code) { - case JSON_ERROR_DEPTH: - $msg = 'Maximum stack depth exceeded'; - break; - case JSON_ERROR_STATE_MISMATCH: - $msg = 'Underflow or the modes mismatch'; - break; - case JSON_ERROR_CTRL_CHAR: - $msg = 'Unexpected control character found'; - break; - case JSON_ERROR_UTF8: - $msg = 'Malformed UTF-8 characters, possibly incorrectly encoded'; - break; - default: - $msg = 'Unknown error'; - } - - throw new \RuntimeException('JSON encoding failed: '.$msg.'. Encoding: '.var_export($data, true)); - } - - /** - * Detect invalid UTF-8 string characters and convert to valid UTF-8. - * - * Valid UTF-8 input will be left unmodified, but strings containing - * invalid UTF-8 codepoints will be reencoded as UTF-8 with an assumed - * original encoding of ISO-8859-15. This conversion may result in - * incorrect output if the actual encoding was not ISO-8859-15, but it - * will be clean UTF-8 output and will not rely on expensive and fragile - * detection algorithms. - * - * Function converts the input in place in the passed variable so that it - * can be used as a callback for array_walk_recursive. - * - * @param mixed &$data Input to check and convert if needed - * @private - */ - public function detectAndCleanUtf8(&$data) - { - if (is_string($data) && !preg_match('//u', $data)) { - $data = preg_replace_callback( - '/[\x80-\xFF]+/', - function ($m) { return utf8_encode($m[0]); }, - $data - ); - $data = str_replace( - array('¤', '¦', '¨', '´', '¸', '¼', '½', '¾'), - array('€', 'Š', 'š', 'Ž', 'ž', 'Œ', 'œ', 'Ÿ'), - $data - ); - } - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php deleted file mode 100644 index 5d345d53c..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/ScalarFormatter.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * Formats data into an associative array of scalar values. - * Objects and arrays will be JSON encoded. - * - * @author Andrew Lawson - */ -class ScalarFormatter extends NormalizerFormatter -{ - /** - * {@inheritdoc} - */ - public function format(array $record) - { - foreach ($record as $key => $value) { - $record[$key] = $this->normalizeValue($value); - } - - return $record; - } - - /** - * @param mixed $value - * @return mixed - */ - protected function normalizeValue($value) - { - $normalized = $this->normalize($value); - - if (is_array($normalized) || is_object($normalized)) { - return $this->toJson($normalized, true); - } - - return $normalized; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php b/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php deleted file mode 100644 index 654710a8d..000000000 --- a/vendor/monolog/monolog/src/Monolog/Formatter/WildfireFormatter.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -/** - * Serializes a log message according to Wildfire's header requirements - * - * @author Eric Clemmons (@ericclemmons) - * @author Christophe Coevoet - * @author Kirill chEbba Chebunin - */ -class WildfireFormatter extends NormalizerFormatter -{ - const TABLE = 'table'; - - /** - * Translates Monolog log levels to Wildfire levels. - */ - private $logLevels = array( - Logger::DEBUG => 'LOG', - Logger::INFO => 'INFO', - Logger::NOTICE => 'INFO', - Logger::WARNING => 'WARN', - Logger::ERROR => 'ERROR', - Logger::CRITICAL => 'ERROR', - Logger::ALERT => 'ERROR', - Logger::EMERGENCY => 'ERROR', - ); - - /** - * {@inheritdoc} - */ - public function format(array $record) - { - // Retrieve the line and file if set and remove them from the formatted extra - $file = $line = ''; - if (isset($record['extra']['file'])) { - $file = $record['extra']['file']; - unset($record['extra']['file']); - } - if (isset($record['extra']['line'])) { - $line = $record['extra']['line']; - unset($record['extra']['line']); - } - - $record = $this->normalize($record); - $message = array('message' => $record['message']); - $handleError = false; - if ($record['context']) { - $message['context'] = $record['context']; - $handleError = true; - } - if ($record['extra']) { - $message['extra'] = $record['extra']; - $handleError = true; - } - if (count($message) === 1) { - $message = reset($message); - } - - if (isset($record['context'][self::TABLE])) { - $type = 'TABLE'; - $label = $record['channel'] .': '. $record['message']; - $message = $record['context'][self::TABLE]; - } else { - $type = $this->logLevels[$record['level']]; - $label = $record['channel']; - } - - // Create JSON object describing the appearance of the message in the console - $json = $this->toJson(array( - array( - 'Type' => $type, - 'File' => $file, - 'Line' => $line, - 'Label' => $label, - ), - $message, - ), $handleError); - - // The message itself is a serialization of the above JSON object + it's length - return sprintf( - '%s|%s|', - strlen($json), - $json - ); - } - - public function formatBatch(array $records) - { - throw new \BadMethodCallException('Batch formatting does not make sense for the WildfireFormatter'); - } - - protected function normalize($data) - { - if (is_object($data) && !$data instanceof \DateTime) { - return $data; - } - - return parent::normalize($data); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php deleted file mode 100644 index 758a425c3..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/AbstractHandler.php +++ /dev/null @@ -1,186 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\FormatterInterface; -use Monolog\Formatter\LineFormatter; - -/** - * Base Handler class providing the Handler structure - * - * @author Jordi Boggiano - */ -abstract class AbstractHandler implements HandlerInterface -{ - protected $level = Logger::DEBUG; - protected $bubble = true; - - /** - * @var FormatterInterface - */ - protected $formatter; - protected $processors = array(); - - /** - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($level = Logger::DEBUG, $bubble = true) - { - $this->setLevel($level); - $this->bubble = $bubble; - } - - /** - * {@inheritdoc} - */ - public function isHandling(array $record) - { - return $record['level'] >= $this->level; - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - foreach ($records as $record) { - $this->handle($record); - } - } - - /** - * Closes the handler. - * - * This will be called automatically when the object is destroyed - */ - public function close() - { - } - - /** - * {@inheritdoc} - */ - public function pushProcessor($callback) - { - if (!is_callable($callback)) { - throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given'); - } - array_unshift($this->processors, $callback); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function popProcessor() - { - if (!$this->processors) { - throw new \LogicException('You tried to pop from an empty processor stack.'); - } - - return array_shift($this->processors); - } - - /** - * {@inheritdoc} - */ - public function setFormatter(FormatterInterface $formatter) - { - $this->formatter = $formatter; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getFormatter() - { - if (!$this->formatter) { - $this->formatter = $this->getDefaultFormatter(); - } - - return $this->formatter; - } - - /** - * Sets minimum logging level at which this handler will be triggered. - * - * @param int|string $level Level or level name - * @return self - */ - public function setLevel($level) - { - $this->level = Logger::toMonologLevel($level); - - return $this; - } - - /** - * Gets minimum logging level at which this handler will be triggered. - * - * @return int - */ - public function getLevel() - { - return $this->level; - } - - /** - * Sets the bubbling behavior. - * - * @param Boolean $bubble true means that this handler allows bubbling. - * false means that bubbling is not permitted. - * @return self - */ - public function setBubble($bubble) - { - $this->bubble = $bubble; - - return $this; - } - - /** - * Gets the bubbling behavior. - * - * @return Boolean true means that this handler allows bubbling. - * false means that bubbling is not permitted. - */ - public function getBubble() - { - return $this->bubble; - } - - public function __destruct() - { - try { - $this->close(); - } catch (\Exception $e) { - // do nothing - } catch (\Throwable $e) { - // do nothing - } - } - - /** - * Gets the default formatter. - * - * @return FormatterInterface - */ - protected function getDefaultFormatter() - { - return new LineFormatter(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php deleted file mode 100644 index 6f18f72e1..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -/** - * Base Handler class providing the Handler structure - * - * Classes extending it should (in most cases) only implement write($record) - * - * @author Jordi Boggiano - * @author Christophe Coevoet - */ -abstract class AbstractProcessingHandler extends AbstractHandler -{ - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - if (!$this->isHandling($record)) { - return false; - } - - $record = $this->processRecord($record); - - $record['formatted'] = $this->getFormatter()->format($record); - - $this->write($record); - - return false === $this->bubble; - } - - /** - * Writes the record down to the log of the implementing handler - * - * @param array $record - * @return void - */ - abstract protected function write(array $record); - - /** - * Processes a record. - * - * @param array $record - * @return array - */ - protected function processRecord(array $record) - { - if ($this->processors) { - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); - } - } - - return $record; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php deleted file mode 100644 index e2b2832d0..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/AbstractSyslogHandler.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; - -/** - * Common syslog functionality - */ -abstract class AbstractSyslogHandler extends AbstractProcessingHandler -{ - protected $facility; - - /** - * Translates Monolog log levels to syslog log priorities. - */ - protected $logLevels = array( - Logger::DEBUG => LOG_DEBUG, - Logger::INFO => LOG_INFO, - Logger::NOTICE => LOG_NOTICE, - Logger::WARNING => LOG_WARNING, - Logger::ERROR => LOG_ERR, - Logger::CRITICAL => LOG_CRIT, - Logger::ALERT => LOG_ALERT, - Logger::EMERGENCY => LOG_EMERG, - ); - - /** - * List of valid log facility names. - */ - protected $facilities = array( - 'auth' => LOG_AUTH, - 'authpriv' => LOG_AUTHPRIV, - 'cron' => LOG_CRON, - 'daemon' => LOG_DAEMON, - 'kern' => LOG_KERN, - 'lpr' => LOG_LPR, - 'mail' => LOG_MAIL, - 'news' => LOG_NEWS, - 'syslog' => LOG_SYSLOG, - 'user' => LOG_USER, - 'uucp' => LOG_UUCP, - ); - - /** - * @param mixed $facility - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($facility = LOG_USER, $level = Logger::DEBUG, $bubble = true) - { - parent::__construct($level, $bubble); - - if (!defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->facilities['local0'] = LOG_LOCAL0; - $this->facilities['local1'] = LOG_LOCAL1; - $this->facilities['local2'] = LOG_LOCAL2; - $this->facilities['local3'] = LOG_LOCAL3; - $this->facilities['local4'] = LOG_LOCAL4; - $this->facilities['local5'] = LOG_LOCAL5; - $this->facilities['local6'] = LOG_LOCAL6; - $this->facilities['local7'] = LOG_LOCAL7; - } else { - $this->facilities['local0'] = 128; // LOG_LOCAL0 - $this->facilities['local1'] = 136; // LOG_LOCAL1 - $this->facilities['local2'] = 144; // LOG_LOCAL2 - $this->facilities['local3'] = 152; // LOG_LOCAL3 - $this->facilities['local4'] = 160; // LOG_LOCAL4 - $this->facilities['local5'] = 168; // LOG_LOCAL5 - $this->facilities['local6'] = 176; // LOG_LOCAL6 - $this->facilities['local7'] = 184; // LOG_LOCAL7 - } - - // convert textual description of facility to syslog constant - if (array_key_exists(strtolower($facility), $this->facilities)) { - $facility = $this->facilities[strtolower($facility)]; - } elseif (!in_array($facility, array_values($this->facilities), true)) { - throw new \UnexpectedValueException('Unknown facility value "'.$facility.'" given'); - } - - $this->facility = $facility; - } - - /** - * {@inheritdoc} - */ - protected function getDefaultFormatter() - { - return new LineFormatter('%channel%.%level_name%: %message% %context% %extra%'); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php deleted file mode 100644 index 95a91fcd9..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/AmqpHandler.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\JsonFormatter; -use PhpAmqpLib\Message\AMQPMessage; -use PhpAmqpLib\Channel\AMQPChannel; -use AMQPExchange; - -class AmqpHandler extends AbstractProcessingHandler -{ - /** - * @var AMQPExchange|AMQPChannel $exchange - */ - protected $exchange; - - /** - * @var string - */ - protected $exchangeName; - - /** - * @param AMQPExchange|AMQPChannel $exchange AMQPExchange (php AMQP ext) or PHP AMQP lib channel, ready for use - * @param string $exchangeName - * @param int $level - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($exchange, $exchangeName = 'log', $level = Logger::DEBUG, $bubble = true) - { - if ($exchange instanceof AMQPExchange) { - $exchange->setName($exchangeName); - } elseif ($exchange instanceof AMQPChannel) { - $this->exchangeName = $exchangeName; - } else { - throw new \InvalidArgumentException('PhpAmqpLib\Channel\AMQPChannel or AMQPExchange instance required'); - } - $this->exchange = $exchange; - - parent::__construct($level, $bubble); - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) - { - $data = $record["formatted"]; - $routingKey = $this->getRoutingKey($record); - - if ($this->exchange instanceof AMQPExchange) { - $this->exchange->publish( - $data, - $routingKey, - 0, - array( - 'delivery_mode' => 2, - 'content_type' => 'application/json', - ) - ); - } else { - $this->exchange->basic_publish( - $this->createAmqpMessage($data), - $this->exchangeName, - $routingKey - ); - } - } - - /** - * {@inheritDoc} - */ - public function handleBatch(array $records) - { - if ($this->exchange instanceof AMQPExchange) { - parent::handleBatch($records); - - return; - } - - foreach ($records as $record) { - if (!$this->isHandling($record)) { - continue; - } - - $record = $this->processRecord($record); - $data = $this->getFormatter()->format($record); - - $this->exchange->batch_basic_publish( - $this->createAmqpMessage($data), - $this->exchangeName, - $this->getRoutingKey($record) - ); - } - - $this->exchange->publish_batch(); - } - - /** - * Gets the routing key for the AMQP exchange - * - * @param array $record - * @return string - */ - private function getRoutingKey(array $record) - { - $routingKey = sprintf( - '%s.%s', - // TODO 2.0 remove substr call - substr($record['level_name'], 0, 4), - $record['channel'] - ); - - return strtolower($routingKey); - } - - /** - * @param string $data - * @return AMQPMessage - */ - private function createAmqpMessage($data) - { - return new AMQPMessage( - (string) $data, - array( - 'delivery_mode' => 2, - 'content_type' => 'application/json', - ) - ); - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php deleted file mode 100644 index b3a21bd40..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/BrowserConsoleHandler.php +++ /dev/null @@ -1,230 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\LineFormatter; - -/** - * Handler sending logs to browser's javascript console with no browser extension required - * - * @author Olivier Poitrey - */ -class BrowserConsoleHandler extends AbstractProcessingHandler -{ - protected static $initialized = false; - protected static $records = array(); - - /** - * {@inheritDoc} - * - * Formatted output may contain some formatting markers to be transferred to `console.log` using the %c format. - * - * Example of formatted string: - * - * You can do [[blue text]]{color: blue} or [[green background]]{background-color: green; color: white} - */ - protected function getDefaultFormatter() - { - return new LineFormatter('[[%channel%]]{macro: autolabel} [[%level_name%]]{font-weight: bold} %message%'); - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) - { - // Accumulate records - self::$records[] = $record; - - // Register shutdown handler if not already done - if (!self::$initialized) { - self::$initialized = true; - $this->registerShutdownFunction(); - } - } - - /** - * Convert records to javascript console commands and send it to the browser. - * This method is automatically called on PHP shutdown if output is HTML or Javascript. - */ - public static function send() - { - $format = self::getResponseFormat(); - if ($format === 'unknown') { - return; - } - - if (count(self::$records)) { - if ($format === 'html') { - self::writeOutput(''); - } elseif ($format === 'js') { - self::writeOutput(self::generateScript()); - } - self::reset(); - } - } - - /** - * Forget all logged records - */ - public static function reset() - { - self::$records = array(); - } - - /** - * Wrapper for register_shutdown_function to allow overriding - */ - protected function registerShutdownFunction() - { - if (PHP_SAPI !== 'cli') { - register_shutdown_function(array('Monolog\Handler\BrowserConsoleHandler', 'send')); - } - } - - /** - * Wrapper for echo to allow overriding - * - * @param string $str - */ - protected static function writeOutput($str) - { - echo $str; - } - - /** - * Checks the format of the response - * - * If Content-Type is set to application/javascript or text/javascript -> js - * If Content-Type is set to text/html, or is unset -> html - * If Content-Type is anything else -> unknown - * - * @return string One of 'js', 'html' or 'unknown' - */ - protected static function getResponseFormat() - { - // Check content type - foreach (headers_list() as $header) { - if (stripos($header, 'content-type:') === 0) { - // This handler only works with HTML and javascript outputs - // text/javascript is obsolete in favour of application/javascript, but still used - if (stripos($header, 'application/javascript') !== false || stripos($header, 'text/javascript') !== false) { - return 'js'; - } - if (stripos($header, 'text/html') === false) { - return 'unknown'; - } - break; - } - } - - return 'html'; - } - - private static function generateScript() - { - $script = array(); - foreach (self::$records as $record) { - $context = self::dump('Context', $record['context']); - $extra = self::dump('Extra', $record['extra']); - - if (empty($context) && empty($extra)) { - $script[] = self::call_array('log', self::handleStyles($record['formatted'])); - } else { - $script = array_merge($script, - array(self::call_array('groupCollapsed', self::handleStyles($record['formatted']))), - $context, - $extra, - array(self::call('groupEnd')) - ); - } - } - - return "(function (c) {if (c && c.groupCollapsed) {\n" . implode("\n", $script) . "\n}})(console);"; - } - - private static function handleStyles($formatted) - { - $args = array(self::quote('font-weight: normal')); - $format = '%c' . $formatted; - preg_match_all('/\[\[(.*?)\]\]\{([^}]*)\}/s', $format, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER); - - foreach (array_reverse($matches) as $match) { - $args[] = self::quote(self::handleCustomStyles($match[2][0], $match[1][0])); - $args[] = '"font-weight: normal"'; - - $pos = $match[0][1]; - $format = substr($format, 0, $pos) . '%c' . $match[1][0] . '%c' . substr($format, $pos + strlen($match[0][0])); - } - - array_unshift($args, self::quote($format)); - - return $args; - } - - private static function handleCustomStyles($style, $string) - { - static $colors = array('blue', 'green', 'red', 'magenta', 'orange', 'black', 'grey'); - static $labels = array(); - - return preg_replace_callback('/macro\s*:(.*?)(?:;|$)/', function ($m) use ($string, &$colors, &$labels) { - if (trim($m[1]) === 'autolabel') { - // Format the string as a label with consistent auto assigned background color - if (!isset($labels[$string])) { - $labels[$string] = $colors[count($labels) % count($colors)]; - } - $color = $labels[$string]; - - return "background-color: $color; color: white; border-radius: 3px; padding: 0 2px 0 2px"; - } - - return $m[1]; - }, $style); - } - - private static function dump($title, array $dict) - { - $script = array(); - $dict = array_filter($dict); - if (empty($dict)) { - return $script; - } - $script[] = self::call('log', self::quote('%c%s'), self::quote('font-weight: bold'), self::quote($title)); - foreach ($dict as $key => $value) { - $value = json_encode($value); - if (empty($value)) { - $value = self::quote(''); - } - $script[] = self::call('log', self::quote('%s: %o'), self::quote($key), $value); - } - - return $script; - } - - private static function quote($arg) - { - return '"' . addcslashes($arg, "\"\n\\") . '"'; - } - - private static function call() - { - $args = func_get_args(); - $method = array_shift($args); - - return self::call_array($method, $args); - } - - private static function call_array($method, array $args) - { - return 'c.' . $method . '(' . implode(', ', $args) . ');'; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php deleted file mode 100644 index 72f895357..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/BufferHandler.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Buffers all records until closing the handler and then pass them as batch. - * - * This is useful for a MailHandler to send only one mail per request instead of - * sending one per log message. - * - * @author Christophe Coevoet - */ -class BufferHandler extends AbstractHandler -{ - protected $handler; - protected $bufferSize = 0; - protected $bufferLimit; - protected $flushOnOverflow; - protected $buffer = array(); - protected $initialized = false; - - /** - * @param HandlerInterface $handler Handler. - * @param int $bufferLimit How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - * @param Boolean $flushOnOverflow If true, the buffer is flushed when the max size has been reached, by default oldest entries are discarded - */ - public function __construct(HandlerInterface $handler, $bufferLimit = 0, $level = Logger::DEBUG, $bubble = true, $flushOnOverflow = false) - { - parent::__construct($level, $bubble); - $this->handler = $handler; - $this->bufferLimit = (int) $bufferLimit; - $this->flushOnOverflow = $flushOnOverflow; - } - - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - if ($record['level'] < $this->level) { - return false; - } - - if (!$this->initialized) { - // __destructor() doesn't get called on Fatal errors - register_shutdown_function(array($this, 'close')); - $this->initialized = true; - } - - if ($this->bufferLimit > 0 && $this->bufferSize === $this->bufferLimit) { - if ($this->flushOnOverflow) { - $this->flush(); - } else { - array_shift($this->buffer); - $this->bufferSize--; - } - } - - if ($this->processors) { - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); - } - } - - $this->buffer[] = $record; - $this->bufferSize++; - - return false === $this->bubble; - } - - public function flush() - { - if ($this->bufferSize === 0) { - return; - } - - $this->handler->handleBatch($this->buffer); - $this->clear(); - } - - public function __destruct() - { - // suppress the parent behavior since we already have register_shutdown_function() - // to call close(), and the reference contained there will prevent this from being - // GC'd until the end of the request - } - - /** - * {@inheritdoc} - */ - public function close() - { - $this->flush(); - } - - /** - * Clears the buffer without flushing any messages down to the wrapped handler. - */ - public function clear() - { - $this->bufferSize = 0; - $this->buffer = array(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php deleted file mode 100644 index b00fa844c..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/ChromePHPHandler.php +++ /dev/null @@ -1,211 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\ChromePHPFormatter; -use Monolog\Logger; - -/** - * Handler sending logs to the ChromePHP extension (http://www.chromephp.com/) - * - * This also works out of the box with Firefox 43+ - * - * @author Christophe Coevoet - */ -class ChromePHPHandler extends AbstractProcessingHandler -{ - /** - * Version of the extension - */ - const VERSION = '4.0'; - - /** - * Header name - */ - const HEADER_NAME = 'X-ChromeLogger-Data'; - - /** - * Regular expression to detect supported browsers (matches any Chrome, or Firefox 43+) - */ - const USER_AGENT_REGEX = '{\b(?:Chrome/\d+(?:\.\d+)*|Firefox/(?:4[3-9]|[5-9]\d|\d{3,})(?:\.\d)*)\b}'; - - protected static $initialized = false; - - /** - * Tracks whether we sent too much data - * - * Chrome limits the headers to 256KB, so when we sent 240KB we stop sending - * - * @var Boolean - */ - protected static $overflowed = false; - - protected static $json = array( - 'version' => self::VERSION, - 'columns' => array('label', 'log', 'backtrace', 'type'), - 'rows' => array(), - ); - - protected static $sendHeaders = true; - - /** - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($level = Logger::DEBUG, $bubble = true) - { - parent::__construct($level, $bubble); - if (!function_exists('json_encode')) { - throw new \RuntimeException('PHP\'s json extension is required to use Monolog\'s ChromePHPHandler'); - } - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - $messages = array(); - - foreach ($records as $record) { - if ($record['level'] < $this->level) { - continue; - } - $messages[] = $this->processRecord($record); - } - - if (!empty($messages)) { - $messages = $this->getFormatter()->formatBatch($messages); - self::$json['rows'] = array_merge(self::$json['rows'], $messages); - $this->send(); - } - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new ChromePHPFormatter(); - } - - /** - * Creates & sends header for a record - * - * @see sendHeader() - * @see send() - * @param array $record - */ - protected function write(array $record) - { - self::$json['rows'][] = $record['formatted']; - - $this->send(); - } - - /** - * Sends the log header - * - * @see sendHeader() - */ - protected function send() - { - if (self::$overflowed || !self::$sendHeaders) { - return; - } - - if (!self::$initialized) { - self::$initialized = true; - - self::$sendHeaders = $this->headersAccepted(); - if (!self::$sendHeaders) { - return; - } - - self::$json['request_uri'] = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : ''; - } - - $json = @json_encode(self::$json); - $data = base64_encode(utf8_encode($json)); - if (strlen($data) > 240 * 1024) { - self::$overflowed = true; - - $record = array( - 'message' => 'Incomplete logs, chrome header size limit reached', - 'context' => array(), - 'level' => Logger::WARNING, - 'level_name' => Logger::getLevelName(Logger::WARNING), - 'channel' => 'monolog', - 'datetime' => new \DateTime(), - 'extra' => array(), - ); - self::$json['rows'][count(self::$json['rows']) - 1] = $this->getFormatter()->format($record); - $json = @json_encode(self::$json); - $data = base64_encode(utf8_encode($json)); - } - - if (trim($data) !== '') { - $this->sendHeader(self::HEADER_NAME, $data); - } - } - - /** - * Send header string to the client - * - * @param string $header - * @param string $content - */ - protected function sendHeader($header, $content) - { - if (!headers_sent() && self::$sendHeaders) { - header(sprintf('%s: %s', $header, $content)); - } - } - - /** - * Verifies if the headers are accepted by the current user agent - * - * @return Boolean - */ - protected function headersAccepted() - { - if (empty($_SERVER['HTTP_USER_AGENT'])) { - return false; - } - - return preg_match(self::USER_AGENT_REGEX, $_SERVER['HTTP_USER_AGENT']); - } - - /** - * BC getter for the sendHeaders property that has been made static - */ - public function __get($property) - { - if ('sendHeaders' !== $property) { - throw new \InvalidArgumentException('Undefined property '.$property); - } - - return static::$sendHeaders; - } - - /** - * BC setter for the sendHeaders property that has been made static - */ - public function __set($property, $value) - { - if ('sendHeaders' !== $property) { - throw new \InvalidArgumentException('Undefined property '.$property); - } - - static::$sendHeaders = $value; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php deleted file mode 100644 index cc9869719..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/CouchDBHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\JsonFormatter; -use Monolog\Logger; - -/** - * CouchDB handler - * - * @author Markus Bachmann - */ -class CouchDBHandler extends AbstractProcessingHandler -{ - private $options; - - public function __construct(array $options = array(), $level = Logger::DEBUG, $bubble = true) - { - $this->options = array_merge(array( - 'host' => 'localhost', - 'port' => 5984, - 'dbname' => 'logger', - 'username' => null, - 'password' => null, - ), $options); - - parent::__construct($level, $bubble); - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) - { - $basicAuth = null; - if ($this->options['username']) { - $basicAuth = sprintf('%s:%s@', $this->options['username'], $this->options['password']); - } - - $url = 'http://'.$basicAuth.$this->options['host'].':'.$this->options['port'].'/'.$this->options['dbname']; - $context = stream_context_create(array( - 'http' => array( - 'method' => 'POST', - 'content' => $record['formatted'], - 'ignore_errors' => true, - 'max_redirects' => 0, - 'header' => 'Content-type: application/json', - ), - )); - - if (false === @file_get_contents($url, null, $context)) { - throw new \RuntimeException(sprintf('Could not connect to %s', $url)); - } - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php deleted file mode 100644 index 96b3ca0c5..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/CubeHandler.php +++ /dev/null @@ -1,151 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Logs to Cube. - * - * @link http://square.github.com/cube/ - * @author Wan Chen - */ -class CubeHandler extends AbstractProcessingHandler -{ - private $udpConnection; - private $httpConnection; - private $scheme; - private $host; - private $port; - private $acceptedSchemes = array('http', 'udp'); - - /** - * Create a Cube handler - * - * @throws \UnexpectedValueException when given url is not a valid url. - * A valid url must consist of three parts : protocol://host:port - * Only valid protocols used by Cube are http and udp - */ - public function __construct($url, $level = Logger::DEBUG, $bubble = true) - { - $urlInfo = parse_url($url); - - if (!isset($urlInfo['scheme'], $urlInfo['host'], $urlInfo['port'])) { - throw new \UnexpectedValueException('URL "'.$url.'" is not valid'); - } - - if (!in_array($urlInfo['scheme'], $this->acceptedSchemes)) { - throw new \UnexpectedValueException( - 'Invalid protocol (' . $urlInfo['scheme'] . ').' - . ' Valid options are ' . implode(', ', $this->acceptedSchemes)); - } - - $this->scheme = $urlInfo['scheme']; - $this->host = $urlInfo['host']; - $this->port = $urlInfo['port']; - - parent::__construct($level, $bubble); - } - - /** - * Establish a connection to an UDP socket - * - * @throws \LogicException when unable to connect to the socket - * @throws MissingExtensionException when there is no socket extension - */ - protected function connectUdp() - { - if (!extension_loaded('sockets')) { - throw new MissingExtensionException('The sockets extension is required to use udp URLs with the CubeHandler'); - } - - $this->udpConnection = socket_create(AF_INET, SOCK_DGRAM, 0); - if (!$this->udpConnection) { - throw new \LogicException('Unable to create a socket'); - } - - if (!socket_connect($this->udpConnection, $this->host, $this->port)) { - throw new \LogicException('Unable to connect to the socket at ' . $this->host . ':' . $this->port); - } - } - - /** - * Establish a connection to a http server - * @throws \LogicException when no curl extension - */ - protected function connectHttp() - { - if (!extension_loaded('curl')) { - throw new \LogicException('The curl extension is needed to use http URLs with the CubeHandler'); - } - - $this->httpConnection = curl_init('http://'.$this->host.':'.$this->port.'/1.0/event/put'); - - if (!$this->httpConnection) { - throw new \LogicException('Unable to connect to ' . $this->host . ':' . $this->port); - } - - curl_setopt($this->httpConnection, CURLOPT_CUSTOMREQUEST, "POST"); - curl_setopt($this->httpConnection, CURLOPT_RETURNTRANSFER, true); - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - $date = $record['datetime']; - - $data = array('time' => $date->format('Y-m-d\TH:i:s.uO')); - unset($record['datetime']); - - if (isset($record['context']['type'])) { - $data['type'] = $record['context']['type']; - unset($record['context']['type']); - } else { - $data['type'] = $record['channel']; - } - - $data['data'] = $record['context']; - $data['data']['level'] = $record['level']; - - if ($this->scheme === 'http') { - $this->writeHttp(json_encode($data)); - } else { - $this->writeUdp(json_encode($data)); - } - } - - private function writeUdp($data) - { - if (!$this->udpConnection) { - $this->connectUdp(); - } - - socket_send($this->udpConnection, $data, strlen($data), 0); - } - - private function writeHttp($data) - { - if (!$this->httpConnection) { - $this->connectHttp(); - } - - curl_setopt($this->httpConnection, CURLOPT_POSTFIELDS, '['.$data.']'); - curl_setopt($this->httpConnection, CURLOPT_HTTPHEADER, array( - 'Content-Type: application/json', - 'Content-Length: ' . strlen('['.$data.']'), - )); - - Curl\Util::execute($this->httpConnection, 5, false); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php b/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php deleted file mode 100644 index 48d30b358..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/Curl/Util.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler\Curl; - -class Util -{ - private static $retriableErrorCodes = array( - CURLE_COULDNT_RESOLVE_HOST, - CURLE_COULDNT_CONNECT, - CURLE_HTTP_NOT_FOUND, - CURLE_READ_ERROR, - CURLE_OPERATION_TIMEOUTED, - CURLE_HTTP_POST_ERROR, - CURLE_SSL_CONNECT_ERROR, - ); - - /** - * Executes a CURL request with optional retries and exception on failure - * - * @param resource $ch curl handler - * @throws \RuntimeException - */ - public static function execute($ch, $retries = 5, $closeAfterDone = true) - { - while ($retries--) { - if (curl_exec($ch) === false) { - $curlErrno = curl_errno($ch); - - if (false === in_array($curlErrno, self::$retriableErrorCodes, true) || !$retries) { - $curlError = curl_error($ch); - - if ($closeAfterDone) { - curl_close($ch); - } - - throw new \RuntimeException(sprintf('Curl error (code %s): %s', $curlErrno, $curlError)); - } - - continue; - } - - if ($closeAfterDone) { - curl_close($ch); - } - break; - } - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php deleted file mode 100644 index 7778c22a6..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/DeduplicationHandler.php +++ /dev/null @@ -1,169 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Simple handler wrapper that deduplicates log records across multiple requests - * - * It also includes the BufferHandler functionality and will buffer - * all messages until the end of the request or flush() is called. - * - * This works by storing all log records' messages above $deduplicationLevel - * to the file specified by $deduplicationStore. When further logs come in at the end of the - * request (or when flush() is called), all those above $deduplicationLevel are checked - * against the existing stored logs. If they match and the timestamps in the stored log is - * not older than $time seconds, the new log record is discarded. If no log record is new, the - * whole data set is discarded. - * - * This is mainly useful in combination with Mail handlers or things like Slack or HipChat handlers - * that send messages to people, to avoid spamming with the same message over and over in case of - * a major component failure like a database server being down which makes all requests fail in the - * same way. - * - * @author Jordi Boggiano - */ -class DeduplicationHandler extends BufferHandler -{ - /** - * @var string - */ - protected $deduplicationStore; - - /** - * @var int - */ - protected $deduplicationLevel; - - /** - * @var int - */ - protected $time; - - /** - * @var bool - */ - private $gc = false; - - /** - * @param HandlerInterface $handler Handler. - * @param string $deduplicationStore The file/path where the deduplication log should be kept - * @param int $deduplicationLevel The minimum logging level for log records to be looked at for deduplication purposes - * @param int $time The period (in seconds) during which duplicate entries should be suppressed after a given log is sent through - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct(HandlerInterface $handler, $deduplicationStore = null, $deduplicationLevel = Logger::ERROR, $time = 60, $bubble = true) - { - parent::__construct($handler, 0, Logger::DEBUG, $bubble, false); - - $this->deduplicationStore = $deduplicationStore === null ? sys_get_temp_dir() . '/monolog-dedup-' . substr(md5(__FILE__), 0, 20) .'.log' : $deduplicationStore; - $this->deduplicationLevel = Logger::toMonologLevel($deduplicationLevel); - $this->time = $time; - } - - public function flush() - { - if ($this->bufferSize === 0) { - return; - } - - $passthru = null; - - foreach ($this->buffer as $record) { - if ($record['level'] >= $this->deduplicationLevel) { - - $passthru = $passthru || !$this->isDuplicate($record); - if ($passthru) { - $this->appendRecord($record); - } - } - } - - // default of null is valid as well as if no record matches duplicationLevel we just pass through - if ($passthru === true || $passthru === null) { - $this->handler->handleBatch($this->buffer); - } - - $this->clear(); - - if ($this->gc) { - $this->collectLogs(); - } - } - - private function isDuplicate(array $record) - { - if (!file_exists($this->deduplicationStore)) { - return false; - } - - $store = file($this->deduplicationStore, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - if (!is_array($store)) { - return false; - } - - $yesterday = time() - 86400; - $timestampValidity = $record['datetime']->getTimestamp() - $this->time; - $expectedMessage = preg_replace('{[\r\n].*}', '', $record['message']); - - for ($i = count($store) - 1; $i >= 0; $i--) { - list($timestamp, $level, $message) = explode(':', $store[$i], 3); - - if ($level === $record['level_name'] && $message === $expectedMessage && $timestamp > $timestampValidity) { - return true; - } - - if ($timestamp < $yesterday) { - $this->gc = true; - } - } - - return false; - } - - private function collectLogs() - { - if (!file_exists($this->deduplicationStore)) { - return false; - } - - $handle = fopen($this->deduplicationStore, 'rw+'); - flock($handle, LOCK_EX); - $validLogs = array(); - - $timestampValidity = time() - $this->time; - - while (!feof($handle)) { - $log = fgets($handle); - if (substr($log, 0, 10) >= $timestampValidity) { - $validLogs[] = $log; - } - } - - ftruncate($handle, 0); - rewind($handle); - foreach ($validLogs as $log) { - fwrite($handle, $log); - } - - flock($handle, LOCK_UN); - fclose($handle); - - $this->gc = false; - } - - private function appendRecord(array $record) - { - file_put_contents($this->deduplicationStore, $record['datetime']->getTimestamp() . ':' . $record['level_name'] . ':' . preg_replace('{[\r\n].*}', '', $record['message']) . "\n", FILE_APPEND); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php deleted file mode 100644 index b91ffec90..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/DoctrineCouchDBHandler.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\NormalizerFormatter; -use Doctrine\CouchDB\CouchDBClient; - -/** - * CouchDB handler for Doctrine CouchDB ODM - * - * @author Markus Bachmann - */ -class DoctrineCouchDBHandler extends AbstractProcessingHandler -{ - private $client; - - public function __construct(CouchDBClient $client, $level = Logger::DEBUG, $bubble = true) - { - $this->client = $client; - parent::__construct($level, $bubble); - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) - { - $this->client->postDocument($record['formatted']); - } - - protected function getDefaultFormatter() - { - return new NormalizerFormatter; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php deleted file mode 100644 index 7b2083094..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/DynamoDbHandler.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Aws\Common\Aws; -use Aws\DynamoDb\DynamoDbClient; -use Monolog\Formatter\ScalarFormatter; -use Monolog\Logger; - -/** - * Amazon DynamoDB handler (http://aws.amazon.com/dynamodb/) - * - * @link https://github.com/aws/aws-sdk-php/ - * @author Andrew Lawson - */ -class DynamoDbHandler extends AbstractProcessingHandler -{ - const DATE_FORMAT = 'Y-m-d\TH:i:s.uO'; - - /** - * @var DynamoDbClient - */ - protected $client; - - /** - * @var string - */ - protected $table; - - /** - * @param DynamoDbClient $client - * @param string $table - * @param int $level - * @param bool $bubble - */ - public function __construct(DynamoDbClient $client, $table, $level = Logger::DEBUG, $bubble = true) - { - if (!defined('Aws\Common\Aws::VERSION') || version_compare('3.0', Aws::VERSION, '<=')) { - throw new \RuntimeException('The DynamoDbHandler is only known to work with the AWS SDK 2.x releases'); - } - - $this->client = $client; - $this->table = $table; - - parent::__construct($level, $bubble); - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - $filtered = $this->filterEmptyFields($record['formatted']); - $formatted = $this->client->formatAttributes($filtered); - - $this->client->putItem(array( - 'TableName' => $this->table, - 'Item' => $formatted, - )); - } - - /** - * @param array $record - * @return array - */ - protected function filterEmptyFields(array $record) - { - return array_filter($record, function ($value) { - return !empty($value) || false === $value || 0 === $value; - }); - } - - /** - * {@inheritdoc} - */ - protected function getDefaultFormatter() - { - return new ScalarFormatter(self::DATE_FORMAT); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php deleted file mode 100644 index 819674069..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/ElasticSearchHandler.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\FormatterInterface; -use Monolog\Formatter\ElasticaFormatter; -use Monolog\Logger; -use Elastica\Client; -use Elastica\Exception\ExceptionInterface; - -/** - * Elastic Search handler - * - * Usage example: - * - * $client = new \Elastica\Client(); - * $options = array( - * 'index' => 'elastic_index_name', - * 'type' => 'elastic_doc_type', - * ); - * $handler = new ElasticSearchHandler($client, $options); - * $log = new Logger('application'); - * $log->pushHandler($handler); - * - * @author Jelle Vink - */ -class ElasticSearchHandler extends AbstractProcessingHandler -{ - /** - * @var Client - */ - protected $client; - - /** - * @var array Handler config options - */ - protected $options = array(); - - /** - * @param Client $client Elastica Client object - * @param array $options Handler configuration - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct(Client $client, array $options = array(), $level = Logger::DEBUG, $bubble = true) - { - parent::__construct($level, $bubble); - $this->client = $client; - $this->options = array_merge( - array( - 'index' => 'monolog', // Elastic index name - 'type' => 'record', // Elastic document type - 'ignore_error' => false, // Suppress Elastica exceptions - ), - $options - ); - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) - { - $this->bulkSend(array($record['formatted'])); - } - - /** - * {@inheritdoc} - */ - public function setFormatter(FormatterInterface $formatter) - { - if ($formatter instanceof ElasticaFormatter) { - return parent::setFormatter($formatter); - } - throw new \InvalidArgumentException('ElasticSearchHandler is only compatible with ElasticaFormatter'); - } - - /** - * Getter options - * @return array - */ - public function getOptions() - { - return $this->options; - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new ElasticaFormatter($this->options['index'], $this->options['type']); - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - $documents = $this->getFormatter()->formatBatch($records); - $this->bulkSend($documents); - } - - /** - * Use Elasticsearch bulk API to send list of documents - * @param array $documents - * @throws \RuntimeException - */ - protected function bulkSend(array $documents) - { - try { - $this->client->addDocuments($documents); - } catch (ExceptionInterface $e) { - if (!$this->options['ignore_error']) { - throw new \RuntimeException("Error sending messages to Elasticsearch", 0, $e); - } - } - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php deleted file mode 100644 index 1447a584b..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/ErrorLogHandler.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\LineFormatter; -use Monolog\Logger; - -/** - * Stores to PHP error_log() handler. - * - * @author Elan Ruusamäe - */ -class ErrorLogHandler extends AbstractProcessingHandler -{ - const OPERATING_SYSTEM = 0; - const SAPI = 4; - - protected $messageType; - protected $expandNewlines; - - /** - * @param int $messageType Says where the error should go. - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - * @param Boolean $expandNewlines If set to true, newlines in the message will be expanded to be take multiple log entries - */ - public function __construct($messageType = self::OPERATING_SYSTEM, $level = Logger::DEBUG, $bubble = true, $expandNewlines = false) - { - parent::__construct($level, $bubble); - - if (false === in_array($messageType, self::getAvailableTypes())) { - $message = sprintf('The given message type "%s" is not supported', print_r($messageType, true)); - throw new \InvalidArgumentException($message); - } - - $this->messageType = $messageType; - $this->expandNewlines = $expandNewlines; - } - - /** - * @return array With all available types - */ - public static function getAvailableTypes() - { - return array( - self::OPERATING_SYSTEM, - self::SAPI, - ); - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new LineFormatter('[%datetime%] %channel%.%level_name%: %message% %context% %extra%'); - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - if ($this->expandNewlines) { - $lines = preg_split('{[\r\n]+}', (string) $record['formatted']); - foreach ($lines as $line) { - error_log($line, $this->messageType); - } - } else { - error_log((string) $record['formatted'], $this->messageType); - } - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php deleted file mode 100644 index 2a0f7fd15..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/FilterHandler.php +++ /dev/null @@ -1,140 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Simple handler wrapper that filters records based on a list of levels - * - * It can be configured with an exact list of levels to allow, or a min/max level. - * - * @author Hennadiy Verkh - * @author Jordi Boggiano - */ -class FilterHandler extends AbstractHandler -{ - /** - * Handler or factory callable($record, $this) - * - * @var callable|\Monolog\Handler\HandlerInterface - */ - protected $handler; - - /** - * Minimum level for logs that are passed to handler - * - * @var int[] - */ - protected $acceptedLevels; - - /** - * Whether the messages that are handled can bubble up the stack or not - * - * @var Boolean - */ - protected $bubble; - - /** - * @param callable|HandlerInterface $handler Handler or factory callable($record, $this). - * @param int|array $minLevelOrList A list of levels to accept or a minimum level if maxLevel is provided - * @param int $maxLevel Maximum level to accept, only used if $minLevelOrList is not an array - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($handler, $minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY, $bubble = true) - { - $this->handler = $handler; - $this->bubble = $bubble; - $this->setAcceptedLevels($minLevelOrList, $maxLevel); - - if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) { - throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object"); - } - } - - /** - * @return array - */ - public function getAcceptedLevels() - { - return array_flip($this->acceptedLevels); - } - - /** - * @param int|string|array $minLevelOrList A list of levels to accept or a minimum level or level name if maxLevel is provided - * @param int|string $maxLevel Maximum level or level name to accept, only used if $minLevelOrList is not an array - */ - public function setAcceptedLevels($minLevelOrList = Logger::DEBUG, $maxLevel = Logger::EMERGENCY) - { - if (is_array($minLevelOrList)) { - $acceptedLevels = array_map('Monolog\Logger::toMonologLevel', $minLevelOrList); - } else { - $minLevelOrList = Logger::toMonologLevel($minLevelOrList); - $maxLevel = Logger::toMonologLevel($maxLevel); - $acceptedLevels = array_values(array_filter(Logger::getLevels(), function ($level) use ($minLevelOrList, $maxLevel) { - return $level >= $minLevelOrList && $level <= $maxLevel; - })); - } - $this->acceptedLevels = array_flip($acceptedLevels); - } - - /** - * {@inheritdoc} - */ - public function isHandling(array $record) - { - return isset($this->acceptedLevels[$record['level']]); - } - - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - if (!$this->isHandling($record)) { - return false; - } - - // The same logic as in FingersCrossedHandler - if (!$this->handler instanceof HandlerInterface) { - $this->handler = call_user_func($this->handler, $record, $this); - if (!$this->handler instanceof HandlerInterface) { - throw new \RuntimeException("The factory callable should return a HandlerInterface"); - } - } - - if ($this->processors) { - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); - } - } - - $this->handler->handle($record); - - return false === $this->bubble; - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - $filtered = array(); - foreach ($records as $record) { - if ($this->isHandling($record)) { - $filtered[] = $record; - } - } - - $this->handler->handleBatch($filtered); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php deleted file mode 100644 index c3e42efef..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ActivationStrategyInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler\FingersCrossed; - -/** - * Interface for activation strategies for the FingersCrossedHandler. - * - * @author Johannes M. Schmitt - */ -interface ActivationStrategyInterface -{ - /** - * Returns whether the given record activates the handler. - * - * @param array $record - * @return Boolean - */ - public function isHandlerActivated(array $record); -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php deleted file mode 100644 index 2a2a64d94..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ChannelLevelActivationStrategy.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler\FingersCrossed; - -use Monolog\Logger; - -/** - * Channel and Error level based monolog activation strategy. Allows to trigger activation - * based on level per channel. e.g. trigger activation on level 'ERROR' by default, except - * for records of the 'sql' channel; those should trigger activation on level 'WARN'. - * - * Example: - * - * - * $activationStrategy = new ChannelLevelActivationStrategy( - * Logger::CRITICAL, - * array( - * 'request' => Logger::ALERT, - * 'sensitive' => Logger::ERROR, - * ) - * ); - * $handler = new FingersCrossedHandler(new StreamHandler('php://stderr'), $activationStrategy); - * - * - * @author Mike Meessen - */ -class ChannelLevelActivationStrategy implements ActivationStrategyInterface -{ - private $defaultActionLevel; - private $channelToActionLevel; - - /** - * @param int $defaultActionLevel The default action level to be used if the record's category doesn't match any - * @param array $channelToActionLevel An array that maps channel names to action levels. - */ - public function __construct($defaultActionLevel, $channelToActionLevel = array()) - { - $this->defaultActionLevel = Logger::toMonologLevel($defaultActionLevel); - $this->channelToActionLevel = array_map('Monolog\Logger::toMonologLevel', $channelToActionLevel); - } - - public function isHandlerActivated(array $record) - { - if (isset($this->channelToActionLevel[$record['channel']])) { - return $record['level'] >= $this->channelToActionLevel[$record['channel']]; - } - - return $record['level'] >= $this->defaultActionLevel; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php deleted file mode 100644 index 6e630852f..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossed/ErrorLevelActivationStrategy.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler\FingersCrossed; - -use Monolog\Logger; - -/** - * Error level based activation strategy. - * - * @author Johannes M. Schmitt - */ -class ErrorLevelActivationStrategy implements ActivationStrategyInterface -{ - private $actionLevel; - - public function __construct($actionLevel) - { - $this->actionLevel = Logger::toMonologLevel($actionLevel); - } - - public function isHandlerActivated(array $record) - { - return $record['level'] >= $this->actionLevel; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php deleted file mode 100644 index d1dcaacf0..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/FingersCrossedHandler.php +++ /dev/null @@ -1,163 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; -use Monolog\Handler\FingersCrossed\ActivationStrategyInterface; -use Monolog\Logger; - -/** - * Buffers all records until a certain level is reached - * - * The advantage of this approach is that you don't get any clutter in your log files. - * Only requests which actually trigger an error (or whatever your actionLevel is) will be - * in the logs, but they will contain all records, not only those above the level threshold. - * - * You can find the various activation strategies in the - * Monolog\Handler\FingersCrossed\ namespace. - * - * @author Jordi Boggiano - */ -class FingersCrossedHandler extends AbstractHandler -{ - protected $handler; - protected $activationStrategy; - protected $buffering = true; - protected $bufferSize; - protected $buffer = array(); - protected $stopBuffering; - protected $passthruLevel; - - /** - * @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler). - * @param int|ActivationStrategyInterface $activationStrategy Strategy which determines when this handler takes action - * @param int $bufferSize How many entries should be buffered at most, beyond that the oldest items are removed from the buffer. - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - * @param Boolean $stopBuffering Whether the handler should stop buffering after being triggered (default true) - * @param int $passthruLevel Minimum level to always flush to handler on close, even if strategy not triggered - */ - public function __construct($handler, $activationStrategy = null, $bufferSize = 0, $bubble = true, $stopBuffering = true, $passthruLevel = null) - { - if (null === $activationStrategy) { - $activationStrategy = new ErrorLevelActivationStrategy(Logger::WARNING); - } - - // convert simple int activationStrategy to an object - if (!$activationStrategy instanceof ActivationStrategyInterface) { - $activationStrategy = new ErrorLevelActivationStrategy($activationStrategy); - } - - $this->handler = $handler; - $this->activationStrategy = $activationStrategy; - $this->bufferSize = $bufferSize; - $this->bubble = $bubble; - $this->stopBuffering = $stopBuffering; - - if ($passthruLevel !== null) { - $this->passthruLevel = Logger::toMonologLevel($passthruLevel); - } - - if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) { - throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object"); - } - } - - /** - * {@inheritdoc} - */ - public function isHandling(array $record) - { - return true; - } - - /** - * Manually activate this logger regardless of the activation strategy - */ - public function activate() - { - if ($this->stopBuffering) { - $this->buffering = false; - } - if (!$this->handler instanceof HandlerInterface) { - $record = end($this->buffer) ?: null; - - $this->handler = call_user_func($this->handler, $record, $this); - if (!$this->handler instanceof HandlerInterface) { - throw new \RuntimeException("The factory callable should return a HandlerInterface"); - } - } - $this->handler->handleBatch($this->buffer); - $this->buffer = array(); - } - - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - if ($this->processors) { - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); - } - } - - if ($this->buffering) { - $this->buffer[] = $record; - if ($this->bufferSize > 0 && count($this->buffer) > $this->bufferSize) { - array_shift($this->buffer); - } - if ($this->activationStrategy->isHandlerActivated($record)) { - $this->activate(); - } - } else { - $this->handler->handle($record); - } - - return false === $this->bubble; - } - - /** - * {@inheritdoc} - */ - public function close() - { - if (null !== $this->passthruLevel) { - $level = $this->passthruLevel; - $this->buffer = array_filter($this->buffer, function ($record) use ($level) { - return $record['level'] >= $level; - }); - if (count($this->buffer) > 0) { - $this->handler->handleBatch($this->buffer); - $this->buffer = array(); - } - } - } - - /** - * Resets the state of the handler. Stops forwarding records to the wrapped handler. - */ - public function reset() - { - $this->buffering = true; - } - - /** - * Clears the buffer without flushing any messages down to the wrapped handler. - * - * It also resets the handler to its initial buffering state. - */ - public function clear() - { - $this->buffer = array(); - $this->reset(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php deleted file mode 100644 index fee479508..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/FirePHPHandler.php +++ /dev/null @@ -1,195 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\WildfireFormatter; - -/** - * Simple FirePHP Handler (http://www.firephp.org/), which uses the Wildfire protocol. - * - * @author Eric Clemmons (@ericclemmons) - */ -class FirePHPHandler extends AbstractProcessingHandler -{ - /** - * WildFire JSON header message format - */ - const PROTOCOL_URI = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2'; - - /** - * FirePHP structure for parsing messages & their presentation - */ - const STRUCTURE_URI = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1'; - - /** - * Must reference a "known" plugin, otherwise headers won't display in FirePHP - */ - const PLUGIN_URI = 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3'; - - /** - * Header prefix for Wildfire to recognize & parse headers - */ - const HEADER_PREFIX = 'X-Wf'; - - /** - * Whether or not Wildfire vendor-specific headers have been generated & sent yet - */ - protected static $initialized = false; - - /** - * Shared static message index between potentially multiple handlers - * @var int - */ - protected static $messageIndex = 1; - - protected static $sendHeaders = true; - - /** - * Base header creation function used by init headers & record headers - * - * @param array $meta Wildfire Plugin, Protocol & Structure Indexes - * @param string $message Log message - * @return array Complete header string ready for the client as key and message as value - */ - protected function createHeader(array $meta, $message) - { - $header = sprintf('%s-%s', self::HEADER_PREFIX, join('-', $meta)); - - return array($header => $message); - } - - /** - * Creates message header from record - * - * @see createHeader() - * @param array $record - * @return string - */ - protected function createRecordHeader(array $record) - { - // Wildfire is extensible to support multiple protocols & plugins in a single request, - // but we're not taking advantage of that (yet), so we're using "1" for simplicity's sake. - return $this->createHeader( - array(1, 1, 1, self::$messageIndex++), - $record['formatted'] - ); - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new WildfireFormatter(); - } - - /** - * Wildfire initialization headers to enable message parsing - * - * @see createHeader() - * @see sendHeader() - * @return array - */ - protected function getInitHeaders() - { - // Initial payload consists of required headers for Wildfire - return array_merge( - $this->createHeader(array('Protocol', 1), self::PROTOCOL_URI), - $this->createHeader(array(1, 'Structure', 1), self::STRUCTURE_URI), - $this->createHeader(array(1, 'Plugin', 1), self::PLUGIN_URI) - ); - } - - /** - * Send header string to the client - * - * @param string $header - * @param string $content - */ - protected function sendHeader($header, $content) - { - if (!headers_sent() && self::$sendHeaders) { - header(sprintf('%s: %s', $header, $content)); - } - } - - /** - * Creates & sends header for a record, ensuring init headers have been sent prior - * - * @see sendHeader() - * @see sendInitHeaders() - * @param array $record - */ - protected function write(array $record) - { - if (!self::$sendHeaders) { - return; - } - - // WildFire-specific headers must be sent prior to any messages - if (!self::$initialized) { - self::$initialized = true; - - self::$sendHeaders = $this->headersAccepted(); - if (!self::$sendHeaders) { - return; - } - - foreach ($this->getInitHeaders() as $header => $content) { - $this->sendHeader($header, $content); - } - } - - $header = $this->createRecordHeader($record); - if (trim(current($header)) !== '') { - $this->sendHeader(key($header), current($header)); - } - } - - /** - * Verifies if the headers are accepted by the current user agent - * - * @return Boolean - */ - protected function headersAccepted() - { - if (!empty($_SERVER['HTTP_USER_AGENT']) && preg_match('{\bFirePHP/\d+\.\d+\b}', $_SERVER['HTTP_USER_AGENT'])) { - return true; - } - - return isset($_SERVER['HTTP_X_FIREPHP_VERSION']); - } - - /** - * BC getter for the sendHeaders property that has been made static - */ - public function __get($property) - { - if ('sendHeaders' !== $property) { - throw new \InvalidArgumentException('Undefined property '.$property); - } - - return static::$sendHeaders; - } - - /** - * BC setter for the sendHeaders property that has been made static - */ - public function __set($property, $value) - { - if ('sendHeaders' !== $property) { - throw new \InvalidArgumentException('Undefined property '.$property); - } - - static::$sendHeaders = $value; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php deleted file mode 100644 index c43c0134f..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/FleepHookHandler.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\LineFormatter; -use Monolog\Logger; - -/** - * Sends logs to Fleep.io using Webhook integrations - * - * You'll need a Fleep.io account to use this handler. - * - * @see https://fleep.io/integrations/webhooks/ Fleep Webhooks Documentation - * @author Ando Roots - */ -class FleepHookHandler extends SocketHandler -{ - const FLEEP_HOST = 'fleep.io'; - - const FLEEP_HOOK_URI = '/hook/'; - - /** - * @var string Webhook token (specifies the conversation where logs are sent) - */ - protected $token; - - /** - * Construct a new Fleep.io Handler. - * - * For instructions on how to create a new web hook in your conversations - * see https://fleep.io/integrations/webhooks/ - * - * @param string $token Webhook token - * @param bool|int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * @throws MissingExtensionException - */ - public function __construct($token, $level = Logger::DEBUG, $bubble = true) - { - if (!extension_loaded('openssl')) { - throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FleepHookHandler'); - } - - $this->token = $token; - - $connectionString = 'ssl://' . self::FLEEP_HOST . ':443'; - parent::__construct($connectionString, $level, $bubble); - } - - /** - * Returns the default formatter to use with this handler - * - * Overloaded to remove empty context and extra arrays from the end of the log message. - * - * @return LineFormatter - */ - protected function getDefaultFormatter() - { - return new LineFormatter(null, null, true, true); - } - - /** - * Handles a log record - * - * @param array $record - */ - public function write(array $record) - { - parent::write($record); - $this->closeSocket(); - } - - /** - * {@inheritdoc} - * - * @param array $record - * @return string - */ - protected function generateDataStream($record) - { - $content = $this->buildContent($record); - - return $this->buildHeader($content) . $content; - } - - /** - * Builds the header of the API Call - * - * @param string $content - * @return string - */ - private function buildHeader($content) - { - $header = "POST " . self::FLEEP_HOOK_URI . $this->token . " HTTP/1.1\r\n"; - $header .= "Host: " . self::FLEEP_HOST . "\r\n"; - $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; - $header .= "\r\n"; - - return $header; - } - - /** - * Builds the body of API call - * - * @param array $record - * @return string - */ - private function buildContent($record) - { - $dataArray = array( - 'message' => $record['formatted'], - ); - - return http_build_query($dataArray); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php deleted file mode 100644 index dd9a361c2..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/FlowdockHandler.php +++ /dev/null @@ -1,127 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\FlowdockFormatter; -use Monolog\Formatter\FormatterInterface; - -/** - * Sends notifications through the Flowdock push API - * - * This must be configured with a FlowdockFormatter instance via setFormatter() - * - * Notes: - * API token - Flowdock API token - * - * @author Dominik Liebler - * @see https://www.flowdock.com/api/push - */ -class FlowdockHandler extends SocketHandler -{ - /** - * @var string - */ - protected $apiToken; - - /** - * @param string $apiToken - * @param bool|int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * - * @throws MissingExtensionException if OpenSSL is missing - */ - public function __construct($apiToken, $level = Logger::DEBUG, $bubble = true) - { - if (!extension_loaded('openssl')) { - throw new MissingExtensionException('The OpenSSL PHP extension is required to use the FlowdockHandler'); - } - - parent::__construct('ssl://api.flowdock.com:443', $level, $bubble); - $this->apiToken = $apiToken; - } - - /** - * {@inheritdoc} - */ - public function setFormatter(FormatterInterface $formatter) - { - if (!$formatter instanceof FlowdockFormatter) { - throw new \InvalidArgumentException('The FlowdockHandler requires an instance of Monolog\Formatter\FlowdockFormatter to function correctly'); - } - - return parent::setFormatter($formatter); - } - - /** - * Gets the default formatter. - * - * @return FormatterInterface - */ - protected function getDefaultFormatter() - { - throw new \InvalidArgumentException('The FlowdockHandler must be configured (via setFormatter) with an instance of Monolog\Formatter\FlowdockFormatter to function correctly'); - } - - /** - * {@inheritdoc} - * - * @param array $record - */ - protected function write(array $record) - { - parent::write($record); - - $this->closeSocket(); - } - - /** - * {@inheritdoc} - * - * @param array $record - * @return string - */ - protected function generateDataStream($record) - { - $content = $this->buildContent($record); - - return $this->buildHeader($content) . $content; - } - - /** - * Builds the body of API call - * - * @param array $record - * @return string - */ - private function buildContent($record) - { - return json_encode($record['formatted']['flowdock']); - } - - /** - * Builds the header of the API Call - * - * @param string $content - * @return string - */ - private function buildHeader($content) - { - $header = "POST /v1/messages/team_inbox/" . $this->apiToken . " HTTP/1.1\r\n"; - $header .= "Host: api.flowdock.com\r\n"; - $header .= "Content-Type: application/json\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; - $header .= "\r\n"; - - return $header; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php deleted file mode 100644 index d3847d828..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/GelfHandler.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Gelf\IMessagePublisher; -use Gelf\PublisherInterface; -use Gelf\Publisher; -use InvalidArgumentException; -use Monolog\Logger; -use Monolog\Formatter\GelfMessageFormatter; - -/** - * Handler to send messages to a Graylog2 (http://www.graylog2.org) server - * - * @author Matt Lehner - * @author Benjamin Zikarsky - */ -class GelfHandler extends AbstractProcessingHandler -{ - /** - * @var Publisher the publisher object that sends the message to the server - */ - protected $publisher; - - /** - * @param PublisherInterface|IMessagePublisher|Publisher $publisher a publisher object - * @param int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($publisher, $level = Logger::DEBUG, $bubble = true) - { - parent::__construct($level, $bubble); - - if (!$publisher instanceof Publisher && !$publisher instanceof IMessagePublisher && !$publisher instanceof PublisherInterface) { - throw new InvalidArgumentException('Invalid publisher, expected a Gelf\Publisher, Gelf\IMessagePublisher or Gelf\PublisherInterface instance'); - } - - $this->publisher = $publisher; - } - - /** - * {@inheritdoc} - */ - public function close() - { - $this->publisher = null; - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - $this->publisher->publish($record['formatted']); - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new GelfMessageFormatter(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php deleted file mode 100644 index 663f5a923..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/GroupHandler.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\FormatterInterface; - -/** - * Forwards records to multiple handlers - * - * @author Lenar Lõhmus - */ -class GroupHandler extends AbstractHandler -{ - protected $handlers; - - /** - * @param array $handlers Array of Handlers. - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct(array $handlers, $bubble = true) - { - foreach ($handlers as $handler) { - if (!$handler instanceof HandlerInterface) { - throw new \InvalidArgumentException('The first argument of the GroupHandler must be an array of HandlerInterface instances.'); - } - } - - $this->handlers = $handlers; - $this->bubble = $bubble; - } - - /** - * {@inheritdoc} - */ - public function isHandling(array $record) - { - foreach ($this->handlers as $handler) { - if ($handler->isHandling($record)) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - if ($this->processors) { - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); - } - } - - foreach ($this->handlers as $handler) { - $handler->handle($record); - } - - return false === $this->bubble; - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - if ($this->processors) { - $processed = array(); - foreach ($records as $record) { - foreach ($this->processors as $processor) { - $processed[] = call_user_func($processor, $record); - } - } - $records = $processed; - } - - foreach ($this->handlers as $handler) { - $handler->handleBatch($records); - } - } - - /** - * {@inheritdoc} - */ - public function setFormatter(FormatterInterface $formatter) - { - foreach ($this->handlers as $handler) { - $handler->setFormatter($formatter); - } - - return $this; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php b/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php deleted file mode 100644 index d920c4ba0..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/HandlerInterface.php +++ /dev/null @@ -1,90 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\FormatterInterface; - -/** - * Interface that all Monolog Handlers must implement - * - * @author Jordi Boggiano - */ -interface HandlerInterface -{ - /** - * Checks whether the given record will be handled by this handler. - * - * This is mostly done for performance reasons, to avoid calling processors for nothing. - * - * Handlers should still check the record levels within handle(), returning false in isHandling() - * is no guarantee that handle() will not be called, and isHandling() might not be called - * for a given record. - * - * @param array $record Partial log record containing only a level key - * - * @return Boolean - */ - public function isHandling(array $record); - - /** - * Handles a record. - * - * All records may be passed to this method, and the handler should discard - * those that it does not want to handle. - * - * The return value of this function controls the bubbling process of the handler stack. - * Unless the bubbling is interrupted (by returning true), the Logger class will keep on - * calling further handlers in the stack with a given log record. - * - * @param array $record The record to handle - * @return Boolean true means that this handler handled the record, and that bubbling is not permitted. - * false means the record was either not processed or that this handler allows bubbling. - */ - public function handle(array $record); - - /** - * Handles a set of records at once. - * - * @param array $records The records to handle (an array of record arrays) - */ - public function handleBatch(array $records); - - /** - * Adds a processor in the stack. - * - * @param callable $callback - * @return self - */ - public function pushProcessor($callback); - - /** - * Removes the processor on top of the stack and returns it. - * - * @return callable - */ - public function popProcessor(); - - /** - * Sets the formatter. - * - * @param FormatterInterface $formatter - * @return self - */ - public function setFormatter(FormatterInterface $formatter); - - /** - * Gets the formatter. - * - * @return FormatterInterface - */ - public function getFormatter(); -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php b/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php deleted file mode 100644 index 56bc2704f..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/HandlerWrapper.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\FormatterInterface; - -/** - * This simple wrapper class can be used to extend handlers functionality. - * - * Example: A filtering handle. Inherit from this class, override isHandling() like this - * - * public function isHandling(array $record) - * { - * if ($record meets certain conditions) { - * return false; - * } - * return $this->handler->isHandling($record); - * } - * - * @author Alexey Karapetov - */ -class HandlerWrapper implements HandlerInterface -{ - /** - * @var HandlerInterface - */ - protected $handler; - - /** - * HandlerWrapper constructor. - * @param HandlerInterface $handler - */ - public function __construct(HandlerInterface $handler) - { - $this->handler = $handler; - } - - /** - * {@inheritdoc} - */ - public function isHandling(array $record) - { - return $this->handler->isHandling($record); - } - - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - return $this->handler->handle($record); - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - return $this->handler->handleBatch($records); - } - - /** - * {@inheritdoc} - */ - public function pushProcessor($callback) - { - $this->handler->pushProcessor($callback); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function popProcessor() - { - return $this->handler->popProcessor(); - } - - /** - * {@inheritdoc} - */ - public function setFormatter(FormatterInterface $formatter) - { - $this->handler->setFormatter($formatter); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getFormatter() - { - return $this->handler->getFormatter(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php deleted file mode 100644 index 73049f369..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/HipChatHandler.php +++ /dev/null @@ -1,350 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Sends notifications through the hipchat api to a hipchat room - * - * Notes: - * API token - HipChat API token - * Room - HipChat Room Id or name, where messages are sent - * Name - Name used to send the message (from) - * notify - Should the message trigger a notification in the clients - * version - The API version to use (HipChatHandler::API_V1 | HipChatHandler::API_V2) - * - * @author Rafael Dohms - * @see https://www.hipchat.com/docs/api - */ -class HipChatHandler extends SocketHandler -{ - /** - * Use API version 1 - */ - const API_V1 = 'v1'; - - /** - * Use API version v2 - */ - const API_V2 = 'v2'; - - /** - * The maximum allowed length for the name used in the "from" field. - */ - const MAXIMUM_NAME_LENGTH = 15; - - /** - * The maximum allowed length for the message. - */ - const MAXIMUM_MESSAGE_LENGTH = 9500; - - /** - * @var string - */ - private $token; - - /** - * @var string - */ - private $room; - - /** - * @var string - */ - private $name; - - /** - * @var bool - */ - private $notify; - - /** - * @var string - */ - private $format; - - /** - * @var string - */ - private $host; - - /** - * @var string - */ - private $version; - - /** - * @param string $token HipChat API Token - * @param string $room The room that should be alerted of the message (Id or Name) - * @param string $name Name used in the "from" field. - * @param bool $notify Trigger a notification in clients or not - * @param int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * @param bool $useSSL Whether to connect via SSL. - * @param string $format The format of the messages (default to text, can be set to html if you have html in the messages) - * @param string $host The HipChat server hostname. - * @param string $version The HipChat API version (default HipChatHandler::API_V1) - */ - public function __construct($token, $room, $name = 'Monolog', $notify = false, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $format = 'text', $host = 'api.hipchat.com', $version = self::API_V1) - { - if ($version == self::API_V1 && !$this->validateStringLength($name, static::MAXIMUM_NAME_LENGTH)) { - throw new \InvalidArgumentException('The supplied name is too long. HipChat\'s v1 API supports names up to 15 UTF-8 characters.'); - } - - $connectionString = $useSSL ? 'ssl://'.$host.':443' : $host.':80'; - parent::__construct($connectionString, $level, $bubble); - - $this->token = $token; - $this->name = $name; - $this->notify = $notify; - $this->room = $room; - $this->format = $format; - $this->host = $host; - $this->version = $version; - } - - /** - * {@inheritdoc} - * - * @param array $record - * @return string - */ - protected function generateDataStream($record) - { - $content = $this->buildContent($record); - - return $this->buildHeader($content) . $content; - } - - /** - * Builds the body of API call - * - * @param array $record - * @return string - */ - private function buildContent($record) - { - $dataArray = array( - 'notify' => $this->version == self::API_V1 ? - ($this->notify ? 1 : 0) : - ($this->notify ? 'true' : 'false'), - 'message' => $record['formatted'], - 'message_format' => $this->format, - 'color' => $this->getAlertColor($record['level']), - ); - - if (!$this->validateStringLength($dataArray['message'], static::MAXIMUM_MESSAGE_LENGTH)) { - if (function_exists('mb_substr')) { - $dataArray['message'] = mb_substr($dataArray['message'], 0, static::MAXIMUM_MESSAGE_LENGTH).' [truncated]'; - } else { - $dataArray['message'] = substr($dataArray['message'], 0, static::MAXIMUM_MESSAGE_LENGTH).' [truncated]'; - } - } - - // if we are using the legacy API then we need to send some additional information - if ($this->version == self::API_V1) { - $dataArray['room_id'] = $this->room; - } - - // append the sender name if it is set - // always append it if we use the v1 api (it is required in v1) - if ($this->version == self::API_V1 || $this->name !== null) { - $dataArray['from'] = (string) $this->name; - } - - return http_build_query($dataArray); - } - - /** - * Builds the header of the API Call - * - * @param string $content - * @return string - */ - private function buildHeader($content) - { - if ($this->version == self::API_V1) { - $header = "POST /v1/rooms/message?format=json&auth_token={$this->token} HTTP/1.1\r\n"; - } else { - // needed for rooms with special (spaces, etc) characters in the name - $room = rawurlencode($this->room); - $header = "POST /v2/room/{$room}/notification?auth_token={$this->token} HTTP/1.1\r\n"; - } - - $header .= "Host: {$this->host}\r\n"; - $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; - $header .= "\r\n"; - - return $header; - } - - /** - * Assigns a color to each level of log records. - * - * @param int $level - * @return string - */ - protected function getAlertColor($level) - { - switch (true) { - case $level >= Logger::ERROR: - return 'red'; - case $level >= Logger::WARNING: - return 'yellow'; - case $level >= Logger::INFO: - return 'green'; - case $level == Logger::DEBUG: - return 'gray'; - default: - return 'yellow'; - } - } - - /** - * {@inheritdoc} - * - * @param array $record - */ - protected function write(array $record) - { - parent::write($record); - $this->closeSocket(); - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - if (count($records) == 0) { - return true; - } - - $batchRecords = $this->combineRecords($records); - - $handled = false; - foreach ($batchRecords as $batchRecord) { - if ($this->isHandling($batchRecord)) { - $this->write($batchRecord); - $handled = true; - } - } - - if (!$handled) { - return false; - } - - return false === $this->bubble; - } - - /** - * Combines multiple records into one. Error level of the combined record - * will be the highest level from the given records. Datetime will be taken - * from the first record. - * - * @param $records - * @return array - */ - private function combineRecords($records) - { - $batchRecord = null; - $batchRecords = array(); - $messages = array(); - $formattedMessages = array(); - $level = 0; - $levelName = null; - $datetime = null; - - foreach ($records as $record) { - $record = $this->processRecord($record); - - if ($record['level'] > $level) { - $level = $record['level']; - $levelName = $record['level_name']; - } - - if (null === $datetime) { - $datetime = $record['datetime']; - } - - $messages[] = $record['message']; - $messageStr = implode(PHP_EOL, $messages); - $formattedMessages[] = $this->getFormatter()->format($record); - $formattedMessageStr = implode('', $formattedMessages); - - $batchRecord = array( - 'message' => $messageStr, - 'formatted' => $formattedMessageStr, - 'context' => array(), - 'extra' => array(), - ); - - if (!$this->validateStringLength($batchRecord['formatted'], static::MAXIMUM_MESSAGE_LENGTH)) { - // Pop the last message and implode the remaining messages - $lastMessage = array_pop($messages); - $lastFormattedMessage = array_pop($formattedMessages); - $batchRecord['message'] = implode(PHP_EOL, $messages); - $batchRecord['formatted'] = implode('', $formattedMessages); - - $batchRecords[] = $batchRecord; - $messages = array($lastMessage); - $formattedMessages = array($lastFormattedMessage); - - $batchRecord = null; - } - } - - if (null !== $batchRecord) { - $batchRecords[] = $batchRecord; - } - - // Set the max level and datetime for all records - foreach ($batchRecords as &$batchRecord) { - $batchRecord = array_merge( - $batchRecord, - array( - 'level' => $level, - 'level_name' => $levelName, - 'datetime' => $datetime, - ) - ); - } - - return $batchRecords; - } - - /** - * Validates the length of a string. - * - * If the `mb_strlen()` function is available, it will use that, as HipChat - * allows UTF-8 characters. Otherwise, it will fall back to `strlen()`. - * - * Note that this might cause false failures in the specific case of using - * a valid name with less than 16 characters, but 16 or more bytes, on a - * system where `mb_strlen()` is unavailable. - * - * @param string $str - * @param int $length - * - * @return bool - */ - private function validateStringLength($str, $length) - { - if (function_exists('mb_strlen')) { - return (mb_strlen($str) <= $length); - } - - return (strlen($str) <= $length); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php deleted file mode 100644 index d60a3c825..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/IFTTTHandler.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * IFTTTHandler uses cURL to trigger IFTTT Maker actions - * - * Register a secret key and trigger/event name at https://ifttt.com/maker - * - * value1 will be the channel from monolog's Logger constructor, - * value2 will be the level name (ERROR, WARNING, ..) - * value3 will be the log record's message - * - * @author Nehal Patel - */ -class IFTTTHandler extends AbstractProcessingHandler -{ - private $eventName; - private $secretKey; - - /** - * @param string $eventName The name of the IFTTT Maker event that should be triggered - * @param string $secretKey A valid IFTTT secret key - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($eventName, $secretKey, $level = Logger::ERROR, $bubble = true) - { - $this->eventName = $eventName; - $this->secretKey = $secretKey; - - parent::__construct($level, $bubble); - } - - /** - * {@inheritdoc} - */ - public function write(array $record) - { - $postData = array( - "value1" => $record["channel"], - "value2" => $record["level_name"], - "value3" => $record["message"], - ); - $postString = json_encode($postData); - - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, "https://maker.ifttt.com/trigger/" . $this->eventName . "/with/key/" . $this->secretKey); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $postString); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - "Content-Type: application/json", - )); - - Curl\Util::execute($ch); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php deleted file mode 100644 index 494c605bc..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/LogEntriesHandler.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * @author Robert Kaufmann III - */ -class LogEntriesHandler extends SocketHandler -{ - /** - * @var string - */ - protected $logToken; - - /** - * @param string $token Log token supplied by LogEntries - * @param bool $useSSL Whether or not SSL encryption should be used. - * @param int $level The minimum logging level to trigger this handler - * @param bool $bubble Whether or not messages that are handled should bubble up the stack. - * - * @throws MissingExtensionException If SSL encryption is set to true and OpenSSL is missing - */ - public function __construct($token, $useSSL = true, $level = Logger::DEBUG, $bubble = true) - { - if ($useSSL && !extension_loaded('openssl')) { - throw new MissingExtensionException('The OpenSSL PHP plugin is required to use SSL encrypted connection for LogEntriesHandler'); - } - - $endpoint = $useSSL ? 'ssl://data.logentries.com:443' : 'data.logentries.com:80'; - parent::__construct($endpoint, $level, $bubble); - $this->logToken = $token; - } - - /** - * {@inheritdoc} - * - * @param array $record - * @return string - */ - protected function generateDataStream($record) - { - return $this->logToken . ' ' . $record['formatted']; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php deleted file mode 100644 index bcd62e1c5..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/LogglyHandler.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\LogglyFormatter; - -/** - * Sends errors to Loggly. - * - * @author Przemek Sobstel - * @author Adam Pancutt - * @author Gregory Barchard - */ -class LogglyHandler extends AbstractProcessingHandler -{ - const HOST = 'logs-01.loggly.com'; - const ENDPOINT_SINGLE = 'inputs'; - const ENDPOINT_BATCH = 'bulk'; - - protected $token; - - protected $tag = array(); - - public function __construct($token, $level = Logger::DEBUG, $bubble = true) - { - if (!extension_loaded('curl')) { - throw new \LogicException('The curl extension is needed to use the LogglyHandler'); - } - - $this->token = $token; - - parent::__construct($level, $bubble); - } - - public function setTag($tag) - { - $tag = !empty($tag) ? $tag : array(); - $this->tag = is_array($tag) ? $tag : array($tag); - } - - public function addTag($tag) - { - if (!empty($tag)) { - $tag = is_array($tag) ? $tag : array($tag); - $this->tag = array_unique(array_merge($this->tag, $tag)); - } - } - - protected function write(array $record) - { - $this->send($record["formatted"], self::ENDPOINT_SINGLE); - } - - public function handleBatch(array $records) - { - $level = $this->level; - - $records = array_filter($records, function ($record) use ($level) { - return ($record['level'] >= $level); - }); - - if ($records) { - $this->send($this->getFormatter()->formatBatch($records), self::ENDPOINT_BATCH); - } - } - - protected function send($data, $endpoint) - { - $url = sprintf("https://%s/%s/%s/", self::HOST, $endpoint, $this->token); - - $headers = array('Content-Type: application/json'); - - if (!empty($this->tag)) { - $headers[] = 'X-LOGGLY-TAG: '.implode(',', $this->tag); - } - - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_POSTFIELDS, $data); - curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); - - Curl\Util::execute($ch); - } - - protected function getDefaultFormatter() - { - return new LogglyFormatter(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php deleted file mode 100644 index 9e2328385..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/MailHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -/** - * Base class for all mail handlers - * - * @author Gyula Sallai - */ -abstract class MailHandler extends AbstractProcessingHandler -{ - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - $messages = array(); - - foreach ($records as $record) { - if ($record['level'] < $this->level) { - continue; - } - $messages[] = $this->processRecord($record); - } - - if (!empty($messages)) { - $this->send((string) $this->getFormatter()->formatBatch($messages), $messages); - } - } - - /** - * Send a mail with the given content - * - * @param string $content formatted email body to be sent - * @param array $records the array of log records that formed this content - */ - abstract protected function send($content, array $records); - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - $this->send((string) $record['formatted'], array($record)); - } - - protected function getHighestRecord(array $records) - { - $highestRecord = null; - foreach ($records as $record) { - if ($highestRecord === null || $highestRecord['level'] < $record['level']) { - $highestRecord = $record; - } - } - - return $highestRecord; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php deleted file mode 100644 index ab95924f9..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/MandrillHandler.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * MandrillHandler uses cURL to send the emails to the Mandrill API - * - * @author Adam Nicholson - */ -class MandrillHandler extends MailHandler -{ - protected $message; - protected $apiKey; - - /** - * @param string $apiKey A valid Mandrill API key - * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($apiKey, $message, $level = Logger::ERROR, $bubble = true) - { - parent::__construct($level, $bubble); - - if (!$message instanceof \Swift_Message && is_callable($message)) { - $message = call_user_func($message); - } - if (!$message instanceof \Swift_Message) { - throw new \InvalidArgumentException('You must provide either a Swift_Message instance or a callable returning it'); - } - $this->message = $message; - $this->apiKey = $apiKey; - } - - /** - * {@inheritdoc} - */ - protected function send($content, array $records) - { - $message = clone $this->message; - $message->setBody($content); - $message->setDate(time()); - - $ch = curl_init(); - - curl_setopt($ch, CURLOPT_URL, 'https://mandrillapp.com/api/1.0/messages/send-raw.json'); - curl_setopt($ch, CURLOPT_POST, 1); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array( - 'key' => $this->apiKey, - 'raw_message' => (string) $message, - 'async' => false, - ))); - - Curl\Util::execute($ch); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php b/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php deleted file mode 100644 index 4724a7e2d..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/MissingExtensionException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -/** - * Exception can be thrown if an extension for an handler is missing - * - * @author Christian Bergau - */ -class MissingExtensionException extends \Exception -{ -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php deleted file mode 100644 index 56fe755b9..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/MongoDBHandler.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\NormalizerFormatter; - -/** - * Logs to a MongoDB database. - * - * usage example: - * - * $log = new Logger('application'); - * $mongodb = new MongoDBHandler(new \Mongo("mongodb://localhost:27017"), "logs", "prod"); - * $log->pushHandler($mongodb); - * - * @author Thomas Tourlourat - */ -class MongoDBHandler extends AbstractProcessingHandler -{ - protected $mongoCollection; - - public function __construct($mongo, $database, $collection, $level = Logger::DEBUG, $bubble = true) - { - if (!($mongo instanceof \MongoClient || $mongo instanceof \Mongo || $mongo instanceof \MongoDB\Client)) { - throw new \InvalidArgumentException('MongoClient, Mongo or MongoDB\Client instance required'); - } - - $this->mongoCollection = $mongo->selectCollection($database, $collection); - - parent::__construct($level, $bubble); - } - - protected function write(array $record) - { - if ($this->mongoCollection instanceof \MongoDB\Collection) { - $this->mongoCollection->insertOne($record["formatted"]); - } else { - $this->mongoCollection->save($record["formatted"]); - } - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new NormalizerFormatter(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php deleted file mode 100644 index d7807fd11..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/NativeMailerHandler.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; - -/** - * NativeMailerHandler uses the mail() function to send the emails - * - * @author Christophe Coevoet - * @author Mark Garrett - */ -class NativeMailerHandler extends MailHandler -{ - /** - * The email addresses to which the message will be sent - * @var array - */ - protected $to; - - /** - * The subject of the email - * @var string - */ - protected $subject; - - /** - * Optional headers for the message - * @var array - */ - protected $headers = array(); - - /** - * Optional parameters for the message - * @var array - */ - protected $parameters = array(); - - /** - * The wordwrap length for the message - * @var int - */ - protected $maxColumnWidth; - - /** - * The Content-type for the message - * @var string - */ - protected $contentType = 'text/plain'; - - /** - * The encoding for the message - * @var string - */ - protected $encoding = 'utf-8'; - - /** - * @param string|array $to The receiver of the mail - * @param string $subject The subject of the mail - * @param string $from The sender of the mail - * @param int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * @param int $maxColumnWidth The maximum column width that the message lines will have - */ - public function __construct($to, $subject, $from, $level = Logger::ERROR, $bubble = true, $maxColumnWidth = 70) - { - parent::__construct($level, $bubble); - $this->to = is_array($to) ? $to : array($to); - $this->subject = $subject; - $this->addHeader(sprintf('From: %s', $from)); - $this->maxColumnWidth = $maxColumnWidth; - } - - /** - * Add headers to the message - * - * @param string|array $headers Custom added headers - * @return self - */ - public function addHeader($headers) - { - foreach ((array) $headers as $header) { - if (strpos($header, "\n") !== false || strpos($header, "\r") !== false) { - throw new \InvalidArgumentException('Headers can not contain newline characters for security reasons'); - } - $this->headers[] = $header; - } - - return $this; - } - - /** - * Add parameters to the message - * - * @param string|array $parameters Custom added parameters - * @return self - */ - public function addParameter($parameters) - { - $this->parameters = array_merge($this->parameters, (array) $parameters); - - return $this; - } - - /** - * {@inheritdoc} - */ - protected function send($content, array $records) - { - $content = wordwrap($content, $this->maxColumnWidth); - $headers = ltrim(implode("\r\n", $this->headers) . "\r\n", "\r\n"); - $headers .= 'Content-type: ' . $this->getContentType() . '; charset=' . $this->getEncoding() . "\r\n"; - if ($this->getContentType() == 'text/html' && false === strpos($headers, 'MIME-Version:')) { - $headers .= 'MIME-Version: 1.0' . "\r\n"; - } - - $subject = $this->subject; - if ($records) { - $subjectFormatter = new LineFormatter($this->subject); - $subject = $subjectFormatter->format($this->getHighestRecord($records)); - } - - $parameters = implode(' ', $this->parameters); - foreach ($this->to as $to) { - mail($to, $subject, $content, $headers, $parameters); - } - } - - /** - * @return string $contentType - */ - public function getContentType() - { - return $this->contentType; - } - - /** - * @return string $encoding - */ - public function getEncoding() - { - return $this->encoding; - } - - /** - * @param string $contentType The content type of the email - Defaults to text/plain. Use text/html for HTML - * messages. - * @return self - */ - public function setContentType($contentType) - { - if (strpos($contentType, "\n") !== false || strpos($contentType, "\r") !== false) { - throw new \InvalidArgumentException('The content type can not contain newline characters to prevent email header injection'); - } - - $this->contentType = $contentType; - - return $this; - } - - /** - * @param string $encoding - * @return self - */ - public function setEncoding($encoding) - { - if (strpos($encoding, "\n") !== false || strpos($encoding, "\r") !== false) { - throw new \InvalidArgumentException('The encoding can not contain newline characters to prevent email header injection'); - } - - $this->encoding = $encoding; - - return $this; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php deleted file mode 100644 index 6718e9e09..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/NewRelicHandler.php +++ /dev/null @@ -1,202 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\NormalizerFormatter; - -/** - * Class to record a log on a NewRelic application. - * Enabling New Relic High Security mode may prevent capture of useful information. - * - * @see https://docs.newrelic.com/docs/agents/php-agent - * @see https://docs.newrelic.com/docs/accounts-partnerships/accounts/security/high-security - */ -class NewRelicHandler extends AbstractProcessingHandler -{ - /** - * Name of the New Relic application that will receive logs from this handler. - * - * @var string - */ - protected $appName; - - /** - * Name of the current transaction - * - * @var string - */ - protected $transactionName; - - /** - * Some context and extra data is passed into the handler as arrays of values. Do we send them as is - * (useful if we are using the API), or explode them for display on the NewRelic RPM website? - * - * @var bool - */ - protected $explodeArrays; - - /** - * {@inheritDoc} - * - * @param string $appName - * @param bool $explodeArrays - * @param string $transactionName - */ - public function __construct( - $level = Logger::ERROR, - $bubble = true, - $appName = null, - $explodeArrays = false, - $transactionName = null - ) { - parent::__construct($level, $bubble); - - $this->appName = $appName; - $this->explodeArrays = $explodeArrays; - $this->transactionName = $transactionName; - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) - { - if (!$this->isNewRelicEnabled()) { - throw new MissingExtensionException('The newrelic PHP extension is required to use the NewRelicHandler'); - } - - if ($appName = $this->getAppName($record['context'])) { - $this->setNewRelicAppName($appName); - } - - if ($transactionName = $this->getTransactionName($record['context'])) { - $this->setNewRelicTransactionName($transactionName); - unset($record['formatted']['context']['transaction_name']); - } - - if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { - newrelic_notice_error($record['message'], $record['context']['exception']); - unset($record['formatted']['context']['exception']); - } else { - newrelic_notice_error($record['message']); - } - - if (isset($record['formatted']['context']) && is_array($record['formatted']['context'])) { - foreach ($record['formatted']['context'] as $key => $parameter) { - if (is_array($parameter) && $this->explodeArrays) { - foreach ($parameter as $paramKey => $paramValue) { - $this->setNewRelicParameter('context_' . $key . '_' . $paramKey, $paramValue); - } - } else { - $this->setNewRelicParameter('context_' . $key, $parameter); - } - } - } - - if (isset($record['formatted']['extra']) && is_array($record['formatted']['extra'])) { - foreach ($record['formatted']['extra'] as $key => $parameter) { - if (is_array($parameter) && $this->explodeArrays) { - foreach ($parameter as $paramKey => $paramValue) { - $this->setNewRelicParameter('extra_' . $key . '_' . $paramKey, $paramValue); - } - } else { - $this->setNewRelicParameter('extra_' . $key, $parameter); - } - } - } - } - - /** - * Checks whether the NewRelic extension is enabled in the system. - * - * @return bool - */ - protected function isNewRelicEnabled() - { - return extension_loaded('newrelic'); - } - - /** - * Returns the appname where this log should be sent. Each log can override the default appname, set in this - * handler's constructor, by providing the appname in it's context. - * - * @param array $context - * @return null|string - */ - protected function getAppName(array $context) - { - if (isset($context['appname'])) { - return $context['appname']; - } - - return $this->appName; - } - - /** - * Returns the name of the current transaction. Each log can override the default transaction name, set in this - * handler's constructor, by providing the transaction_name in it's context - * - * @param array $context - * - * @return null|string - */ - protected function getTransactionName(array $context) - { - if (isset($context['transaction_name'])) { - return $context['transaction_name']; - } - - return $this->transactionName; - } - - /** - * Sets the NewRelic application that should receive this log. - * - * @param string $appName - */ - protected function setNewRelicAppName($appName) - { - newrelic_set_appname($appName); - } - - /** - * Overwrites the name of the current transaction - * - * @param string $transactionName - */ - protected function setNewRelicTransactionName($transactionName) - { - newrelic_name_transaction($transactionName); - } - - /** - * @param string $key - * @param mixed $value - */ - protected function setNewRelicParameter($key, $value) - { - if (null === $value || is_scalar($value)) { - newrelic_add_custom_parameter($key, $value); - } else { - newrelic_add_custom_parameter($key, @json_encode($value)); - } - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new NormalizerFormatter(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php deleted file mode 100644 index 4b8458833..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/NullHandler.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Blackhole - * - * Any record it can handle will be thrown away. This can be used - * to put on top of an existing stack to override it temporarily. - * - * @author Jordi Boggiano - */ -class NullHandler extends AbstractHandler -{ - /** - * @param int $level The minimum logging level at which this handler will be triggered - */ - public function __construct($level = Logger::DEBUG) - { - parent::__construct($level, false); - } - - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - if ($record['level'] < $this->level) { - return false; - } - - return true; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php deleted file mode 100644 index 1f2076a49..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/PHPConsoleHandler.php +++ /dev/null @@ -1,242 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Exception; -use Monolog\Formatter\LineFormatter; -use Monolog\Logger; -use PhpConsole\Connector; -use PhpConsole\Handler; -use PhpConsole\Helper; - -/** - * Monolog handler for Google Chrome extension "PHP Console" - * - * Display PHP error/debug log messages in Google Chrome console and notification popups, executes PHP code remotely - * - * Usage: - * 1. Install Google Chrome extension https://chrome.google.com/webstore/detail/php-console/nfhmhhlpfleoednkpnnnkolmclajemef - * 2. See overview https://github.com/barbushin/php-console#overview - * 3. Install PHP Console library https://github.com/barbushin/php-console#installation - * 4. Example (result will looks like http://i.hizliresim.com/vg3Pz4.png) - * - * $logger = new \Monolog\Logger('all', array(new \Monolog\Handler\PHPConsoleHandler())); - * \Monolog\ErrorHandler::register($logger); - * echo $undefinedVar; - * $logger->addDebug('SELECT * FROM users', array('db', 'time' => 0.012)); - * PC::debug($_SERVER); // PHP Console debugger for any type of vars - * - * @author Sergey Barbushin https://www.linkedin.com/in/barbushin - */ -class PHPConsoleHandler extends AbstractProcessingHandler -{ - private $options = array( - 'enabled' => true, // bool Is PHP Console server enabled - 'classesPartialsTraceIgnore' => array('Monolog\\'), // array Hide calls of classes started with... - 'debugTagsKeysInContext' => array(0, 'tag'), // bool Is PHP Console server enabled - 'useOwnErrorsHandler' => false, // bool Enable errors handling - 'useOwnExceptionsHandler' => false, // bool Enable exceptions handling - 'sourcesBasePath' => null, // string Base path of all project sources to strip in errors source paths - 'registerHelper' => true, // bool Register PhpConsole\Helper that allows short debug calls like PC::debug($var, 'ta.g.s') - 'serverEncoding' => null, // string|null Server internal encoding - 'headersLimit' => null, // int|null Set headers size limit for your web-server - 'password' => null, // string|null Protect PHP Console connection by password - 'enableSslOnlyMode' => false, // bool Force connection by SSL for clients with PHP Console installed - 'ipMasks' => array(), // array Set IP masks of clients that will be allowed to connect to PHP Console: array('192.168.*.*', '127.0.0.1') - 'enableEvalListener' => false, // bool Enable eval request to be handled by eval dispatcher(if enabled, 'password' option is also required) - 'dumperDetectCallbacks' => false, // bool Convert callback items in dumper vars to (callback SomeClass::someMethod) strings - 'dumperLevelLimit' => 5, // int Maximum dumped vars array or object nested dump level - 'dumperItemsCountLimit' => 100, // int Maximum dumped var same level array items or object properties number - 'dumperItemSizeLimit' => 5000, // int Maximum length of any string or dumped array item - 'dumperDumpSizeLimit' => 500000, // int Maximum approximate size of dumped vars result formatted in JSON - 'detectDumpTraceAndSource' => false, // bool Autodetect and append trace data to debug - 'dataStorage' => null, // PhpConsole\Storage|null Fixes problem with custom $_SESSION handler(see http://goo.gl/Ne8juJ) - ); - - /** @var Connector */ - private $connector; - - /** - * @param array $options See \Monolog\Handler\PHPConsoleHandler::$options for more details - * @param Connector|null $connector Instance of \PhpConsole\Connector class (optional) - * @param int $level - * @param bool $bubble - * @throws Exception - */ - public function __construct(array $options = array(), Connector $connector = null, $level = Logger::DEBUG, $bubble = true) - { - if (!class_exists('PhpConsole\Connector')) { - throw new Exception('PHP Console library not found. See https://github.com/barbushin/php-console#installation'); - } - parent::__construct($level, $bubble); - $this->options = $this->initOptions($options); - $this->connector = $this->initConnector($connector); - } - - private function initOptions(array $options) - { - $wrongOptions = array_diff(array_keys($options), array_keys($this->options)); - if ($wrongOptions) { - throw new Exception('Unknown options: ' . implode(', ', $wrongOptions)); - } - - return array_replace($this->options, $options); - } - - private function initConnector(Connector $connector = null) - { - if (!$connector) { - if ($this->options['dataStorage']) { - Connector::setPostponeStorage($this->options['dataStorage']); - } - $connector = Connector::getInstance(); - } - - if ($this->options['registerHelper'] && !Helper::isRegistered()) { - Helper::register(); - } - - if ($this->options['enabled'] && $connector->isActiveClient()) { - if ($this->options['useOwnErrorsHandler'] || $this->options['useOwnExceptionsHandler']) { - $handler = Handler::getInstance(); - $handler->setHandleErrors($this->options['useOwnErrorsHandler']); - $handler->setHandleExceptions($this->options['useOwnExceptionsHandler']); - $handler->start(); - } - if ($this->options['sourcesBasePath']) { - $connector->setSourcesBasePath($this->options['sourcesBasePath']); - } - if ($this->options['serverEncoding']) { - $connector->setServerEncoding($this->options['serverEncoding']); - } - if ($this->options['password']) { - $connector->setPassword($this->options['password']); - } - if ($this->options['enableSslOnlyMode']) { - $connector->enableSslOnlyMode(); - } - if ($this->options['ipMasks']) { - $connector->setAllowedIpMasks($this->options['ipMasks']); - } - if ($this->options['headersLimit']) { - $connector->setHeadersLimit($this->options['headersLimit']); - } - if ($this->options['detectDumpTraceAndSource']) { - $connector->getDebugDispatcher()->detectTraceAndSource = true; - } - $dumper = $connector->getDumper(); - $dumper->levelLimit = $this->options['dumperLevelLimit']; - $dumper->itemsCountLimit = $this->options['dumperItemsCountLimit']; - $dumper->itemSizeLimit = $this->options['dumperItemSizeLimit']; - $dumper->dumpSizeLimit = $this->options['dumperDumpSizeLimit']; - $dumper->detectCallbacks = $this->options['dumperDetectCallbacks']; - if ($this->options['enableEvalListener']) { - $connector->startEvalRequestsListener(); - } - } - - return $connector; - } - - public function getConnector() - { - return $this->connector; - } - - public function getOptions() - { - return $this->options; - } - - public function handle(array $record) - { - if ($this->options['enabled'] && $this->connector->isActiveClient()) { - return parent::handle($record); - } - - return !$this->bubble; - } - - /** - * Writes the record down to the log of the implementing handler - * - * @param array $record - * @return void - */ - protected function write(array $record) - { - if ($record['level'] < Logger::NOTICE) { - $this->handleDebugRecord($record); - } elseif (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) { - $this->handleExceptionRecord($record); - } else { - $this->handleErrorRecord($record); - } - } - - private function handleDebugRecord(array $record) - { - $tags = $this->getRecordTags($record); - $message = $record['message']; - if ($record['context']) { - $message .= ' ' . json_encode($this->connector->getDumper()->dump(array_filter($record['context']))); - } - $this->connector->getDebugDispatcher()->dispatchDebug($message, $tags, $this->options['classesPartialsTraceIgnore']); - } - - private function handleExceptionRecord(array $record) - { - $this->connector->getErrorsDispatcher()->dispatchException($record['context']['exception']); - } - - private function handleErrorRecord(array $record) - { - $context = $record['context']; - - $this->connector->getErrorsDispatcher()->dispatchError( - isset($context['code']) ? $context['code'] : null, - isset($context['message']) ? $context['message'] : $record['message'], - isset($context['file']) ? $context['file'] : null, - isset($context['line']) ? $context['line'] : null, - $this->options['classesPartialsTraceIgnore'] - ); - } - - private function getRecordTags(array &$record) - { - $tags = null; - if (!empty($record['context'])) { - $context = & $record['context']; - foreach ($this->options['debugTagsKeysInContext'] as $key) { - if (!empty($context[$key])) { - $tags = $context[$key]; - if ($key === 0) { - array_shift($context); - } else { - unset($context[$key]); - } - break; - } - } - } - - return $tags ?: strtolower($record['level_name']); - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new LineFormatter('%message%'); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php deleted file mode 100644 index 1ae85845d..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/PsrHandler.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Psr\Log\LoggerInterface; - -/** - * Proxies log messages to an existing PSR-3 compliant logger. - * - * @author Michael Moussa - */ -class PsrHandler extends AbstractHandler -{ - /** - * PSR-3 compliant logger - * - * @var LoggerInterface - */ - protected $logger; - - /** - * @param LoggerInterface $logger The underlying PSR-3 compliant logger to which messages will be proxied - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct(LoggerInterface $logger, $level = Logger::DEBUG, $bubble = true) - { - parent::__construct($level, $bubble); - - $this->logger = $logger; - } - - /** - * {@inheritDoc} - */ - public function handle(array $record) - { - if (!$this->isHandling($record)) { - return false; - } - - $this->logger->log(strtolower($record['level_name']), $record['message'], $record['context']); - - return false === $this->bubble; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php deleted file mode 100644 index bba720059..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/PushoverHandler.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Sends notifications through the pushover api to mobile phones - * - * @author Sebastian Göttschkes - * @see https://www.pushover.net/api - */ -class PushoverHandler extends SocketHandler -{ - private $token; - private $users; - private $title; - private $user; - private $retry; - private $expire; - - private $highPriorityLevel; - private $emergencyLevel; - private $useFormattedMessage = false; - - /** - * All parameters that can be sent to Pushover - * @see https://pushover.net/api - * @var array - */ - private $parameterNames = array( - 'token' => true, - 'user' => true, - 'message' => true, - 'device' => true, - 'title' => true, - 'url' => true, - 'url_title' => true, - 'priority' => true, - 'timestamp' => true, - 'sound' => true, - 'retry' => true, - 'expire' => true, - 'callback' => true, - ); - - /** - * Sounds the api supports by default - * @see https://pushover.net/api#sounds - * @var array - */ - private $sounds = array( - 'pushover', 'bike', 'bugle', 'cashregister', 'classical', 'cosmic', 'falling', 'gamelan', 'incoming', - 'intermission', 'magic', 'mechanical', 'pianobar', 'siren', 'spacealarm', 'tugboat', 'alien', 'climb', - 'persistent', 'echo', 'updown', 'none', - ); - - /** - * @param string $token Pushover api token - * @param string|array $users Pushover user id or array of ids the message will be sent to - * @param string $title Title sent to the Pushover API - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - * @param Boolean $useSSL Whether to connect via SSL. Required when pushing messages to users that are not - * the pushover.net app owner. OpenSSL is required for this option. - * @param int $highPriorityLevel The minimum logging level at which this handler will start - * sending "high priority" requests to the Pushover API - * @param int $emergencyLevel The minimum logging level at which this handler will start - * sending "emergency" requests to the Pushover API - * @param int $retry The retry parameter specifies how often (in seconds) the Pushover servers will send the same notification to the user. - * @param int $expire The expire parameter specifies how many seconds your notification will continue to be retried for (every retry seconds). - */ - public function __construct($token, $users, $title = null, $level = Logger::CRITICAL, $bubble = true, $useSSL = true, $highPriorityLevel = Logger::CRITICAL, $emergencyLevel = Logger::EMERGENCY, $retry = 30, $expire = 25200) - { - $connectionString = $useSSL ? 'ssl://api.pushover.net:443' : 'api.pushover.net:80'; - parent::__construct($connectionString, $level, $bubble); - - $this->token = $token; - $this->users = (array) $users; - $this->title = $title ?: gethostname(); - $this->highPriorityLevel = Logger::toMonologLevel($highPriorityLevel); - $this->emergencyLevel = Logger::toMonologLevel($emergencyLevel); - $this->retry = $retry; - $this->expire = $expire; - } - - protected function generateDataStream($record) - { - $content = $this->buildContent($record); - - return $this->buildHeader($content) . $content; - } - - private function buildContent($record) - { - // Pushover has a limit of 512 characters on title and message combined. - $maxMessageLength = 512 - strlen($this->title); - - $message = ($this->useFormattedMessage) ? $record['formatted'] : $record['message']; - $message = substr($message, 0, $maxMessageLength); - - $timestamp = $record['datetime']->getTimestamp(); - - $dataArray = array( - 'token' => $this->token, - 'user' => $this->user, - 'message' => $message, - 'title' => $this->title, - 'timestamp' => $timestamp, - ); - - if (isset($record['level']) && $record['level'] >= $this->emergencyLevel) { - $dataArray['priority'] = 2; - $dataArray['retry'] = $this->retry; - $dataArray['expire'] = $this->expire; - } elseif (isset($record['level']) && $record['level'] >= $this->highPriorityLevel) { - $dataArray['priority'] = 1; - } - - // First determine the available parameters - $context = array_intersect_key($record['context'], $this->parameterNames); - $extra = array_intersect_key($record['extra'], $this->parameterNames); - - // Least important info should be merged with subsequent info - $dataArray = array_merge($extra, $context, $dataArray); - - // Only pass sounds that are supported by the API - if (isset($dataArray['sound']) && !in_array($dataArray['sound'], $this->sounds)) { - unset($dataArray['sound']); - } - - return http_build_query($dataArray); - } - - private function buildHeader($content) - { - $header = "POST /1/messages.json HTTP/1.1\r\n"; - $header .= "Host: api.pushover.net\r\n"; - $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; - $header .= "\r\n"; - - return $header; - } - - protected function write(array $record) - { - foreach ($this->users as $user) { - $this->user = $user; - - parent::write($record); - $this->closeSocket(); - } - - $this->user = null; - } - - public function setHighPriorityLevel($value) - { - $this->highPriorityLevel = $value; - } - - public function setEmergencyLevel($value) - { - $this->emergencyLevel = $value; - } - - /** - * Use the formatted message? - * @param bool $value - */ - public function useFormattedMessage($value) - { - $this->useFormattedMessage = (boolean) $value; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php deleted file mode 100644 index 90758274d..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/RavenHandler.php +++ /dev/null @@ -1,231 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\LineFormatter; -use Monolog\Formatter\FormatterInterface; -use Monolog\Logger; -use Raven_Client; - -/** - * Handler to send messages to a Sentry (https://github.com/getsentry/sentry) server - * using raven-php (https://github.com/getsentry/raven-php) - * - * @author Marc Abramowitz - */ -class RavenHandler extends AbstractProcessingHandler -{ - /** - * Translates Monolog log levels to Raven log levels. - */ - private $logLevels = array( - Logger::DEBUG => Raven_Client::DEBUG, - Logger::INFO => Raven_Client::INFO, - Logger::NOTICE => Raven_Client::INFO, - Logger::WARNING => Raven_Client::WARNING, - Logger::ERROR => Raven_Client::ERROR, - Logger::CRITICAL => Raven_Client::FATAL, - Logger::ALERT => Raven_Client::FATAL, - Logger::EMERGENCY => Raven_Client::FATAL, - ); - - /** - * @var string should represent the current version of the calling - * software. Can be any string (git commit, version number) - */ - private $release; - - /** - * @var Raven_Client the client object that sends the message to the server - */ - protected $ravenClient; - - /** - * @var LineFormatter The formatter to use for the logs generated via handleBatch() - */ - protected $batchFormatter; - - /** - * @param Raven_Client $ravenClient - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct(Raven_Client $ravenClient, $level = Logger::DEBUG, $bubble = true) - { - parent::__construct($level, $bubble); - - $this->ravenClient = $ravenClient; - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - $level = $this->level; - - // filter records based on their level - $records = array_filter($records, function ($record) use ($level) { - return $record['level'] >= $level; - }); - - if (!$records) { - return; - } - - // the record with the highest severity is the "main" one - $record = array_reduce($records, function ($highest, $record) { - if ($record['level'] >= $highest['level']) { - return $record; - } - - return $highest; - }); - - // the other ones are added as a context item - $logs = array(); - foreach ($records as $r) { - $logs[] = $this->processRecord($r); - } - - if ($logs) { - $record['context']['logs'] = (string) $this->getBatchFormatter()->formatBatch($logs); - } - - $this->handle($record); - } - - /** - * Sets the formatter for the logs generated by handleBatch(). - * - * @param FormatterInterface $formatter - */ - public function setBatchFormatter(FormatterInterface $formatter) - { - $this->batchFormatter = $formatter; - } - - /** - * Gets the formatter for the logs generated by handleBatch(). - * - * @return FormatterInterface - */ - public function getBatchFormatter() - { - if (!$this->batchFormatter) { - $this->batchFormatter = $this->getDefaultBatchFormatter(); - } - - return $this->batchFormatter; - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - $previousUserContext = false; - $options = array(); - $options['level'] = $this->logLevels[$record['level']]; - $options['tags'] = array(); - if (!empty($record['extra']['tags'])) { - $options['tags'] = array_merge($options['tags'], $record['extra']['tags']); - unset($record['extra']['tags']); - } - if (!empty($record['context']['tags'])) { - $options['tags'] = array_merge($options['tags'], $record['context']['tags']); - unset($record['context']['tags']); - } - if (!empty($record['context']['fingerprint'])) { - $options['fingerprint'] = $record['context']['fingerprint']; - unset($record['context']['fingerprint']); - } - if (!empty($record['context']['logger'])) { - $options['logger'] = $record['context']['logger']; - unset($record['context']['logger']); - } else { - $options['logger'] = $record['channel']; - } - foreach ($this->getExtraParameters() as $key) { - foreach (array('extra', 'context') as $source) { - if (!empty($record[$source][$key])) { - $options[$key] = $record[$source][$key]; - unset($record[$source][$key]); - } - } - } - if (!empty($record['context'])) { - $options['extra']['context'] = $record['context']; - if (!empty($record['context']['user'])) { - $previousUserContext = $this->ravenClient->context->user; - $this->ravenClient->user_context($record['context']['user']); - unset($options['extra']['context']['user']); - } - } - if (!empty($record['extra'])) { - $options['extra']['extra'] = $record['extra']; - } - - if (!empty($this->release) && !isset($options['release'])) { - $options['release'] = $this->release; - } - - if (isset($record['context']['exception']) && $record['context']['exception'] instanceof \Exception) { - $options['extra']['message'] = $record['formatted']; - $this->ravenClient->captureException($record['context']['exception'], $options); - } else { - $this->ravenClient->captureMessage($record['formatted'], array(), $options); - } - - if ($previousUserContext !== false) { - $this->ravenClient->user_context($previousUserContext); - } - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new LineFormatter('[%channel%] %message%'); - } - - /** - * Gets the default formatter for the logs generated by handleBatch(). - * - * @return FormatterInterface - */ - protected function getDefaultBatchFormatter() - { - return new LineFormatter(); - } - - /** - * Gets extra parameters supported by Raven that can be found in "extra" and "context" - * - * @return array - */ - protected function getExtraParameters() - { - return array('checksum', 'release'); - } - - /** - * @param string $value - */ - public function setRelease($value) - { - $this->release = $value; - - return $this; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php deleted file mode 100644 index 590f99657..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/RedisHandler.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\LineFormatter; -use Monolog\Logger; - -/** - * Logs to a Redis key using rpush - * - * usage example: - * - * $log = new Logger('application'); - * $redis = new RedisHandler(new Predis\Client("tcp://localhost:6379"), "logs", "prod"); - * $log->pushHandler($redis); - * - * @author Thomas Tourlourat - */ -class RedisHandler extends AbstractProcessingHandler -{ - private $redisClient; - private $redisKey; - protected $capSize; - - /** - * @param \Predis\Client|\Redis $redis The redis instance - * @param string $key The key name to push records to - * @param int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * @param int $capSize Number of entries to limit list size to - */ - public function __construct($redis, $key, $level = Logger::DEBUG, $bubble = true, $capSize = false) - { - if (!(($redis instanceof \Predis\Client) || ($redis instanceof \Redis))) { - throw new \InvalidArgumentException('Predis\Client or Redis instance required'); - } - - $this->redisClient = $redis; - $this->redisKey = $key; - $this->capSize = $capSize; - - parent::__construct($level, $bubble); - } - - /** - * {@inheritDoc} - */ - protected function write(array $record) - { - if ($this->capSize) { - $this->writeCapped($record); - } else { - $this->redisClient->rpush($this->redisKey, $record["formatted"]); - } - } - - /** - * Write and cap the collection - * Writes the record to the redis list and caps its - * - * @param array $record associative record array - * @return void - */ - protected function writeCapped(array $record) - { - if ($this->redisClient instanceof \Redis) { - $this->redisClient->multi() - ->rpush($this->redisKey, $record["formatted"]) - ->ltrim($this->redisKey, -$this->capSize, -1) - ->exec(); - } else { - $redisKey = $this->redisKey; - $capSize = $this->capSize; - $this->redisClient->transaction(function ($tx) use ($record, $redisKey, $capSize) { - $tx->rpush($redisKey, $record["formatted"]); - $tx->ltrim($redisKey, -$capSize, -1); - }); - } - } - - /** - * {@inheritDoc} - */ - protected function getDefaultFormatter() - { - return new LineFormatter(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php deleted file mode 100644 index e11d46422..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/RollbarHandler.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use RollbarNotifier; -use Exception; -use Monolog\Logger; - -/** - * Sends errors to Rollbar - * - * If the context data contains a `payload` key, that is used as an array - * of payload options to RollbarNotifier's report_message/report_exception methods. - * - * @author Paul Statezny - */ -class RollbarHandler extends AbstractProcessingHandler -{ - /** - * Rollbar notifier - * - * @var RollbarNotifier - */ - protected $rollbarNotifier; - - /** - * Records whether any log records have been added since the last flush of the rollbar notifier - * - * @var bool - */ - private $hasRecords = false; - - /** - * @param RollbarNotifier $rollbarNotifier RollbarNotifier object constructed with valid token - * @param int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct(RollbarNotifier $rollbarNotifier, $level = Logger::ERROR, $bubble = true) - { - $this->rollbarNotifier = $rollbarNotifier; - - parent::__construct($level, $bubble); - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - if (isset($record['context']['exception']) && $record['context']['exception'] instanceof Exception) { - $context = $record['context']; - $exception = $context['exception']; - unset($context['exception']); - - $payload = array(); - if (isset($context['payload'])) { - $payload = $context['payload']; - unset($context['payload']); - } - - $this->rollbarNotifier->report_exception($exception, $context, $payload); - } else { - $extraData = array( - 'level' => $record['level'], - 'channel' => $record['channel'], - 'datetime' => $record['datetime']->format('U'), - ); - - $context = $record['context']; - $payload = array(); - if (isset($context['payload'])) { - $payload = $context['payload']; - unset($context['payload']); - } - - $this->rollbarNotifier->report_message( - $record['message'], - $record['level_name'], - array_merge($record['context'], $record['extra'], $extraData), - $payload - ); - } - - $this->hasRecords = true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - if ($this->hasRecords) { - $this->rollbarNotifier->flush(); - $this->hasRecords = false; - } - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php deleted file mode 100644 index 3b60b3d15..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php +++ /dev/null @@ -1,178 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Stores logs to files that are rotated every day and a limited number of files are kept. - * - * This rotation is only intended to be used as a workaround. Using logrotate to - * handle the rotation is strongly encouraged when you can use it. - * - * @author Christophe Coevoet - * @author Jordi Boggiano - */ -class RotatingFileHandler extends StreamHandler -{ - const FILE_PER_DAY = 'Y-m-d'; - const FILE_PER_MONTH = 'Y-m'; - const FILE_PER_YEAR = 'Y'; - - protected $filename; - protected $maxFiles; - protected $mustRotate; - protected $nextRotation; - protected $filenameFormat; - protected $dateFormat; - - /** - * @param string $filename - * @param int $maxFiles The maximal amount of files to keep (0 means unlimited) - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) - * @param Boolean $useLocking Try to lock log file before doing any writes - */ - public function __construct($filename, $maxFiles = 0, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false) - { - $this->filename = $filename; - $this->maxFiles = (int) $maxFiles; - $this->nextRotation = new \DateTime('tomorrow'); - $this->filenameFormat = '{filename}-{date}'; - $this->dateFormat = 'Y-m-d'; - - parent::__construct($this->getTimedFilename(), $level, $bubble, $filePermission, $useLocking); - } - - /** - * {@inheritdoc} - */ - public function close() - { - parent::close(); - - if (true === $this->mustRotate) { - $this->rotate(); - } - } - - public function setFilenameFormat($filenameFormat, $dateFormat) - { - if (!preg_match('{^Y(([/_.-]?m)([/_.-]?d)?)?$}', $dateFormat)) { - trigger_error( - 'Invalid date format - format must be one of '. - 'RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), RotatingFileHandler::FILE_PER_MONTH ("Y-m") '. - 'or RotatingFileHandler::FILE_PER_YEAR ("Y"), or you can set one of the '. - 'date formats using slashes, underscores and/or dots instead of dashes.', - E_USER_DEPRECATED - ); - } - if (substr_count($filenameFormat, '{date}') === 0) { - trigger_error( - 'Invalid filename format - format should contain at least `{date}`, because otherwise rotating is impossible.', - E_USER_DEPRECATED - ); - } - $this->filenameFormat = $filenameFormat; - $this->dateFormat = $dateFormat; - $this->url = $this->getTimedFilename(); - $this->close(); - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - // on the first record written, if the log is new, we should rotate (once per day) - if (null === $this->mustRotate) { - $this->mustRotate = !file_exists($this->url); - } - - if ($this->nextRotation < $record['datetime']) { - $this->mustRotate = true; - $this->close(); - } - - parent::write($record); - } - - /** - * Rotates the files. - */ - protected function rotate() - { - // update filename - $this->url = $this->getTimedFilename(); - $this->nextRotation = new \DateTime('tomorrow'); - - // skip GC of old logs if files are unlimited - if (0 === $this->maxFiles) { - return; - } - - $logFiles = glob($this->getGlobPattern()); - if ($this->maxFiles >= count($logFiles)) { - // no files to remove - return; - } - - // Sorting the files by name to remove the older ones - usort($logFiles, function ($a, $b) { - return strcmp($b, $a); - }); - - foreach (array_slice($logFiles, $this->maxFiles) as $file) { - if (is_writable($file)) { - // suppress errors here as unlink() might fail if two processes - // are cleaning up/rotating at the same time - set_error_handler(function ($errno, $errstr, $errfile, $errline) {}); - unlink($file); - restore_error_handler(); - } - } - - $this->mustRotate = false; - } - - protected function getTimedFilename() - { - $fileInfo = pathinfo($this->filename); - $timedFilename = str_replace( - array('{filename}', '{date}'), - array($fileInfo['filename'], date($this->dateFormat)), - $fileInfo['dirname'] . '/' . $this->filenameFormat - ); - - if (!empty($fileInfo['extension'])) { - $timedFilename .= '.'.$fileInfo['extension']; - } - - return $timedFilename; - } - - protected function getGlobPattern() - { - $fileInfo = pathinfo($this->filename); - $glob = str_replace( - array('{filename}', '{date}'), - array($fileInfo['filename'], '*'), - $fileInfo['dirname'] . '/' . $this->filenameFormat - ); - if (!empty($fileInfo['extension'])) { - $glob .= '.'.$fileInfo['extension']; - } - - return $glob; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php deleted file mode 100644 index 9509ae378..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/SamplingHandler.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -/** - * Sampling handler - * - * A sampled event stream can be useful for logging high frequency events in - * a production environment where you only need an idea of what is happening - * and are not concerned with capturing every occurrence. Since the decision to - * handle or not handle a particular event is determined randomly, the - * resulting sampled log is not guaranteed to contain 1/N of the events that - * occurred in the application, but based on the Law of large numbers, it will - * tend to be close to this ratio with a large number of attempts. - * - * @author Bryan Davis - * @author Kunal Mehta - */ -class SamplingHandler extends AbstractHandler -{ - /** - * @var callable|HandlerInterface $handler - */ - protected $handler; - - /** - * @var int $factor - */ - protected $factor; - - /** - * @param callable|HandlerInterface $handler Handler or factory callable($record, $fingersCrossedHandler). - * @param int $factor Sample factor - */ - public function __construct($handler, $factor) - { - parent::__construct(); - $this->handler = $handler; - $this->factor = $factor; - - if (!$this->handler instanceof HandlerInterface && !is_callable($this->handler)) { - throw new \RuntimeException("The given handler (".json_encode($this->handler).") is not a callable nor a Monolog\Handler\HandlerInterface object"); - } - } - - public function isHandling(array $record) - { - return $this->handler->isHandling($record); - } - - public function handle(array $record) - { - if ($this->isHandling($record) && mt_rand(1, $this->factor) === 1) { - // The same logic as in FingersCrossedHandler - if (!$this->handler instanceof HandlerInterface) { - $this->handler = call_user_func($this->handler, $record, $this); - if (!$this->handler instanceof HandlerInterface) { - throw new \RuntimeException("The factory callable should return a HandlerInterface"); - } - } - - if ($this->processors) { - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); - } - } - - $this->handler->handle($record); - } - - return false === $this->bubble; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php deleted file mode 100644 index 3de2576a0..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/SlackHandler.php +++ /dev/null @@ -1,295 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; - -/** - * Sends notifications through Slack API - * - * @author Greg Kedzierski - * @see https://api.slack.com/ - */ -class SlackHandler extends SocketHandler -{ - /** - * Slack API token - * @var string - */ - private $token; - - /** - * Slack channel (encoded ID or name) - * @var string - */ - private $channel; - - /** - * Name of a bot - * @var string - */ - private $username; - - /** - * Emoji icon name - * @var string - */ - private $iconEmoji; - - /** - * Whether the message should be added to Slack as attachment (plain text otherwise) - * @var bool - */ - private $useAttachment; - - /** - * Whether the the context/extra messages added to Slack as attachments are in a short style - * @var bool - */ - private $useShortAttachment; - - /** - * Whether the attachment should include context and extra data - * @var bool - */ - private $includeContextAndExtra; - - /** - * @var LineFormatter - */ - private $lineFormatter; - - /** - * @param string $token Slack API token - * @param string $channel Slack channel (encoded ID or name) - * @param string $username Name of a bot - * @param bool $useAttachment Whether the message should be added to Slack as attachment (plain text otherwise) - * @param string|null $iconEmoji The emoji name to use (or null) - * @param int $level The minimum logging level at which this handler will be triggered - * @param bool $bubble Whether the messages that are handled can bubble up the stack or not - * @param bool $useShortAttachment Whether the the context/extra messages added to Slack as attachments are in a short style - * @param bool $includeContextAndExtra Whether the attachment should include context and extra data - * @throws MissingExtensionException If no OpenSSL PHP extension configured - */ - public function __construct($token, $channel, $username = 'Monolog', $useAttachment = true, $iconEmoji = null, $level = Logger::CRITICAL, $bubble = true, $useShortAttachment = false, $includeContextAndExtra = false) - { - if (!extension_loaded('openssl')) { - throw new MissingExtensionException('The OpenSSL PHP extension is required to use the SlackHandler'); - } - - parent::__construct('ssl://slack.com:443', $level, $bubble); - - $this->token = $token; - $this->channel = $channel; - $this->username = $username; - $this->iconEmoji = trim($iconEmoji, ':'); - $this->useAttachment = $useAttachment; - $this->useShortAttachment = $useShortAttachment; - $this->includeContextAndExtra = $includeContextAndExtra; - - if ($this->includeContextAndExtra && $this->useShortAttachment) { - $this->lineFormatter = new LineFormatter; - } - } - - /** - * {@inheritdoc} - * - * @param array $record - * @return string - */ - protected function generateDataStream($record) - { - $content = $this->buildContent($record); - - return $this->buildHeader($content) . $content; - } - - /** - * Builds the body of API call - * - * @param array $record - * @return string - */ - private function buildContent($record) - { - $dataArray = $this->prepareContentData($record); - - return http_build_query($dataArray); - } - - /** - * Prepares content data - * - * @param array $record - * @return array - */ - protected function prepareContentData($record) - { - $dataArray = array( - 'token' => $this->token, - 'channel' => $this->channel, - 'username' => $this->username, - 'text' => '', - 'attachments' => array(), - ); - - if ($this->formatter) { - $message = $this->formatter->format($record); - } else { - $message = $record['message']; - } - - if ($this->useAttachment) { - $attachment = array( - 'fallback' => $message, - 'color' => $this->getAttachmentColor($record['level']), - 'fields' => array(), - ); - - if ($this->useShortAttachment) { - $attachment['title'] = $record['level_name']; - $attachment['text'] = $message; - } else { - $attachment['title'] = 'Message'; - $attachment['text'] = $message; - $attachment['fields'][] = array( - 'title' => 'Level', - 'value' => $record['level_name'], - 'short' => true, - ); - } - - if ($this->includeContextAndExtra) { - if (!empty($record['extra'])) { - if ($this->useShortAttachment) { - $attachment['fields'][] = array( - 'title' => "Extra", - 'value' => $this->stringify($record['extra']), - 'short' => $this->useShortAttachment, - ); - } else { - // Add all extra fields as individual fields in attachment - foreach ($record['extra'] as $var => $val) { - $attachment['fields'][] = array( - 'title' => $var, - 'value' => $val, - 'short' => $this->useShortAttachment, - ); - } - } - } - - if (!empty($record['context'])) { - if ($this->useShortAttachment) { - $attachment['fields'][] = array( - 'title' => "Context", - 'value' => $this->stringify($record['context']), - 'short' => $this->useShortAttachment, - ); - } else { - // Add all context fields as individual fields in attachment - foreach ($record['context'] as $var => $val) { - $attachment['fields'][] = array( - 'title' => $var, - 'value' => $val, - 'short' => $this->useShortAttachment, - ); - } - } - } - } - - $dataArray['attachments'] = json_encode(array($attachment)); - } else { - $dataArray['text'] = $message; - } - - if ($this->iconEmoji) { - $dataArray['icon_emoji'] = ":{$this->iconEmoji}:"; - } - - return $dataArray; - } - - /** - * Builds the header of the API Call - * - * @param string $content - * @return string - */ - private function buildHeader($content) - { - $header = "POST /api/chat.postMessage HTTP/1.1\r\n"; - $header .= "Host: slack.com\r\n"; - $header .= "Content-Type: application/x-www-form-urlencoded\r\n"; - $header .= "Content-Length: " . strlen($content) . "\r\n"; - $header .= "\r\n"; - - return $header; - } - - /** - * {@inheritdoc} - * - * @param array $record - */ - protected function write(array $record) - { - parent::write($record); - $res = $this->getResource(); - if (is_resource($res)) { - @fread($res, 2048); - } - $this->closeSocket(); - } - - /** - * Returned a Slack message attachment color associated with - * provided level. - * - * @param int $level - * @return string - */ - protected function getAttachmentColor($level) - { - switch (true) { - case $level >= Logger::ERROR: - return 'danger'; - case $level >= Logger::WARNING: - return 'warning'; - case $level >= Logger::INFO: - return 'good'; - default: - return '#e3e4e6'; - } - } - - /** - * Stringifies an array of key/value pairs to be used in attachment fields - * - * @param array $fields - * @return string - */ - protected function stringify($fields) - { - $string = ''; - foreach ($fields as $var => $val) { - $string .= $var.': '.$this->lineFormatter->stringify($val)." | "; - } - - $string = rtrim($string, " |"); - - return $string; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php deleted file mode 100644 index 7a61bf4e0..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/SocketHandler.php +++ /dev/null @@ -1,346 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Stores to any socket - uses fsockopen() or pfsockopen(). - * - * @author Pablo de Leon Belloc - * @see http://php.net/manual/en/function.fsockopen.php - */ -class SocketHandler extends AbstractProcessingHandler -{ - private $connectionString; - private $connectionTimeout; - private $resource; - private $timeout = 0; - private $writingTimeout = 10; - private $lastSentBytes = null; - private $persistent = false; - private $errno; - private $errstr; - private $lastWritingAt; - - /** - * @param string $connectionString Socket connection string - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($connectionString, $level = Logger::DEBUG, $bubble = true) - { - parent::__construct($level, $bubble); - $this->connectionString = $connectionString; - $this->connectionTimeout = (float) ini_get('default_socket_timeout'); - } - - /** - * Connect (if necessary) and write to the socket - * - * @param array $record - * - * @throws \UnexpectedValueException - * @throws \RuntimeException - */ - protected function write(array $record) - { - $this->connectIfNotConnected(); - $data = $this->generateDataStream($record); - $this->writeToSocket($data); - } - - /** - * We will not close a PersistentSocket instance so it can be reused in other requests. - */ - public function close() - { - if (!$this->isPersistent()) { - $this->closeSocket(); - } - } - - /** - * Close socket, if open - */ - public function closeSocket() - { - if (is_resource($this->resource)) { - fclose($this->resource); - $this->resource = null; - } - } - - /** - * Set socket connection to nbe persistent. It only has effect before the connection is initiated. - * - * @param bool $persistent - */ - public function setPersistent($persistent) - { - $this->persistent = (boolean) $persistent; - } - - /** - * Set connection timeout. Only has effect before we connect. - * - * @param float $seconds - * - * @see http://php.net/manual/en/function.fsockopen.php - */ - public function setConnectionTimeout($seconds) - { - $this->validateTimeout($seconds); - $this->connectionTimeout = (float) $seconds; - } - - /** - * Set write timeout. Only has effect before we connect. - * - * @param float $seconds - * - * @see http://php.net/manual/en/function.stream-set-timeout.php - */ - public function setTimeout($seconds) - { - $this->validateTimeout($seconds); - $this->timeout = (float) $seconds; - } - - /** - * Set writing timeout. Only has effect during connection in the writing cycle. - * - * @param float $seconds 0 for no timeout - */ - public function setWritingTimeout($seconds) - { - $this->validateTimeout($seconds); - $this->writingTimeout = (float) $seconds; - } - - /** - * Get current connection string - * - * @return string - */ - public function getConnectionString() - { - return $this->connectionString; - } - - /** - * Get persistent setting - * - * @return bool - */ - public function isPersistent() - { - return $this->persistent; - } - - /** - * Get current connection timeout setting - * - * @return float - */ - public function getConnectionTimeout() - { - return $this->connectionTimeout; - } - - /** - * Get current in-transfer timeout - * - * @return float - */ - public function getTimeout() - { - return $this->timeout; - } - - /** - * Get current local writing timeout - * - * @return float - */ - public function getWritingTimeout() - { - return $this->writingTimeout; - } - - /** - * Check to see if the socket is currently available. - * - * UDP might appear to be connected but might fail when writing. See http://php.net/fsockopen for details. - * - * @return bool - */ - public function isConnected() - { - return is_resource($this->resource) - && !feof($this->resource); // on TCP - other party can close connection. - } - - /** - * Wrapper to allow mocking - */ - protected function pfsockopen() - { - return @pfsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout); - } - - /** - * Wrapper to allow mocking - */ - protected function fsockopen() - { - return @fsockopen($this->connectionString, -1, $this->errno, $this->errstr, $this->connectionTimeout); - } - - /** - * Wrapper to allow mocking - * - * @see http://php.net/manual/en/function.stream-set-timeout.php - */ - protected function streamSetTimeout() - { - $seconds = floor($this->timeout); - $microseconds = round(($this->timeout - $seconds) * 1e6); - - return stream_set_timeout($this->resource, $seconds, $microseconds); - } - - /** - * Wrapper to allow mocking - */ - protected function fwrite($data) - { - return @fwrite($this->resource, $data); - } - - /** - * Wrapper to allow mocking - */ - protected function streamGetMetadata() - { - return stream_get_meta_data($this->resource); - } - - private function validateTimeout($value) - { - $ok = filter_var($value, FILTER_VALIDATE_FLOAT); - if ($ok === false || $value < 0) { - throw new \InvalidArgumentException("Timeout must be 0 or a positive float (got $value)"); - } - } - - private function connectIfNotConnected() - { - if ($this->isConnected()) { - return; - } - $this->connect(); - } - - protected function generateDataStream($record) - { - return (string) $record['formatted']; - } - - /** - * @return resource|null - */ - protected function getResource() - { - return $this->resource; - } - - private function connect() - { - $this->createSocketResource(); - $this->setSocketTimeout(); - } - - private function createSocketResource() - { - if ($this->isPersistent()) { - $resource = $this->pfsockopen(); - } else { - $resource = $this->fsockopen(); - } - if (!$resource) { - throw new \UnexpectedValueException("Failed connecting to $this->connectionString ($this->errno: $this->errstr)"); - } - $this->resource = $resource; - } - - private function setSocketTimeout() - { - if (!$this->streamSetTimeout()) { - throw new \UnexpectedValueException("Failed setting timeout with stream_set_timeout()"); - } - } - - private function writeToSocket($data) - { - $length = strlen($data); - $sent = 0; - $this->lastSentBytes = $sent; - while ($this->isConnected() && $sent < $length) { - if (0 == $sent) { - $chunk = $this->fwrite($data); - } else { - $chunk = $this->fwrite(substr($data, $sent)); - } - if ($chunk === false) { - throw new \RuntimeException("Could not write to socket"); - } - $sent += $chunk; - $socketInfo = $this->streamGetMetadata(); - if ($socketInfo['timed_out']) { - throw new \RuntimeException("Write timed-out"); - } - - if ($this->writingIsTimedOut($sent)) { - throw new \RuntimeException("Write timed-out, no data sent for `{$this->writingTimeout}` seconds, probably we got disconnected (sent $sent of $length)"); - } - } - if (!$this->isConnected() && $sent < $length) { - throw new \RuntimeException("End-of-file reached, probably we got disconnected (sent $sent of $length)"); - } - } - - private function writingIsTimedOut($sent) - { - $writingTimeout = (int) floor($this->writingTimeout); - if (0 === $writingTimeout) { - return false; - } - - if ($sent !== $this->lastSentBytes) { - $this->lastWritingAt = time(); - $this->lastSentBytes = $sent; - - return false; - } else { - usleep(100); - } - - if ((time() - $this->lastWritingAt) >= $writingTimeout) { - $this->closeSocket(); - - return true; - } - - return false; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php deleted file mode 100644 index b084f1a79..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php +++ /dev/null @@ -1,166 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Stores to any stream resource - * - * Can be used to store into php://stderr, remote and local files, etc. - * - * @author Jordi Boggiano - */ -class StreamHandler extends AbstractProcessingHandler -{ - protected $stream; - protected $url; - private $errorMessage; - protected $filePermission; - protected $useLocking; - private $dirCreated; - - /** - * @param resource|string $stream - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - * @param int|null $filePermission Optional file permissions (default (0644) are only for owner read/write) - * @param Boolean $useLocking Try to lock log file before doing any writes - * - * @throws \Exception If a missing directory is not buildable - * @throws \InvalidArgumentException If stream is not a resource or string - */ - public function __construct($stream, $level = Logger::DEBUG, $bubble = true, $filePermission = null, $useLocking = false) - { - parent::__construct($level, $bubble); - if (is_resource($stream)) { - $this->stream = $stream; - } elseif (is_string($stream)) { - $this->url = $stream; - } else { - throw new \InvalidArgumentException('A stream must either be a resource or a string.'); - } - - $this->filePermission = $filePermission; - $this->useLocking = $useLocking; - } - - /** - * {@inheritdoc} - */ - public function close() - { - if ($this->url && is_resource($this->stream)) { - fclose($this->stream); - } - $this->stream = null; - } - - /** - * Return the currently active stream if it is open - * - * @return resource|null - */ - public function getStream() - { - return $this->stream; - } - - /** - * Return the stream URL if it was configured with a URL and not an active resource - * - * @return string|null - */ - public function getUrl() - { - return $this->url; - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - if (!is_resource($this->stream)) { - if (null === $this->url || '' === $this->url) { - throw new \LogicException('Missing stream url, the stream can not be opened. This may be caused by a premature call to close().'); - } - $this->createDir(); - $this->errorMessage = null; - set_error_handler(array($this, 'customErrorHandler')); - $this->stream = fopen($this->url, 'a'); - if ($this->filePermission !== null) { - @chmod($this->url, $this->filePermission); - } - restore_error_handler(); - if (!is_resource($this->stream)) { - $this->stream = null; - throw new \UnexpectedValueException(sprintf('The stream or file "%s" could not be opened: '.$this->errorMessage, $this->url)); - } - } - - if ($this->useLocking) { - // ignoring errors here, there's not much we can do about them - flock($this->stream, LOCK_EX); - } - - fwrite($this->stream, (string) $record['formatted']); - - if ($this->useLocking) { - flock($this->stream, LOCK_UN); - } - } - - private function customErrorHandler($code, $msg) - { - $this->errorMessage = preg_replace('{^(fopen|mkdir)\(.*?\): }', '', $msg); - } - - /** - * @param string $stream - * - * @return null|string - */ - private function getDirFromStream($stream) - { - $pos = strpos($stream, '://'); - if ($pos === false) { - return dirname($stream); - } - - if ('file://' === substr($stream, 0, 7)) { - return dirname(substr($stream, 7)); - } - - return; - } - - private function createDir() - { - // Do not try to create dir if it has already been tried. - if ($this->dirCreated) { - return; - } - - $dir = $this->getDirFromStream($this->url); - if (null !== $dir && !is_dir($dir)) { - $this->errorMessage = null; - set_error_handler(array($this, 'customErrorHandler')); - $status = mkdir($dir, 0777, true); - restore_error_handler(); - if (false === $status) { - throw new \UnexpectedValueException(sprintf('There is no existing directory at "%s" and its not buildable: '.$this->errorMessage, $dir)); - } - } - $this->dirCreated = true; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php deleted file mode 100644 index aba139679..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/SwiftMailerHandler.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; - -/** - * SwiftMailerHandler uses Swift_Mailer to send the emails - * - * @author Gyula Sallai - */ -class SwiftMailerHandler extends MailHandler -{ - protected $mailer; - private $messageTemplate; - - /** - * @param \Swift_Mailer $mailer The mailer to use - * @param callable|\Swift_Message $message An example message for real messages, only the body will be replaced - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct(\Swift_Mailer $mailer, $message, $level = Logger::ERROR, $bubble = true) - { - parent::__construct($level, $bubble); - - $this->mailer = $mailer; - $this->messageTemplate = $message; - } - - /** - * {@inheritdoc} - */ - protected function send($content, array $records) - { - $this->mailer->send($this->buildMessage($content, $records)); - } - - /** - * Creates instance of Swift_Message to be sent - * - * @param string $content formatted email body to be sent - * @param array $records Log records that formed the content - * @return \Swift_Message - */ - protected function buildMessage($content, array $records) - { - $message = null; - if ($this->messageTemplate instanceof \Swift_Message) { - $message = clone $this->messageTemplate; - $message->generateId(); - } elseif (is_callable($this->messageTemplate)) { - $message = call_user_func($this->messageTemplate, $content, $records); - } - - if (!$message instanceof \Swift_Message) { - throw new \InvalidArgumentException('Could not resolve message as instance of Swift_Message or a callable returning it'); - } - - if ($records) { - $subjectFormatter = new LineFormatter($message->getSubject()); - $message->setSubject($subjectFormatter->format($this->getHighestRecord($records))); - } - - $message->setBody($content); - $message->setDate(time()); - - return $message; - } - - /** - * BC getter, to be removed in 2.0 - */ - public function __get($name) - { - if ($name === 'message') { - trigger_error('SwiftMailerHandler->message is deprecated, use ->buildMessage() instead to retrieve the message', E_USER_DEPRECATED); - - return $this->buildMessage(null, array()); - } - - throw new \InvalidArgumentException('Invalid property '.$name); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php deleted file mode 100644 index 376bc3b24..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/SyslogHandler.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -/** - * Logs to syslog service. - * - * usage example: - * - * $log = new Logger('application'); - * $syslog = new SyslogHandler('myfacility', 'local6'); - * $formatter = new LineFormatter("%channel%.%level_name%: %message% %extra%"); - * $syslog->setFormatter($formatter); - * $log->pushHandler($syslog); - * - * @author Sven Paulus - */ -class SyslogHandler extends AbstractSyslogHandler -{ - protected $ident; - protected $logopts; - - /** - * @param string $ident - * @param mixed $facility - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - * @param int $logopts Option flags for the openlog() call, defaults to LOG_PID - */ - public function __construct($ident, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true, $logopts = LOG_PID) - { - parent::__construct($facility, $level, $bubble); - - $this->ident = $ident; - $this->logopts = $logopts; - } - - /** - * {@inheritdoc} - */ - public function close() - { - closelog(); - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - if (!openlog($this->ident, $this->logopts, $this->facility)) { - throw new \LogicException('Can\'t open syslog for ident "'.$this->ident.'" and facility "'.$this->facility.'"'); - } - syslog($this->logLevels[$record['level']], (string) $record['formatted']); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php b/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php deleted file mode 100644 index 3bff085bf..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdp/UdpSocket.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler\SyslogUdp; - -class UdpSocket -{ - const DATAGRAM_MAX_LENGTH = 65023; - - protected $ip; - protected $port; - protected $socket; - - public function __construct($ip, $port = 514) - { - $this->ip = $ip; - $this->port = $port; - $this->socket = socket_create(AF_INET, SOCK_DGRAM, SOL_UDP); - } - - public function write($line, $header = "") - { - $this->send($this->assembleMessage($line, $header)); - } - - public function close() - { - if (is_resource($this->socket)) { - socket_close($this->socket); - $this->socket = null; - } - } - - protected function send($chunk) - { - if (!is_resource($this->socket)) { - throw new \LogicException('The UdpSocket to '.$this->ip.':'.$this->port.' has been closed and can not be written to anymore'); - } - socket_sendto($this->socket, $chunk, strlen($chunk), $flags = 0, $this->ip, $this->port); - } - - protected function assembleMessage($line, $header) - { - $chunkSize = self::DATAGRAM_MAX_LENGTH - strlen($header); - - return $header . substr($line, 0, $chunkSize); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php deleted file mode 100644 index b175cc3af..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/SyslogUdpHandler.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\Handler\SyslogUdp\UdpSocket; - -/** - * A Handler for logging to a remote syslogd server. - * - * @author Jesper Skovgaard Nielsen - */ -class SyslogUdpHandler extends AbstractSyslogHandler -{ - protected $socket; - - /** - * @param string $host - * @param int $port - * @param mixed $facility - * @param int $level The minimum logging level at which this handler will be triggered - * @param Boolean $bubble Whether the messages that are handled can bubble up the stack or not - */ - public function __construct($host, $port = 514, $facility = LOG_USER, $level = Logger::DEBUG, $bubble = true) - { - parent::__construct($facility, $level, $bubble); - - $this->socket = new UdpSocket($host, $port ?: 514); - } - - protected function write(array $record) - { - $lines = $this->splitMessageIntoLines($record['formatted']); - - $header = $this->makeCommonSyslogHeader($this->logLevels[$record['level']]); - - foreach ($lines as $line) { - $this->socket->write($line, $header); - } - } - - public function close() - { - $this->socket->close(); - } - - private function splitMessageIntoLines($message) - { - if (is_array($message)) { - $message = implode("\n", $message); - } - - return preg_split('/$\R?^/m', $message); - } - - /** - * Make common syslog header (see rfc5424) - */ - protected function makeCommonSyslogHeader($severity) - { - $priority = $severity + $this->facility; - - return "<$priority>1 "; - } - - /** - * Inject your own socket, mainly used for testing - */ - public function setSocket($socket) - { - $this->socket = $socket; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php deleted file mode 100644 index 458020b62..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/TestHandler.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -/** - * Used for testing purposes. - * - * It records all records and gives you access to them for verification. - * - * @author Jordi Boggiano - * - * @method bool hasEmergency($record) - * @method bool hasAlert($record) - * @method bool hasCritical($record) - * @method bool hasError($record) - * @method bool hasWarning($record) - * @method bool hasNotice($record) - * @method bool hasInfo($record) - * @method bool hasDebug($record) - * - * @method bool hasEmergencyRecords() - * @method bool hasAlertRecords() - * @method bool hasCriticalRecords() - * @method bool hasErrorRecords() - * @method bool hasWarningRecords() - * @method bool hasNoticeRecords() - * @method bool hasInfoRecords() - * @method bool hasDebugRecords() - * - * @method bool hasEmergencyThatContains($message) - * @method bool hasAlertThatContains($message) - * @method bool hasCriticalThatContains($message) - * @method bool hasErrorThatContains($message) - * @method bool hasWarningThatContains($message) - * @method bool hasNoticeThatContains($message) - * @method bool hasInfoThatContains($message) - * @method bool hasDebugThatContains($message) - * - * @method bool hasEmergencyThatMatches($message) - * @method bool hasAlertThatMatches($message) - * @method bool hasCriticalThatMatches($message) - * @method bool hasErrorThatMatches($message) - * @method bool hasWarningThatMatches($message) - * @method bool hasNoticeThatMatches($message) - * @method bool hasInfoThatMatches($message) - * @method bool hasDebugThatMatches($message) - * - * @method bool hasEmergencyThatPasses($message) - * @method bool hasAlertThatPasses($message) - * @method bool hasCriticalThatPasses($message) - * @method bool hasErrorThatPasses($message) - * @method bool hasWarningThatPasses($message) - * @method bool hasNoticeThatPasses($message) - * @method bool hasInfoThatPasses($message) - * @method bool hasDebugThatPasses($message) - */ -class TestHandler extends AbstractProcessingHandler -{ - protected $records = array(); - protected $recordsByLevel = array(); - - public function getRecords() - { - return $this->records; - } - - public function clear() - { - $this->records = array(); - $this->recordsByLevel = array(); - } - - protected function hasRecordRecords($level) - { - return isset($this->recordsByLevel[$level]); - } - - protected function hasRecord($record, $level) - { - if (is_array($record)) { - $record = $record['message']; - } - - return $this->hasRecordThatPasses(function ($rec) use ($record) { - return $rec['message'] === $record; - }, $level); - } - - public function hasRecordThatContains($message, $level) - { - return $this->hasRecordThatPasses(function ($rec) use ($message) { - return strpos($rec['message'], $message) !== false; - }, $level); - } - - public function hasRecordThatMatches($regex, $level) - { - return $this->hasRecordThatPasses(function ($rec) use ($regex) { - return preg_match($regex, $rec['message']) > 0; - }, $level); - } - - public function hasRecordThatPasses($predicate, $level) - { - if (!is_callable($predicate)) { - throw new \InvalidArgumentException("Expected a callable for hasRecordThatSucceeds"); - } - - if (!isset($this->recordsByLevel[$level])) { - return false; - } - - foreach ($this->recordsByLevel[$level] as $i => $rec) { - if (call_user_func($predicate, $rec, $i)) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - $this->recordsByLevel[$record['level']][] = $record; - $this->records[] = $record; - } - - public function __call($method, $args) - { - if (preg_match('/(.*)(Debug|Info|Notice|Warning|Error|Critical|Alert|Emergency)(.*)/', $method, $matches) > 0) { - $genericMethod = $matches[1] . 'Record' . $matches[3]; - $level = constant('Monolog\Logger::' . strtoupper($matches[2])); - if (method_exists($this, $genericMethod)) { - $args[] = $level; - - return call_user_func_array(array($this, $genericMethod), $args); - } - } - - throw new \BadMethodCallException('Call to undefined method ' . get_class($this) . '::' . $method . '()'); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php deleted file mode 100644 index 2732ba3d6..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/WhatFailureGroupHandler.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -/** - * Forwards records to multiple handlers suppressing failures of each handler - * and continuing through to give every handler a chance to succeed. - * - * @author Craig D'Amelio - */ -class WhatFailureGroupHandler extends GroupHandler -{ - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - if ($this->processors) { - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); - } - } - - foreach ($this->handlers as $handler) { - try { - $handler->handle($record); - } catch (\Exception $e) { - // What failure? - } catch (\Throwable $e) { - // What failure? - } - } - - return false === $this->bubble; - } - - /** - * {@inheritdoc} - */ - public function handleBatch(array $records) - { - foreach ($this->handlers as $handler) { - try { - $handler->handleBatch($records); - } catch (\Exception $e) { - // What failure? - } catch (\Throwable $e) { - // What failure? - } - } - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php b/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php deleted file mode 100644 index f22cf2187..000000000 --- a/vendor/monolog/monolog/src/Monolog/Handler/ZendMonitorHandler.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\NormalizerFormatter; -use Monolog\Logger; - -/** - * Handler sending logs to Zend Monitor - * - * @author Christian Bergau - */ -class ZendMonitorHandler extends AbstractProcessingHandler -{ - /** - * Monolog level / ZendMonitor Custom Event priority map - * - * @var array - */ - protected $levelMap = array( - Logger::DEBUG => 1, - Logger::INFO => 2, - Logger::NOTICE => 3, - Logger::WARNING => 4, - Logger::ERROR => 5, - Logger::CRITICAL => 6, - Logger::ALERT => 7, - Logger::EMERGENCY => 0, - ); - - /** - * Construct - * - * @param int $level - * @param bool $bubble - * @throws MissingExtensionException - */ - public function __construct($level = Logger::DEBUG, $bubble = true) - { - if (!function_exists('zend_monitor_custom_event')) { - throw new MissingExtensionException('You must have Zend Server installed in order to use this handler'); - } - parent::__construct($level, $bubble); - } - - /** - * {@inheritdoc} - */ - protected function write(array $record) - { - $this->writeZendMonitorCustomEvent( - $this->levelMap[$record['level']], - $record['message'], - $record['formatted'] - ); - } - - /** - * Write a record to Zend Monitor - * - * @param int $level - * @param string $message - * @param array $formatted - */ - protected function writeZendMonitorCustomEvent($level, $message, $formatted) - { - zend_monitor_custom_event($level, $message, $formatted); - } - - /** - * {@inheritdoc} - */ - public function getDefaultFormatter() - { - return new NormalizerFormatter(); - } - - /** - * Get the level map - * - * @return array - */ - public function getLevelMap() - { - return $this->levelMap; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Logger.php b/vendor/monolog/monolog/src/Monolog/Logger.php deleted file mode 100644 index 2fbc02c79..000000000 --- a/vendor/monolog/monolog/src/Monolog/Logger.php +++ /dev/null @@ -1,699 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog; - -use Monolog\Handler\HandlerInterface; -use Monolog\Handler\StreamHandler; -use Psr\Log\LoggerInterface; -use Psr\Log\InvalidArgumentException; - -/** - * Monolog log channel - * - * It contains a stack of Handlers and a stack of Processors, - * and uses them to store records that are added to it. - * - * @author Jordi Boggiano - */ -class Logger implements LoggerInterface -{ - /** - * Detailed debug information - */ - const DEBUG = 100; - - /** - * Interesting events - * - * Examples: User logs in, SQL logs. - */ - const INFO = 200; - - /** - * Uncommon events - */ - const NOTICE = 250; - - /** - * Exceptional occurrences that are not errors - * - * Examples: Use of deprecated APIs, poor use of an API, - * undesirable things that are not necessarily wrong. - */ - const WARNING = 300; - - /** - * Runtime errors - */ - const ERROR = 400; - - /** - * Critical conditions - * - * Example: Application component unavailable, unexpected exception. - */ - const CRITICAL = 500; - - /** - * Action must be taken immediately - * - * Example: Entire website down, database unavailable, etc. - * This should trigger the SMS alerts and wake you up. - */ - const ALERT = 550; - - /** - * Urgent alert. - */ - const EMERGENCY = 600; - - /** - * Monolog API version - * - * This is only bumped when API breaks are done and should - * follow the major version of the library - * - * @var int - */ - const API = 1; - - /** - * Logging levels from syslog protocol defined in RFC 5424 - * - * @var array $levels Logging levels - */ - protected static $levels = array( - self::DEBUG => 'DEBUG', - self::INFO => 'INFO', - self::NOTICE => 'NOTICE', - self::WARNING => 'WARNING', - self::ERROR => 'ERROR', - self::CRITICAL => 'CRITICAL', - self::ALERT => 'ALERT', - self::EMERGENCY => 'EMERGENCY', - ); - - /** - * @var \DateTimeZone - */ - protected static $timezone; - - /** - * @var string - */ - protected $name; - - /** - * The handler stack - * - * @var HandlerInterface[] - */ - protected $handlers; - - /** - * Processors that will process all log records - * - * To process records of a single handler instead, add the processor on that specific handler - * - * @var callable[] - */ - protected $processors; - - /** - * @var bool - */ - protected $microsecondTimestamps = true; - - /** - * @param string $name The logging channel - * @param HandlerInterface[] $handlers Optional stack of handlers, the first one in the array is called first, etc. - * @param callable[] $processors Optional array of processors - */ - public function __construct($name, array $handlers = array(), array $processors = array()) - { - $this->name = $name; - $this->handlers = $handlers; - $this->processors = $processors; - } - - /** - * @return string - */ - public function getName() - { - return $this->name; - } - - /** - * Return a new cloned instance with the name changed - * - * @return static - */ - public function withName($name) - { - $new = clone $this; - $new->name = $name; - - return $new; - } - - /** - * Pushes a handler on to the stack. - * - * @param HandlerInterface $handler - * @return $this - */ - public function pushHandler(HandlerInterface $handler) - { - array_unshift($this->handlers, $handler); - - return $this; - } - - /** - * Pops a handler from the stack - * - * @return HandlerInterface - */ - public function popHandler() - { - if (!$this->handlers) { - throw new \LogicException('You tried to pop from an empty handler stack.'); - } - - return array_shift($this->handlers); - } - - /** - * Set handlers, replacing all existing ones. - * - * If a map is passed, keys will be ignored. - * - * @param HandlerInterface[] $handlers - * @return $this - */ - public function setHandlers(array $handlers) - { - $this->handlers = array(); - foreach (array_reverse($handlers) as $handler) { - $this->pushHandler($handler); - } - - return $this; - } - - /** - * @return HandlerInterface[] - */ - public function getHandlers() - { - return $this->handlers; - } - - /** - * Adds a processor on to the stack. - * - * @param callable $callback - * @return $this - */ - public function pushProcessor($callback) - { - if (!is_callable($callback)) { - throw new \InvalidArgumentException('Processors must be valid callables (callback or object with an __invoke method), '.var_export($callback, true).' given'); - } - array_unshift($this->processors, $callback); - - return $this; - } - - /** - * Removes the processor on top of the stack and returns it. - * - * @return callable - */ - public function popProcessor() - { - if (!$this->processors) { - throw new \LogicException('You tried to pop from an empty processor stack.'); - } - - return array_shift($this->processors); - } - - /** - * @return callable[] - */ - public function getProcessors() - { - return $this->processors; - } - - /** - * Control the use of microsecond resolution timestamps in the 'datetime' - * member of new records. - * - * Generating microsecond resolution timestamps by calling - * microtime(true), formatting the result via sprintf() and then parsing - * the resulting string via \DateTime::createFromFormat() can incur - * a measurable runtime overhead vs simple usage of DateTime to capture - * a second resolution timestamp in systems which generate a large number - * of log events. - * - * @param bool $micro True to use microtime() to create timestamps - */ - public function useMicrosecondTimestamps($micro) - { - $this->microsecondTimestamps = (bool) $micro; - } - - /** - * Adds a log record. - * - * @param int $level The logging level - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addRecord($level, $message, array $context = array()) - { - if (!$this->handlers) { - $this->pushHandler(new StreamHandler('php://stderr', static::DEBUG)); - } - - $levelName = static::getLevelName($level); - - // check if any handler will handle this message so we can return early and save cycles - $handlerKey = null; - reset($this->handlers); - while ($handler = current($this->handlers)) { - if ($handler->isHandling(array('level' => $level))) { - $handlerKey = key($this->handlers); - break; - } - - next($this->handlers); - } - - if (null === $handlerKey) { - return false; - } - - if (!static::$timezone) { - static::$timezone = new \DateTimeZone(date_default_timezone_get() ?: 'UTC'); - } - - if ($this->microsecondTimestamps) { - $ts = \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true)), static::$timezone); - } else { - $ts = new \DateTime(null, static::$timezone); - } - $ts->setTimezone(static::$timezone); - - $record = array( - 'message' => (string) $message, - 'context' => $context, - 'level' => $level, - 'level_name' => $levelName, - 'channel' => $this->name, - 'datetime' => $ts, - 'extra' => array(), - ); - - foreach ($this->processors as $processor) { - $record = call_user_func($processor, $record); - } - - while ($handler = current($this->handlers)) { - if (true === $handler->handle($record)) { - break; - } - - next($this->handlers); - } - - return true; - } - - /** - * Adds a log record at the DEBUG level. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addDebug($message, array $context = array()) - { - return $this->addRecord(static::DEBUG, $message, $context); - } - - /** - * Adds a log record at the INFO level. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addInfo($message, array $context = array()) - { - return $this->addRecord(static::INFO, $message, $context); - } - - /** - * Adds a log record at the NOTICE level. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addNotice($message, array $context = array()) - { - return $this->addRecord(static::NOTICE, $message, $context); - } - - /** - * Adds a log record at the WARNING level. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addWarning($message, array $context = array()) - { - return $this->addRecord(static::WARNING, $message, $context); - } - - /** - * Adds a log record at the ERROR level. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addError($message, array $context = array()) - { - return $this->addRecord(static::ERROR, $message, $context); - } - - /** - * Adds a log record at the CRITICAL level. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addCritical($message, array $context = array()) - { - return $this->addRecord(static::CRITICAL, $message, $context); - } - - /** - * Adds a log record at the ALERT level. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addAlert($message, array $context = array()) - { - return $this->addRecord(static::ALERT, $message, $context); - } - - /** - * Adds a log record at the EMERGENCY level. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function addEmergency($message, array $context = array()) - { - return $this->addRecord(static::EMERGENCY, $message, $context); - } - - /** - * Gets all supported logging levels. - * - * @return array Assoc array with human-readable level names => level codes. - */ - public static function getLevels() - { - return array_flip(static::$levels); - } - - /** - * Gets the name of the logging level. - * - * @param int $level - * @return string - */ - public static function getLevelName($level) - { - if (!isset(static::$levels[$level])) { - throw new InvalidArgumentException('Level "'.$level.'" is not defined, use one of: '.implode(', ', array_keys(static::$levels))); - } - - return static::$levels[$level]; - } - - /** - * Converts PSR-3 levels to Monolog ones if necessary - * - * @param string|int Level number (monolog) or name (PSR-3) - * @return int - */ - public static function toMonologLevel($level) - { - if (is_string($level) && defined(__CLASS__.'::'.strtoupper($level))) { - return constant(__CLASS__.'::'.strtoupper($level)); - } - - return $level; - } - - /** - * Checks whether the Logger has a handler that listens on the given level - * - * @param int $level - * @return Boolean - */ - public function isHandling($level) - { - $record = array( - 'level' => $level, - ); - - foreach ($this->handlers as $handler) { - if ($handler->isHandling($record)) { - return true; - } - } - - return false; - } - - /** - * Adds a log record at an arbitrary level. - * - * This method allows for compatibility with common interfaces. - * - * @param mixed $level The log level - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function log($level, $message, array $context = array()) - { - $level = static::toMonologLevel($level); - - return $this->addRecord($level, $message, $context); - } - - /** - * Adds a log record at the DEBUG level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function debug($message, array $context = array()) - { - return $this->addRecord(static::DEBUG, $message, $context); - } - - /** - * Adds a log record at the INFO level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function info($message, array $context = array()) - { - return $this->addRecord(static::INFO, $message, $context); - } - - /** - * Adds a log record at the NOTICE level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function notice($message, array $context = array()) - { - return $this->addRecord(static::NOTICE, $message, $context); - } - - /** - * Adds a log record at the WARNING level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function warn($message, array $context = array()) - { - return $this->addRecord(static::WARNING, $message, $context); - } - - /** - * Adds a log record at the WARNING level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function warning($message, array $context = array()) - { - return $this->addRecord(static::WARNING, $message, $context); - } - - /** - * Adds a log record at the ERROR level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function err($message, array $context = array()) - { - return $this->addRecord(static::ERROR, $message, $context); - } - - /** - * Adds a log record at the ERROR level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function error($message, array $context = array()) - { - return $this->addRecord(static::ERROR, $message, $context); - } - - /** - * Adds a log record at the CRITICAL level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function crit($message, array $context = array()) - { - return $this->addRecord(static::CRITICAL, $message, $context); - } - - /** - * Adds a log record at the CRITICAL level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function critical($message, array $context = array()) - { - return $this->addRecord(static::CRITICAL, $message, $context); - } - - /** - * Adds a log record at the ALERT level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function alert($message, array $context = array()) - { - return $this->addRecord(static::ALERT, $message, $context); - } - - /** - * Adds a log record at the EMERGENCY level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function emerg($message, array $context = array()) - { - return $this->addRecord(static::EMERGENCY, $message, $context); - } - - /** - * Adds a log record at the EMERGENCY level. - * - * This method allows for compatibility with common interfaces. - * - * @param string $message The log message - * @param array $context The log context - * @return Boolean Whether the record has been processed - */ - public function emergency($message, array $context = array()) - { - return $this->addRecord(static::EMERGENCY, $message, $context); - } - - /** - * Set the timezone to be used for the timestamp of log records. - * - * This is stored globally for all Logger instances - * - * @param \DateTimeZone $tz Timezone object - */ - public static function setTimezone(\DateTimeZone $tz) - { - self::$timezone = $tz; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php deleted file mode 100644 index 1899400dc..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/GitProcessor.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\Logger; - -/** - * Injects Git branch and Git commit SHA in all records - * - * @author Nick Otter - * @author Jordi Boggiano - */ -class GitProcessor -{ - private $level; - private static $cache; - - public function __construct($level = Logger::DEBUG) - { - $this->level = Logger::toMonologLevel($level); - } - - /** - * @param array $record - * @return array - */ - public function __invoke(array $record) - { - // return if the level is not high enough - if ($record['level'] < $this->level) { - return $record; - } - - $record['extra']['git'] = self::getGitInfo(); - - return $record; - } - - private static function getGitInfo() - { - if (self::$cache) { - return self::$cache; - } - - $branches = `git branch -v --no-abbrev`; - if (preg_match('{^\* (.+?)\s+([a-f0-9]{40})(?:\s|$)}m', $branches, $matches)) { - return self::$cache = array( - 'branch' => $matches[1], - 'commit' => $matches[2], - ); - } - - return self::$cache = array(); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php deleted file mode 100644 index 2691630af..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/IntrospectionProcessor.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\Logger; - -/** - * Injects line/file:class/function where the log message came from - * - * Warning: This only works if the handler processes the logs directly. - * If you put the processor on a handler that is behind a FingersCrossedHandler - * for example, the processor will only be called once the trigger level is reached, - * and all the log records will have the same file/line/.. data from the call that - * triggered the FingersCrossedHandler. - * - * @author Jordi Boggiano - */ -class IntrospectionProcessor -{ - private $level; - - private $skipClassesPartials; - - private $skipStackFramesCount; - - private $skipFunctions = array( - 'call_user_func', - 'call_user_func_array', - ); - - public function __construct($level = Logger::DEBUG, array $skipClassesPartials = array(), $skipStackFramesCount = 0) - { - $this->level = Logger::toMonologLevel($level); - $this->skipClassesPartials = array_merge(array('Monolog\\'), $skipClassesPartials); - $this->skipStackFramesCount = $skipStackFramesCount; - } - - /** - * @param array $record - * @return array - */ - public function __invoke(array $record) - { - // return if the level is not high enough - if ($record['level'] < $this->level) { - return $record; - } - - $trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS); - - // skip first since it's always the current method - array_shift($trace); - // the call_user_func call is also skipped - array_shift($trace); - - $i = 0; - - while ($this->isTraceClassOrSkippedFunction($trace, $i)) { - if (isset($trace[$i]['class'])) { - foreach ($this->skipClassesPartials as $part) { - if (strpos($trace[$i]['class'], $part) !== false) { - $i++; - continue 2; - } - } - } elseif (in_array($trace[$i]['function'], $this->skipFunctions)) { - $i++; - continue; - } - - break; - } - - $i += $this->skipStackFramesCount; - - // we should have the call source now - $record['extra'] = array_merge( - $record['extra'], - array( - 'file' => isset($trace[$i - 1]['file']) ? $trace[$i - 1]['file'] : null, - 'line' => isset($trace[$i - 1]['line']) ? $trace[$i - 1]['line'] : null, - 'class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : null, - 'function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : null, - ) - ); - - return $record; - } - - private function isTraceClassOrSkippedFunction(array $trace, $index) - { - if (!isset($trace[$index])) { - return false; - } - - return isset($trace[$index]['class']) || in_array($trace[$index]['function'], $this->skipFunctions); - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php deleted file mode 100644 index 0543e9292..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/MemoryPeakUsageProcessor.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -/** - * Injects memory_get_peak_usage in all records - * - * @see Monolog\Processor\MemoryProcessor::__construct() for options - * @author Rob Jensen - */ -class MemoryPeakUsageProcessor extends MemoryProcessor -{ - /** - * @param array $record - * @return array - */ - public function __invoke(array $record) - { - $bytes = memory_get_peak_usage($this->realUsage); - $formatted = $this->formatBytes($bytes); - - $record['extra']['memory_peak_usage'] = $formatted; - - return $record; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php deleted file mode 100644 index 85f9dc5e7..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/MemoryProcessor.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -/** - * Some methods that are common for all memory processors - * - * @author Rob Jensen - */ -abstract class MemoryProcessor -{ - /** - * @var bool If true, get the real size of memory allocated from system. Else, only the memory used by emalloc() is reported. - */ - protected $realUsage; - - /** - * @var bool If true, then format memory size to human readable string (MB, KB, B depending on size) - */ - protected $useFormatting; - - /** - * @param bool $realUsage Set this to true to get the real size of memory allocated from system. - * @param bool $useFormatting If true, then format memory size to human readable string (MB, KB, B depending on size) - */ - public function __construct($realUsage = true, $useFormatting = true) - { - $this->realUsage = (boolean) $realUsage; - $this->useFormatting = (boolean) $useFormatting; - } - - /** - * Formats bytes into a human readable string if $this->useFormatting is true, otherwise return $bytes as is - * - * @param int $bytes - * @return string|int Formatted string if $this->useFormatting is true, otherwise return $bytes as is - */ - protected function formatBytes($bytes) - { - $bytes = (int) $bytes; - - if (!$this->useFormatting) { - return $bytes; - } - - if ($bytes > 1024 * 1024) { - return round($bytes / 1024 / 1024, 2).' MB'; - } elseif ($bytes > 1024) { - return round($bytes / 1024, 2).' KB'; - } - - return $bytes . ' B'; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php deleted file mode 100644 index 2783d656b..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/MemoryUsageProcessor.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -/** - * Injects memory_get_usage in all records - * - * @see Monolog\Processor\MemoryProcessor::__construct() for options - * @author Rob Jensen - */ -class MemoryUsageProcessor extends MemoryProcessor -{ - /** - * @param array $record - * @return array - */ - public function __invoke(array $record) - { - $bytes = memory_get_usage($this->realUsage); - $formatted = $this->formatBytes($bytes); - - $record['extra']['memory_usage'] = $formatted; - - return $record; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php deleted file mode 100644 index 9d3f5590f..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/ProcessIdProcessor.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -/** - * Adds value of getmypid into records - * - * @author Andreas Hörnicke - */ -class ProcessIdProcessor -{ - /** - * @param array $record - * @return array - */ - public function __invoke(array $record) - { - $record['extra']['process_id'] = getmypid(); - - return $record; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php deleted file mode 100644 index c2686ce5b..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/PsrLogMessageProcessor.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -/** - * Processes a record's message according to PSR-3 rules - * - * It replaces {foo} with the value from $context['foo'] - * - * @author Jordi Boggiano - */ -class PsrLogMessageProcessor -{ - /** - * @param array $record - * @return array - */ - public function __invoke(array $record) - { - if (false === strpos($record['message'], '{')) { - return $record; - } - - $replacements = array(); - foreach ($record['context'] as $key => $val) { - if (is_null($val) || is_scalar($val) || (is_object($val) && method_exists($val, "__toString"))) { - $replacements['{'.$key.'}'] = $val; - } elseif (is_object($val)) { - $replacements['{'.$key.'}'] = '[object '.get_class($val).']'; - } else { - $replacements['{'.$key.'}'] = '['.gettype($val).']'; - } - } - - $record['message'] = strtr($record['message'], $replacements); - - return $record; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php deleted file mode 100644 index 7e2df2acb..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/TagProcessor.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -/** - * Adds a tags array into record - * - * @author Martijn Riemers - */ -class TagProcessor -{ - private $tags; - - public function __construct(array $tags = array()) - { - $this->setTags($tags); - } - - public function addTags(array $tags = array()) - { - $this->tags = array_merge($this->tags, $tags); - } - - public function setTags(array $tags = array()) - { - $this->tags = $tags; - } - - public function __invoke(array $record) - { - $record['extra']['tags'] = $this->tags; - - return $record; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php deleted file mode 100644 index 812707cdb..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/UidProcessor.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -/** - * Adds a unique identifier into records - * - * @author Simon Mönch - */ -class UidProcessor -{ - private $uid; - - public function __construct($length = 7) - { - if (!is_int($length) || $length > 32 || $length < 1) { - throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32'); - } - - $this->uid = substr(hash('md5', uniqid('', true)), 0, $length); - } - - public function __invoke(array $record) - { - $record['extra']['uid'] = $this->uid; - - return $record; - } - - /** - * @return string - */ - public function getUid() - { - return $this->uid; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php b/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php deleted file mode 100644 index ea1d89782..000000000 --- a/vendor/monolog/monolog/src/Monolog/Processor/WebProcessor.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -/** - * Injects url/method and remote IP of the current web request in all records - * - * @author Jordi Boggiano - */ -class WebProcessor -{ - /** - * @var array|\ArrayAccess - */ - protected $serverData; - - /** - * Default fields - * - * Array is structured as [key in record.extra => key in $serverData] - * - * @var array - */ - protected $extraFields = array( - 'url' => 'REQUEST_URI', - 'ip' => 'REMOTE_ADDR', - 'http_method' => 'REQUEST_METHOD', - 'server' => 'SERVER_NAME', - 'referrer' => 'HTTP_REFERER', - ); - - /** - * @param array|\ArrayAccess $serverData Array or object w/ ArrayAccess that provides access to the $_SERVER data - * @param array|null $extraFields Field names and the related key inside $serverData to be added. If not provided it defaults to: url, ip, http_method, server, referrer - */ - public function __construct($serverData = null, array $extraFields = null) - { - if (null === $serverData) { - $this->serverData = &$_SERVER; - } elseif (is_array($serverData) || $serverData instanceof \ArrayAccess) { - $this->serverData = $serverData; - } else { - throw new \UnexpectedValueException('$serverData must be an array or object implementing ArrayAccess.'); - } - - if (null !== $extraFields) { - if (isset($extraFields[0])) { - foreach (array_keys($this->extraFields) as $fieldName) { - if (!in_array($fieldName, $extraFields)) { - unset($this->extraFields[$fieldName]); - } - } - } else { - $this->extraFields = $extraFields; - } - } - } - - /** - * @param array $record - * @return array - */ - public function __invoke(array $record) - { - // skip processing if for some reason request data - // is not present (CLI or wonky SAPIs) - if (!isset($this->serverData['REQUEST_URI'])) { - return $record; - } - - $record['extra'] = $this->appendExtraFields($record['extra']); - - return $record; - } - - /** - * @param string $extraName - * @param string $serverName - * @return $this - */ - public function addExtraField($extraName, $serverName) - { - $this->extraFields[$extraName] = $serverName; - - return $this; - } - - /** - * @param array $extra - * @return array - */ - private function appendExtraFields(array $extra) - { - foreach ($this->extraFields as $extraName => $serverName) { - $extra[$extraName] = isset($this->serverData[$serverName]) ? $this->serverData[$serverName] : null; - } - - if (isset($this->serverData['UNIQUE_ID'])) { - $extra['unique_id'] = $this->serverData['UNIQUE_ID']; - } - - return $extra; - } -} diff --git a/vendor/monolog/monolog/src/Monolog/Registry.php b/vendor/monolog/monolog/src/Monolog/Registry.php deleted file mode 100644 index 159b751cd..000000000 --- a/vendor/monolog/monolog/src/Monolog/Registry.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog; - -use InvalidArgumentException; - -/** - * Monolog log registry - * - * Allows to get `Logger` instances in the global scope - * via static method calls on this class. - * - * - * $application = new Monolog\Logger('application'); - * $api = new Monolog\Logger('api'); - * - * Monolog\Registry::addLogger($application); - * Monolog\Registry::addLogger($api); - * - * function testLogger() - * { - * Monolog\Registry::api()->addError('Sent to $api Logger instance'); - * Monolog\Registry::application()->addError('Sent to $application Logger instance'); - * } - * - * - * @author Tomas Tatarko - */ -class Registry -{ - /** - * List of all loggers in the registry (by named indexes) - * - * @var Logger[] - */ - private static $loggers = array(); - - /** - * Adds new logging channel to the registry - * - * @param Logger $logger Instance of the logging channel - * @param string|null $name Name of the logging channel ($logger->getName() by default) - * @param bool $overwrite Overwrite instance in the registry if the given name already exists? - * @throws \InvalidArgumentException If $overwrite set to false and named Logger instance already exists - */ - public static function addLogger(Logger $logger, $name = null, $overwrite = false) - { - $name = $name ?: $logger->getName(); - - if (isset(self::$loggers[$name]) && !$overwrite) { - throw new InvalidArgumentException('Logger with the given name already exists'); - } - - self::$loggers[$name] = $logger; - } - - /** - * Checks if such logging channel exists by name or instance - * - * @param string|Logger $logger Name or logger instance - */ - public static function hasLogger($logger) - { - if ($logger instanceof Logger) { - $index = array_search($logger, self::$loggers, true); - - return false !== $index; - } else { - return isset(self::$loggers[$logger]); - } - } - - /** - * Removes instance from registry by name or instance - * - * @param string|Logger $logger Name or logger instance - */ - public static function removeLogger($logger) - { - if ($logger instanceof Logger) { - if (false !== ($idx = array_search($logger, self::$loggers, true))) { - unset(self::$loggers[$idx]); - } - } else { - unset(self::$loggers[$logger]); - } - } - - /** - * Clears the registry - */ - public static function clear() - { - self::$loggers = array(); - } - - /** - * Gets Logger instance from the registry - * - * @param string $name Name of the requested Logger instance - * @throws \InvalidArgumentException If named Logger instance is not in the registry - * @return Logger Requested instance of Logger - */ - public static function getInstance($name) - { - if (!isset(self::$loggers[$name])) { - throw new InvalidArgumentException(sprintf('Requested "%s" logger instance is not in the registry', $name)); - } - - return self::$loggers[$name]; - } - - /** - * Gets Logger instance from the registry via static method call - * - * @param string $name Name of the requested Logger instance - * @param array $arguments Arguments passed to static method call - * @throws \InvalidArgumentException If named Logger instance is not in the registry - * @return Logger Requested instance of Logger - */ - public static function __callStatic($name, $arguments) - { - return self::getInstance($name); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php deleted file mode 100644 index a9a3f301f..000000000 --- a/vendor/monolog/monolog/tests/Monolog/ErrorHandlerTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog; - -use Monolog\Handler\TestHandler; - -class ErrorHandlerTest extends \PHPUnit_Framework_TestCase -{ - public function testHandleError() - { - $logger = new Logger('test', array($handler = new TestHandler)); - $errHandler = new ErrorHandler($logger); - - $errHandler->registerErrorHandler(array(E_USER_NOTICE => Logger::EMERGENCY), false); - trigger_error('Foo', E_USER_ERROR); - $this->assertCount(1, $handler->getRecords()); - $this->assertTrue($handler->hasErrorRecords()); - trigger_error('Foo', E_USER_NOTICE); - $this->assertCount(2, $handler->getRecords()); - $this->assertTrue($handler->hasEmergencyRecords()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php deleted file mode 100644 index 71c420461..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/ChromePHPFormatterTest.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -class ChromePHPFormatterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Monolog\Formatter\ChromePHPFormatter::format - */ - public function testDefaultFormat() - { - $formatter = new ChromePHPFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('ip' => '127.0.0.1'), - 'message' => 'log', - ); - - $message = $formatter->format($record); - - $this->assertEquals( - array( - 'meh', - array( - 'message' => 'log', - 'context' => array('from' => 'logger'), - 'extra' => array('ip' => '127.0.0.1'), - ), - 'unknown', - 'error', - ), - $message - ); - } - - /** - * @covers Monolog\Formatter\ChromePHPFormatter::format - */ - public function testFormatWithFileAndLine() - { - $formatter = new ChromePHPFormatter(); - $record = array( - 'level' => Logger::CRITICAL, - 'level_name' => 'CRITICAL', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14), - 'message' => 'log', - ); - - $message = $formatter->format($record); - - $this->assertEquals( - array( - 'meh', - array( - 'message' => 'log', - 'context' => array('from' => 'logger'), - 'extra' => array('ip' => '127.0.0.1'), - ), - 'test : 14', - 'error', - ), - $message - ); - } - - /** - * @covers Monolog\Formatter\ChromePHPFormatter::format - */ - public function testFormatWithoutContext() - { - $formatter = new ChromePHPFormatter(); - $record = array( - 'level' => Logger::DEBUG, - 'level_name' => 'DEBUG', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - $message = $formatter->format($record); - - $this->assertEquals( - array( - 'meh', - 'log', - 'unknown', - 'log', - ), - $message - ); - } - - /** - * @covers Monolog\Formatter\ChromePHPFormatter::formatBatch - */ - public function testBatchFormatThrowException() - { - $formatter = new ChromePHPFormatter(); - $records = array( - array( - 'level' => Logger::INFO, - 'level_name' => 'INFO', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ), - array( - 'level' => Logger::WARNING, - 'level_name' => 'WARNING', - 'channel' => 'foo', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log2', - ), - ); - - $this->assertEquals( - array( - array( - 'meh', - 'log', - 'unknown', - 'info', - ), - array( - 'foo', - 'log2', - 'unknown', - 'warn', - ), - ), - $formatter->formatBatch($records) - ); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php deleted file mode 100644 index 90cc48dd7..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/ElasticaFormatterTest.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -class ElasticaFormatterTest extends \PHPUnit_Framework_TestCase -{ - public function setUp() - { - if (!class_exists("Elastica\Document")) { - $this->markTestSkipped("ruflin/elastica not installed"); - } - } - - /** - * @covers Monolog\Formatter\ElasticaFormatter::__construct - * @covers Monolog\Formatter\ElasticaFormatter::format - * @covers Monolog\Formatter\ElasticaFormatter::getDocument - */ - public function testFormat() - { - // test log message - $msg = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - // expected values - $expected = $msg; - $expected['datetime'] = '1970-01-01T00:00:00.000000+00:00'; - $expected['context'] = array( - 'class' => '[object] (stdClass: {})', - 'foo' => 7, - 0 => 'bar', - ); - - // format log message - $formatter = new ElasticaFormatter('my_index', 'doc_type'); - $doc = $formatter->format($msg); - $this->assertInstanceOf('Elastica\Document', $doc); - - // Document parameters - $params = $doc->getParams(); - $this->assertEquals('my_index', $params['_index']); - $this->assertEquals('doc_type', $params['_type']); - - // Document data values - $data = $doc->getData(); - foreach (array_keys($expected) as $key) { - $this->assertEquals($expected[$key], $data[$key]); - } - } - - /** - * @covers Monolog\Formatter\ElasticaFormatter::getIndex - * @covers Monolog\Formatter\ElasticaFormatter::getType - */ - public function testGetters() - { - $formatter = new ElasticaFormatter('my_index', 'doc_type'); - $this->assertEquals('my_index', $formatter->getIndex()); - $this->assertEquals('doc_type', $formatter->getType()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php deleted file mode 100644 index 1b2fd97a6..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/FlowdockFormatterTest.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; -use Monolog\TestCase; - -class FlowdockFormatterTest extends TestCase -{ - /** - * @covers Monolog\Formatter\FlowdockFormatter::format - */ - public function testFormat() - { - $formatter = new FlowdockFormatter('test_source', 'source@test.com'); - $record = $this->getRecord(); - - $expected = array( - 'source' => 'test_source', - 'from_address' => 'source@test.com', - 'subject' => 'in test_source: WARNING - test', - 'content' => 'test', - 'tags' => array('#logs', '#warning', '#test'), - 'project' => 'test_source', - ); - $formatted = $formatter->format($record); - - $this->assertEquals($expected, $formatted['flowdock']); - } - - /** - * @ covers Monolog\Formatter\FlowdockFormatter::formatBatch - */ - public function testFormatBatch() - { - $formatter = new FlowdockFormatter('test_source', 'source@test.com'); - $records = array( - $this->getRecord(Logger::WARNING), - $this->getRecord(Logger::DEBUG), - ); - $formatted = $formatter->formatBatch($records); - - $this->assertArrayHasKey('flowdock', $formatted[0]); - $this->assertArrayHasKey('flowdock', $formatted[1]); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php deleted file mode 100644 index 622b2bae2..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/FluentdFormatterTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; -use Monolog\TestCase; - -class FluentdFormatterTest extends TestCase -{ - /** - * @covers Monolog\Formatter\FluentdFormatter::__construct - * @covers Monolog\Formatter\FluentdFormatter::isUsingLevelsInTag - */ - public function testConstruct() - { - $formatter = new FluentdFormatter(); - $this->assertEquals(false, $formatter->isUsingLevelsInTag()); - $formatter = new FluentdFormatter(false); - $this->assertEquals(false, $formatter->isUsingLevelsInTag()); - $formatter = new FluentdFormatter(true); - $this->assertEquals(true, $formatter->isUsingLevelsInTag()); - } - - /** - * @covers Monolog\Formatter\FluentdFormatter::format - */ - public function testFormat() - { - $record = $this->getRecord(Logger::WARNING); - $record['datetime'] = new \DateTime("@0"); - - $formatter = new FluentdFormatter(); - $this->assertEquals( - '["test",0,{"message":"test","extra":[],"level":300,"level_name":"WARNING"}]', - $formatter->format($record) - ); - } - - /** - * @covers Monolog\Formatter\FluentdFormatter::format - */ - public function testFormatWithTag() - { - $record = $this->getRecord(Logger::ERROR); - $record['datetime'] = new \DateTime("@0"); - - $formatter = new FluentdFormatter(true); - $this->assertEquals( - '["test.error",0,{"message":"test","extra":[]}]', - $formatter->format($record) - ); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php deleted file mode 100644 index e6bd3098a..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/GelfMessageFormatterTest.php +++ /dev/null @@ -1,234 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -class GelfMessageFormatterTest extends \PHPUnit_Framework_TestCase -{ - public function setUp() - { - if (!class_exists('\Gelf\Message')) { - $this->markTestSkipped("graylog2/gelf-php or mlehner/gelf-php is not installed"); - } - } - - /** - * @covers Monolog\Formatter\GelfMessageFormatter::format - */ - public function testDefaultFormatter() - { - $formatter = new GelfMessageFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - $message = $formatter->format($record); - - $this->assertInstanceOf('Gelf\Message', $message); - $this->assertEquals(0, $message->getTimestamp()); - $this->assertEquals('log', $message->getShortMessage()); - $this->assertEquals('meh', $message->getFacility()); - $this->assertEquals(null, $message->getLine()); - $this->assertEquals(null, $message->getFile()); - $this->assertEquals($this->isLegacy() ? 3 : 'error', $message->getLevel()); - $this->assertNotEmpty($message->getHost()); - - $formatter = new GelfMessageFormatter('mysystem'); - - $message = $formatter->format($record); - - $this->assertInstanceOf('Gelf\Message', $message); - $this->assertEquals('mysystem', $message->getHost()); - } - - /** - * @covers Monolog\Formatter\GelfMessageFormatter::format - */ - public function testFormatWithFileAndLine() - { - $formatter = new GelfMessageFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('file' => 'test', 'line' => 14), - 'message' => 'log', - ); - - $message = $formatter->format($record); - - $this->assertInstanceOf('Gelf\Message', $message); - $this->assertEquals('test', $message->getFile()); - $this->assertEquals(14, $message->getLine()); - } - - /** - * @covers Monolog\Formatter\GelfMessageFormatter::format - * @expectedException InvalidArgumentException - */ - public function testFormatInvalidFails() - { - $formatter = new GelfMessageFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - ); - - $formatter->format($record); - } - - /** - * @covers Monolog\Formatter\GelfMessageFormatter::format - */ - public function testFormatWithContext() - { - $formatter = new GelfMessageFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => 'pair'), - 'message' => 'log', - ); - - $message = $formatter->format($record); - - $this->assertInstanceOf('Gelf\Message', $message); - - $message_array = $message->toArray(); - - $this->assertArrayHasKey('_ctxt_from', $message_array); - $this->assertEquals('logger', $message_array['_ctxt_from']); - - // Test with extraPrefix - $formatter = new GelfMessageFormatter(null, null, 'CTX'); - $message = $formatter->format($record); - - $this->assertInstanceOf('Gelf\Message', $message); - - $message_array = $message->toArray(); - - $this->assertArrayHasKey('_CTXfrom', $message_array); - $this->assertEquals('logger', $message_array['_CTXfrom']); - } - - /** - * @covers Monolog\Formatter\GelfMessageFormatter::format - */ - public function testFormatWithContextContainingException() - { - $formatter = new GelfMessageFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger', 'exception' => array( - 'class' => '\Exception', - 'file' => '/some/file/in/dir.php:56', - 'trace' => array('/some/file/1.php:23', '/some/file/2.php:3'), - )), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - $message = $formatter->format($record); - - $this->assertInstanceOf('Gelf\Message', $message); - - $this->assertEquals("/some/file/in/dir.php", $message->getFile()); - $this->assertEquals("56", $message->getLine()); - } - - /** - * @covers Monolog\Formatter\GelfMessageFormatter::format - */ - public function testFormatWithExtra() - { - $formatter = new GelfMessageFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => 'pair'), - 'message' => 'log', - ); - - $message = $formatter->format($record); - - $this->assertInstanceOf('Gelf\Message', $message); - - $message_array = $message->toArray(); - - $this->assertArrayHasKey('_key', $message_array); - $this->assertEquals('pair', $message_array['_key']); - - // Test with extraPrefix - $formatter = new GelfMessageFormatter(null, 'EXT'); - $message = $formatter->format($record); - - $this->assertInstanceOf('Gelf\Message', $message); - - $message_array = $message->toArray(); - - $this->assertArrayHasKey('_EXTkey', $message_array); - $this->assertEquals('pair', $message_array['_EXTkey']); - } - - public function testFormatWithLargeData() - { - $formatter = new GelfMessageFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('exception' => str_repeat(' ', 32767)), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => str_repeat(' ', 32767)), - 'message' => 'log' - ); - $message = $formatter->format($record); - $messageArray = $message->toArray(); - - // 200 for padding + metadata - $length = 200; - - foreach ($messageArray as $key => $value) { - if (!in_array($key, array('level', 'timestamp'))) { - $length += strlen($value); - } - } - - // in graylog2/gelf-php before 1.4.1 empty strings are filtered and won't be included in the message - // though it should be sufficient to ensure that the entire message length does not exceed the maximum - // length being allowed - $this->assertLessThanOrEqual(32766, $length, 'The message length is no longer than the maximum allowed length'); - } - - private function isLegacy() - { - return interface_exists('\Gelf\IMessagePublisher'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php deleted file mode 100644 index df7e35de5..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/JsonFormatterTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; -use Monolog\TestCase; - -class JsonFormatterTest extends TestCase -{ - /** - * @covers Monolog\Formatter\JsonFormatter::__construct - * @covers Monolog\Formatter\JsonFormatter::getBatchMode - * @covers Monolog\Formatter\JsonFormatter::isAppendingNewlines - */ - public function testConstruct() - { - $formatter = new JsonFormatter(); - $this->assertEquals(JsonFormatter::BATCH_MODE_JSON, $formatter->getBatchMode()); - $this->assertEquals(true, $formatter->isAppendingNewlines()); - $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES, false); - $this->assertEquals(JsonFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode()); - $this->assertEquals(false, $formatter->isAppendingNewlines()); - } - - /** - * @covers Monolog\Formatter\JsonFormatter::format - */ - public function testFormat() - { - $formatter = new JsonFormatter(); - $record = $this->getRecord(); - $this->assertEquals(json_encode($record)."\n", $formatter->format($record)); - - $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_JSON, false); - $record = $this->getRecord(); - $this->assertEquals(json_encode($record), $formatter->format($record)); - } - - /** - * @covers Monolog\Formatter\JsonFormatter::formatBatch - * @covers Monolog\Formatter\JsonFormatter::formatBatchJson - */ - public function testFormatBatch() - { - $formatter = new JsonFormatter(); - $records = array( - $this->getRecord(Logger::WARNING), - $this->getRecord(Logger::DEBUG), - ); - $this->assertEquals(json_encode($records), $formatter->formatBatch($records)); - } - - /** - * @covers Monolog\Formatter\JsonFormatter::formatBatch - * @covers Monolog\Formatter\JsonFormatter::formatBatchNewlines - */ - public function testFormatBatchNewlines() - { - $formatter = new JsonFormatter(JsonFormatter::BATCH_MODE_NEWLINES); - $records = $expected = array( - $this->getRecord(Logger::WARNING), - $this->getRecord(Logger::DEBUG), - ); - array_walk($expected, function (&$value, $key) { - $value = json_encode($value); - }); - $this->assertEquals(implode("\n", $expected), $formatter->formatBatch($records)); - } - - public function testDefFormatWithException() - { - $formatter = new JsonFormatter(); - $exception = new \RuntimeException('Foo'); - $message = $formatter->format(array( - 'level_name' => 'CRITICAL', - 'channel' => 'core', - 'context' => array('exception' => $exception), - 'datetime' => new \DateTime(), - 'extra' => array(), - 'message' => 'foobar', - )); - - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { - $path = substr(json_encode($exception->getFile(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), 1, -1); - } else { - $path = substr(json_encode($exception->getFile()), 1, -1); - } - $this->assertEquals('{"level_name":"CRITICAL","channel":"core","context":{"exception":{"class":"RuntimeException","message":"'.$exception->getMessage().'","code":'.$exception->getCode().',"file":"'.$path.':'.$exception->getLine().'"}},"datetime":'.json_encode(new \DateTime()).',"extra":[],"message":"foobar"}'."\n", $message); - } - - public function testDefFormatWithPreviousException() - { - $formatter = new JsonFormatter(); - $exception = new \RuntimeException('Foo', 0, new \LogicException('Wut?')); - $message = $formatter->format(array( - 'level_name' => 'CRITICAL', - 'channel' => 'core', - 'context' => array('exception' => $exception), - 'datetime' => new \DateTime(), - 'extra' => array(), - 'message' => 'foobar', - )); - - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { - $pathPrevious = substr(json_encode($exception->getPrevious()->getFile(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), 1, -1); - $pathException = substr(json_encode($exception->getFile(), JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE), 1, -1); - } else { - $pathPrevious = substr(json_encode($exception->getPrevious()->getFile()), 1, -1); - $pathException = substr(json_encode($exception->getFile()), 1, -1); - } - $this->assertEquals('{"level_name":"CRITICAL","channel":"core","context":{"exception":{"class":"RuntimeException","message":"'.$exception->getMessage().'","code":'.$exception->getCode().',"file":"'.$pathException.':'.$exception->getLine().'","previous":{"class":"LogicException","message":"'.$exception->getPrevious()->getMessage().'","code":'.$exception->getPrevious()->getCode().',"file":"'.$pathPrevious.':'.$exception->getPrevious()->getLine().'"}}},"datetime":'.json_encode(new \DateTime()).',"extra":[],"message":"foobar"}'."\n", $message); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php deleted file mode 100644 index 310d93cad..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/LineFormatterTest.php +++ /dev/null @@ -1,222 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * @covers Monolog\Formatter\LineFormatter - */ -class LineFormatterTest extends \PHPUnit_Framework_TestCase -{ - public function testDefFormatWithString() - { - $formatter = new LineFormatter(null, 'Y-m-d'); - $message = $formatter->format(array( - 'level_name' => 'WARNING', - 'channel' => 'log', - 'context' => array(), - 'message' => 'foo', - 'datetime' => new \DateTime, - 'extra' => array(), - )); - $this->assertEquals('['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message); - } - - public function testDefFormatWithArrayContext() - { - $formatter = new LineFormatter(null, 'Y-m-d'); - $message = $formatter->format(array( - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'message' => 'foo', - 'datetime' => new \DateTime, - 'extra' => array(), - 'context' => array( - 'foo' => 'bar', - 'baz' => 'qux', - 'bool' => false, - 'null' => null, - ), - )); - $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foo {"foo":"bar","baz":"qux","bool":false,"null":null} []'."\n", $message); - } - - public function testDefFormatExtras() - { - $formatter = new LineFormatter(null, 'Y-m-d'); - $message = $formatter->format(array( - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime, - 'extra' => array('ip' => '127.0.0.1'), - 'message' => 'log', - )); - $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] {"ip":"127.0.0.1"}'."\n", $message); - } - - public function testFormatExtras() - { - $formatter = new LineFormatter("[%datetime%] %channel%.%level_name%: %message% %context% %extra.file% %extra%\n", 'Y-m-d'); - $message = $formatter->format(array( - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime, - 'extra' => array('ip' => '127.0.0.1', 'file' => 'test'), - 'message' => 'log', - )); - $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log [] test {"ip":"127.0.0.1"}'."\n", $message); - } - - public function testContextAndExtraOptionallyNotShownIfEmpty() - { - $formatter = new LineFormatter(null, 'Y-m-d', false, true); - $message = $formatter->format(array( - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime, - 'extra' => array(), - 'message' => 'log', - )); - $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: log '."\n", $message); - } - - public function testContextAndExtraReplacement() - { - $formatter = new LineFormatter('%context.foo% => %extra.foo%'); - $message = $formatter->format(array( - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('foo' => 'bar'), - 'datetime' => new \DateTime, - 'extra' => array('foo' => 'xbar'), - 'message' => 'log', - )); - $this->assertEquals('bar => xbar', $message); - } - - public function testDefFormatWithObject() - { - $formatter = new LineFormatter(null, 'Y-m-d'); - $message = $formatter->format(array( - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime, - 'extra' => array('foo' => new TestFoo, 'bar' => new TestBar, 'baz' => array(), 'res' => fopen('php://memory', 'rb')), - 'message' => 'foobar', - )); - - $this->assertEquals('['.date('Y-m-d').'] meh.ERROR: foobar [] {"foo":"[object] (Monolog\\\\Formatter\\\\TestFoo: {\\"foo\\":\\"foo\\"})","bar":"[object] (Monolog\\\\Formatter\\\\TestBar: bar)","baz":[],"res":"[resource] (stream)"}'."\n", $message); - } - - public function testDefFormatWithException() - { - $formatter = new LineFormatter(null, 'Y-m-d'); - $message = $formatter->format(array( - 'level_name' => 'CRITICAL', - 'channel' => 'core', - 'context' => array('exception' => new \RuntimeException('Foo')), - 'datetime' => new \DateTime, - 'extra' => array(), - 'message' => 'foobar', - )); - - $path = str_replace('\\/', '/', json_encode(__FILE__)); - - $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).')"} []'."\n", $message); - } - - public function testDefFormatWithPreviousException() - { - $formatter = new LineFormatter(null, 'Y-m-d'); - $previous = new \LogicException('Wut?'); - $message = $formatter->format(array( - 'level_name' => 'CRITICAL', - 'channel' => 'core', - 'context' => array('exception' => new \RuntimeException('Foo', 0, $previous)), - 'datetime' => new \DateTime, - 'extra' => array(), - 'message' => 'foobar', - )); - - $path = str_replace('\\/', '/', json_encode(__FILE__)); - - $this->assertEquals('['.date('Y-m-d').'] core.CRITICAL: foobar {"exception":"[object] (RuntimeException(code: 0): Foo at '.substr($path, 1, -1).':'.(__LINE__ - 8).', LogicException(code: 0): Wut? at '.substr($path, 1, -1).':'.(__LINE__ - 12).')"} []'."\n", $message); - } - - public function testBatchFormat() - { - $formatter = new LineFormatter(null, 'Y-m-d'); - $message = $formatter->formatBatch(array( - array( - 'level_name' => 'CRITICAL', - 'channel' => 'test', - 'message' => 'bar', - 'context' => array(), - 'datetime' => new \DateTime, - 'extra' => array(), - ), - array( - 'level_name' => 'WARNING', - 'channel' => 'log', - 'message' => 'foo', - 'context' => array(), - 'datetime' => new \DateTime, - 'extra' => array(), - ), - )); - $this->assertEquals('['.date('Y-m-d').'] test.CRITICAL: bar [] []'."\n".'['.date('Y-m-d').'] log.WARNING: foo [] []'."\n", $message); - } - - public function testFormatShouldStripInlineLineBreaks() - { - $formatter = new LineFormatter(null, 'Y-m-d'); - $message = $formatter->format( - array( - 'message' => "foo\nbar", - 'context' => array(), - 'extra' => array(), - ) - ); - - $this->assertRegExp('/foo bar/', $message); - } - - public function testFormatShouldNotStripInlineLineBreaksWhenFlagIsSet() - { - $formatter = new LineFormatter(null, 'Y-m-d', true); - $message = $formatter->format( - array( - 'message' => "foo\nbar", - 'context' => array(), - 'extra' => array(), - ) - ); - - $this->assertRegExp('/foo\nbar/', $message); - } -} - -class TestFoo -{ - public $foo = 'foo'; -} - -class TestBar -{ - public function __toString() - { - return 'bar'; - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php deleted file mode 100644 index 6d59b3f3d..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/LogglyFormatterTest.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\TestCase; - -class LogglyFormatterTest extends TestCase -{ - /** - * @covers Monolog\Formatter\LogglyFormatter::__construct - */ - public function testConstruct() - { - $formatter = new LogglyFormatter(); - $this->assertEquals(LogglyFormatter::BATCH_MODE_NEWLINES, $formatter->getBatchMode()); - $formatter = new LogglyFormatter(LogglyFormatter::BATCH_MODE_JSON); - $this->assertEquals(LogglyFormatter::BATCH_MODE_JSON, $formatter->getBatchMode()); - } - - /** - * @covers Monolog\Formatter\LogglyFormatter::format - */ - public function testFormat() - { - $formatter = new LogglyFormatter(); - $record = $this->getRecord(); - $formatted_decoded = json_decode($formatter->format($record), true); - $this->assertArrayHasKey("timestamp", $formatted_decoded); - $this->assertEquals(new \DateTime($formatted_decoded["timestamp"]), $record["datetime"]); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php deleted file mode 100644 index 9f6b1cc43..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/LogstashFormatterTest.php +++ /dev/null @@ -1,333 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -class LogstashFormatterTest extends \PHPUnit_Framework_TestCase -{ - public function tearDown() - { - \PHPUnit_Framework_Error_Warning::$enabled = true; - - return parent::tearDown(); - } - - /** - * @covers Monolog\Formatter\LogstashFormatter::format - */ - public function testDefaultFormatter() - { - $formatter = new LogstashFormatter('test', 'hostname'); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']); - $this->assertEquals('log', $message['@message']); - $this->assertEquals('meh', $message['@fields']['channel']); - $this->assertContains('meh', $message['@tags']); - $this->assertEquals(Logger::ERROR, $message['@fields']['level']); - $this->assertEquals('test', $message['@type']); - $this->assertEquals('hostname', $message['@source']); - - $formatter = new LogstashFormatter('mysystem'); - - $message = json_decode($formatter->format($record), true); - - $this->assertEquals('mysystem', $message['@type']); - } - - /** - * @covers Monolog\Formatter\LogstashFormatter::format - */ - public function testFormatWithFileAndLine() - { - $formatter = new LogstashFormatter('test'); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('file' => 'test', 'line' => 14), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertEquals('test', $message['@fields']['file']); - $this->assertEquals(14, $message['@fields']['line']); - } - - /** - * @covers Monolog\Formatter\LogstashFormatter::format - */ - public function testFormatWithContext() - { - $formatter = new LogstashFormatter('test'); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => 'pair'), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $message_array = $message['@fields']; - - $this->assertArrayHasKey('ctxt_from', $message_array); - $this->assertEquals('logger', $message_array['ctxt_from']); - - // Test with extraPrefix - $formatter = new LogstashFormatter('test', null, null, 'CTX'); - $message = json_decode($formatter->format($record), true); - - $message_array = $message['@fields']; - - $this->assertArrayHasKey('CTXfrom', $message_array); - $this->assertEquals('logger', $message_array['CTXfrom']); - } - - /** - * @covers Monolog\Formatter\LogstashFormatter::format - */ - public function testFormatWithExtra() - { - $formatter = new LogstashFormatter('test'); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => 'pair'), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $message_array = $message['@fields']; - - $this->assertArrayHasKey('key', $message_array); - $this->assertEquals('pair', $message_array['key']); - - // Test with extraPrefix - $formatter = new LogstashFormatter('test', null, 'EXT'); - $message = json_decode($formatter->format($record), true); - - $message_array = $message['@fields']; - - $this->assertArrayHasKey('EXTkey', $message_array); - $this->assertEquals('pair', $message_array['EXTkey']); - } - - public function testFormatWithApplicationName() - { - $formatter = new LogstashFormatter('app', 'test'); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => 'pair'), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertArrayHasKey('@type', $message); - $this->assertEquals('app', $message['@type']); - } - - /** - * @covers Monolog\Formatter\LogstashFormatter::format - */ - public function testDefaultFormatterV1() - { - $formatter = new LogstashFormatter('test', 'hostname', null, 'ctxt_', LogstashFormatter::V1); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']); - $this->assertEquals("1", $message['@version']); - $this->assertEquals('log', $message['message']); - $this->assertEquals('meh', $message['channel']); - $this->assertEquals('ERROR', $message['level']); - $this->assertEquals('test', $message['type']); - $this->assertEquals('hostname', $message['host']); - - $formatter = new LogstashFormatter('mysystem', null, null, 'ctxt_', LogstashFormatter::V1); - - $message = json_decode($formatter->format($record), true); - - $this->assertEquals('mysystem', $message['type']); - } - - /** - * @covers Monolog\Formatter\LogstashFormatter::format - */ - public function testFormatWithFileAndLineV1() - { - $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('file' => 'test', 'line' => 14), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertEquals('test', $message['file']); - $this->assertEquals(14, $message['line']); - } - - /** - * @covers Monolog\Formatter\LogstashFormatter::format - */ - public function testFormatWithContextV1() - { - $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => 'pair'), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertArrayHasKey('ctxt_from', $message); - $this->assertEquals('logger', $message['ctxt_from']); - - // Test with extraPrefix - $formatter = new LogstashFormatter('test', null, null, 'CTX', LogstashFormatter::V1); - $message = json_decode($formatter->format($record), true); - - $this->assertArrayHasKey('CTXfrom', $message); - $this->assertEquals('logger', $message['CTXfrom']); - } - - /** - * @covers Monolog\Formatter\LogstashFormatter::format - */ - public function testFormatWithExtraV1() - { - $formatter = new LogstashFormatter('test', null, null, 'ctxt_', LogstashFormatter::V1); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => 'pair'), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertArrayHasKey('key', $message); - $this->assertEquals('pair', $message['key']); - - // Test with extraPrefix - $formatter = new LogstashFormatter('test', null, 'EXT', 'ctxt_', LogstashFormatter::V1); - $message = json_decode($formatter->format($record), true); - - $this->assertArrayHasKey('EXTkey', $message); - $this->assertEquals('pair', $message['EXTkey']); - } - - public function testFormatWithApplicationNameV1() - { - $formatter = new LogstashFormatter('app', 'test', null, 'ctxt_', LogstashFormatter::V1); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('key' => 'pair'), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertArrayHasKey('type', $message); - $this->assertEquals('app', $message['type']); - } - - public function testFormatWithLatin9Data() - { - if (version_compare(PHP_VERSION, '5.5.0', '<')) { - // Ignore the warning that will be emitted by PHP <5.5.0 - \PHPUnit_Framework_Error_Warning::$enabled = false; - } - $formatter = new LogstashFormatter('test', 'hostname'); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => '¯\_(ツ)_/¯', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array( - 'user_agent' => "\xD6WN; FBCR/OrangeEspa\xF1a; Vers\xE3o/4.0; F\xE4rist", - ), - 'message' => 'log', - ); - - $message = json_decode($formatter->format($record), true); - - $this->assertEquals("1970-01-01T00:00:00.000000+00:00", $message['@timestamp']); - $this->assertEquals('log', $message['@message']); - $this->assertEquals('¯\_(ツ)_/¯', $message['@fields']['channel']); - $this->assertContains('¯\_(ツ)_/¯', $message['@tags']); - $this->assertEquals(Logger::ERROR, $message['@fields']['level']); - $this->assertEquals('test', $message['@type']); - $this->assertEquals('hostname', $message['@source']); - if (version_compare(PHP_VERSION, '5.5.0', '>=')) { - $this->assertEquals('ÖWN; FBCR/OrangeEspaña; Versão/4.0; Färist', $message['@fields']['user_agent']); - } else { - // PHP <5.5 does not return false for an element encoding failure, - // instead it emits a warning (possibly) and nulls the value. - $this->assertEquals(null, $message['@fields']['user_agent']); - } - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/MongoDBFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/MongoDBFormatterTest.php deleted file mode 100644 index 52e699e02..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/MongoDBFormatterTest.php +++ /dev/null @@ -1,262 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -/** - * @author Florian Plattner - */ -class MongoDBFormatterTest extends \PHPUnit_Framework_TestCase -{ - public function setUp() - { - if (!class_exists('MongoDate')) { - $this->markTestSkipped('mongo extension not installed'); - } - } - - public function constructArgumentProvider() - { - return array( - array(1, true, 1, true), - array(0, false, 0, false), - ); - } - - /** - * @param $traceDepth - * @param $traceAsString - * @param $expectedTraceDepth - * @param $expectedTraceAsString - * - * @dataProvider constructArgumentProvider - */ - public function testConstruct($traceDepth, $traceAsString, $expectedTraceDepth, $expectedTraceAsString) - { - $formatter = new MongoDBFormatter($traceDepth, $traceAsString); - - $reflTrace = new \ReflectionProperty($formatter, 'exceptionTraceAsString'); - $reflTrace->setAccessible(true); - $this->assertEquals($expectedTraceAsString, $reflTrace->getValue($formatter)); - - $reflDepth = new\ReflectionProperty($formatter, 'maxNestingLevel'); - $reflDepth->setAccessible(true); - $this->assertEquals($expectedTraceDepth, $reflDepth->getValue($formatter)); - } - - public function testSimpleFormat() - { - $record = array( - 'message' => 'some log message', - 'context' => array(), - 'level' => Logger::WARNING, - 'level_name' => Logger::getLevelName(Logger::WARNING), - 'channel' => 'test', - 'datetime' => new \DateTime('2014-02-01 00:00:00'), - 'extra' => array(), - ); - - $formatter = new MongoDBFormatter(); - $formattedRecord = $formatter->format($record); - - $this->assertCount(7, $formattedRecord); - $this->assertEquals('some log message', $formattedRecord['message']); - $this->assertEquals(array(), $formattedRecord['context']); - $this->assertEquals(Logger::WARNING, $formattedRecord['level']); - $this->assertEquals(Logger::getLevelName(Logger::WARNING), $formattedRecord['level_name']); - $this->assertEquals('test', $formattedRecord['channel']); - $this->assertInstanceOf('\MongoDate', $formattedRecord['datetime']); - $this->assertEquals('0.00000000 1391212800', $formattedRecord['datetime']->__toString()); - $this->assertEquals(array(), $formattedRecord['extra']); - } - - public function testRecursiveFormat() - { - $someObject = new \stdClass(); - $someObject->foo = 'something'; - $someObject->bar = 'stuff'; - - $record = array( - 'message' => 'some log message', - 'context' => array( - 'stuff' => new \DateTime('2014-02-01 02:31:33'), - 'some_object' => $someObject, - 'context_string' => 'some string', - 'context_int' => 123456, - 'except' => new \Exception('exception message', 987), - ), - 'level' => Logger::WARNING, - 'level_name' => Logger::getLevelName(Logger::WARNING), - 'channel' => 'test', - 'datetime' => new \DateTime('2014-02-01 00:00:00'), - 'extra' => array(), - ); - - $formatter = new MongoDBFormatter(); - $formattedRecord = $formatter->format($record); - - $this->assertCount(5, $formattedRecord['context']); - $this->assertInstanceOf('\MongoDate', $formattedRecord['context']['stuff']); - $this->assertEquals('0.00000000 1391221893', $formattedRecord['context']['stuff']->__toString()); - $this->assertEquals( - array( - 'foo' => 'something', - 'bar' => 'stuff', - 'class' => 'stdClass', - ), - $formattedRecord['context']['some_object'] - ); - $this->assertEquals('some string', $formattedRecord['context']['context_string']); - $this->assertEquals(123456, $formattedRecord['context']['context_int']); - - $this->assertCount(5, $formattedRecord['context']['except']); - $this->assertEquals('exception message', $formattedRecord['context']['except']['message']); - $this->assertEquals(987, $formattedRecord['context']['except']['code']); - $this->assertInternalType('string', $formattedRecord['context']['except']['file']); - $this->assertInternalType('integer', $formattedRecord['context']['except']['code']); - $this->assertInternalType('string', $formattedRecord['context']['except']['trace']); - $this->assertEquals('Exception', $formattedRecord['context']['except']['class']); - } - - public function testFormatDepthArray() - { - $record = array( - 'message' => 'some log message', - 'context' => array( - 'nest2' => array( - 'property' => 'anything', - 'nest3' => array( - 'nest4' => 'value', - 'property' => 'nothing', - ), - ), - ), - 'level' => Logger::WARNING, - 'level_name' => Logger::getLevelName(Logger::WARNING), - 'channel' => 'test', - 'datetime' => new \DateTime('2014-02-01 00:00:00'), - 'extra' => array(), - ); - - $formatter = new MongoDBFormatter(2); - $formattedResult = $formatter->format($record); - - $this->assertEquals( - array( - 'nest2' => array( - 'property' => 'anything', - 'nest3' => '[...]', - ), - ), - $formattedResult['context'] - ); - } - - public function testFormatDepthArrayInfiniteNesting() - { - $record = array( - 'message' => 'some log message', - 'context' => array( - 'nest2' => array( - 'property' => 'something', - 'nest3' => array( - 'property' => 'anything', - 'nest4' => array( - 'property' => 'nothing', - ), - ), - ), - ), - 'level' => Logger::WARNING, - 'level_name' => Logger::getLevelName(Logger::WARNING), - 'channel' => 'test', - 'datetime' => new \DateTime('2014-02-01 00:00:00'), - 'extra' => array(), - ); - - $formatter = new MongoDBFormatter(0); - $formattedResult = $formatter->format($record); - - $this->assertEquals( - array( - 'nest2' => array( - 'property' => 'something', - 'nest3' => array( - 'property' => 'anything', - 'nest4' => array( - 'property' => 'nothing', - ), - ), - ), - ), - $formattedResult['context'] - ); - } - - public function testFormatDepthObjects() - { - $someObject = new \stdClass(); - $someObject->property = 'anything'; - $someObject->nest3 = new \stdClass(); - $someObject->nest3->property = 'nothing'; - $someObject->nest3->nest4 = 'invisible'; - - $record = array( - 'message' => 'some log message', - 'context' => array( - 'nest2' => $someObject, - ), - 'level' => Logger::WARNING, - 'level_name' => Logger::getLevelName(Logger::WARNING), - 'channel' => 'test', - 'datetime' => new \DateTime('2014-02-01 00:00:00'), - 'extra' => array(), - ); - - $formatter = new MongoDBFormatter(2, true); - $formattedResult = $formatter->format($record); - - $this->assertEquals( - array( - 'nest2' => array( - 'property' => 'anything', - 'nest3' => '[...]', - 'class' => 'stdClass', - ), - ), - $formattedResult['context'] - ); - } - - public function testFormatDepthException() - { - $record = array( - 'message' => 'some log message', - 'context' => array( - 'nest2' => new \Exception('exception message', 987), - ), - 'level' => Logger::WARNING, - 'level_name' => Logger::getLevelName(Logger::WARNING), - 'channel' => 'test', - 'datetime' => new \DateTime('2014-02-01 00:00:00'), - 'extra' => array(), - ); - - $formatter = new MongoDBFormatter(2, false); - $formattedRecord = $formatter->format($record); - - $this->assertEquals('exception message', $formattedRecord['context']['nest2']['message']); - $this->assertEquals(987, $formattedRecord['context']['nest2']['code']); - $this->assertEquals('[...]', $formattedRecord['context']['nest2']['trace']); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php deleted file mode 100644 index ea752b4a9..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/NormalizerFormatterTest.php +++ /dev/null @@ -1,405 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -/** - * @covers Monolog\Formatter\NormalizerFormatter - */ -class NormalizerFormatterTest extends \PHPUnit_Framework_TestCase -{ - public function tearDown() - { - \PHPUnit_Framework_Error_Warning::$enabled = true; - - return parent::tearDown(); - } - - public function testFormat() - { - $formatter = new NormalizerFormatter('Y-m-d'); - $formatted = $formatter->format(array( - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'message' => 'foo', - 'datetime' => new \DateTime, - 'extra' => array('foo' => new TestFooNorm, 'bar' => new TestBarNorm, 'baz' => array(), 'res' => fopen('php://memory', 'rb')), - 'context' => array( - 'foo' => 'bar', - 'baz' => 'qux', - 'inf' => INF, - '-inf' => -INF, - 'nan' => acos(4), - ), - )); - - $this->assertEquals(array( - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'message' => 'foo', - 'datetime' => date('Y-m-d'), - 'extra' => array( - 'foo' => '[object] (Monolog\\Formatter\\TestFooNorm: {"foo":"foo"})', - 'bar' => '[object] (Monolog\\Formatter\\TestBarNorm: bar)', - 'baz' => array(), - 'res' => '[resource] (stream)', - ), - 'context' => array( - 'foo' => 'bar', - 'baz' => 'qux', - 'inf' => 'INF', - '-inf' => '-INF', - 'nan' => 'NaN', - ), - ), $formatted); - } - - public function testFormatExceptions() - { - $formatter = new NormalizerFormatter('Y-m-d'); - $e = new \LogicException('bar'); - $e2 = new \RuntimeException('foo', 0, $e); - $formatted = $formatter->format(array( - 'exception' => $e2, - )); - - $this->assertGreaterThan(5, count($formatted['exception']['trace'])); - $this->assertTrue(isset($formatted['exception']['previous'])); - unset($formatted['exception']['trace'], $formatted['exception']['previous']); - - $this->assertEquals(array( - 'exception' => array( - 'class' => get_class($e2), - 'message' => $e2->getMessage(), - 'code' => $e2->getCode(), - 'file' => $e2->getFile().':'.$e2->getLine(), - ), - ), $formatted); - } - - public function testFormatSoapFaultException() - { - if (!class_exists('SoapFault')) { - $this->markTestSkipped('Requires the soap extension'); - } - - $formatter = new NormalizerFormatter('Y-m-d'); - $e = new \SoapFault('foo', 'bar', 'hello', 'world'); - $formatted = $formatter->format(array( - 'exception' => $e, - )); - - unset($formatted['exception']['trace']); - - $this->assertEquals(array( - 'exception' => array( - 'class' => 'SoapFault', - 'message' => 'bar', - 'code' => 0, - 'file' => $e->getFile().':'.$e->getLine(), - 'faultcode' => 'foo', - 'faultactor' => 'hello', - 'detail' => 'world', - ), - ), $formatted); - } - - public function testFormatToStringExceptionHandle() - { - $formatter = new NormalizerFormatter('Y-m-d'); - $this->setExpectedException('RuntimeException', 'Could not convert to string'); - $formatter->format(array( - 'myObject' => new TestToStringError(), - )); - } - - public function testBatchFormat() - { - $formatter = new NormalizerFormatter('Y-m-d'); - $formatted = $formatter->formatBatch(array( - array( - 'level_name' => 'CRITICAL', - 'channel' => 'test', - 'message' => 'bar', - 'context' => array(), - 'datetime' => new \DateTime, - 'extra' => array(), - ), - array( - 'level_name' => 'WARNING', - 'channel' => 'log', - 'message' => 'foo', - 'context' => array(), - 'datetime' => new \DateTime, - 'extra' => array(), - ), - )); - $this->assertEquals(array( - array( - 'level_name' => 'CRITICAL', - 'channel' => 'test', - 'message' => 'bar', - 'context' => array(), - 'datetime' => date('Y-m-d'), - 'extra' => array(), - ), - array( - 'level_name' => 'WARNING', - 'channel' => 'log', - 'message' => 'foo', - 'context' => array(), - 'datetime' => date('Y-m-d'), - 'extra' => array(), - ), - ), $formatted); - } - - /** - * Test issue #137 - */ - public function testIgnoresRecursiveObjectReferences() - { - // set up the recursion - $foo = new \stdClass(); - $bar = new \stdClass(); - - $foo->bar = $bar; - $bar->foo = $foo; - - // set an error handler to assert that the error is not raised anymore - $that = $this; - set_error_handler(function ($level, $message, $file, $line, $context) use ($that) { - if (error_reporting() & $level) { - restore_error_handler(); - $that->fail("$message should not be raised"); - } - }); - - $formatter = new NormalizerFormatter(); - $reflMethod = new \ReflectionMethod($formatter, 'toJson'); - $reflMethod->setAccessible(true); - $res = $reflMethod->invoke($formatter, array($foo, $bar), true); - - restore_error_handler(); - - $this->assertEquals(@json_encode(array($foo, $bar)), $res); - } - - public function testIgnoresInvalidTypes() - { - // set up the recursion - $resource = fopen(__FILE__, 'r'); - - // set an error handler to assert that the error is not raised anymore - $that = $this; - set_error_handler(function ($level, $message, $file, $line, $context) use ($that) { - if (error_reporting() & $level) { - restore_error_handler(); - $that->fail("$message should not be raised"); - } - }); - - $formatter = new NormalizerFormatter(); - $reflMethod = new \ReflectionMethod($formatter, 'toJson'); - $reflMethod->setAccessible(true); - $res = $reflMethod->invoke($formatter, array($resource), true); - - restore_error_handler(); - - $this->assertEquals(@json_encode(array($resource)), $res); - } - - /** - * @expectedException RuntimeException - */ - public function testThrowsOnInvalidEncoding() - { - if (version_compare(PHP_VERSION, '5.5.0', '<')) { - // Ignore the warning that will be emitted by PHP <5.5.0 - \PHPUnit_Framework_Error_Warning::$enabled = false; - } - $formatter = new NormalizerFormatter(); - $reflMethod = new \ReflectionMethod($formatter, 'toJson'); - $reflMethod->setAccessible(true); - - // send an invalid unicode sequence as a object that can't be cleaned - $record = new \stdClass; - $record->message = "\xB1\x31"; - $res = $reflMethod->invoke($formatter, $record); - if (PHP_VERSION_ID < 50500 && $res === '{"message":null}') { - throw new \RuntimeException('PHP 5.3/5.4 throw a warning and null the value instead of returning false entirely'); - } - } - - public function testConvertsInvalidEncodingAsLatin9() - { - if (version_compare(PHP_VERSION, '5.5.0', '<')) { - // Ignore the warning that will be emitted by PHP <5.5.0 - \PHPUnit_Framework_Error_Warning::$enabled = false; - } - $formatter = new NormalizerFormatter(); - $reflMethod = new \ReflectionMethod($formatter, 'toJson'); - $reflMethod->setAccessible(true); - - $res = $reflMethod->invoke($formatter, array('message' => "\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE")); - - if (version_compare(PHP_VERSION, '5.5.0', '>=')) { - $this->assertSame('{"message":"€ŠšŽžŒœŸ"}', $res); - } else { - // PHP <5.5 does not return false for an element encoding failure, - // instead it emits a warning (possibly) and nulls the value. - $this->assertSame('{"message":null}', $res); - } - } - - /** - * @param mixed $in Input - * @param mixed $expect Expected output - * @covers Monolog\Formatter\NormalizerFormatter::detectAndCleanUtf8 - * @dataProvider providesDetectAndCleanUtf8 - */ - public function testDetectAndCleanUtf8($in, $expect) - { - $formatter = new NormalizerFormatter(); - $formatter->detectAndCleanUtf8($in); - $this->assertSame($expect, $in); - } - - public function providesDetectAndCleanUtf8() - { - $obj = new \stdClass; - - return array( - 'null' => array(null, null), - 'int' => array(123, 123), - 'float' => array(123.45, 123.45), - 'bool false' => array(false, false), - 'bool true' => array(true, true), - 'ascii string' => array('abcdef', 'abcdef'), - 'latin9 string' => array("\xB1\x31\xA4\xA6\xA8\xB4\xB8\xBC\xBD\xBE\xFF", '±1€ŠšŽžŒœŸÿ'), - 'unicode string' => array('¤¦¨´¸¼½¾€ŠšŽžŒœŸ', '¤¦¨´¸¼½¾€ŠšŽžŒœŸ'), - 'empty array' => array(array(), array()), - 'array' => array(array('abcdef'), array('abcdef')), - 'object' => array($obj, $obj), - ); - } - - /** - * @param int $code - * @param string $msg - * @dataProvider providesHandleJsonErrorFailure - */ - public function testHandleJsonErrorFailure($code, $msg) - { - $formatter = new NormalizerFormatter(); - $reflMethod = new \ReflectionMethod($formatter, 'handleJsonError'); - $reflMethod->setAccessible(true); - - $this->setExpectedException('RuntimeException', $msg); - $reflMethod->invoke($formatter, $code, 'faked'); - } - - public function providesHandleJsonErrorFailure() - { - return array( - 'depth' => array(JSON_ERROR_DEPTH, 'Maximum stack depth exceeded'), - 'state' => array(JSON_ERROR_STATE_MISMATCH, 'Underflow or the modes mismatch'), - 'ctrl' => array(JSON_ERROR_CTRL_CHAR, 'Unexpected control character found'), - 'default' => array(-1, 'Unknown error'), - ); - } - - public function testExceptionTraceWithArgs() - { - if (defined('HHVM_VERSION')) { - $this->markTestSkipped('Not supported in HHVM since it detects errors differently'); - } - - // This happens i.e. in React promises or Guzzle streams where stream wrappers are registered - // and no file or line are included in the trace because it's treated as internal function - set_error_handler(function ($errno, $errstr, $errfile, $errline) { - throw new \ErrorException($errstr, 0, $errno, $errfile, $errline); - }); - - try { - // This will contain $resource and $wrappedResource as arguments in the trace item - $resource = fopen('php://memory', 'rw+'); - fwrite($resource, 'test_resource'); - $wrappedResource = new TestFooNorm; - $wrappedResource->foo = $resource; - // Just do something stupid with a resource/wrapped resource as argument - array_keys($wrappedResource); - } catch (\Exception $e) { - restore_error_handler(); - } - - $formatter = new NormalizerFormatter(); - $record = array('context' => array('exception' => $e)); - $result = $formatter->format($record); - - $this->assertRegExp( - '%"resource":"\[resource\] \(stream\)"%', - $result['context']['exception']['trace'][0] - ); - - if (version_compare(PHP_VERSION, '5.5.0', '>=')) { - $pattern = '%"wrappedResource":"\[object\] \(Monolog\\\\\\\\Formatter\\\\\\\\TestFooNorm: \)"%'; - } else { - $pattern = '%\\\\"foo\\\\":null%'; - } - - // Tests that the wrapped resource is ignored while encoding, only works for PHP <= 5.4 - $this->assertRegExp( - $pattern, - $result['context']['exception']['trace'][0] - ); - } -} - -class TestFooNorm -{ - public $foo = 'foo'; -} - -class TestBarNorm -{ - public function __toString() - { - return 'bar'; - } -} - -class TestStreamFoo -{ - public $foo; - public $resource; - - public function __construct($resource) - { - $this->resource = $resource; - $this->foo = 'BAR'; - } - - public function __toString() - { - fseek($this->resource, 0); - - return $this->foo . ' - ' . (string) stream_get_contents($this->resource); - } -} - -class TestToStringError -{ - public function __toString() - { - throw new \RuntimeException('Could not convert to string'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php deleted file mode 100644 index b1c8fd491..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/ScalarFormatterTest.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -class ScalarFormatterTest extends \PHPUnit_Framework_TestCase -{ - private $formatter; - - public function setUp() - { - $this->formatter = new ScalarFormatter(); - } - - public function buildTrace(\Exception $e) - { - $data = array(); - $trace = $e->getTrace(); - foreach ($trace as $frame) { - if (isset($frame['file'])) { - $data[] = $frame['file'].':'.$frame['line']; - } else { - $data[] = json_encode($frame); - } - } - - return $data; - } - - public function encodeJson($data) - { - if (version_compare(PHP_VERSION, '5.4.0', '>=')) { - return json_encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); - } - - return json_encode($data); - } - - public function testFormat() - { - $exception = new \Exception('foo'); - $formatted = $this->formatter->format(array( - 'foo' => 'string', - 'bar' => 1, - 'baz' => false, - 'bam' => array(1, 2, 3), - 'bat' => array('foo' => 'bar'), - 'bap' => \DateTime::createFromFormat(\DateTime::ISO8601, '1970-01-01T00:00:00+0000'), - 'ban' => $exception, - )); - - $this->assertSame(array( - 'foo' => 'string', - 'bar' => 1, - 'baz' => false, - 'bam' => $this->encodeJson(array(1, 2, 3)), - 'bat' => $this->encodeJson(array('foo' => 'bar')), - 'bap' => '1970-01-01 00:00:00', - 'ban' => $this->encodeJson(array( - 'class' => get_class($exception), - 'message' => $exception->getMessage(), - 'code' => $exception->getCode(), - 'file' => $exception->getFile() . ':' . $exception->getLine(), - 'trace' => $this->buildTrace($exception), - )), - ), $formatted); - } - - public function testFormatWithErrorContext() - { - $context = array('file' => 'foo', 'line' => 1); - $formatted = $this->formatter->format(array( - 'context' => $context, - )); - - $this->assertSame(array( - 'context' => $this->encodeJson($context), - ), $formatted); - } - - public function testFormatWithExceptionContext() - { - $exception = new \Exception('foo'); - $formatted = $this->formatter->format(array( - 'context' => array( - 'exception' => $exception, - ), - )); - - $this->assertSame(array( - 'context' => $this->encodeJson(array( - 'exception' => array( - 'class' => get_class($exception), - 'message' => $exception->getMessage(), - 'code' => $exception->getCode(), - 'file' => $exception->getFile() . ':' . $exception->getLine(), - 'trace' => $this->buildTrace($exception), - ), - )), - ), $formatted); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php b/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php deleted file mode 100644 index 52f15a360..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Formatter/WildfireFormatterTest.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Formatter; - -use Monolog\Logger; - -class WildfireFormatterTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Monolog\Formatter\WildfireFormatter::format - */ - public function testDefaultFormat() - { - $wildfire = new WildfireFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('ip' => '127.0.0.1'), - 'message' => 'log', - ); - - $message = $wildfire->format($record); - - $this->assertEquals( - '125|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},' - .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|', - $message - ); - } - - /** - * @covers Monolog\Formatter\WildfireFormatter::format - */ - public function testFormatWithFileAndLine() - { - $wildfire = new WildfireFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('from' => 'logger'), - 'datetime' => new \DateTime("@0"), - 'extra' => array('ip' => '127.0.0.1', 'file' => 'test', 'line' => 14), - 'message' => 'log', - ); - - $message = $wildfire->format($record); - - $this->assertEquals( - '129|[{"Type":"ERROR","File":"test","Line":14,"Label":"meh"},' - .'{"message":"log","context":{"from":"logger"},"extra":{"ip":"127.0.0.1"}}]|', - $message - ); - } - - /** - * @covers Monolog\Formatter\WildfireFormatter::format - */ - public function testFormatWithoutContext() - { - $wildfire = new WildfireFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - $message = $wildfire->format($record); - - $this->assertEquals( - '58|[{"Type":"ERROR","File":"","Line":"","Label":"meh"},"log"]|', - $message - ); - } - - /** - * @covers Monolog\Formatter\WildfireFormatter::formatBatch - * @expectedException BadMethodCallException - */ - public function testBatchFormatThrowException() - { - $wildfire = new WildfireFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array(), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - $wildfire->formatBatch(array($record)); - } - - /** - * @covers Monolog\Formatter\WildfireFormatter::format - */ - public function testTableFormat() - { - $wildfire = new WildfireFormatter(); - $record = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'table-channel', - 'context' => array( - WildfireFormatter::TABLE => array( - array('col1', 'col2', 'col3'), - array('val1', 'val2', 'val3'), - array('foo1', 'foo2', 'foo3'), - array('bar1', 'bar2', 'bar3'), - ), - ), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'table-message', - ); - - $message = $wildfire->format($record); - - $this->assertEquals( - '171|[{"Type":"TABLE","File":"","Line":"","Label":"table-channel: table-message"},[["col1","col2","col3"],["val1","val2","val3"],["foo1","foo2","foo3"],["bar1","bar2","bar3"]]]|', - $message - ); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php deleted file mode 100644 index 568eb9dad..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/AbstractHandlerTest.php +++ /dev/null @@ -1,115 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; -use Monolog\Processor\WebProcessor; - -class AbstractHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\AbstractHandler::__construct - * @covers Monolog\Handler\AbstractHandler::getLevel - * @covers Monolog\Handler\AbstractHandler::setLevel - * @covers Monolog\Handler\AbstractHandler::getBubble - * @covers Monolog\Handler\AbstractHandler::setBubble - * @covers Monolog\Handler\AbstractHandler::getFormatter - * @covers Monolog\Handler\AbstractHandler::setFormatter - */ - public function testConstructAndGetSet() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false)); - $this->assertEquals(Logger::WARNING, $handler->getLevel()); - $this->assertEquals(false, $handler->getBubble()); - - $handler->setLevel(Logger::ERROR); - $handler->setBubble(true); - $handler->setFormatter($formatter = new LineFormatter); - $this->assertEquals(Logger::ERROR, $handler->getLevel()); - $this->assertEquals(true, $handler->getBubble()); - $this->assertSame($formatter, $handler->getFormatter()); - } - - /** - * @covers Monolog\Handler\AbstractHandler::handleBatch - */ - public function testHandleBatch() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); - $handler->expects($this->exactly(2)) - ->method('handle'); - $handler->handleBatch(array($this->getRecord(), $this->getRecord())); - } - - /** - * @covers Monolog\Handler\AbstractHandler::isHandling - */ - public function testIsHandling() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array(Logger::WARNING, false)); - $this->assertTrue($handler->isHandling($this->getRecord())); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); - } - - /** - * @covers Monolog\Handler\AbstractHandler::__construct - */ - public function testHandlesPsrStyleLevels() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler', array('warning', false)); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); - $handler->setLevel('debug'); - $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG))); - } - - /** - * @covers Monolog\Handler\AbstractHandler::getFormatter - * @covers Monolog\Handler\AbstractHandler::getDefaultFormatter - */ - public function testGetFormatterInitializesDefault() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); - $this->assertInstanceOf('Monolog\Formatter\LineFormatter', $handler->getFormatter()); - } - - /** - * @covers Monolog\Handler\AbstractHandler::pushProcessor - * @covers Monolog\Handler\AbstractHandler::popProcessor - * @expectedException LogicException - */ - public function testPushPopProcessor() - { - $logger = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); - $processor1 = new WebProcessor; - $processor2 = new WebProcessor; - - $logger->pushProcessor($processor1); - $logger->pushProcessor($processor2); - - $this->assertEquals($processor2, $logger->popProcessor()); - $this->assertEquals($processor1, $logger->popProcessor()); - $logger->popProcessor(); - } - - /** - * @covers Monolog\Handler\AbstractHandler::pushProcessor - * @expectedException InvalidArgumentException - */ - public function testPushProcessorWithNonCallable() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractHandler'); - - $handler->pushProcessor(new \stdClass()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php deleted file mode 100644 index 24d4f63ce..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/AbstractProcessingHandlerTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Processor\WebProcessor; - -class AbstractProcessingHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\AbstractProcessingHandler::handle - */ - public function testHandleLowerLevelMessage() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, true)); - $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); - } - - /** - * @covers Monolog\Handler\AbstractProcessingHandler::handle - */ - public function testHandleBubbling() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, true)); - $this->assertFalse($handler->handle($this->getRecord())); - } - - /** - * @covers Monolog\Handler\AbstractProcessingHandler::handle - */ - public function testHandleNotBubbling() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::DEBUG, false)); - $this->assertTrue($handler->handle($this->getRecord())); - } - - /** - * @covers Monolog\Handler\AbstractProcessingHandler::handle - */ - public function testHandleIsFalseWhenNotHandled() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler', array(Logger::WARNING, false)); - $this->assertTrue($handler->handle($this->getRecord())); - $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); - } - - /** - * @covers Monolog\Handler\AbstractProcessingHandler::processRecord - */ - public function testProcessRecord() - { - $handler = $this->getMockForAbstractClass('Monolog\Handler\AbstractProcessingHandler'); - $handler->pushProcessor(new WebProcessor(array( - 'REQUEST_URI' => '', - 'REQUEST_METHOD' => '', - 'REMOTE_ADDR' => '', - 'SERVER_NAME' => '', - 'UNIQUE_ID' => '', - ))); - $handledRecord = null; - $handler->expects($this->once()) - ->method('write') - ->will($this->returnCallback(function ($record) use (&$handledRecord) { - $handledRecord = $record; - })) - ; - $handler->handle($this->getRecord()); - $this->assertEquals(6, count($handledRecord['extra'])); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php deleted file mode 100644 index 8e0e7237b..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/AmqpHandlerTest.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use PhpAmqpLib\Message\AMQPMessage; -use PhpAmqpLib\Connection\AMQPConnection; - -/** - * @covers Monolog\Handler\RotatingFileHandler - */ -class AmqpHandlerTest extends TestCase -{ - public function testHandleAmqpExt() - { - if (!class_exists('AMQPConnection') || !class_exists('AMQPExchange')) { - $this->markTestSkipped("amqp-php not installed"); - } - - if (!class_exists('AMQPChannel')) { - $this->markTestSkipped("Please update AMQP to version >= 1.0"); - } - - $messages = array(); - - $exchange = $this->getMock('AMQPExchange', array('publish', 'setName'), array(), '', false); - $exchange->expects($this->once()) - ->method('setName') - ->with('log') - ; - $exchange->expects($this->any()) - ->method('publish') - ->will($this->returnCallback(function ($message, $routing_key, $flags = 0, $attributes = array()) use (&$messages) { - $messages[] = array($message, $routing_key, $flags, $attributes); - })) - ; - - $handler = new AmqpHandler($exchange, 'log'); - - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $expected = array( - array( - 'message' => 'test', - 'context' => array( - 'data' => array(), - 'foo' => 34, - ), - 'level' => 300, - 'level_name' => 'WARNING', - 'channel' => 'test', - 'extra' => array(), - ), - 'warn.test', - 0, - array( - 'delivery_mode' => 2, - 'content_type' => 'application/json', - ), - ); - - $handler->handle($record); - - $this->assertCount(1, $messages); - $messages[0][0] = json_decode($messages[0][0], true); - unset($messages[0][0]['datetime']); - $this->assertEquals($expected, $messages[0]); - } - - public function testHandlePhpAmqpLib() - { - if (!class_exists('PhpAmqpLib\Connection\AMQPConnection')) { - $this->markTestSkipped("php-amqplib not installed"); - } - - $messages = array(); - - $exchange = $this->getMock('PhpAmqpLib\Channel\AMQPChannel', array('basic_publish', '__destruct'), array(), '', false); - - $exchange->expects($this->any()) - ->method('basic_publish') - ->will($this->returnCallback(function (AMQPMessage $msg, $exchange = "", $routing_key = "", $mandatory = false, $immediate = false, $ticket = null) use (&$messages) { - $messages[] = array($msg, $exchange, $routing_key, $mandatory, $immediate, $ticket); - })) - ; - - $handler = new AmqpHandler($exchange, 'log'); - - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $expected = array( - array( - 'message' => 'test', - 'context' => array( - 'data' => array(), - 'foo' => 34, - ), - 'level' => 300, - 'level_name' => 'WARNING', - 'channel' => 'test', - 'extra' => array(), - ), - 'log', - 'warn.test', - false, - false, - null, - array( - 'delivery_mode' => 2, - 'content_type' => 'application/json', - ), - ); - - $handler->handle($record); - - $this->assertCount(1, $messages); - - /* @var $msg AMQPMessage */ - $msg = $messages[0][0]; - $messages[0][0] = json_decode($msg->body, true); - $messages[0][] = $msg->get_properties(); - unset($messages[0][0]['datetime']); - - $this->assertEquals($expected, $messages[0]); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php deleted file mode 100644 index ffb1d746a..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/BrowserConsoleHandlerTest.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @covers Monolog\Handler\BrowserConsoleHandlerTest - */ -class BrowserConsoleHandlerTest extends TestCase -{ - protected function setUp() - { - BrowserConsoleHandler::reset(); - } - - protected function generateScript() - { - $reflMethod = new \ReflectionMethod('Monolog\Handler\BrowserConsoleHandler', 'generateScript'); - $reflMethod->setAccessible(true); - - return $reflMethod->invoke(null); - } - - public function testStyling() - { - $handler = new BrowserConsoleHandler(); - $handler->setFormatter($this->getIdentityFormatter()); - - $handler->handle($this->getRecord(Logger::DEBUG, 'foo[[bar]]{color: red}')); - - $expected = <<assertEquals($expected, $this->generateScript()); - } - - public function testEscaping() - { - $handler = new BrowserConsoleHandler(); - $handler->setFormatter($this->getIdentityFormatter()); - - $handler->handle($this->getRecord(Logger::DEBUG, "[foo] [[\"bar\n[baz]\"]]{color: red}")); - - $expected = <<assertEquals($expected, $this->generateScript()); - } - - public function testAutolabel() - { - $handler = new BrowserConsoleHandler(); - $handler->setFormatter($this->getIdentityFormatter()); - - $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}')); - $handler->handle($this->getRecord(Logger::DEBUG, '[[bar]]{macro: autolabel}')); - $handler->handle($this->getRecord(Logger::DEBUG, '[[foo]]{macro: autolabel}')); - - $expected = <<assertEquals($expected, $this->generateScript()); - } - - public function testContext() - { - $handler = new BrowserConsoleHandler(); - $handler->setFormatter($this->getIdentityFormatter()); - - $handler->handle($this->getRecord(Logger::DEBUG, 'test', array('foo' => 'bar'))); - - $expected = <<assertEquals($expected, $this->generateScript()); - } - - public function testConcurrentHandlers() - { - $handler1 = new BrowserConsoleHandler(); - $handler1->setFormatter($this->getIdentityFormatter()); - - $handler2 = new BrowserConsoleHandler(); - $handler2->setFormatter($this->getIdentityFormatter()); - - $handler1->handle($this->getRecord(Logger::DEBUG, 'test1')); - $handler2->handle($this->getRecord(Logger::DEBUG, 'test2')); - $handler1->handle($this->getRecord(Logger::DEBUG, 'test3')); - $handler2->handle($this->getRecord(Logger::DEBUG, 'test4')); - - $expected = <<assertEquals($expected, $this->generateScript()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php deleted file mode 100644 index da8b3c392..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/BufferHandlerTest.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -class BufferHandlerTest extends TestCase -{ - private $shutdownCheckHandler; - - /** - * @covers Monolog\Handler\BufferHandler::__construct - * @covers Monolog\Handler\BufferHandler::handle - * @covers Monolog\Handler\BufferHandler::close - */ - public function testHandleBuffers() - { - $test = new TestHandler(); - $handler = new BufferHandler($test); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $this->assertFalse($test->hasDebugRecords()); - $this->assertFalse($test->hasInfoRecords()); - $handler->close(); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue(count($test->getRecords()) === 2); - } - - /** - * @covers Monolog\Handler\BufferHandler::close - * @covers Monolog\Handler\BufferHandler::flush - */ - public function testPropagatesRecordsAtEndOfRequest() - { - $test = new TestHandler(); - $handler = new BufferHandler($test); - $handler->handle($this->getRecord(Logger::WARNING)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $this->shutdownCheckHandler = $test; - register_shutdown_function(array($this, 'checkPropagation')); - } - - public function checkPropagation() - { - if (!$this->shutdownCheckHandler->hasWarningRecords() || !$this->shutdownCheckHandler->hasDebugRecords()) { - echo '!!! BufferHandlerTest::testPropagatesRecordsAtEndOfRequest failed to verify that the messages have been propagated' . PHP_EOL; - exit(1); - } - } - - /** - * @covers Monolog\Handler\BufferHandler::handle - */ - public function testHandleBufferLimit() - { - $test = new TestHandler(); - $handler = new BufferHandler($test, 2); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $handler->handle($this->getRecord(Logger::WARNING)); - $handler->close(); - $this->assertTrue($test->hasWarningRecords()); - $this->assertTrue($test->hasInfoRecords()); - $this->assertFalse($test->hasDebugRecords()); - } - - /** - * @covers Monolog\Handler\BufferHandler::handle - */ - public function testHandleBufferLimitWithFlushOnOverflow() - { - $test = new TestHandler(); - $handler = new BufferHandler($test, 3, Logger::DEBUG, true, true); - - // send two records - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $this->assertFalse($test->hasDebugRecords()); - $this->assertCount(0, $test->getRecords()); - - // overflow - $handler->handle($this->getRecord(Logger::INFO)); - $this->assertTrue($test->hasDebugRecords()); - $this->assertCount(3, $test->getRecords()); - - // should buffer again - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertCount(3, $test->getRecords()); - - $handler->close(); - $this->assertCount(5, $test->getRecords()); - $this->assertTrue($test->hasWarningRecords()); - $this->assertTrue($test->hasInfoRecords()); - } - - /** - * @covers Monolog\Handler\BufferHandler::handle - */ - public function testHandleLevel() - { - $test = new TestHandler(); - $handler = new BufferHandler($test, 0, Logger::INFO); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $handler->handle($this->getRecord(Logger::WARNING)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->close(); - $this->assertTrue($test->hasWarningRecords()); - $this->assertTrue($test->hasInfoRecords()); - $this->assertFalse($test->hasDebugRecords()); - } - - /** - * @covers Monolog\Handler\BufferHandler::flush - */ - public function testFlush() - { - $test = new TestHandler(); - $handler = new BufferHandler($test, 0); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $handler->flush(); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue($test->hasDebugRecords()); - $this->assertFalse($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\BufferHandler::handle - */ - public function testHandleUsesProcessors() - { - $test = new TestHandler(); - $handler = new BufferHandler($test); - $handler->pushProcessor(function ($record) { - $record['extra']['foo'] = true; - - return $record; - }); - $handler->handle($this->getRecord(Logger::WARNING)); - $handler->flush(); - $this->assertTrue($test->hasWarningRecords()); - $records = $test->getRecords(); - $this->assertTrue($records[0]['extra']['foo']); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php deleted file mode 100644 index ef3cd1cbc..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/ChromePHPHandlerTest.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @covers Monolog\Handler\ChromePHPHandler - */ -class ChromePHPHandlerTest extends TestCase -{ - protected function setUp() - { - TestChromePHPHandler::reset(); - $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; Chrome/1.0'; - } - - public function testHeaders() - { - $handler = new TestChromePHPHandler(); - $handler->setFormatter($this->getIdentityFormatter()); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::WARNING)); - - $expected = array( - 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array( - 'version' => ChromePHPHandler::VERSION, - 'columns' => array('label', 'log', 'backtrace', 'type'), - 'rows' => array( - 'test', - 'test', - ), - 'request_uri' => '', - )))), - ); - - $this->assertEquals($expected, $handler->getHeaders()); - } - - public function testHeadersOverflow() - { - $handler = new TestChromePHPHandler(); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 150 * 1024))); - - // overflow chrome headers limit - $handler->handle($this->getRecord(Logger::WARNING, str_repeat('a', 100 * 1024))); - - $expected = array( - 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array( - 'version' => ChromePHPHandler::VERSION, - 'columns' => array('label', 'log', 'backtrace', 'type'), - 'rows' => array( - array( - 'test', - 'test', - 'unknown', - 'log', - ), - array( - 'test', - str_repeat('a', 150 * 1024), - 'unknown', - 'warn', - ), - array( - 'monolog', - 'Incomplete logs, chrome header size limit reached', - 'unknown', - 'warn', - ), - ), - 'request_uri' => '', - )))), - ); - - $this->assertEquals($expected, $handler->getHeaders()); - } - - public function testConcurrentHandlers() - { - $handler = new TestChromePHPHandler(); - $handler->setFormatter($this->getIdentityFormatter()); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::WARNING)); - - $handler2 = new TestChromePHPHandler(); - $handler2->setFormatter($this->getIdentityFormatter()); - $handler2->handle($this->getRecord(Logger::DEBUG)); - $handler2->handle($this->getRecord(Logger::WARNING)); - - $expected = array( - 'X-ChromeLogger-Data' => base64_encode(utf8_encode(json_encode(array( - 'version' => ChromePHPHandler::VERSION, - 'columns' => array('label', 'log', 'backtrace', 'type'), - 'rows' => array( - 'test', - 'test', - 'test', - 'test', - ), - 'request_uri' => '', - )))), - ); - - $this->assertEquals($expected, $handler2->getHeaders()); - } -} - -class TestChromePHPHandler extends ChromePHPHandler -{ - protected $headers = array(); - - public static function reset() - { - self::$initialized = false; - self::$overflowed = false; - self::$sendHeaders = true; - self::$json['rows'] = array(); - } - - protected function sendHeader($header, $content) - { - $this->headers[$header] = $content; - } - - public function getHeaders() - { - return $this->headers; - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php deleted file mode 100644 index 9fc4b3885..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/CouchDBHandlerTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -class CouchDBHandlerTest extends TestCase -{ - public function testHandle() - { - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $handler = new CouchDBHandler(); - - try { - $handler->handle($record); - } catch (\RuntimeException $e) { - $this->markTestSkipped('Could not connect to couchdb server on http://localhost:5984'); - } - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/DeduplicationHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/DeduplicationHandlerTest.php deleted file mode 100644 index e2aff868a..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/DeduplicationHandlerTest.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -class DeduplicationHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\DeduplicationHandler::flush - */ - public function testFlushPassthruIfAllRecordsUnderTrigger() - { - $test = new TestHandler(); - @unlink(sys_get_temp_dir().'/monolog_dedup.log'); - $handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0); - - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - - $handler->flush(); - - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue($test->hasDebugRecords()); - $this->assertFalse($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\DeduplicationHandler::flush - * @covers Monolog\Handler\DeduplicationHandler::appendRecord - */ - public function testFlushPassthruIfEmptyLog() - { - $test = new TestHandler(); - @unlink(sys_get_temp_dir().'/monolog_dedup.log'); - $handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0); - - $handler->handle($this->getRecord(Logger::ERROR, 'Foo:bar')); - $handler->handle($this->getRecord(Logger::CRITICAL, "Foo\nbar")); - - $handler->flush(); - - $this->assertTrue($test->hasErrorRecords()); - $this->assertTrue($test->hasCriticalRecords()); - $this->assertFalse($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\DeduplicationHandler::flush - * @covers Monolog\Handler\DeduplicationHandler::appendRecord - * @covers Monolog\Handler\DeduplicationHandler::isDuplicate - * @depends testFlushPassthruIfEmptyLog - */ - public function testFlushSkipsIfLogExists() - { - $test = new TestHandler(); - $handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0); - - $handler->handle($this->getRecord(Logger::ERROR, 'Foo:bar')); - $handler->handle($this->getRecord(Logger::CRITICAL, "Foo\nbar")); - - $handler->flush(); - - $this->assertFalse($test->hasErrorRecords()); - $this->assertFalse($test->hasCriticalRecords()); - $this->assertFalse($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\DeduplicationHandler::flush - * @covers Monolog\Handler\DeduplicationHandler::appendRecord - * @covers Monolog\Handler\DeduplicationHandler::isDuplicate - * @depends testFlushPassthruIfEmptyLog - */ - public function testFlushPassthruIfLogTooOld() - { - $test = new TestHandler(); - $handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0); - - $record = $this->getRecord(Logger::ERROR); - $record['datetime']->modify('+62seconds'); - $handler->handle($record); - $record = $this->getRecord(Logger::CRITICAL); - $record['datetime']->modify('+62seconds'); - $handler->handle($record); - - $handler->flush(); - - $this->assertTrue($test->hasErrorRecords()); - $this->assertTrue($test->hasCriticalRecords()); - $this->assertFalse($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\DeduplicationHandler::flush - * @covers Monolog\Handler\DeduplicationHandler::appendRecord - * @covers Monolog\Handler\DeduplicationHandler::isDuplicate - * @covers Monolog\Handler\DeduplicationHandler::collectLogs - */ - public function testGcOldLogs() - { - $test = new TestHandler(); - @unlink(sys_get_temp_dir().'/monolog_dedup.log'); - $handler = new DeduplicationHandler($test, sys_get_temp_dir().'/monolog_dedup.log', 0); - - // handle two records from yesterday, and one recent - $record = $this->getRecord(Logger::ERROR); - $record['datetime']->modify('-1day -10seconds'); - $handler->handle($record); - $record2 = $this->getRecord(Logger::CRITICAL); - $record2['datetime']->modify('-1day -10seconds'); - $handler->handle($record2); - $record3 = $this->getRecord(Logger::CRITICAL); - $record3['datetime']->modify('-30seconds'); - $handler->handle($record3); - - // log is written as none of them are duplicate - $handler->flush(); - $this->assertSame( - $record['datetime']->getTimestamp() . ":ERROR:test\n" . - $record2['datetime']->getTimestamp() . ":CRITICAL:test\n" . - $record3['datetime']->getTimestamp() . ":CRITICAL:test\n", - file_get_contents(sys_get_temp_dir() . '/monolog_dedup.log') - ); - $this->assertTrue($test->hasErrorRecords()); - $this->assertTrue($test->hasCriticalRecords()); - $this->assertFalse($test->hasWarningRecords()); - - // clear test handler - $test->clear(); - $this->assertFalse($test->hasErrorRecords()); - $this->assertFalse($test->hasCriticalRecords()); - - // log new records, duplicate log gets GC'd at the end of this flush call - $handler->handle($record = $this->getRecord(Logger::ERROR)); - $handler->handle($record2 = $this->getRecord(Logger::CRITICAL)); - $handler->flush(); - - // log should now contain the new errors and the previous one that was recent enough - $this->assertSame( - $record3['datetime']->getTimestamp() . ":CRITICAL:test\n" . - $record['datetime']->getTimestamp() . ":ERROR:test\n" . - $record2['datetime']->getTimestamp() . ":CRITICAL:test\n", - file_get_contents(sys_get_temp_dir() . '/monolog_dedup.log') - ); - $this->assertTrue($test->hasErrorRecords()); - $this->assertTrue($test->hasCriticalRecords()); - $this->assertFalse($test->hasWarningRecords()); - } - - public static function tearDownAfterClass() - { - @unlink(sys_get_temp_dir().'/monolog_dedup.log'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php deleted file mode 100644 index d67da90ae..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/DoctrineCouchDBHandlerTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -class DoctrineCouchDBHandlerTest extends TestCase -{ - protected function setup() - { - if (!class_exists('Doctrine\CouchDB\CouchDBClient')) { - $this->markTestSkipped('The "doctrine/couchdb" package is not installed'); - } - } - - public function testHandle() - { - $client = $this->getMockBuilder('Doctrine\\CouchDB\\CouchDBClient') - ->setMethods(array('postDocument')) - ->disableOriginalConstructor() - ->getMock(); - - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $expected = array( - 'message' => 'test', - 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34), - 'level' => Logger::WARNING, - 'level_name' => 'WARNING', - 'channel' => 'test', - 'datetime' => $record['datetime']->format('Y-m-d H:i:s'), - 'extra' => array(), - ); - - $client->expects($this->once()) - ->method('postDocument') - ->with($expected); - - $handler = new DoctrineCouchDBHandler($client); - $handler->handle($record); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php deleted file mode 100644 index f3a696806..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/DynamoDbHandlerTest.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; - -class DynamoDbHandlerTest extends TestCase -{ - private $client; - - public function setUp() - { - if (!class_exists('Aws\DynamoDb\DynamoDbClient')) { - $this->markTestSkipped('aws/aws-sdk-php not installed'); - } - - $this->client = $this->getMockBuilder('Aws\DynamoDb\DynamoDbClient') - ->setMethods(array('formatAttributes', '__call')) - ->disableOriginalConstructor()->getMock(); - } - - public function testConstruct() - { - $this->assertInstanceOf('Monolog\Handler\DynamoDbHandler', new DynamoDbHandler($this->client, 'foo')); - } - - public function testInterface() - { - $this->assertInstanceOf('Monolog\Handler\HandlerInterface', new DynamoDbHandler($this->client, 'foo')); - } - - public function testGetFormatter() - { - $handler = new DynamoDbHandler($this->client, 'foo'); - $this->assertInstanceOf('Monolog\Formatter\ScalarFormatter', $handler->getFormatter()); - } - - public function testHandle() - { - $record = $this->getRecord(); - $formatter = $this->getMock('Monolog\Formatter\FormatterInterface'); - $formatted = array('foo' => 1, 'bar' => 2); - $handler = new DynamoDbHandler($this->client, 'foo'); - $handler->setFormatter($formatter); - - $formatter - ->expects($this->once()) - ->method('format') - ->with($record) - ->will($this->returnValue($formatted)); - $this->client - ->expects($this->once()) - ->method('formatAttributes') - ->with($this->isType('array')) - ->will($this->returnValue($formatted)); - $this->client - ->expects($this->once()) - ->method('__call') - ->with('putItem', array(array( - 'TableName' => 'foo', - 'Item' => $formatted, - ))); - - $handler->handle($record); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php deleted file mode 100644 index 1687074b8..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/ElasticSearchHandlerTest.php +++ /dev/null @@ -1,239 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\ElasticaFormatter; -use Monolog\Formatter\NormalizerFormatter; -use Monolog\TestCase; -use Monolog\Logger; -use Elastica\Client; -use Elastica\Request; -use Elastica\Response; - -class ElasticSearchHandlerTest extends TestCase -{ - /** - * @var Client mock - */ - protected $client; - - /** - * @var array Default handler options - */ - protected $options = array( - 'index' => 'my_index', - 'type' => 'doc_type', - ); - - public function setUp() - { - // Elastica lib required - if (!class_exists("Elastica\Client")) { - $this->markTestSkipped("ruflin/elastica not installed"); - } - - // base mock Elastica Client object - $this->client = $this->getMockBuilder('Elastica\Client') - ->setMethods(array('addDocuments')) - ->disableOriginalConstructor() - ->getMock(); - } - - /** - * @covers Monolog\Handler\ElasticSearchHandler::write - * @covers Monolog\Handler\ElasticSearchHandler::handleBatch - * @covers Monolog\Handler\ElasticSearchHandler::bulkSend - * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter - */ - public function testHandle() - { - // log message - $msg = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - // format expected result - $formatter = new ElasticaFormatter($this->options['index'], $this->options['type']); - $expected = array($formatter->format($msg)); - - // setup ES client mock - $this->client->expects($this->any()) - ->method('addDocuments') - ->with($expected); - - // perform tests - $handler = new ElasticSearchHandler($this->client, $this->options); - $handler->handle($msg); - $handler->handleBatch(array($msg)); - } - - /** - * @covers Monolog\Handler\ElasticSearchHandler::setFormatter - */ - public function testSetFormatter() - { - $handler = new ElasticSearchHandler($this->client); - $formatter = new ElasticaFormatter('index_new', 'type_new'); - $handler->setFormatter($formatter); - $this->assertInstanceOf('Monolog\Formatter\ElasticaFormatter', $handler->getFormatter()); - $this->assertEquals('index_new', $handler->getFormatter()->getIndex()); - $this->assertEquals('type_new', $handler->getFormatter()->getType()); - } - - /** - * @covers Monolog\Handler\ElasticSearchHandler::setFormatter - * @expectedException InvalidArgumentException - * @expectedExceptionMessage ElasticSearchHandler is only compatible with ElasticaFormatter - */ - public function testSetFormatterInvalid() - { - $handler = new ElasticSearchHandler($this->client); - $formatter = new NormalizerFormatter(); - $handler->setFormatter($formatter); - } - - /** - * @covers Monolog\Handler\ElasticSearchHandler::__construct - * @covers Monolog\Handler\ElasticSearchHandler::getOptions - */ - public function testOptions() - { - $expected = array( - 'index' => $this->options['index'], - 'type' => $this->options['type'], - 'ignore_error' => false, - ); - $handler = new ElasticSearchHandler($this->client, $this->options); - $this->assertEquals($expected, $handler->getOptions()); - } - - /** - * @covers Monolog\Handler\ElasticSearchHandler::bulkSend - * @dataProvider providerTestConnectionErrors - */ - public function testConnectionErrors($ignore, $expectedError) - { - $clientOpts = array('host' => '127.0.0.1', 'port' => 1); - $client = new Client($clientOpts); - $handlerOpts = array('ignore_error' => $ignore); - $handler = new ElasticSearchHandler($client, $handlerOpts); - - if ($expectedError) { - $this->setExpectedException($expectedError[0], $expectedError[1]); - $handler->handle($this->getRecord()); - } else { - $this->assertFalse($handler->handle($this->getRecord())); - } - } - - /** - * @return array - */ - public function providerTestConnectionErrors() - { - return array( - array(false, array('RuntimeException', 'Error sending messages to Elasticsearch')), - array(true, false), - ); - } - - /** - * Integration test using localhost Elastic Search server - * - * @covers Monolog\Handler\ElasticSearchHandler::__construct - * @covers Monolog\Handler\ElasticSearchHandler::handleBatch - * @covers Monolog\Handler\ElasticSearchHandler::bulkSend - * @covers Monolog\Handler\ElasticSearchHandler::getDefaultFormatter - */ - public function testHandleIntegration() - { - $msg = array( - 'level' => Logger::ERROR, - 'level_name' => 'ERROR', - 'channel' => 'meh', - 'context' => array('foo' => 7, 'bar', 'class' => new \stdClass), - 'datetime' => new \DateTime("@0"), - 'extra' => array(), - 'message' => 'log', - ); - - $expected = $msg; - $expected['datetime'] = $msg['datetime']->format(\DateTime::ISO8601); - $expected['context'] = array( - 'class' => '[object] (stdClass: {})', - 'foo' => 7, - 0 => 'bar', - ); - - $client = new Client(); - $handler = new ElasticSearchHandler($client, $this->options); - try { - $handler->handleBatch(array($msg)); - } catch (\RuntimeException $e) { - $this->markTestSkipped("Cannot connect to Elastic Search server on localhost"); - } - - // check document id from ES server response - $documentId = $this->getCreatedDocId($client->getLastResponse()); - $this->assertNotEmpty($documentId, 'No elastic document id received'); - - // retrieve document source from ES and validate - $document = $this->getDocSourceFromElastic( - $client, - $this->options['index'], - $this->options['type'], - $documentId - ); - $this->assertEquals($expected, $document); - - // remove test index from ES - $client->request("/{$this->options['index']}", Request::DELETE); - } - - /** - * Return last created document id from ES response - * @param Response $response Elastica Response object - * @return string|null - */ - protected function getCreatedDocId(Response $response) - { - $data = $response->getData(); - if (!empty($data['items'][0]['create']['_id'])) { - return $data['items'][0]['create']['_id']; - } - } - - /** - * Retrieve document by id from Elasticsearch - * @param Client $client Elastica client - * @param string $index - * @param string $type - * @param string $documentId - * @return array - */ - protected function getDocSourceFromElastic(Client $client, $index, $type, $documentId) - { - $resp = $client->request("/{$index}/{$type}/{$documentId}", Request::GET); - $data = $resp->getData(); - if (!empty($data['_source'])) { - return $data['_source']; - } - - return array(); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php deleted file mode 100644 index 99785cbbb..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/ErrorLogHandlerTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; - -function error_log() -{ - $GLOBALS['error_log'][] = func_get_args(); -} - -class ErrorLogHandlerTest extends TestCase -{ - protected function setUp() - { - $GLOBALS['error_log'] = array(); - } - - /** - * @covers Monolog\Handler\ErrorLogHandler::__construct - * @expectedException InvalidArgumentException - * @expectedExceptionMessage The given message type "42" is not supported - */ - public function testShouldNotAcceptAnInvalidTypeOnContructor() - { - new ErrorLogHandler(42); - } - - /** - * @covers Monolog\Handler\ErrorLogHandler::write - */ - public function testShouldLogMessagesUsingErrorLogFuncion() - { - $type = ErrorLogHandler::OPERATING_SYSTEM; - $handler = new ErrorLogHandler($type); - $handler->setFormatter(new LineFormatter('%channel%.%level_name%: %message% %context% %extra%', null, true)); - $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz")); - - $this->assertSame("test.ERROR: Foo\nBar\r\n\r\nBaz [] []", $GLOBALS['error_log'][0][0]); - $this->assertSame($GLOBALS['error_log'][0][1], $type); - - $handler = new ErrorLogHandler($type, Logger::DEBUG, true, true); - $handler->setFormatter(new LineFormatter(null, null, true)); - $handler->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz")); - - $this->assertStringMatchesFormat('[%s] test.ERROR: Foo', $GLOBALS['error_log'][1][0]); - $this->assertSame($GLOBALS['error_log'][1][1], $type); - - $this->assertStringMatchesFormat('Bar', $GLOBALS['error_log'][2][0]); - $this->assertSame($GLOBALS['error_log'][2][1], $type); - - $this->assertStringMatchesFormat('Baz [] []', $GLOBALS['error_log'][3][0]); - $this->assertSame($GLOBALS['error_log'][3][1], $type); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php deleted file mode 100644 index 31b7686a0..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/FilterHandlerTest.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\TestCase; - -class FilterHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\FilterHandler::isHandling - */ - public function testIsHandling() - { - $test = new TestHandler(); - $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); - $this->assertTrue($handler->isHandling($this->getRecord(Logger::INFO))); - $this->assertTrue($handler->isHandling($this->getRecord(Logger::NOTICE))); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::WARNING))); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::ERROR))); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::CRITICAL))); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::ALERT))); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::EMERGENCY))); - } - - /** - * @covers Monolog\Handler\FilterHandler::handle - * @covers Monolog\Handler\FilterHandler::setAcceptedLevels - * @covers Monolog\Handler\FilterHandler::isHandling - */ - public function testHandleProcessOnlyNeededLevels() - { - $test = new TestHandler(); - $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE); - - $handler->handle($this->getRecord(Logger::DEBUG)); - $this->assertFalse($test->hasDebugRecords()); - - $handler->handle($this->getRecord(Logger::INFO)); - $this->assertTrue($test->hasInfoRecords()); - $handler->handle($this->getRecord(Logger::NOTICE)); - $this->assertTrue($test->hasNoticeRecords()); - - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertFalse($test->hasWarningRecords()); - $handler->handle($this->getRecord(Logger::ERROR)); - $this->assertFalse($test->hasErrorRecords()); - $handler->handle($this->getRecord(Logger::CRITICAL)); - $this->assertFalse($test->hasCriticalRecords()); - $handler->handle($this->getRecord(Logger::ALERT)); - $this->assertFalse($test->hasAlertRecords()); - $handler->handle($this->getRecord(Logger::EMERGENCY)); - $this->assertFalse($test->hasEmergencyRecords()); - - $test = new TestHandler(); - $handler = new FilterHandler($test, array(Logger::INFO, Logger::ERROR)); - - $handler->handle($this->getRecord(Logger::DEBUG)); - $this->assertFalse($test->hasDebugRecords()); - $handler->handle($this->getRecord(Logger::INFO)); - $this->assertTrue($test->hasInfoRecords()); - $handler->handle($this->getRecord(Logger::NOTICE)); - $this->assertFalse($test->hasNoticeRecords()); - $handler->handle($this->getRecord(Logger::ERROR)); - $this->assertTrue($test->hasErrorRecords()); - $handler->handle($this->getRecord(Logger::CRITICAL)); - $this->assertFalse($test->hasCriticalRecords()); - } - - /** - * @covers Monolog\Handler\FilterHandler::setAcceptedLevels - * @covers Monolog\Handler\FilterHandler::getAcceptedLevels - */ - public function testAcceptedLevelApi() - { - $test = new TestHandler(); - $handler = new FilterHandler($test); - - $levels = array(Logger::INFO, Logger::ERROR); - $handler->setAcceptedLevels($levels); - $this->assertSame($levels, $handler->getAcceptedLevels()); - - $handler->setAcceptedLevels(array('info', 'error')); - $this->assertSame($levels, $handler->getAcceptedLevels()); - - $levels = array(Logger::CRITICAL, Logger::ALERT, Logger::EMERGENCY); - $handler->setAcceptedLevels(Logger::CRITICAL, Logger::EMERGENCY); - $this->assertSame($levels, $handler->getAcceptedLevels()); - - $handler->setAcceptedLevels('critical', 'emergency'); - $this->assertSame($levels, $handler->getAcceptedLevels()); - } - - /** - * @covers Monolog\Handler\FilterHandler::handle - */ - public function testHandleUsesProcessors() - { - $test = new TestHandler(); - $handler = new FilterHandler($test, Logger::DEBUG, Logger::EMERGENCY); - $handler->pushProcessor( - function ($record) { - $record['extra']['foo'] = true; - - return $record; - } - ); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasWarningRecords()); - $records = $test->getRecords(); - $this->assertTrue($records[0]['extra']['foo']); - } - - /** - * @covers Monolog\Handler\FilterHandler::handle - */ - public function testHandleRespectsBubble() - { - $test = new TestHandler(); - - $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, false); - $this->assertTrue($handler->handle($this->getRecord(Logger::INFO))); - $this->assertFalse($handler->handle($this->getRecord(Logger::WARNING))); - - $handler = new FilterHandler($test, Logger::INFO, Logger::NOTICE, true); - $this->assertFalse($handler->handle($this->getRecord(Logger::INFO))); - $this->assertFalse($handler->handle($this->getRecord(Logger::WARNING))); - } - - /** - * @covers Monolog\Handler\FilterHandler::handle - */ - public function testHandleWithCallback() - { - $test = new TestHandler(); - $handler = new FilterHandler( - function ($record, $handler) use ($test) { - return $test; - }, Logger::INFO, Logger::NOTICE, false - ); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $this->assertFalse($test->hasDebugRecords()); - $this->assertTrue($test->hasInfoRecords()); - } - - /** - * @covers Monolog\Handler\FilterHandler::handle - * @expectedException \RuntimeException - */ - public function testHandleWithBadCallbackThrowsException() - { - $handler = new FilterHandler( - function ($record, $handler) { - return 'foo'; - } - ); - $handler->handle($this->getRecord(Logger::WARNING)); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php deleted file mode 100644 index b92bf437b..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/FingersCrossedHandlerTest.php +++ /dev/null @@ -1,279 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy; -use Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy; -use Psr\Log\LogLevel; - -class FingersCrossedHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\FingersCrossedHandler::__construct - * @covers Monolog\Handler\FingersCrossedHandler::handle - * @covers Monolog\Handler\FingersCrossedHandler::activate - */ - public function testHandleBuffers() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $this->assertFalse($test->hasDebugRecords()); - $this->assertFalse($test->hasInfoRecords()); - $handler->handle($this->getRecord(Logger::WARNING)); - $handler->close(); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue(count($test->getRecords()) === 3); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::handle - * @covers Monolog\Handler\FingersCrossedHandler::activate - */ - public function testHandleStopsBufferingAfterTrigger() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test); - $handler->handle($this->getRecord(Logger::WARNING)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->close(); - $this->assertTrue($test->hasWarningRecords()); - $this->assertTrue($test->hasDebugRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::handle - * @covers Monolog\Handler\FingersCrossedHandler::activate - * @covers Monolog\Handler\FingersCrossedHandler::reset - */ - public function testHandleRestartBufferingAfterReset() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test); - $handler->handle($this->getRecord(Logger::WARNING)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->reset(); - $handler->handle($this->getRecord(Logger::INFO)); - $handler->close(); - $this->assertTrue($test->hasWarningRecords()); - $this->assertTrue($test->hasDebugRecords()); - $this->assertFalse($test->hasInfoRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::handle - * @covers Monolog\Handler\FingersCrossedHandler::activate - */ - public function testHandleRestartBufferingAfterBeingTriggeredWhenStopBufferingIsDisabled() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, Logger::WARNING, 0, false, false); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::WARNING)); - $handler->handle($this->getRecord(Logger::INFO)); - $handler->close(); - $this->assertTrue($test->hasWarningRecords()); - $this->assertTrue($test->hasDebugRecords()); - $this->assertFalse($test->hasInfoRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::handle - * @covers Monolog\Handler\FingersCrossedHandler::activate - */ - public function testHandleBufferLimit() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, Logger::WARNING, 2); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasWarningRecords()); - $this->assertTrue($test->hasInfoRecords()); - $this->assertFalse($test->hasDebugRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::handle - * @covers Monolog\Handler\FingersCrossedHandler::activate - */ - public function testHandleWithCallback() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler(function ($record, $handler) use ($test) { - return $test; - }); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $this->assertFalse($test->hasDebugRecords()); - $this->assertFalse($test->hasInfoRecords()); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue(count($test->getRecords()) === 3); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::handle - * @covers Monolog\Handler\FingersCrossedHandler::activate - * @expectedException RuntimeException - */ - public function testHandleWithBadCallbackThrowsException() - { - $handler = new FingersCrossedHandler(function ($record, $handler) { - return 'foo'; - }); - $handler->handle($this->getRecord(Logger::WARNING)); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::isHandling - */ - public function testIsHandlingAlways() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, Logger::ERROR); - $this->assertTrue($handler->isHandling($this->getRecord(Logger::DEBUG))); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::__construct - * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::__construct - * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::isHandlerActivated - */ - public function testErrorLevelActivationStrategy() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING)); - $handler->handle($this->getRecord(Logger::DEBUG)); - $this->assertFalse($test->hasDebugRecords()); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::__construct - * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::__construct - * @covers Monolog\Handler\FingersCrossed\ErrorLevelActivationStrategy::isHandlerActivated - */ - public function testErrorLevelActivationStrategyWithPsrLevel() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy('warning')); - $handler->handle($this->getRecord(Logger::DEBUG)); - $this->assertFalse($test->hasDebugRecords()); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::__construct - * @covers Monolog\Handler\FingersCrossedHandler::activate - */ - public function testOverrideActivationStrategy() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy('warning')); - $handler->handle($this->getRecord(Logger::DEBUG)); - $this->assertFalse($test->hasDebugRecords()); - $handler->activate(); - $this->assertTrue($test->hasDebugRecords()); - $handler->handle($this->getRecord(Logger::INFO)); - $this->assertTrue($test->hasInfoRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::__construct - * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::isHandlerActivated - */ - public function testChannelLevelActivationStrategy() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy(Logger::ERROR, array('othertest' => Logger::DEBUG))); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertFalse($test->hasWarningRecords()); - $record = $this->getRecord(Logger::DEBUG); - $record['channel'] = 'othertest'; - $handler->handle($record); - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::__construct - * @covers Monolog\Handler\FingersCrossed\ChannelLevelActivationStrategy::isHandlerActivated - */ - public function testChannelLevelActivationStrategyWithPsrLevels() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, new ChannelLevelActivationStrategy('error', array('othertest' => 'debug'))); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertFalse($test->hasWarningRecords()); - $record = $this->getRecord(Logger::DEBUG); - $record['channel'] = 'othertest'; - $handler->handle($record); - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasWarningRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::handle - * @covers Monolog\Handler\FingersCrossedHandler::activate - */ - public function testHandleUsesProcessors() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, Logger::INFO); - $handler->pushProcessor(function ($record) { - $record['extra']['foo'] = true; - - return $record; - }); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasWarningRecords()); - $records = $test->getRecords(); - $this->assertTrue($records[0]['extra']['foo']); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::close - */ - public function testPassthruOnClose() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, true, true, Logger::INFO); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $handler->close(); - $this->assertFalse($test->hasDebugRecords()); - $this->assertTrue($test->hasInfoRecords()); - } - - /** - * @covers Monolog\Handler\FingersCrossedHandler::close - */ - public function testPsrLevelPassthruOnClose() - { - $test = new TestHandler(); - $handler = new FingersCrossedHandler($test, new ErrorLevelActivationStrategy(Logger::WARNING), 0, true, true, LogLevel::INFO); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - $handler->close(); - $this->assertFalse($test->hasDebugRecords()); - $this->assertTrue($test->hasInfoRecords()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php deleted file mode 100644 index 0eb10a63f..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/FirePHPHandlerTest.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @covers Monolog\Handler\FirePHPHandler - */ -class FirePHPHandlerTest extends TestCase -{ - public function setUp() - { - TestFirePHPHandler::reset(); - $_SERVER['HTTP_USER_AGENT'] = 'Monolog Test; FirePHP/1.0'; - } - - public function testHeaders() - { - $handler = new TestFirePHPHandler; - $handler->setFormatter($this->getIdentityFormatter()); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::WARNING)); - - $expected = array( - 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2', - 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1', - 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3', - 'X-Wf-1-1-1-1' => 'test', - 'X-Wf-1-1-1-2' => 'test', - ); - - $this->assertEquals($expected, $handler->getHeaders()); - } - - public function testConcurrentHandlers() - { - $handler = new TestFirePHPHandler; - $handler->setFormatter($this->getIdentityFormatter()); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::WARNING)); - - $handler2 = new TestFirePHPHandler; - $handler2->setFormatter($this->getIdentityFormatter()); - $handler2->handle($this->getRecord(Logger::DEBUG)); - $handler2->handle($this->getRecord(Logger::WARNING)); - - $expected = array( - 'X-Wf-Protocol-1' => 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2', - 'X-Wf-1-Structure-1' => 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1', - 'X-Wf-1-Plugin-1' => 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/0.3', - 'X-Wf-1-1-1-1' => 'test', - 'X-Wf-1-1-1-2' => 'test', - ); - - $expected2 = array( - 'X-Wf-1-1-1-3' => 'test', - 'X-Wf-1-1-1-4' => 'test', - ); - - $this->assertEquals($expected, $handler->getHeaders()); - $this->assertEquals($expected2, $handler2->getHeaders()); - } -} - -class TestFirePHPHandler extends FirePHPHandler -{ - protected $headers = array(); - - public static function reset() - { - self::$initialized = false; - self::$sendHeaders = true; - self::$messageIndex = 1; - } - - protected function sendHeader($header, $content) - { - $this->headers[$header] = $content; - } - - public function getHeaders() - { - return $this->headers; - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/Fixtures/.gitkeep b/vendor/monolog/monolog/tests/Monolog/Handler/Fixtures/.gitkeep deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php deleted file mode 100644 index 91cdd3128..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/FleepHookHandlerTest.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\LineFormatter; -use Monolog\Logger; -use Monolog\TestCase; - -/** - * @coversDefaultClass \Monolog\Handler\FleepHookHandler - */ -class FleepHookHandlerTest extends TestCase -{ - /** - * Default token to use in tests - */ - const TOKEN = '123abc'; - - /** - * @var FleepHookHandler - */ - private $handler; - - public function setUp() - { - parent::setUp(); - - if (!extension_loaded('openssl')) { - $this->markTestSkipped('This test requires openssl extension to run'); - } - - // Create instances of the handler and logger for convenience - $this->handler = new FleepHookHandler(self::TOKEN); - } - - /** - * @covers ::__construct - */ - public function testConstructorSetsExpectedDefaults() - { - $this->assertEquals(Logger::DEBUG, $this->handler->getLevel()); - $this->assertEquals(true, $this->handler->getBubble()); - } - - /** - * @covers ::getDefaultFormatter - */ - public function testHandlerUsesLineFormatterWhichIgnoresEmptyArrays() - { - $record = array( - 'message' => 'msg', - 'context' => array(), - 'level' => Logger::DEBUG, - 'level_name' => Logger::getLevelName(Logger::DEBUG), - 'channel' => 'channel', - 'datetime' => new \DateTime(), - 'extra' => array(), - ); - - $expectedFormatter = new LineFormatter(null, null, true, true); - $expected = $expectedFormatter->format($record); - - $handlerFormatter = $this->handler->getFormatter(); - $actual = $handlerFormatter->format($record); - - $this->assertEquals($expected, $actual, 'Empty context and extra arrays should not be rendered'); - } - - /** - * @covers ::__construct - */ - public function testConnectionStringisConstructedCorrectly() - { - $this->assertEquals('ssl://' . FleepHookHandler::FLEEP_HOST . ':443', $this->handler->getConnectionString()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php deleted file mode 100644 index 4b120d51a..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/FlowdockHandlerTest.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\FlowdockFormatter; -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @author Dominik Liebler - * @see https://www.hipchat.com/docs/api - */ -class FlowdockHandlerTest extends TestCase -{ - /** - * @var resource - */ - private $res; - - /** - * @var FlowdockHandler - */ - private $handler; - - public function setUp() - { - if (!extension_loaded('openssl')) { - $this->markTestSkipped('This test requires openssl to run'); - } - } - - public function testWriteHeader() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/v1\/messages\/team_inbox\/.* HTTP\/1.1\\r\\nHost: api.flowdock.com\\r\\nContent-Type: application\/json\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); - - return $content; - } - - /** - * @depends testWriteHeader - */ - public function testWriteContent($content) - { - $this->assertRegexp('/"source":"test_source"/', $content); - $this->assertRegexp('/"from_address":"source@test\.com"/', $content); - } - - private function createHandler($token = 'myToken') - { - $constructorArgs = array($token, Logger::DEBUG); - $this->res = fopen('php://memory', 'a'); - $this->handler = $this->getMock( - '\Monolog\Handler\FlowdockHandler', - array('fsockopen', 'streamSetTimeout', 'closeSocket'), - $constructorArgs - ); - - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($this->handler, 'localhost:1234'); - - $this->handler->expects($this->any()) - ->method('fsockopen') - ->will($this->returnValue($this->res)); - $this->handler->expects($this->any()) - ->method('streamSetTimeout') - ->will($this->returnValue(true)); - $this->handler->expects($this->any()) - ->method('closeSocket') - ->will($this->returnValue(true)); - - $this->handler->setFormatter(new FlowdockFormatter('test_source', 'source@test.com')); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php deleted file mode 100644 index 9d007b13d..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerLegacyTest.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Gelf\Message; -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Formatter\GelfMessageFormatter; - -class GelfHandlerLegacyTest extends TestCase -{ - public function setUp() - { - if (!class_exists('Gelf\MessagePublisher') || !class_exists('Gelf\Message')) { - $this->markTestSkipped("mlehner/gelf-php not installed"); - } - - require_once __DIR__ . '/GelfMockMessagePublisher.php'; - } - - /** - * @covers Monolog\Handler\GelfHandler::__construct - */ - public function testConstruct() - { - $handler = new GelfHandler($this->getMessagePublisher()); - $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler); - } - - protected function getHandler($messagePublisher) - { - $handler = new GelfHandler($messagePublisher); - - return $handler; - } - - protected function getMessagePublisher() - { - return new GelfMockMessagePublisher('localhost'); - } - - public function testDebug() - { - $messagePublisher = $this->getMessagePublisher(); - $handler = $this->getHandler($messagePublisher); - - $record = $this->getRecord(Logger::DEBUG, "A test debug message"); - $handler->handle($record); - - $this->assertEquals(7, $messagePublisher->lastMessage->getLevel()); - $this->assertEquals('test', $messagePublisher->lastMessage->getFacility()); - $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage()); - $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage()); - } - - public function testWarning() - { - $messagePublisher = $this->getMessagePublisher(); - $handler = $this->getHandler($messagePublisher); - - $record = $this->getRecord(Logger::WARNING, "A test warning message"); - $handler->handle($record); - - $this->assertEquals(4, $messagePublisher->lastMessage->getLevel()); - $this->assertEquals('test', $messagePublisher->lastMessage->getFacility()); - $this->assertEquals($record['message'], $messagePublisher->lastMessage->getShortMessage()); - $this->assertEquals(null, $messagePublisher->lastMessage->getFullMessage()); - } - - public function testInjectedGelfMessageFormatter() - { - $messagePublisher = $this->getMessagePublisher(); - $handler = $this->getHandler($messagePublisher); - - $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX')); - - $record = $this->getRecord(Logger::WARNING, "A test warning message"); - $record['extra']['blarg'] = 'yep'; - $record['context']['from'] = 'logger'; - $handler->handle($record); - - $this->assertEquals('mysystem', $messagePublisher->lastMessage->getHost()); - $this->assertArrayHasKey('_EXTblarg', $messagePublisher->lastMessage->toArray()); - $this->assertArrayHasKey('_CTXfrom', $messagePublisher->lastMessage->toArray()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php deleted file mode 100644 index 8cdd64f44..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/GelfHandlerTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Gelf\Message; -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Formatter\GelfMessageFormatter; - -class GelfHandlerTest extends TestCase -{ - public function setUp() - { - if (!class_exists('Gelf\Publisher') || !class_exists('Gelf\Message')) { - $this->markTestSkipped("graylog2/gelf-php not installed"); - } - } - - /** - * @covers Monolog\Handler\GelfHandler::__construct - */ - public function testConstruct() - { - $handler = new GelfHandler($this->getMessagePublisher()); - $this->assertInstanceOf('Monolog\Handler\GelfHandler', $handler); - } - - protected function getHandler($messagePublisher) - { - $handler = new GelfHandler($messagePublisher); - - return $handler; - } - - protected function getMessagePublisher() - { - return $this->getMock('Gelf\Publisher', array('publish'), array(), '', false); - } - - public function testDebug() - { - $record = $this->getRecord(Logger::DEBUG, "A test debug message"); - $expectedMessage = new Message(); - $expectedMessage - ->setLevel(7) - ->setFacility("test") - ->setShortMessage($record['message']) - ->setTimestamp($record['datetime']) - ; - - $messagePublisher = $this->getMessagePublisher(); - $messagePublisher->expects($this->once()) - ->method('publish') - ->with($expectedMessage); - - $handler = $this->getHandler($messagePublisher); - - $handler->handle($record); - } - - public function testWarning() - { - $record = $this->getRecord(Logger::WARNING, "A test warning message"); - $expectedMessage = new Message(); - $expectedMessage - ->setLevel(4) - ->setFacility("test") - ->setShortMessage($record['message']) - ->setTimestamp($record['datetime']) - ; - - $messagePublisher = $this->getMessagePublisher(); - $messagePublisher->expects($this->once()) - ->method('publish') - ->with($expectedMessage); - - $handler = $this->getHandler($messagePublisher); - - $handler->handle($record); - } - - public function testInjectedGelfMessageFormatter() - { - $record = $this->getRecord(Logger::WARNING, "A test warning message"); - $record['extra']['blarg'] = 'yep'; - $record['context']['from'] = 'logger'; - - $expectedMessage = new Message(); - $expectedMessage - ->setLevel(4) - ->setFacility("test") - ->setHost("mysystem") - ->setShortMessage($record['message']) - ->setTimestamp($record['datetime']) - ->setAdditional("EXTblarg", 'yep') - ->setAdditional("CTXfrom", 'logger') - ; - - $messagePublisher = $this->getMessagePublisher(); - $messagePublisher->expects($this->once()) - ->method('publish') - ->with($expectedMessage); - - $handler = $this->getHandler($messagePublisher); - $handler->setFormatter(new GelfMessageFormatter('mysystem', 'EXT', 'CTX')); - $handler->handle($record); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php b/vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php deleted file mode 100644 index 873d92fb6..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/GelfMockMessagePublisher.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Gelf\MessagePublisher; -use Gelf\Message; - -class GelfMockMessagePublisher extends MessagePublisher -{ - public function publish(Message $message) - { - $this->lastMessage = $message; - } - - public $lastMessage = null; -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php deleted file mode 100644 index a1b86176d..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/GroupHandlerTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -class GroupHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\GroupHandler::__construct - * @expectedException InvalidArgumentException - */ - public function testConstructorOnlyTakesHandler() - { - new GroupHandler(array(new TestHandler(), "foo")); - } - - /** - * @covers Monolog\Handler\GroupHandler::__construct - * @covers Monolog\Handler\GroupHandler::handle - */ - public function testHandle() - { - $testHandlers = array(new TestHandler(), new TestHandler()); - $handler = new GroupHandler($testHandlers); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - foreach ($testHandlers as $test) { - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue(count($test->getRecords()) === 2); - } - } - - /** - * @covers Monolog\Handler\GroupHandler::handleBatch - */ - public function testHandleBatch() - { - $testHandlers = array(new TestHandler(), new TestHandler()); - $handler = new GroupHandler($testHandlers); - $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO))); - foreach ($testHandlers as $test) { - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue(count($test->getRecords()) === 2); - } - } - - /** - * @covers Monolog\Handler\GroupHandler::isHandling - */ - public function testIsHandling() - { - $testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING)); - $handler = new GroupHandler($testHandlers); - $this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR))); - $this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING))); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); - } - - /** - * @covers Monolog\Handler\GroupHandler::handle - */ - public function testHandleUsesProcessors() - { - $test = new TestHandler(); - $handler = new GroupHandler(array($test)); - $handler->pushProcessor(function ($record) { - $record['extra']['foo'] = true; - - return $record; - }); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasWarningRecords()); - $records = $test->getRecords(); - $this->assertTrue($records[0]['extra']['foo']); - } - - /** - * @covers Monolog\Handler\GroupHandler::handle - */ - public function testHandleBatchUsesProcessors() - { - $testHandlers = array(new TestHandler(), new TestHandler()); - $handler = new GroupHandler($testHandlers); - $handler->pushProcessor(function ($record) { - $record['extra']['foo'] = true; - - return $record; - }); - $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO))); - foreach ($testHandlers as $test) { - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue(count($test->getRecords()) === 2); - $records = $test->getRecords(); - $this->assertTrue($records[0]['extra']['foo']); - $this->assertTrue($records[1]['extra']['foo']); - } - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/HandlerWrapperTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/HandlerWrapperTest.php deleted file mode 100644 index d8d0452ca..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/HandlerWrapperTest.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; - -/** - * @author Alexey Karapetov - */ -class HandlerWrapperTest extends TestCase -{ - /** - * @var HandlerWrapper - */ - private $wrapper; - - private $handler; - - public function setUp() - { - parent::setUp(); - $this->handler = $this->getMock('Monolog\\Handler\\HandlerInterface'); - $this->wrapper = new HandlerWrapper($this->handler); - } - - /** - * @return array - */ - public function trueFalseDataProvider() - { - return array( - array(true), - array(false), - ); - } - - /** - * @param $result - * @dataProvider trueFalseDataProvider - */ - public function testIsHandling($result) - { - $record = $this->getRecord(); - $this->handler->expects($this->once()) - ->method('isHandling') - ->with($record) - ->willReturn($result); - - $this->assertEquals($result, $this->wrapper->isHandling($record)); - } - - /** - * @param $result - * @dataProvider trueFalseDataProvider - */ - public function testHandle($result) - { - $record = $this->getRecord(); - $this->handler->expects($this->once()) - ->method('handle') - ->with($record) - ->willReturn($result); - - $this->assertEquals($result, $this->wrapper->handle($record)); - } - - /** - * @param $result - * @dataProvider trueFalseDataProvider - */ - public function testHandleBatch($result) - { - $records = $this->getMultipleRecords(); - $this->handler->expects($this->once()) - ->method('handleBatch') - ->with($records) - ->willReturn($result); - - $this->assertEquals($result, $this->wrapper->handleBatch($records)); - } - - public function testPushProcessor() - { - $processor = function () {}; - $this->handler->expects($this->once()) - ->method('pushProcessor') - ->with($processor); - - $this->assertEquals($this->wrapper, $this->wrapper->pushProcessor($processor)); - } - - public function testPopProcessor() - { - $processor = function () {}; - $this->handler->expects($this->once()) - ->method('popProcessor') - ->willReturn($processor); - - $this->assertEquals($processor, $this->wrapper->popProcessor()); - } - - public function testSetFormatter() - { - $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); - $this->handler->expects($this->once()) - ->method('setFormatter') - ->with($formatter); - - $this->assertEquals($this->wrapper, $this->wrapper->setFormatter($formatter)); - } - - public function testGetFormatter() - { - $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); - $this->handler->expects($this->once()) - ->method('getFormatter') - ->willReturn($formatter); - - $this->assertEquals($formatter, $this->wrapper->getFormatter()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php deleted file mode 100644 index 52dc9daca..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/HipChatHandlerTest.php +++ /dev/null @@ -1,279 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @author Rafael Dohms - * @see https://www.hipchat.com/docs/api - */ -class HipChatHandlerTest extends TestCase -{ - private $res; - /** @var HipChatHandler */ - private $handler; - - public function testWriteHeader() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: api.hipchat.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); - - return $content; - } - - public function testWriteCustomHostHeader() - { - $this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/v1\/rooms\/message\?format=json&auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); - - return $content; - } - - public function testWriteV2() - { - $this->createHandler('myToken', 'room1', 'Monolog', false, 'hipchat.foo.bar', 'v2'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/v2\/room\/room1\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); - - return $content; - } - - public function testWriteV2Notify() - { - $this->createHandler('myToken', 'room1', 'Monolog', true, 'hipchat.foo.bar', 'v2'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/v2\/room\/room1\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); - - return $content; - } - - public function testRoomSpaces() - { - $this->createHandler('myToken', 'room name', 'Monolog', false, 'hipchat.foo.bar', 'v2'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/v2\/room\/room%20name\/notification\?auth_token=.* HTTP\/1.1\\r\\nHost: hipchat.foo.bar\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); - - return $content; - } - - /** - * @depends testWriteHeader - */ - public function testWriteContent($content) - { - $this->assertRegexp('/notify=0&message=test1&message_format=text&color=red&room_id=room1&from=Monolog$/', $content); - } - - public function testWriteContentV1WithoutName() - { - $this->createHandler('myToken', 'room1', null, false, 'hipchat.foo.bar', 'v1'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/notify=0&message=test1&message_format=text&color=red&room_id=room1&from=$/', $content); - - return $content; - } - - /** - * @depends testWriteCustomHostHeader - */ - public function testWriteContentNotify($content) - { - $this->assertRegexp('/notify=1&message=test1&message_format=text&color=red&room_id=room1&from=Monolog$/', $content); - } - - /** - * @depends testWriteV2 - */ - public function testWriteContentV2($content) - { - $this->assertRegexp('/notify=false&message=test1&message_format=text&color=red&from=Monolog$/', $content); - } - - /** - * @depends testWriteV2Notify - */ - public function testWriteContentV2Notify($content) - { - $this->assertRegexp('/notify=true&message=test1&message_format=text&color=red&from=Monolog$/', $content); - } - - public function testWriteContentV2WithoutName() - { - $this->createHandler('myToken', 'room1', null, false, 'hipchat.foo.bar', 'v2'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/notify=false&message=test1&message_format=text&color=red$/', $content); - - return $content; - } - - public function testWriteWithComplexMessage() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content); - } - - public function testWriteTruncatesLongMessage() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::CRITICAL, str_repeat('abcde', 2000))); - fseek($this->res, 0); - $content = fread($this->res, 12000); - - $this->assertRegexp('/message='.str_repeat('abcde', 1900).'\+%5Btruncated%5D/', $content); - } - - /** - * @dataProvider provideLevelColors - */ - public function testWriteWithErrorLevelsAndColors($level, $expectedColor) - { - $this->createHandler(); - $this->handler->handle($this->getRecord($level, 'Backup of database "example" finished in 16 minutes.')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/color='.$expectedColor.'/', $content); - } - - public function provideLevelColors() - { - return array( - array(Logger::DEBUG, 'gray'), - array(Logger::INFO, 'green'), - array(Logger::WARNING, 'yellow'), - array(Logger::ERROR, 'red'), - array(Logger::CRITICAL, 'red'), - array(Logger::ALERT, 'red'), - array(Logger::EMERGENCY,'red'), - array(Logger::NOTICE, 'green'), - ); - } - - /** - * @dataProvider provideBatchRecords - */ - public function testHandleBatch($records, $expectedColor) - { - $this->createHandler(); - - $this->handler->handleBatch($records); - - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/color='.$expectedColor.'/', $content); - } - - public function provideBatchRecords() - { - return array( - array( - array( - array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()), - array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()), - array('level' => Logger::CRITICAL, 'message' => 'Everything is broken!', 'level_name' => 'critical', 'datetime' => new \DateTime()), - ), - 'red', - ), - array( - array( - array('level' => Logger::WARNING, 'message' => 'Oh bugger!', 'level_name' => 'warning', 'datetime' => new \DateTime()), - array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()), - ), - 'yellow', - ), - array( - array( - array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()), - array('level' => Logger::NOTICE, 'message' => 'Something noticeable happened.', 'level_name' => 'notice', 'datetime' => new \DateTime()), - ), - 'green', - ), - array( - array( - array('level' => Logger::DEBUG, 'message' => 'Just debugging.', 'level_name' => 'debug', 'datetime' => new \DateTime()), - ), - 'gray', - ), - ); - } - - private function createHandler($token = 'myToken', $room = 'room1', $name = 'Monolog', $notify = false, $host = 'api.hipchat.com', $version = 'v1') - { - $constructorArgs = array($token, $room, $name, $notify, Logger::DEBUG, true, true, 'text', $host, $version); - $this->res = fopen('php://memory', 'a'); - $this->handler = $this->getMock( - '\Monolog\Handler\HipChatHandler', - array('fsockopen', 'streamSetTimeout', 'closeSocket'), - $constructorArgs - ); - - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($this->handler, 'localhost:1234'); - - $this->handler->expects($this->any()) - ->method('fsockopen') - ->will($this->returnValue($this->res)); - $this->handler->expects($this->any()) - ->method('streamSetTimeout') - ->will($this->returnValue(true)); - $this->handler->expects($this->any()) - ->method('closeSocket') - ->will($this->returnValue(true)); - - $this->handler->setFormatter($this->getIdentityFormatter()); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testCreateWithTooLongName() - { - $hipChatHandler = new HipChatHandler('token', 'room', 'SixteenCharsHere'); - } - - public function testCreateWithTooLongNameV2() - { - // creating a handler with too long of a name but using the v2 api doesn't matter. - $hipChatHandler = new HipChatHandler('token', 'room', 'SixteenCharsHere', false, Logger::CRITICAL, true, true, 'test', 'api.hipchat.com', 'v2'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php deleted file mode 100644 index b2deb40ae..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/LogEntriesHandlerTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @author Robert Kaufmann III - */ -class LogEntriesHandlerTest extends TestCase -{ - /** - * @var resource - */ - private $res; - - /** - * @var LogEntriesHandler - */ - private $handler; - - public function testWriteContent() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Critical write test')); - - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] test.CRITICAL: Critical write test/', $content); - } - - public function testWriteBatchContent() - { - $records = array( - $this->getRecord(), - $this->getRecord(), - $this->getRecord(), - ); - $this->createHandler(); - $this->handler->handleBatch($records); - - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/(testToken \[\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\] .* \[\] \[\]\n){3}/', $content); - } - - private function createHandler() - { - $useSSL = extension_loaded('openssl'); - $args = array('testToken', $useSSL, Logger::DEBUG, true); - $this->res = fopen('php://memory', 'a'); - $this->handler = $this->getMock( - '\Monolog\Handler\LogEntriesHandler', - array('fsockopen', 'streamSetTimeout', 'closeSocket'), - $args - ); - - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($this->handler, 'localhost:1234'); - - $this->handler->expects($this->any()) - ->method('fsockopen') - ->will($this->returnValue($this->res)); - $this->handler->expects($this->any()) - ->method('streamSetTimeout') - ->will($this->returnValue(true)); - $this->handler->expects($this->any()) - ->method('closeSocket') - ->will($this->returnValue(true)); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php deleted file mode 100644 index 6754f3d62..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/MailHandlerTest.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\TestCase; - -class MailHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\MailHandler::handleBatch - */ - public function testHandleBatch() - { - $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); - $formatter->expects($this->once()) - ->method('formatBatch'); // Each record is formatted - - $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); - $handler->expects($this->once()) - ->method('send'); - $handler->expects($this->never()) - ->method('write'); // write is for individual records - - $handler->setFormatter($formatter); - - $handler->handleBatch($this->getMultipleRecords()); - } - - /** - * @covers Monolog\Handler\MailHandler::handleBatch - */ - public function testHandleBatchNotSendsMailIfMessagesAreBelowLevel() - { - $records = array( - $this->getRecord(Logger::DEBUG, 'debug message 1'), - $this->getRecord(Logger::DEBUG, 'debug message 2'), - $this->getRecord(Logger::INFO, 'information'), - ); - - $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); - $handler->expects($this->never()) - ->method('send'); - $handler->setLevel(Logger::ERROR); - - $handler->handleBatch($records); - } - - /** - * @covers Monolog\Handler\MailHandler::write - */ - public function testHandle() - { - $handler = $this->getMockForAbstractClass('Monolog\\Handler\\MailHandler'); - - $record = $this->getRecord(); - $records = array($record); - $records[0]['formatted'] = '['.$record['datetime']->format('Y-m-d H:i:s').'] test.WARNING: test [] []'."\n"; - - $handler->expects($this->once()) - ->method('send') - ->with($records[0]['formatted'], $records); - - $handler->handle($record); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php b/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php deleted file mode 100644 index a0833225d..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/MockRavenClient.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Raven_Client; - -class MockRavenClient extends Raven_Client -{ - public function capture($data, $stack, $vars = null) - { - $data = array_merge($this->get_user_data(), $data); - $this->lastData = $data; - $this->lastStack = $stack; - } - - public $lastData; - public $lastStack; -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php deleted file mode 100644 index 0fdef63aa..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/MongoDBHandlerTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -class MongoDBHandlerTest extends TestCase -{ - /** - * @expectedException InvalidArgumentException - */ - public function testConstructorShouldThrowExceptionForInvalidMongo() - { - new MongoDBHandler(new \stdClass(), 'DB', 'Collection'); - } - - public function testHandle() - { - $mongo = $this->getMock('Mongo', array('selectCollection'), array(), '', false); - $collection = $this->getMock('stdClass', array('save')); - - $mongo->expects($this->once()) - ->method('selectCollection') - ->with('DB', 'Collection') - ->will($this->returnValue($collection)); - - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $expected = array( - 'message' => 'test', - 'context' => array('data' => '[object] (stdClass: {})', 'foo' => 34), - 'level' => Logger::WARNING, - 'level_name' => 'WARNING', - 'channel' => 'test', - 'datetime' => $record['datetime']->format('Y-m-d H:i:s'), - 'extra' => array(), - ); - - $collection->expects($this->once()) - ->method('save') - ->with($expected); - - $handler = new MongoDBHandler($mongo, 'DB', 'Collection'); - $handler->handle($record); - } -} - -if (!class_exists('Mongo')) { - class Mongo - { - public function selectCollection() - { - } - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php deleted file mode 100644 index ddf545dbe..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/NativeMailerHandlerTest.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use InvalidArgumentException; - -function mail($to, $subject, $message, $additional_headers = null, $additional_parameters = null) -{ - $GLOBALS['mail'][] = func_get_args(); -} - -class NativeMailerHandlerTest extends TestCase -{ - protected function setUp() - { - $GLOBALS['mail'] = array(); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testConstructorHeaderInjection() - { - $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', "receiver@example.org\r\nFrom: faked@attacker.org"); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testSetterHeaderInjection() - { - $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org'); - $mailer->addHeader("Content-Type: text/html\r\nFrom: faked@attacker.org"); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testSetterArrayHeaderInjection() - { - $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org'); - $mailer->addHeader(array("Content-Type: text/html\r\nFrom: faked@attacker.org")); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testSetterContentTypeInjection() - { - $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org'); - $mailer->setContentType("text/html\r\nFrom: faked@attacker.org"); - } - - /** - * @expectedException InvalidArgumentException - */ - public function testSetterEncodingInjection() - { - $mailer = new NativeMailerHandler('spammer@example.org', 'dear victim', 'receiver@example.org'); - $mailer->setEncoding("utf-8\r\nFrom: faked@attacker.org"); - } - - public function testSend() - { - $to = 'spammer@example.org'; - $subject = 'dear victim'; - $from = 'receiver@example.org'; - - $mailer = new NativeMailerHandler($to, $subject, $from); - $mailer->handleBatch(array()); - - // batch is empty, nothing sent - $this->assertEmpty($GLOBALS['mail']); - - // non-empty batch - $mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz")); - $this->assertNotEmpty($GLOBALS['mail']); - $this->assertInternalType('array', $GLOBALS['mail']); - $this->assertArrayHasKey('0', $GLOBALS['mail']); - $params = $GLOBALS['mail'][0]; - $this->assertCount(5, $params); - $this->assertSame($to, $params[0]); - $this->assertSame($subject, $params[1]); - $this->assertStringEndsWith(" test.ERROR: Foo Bar Baz [] []\n", $params[2]); - $this->assertSame("From: $from\r\nContent-type: text/plain; charset=utf-8\r\n", $params[3]); - $this->assertSame('', $params[4]); - } - - public function testMessageSubjectFormatting() - { - $mailer = new NativeMailerHandler('to@example.org', 'Alert: %level_name% %message%', 'from@example.org'); - $mailer->handle($this->getRecord(Logger::ERROR, "Foo\nBar\r\n\r\nBaz")); - $this->assertNotEmpty($GLOBALS['mail']); - $this->assertInternalType('array', $GLOBALS['mail']); - $this->assertArrayHasKey('0', $GLOBALS['mail']); - $params = $GLOBALS['mail'][0]; - $this->assertCount(5, $params); - $this->assertSame('Alert: ERROR Foo Bar Baz', $params[1]); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php deleted file mode 100644 index 4d3a615f8..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/NewRelicHandlerTest.php +++ /dev/null @@ -1,200 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Formatter\LineFormatter; -use Monolog\TestCase; -use Monolog\Logger; - -class NewRelicHandlerTest extends TestCase -{ - public static $appname; - public static $customParameters; - public static $transactionName; - - public function setUp() - { - self::$appname = null; - self::$customParameters = array(); - self::$transactionName = null; - } - - /** - * @expectedException Monolog\Handler\MissingExtensionException - */ - public function testThehandlerThrowsAnExceptionIfTheNRExtensionIsNotLoaded() - { - $handler = new StubNewRelicHandlerWithoutExtension(); - $handler->handle($this->getRecord(Logger::ERROR)); - } - - public function testThehandlerCanHandleTheRecord() - { - $handler = new StubNewRelicHandler(); - $handler->handle($this->getRecord(Logger::ERROR)); - } - - public function testThehandlerCanAddContextParamsToTheNewRelicTrace() - { - $handler = new StubNewRelicHandler(); - $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('a' => 'b'))); - $this->assertEquals(array('context_a' => 'b'), self::$customParameters); - } - - public function testThehandlerCanAddExplodedContextParamsToTheNewRelicTrace() - { - $handler = new StubNewRelicHandler(Logger::ERROR, true, self::$appname, true); - $handler->handle($this->getRecord( - Logger::ERROR, - 'log message', - array('a' => array('key1' => 'value1', 'key2' => 'value2')) - )); - $this->assertEquals( - array('context_a_key1' => 'value1', 'context_a_key2' => 'value2'), - self::$customParameters - ); - } - - public function testThehandlerCanAddExtraParamsToTheNewRelicTrace() - { - $record = $this->getRecord(Logger::ERROR, 'log message'); - $record['extra'] = array('c' => 'd'); - - $handler = new StubNewRelicHandler(); - $handler->handle($record); - - $this->assertEquals(array('extra_c' => 'd'), self::$customParameters); - } - - public function testThehandlerCanAddExplodedExtraParamsToTheNewRelicTrace() - { - $record = $this->getRecord(Logger::ERROR, 'log message'); - $record['extra'] = array('c' => array('key1' => 'value1', 'key2' => 'value2')); - - $handler = new StubNewRelicHandler(Logger::ERROR, true, self::$appname, true); - $handler->handle($record); - - $this->assertEquals( - array('extra_c_key1' => 'value1', 'extra_c_key2' => 'value2'), - self::$customParameters - ); - } - - public function testThehandlerCanAddExtraContextAndParamsToTheNewRelicTrace() - { - $record = $this->getRecord(Logger::ERROR, 'log message', array('a' => 'b')); - $record['extra'] = array('c' => 'd'); - - $handler = new StubNewRelicHandler(); - $handler->handle($record); - - $expected = array( - 'context_a' => 'b', - 'extra_c' => 'd', - ); - - $this->assertEquals($expected, self::$customParameters); - } - - public function testThehandlerCanHandleTheRecordsFormattedUsingTheLineFormatter() - { - $handler = new StubNewRelicHandler(); - $handler->setFormatter(new LineFormatter()); - $handler->handle($this->getRecord(Logger::ERROR)); - } - - public function testTheAppNameIsNullByDefault() - { - $handler = new StubNewRelicHandler(); - $handler->handle($this->getRecord(Logger::ERROR, 'log message')); - - $this->assertEquals(null, self::$appname); - } - - public function testTheAppNameCanBeInjectedFromtheConstructor() - { - $handler = new StubNewRelicHandler(Logger::DEBUG, false, 'myAppName'); - $handler->handle($this->getRecord(Logger::ERROR, 'log message')); - - $this->assertEquals('myAppName', self::$appname); - } - - public function testTheAppNameCanBeOverriddenFromEachLog() - { - $handler = new StubNewRelicHandler(Logger::DEBUG, false, 'myAppName'); - $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('appname' => 'logAppName'))); - - $this->assertEquals('logAppName', self::$appname); - } - - public function testTheTransactionNameIsNullByDefault() - { - $handler = new StubNewRelicHandler(); - $handler->handle($this->getRecord(Logger::ERROR, 'log message')); - - $this->assertEquals(null, self::$transactionName); - } - - public function testTheTransactionNameCanBeInjectedFromTheConstructor() - { - $handler = new StubNewRelicHandler(Logger::DEBUG, false, null, false, 'myTransaction'); - $handler->handle($this->getRecord(Logger::ERROR, 'log message')); - - $this->assertEquals('myTransaction', self::$transactionName); - } - - public function testTheTransactionNameCanBeOverriddenFromEachLog() - { - $handler = new StubNewRelicHandler(Logger::DEBUG, false, null, false, 'myTransaction'); - $handler->handle($this->getRecord(Logger::ERROR, 'log message', array('transaction_name' => 'logTransactName'))); - - $this->assertEquals('logTransactName', self::$transactionName); - } -} - -class StubNewRelicHandlerWithoutExtension extends NewRelicHandler -{ - protected function isNewRelicEnabled() - { - return false; - } -} - -class StubNewRelicHandler extends NewRelicHandler -{ - protected function isNewRelicEnabled() - { - return true; - } -} - -function newrelic_notice_error() -{ - return true; -} - -function newrelic_set_appname($appname) -{ - return NewRelicHandlerTest::$appname = $appname; -} - -function newrelic_name_transaction($transactionName) -{ - return NewRelicHandlerTest::$transactionName = $transactionName; -} - -function newrelic_add_custom_parameter($key, $value) -{ - NewRelicHandlerTest::$customParameters[$key] = $value; - - return true; -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php deleted file mode 100644 index 292df78c7..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/NullHandlerTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @covers Monolog\Handler\NullHandler::handle - */ -class NullHandlerTest extends TestCase -{ - public function testHandle() - { - $handler = new NullHandler(); - $this->assertTrue($handler->handle($this->getRecord())); - } - - public function testHandleLowerLevelRecord() - { - $handler = new NullHandler(Logger::WARNING); - $this->assertFalse($handler->handle($this->getRecord(Logger::DEBUG))); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php deleted file mode 100644 index 152573ef0..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/PHPConsoleHandlerTest.php +++ /dev/null @@ -1,273 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Exception; -use Monolog\ErrorHandler; -use Monolog\Logger; -use Monolog\TestCase; -use PhpConsole\Connector; -use PhpConsole\Dispatcher\Debug as DebugDispatcher; -use PhpConsole\Dispatcher\Errors as ErrorDispatcher; -use PhpConsole\Handler; -use PHPUnit_Framework_MockObject_MockObject; - -/** - * @covers Monolog\Handler\PHPConsoleHandler - * @author Sergey Barbushin https://www.linkedin.com/in/barbushin - */ -class PHPConsoleHandlerTest extends TestCase -{ - /** @var Connector|PHPUnit_Framework_MockObject_MockObject */ - protected $connector; - /** @var DebugDispatcher|PHPUnit_Framework_MockObject_MockObject */ - protected $debugDispatcher; - /** @var ErrorDispatcher|PHPUnit_Framework_MockObject_MockObject */ - protected $errorDispatcher; - - protected function setUp() - { - if (!class_exists('PhpConsole\Connector')) { - $this->markTestSkipped('PHP Console library not found. See https://github.com/barbushin/php-console#installation'); - } - $this->connector = $this->initConnectorMock(); - - $this->debugDispatcher = $this->initDebugDispatcherMock($this->connector); - $this->connector->setDebugDispatcher($this->debugDispatcher); - - $this->errorDispatcher = $this->initErrorDispatcherMock($this->connector); - $this->connector->setErrorsDispatcher($this->errorDispatcher); - } - - protected function initDebugDispatcherMock(Connector $connector) - { - return $this->getMockBuilder('PhpConsole\Dispatcher\Debug') - ->disableOriginalConstructor() - ->setMethods(array('dispatchDebug')) - ->setConstructorArgs(array($connector, $connector->getDumper())) - ->getMock(); - } - - protected function initErrorDispatcherMock(Connector $connector) - { - return $this->getMockBuilder('PhpConsole\Dispatcher\Errors') - ->disableOriginalConstructor() - ->setMethods(array('dispatchError', 'dispatchException')) - ->setConstructorArgs(array($connector, $connector->getDumper())) - ->getMock(); - } - - protected function initConnectorMock() - { - $connector = $this->getMockBuilder('PhpConsole\Connector') - ->disableOriginalConstructor() - ->setMethods(array( - 'sendMessage', - 'onShutDown', - 'isActiveClient', - 'setSourcesBasePath', - 'setServerEncoding', - 'setPassword', - 'enableSslOnlyMode', - 'setAllowedIpMasks', - 'setHeadersLimit', - 'startEvalRequestsListener', - )) - ->getMock(); - - $connector->expects($this->any()) - ->method('isActiveClient') - ->will($this->returnValue(true)); - - return $connector; - } - - protected function getHandlerDefaultOption($name) - { - $handler = new PHPConsoleHandler(array(), $this->connector); - $options = $handler->getOptions(); - - return $options[$name]; - } - - protected function initLogger($handlerOptions = array(), $level = Logger::DEBUG) - { - return new Logger('test', array( - new PHPConsoleHandler($handlerOptions, $this->connector, $level), - )); - } - - public function testInitWithDefaultConnector() - { - $handler = new PHPConsoleHandler(); - $this->assertEquals(spl_object_hash(Connector::getInstance()), spl_object_hash($handler->getConnector())); - } - - public function testInitWithCustomConnector() - { - $handler = new PHPConsoleHandler(array(), $this->connector); - $this->assertEquals(spl_object_hash($this->connector), spl_object_hash($handler->getConnector())); - } - - public function testDebug() - { - $this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with($this->equalTo('test')); - $this->initLogger()->addDebug('test'); - } - - public function testDebugContextInMessage() - { - $message = 'test'; - $tag = 'tag'; - $context = array($tag, 'custom' => mt_rand()); - $expectedMessage = $message . ' ' . json_encode(array_slice($context, 1)); - $this->debugDispatcher->expects($this->once())->method('dispatchDebug')->with( - $this->equalTo($expectedMessage), - $this->equalTo($tag) - ); - $this->initLogger()->addDebug($message, $context); - } - - public function testDebugTags($tagsContextKeys = null) - { - $expectedTags = mt_rand(); - $logger = $this->initLogger($tagsContextKeys ? array('debugTagsKeysInContext' => $tagsContextKeys) : array()); - if (!$tagsContextKeys) { - $tagsContextKeys = $this->getHandlerDefaultOption('debugTagsKeysInContext'); - } - foreach ($tagsContextKeys as $key) { - $debugDispatcher = $this->initDebugDispatcherMock($this->connector); - $debugDispatcher->expects($this->once())->method('dispatchDebug')->with( - $this->anything(), - $this->equalTo($expectedTags) - ); - $this->connector->setDebugDispatcher($debugDispatcher); - $logger->addDebug('test', array($key => $expectedTags)); - } - } - - public function testError($classesPartialsTraceIgnore = null) - { - $code = E_USER_NOTICE; - $message = 'message'; - $file = __FILE__; - $line = __LINE__; - $this->errorDispatcher->expects($this->once())->method('dispatchError')->with( - $this->equalTo($code), - $this->equalTo($message), - $this->equalTo($file), - $this->equalTo($line), - $classesPartialsTraceIgnore ?: $this->equalTo($this->getHandlerDefaultOption('classesPartialsTraceIgnore')) - ); - $errorHandler = ErrorHandler::register($this->initLogger($classesPartialsTraceIgnore ? array('classesPartialsTraceIgnore' => $classesPartialsTraceIgnore) : array()), false); - $errorHandler->registerErrorHandler(array(), false, E_USER_WARNING); - $errorHandler->handleError($code, $message, $file, $line); - } - - public function testException() - { - $e = new Exception(); - $this->errorDispatcher->expects($this->once())->method('dispatchException')->with( - $this->equalTo($e) - ); - $handler = $this->initLogger(); - $handler->log( - \Psr\Log\LogLevel::ERROR, - sprintf('Uncaught Exception %s: "%s" at %s line %s', get_class($e), $e->getMessage(), $e->getFile(), $e->getLine()), - array('exception' => $e) - ); - } - - /** - * @expectedException Exception - */ - public function testWrongOptionsThrowsException() - { - new PHPConsoleHandler(array('xxx' => 1)); - } - - public function testOptionEnabled() - { - $this->debugDispatcher->expects($this->never())->method('dispatchDebug'); - $this->initLogger(array('enabled' => false))->addDebug('test'); - } - - public function testOptionClassesPartialsTraceIgnore() - { - $this->testError(array('Class', 'Namespace\\')); - } - - public function testOptionDebugTagsKeysInContext() - { - $this->testDebugTags(array('key1', 'key2')); - } - - public function testOptionUseOwnErrorsAndExceptionsHandler() - { - $this->initLogger(array('useOwnErrorsHandler' => true, 'useOwnExceptionsHandler' => true)); - $this->assertEquals(array(Handler::getInstance(), 'handleError'), set_error_handler(function () { - })); - $this->assertEquals(array(Handler::getInstance(), 'handleException'), set_exception_handler(function () { - })); - } - - public static function provideConnectorMethodsOptionsSets() - { - return array( - array('sourcesBasePath', 'setSourcesBasePath', __DIR__), - array('serverEncoding', 'setServerEncoding', 'cp1251'), - array('password', 'setPassword', '******'), - array('enableSslOnlyMode', 'enableSslOnlyMode', true, false), - array('ipMasks', 'setAllowedIpMasks', array('127.0.0.*')), - array('headersLimit', 'setHeadersLimit', 2500), - array('enableEvalListener', 'startEvalRequestsListener', true, false), - ); - } - - /** - * @dataProvider provideConnectorMethodsOptionsSets - */ - public function testOptionCallsConnectorMethod($option, $method, $value, $isArgument = true) - { - $expectCall = $this->connector->expects($this->once())->method($method); - if ($isArgument) { - $expectCall->with($value); - } - new PHPConsoleHandler(array($option => $value), $this->connector); - } - - public function testOptionDetectDumpTraceAndSource() - { - new PHPConsoleHandler(array('detectDumpTraceAndSource' => true), $this->connector); - $this->assertTrue($this->connector->getDebugDispatcher()->detectTraceAndSource); - } - - public static function provideDumperOptionsValues() - { - return array( - array('dumperLevelLimit', 'levelLimit', 1001), - array('dumperItemsCountLimit', 'itemsCountLimit', 1002), - array('dumperItemSizeLimit', 'itemSizeLimit', 1003), - array('dumperDumpSizeLimit', 'dumpSizeLimit', 1004), - array('dumperDetectCallbacks', 'detectCallbacks', true), - ); - } - - /** - * @dataProvider provideDumperOptionsValues - */ - public function testDumperOptions($option, $dumperProperty, $value) - { - new PHPConsoleHandler(array($option => $value), $this->connector); - $this->assertEquals($value, $this->connector->getDumper()->$dumperProperty); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php deleted file mode 100644 index 64eaab16e..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/PsrHandlerTest.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @covers Monolog\Handler\PsrHandler::handle - */ -class PsrHandlerTest extends TestCase -{ - public function logLevelProvider() - { - $levels = array(); - $monologLogger = new Logger(''); - - foreach ($monologLogger->getLevels() as $levelName => $level) { - $levels[] = array($levelName, $level); - } - - return $levels; - } - - /** - * @dataProvider logLevelProvider - */ - public function testHandlesAllLevels($levelName, $level) - { - $message = 'Hello, world! ' . $level; - $context = array('foo' => 'bar', 'level' => $level); - - $psrLogger = $this->getMock('Psr\Log\NullLogger'); - $psrLogger->expects($this->once()) - ->method('log') - ->with(strtolower($levelName), $message, $context); - - $handler = new PsrHandler($psrLogger); - $handler->handle(array('level' => $level, 'level_name' => $levelName, 'message' => $message, 'context' => $context)); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php deleted file mode 100644 index 56df474a7..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/PushoverHandlerTest.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * Almost all examples (expected header, titles, messages) taken from - * https://www.pushover.net/api - * @author Sebastian Göttschkes - * @see https://www.pushover.net/api - */ -class PushoverHandlerTest extends TestCase -{ - private $res; - private $handler; - - public function testWriteHeader() - { - $this->createHandler(); - $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/1\/messages.json HTTP\/1.1\\r\\nHost: api.pushover.net\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); - - return $content; - } - - /** - * @depends testWriteHeader - */ - public function testWriteContent($content) - { - $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}$/', $content); - } - - public function testWriteWithComplexTitle() - { - $this->createHandler('myToken', 'myUser', 'Backup finished - SQL1'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/title=Backup\+finished\+-\+SQL1/', $content); - } - - public function testWriteWithComplexMessage() - { - $this->createHandler(); - $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'Backup of database "example" finished in 16 minutes.')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/message=Backup\+of\+database\+%22example%22\+finished\+in\+16\+minutes\./', $content); - } - - public function testWriteWithTooLongMessage() - { - $message = str_pad('test', 520, 'a'); - $this->createHandler(); - $this->handler->setHighPriorityLevel(Logger::EMERGENCY); // skip priority notifications - $this->handler->handle($this->getRecord(Logger::CRITICAL, $message)); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $expectedMessage = substr($message, 0, 505); - - $this->assertRegexp('/message=' . $expectedMessage . '&title/', $content); - } - - public function testWriteWithHighPriority() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=1$/', $content); - } - - public function testWriteWithEmergencyPriority() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/token=myToken&user=myUser&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content); - } - - public function testWriteToMultipleUsers() - { - $this->createHandler('myToken', array('userA', 'userB')); - $this->handler->handle($this->getRecord(Logger::EMERGENCY, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/token=myToken&user=userA&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200POST/', $content); - $this->assertRegexp('/token=myToken&user=userB&message=test1&title=Monolog×tamp=\d{10}&priority=2&retry=30&expire=25200$/', $content); - } - - private function createHandler($token = 'myToken', $user = 'myUser', $title = 'Monolog') - { - $constructorArgs = array($token, $user, $title); - $this->res = fopen('php://memory', 'a'); - $this->handler = $this->getMock( - '\Monolog\Handler\PushoverHandler', - array('fsockopen', 'streamSetTimeout', 'closeSocket'), - $constructorArgs - ); - - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($this->handler, 'localhost:1234'); - - $this->handler->expects($this->any()) - ->method('fsockopen') - ->will($this->returnValue($this->res)); - $this->handler->expects($this->any()) - ->method('streamSetTimeout') - ->will($this->returnValue(true)); - $this->handler->expects($this->any()) - ->method('closeSocket') - ->will($this->returnValue(true)); - - $this->handler->setFormatter($this->getIdentityFormatter()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php deleted file mode 100644 index a7c4845f8..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/RavenHandlerTest.php +++ /dev/null @@ -1,227 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; - -class RavenHandlerTest extends TestCase -{ - public function setUp() - { - if (!class_exists('Raven_Client')) { - $this->markTestSkipped('raven/raven not installed'); - } - - require_once __DIR__ . '/MockRavenClient.php'; - } - - /** - * @covers Monolog\Handler\RavenHandler::__construct - */ - public function testConstruct() - { - $handler = new RavenHandler($this->getRavenClient()); - $this->assertInstanceOf('Monolog\Handler\RavenHandler', $handler); - } - - protected function getHandler($ravenClient) - { - $handler = new RavenHandler($ravenClient); - - return $handler; - } - - protected function getRavenClient() - { - $dsn = 'http://43f6017361224d098402974103bfc53d:a6a0538fc2934ba2bed32e08741b2cd3@marca.python.live.cheggnet.com:9000/1'; - - return new MockRavenClient($dsn); - } - - public function testDebug() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - - $record = $this->getRecord(Logger::DEBUG, 'A test debug message'); - $handler->handle($record); - - $this->assertEquals($ravenClient::DEBUG, $ravenClient->lastData['level']); - $this->assertContains($record['message'], $ravenClient->lastData['message']); - } - - public function testWarning() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - - $record = $this->getRecord(Logger::WARNING, 'A test warning message'); - $handler->handle($record); - - $this->assertEquals($ravenClient::WARNING, $ravenClient->lastData['level']); - $this->assertContains($record['message'], $ravenClient->lastData['message']); - } - - public function testTag() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - - $tags = array(1, 2, 'foo'); - $record = $this->getRecord(Logger::INFO, 'test', array('tags' => $tags)); - $handler->handle($record); - - $this->assertEquals($tags, $ravenClient->lastData['tags']); - } - - public function testExtraParameters() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - - $checksum = '098f6bcd4621d373cade4e832627b4f6'; - $release = '05a671c66aefea124cc08b76ea6d30bb'; - $record = $this->getRecord(Logger::INFO, 'test', array('checksum' => $checksum, 'release' => $release)); - $handler->handle($record); - - $this->assertEquals($checksum, $ravenClient->lastData['checksum']); - $this->assertEquals($release, $ravenClient->lastData['release']); - } - - public function testFingerprint() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - - $fingerprint = array('{{ default }}', 'other value'); - $record = $this->getRecord(Logger::INFO, 'test', array('fingerprint' => $fingerprint)); - $handler->handle($record); - - $this->assertEquals($fingerprint, $ravenClient->lastData['fingerprint']); - } - - public function testUserContext() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - - $recordWithNoContext = $this->getRecord(Logger::INFO, 'test with default user context'); - // set user context 'externally' - - $user = array( - 'id' => '123', - 'email' => 'test@test.com', - ); - - $recordWithContext = $this->getRecord(Logger::INFO, 'test', array('user' => $user)); - - $ravenClient->user_context(array('id' => 'test_user_id')); - // handle context - $handler->handle($recordWithContext); - $this->assertEquals($user, $ravenClient->lastData['user']); - - // check to see if its reset - $handler->handle($recordWithNoContext); - $this->assertInternalType('array', $ravenClient->context->user); - $this->assertSame('test_user_id', $ravenClient->context->user['id']); - - // handle with null context - $ravenClient->user_context(null); - $handler->handle($recordWithContext); - $this->assertEquals($user, $ravenClient->lastData['user']); - - // check to see if its reset - $handler->handle($recordWithNoContext); - $this->assertNull($ravenClient->context->user); - } - - public function testException() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - - try { - $this->methodThatThrowsAnException(); - } catch (\Exception $e) { - $record = $this->getRecord(Logger::ERROR, $e->getMessage(), array('exception' => $e)); - $handler->handle($record); - } - - $this->assertEquals($record['message'], $ravenClient->lastData['message']); - } - - public function testHandleBatch() - { - $records = $this->getMultipleRecords(); - $records[] = $this->getRecord(Logger::WARNING, 'warning'); - $records[] = $this->getRecord(Logger::WARNING, 'warning'); - - $logFormatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); - $logFormatter->expects($this->once())->method('formatBatch'); - - $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); - $formatter->expects($this->once())->method('format')->with($this->callback(function ($record) { - return $record['level'] == 400; - })); - - $handler = $this->getHandler($this->getRavenClient()); - $handler->setBatchFormatter($logFormatter); - $handler->setFormatter($formatter); - $handler->handleBatch($records); - } - - public function testHandleBatchDoNothingIfRecordsAreBelowLevel() - { - $records = array( - $this->getRecord(Logger::DEBUG, 'debug message 1'), - $this->getRecord(Logger::DEBUG, 'debug message 2'), - $this->getRecord(Logger::INFO, 'information'), - ); - - $handler = $this->getMock('Monolog\Handler\RavenHandler', null, array($this->getRavenClient())); - $handler->expects($this->never())->method('handle'); - $handler->setLevel(Logger::ERROR); - $handler->handleBatch($records); - } - - public function testGetSetBatchFormatter() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - - $handler->setBatchFormatter($formatter = new LineFormatter()); - $this->assertSame($formatter, $handler->getBatchFormatter()); - } - - public function testRelease() - { - $ravenClient = $this->getRavenClient(); - $handler = $this->getHandler($ravenClient); - $release = 'v42.42.42'; - $handler->setRelease($release); - $record = $this->getRecord(Logger::INFO, 'test'); - $handler->handle($record); - $this->assertEquals($release, $ravenClient->lastData['release']); - - $localRelease = 'v41.41.41'; - $record = $this->getRecord(Logger::INFO, 'test', array('release' => $localRelease)); - $handler->handle($record); - $this->assertEquals($localRelease, $ravenClient->lastData['release']); - } - - private function methodThatThrowsAnException() - { - throw new \Exception('This is an exception'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php deleted file mode 100644 index 689d52785..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/RedisHandlerTest.php +++ /dev/null @@ -1,127 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; - -class RedisHandlerTest extends TestCase -{ - /** - * @expectedException InvalidArgumentException - */ - public function testConstructorShouldThrowExceptionForInvalidRedis() - { - new RedisHandler(new \stdClass(), 'key'); - } - - public function testConstructorShouldWorkWithPredis() - { - $redis = $this->getMock('Predis\Client'); - $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key')); - } - - public function testConstructorShouldWorkWithRedis() - { - $redis = $this->getMock('Redis'); - $this->assertInstanceof('Monolog\Handler\RedisHandler', new RedisHandler($redis, 'key')); - } - - public function testPredisHandle() - { - $redis = $this->getMock('Predis\Client', array('rpush')); - - // Predis\Client uses rpush - $redis->expects($this->once()) - ->method('rpush') - ->with('key', 'test'); - - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $handler = new RedisHandler($redis, 'key'); - $handler->setFormatter(new LineFormatter("%message%")); - $handler->handle($record); - } - - public function testRedisHandle() - { - $redis = $this->getMock('Redis', array('rpush')); - - // Redis uses rPush - $redis->expects($this->once()) - ->method('rPush') - ->with('key', 'test'); - - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $handler = new RedisHandler($redis, 'key'); - $handler->setFormatter(new LineFormatter("%message%")); - $handler->handle($record); - } - - public function testRedisHandleCapped() - { - $redis = $this->getMock('Redis', array('multi', 'rpush', 'ltrim', 'exec')); - - // Redis uses multi - $redis->expects($this->once()) - ->method('multi') - ->will($this->returnSelf()); - - $redis->expects($this->once()) - ->method('rpush') - ->will($this->returnSelf()); - - $redis->expects($this->once()) - ->method('ltrim') - ->will($this->returnSelf()); - - $redis->expects($this->once()) - ->method('exec') - ->will($this->returnSelf()); - - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10); - $handler->setFormatter(new LineFormatter("%message%")); - $handler->handle($record); - } - - public function testPredisHandleCapped() - { - $redis = $this->getMock('Predis\Client', array('transaction')); - - $redisTransaction = $this->getMock('Predis\Client', array('rpush', 'ltrim')); - - $redisTransaction->expects($this->once()) - ->method('rpush') - ->will($this->returnSelf()); - - $redisTransaction->expects($this->once()) - ->method('ltrim') - ->will($this->returnSelf()); - - // Redis uses multi - $redis->expects($this->once()) - ->method('transaction') - ->will($this->returnCallback(function ($cb) use ($redisTransaction) { - $cb($redisTransaction); - })); - - $record = $this->getRecord(Logger::WARNING, 'test', array('data' => new \stdClass, 'foo' => 34)); - - $handler = new RedisHandler($redis, 'key', Logger::DEBUG, true, 10); - $handler->setFormatter(new LineFormatter("%message%")); - $handler->handle($record); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php deleted file mode 100644 index c5106175f..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/RotatingFileHandlerTest.php +++ /dev/null @@ -1,211 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use PHPUnit_Framework_Error_Deprecated; - -/** - * @covers Monolog\Handler\RotatingFileHandler - */ -class RotatingFileHandlerTest extends TestCase -{ - /** - * This var should be private but then the anonymous function - * in the `setUp` method won't be able to set it. `$this` cant't - * be used in the anonymous function in `setUp` because PHP 5.3 - * does not support it. - */ - public $lastError; - - public function setUp() - { - $dir = __DIR__.'/Fixtures'; - chmod($dir, 0777); - if (!is_writable($dir)) { - $this->markTestSkipped($dir.' must be writable to test the RotatingFileHandler.'); - } - $this->lastError = null; - $self = $this; - // workaround with &$self used for PHP 5.3 - set_error_handler(function($code, $message) use (&$self) { - $self->lastError = array( - 'code' => $code, - 'message' => $message, - ); - }); - } - - private function assertErrorWasTriggered($code, $message) - { - if (empty($this->lastError)) { - $this->fail( - sprintf( - 'Failed asserting that error with code `%d` and message `%s` was triggered', - $code, - $message - ) - ); - } - $this->assertEquals($code, $this->lastError['code'], sprintf('Expected an error with code %d to be triggered, got `%s` instead', $code, $this->lastError['code'])); - $this->assertEquals($message, $this->lastError['message'], sprintf('Expected an error with message `%d` to be triggered, got `%s` instead', $message, $this->lastError['message'])); - } - - public function testRotationCreatesNewFile() - { - touch(__DIR__.'/Fixtures/foo-'.date('Y-m-d', time() - 86400).'.rot'); - - $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot'); - $handler->setFormatter($this->getIdentityFormatter()); - $handler->handle($this->getRecord()); - - $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; - $this->assertTrue(file_exists($log)); - $this->assertEquals('test', file_get_contents($log)); - } - - /** - * @dataProvider rotationTests - */ - public function testRotation($createFile, $dateFormat, $timeCallback) - { - touch($old1 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-1)).'.rot'); - touch($old2 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-2)).'.rot'); - touch($old3 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-3)).'.rot'); - touch($old4 = __DIR__.'/Fixtures/foo-'.date($dateFormat, $timeCallback(-4)).'.rot'); - - $log = __DIR__.'/Fixtures/foo-'.date($dateFormat).'.rot'; - - if ($createFile) { - touch($log); - } - - $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2); - $handler->setFormatter($this->getIdentityFormatter()); - $handler->setFilenameFormat('{filename}-{date}', $dateFormat); - $handler->handle($this->getRecord()); - - $handler->close(); - - $this->assertTrue(file_exists($log)); - $this->assertTrue(file_exists($old1)); - $this->assertEquals($createFile, file_exists($old2)); - $this->assertEquals($createFile, file_exists($old3)); - $this->assertEquals($createFile, file_exists($old4)); - $this->assertEquals('test', file_get_contents($log)); - } - - public function rotationTests() - { - $now = time(); - $dayCallback = function($ago) use ($now) { - return $now + 86400 * $ago; - }; - $monthCallback = function($ago) { - return gmmktime(0, 0, 0, date('n') + $ago, date('d'), date('Y')); - }; - $yearCallback = function($ago) { - return gmmktime(0, 0, 0, date('n'), date('d'), date('Y') + $ago); - }; - - return array( - 'Rotation is triggered when the file of the current day is not present' - => array(true, RotatingFileHandler::FILE_PER_DAY, $dayCallback), - 'Rotation is not triggered when the file of the current day is already present' - => array(false, RotatingFileHandler::FILE_PER_DAY, $dayCallback), - - 'Rotation is triggered when the file of the current month is not present' - => array(true, RotatingFileHandler::FILE_PER_MONTH, $monthCallback), - 'Rotation is not triggered when the file of the current month is already present' - => array(false, RotatingFileHandler::FILE_PER_MONTH, $monthCallback), - - 'Rotation is triggered when the file of the current year is not present' - => array(true, RotatingFileHandler::FILE_PER_YEAR, $yearCallback), - 'Rotation is not triggered when the file of the current year is already present' - => array(false, RotatingFileHandler::FILE_PER_YEAR, $yearCallback), - ); - } - - /** - * @dataProvider dateFormatProvider - */ - public function testAllowOnlyFixedDefinedDateFormats($dateFormat, $valid) - { - $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2); - $handler->setFilenameFormat('{filename}-{date}', $dateFormat); - if (!$valid) { - $this->assertErrorWasTriggered( - E_USER_DEPRECATED, - 'Invalid date format - format must be one of RotatingFileHandler::FILE_PER_DAY ("Y-m-d"), '. - 'RotatingFileHandler::FILE_PER_MONTH ("Y-m") or RotatingFileHandler::FILE_PER_YEAR ("Y"), '. - 'or you can set one of the date formats using slashes, underscores and/or dots instead of dashes.' - ); - } - } - - public function dateFormatProvider() - { - return array( - array(RotatingFileHandler::FILE_PER_DAY, true), - array(RotatingFileHandler::FILE_PER_MONTH, true), - array(RotatingFileHandler::FILE_PER_YEAR, true), - array('m-d-Y', false), - array('Y-m-d-h-i', false) - ); - } - - /** - * @dataProvider filenameFormatProvider - */ - public function testDisallowFilenameFormatsWithoutDate($filenameFormat, $valid) - { - $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot', 2); - $handler->setFilenameFormat($filenameFormat, RotatingFileHandler::FILE_PER_DAY); - if (!$valid) { - $this->assertErrorWasTriggered( - E_USER_DEPRECATED, - 'Invalid filename format - format should contain at least `{date}`, because otherwise rotating is impossible.' - ); - } - } - - public function filenameFormatProvider() - { - return array( - array('{filename}', false), - array('{filename}-{date}', true), - array('{date}', true), - array('foobar-{date}', true), - array('foo-{date}-bar', true), - array('{date}-foobar', true), - array('foobar', false), - ); - } - - public function testReuseCurrentFile() - { - $log = __DIR__.'/Fixtures/foo-'.date('Y-m-d').'.rot'; - file_put_contents($log, "foo"); - $handler = new RotatingFileHandler(__DIR__.'/Fixtures/foo.rot'); - $handler->setFormatter($this->getIdentityFormatter()); - $handler->handle($this->getRecord()); - $this->assertEquals('footest', file_get_contents($log)); - } - - public function tearDown() - { - foreach (glob(__DIR__.'/Fixtures/*.rot') as $file) { - unlink($file); - } - restore_error_handler(); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php deleted file mode 100644 index b354cee17..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/SamplingHandlerTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; - -/** - * @covers Monolog\Handler\SamplingHandler::handle - */ -class SamplingHandlerTest extends TestCase -{ - public function testHandle() - { - $testHandler = new TestHandler(); - $handler = new SamplingHandler($testHandler, 2); - for ($i = 0; $i < 10000; $i++) { - $handler->handle($this->getRecord()); - } - $count = count($testHandler->getRecords()); - // $count should be half of 10k, so between 4k and 6k - $this->assertLessThan(6000, $count); - $this->assertGreaterThan(4000, $count); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SlackHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SlackHandlerTest.php deleted file mode 100644 index a1fd8721c..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/SlackHandlerTest.php +++ /dev/null @@ -1,151 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; -use Monolog\Formatter\LineFormatter; - -/** - * @author Greg Kedzierski - * @see https://api.slack.com/ - */ -class SlackHandlerTest extends TestCase -{ - /** - * @var resource - */ - private $res; - - /** - * @var SlackHandler - */ - private $handler; - - public function setUp() - { - if (!extension_loaded('openssl')) { - $this->markTestSkipped('This test requires openssl to run'); - } - } - - public function testWriteHeader() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/POST \/api\/chat.postMessage HTTP\/1.1\\r\\nHost: slack.com\\r\\nContent-Type: application\/x-www-form-urlencoded\\r\\nContent-Length: \d{2,4}\\r\\n\\r\\n/', $content); - } - - public function testWriteContent() - { - $this->createHandler(); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/token=myToken&channel=channel1&username=Monolog&text=&attachments=.*$/', $content); - } - - public function testWriteContentUsesFormatterIfProvided() - { - $this->createHandler('myToken', 'channel1', 'Monolog', false); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->createHandler('myToken', 'channel1', 'Monolog', false); - $this->handler->setFormatter(new LineFormatter('foo--%message%')); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test2')); - fseek($this->res, 0); - $content2 = fread($this->res, 1024); - - $this->assertRegexp('/token=myToken&channel=channel1&username=Monolog&text=test1.*$/', $content); - $this->assertRegexp('/token=myToken&channel=channel1&username=Monolog&text=foo--test2.*$/', $content2); - } - - public function testWriteContentWithEmoji() - { - $this->createHandler('myToken', 'channel1', 'Monolog', true, 'alien'); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/icon_emoji=%3Aalien%3A$/', $content); - } - - /** - * @dataProvider provideLevelColors - */ - public function testWriteContentWithColors($level, $expectedColor) - { - $this->createHandler(); - $this->handler->handle($this->getRecord($level, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/color%22%3A%22'.$expectedColor.'/', $content); - } - - public function testWriteContentWithPlainTextMessage() - { - $this->createHandler('myToken', 'channel1', 'Monolog', false); - $this->handler->handle($this->getRecord(Logger::CRITICAL, 'test1')); - fseek($this->res, 0); - $content = fread($this->res, 1024); - - $this->assertRegexp('/text=test1/', $content); - } - - public function provideLevelColors() - { - return array( - array(Logger::DEBUG, '%23e3e4e6'), // escaped #e3e4e6 - array(Logger::INFO, 'good'), - array(Logger::NOTICE, 'good'), - array(Logger::WARNING, 'warning'), - array(Logger::ERROR, 'danger'), - array(Logger::CRITICAL, 'danger'), - array(Logger::ALERT, 'danger'), - array(Logger::EMERGENCY,'danger'), - ); - } - - private function createHandler($token = 'myToken', $channel = 'channel1', $username = 'Monolog', $useAttachment = true, $iconEmoji = null, $useShortAttachment = false, $includeExtra = false) - { - $constructorArgs = array($token, $channel, $username, $useAttachment, $iconEmoji, Logger::DEBUG, true, $useShortAttachment, $includeExtra); - $this->res = fopen('php://memory', 'a'); - $this->handler = $this->getMock( - '\Monolog\Handler\SlackHandler', - array('fsockopen', 'streamSetTimeout', 'closeSocket'), - $constructorArgs - ); - - $reflectionProperty = new \ReflectionProperty('\Monolog\Handler\SocketHandler', 'connectionString'); - $reflectionProperty->setAccessible(true); - $reflectionProperty->setValue($this->handler, 'localhost:1234'); - - $this->handler->expects($this->any()) - ->method('fsockopen') - ->will($this->returnValue($this->res)); - $this->handler->expects($this->any()) - ->method('streamSetTimeout') - ->will($this->returnValue(true)); - $this->handler->expects($this->any()) - ->method('closeSocket') - ->will($this->returnValue(true)); - - $this->handler->setFormatter($this->getIdentityFormatter()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php deleted file mode 100644 index 1f9c1f287..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/SocketHandlerTest.php +++ /dev/null @@ -1,309 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @author Pablo de Leon Belloc - */ -class SocketHandlerTest extends TestCase -{ - /** - * @var Monolog\Handler\SocketHandler - */ - private $handler; - - /** - * @var resource - */ - private $res; - - /** - * @expectedException UnexpectedValueException - */ - public function testInvalidHostname() - { - $this->createHandler('garbage://here'); - $this->writeRecord('data'); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testBadConnectionTimeout() - { - $this->createHandler('localhost:1234'); - $this->handler->setConnectionTimeout(-1); - } - - public function testSetConnectionTimeout() - { - $this->createHandler('localhost:1234'); - $this->handler->setConnectionTimeout(10.1); - $this->assertEquals(10.1, $this->handler->getConnectionTimeout()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testBadTimeout() - { - $this->createHandler('localhost:1234'); - $this->handler->setTimeout(-1); - } - - public function testSetTimeout() - { - $this->createHandler('localhost:1234'); - $this->handler->setTimeout(10.25); - $this->assertEquals(10.25, $this->handler->getTimeout()); - } - - public function testSetWritingTimeout() - { - $this->createHandler('localhost:1234'); - $this->handler->setWritingTimeout(10.25); - $this->assertEquals(10.25, $this->handler->getWritingTimeout()); - } - - public function testSetConnectionString() - { - $this->createHandler('tcp://localhost:9090'); - $this->assertEquals('tcp://localhost:9090', $this->handler->getConnectionString()); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testExceptionIsThrownOnFsockopenError() - { - $this->setMockHandler(array('fsockopen')); - $this->handler->expects($this->once()) - ->method('fsockopen') - ->will($this->returnValue(false)); - $this->writeRecord('Hello world'); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testExceptionIsThrownOnPfsockopenError() - { - $this->setMockHandler(array('pfsockopen')); - $this->handler->expects($this->once()) - ->method('pfsockopen') - ->will($this->returnValue(false)); - $this->handler->setPersistent(true); - $this->writeRecord('Hello world'); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testExceptionIsThrownIfCannotSetTimeout() - { - $this->setMockHandler(array('streamSetTimeout')); - $this->handler->expects($this->once()) - ->method('streamSetTimeout') - ->will($this->returnValue(false)); - $this->writeRecord('Hello world'); - } - - /** - * @expectedException RuntimeException - */ - public function testWriteFailsOnIfFwriteReturnsFalse() - { - $this->setMockHandler(array('fwrite')); - - $callback = function ($arg) { - $map = array( - 'Hello world' => 6, - 'world' => false, - ); - - return $map[$arg]; - }; - - $this->handler->expects($this->exactly(2)) - ->method('fwrite') - ->will($this->returnCallback($callback)); - - $this->writeRecord('Hello world'); - } - - /** - * @expectedException RuntimeException - */ - public function testWriteFailsIfStreamTimesOut() - { - $this->setMockHandler(array('fwrite', 'streamGetMetadata')); - - $callback = function ($arg) { - $map = array( - 'Hello world' => 6, - 'world' => 5, - ); - - return $map[$arg]; - }; - - $this->handler->expects($this->exactly(1)) - ->method('fwrite') - ->will($this->returnCallback($callback)); - $this->handler->expects($this->exactly(1)) - ->method('streamGetMetadata') - ->will($this->returnValue(array('timed_out' => true))); - - $this->writeRecord('Hello world'); - } - - /** - * @expectedException RuntimeException - */ - public function testWriteFailsOnIncompleteWrite() - { - $this->setMockHandler(array('fwrite', 'streamGetMetadata')); - - $res = $this->res; - $callback = function ($string) use ($res) { - fclose($res); - - return strlen('Hello'); - }; - - $this->handler->expects($this->exactly(1)) - ->method('fwrite') - ->will($this->returnCallback($callback)); - $this->handler->expects($this->exactly(1)) - ->method('streamGetMetadata') - ->will($this->returnValue(array('timed_out' => false))); - - $this->writeRecord('Hello world'); - } - - public function testWriteWithMemoryFile() - { - $this->setMockHandler(); - $this->writeRecord('test1'); - $this->writeRecord('test2'); - $this->writeRecord('test3'); - fseek($this->res, 0); - $this->assertEquals('test1test2test3', fread($this->res, 1024)); - } - - public function testWriteWithMock() - { - $this->setMockHandler(array('fwrite')); - - $callback = function ($arg) { - $map = array( - 'Hello world' => 6, - 'world' => 5, - ); - - return $map[$arg]; - }; - - $this->handler->expects($this->exactly(2)) - ->method('fwrite') - ->will($this->returnCallback($callback)); - - $this->writeRecord('Hello world'); - } - - public function testClose() - { - $this->setMockHandler(); - $this->writeRecord('Hello world'); - $this->assertInternalType('resource', $this->res); - $this->handler->close(); - $this->assertFalse(is_resource($this->res), "Expected resource to be closed after closing handler"); - } - - public function testCloseDoesNotClosePersistentSocket() - { - $this->setMockHandler(); - $this->handler->setPersistent(true); - $this->writeRecord('Hello world'); - $this->assertTrue(is_resource($this->res)); - $this->handler->close(); - $this->assertTrue(is_resource($this->res)); - } - - /** - * @expectedException \RuntimeException - */ - public function testAvoidInfiniteLoopWhenNoDataIsWrittenForAWritingTimeoutSeconds() - { - $this->setMockHandler(array('fwrite', 'streamGetMetadata')); - - $this->handler->expects($this->any()) - ->method('fwrite') - ->will($this->returnValue(0)); - - $this->handler->expects($this->any()) - ->method('streamGetMetadata') - ->will($this->returnValue(array('timed_out' => false))); - - $this->handler->setWritingTimeout(1); - - $this->writeRecord('Hello world'); - } - - private function createHandler($connectionString) - { - $this->handler = new SocketHandler($connectionString); - $this->handler->setFormatter($this->getIdentityFormatter()); - } - - private function writeRecord($string) - { - $this->handler->handle($this->getRecord(Logger::WARNING, $string)); - } - - private function setMockHandler(array $methods = array()) - { - $this->res = fopen('php://memory', 'a'); - - $defaultMethods = array('fsockopen', 'pfsockopen', 'streamSetTimeout'); - $newMethods = array_diff($methods, $defaultMethods); - - $finalMethods = array_merge($defaultMethods, $newMethods); - - $this->handler = $this->getMock( - '\Monolog\Handler\SocketHandler', $finalMethods, array('localhost:1234') - ); - - if (!in_array('fsockopen', $methods)) { - $this->handler->expects($this->any()) - ->method('fsockopen') - ->will($this->returnValue($this->res)); - } - - if (!in_array('pfsockopen', $methods)) { - $this->handler->expects($this->any()) - ->method('pfsockopen') - ->will($this->returnValue($this->res)); - } - - if (!in_array('streamSetTimeout', $methods)) { - $this->handler->expects($this->any()) - ->method('streamSetTimeout') - ->will($this->returnValue(true)); - } - - $this->handler->setFormatter($this->getIdentityFormatter()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php deleted file mode 100644 index 487030fe3..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/StreamHandlerTest.php +++ /dev/null @@ -1,184 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -class StreamHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWrite() - { - $handle = fopen('php://memory', 'a+'); - $handler = new StreamHandler($handle); - $handler->setFormatter($this->getIdentityFormatter()); - $handler->handle($this->getRecord(Logger::WARNING, 'test')); - $handler->handle($this->getRecord(Logger::WARNING, 'test2')); - $handler->handle($this->getRecord(Logger::WARNING, 'test3')); - fseek($handle, 0); - $this->assertEquals('testtest2test3', fread($handle, 100)); - } - - /** - * @covers Monolog\Handler\StreamHandler::close - */ - public function testCloseKeepsExternalHandlersOpen() - { - $handle = fopen('php://memory', 'a+'); - $handler = new StreamHandler($handle); - $this->assertTrue(is_resource($handle)); - $handler->close(); - $this->assertTrue(is_resource($handle)); - } - - /** - * @covers Monolog\Handler\StreamHandler::close - */ - public function testClose() - { - $handler = new StreamHandler('php://memory'); - $handler->handle($this->getRecord(Logger::WARNING, 'test')); - $streamProp = new \ReflectionProperty('Monolog\Handler\StreamHandler', 'stream'); - $streamProp->setAccessible(true); - $handle = $streamProp->getValue($handler); - - $this->assertTrue(is_resource($handle)); - $handler->close(); - $this->assertFalse(is_resource($handle)); - } - - /** - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteCreatesTheStreamResource() - { - $handler = new StreamHandler('php://memory'); - $handler->handle($this->getRecord()); - } - - /** - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteLocking() - { - $temp = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'monolog_locked_log'; - $handler = new StreamHandler($temp, Logger::DEBUG, true, null, true); - $handler->handle($this->getRecord()); - } - - /** - * @expectedException LogicException - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteMissingResource() - { - $handler = new StreamHandler(null); - $handler->handle($this->getRecord()); - } - - public function invalidArgumentProvider() - { - return array( - array(1), - array(array()), - array(array('bogus://url')), - ); - } - - /** - * @dataProvider invalidArgumentProvider - * @expectedException InvalidArgumentException - * @covers Monolog\Handler\StreamHandler::__construct - */ - public function testWriteInvalidArgument($invalidArgument) - { - $handler = new StreamHandler($invalidArgument); - } - - /** - * @expectedException UnexpectedValueException - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteInvalidResource() - { - $handler = new StreamHandler('bogus://url'); - $handler->handle($this->getRecord()); - } - - /** - * @expectedException UnexpectedValueException - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteNonExistingResource() - { - $handler = new StreamHandler('ftp://foo/bar/baz/'.rand(0, 10000)); - $handler->handle($this->getRecord()); - } - - /** - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteNonExistingPath() - { - $handler = new StreamHandler(sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000)); - $handler->handle($this->getRecord()); - } - - /** - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteNonExistingFileResource() - { - $handler = new StreamHandler('file://'.sys_get_temp_dir().'/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000)); - $handler->handle($this->getRecord()); - } - - /** - * @expectedException Exception - * @expectedExceptionMessageRegExp /There is no existing directory at/ - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteNonExistingAndNotCreatablePath() - { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('Permissions checks can not run on windows'); - } - $handler = new StreamHandler('/foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000)); - $handler->handle($this->getRecord()); - } - - /** - * @expectedException Exception - * @expectedExceptionMessageRegExp /There is no existing directory at/ - * @covers Monolog\Handler\StreamHandler::__construct - * @covers Monolog\Handler\StreamHandler::write - */ - public function testWriteNonExistingAndNotCreatableFileResource() - { - if (defined('PHP_WINDOWS_VERSION_BUILD')) { - $this->markTestSkipped('Permissions checks can not run on windows'); - } - $handler = new StreamHandler('file:///foo/bar/'.rand(0, 10000).DIRECTORY_SEPARATOR.rand(0, 10000)); - $handler->handle($this->getRecord()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SwiftMailerHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SwiftMailerHandlerTest.php deleted file mode 100644 index 858869100..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/SwiftMailerHandlerTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; -use Monolog\TestCase; - -class SwiftMailerHandlerTest extends TestCase -{ - /** @var \Swift_Mailer|\PHPUnit_Framework_MockObject_MockObject */ - private $mailer; - - public function setUp() - { - $this->mailer = $this - ->getMockBuilder('Swift_Mailer') - ->disableOriginalConstructor() - ->getMock(); - } - - public function testMessageCreationIsLazyWhenUsingCallback() - { - $this->mailer->expects($this->never()) - ->method('send'); - - $callback = function () { - throw new \RuntimeException('Swift_Message creation callback should not have been called in this test'); - }; - $handler = new SwiftMailerHandler($this->mailer, $callback); - - $records = array( - $this->getRecord(Logger::DEBUG), - $this->getRecord(Logger::INFO), - ); - $handler->handleBatch($records); - } - - public function testMessageCanBeCustomizedGivenLoggedData() - { - // Wire Mailer to expect a specific Swift_Message with a customized Subject - $expectedMessage = new \Swift_Message(); - $this->mailer->expects($this->once()) - ->method('send') - ->with($this->callback(function ($value) use ($expectedMessage) { - return $value instanceof \Swift_Message - && $value->getSubject() === 'Emergency' - && $value === $expectedMessage; - })); - - // Callback dynamically changes subject based on number of logged records - $callback = function ($content, array $records) use ($expectedMessage) { - $subject = count($records) > 0 ? 'Emergency' : 'Normal'; - $expectedMessage->setSubject($subject); - - return $expectedMessage; - }; - $handler = new SwiftMailerHandler($this->mailer, $callback); - - // Logging 1 record makes this an Emergency - $records = array( - $this->getRecord(Logger::EMERGENCY), - ); - $handler->handleBatch($records); - } - - public function testMessageSubjectFormatting() - { - // Wire Mailer to expect a specific Swift_Message with a customized Subject - $messageTemplate = new \Swift_Message(); - $messageTemplate->setSubject('Alert: %level_name% %message%'); - $receivedMessage = null; - - $this->mailer->expects($this->once()) - ->method('send') - ->with($this->callback(function ($value) use (&$receivedMessage) { - $receivedMessage = $value; - return true; - })); - - $handler = new SwiftMailerHandler($this->mailer, $messageTemplate); - - $records = array( - $this->getRecord(Logger::EMERGENCY), - ); - $handler->handleBatch($records); - - $this->assertEquals('Alert: EMERGENCY test', $receivedMessage->getSubject()); - } - - public function testMessageHaveUniqueId() - { - $messageTemplate = \Swift_Message::newInstance(); - $handler = new SwiftMailerHandler($this->mailer, $messageTemplate); - - $method = new \ReflectionMethod('Monolog\Handler\SwiftMailerHandler', 'buildMessage'); - $method->setAccessible(true); - $method->invokeArgs($handler, array($messageTemplate, array())); - - $builtMessage1 = $method->invoke($handler, $messageTemplate, array()); - $builtMessage2 = $method->invoke($handler, $messageTemplate, array()); - - $this->assertFalse($builtMessage1->getId() === $builtMessage2->getId(), 'Two different messages have the same id'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php deleted file mode 100644 index 8f9e46bf1..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/SyslogHandlerTest.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\Logger; - -class SyslogHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Monolog\Handler\SyslogHandler::__construct - */ - public function testConstruct() - { - $handler = new SyslogHandler('test'); - $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); - - $handler = new SyslogHandler('test', LOG_USER); - $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); - - $handler = new SyslogHandler('test', 'user'); - $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); - - $handler = new SyslogHandler('test', LOG_USER, Logger::DEBUG, true, LOG_PERROR); - $this->assertInstanceOf('Monolog\Handler\SyslogHandler', $handler); - } - - /** - * @covers Monolog\Handler\SyslogHandler::__construct - */ - public function testConstructInvalidFacility() - { - $this->setExpectedException('UnexpectedValueException'); - $handler = new SyslogHandler('test', 'unknown'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php deleted file mode 100644 index 497812b32..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/SyslogUdpHandlerTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -/** - * @requires extension sockets - */ -class SyslogUdpHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException UnexpectedValueException - */ - public function testWeValidateFacilities() - { - $handler = new SyslogUdpHandler("ip", null, "invalidFacility"); - } - - public function testWeSplitIntoLines() - { - $handler = new SyslogUdpHandler("127.0.0.1", 514, "authpriv"); - $handler->setFormatter(new \Monolog\Formatter\ChromePHPFormatter()); - - $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('write'), array('lol', 'lol')); - $socket->expects($this->at(0)) - ->method('write') - ->with("lol", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 "); - $socket->expects($this->at(1)) - ->method('write') - ->with("hej", "<".(LOG_AUTHPRIV + LOG_WARNING).">1 "); - - $handler->setSocket($socket); - - $handler->handle($this->getRecordWithMessage("hej\nlol")); - } - - protected function getRecordWithMessage($msg) - { - return array('message' => $msg, 'level' => \Monolog\Logger::WARNING, 'context' => null, 'extra' => array(), 'channel' => 'lol'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php deleted file mode 100644 index 75cc4a8d4..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/TestHandlerTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -/** - * @covers Monolog\Handler\TestHandler - */ -class TestHandlerTest extends TestCase -{ - /** - * @dataProvider methodProvider - */ - public function testHandler($method, $level) - { - $handler = new TestHandler; - $record = $this->getRecord($level, 'test'.$method); - $this->assertFalse($handler->{'has'.$method}($record), 'has'.$method); - $this->assertFalse($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains'); - $this->assertFalse($handler->{'has'.$method.'ThatPasses'}(function ($rec) { - return true; - }), 'has'.$method.'ThatPasses'); - $this->assertFalse($handler->{'has'.$method.'ThatMatches'}('/test\w+/')); - $this->assertFalse($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records'); - $handler->handle($record); - - $this->assertFalse($handler->{'has'.$method}('bar'), 'has'.$method); - $this->assertTrue($handler->{'has'.$method}($record), 'has'.$method); - $this->assertTrue($handler->{'has'.$method}('test'.$method), 'has'.$method); - $this->assertTrue($handler->{'has'.$method.'ThatContains'}('test'), 'has'.$method.'ThatContains'); - $this->assertTrue($handler->{'has'.$method.'ThatPasses'}(function ($rec) { - return true; - }), 'has'.$method.'ThatPasses'); - $this->assertTrue($handler->{'has'.$method.'ThatMatches'}('/test\w+/')); - $this->assertTrue($handler->{'has'.$method.'Records'}(), 'has'.$method.'Records'); - - $records = $handler->getRecords(); - unset($records[0]['formatted']); - $this->assertEquals(array($record), $records); - } - - public function methodProvider() - { - return array( - array('Emergency', Logger::EMERGENCY), - array('Alert' , Logger::ALERT), - array('Critical' , Logger::CRITICAL), - array('Error' , Logger::ERROR), - array('Warning' , Logger::WARNING), - array('Info' , Logger::INFO), - array('Notice' , Logger::NOTICE), - array('Debug' , Logger::DEBUG), - ); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php deleted file mode 100644 index fa524d00f..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/UdpSocketTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Handler\SyslogUdp\UdpSocket; - -/** - * @requires extension sockets - */ -class UdpSocketTest extends TestCase -{ - public function testWeDoNotTruncateShortMessages() - { - $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol')); - - $socket->expects($this->at(0)) - ->method('send') - ->with("HEADER: The quick brown fox jumps over the lazy dog"); - - $socket->write("The quick brown fox jumps over the lazy dog", "HEADER: "); - } - - public function testLongMessagesAreTruncated() - { - $socket = $this->getMock('\Monolog\Handler\SyslogUdp\UdpSocket', array('send'), array('lol', 'lol')); - - $truncatedString = str_repeat("derp", 16254).'d'; - - $socket->expects($this->exactly(1)) - ->method('send') - ->with("HEADER" . $truncatedString); - - $longString = str_repeat("derp", 20000); - - $socket->write($longString, "HEADER"); - } - - public function testDoubleCloseDoesNotError() - { - $socket = new UdpSocket('127.0.0.1', 514); - $socket->close(); - $socket->close(); - } - - /** - * @expectedException LogicException - */ - public function testWriteAfterCloseErrors() - { - $socket = new UdpSocket('127.0.0.1', 514); - $socket->close(); - $socket->write('foo', "HEADER"); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php deleted file mode 100644 index 8d37a1fcc..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/WhatFailureGroupHandlerTest.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; -use Monolog\Logger; - -class WhatFailureGroupHandlerTest extends TestCase -{ - /** - * @covers Monolog\Handler\WhatFailureGroupHandler::__construct - * @expectedException InvalidArgumentException - */ - public function testConstructorOnlyTakesHandler() - { - new WhatFailureGroupHandler(array(new TestHandler(), "foo")); - } - - /** - * @covers Monolog\Handler\WhatFailureGroupHandler::__construct - * @covers Monolog\Handler\WhatFailureGroupHandler::handle - */ - public function testHandle() - { - $testHandlers = array(new TestHandler(), new TestHandler()); - $handler = new WhatFailureGroupHandler($testHandlers); - $handler->handle($this->getRecord(Logger::DEBUG)); - $handler->handle($this->getRecord(Logger::INFO)); - foreach ($testHandlers as $test) { - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue(count($test->getRecords()) === 2); - } - } - - /** - * @covers Monolog\Handler\WhatFailureGroupHandler::handleBatch - */ - public function testHandleBatch() - { - $testHandlers = array(new TestHandler(), new TestHandler()); - $handler = new WhatFailureGroupHandler($testHandlers); - $handler->handleBatch(array($this->getRecord(Logger::DEBUG), $this->getRecord(Logger::INFO))); - foreach ($testHandlers as $test) { - $this->assertTrue($test->hasDebugRecords()); - $this->assertTrue($test->hasInfoRecords()); - $this->assertTrue(count($test->getRecords()) === 2); - } - } - - /** - * @covers Monolog\Handler\WhatFailureGroupHandler::isHandling - */ - public function testIsHandling() - { - $testHandlers = array(new TestHandler(Logger::ERROR), new TestHandler(Logger::WARNING)); - $handler = new WhatFailureGroupHandler($testHandlers); - $this->assertTrue($handler->isHandling($this->getRecord(Logger::ERROR))); - $this->assertTrue($handler->isHandling($this->getRecord(Logger::WARNING))); - $this->assertFalse($handler->isHandling($this->getRecord(Logger::DEBUG))); - } - - /** - * @covers Monolog\Handler\WhatFailureGroupHandler::handle - */ - public function testHandleUsesProcessors() - { - $test = new TestHandler(); - $handler = new WhatFailureGroupHandler(array($test)); - $handler->pushProcessor(function ($record) { - $record['extra']['foo'] = true; - - return $record; - }); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasWarningRecords()); - $records = $test->getRecords(); - $this->assertTrue($records[0]['extra']['foo']); - } - - /** - * @covers Monolog\Handler\WhatFailureGroupHandler::handle - */ - public function testHandleException() - { - $test = new TestHandler(); - $exception = new ExceptionTestHandler(); - $handler = new WhatFailureGroupHandler(array($exception, $test, $exception)); - $handler->pushProcessor(function ($record) { - $record['extra']['foo'] = true; - - return $record; - }); - $handler->handle($this->getRecord(Logger::WARNING)); - $this->assertTrue($test->hasWarningRecords()); - $records = $test->getRecords(); - $this->assertTrue($records[0]['extra']['foo']); - } -} - -class ExceptionTestHandler extends TestHandler -{ - /** - * {@inheritdoc} - */ - public function handle(array $record) - { - parent::handle($record); - - throw new \Exception("ExceptionTestHandler::handle"); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php b/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php deleted file mode 100644 index 69b001eae..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Handler/ZendMonitorHandlerTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Handler; - -use Monolog\TestCase; - -class ZendMonitorHandlerTest extends TestCase -{ - protected $zendMonitorHandler; - - public function setUp() - { - if (!function_exists('zend_monitor_custom_event')) { - $this->markTestSkipped('ZendServer is not installed'); - } - } - - /** - * @covers Monolog\Handler\ZendMonitorHandler::write - */ - public function testWrite() - { - $record = $this->getRecord(); - $formatterResult = array( - 'message' => $record['message'], - ); - - $zendMonitor = $this->getMockBuilder('Monolog\Handler\ZendMonitorHandler') - ->setMethods(array('writeZendMonitorCustomEvent', 'getDefaultFormatter')) - ->getMock(); - - $formatterMock = $this->getMockBuilder('Monolog\Formatter\NormalizerFormatter') - ->disableOriginalConstructor() - ->getMock(); - - $formatterMock->expects($this->once()) - ->method('format') - ->will($this->returnValue($formatterResult)); - - $zendMonitor->expects($this->once()) - ->method('getDefaultFormatter') - ->will($this->returnValue($formatterMock)); - - $levelMap = $zendMonitor->getLevelMap(); - - $zendMonitor->expects($this->once()) - ->method('writeZendMonitorCustomEvent') - ->with($levelMap[$record['level']], $record['message'], $formatterResult); - - $zendMonitor->handle($record); - } - - /** - * @covers Monolog\Handler\ZendMonitorHandler::getDefaultFormatter - */ - public function testGetDefaultFormatterReturnsNormalizerFormatter() - { - $zendMonitor = new ZendMonitorHandler(); - $this->assertInstanceOf('Monolog\Formatter\NormalizerFormatter', $zendMonitor->getDefaultFormatter()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/LoggerTest.php b/vendor/monolog/monolog/tests/Monolog/LoggerTest.php deleted file mode 100644 index c0bd1da90..000000000 --- a/vendor/monolog/monolog/tests/Monolog/LoggerTest.php +++ /dev/null @@ -1,548 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog; - -use Monolog\Processor\WebProcessor; -use Monolog\Handler\TestHandler; - -class LoggerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @covers Monolog\Logger::getName - */ - public function testGetName() - { - $logger = new Logger('foo'); - $this->assertEquals('foo', $logger->getName()); - } - - /** - * @covers Monolog\Logger::getLevelName - */ - public function testGetLevelName() - { - $this->assertEquals('ERROR', Logger::getLevelName(Logger::ERROR)); - } - - /** - * @covers Monolog\Logger::withName - */ - public function testWithName() - { - $first = new Logger('first', array($handler = new TestHandler())); - $second = $first->withName('second'); - - $this->assertSame('first', $first->getName()); - $this->assertSame('second', $second->getName()); - $this->assertSame($handler, $second->popHandler()); - } - - /** - * @covers Monolog\Logger::toMonologLevel - */ - public function testConvertPSR3ToMonologLevel() - { - $this->assertEquals(Logger::toMonologLevel('debug'), 100); - $this->assertEquals(Logger::toMonologLevel('info'), 200); - $this->assertEquals(Logger::toMonologLevel('notice'), 250); - $this->assertEquals(Logger::toMonologLevel('warning'), 300); - $this->assertEquals(Logger::toMonologLevel('error'), 400); - $this->assertEquals(Logger::toMonologLevel('critical'), 500); - $this->assertEquals(Logger::toMonologLevel('alert'), 550); - $this->assertEquals(Logger::toMonologLevel('emergency'), 600); - } - - /** - * @covers Monolog\Logger::getLevelName - * @expectedException InvalidArgumentException - */ - public function testGetLevelNameThrows() - { - Logger::getLevelName(5); - } - - /** - * @covers Monolog\Logger::__construct - */ - public function testChannel() - { - $logger = new Logger('foo'); - $handler = new TestHandler; - $logger->pushHandler($handler); - $logger->addWarning('test'); - list($record) = $handler->getRecords(); - $this->assertEquals('foo', $record['channel']); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testLog() - { - $logger = new Logger(__METHOD__); - - $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle')); - $handler->expects($this->once()) - ->method('handle'); - $logger->pushHandler($handler); - - $this->assertTrue($logger->addWarning('test')); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testLogNotHandled() - { - $logger = new Logger(__METHOD__); - - $handler = $this->getMock('Monolog\Handler\NullHandler', array('handle'), array(Logger::ERROR)); - $handler->expects($this->never()) - ->method('handle'); - $logger->pushHandler($handler); - - $this->assertFalse($logger->addWarning('test')); - } - - public function testHandlersInCtor() - { - $handler1 = new TestHandler; - $handler2 = new TestHandler; - $logger = new Logger(__METHOD__, array($handler1, $handler2)); - - $this->assertEquals($handler1, $logger->popHandler()); - $this->assertEquals($handler2, $logger->popHandler()); - } - - public function testProcessorsInCtor() - { - $processor1 = new WebProcessor; - $processor2 = new WebProcessor; - $logger = new Logger(__METHOD__, array(), array($processor1, $processor2)); - - $this->assertEquals($processor1, $logger->popProcessor()); - $this->assertEquals($processor2, $logger->popProcessor()); - } - - /** - * @covers Monolog\Logger::pushHandler - * @covers Monolog\Logger::popHandler - * @expectedException LogicException - */ - public function testPushPopHandler() - { - $logger = new Logger(__METHOD__); - $handler1 = new TestHandler; - $handler2 = new TestHandler; - - $logger->pushHandler($handler1); - $logger->pushHandler($handler2); - - $this->assertEquals($handler2, $logger->popHandler()); - $this->assertEquals($handler1, $logger->popHandler()); - $logger->popHandler(); - } - - /** - * @covers Monolog\Logger::setHandlers - */ - public function testSetHandlers() - { - $logger = new Logger(__METHOD__); - $handler1 = new TestHandler; - $handler2 = new TestHandler; - - $logger->pushHandler($handler1); - $logger->setHandlers(array($handler2)); - - // handler1 has been removed - $this->assertEquals(array($handler2), $logger->getHandlers()); - - $logger->setHandlers(array( - "AMapKey" => $handler1, - "Woop" => $handler2, - )); - - // Keys have been scrubbed - $this->assertEquals(array($handler1, $handler2), $logger->getHandlers()); - } - - /** - * @covers Monolog\Logger::pushProcessor - * @covers Monolog\Logger::popProcessor - * @expectedException LogicException - */ - public function testPushPopProcessor() - { - $logger = new Logger(__METHOD__); - $processor1 = new WebProcessor; - $processor2 = new WebProcessor; - - $logger->pushProcessor($processor1); - $logger->pushProcessor($processor2); - - $this->assertEquals($processor2, $logger->popProcessor()); - $this->assertEquals($processor1, $logger->popProcessor()); - $logger->popProcessor(); - } - - /** - * @covers Monolog\Logger::pushProcessor - * @expectedException InvalidArgumentException - */ - public function testPushProcessorWithNonCallable() - { - $logger = new Logger(__METHOD__); - - $logger->pushProcessor(new \stdClass()); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testProcessorsAreExecuted() - { - $logger = new Logger(__METHOD__); - $handler = new TestHandler; - $logger->pushHandler($handler); - $logger->pushProcessor(function ($record) { - $record['extra']['win'] = true; - - return $record; - }); - $logger->addError('test'); - list($record) = $handler->getRecords(); - $this->assertTrue($record['extra']['win']); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testProcessorsAreCalledOnlyOnce() - { - $logger = new Logger(__METHOD__); - $handler = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler->expects($this->any()) - ->method('isHandling') - ->will($this->returnValue(true)) - ; - $handler->expects($this->any()) - ->method('handle') - ->will($this->returnValue(true)) - ; - $logger->pushHandler($handler); - - $processor = $this->getMockBuilder('Monolog\Processor\WebProcessor') - ->disableOriginalConstructor() - ->setMethods(array('__invoke')) - ->getMock() - ; - $processor->expects($this->once()) - ->method('__invoke') - ->will($this->returnArgument(0)) - ; - $logger->pushProcessor($processor); - - $logger->addError('test'); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testProcessorsNotCalledWhenNotHandled() - { - $logger = new Logger(__METHOD__); - $handler = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler->expects($this->once()) - ->method('isHandling') - ->will($this->returnValue(false)) - ; - $logger->pushHandler($handler); - $that = $this; - $logger->pushProcessor(function ($record) use ($that) { - $that->fail('The processor should not be called'); - }); - $logger->addAlert('test'); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testHandlersNotCalledBeforeFirstHandling() - { - $logger = new Logger(__METHOD__); - - $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler1->expects($this->never()) - ->method('isHandling') - ->will($this->returnValue(false)) - ; - $handler1->expects($this->once()) - ->method('handle') - ->will($this->returnValue(false)) - ; - $logger->pushHandler($handler1); - - $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler2->expects($this->once()) - ->method('isHandling') - ->will($this->returnValue(true)) - ; - $handler2->expects($this->once()) - ->method('handle') - ->will($this->returnValue(false)) - ; - $logger->pushHandler($handler2); - - $handler3 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler3->expects($this->once()) - ->method('isHandling') - ->will($this->returnValue(false)) - ; - $handler3->expects($this->never()) - ->method('handle') - ; - $logger->pushHandler($handler3); - - $logger->debug('test'); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testHandlersNotCalledBeforeFirstHandlingWithAssocArray() - { - $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler1->expects($this->never()) - ->method('isHandling') - ->will($this->returnValue(false)) - ; - $handler1->expects($this->once()) - ->method('handle') - ->will($this->returnValue(false)) - ; - - $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler2->expects($this->once()) - ->method('isHandling') - ->will($this->returnValue(true)) - ; - $handler2->expects($this->once()) - ->method('handle') - ->will($this->returnValue(false)) - ; - - $handler3 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler3->expects($this->once()) - ->method('isHandling') - ->will($this->returnValue(false)) - ; - $handler3->expects($this->never()) - ->method('handle') - ; - - $logger = new Logger(__METHOD__, array('last' => $handler3, 'second' => $handler2, 'first' => $handler1)); - - $logger->debug('test'); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testBubblingWhenTheHandlerReturnsFalse() - { - $logger = new Logger(__METHOD__); - - $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler1->expects($this->any()) - ->method('isHandling') - ->will($this->returnValue(true)) - ; - $handler1->expects($this->once()) - ->method('handle') - ->will($this->returnValue(false)) - ; - $logger->pushHandler($handler1); - - $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler2->expects($this->any()) - ->method('isHandling') - ->will($this->returnValue(true)) - ; - $handler2->expects($this->once()) - ->method('handle') - ->will($this->returnValue(false)) - ; - $logger->pushHandler($handler2); - - $logger->debug('test'); - } - - /** - * @covers Monolog\Logger::addRecord - */ - public function testNotBubblingWhenTheHandlerReturnsTrue() - { - $logger = new Logger(__METHOD__); - - $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler1->expects($this->any()) - ->method('isHandling') - ->will($this->returnValue(true)) - ; - $handler1->expects($this->never()) - ->method('handle') - ; - $logger->pushHandler($handler1); - - $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler2->expects($this->any()) - ->method('isHandling') - ->will($this->returnValue(true)) - ; - $handler2->expects($this->once()) - ->method('handle') - ->will($this->returnValue(true)) - ; - $logger->pushHandler($handler2); - - $logger->debug('test'); - } - - /** - * @covers Monolog\Logger::isHandling - */ - public function testIsHandling() - { - $logger = new Logger(__METHOD__); - - $handler1 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler1->expects($this->any()) - ->method('isHandling') - ->will($this->returnValue(false)) - ; - - $logger->pushHandler($handler1); - $this->assertFalse($logger->isHandling(Logger::DEBUG)); - - $handler2 = $this->getMock('Monolog\Handler\HandlerInterface'); - $handler2->expects($this->any()) - ->method('isHandling') - ->will($this->returnValue(true)) - ; - - $logger->pushHandler($handler2); - $this->assertTrue($logger->isHandling(Logger::DEBUG)); - } - - /** - * @dataProvider logMethodProvider - * @covers Monolog\Logger::addDebug - * @covers Monolog\Logger::addInfo - * @covers Monolog\Logger::addNotice - * @covers Monolog\Logger::addWarning - * @covers Monolog\Logger::addError - * @covers Monolog\Logger::addCritical - * @covers Monolog\Logger::addAlert - * @covers Monolog\Logger::addEmergency - * @covers Monolog\Logger::debug - * @covers Monolog\Logger::info - * @covers Monolog\Logger::notice - * @covers Monolog\Logger::warn - * @covers Monolog\Logger::err - * @covers Monolog\Logger::crit - * @covers Monolog\Logger::alert - * @covers Monolog\Logger::emerg - */ - public function testLogMethods($method, $expectedLevel) - { - $logger = new Logger('foo'); - $handler = new TestHandler; - $logger->pushHandler($handler); - $logger->{$method}('test'); - list($record) = $handler->getRecords(); - $this->assertEquals($expectedLevel, $record['level']); - } - - public function logMethodProvider() - { - return array( - // monolog methods - array('addDebug', Logger::DEBUG), - array('addInfo', Logger::INFO), - array('addNotice', Logger::NOTICE), - array('addWarning', Logger::WARNING), - array('addError', Logger::ERROR), - array('addCritical', Logger::CRITICAL), - array('addAlert', Logger::ALERT), - array('addEmergency', Logger::EMERGENCY), - - // ZF/Sf2 compat methods - array('debug', Logger::DEBUG), - array('info', Logger::INFO), - array('notice', Logger::NOTICE), - array('warn', Logger::WARNING), - array('err', Logger::ERROR), - array('crit', Logger::CRITICAL), - array('alert', Logger::ALERT), - array('emerg', Logger::EMERGENCY), - ); - } - - /** - * @dataProvider setTimezoneProvider - * @covers Monolog\Logger::setTimezone - */ - public function testSetTimezone($tz) - { - Logger::setTimezone($tz); - $logger = new Logger('foo'); - $handler = new TestHandler; - $logger->pushHandler($handler); - $logger->info('test'); - list($record) = $handler->getRecords(); - $this->assertEquals($tz, $record['datetime']->getTimezone()); - } - - public function setTimezoneProvider() - { - return array_map( - function ($tz) { return array(new \DateTimeZone($tz)); }, - \DateTimeZone::listIdentifiers() - ); - } - - /** - * @dataProvider useMicrosecondTimestampsProvider - * @covers Monolog\Logger::useMicrosecondTimestamps - * @covers Monolog\Logger::addRecord - */ - public function testUseMicrosecondTimestamps($micro, $assert) - { - $logger = new Logger('foo'); - $logger->useMicrosecondTimestamps($micro); - $handler = new TestHandler; - $logger->pushHandler($handler); - $logger->info('test'); - list($record) = $handler->getRecords(); - $this->{$assert}('000000', $record['datetime']->format('u')); - } - - public function useMicrosecondTimestampsProvider() - { - return array( - // this has a very small chance of a false negative (1/10^6) - 'with microseconds' => array(true, 'assertNotSame'), - 'without microseconds' => array(false, 'assertSame'), - ); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php deleted file mode 100644 index 5adb505dc..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/GitProcessorTest.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\TestCase; - -class GitProcessorTest extends TestCase -{ - /** - * @covers Monolog\Processor\GitProcessor::__invoke - */ - public function testProcessor() - { - $processor = new GitProcessor(); - $record = $processor($this->getRecord()); - - $this->assertArrayHasKey('git', $record['extra']); - $this->assertTrue(!is_array($record['extra']['git']['branch'])); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php deleted file mode 100644 index 0dd411d75..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/IntrospectionProcessorTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Acme; - -class Tester -{ - public function test($handler, $record) - { - $handler->handle($record); - } -} - -function tester($handler, $record) -{ - $handler->handle($record); -} - -namespace Monolog\Processor; - -use Monolog\Logger; -use Monolog\TestCase; -use Monolog\Handler\TestHandler; - -class IntrospectionProcessorTest extends TestCase -{ - public function getHandler() - { - $processor = new IntrospectionProcessor(); - $handler = new TestHandler(); - $handler->pushProcessor($processor); - - return $handler; - } - - public function testProcessorFromClass() - { - $handler = $this->getHandler(); - $tester = new \Acme\Tester; - $tester->test($handler, $this->getRecord()); - list($record) = $handler->getRecords(); - $this->assertEquals(__FILE__, $record['extra']['file']); - $this->assertEquals(18, $record['extra']['line']); - $this->assertEquals('Acme\Tester', $record['extra']['class']); - $this->assertEquals('test', $record['extra']['function']); - } - - public function testProcessorFromFunc() - { - $handler = $this->getHandler(); - \Acme\tester($handler, $this->getRecord()); - list($record) = $handler->getRecords(); - $this->assertEquals(__FILE__, $record['extra']['file']); - $this->assertEquals(24, $record['extra']['line']); - $this->assertEquals(null, $record['extra']['class']); - $this->assertEquals('Acme\tester', $record['extra']['function']); - } - - public function testLevelTooLow() - { - $input = array( - 'level' => Logger::DEBUG, - 'extra' => array(), - ); - - $expected = $input; - - $processor = new IntrospectionProcessor(Logger::CRITICAL); - $actual = $processor($input); - - $this->assertEquals($expected, $actual); - } - - public function testLevelEqual() - { - $input = array( - 'level' => Logger::CRITICAL, - 'extra' => array(), - ); - - $expected = $input; - $expected['extra'] = array( - 'file' => null, - 'line' => null, - 'class' => 'ReflectionMethod', - 'function' => 'invokeArgs', - ); - - $processor = new IntrospectionProcessor(Logger::CRITICAL); - $actual = $processor($input); - - $this->assertEquals($expected, $actual); - } - - public function testLevelHigher() - { - $input = array( - 'level' => Logger::EMERGENCY, - 'extra' => array(), - ); - - $expected = $input; - $expected['extra'] = array( - 'file' => null, - 'line' => null, - 'class' => 'ReflectionMethod', - 'function' => 'invokeArgs', - ); - - $processor = new IntrospectionProcessor(Logger::CRITICAL); - $actual = $processor($input); - - $this->assertEquals($expected, $actual); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php deleted file mode 100644 index eb666144e..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/MemoryPeakUsageProcessorTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\TestCase; - -class MemoryPeakUsageProcessorTest extends TestCase -{ - /** - * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke - * @covers Monolog\Processor\MemoryProcessor::formatBytes - */ - public function testProcessor() - { - $processor = new MemoryPeakUsageProcessor(); - $record = $processor($this->getRecord()); - $this->assertArrayHasKey('memory_peak_usage', $record['extra']); - $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_peak_usage']); - } - - /** - * @covers Monolog\Processor\MemoryPeakUsageProcessor::__invoke - * @covers Monolog\Processor\MemoryProcessor::formatBytes - */ - public function testProcessorWithoutFormatting() - { - $processor = new MemoryPeakUsageProcessor(true, false); - $record = $processor($this->getRecord()); - $this->assertArrayHasKey('memory_peak_usage', $record['extra']); - $this->assertInternalType('int', $record['extra']['memory_peak_usage']); - $this->assertGreaterThan(0, $record['extra']['memory_peak_usage']); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php deleted file mode 100644 index 4692dbfc7..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/MemoryUsageProcessorTest.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\TestCase; - -class MemoryUsageProcessorTest extends TestCase -{ - /** - * @covers Monolog\Processor\MemoryUsageProcessor::__invoke - * @covers Monolog\Processor\MemoryProcessor::formatBytes - */ - public function testProcessor() - { - $processor = new MemoryUsageProcessor(); - $record = $processor($this->getRecord()); - $this->assertArrayHasKey('memory_usage', $record['extra']); - $this->assertRegExp('#[0-9.]+ (M|K)?B$#', $record['extra']['memory_usage']); - } - - /** - * @covers Monolog\Processor\MemoryUsageProcessor::__invoke - * @covers Monolog\Processor\MemoryProcessor::formatBytes - */ - public function testProcessorWithoutFormatting() - { - $processor = new MemoryUsageProcessor(true, false); - $record = $processor($this->getRecord()); - $this->assertArrayHasKey('memory_usage', $record['extra']); - $this->assertInternalType('int', $record['extra']['memory_usage']); - $this->assertGreaterThan(0, $record['extra']['memory_usage']); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php deleted file mode 100644 index 458d2a33a..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/ProcessIdProcessorTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\TestCase; - -class ProcessIdProcessorTest extends TestCase -{ - /** - * @covers Monolog\Processor\ProcessIdProcessor::__invoke - */ - public function testProcessor() - { - $processor = new ProcessIdProcessor(); - $record = $processor($this->getRecord()); - $this->assertArrayHasKey('process_id', $record['extra']); - $this->assertInternalType('int', $record['extra']['process_id']); - $this->assertGreaterThan(0, $record['extra']['process_id']); - $this->assertEquals(getmypid(), $record['extra']['process_id']); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php deleted file mode 100644 index 029a0c02d..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/PsrLogMessageProcessorTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -class PsrLogMessageProcessorTest extends \PHPUnit_Framework_TestCase -{ - /** - * @dataProvider getPairs - */ - public function testReplacement($val, $expected) - { - $proc = new PsrLogMessageProcessor; - - $message = $proc(array( - 'message' => '{foo}', - 'context' => array('foo' => $val), - )); - $this->assertEquals($expected, $message['message']); - } - - public function getPairs() - { - return array( - array('foo', 'foo'), - array('3', '3'), - array(3, '3'), - array(null, ''), - array(true, '1'), - array(false, ''), - array(new \stdClass, '[object stdClass]'), - array(array(), '[array]'), - ); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php deleted file mode 100644 index 0d860c61a..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/TagProcessorTest.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\TestCase; - -class TagProcessorTest extends TestCase -{ - /** - * @covers Monolog\Processor\TagProcessor::__invoke - */ - public function testProcessor() - { - $tags = array(1, 2, 3); - $processor = new TagProcessor($tags); - $record = $processor($this->getRecord()); - - $this->assertEquals($tags, $record['extra']['tags']); - } - - /** - * @covers Monolog\Processor\TagProcessor::__invoke - */ - public function testProcessorTagModification() - { - $tags = array(1, 2, 3); - $processor = new TagProcessor($tags); - - $record = $processor($this->getRecord()); - $this->assertEquals($tags, $record['extra']['tags']); - - $processor->setTags(array('a', 'b')); - $record = $processor($this->getRecord()); - $this->assertEquals(array('a', 'b'), $record['extra']['tags']); - - $processor->addTags(array('a', 'c', 'foo' => 'bar')); - $record = $processor($this->getRecord()); - $this->assertEquals(array('a', 'b', 'a', 'c', 'foo' => 'bar'), $record['extra']['tags']); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php deleted file mode 100644 index 5d13058fd..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/UidProcessorTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\TestCase; - -class UidProcessorTest extends TestCase -{ - /** - * @covers Monolog\Processor\UidProcessor::__invoke - */ - public function testProcessor() - { - $processor = new UidProcessor(); - $record = $processor($this->getRecord()); - $this->assertArrayHasKey('uid', $record['extra']); - } - - public function testGetUid() - { - $processor = new UidProcessor(10); - $this->assertEquals(10, strlen($processor->getUid())); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php b/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php deleted file mode 100644 index 4105baf79..000000000 --- a/vendor/monolog/monolog/tests/Monolog/Processor/WebProcessorTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog\Processor; - -use Monolog\TestCase; - -class WebProcessorTest extends TestCase -{ - public function testProcessor() - { - $server = array( - 'REQUEST_URI' => 'A', - 'REMOTE_ADDR' => 'B', - 'REQUEST_METHOD' => 'C', - 'HTTP_REFERER' => 'D', - 'SERVER_NAME' => 'F', - 'UNIQUE_ID' => 'G', - ); - - $processor = new WebProcessor($server); - $record = $processor($this->getRecord()); - $this->assertEquals($server['REQUEST_URI'], $record['extra']['url']); - $this->assertEquals($server['REMOTE_ADDR'], $record['extra']['ip']); - $this->assertEquals($server['REQUEST_METHOD'], $record['extra']['http_method']); - $this->assertEquals($server['HTTP_REFERER'], $record['extra']['referrer']); - $this->assertEquals($server['SERVER_NAME'], $record['extra']['server']); - $this->assertEquals($server['UNIQUE_ID'], $record['extra']['unique_id']); - } - - public function testProcessorDoNothingIfNoRequestUri() - { - $server = array( - 'REMOTE_ADDR' => 'B', - 'REQUEST_METHOD' => 'C', - ); - $processor = new WebProcessor($server); - $record = $processor($this->getRecord()); - $this->assertEmpty($record['extra']); - } - - public function testProcessorReturnNullIfNoHttpReferer() - { - $server = array( - 'REQUEST_URI' => 'A', - 'REMOTE_ADDR' => 'B', - 'REQUEST_METHOD' => 'C', - 'SERVER_NAME' => 'F', - ); - $processor = new WebProcessor($server); - $record = $processor($this->getRecord()); - $this->assertNull($record['extra']['referrer']); - } - - public function testProcessorDoesNotAddUniqueIdIfNotPresent() - { - $server = array( - 'REQUEST_URI' => 'A', - 'REMOTE_ADDR' => 'B', - 'REQUEST_METHOD' => 'C', - 'SERVER_NAME' => 'F', - ); - $processor = new WebProcessor($server); - $record = $processor($this->getRecord()); - $this->assertFalse(isset($record['extra']['unique_id'])); - } - - public function testProcessorAddsOnlyRequestedExtraFields() - { - $server = array( - 'REQUEST_URI' => 'A', - 'REMOTE_ADDR' => 'B', - 'REQUEST_METHOD' => 'C', - 'SERVER_NAME' => 'F', - ); - - $processor = new WebProcessor($server, array('url', 'http_method')); - $record = $processor($this->getRecord()); - - $this->assertSame(array('url' => 'A', 'http_method' => 'C'), $record['extra']); - } - - public function testProcessorConfiguringOfExtraFields() - { - $server = array( - 'REQUEST_URI' => 'A', - 'REMOTE_ADDR' => 'B', - 'REQUEST_METHOD' => 'C', - 'SERVER_NAME' => 'F', - ); - - $processor = new WebProcessor($server, array('url' => 'REMOTE_ADDR')); - $record = $processor($this->getRecord()); - - $this->assertSame(array('url' => 'B'), $record['extra']); - } - - /** - * @expectedException UnexpectedValueException - */ - public function testInvalidData() - { - new WebProcessor(new \stdClass); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php b/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php deleted file mode 100644 index ab8994496..000000000 --- a/vendor/monolog/monolog/tests/Monolog/PsrLogCompatTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog; - -use Monolog\Handler\TestHandler; -use Monolog\Formatter\LineFormatter; -use Monolog\Processor\PsrLogMessageProcessor; -use Psr\Log\Test\LoggerInterfaceTest; - -class PsrLogCompatTest extends LoggerInterfaceTest -{ - private $handler; - - public function getLogger() - { - $logger = new Logger('foo'); - $logger->pushHandler($handler = new TestHandler); - $logger->pushProcessor(new PsrLogMessageProcessor); - $handler->setFormatter(new LineFormatter('%level_name% %message%')); - - $this->handler = $handler; - - return $logger; - } - - public function getLogs() - { - $convert = function ($record) { - $lower = function ($match) { - return strtolower($match[0]); - }; - - return preg_replace_callback('{^[A-Z]+}', $lower, $record['formatted']); - }; - - return array_map($convert, $this->handler->getRecords()); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/RegistryTest.php b/vendor/monolog/monolog/tests/Monolog/RegistryTest.php deleted file mode 100644 index 15fdfbd2e..000000000 --- a/vendor/monolog/monolog/tests/Monolog/RegistryTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog; - -class RegistryTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - Registry::clear(); - } - - /** - * @dataProvider hasLoggerProvider - * @covers Monolog\Registry::hasLogger - */ - public function testHasLogger(array $loggersToAdd, array $loggersToCheck, array $expectedResult) - { - foreach ($loggersToAdd as $loggerToAdd) { - Registry::addLogger($loggerToAdd); - } - foreach ($loggersToCheck as $index => $loggerToCheck) { - $this->assertSame($expectedResult[$index], Registry::hasLogger($loggerToCheck)); - } - } - - public function hasLoggerProvider() - { - $logger1 = new Logger('test1'); - $logger2 = new Logger('test2'); - $logger3 = new Logger('test3'); - - return array( - // only instances - array( - array($logger1), - array($logger1, $logger2), - array(true, false), - ), - // only names - array( - array($logger1), - array('test1', 'test2'), - array(true, false), - ), - // mixed case - array( - array($logger1, $logger2), - array('test1', $logger2, 'test3', $logger3), - array(true, true, false, false), - ), - ); - } - - /** - * @covers Monolog\Registry::clear - */ - public function testClearClears() - { - Registry::addLogger(new Logger('test1'), 'log'); - Registry::clear(); - - $this->setExpectedException('\InvalidArgumentException'); - Registry::getInstance('log'); - } - - /** - * @dataProvider removedLoggerProvider - * @covers Monolog\Registry::addLogger - * @covers Monolog\Registry::removeLogger - */ - public function testRemovesLogger($loggerToAdd, $remove) - { - Registry::addLogger($loggerToAdd); - Registry::removeLogger($remove); - - $this->setExpectedException('\InvalidArgumentException'); - Registry::getInstance($loggerToAdd->getName()); - } - - public function removedLoggerProvider() - { - $logger1 = new Logger('test1'); - - return array( - array($logger1, $logger1), - array($logger1, 'test1'), - ); - } - - /** - * @covers Monolog\Registry::addLogger - * @covers Monolog\Registry::getInstance - * @covers Monolog\Registry::__callStatic - */ - public function testGetsSameLogger() - { - $logger1 = new Logger('test1'); - $logger2 = new Logger('test2'); - - Registry::addLogger($logger1, 'test1'); - Registry::addLogger($logger2); - - $this->assertSame($logger1, Registry::getInstance('test1')); - $this->assertSame($logger2, Registry::test2()); - } - - /** - * @expectedException \InvalidArgumentException - * @covers Monolog\Registry::getInstance - */ - public function testFailsOnNonExistantLogger() - { - Registry::getInstance('test1'); - } - - /** - * @covers Monolog\Registry::addLogger - */ - public function testReplacesLogger() - { - $log1 = new Logger('test1'); - $log2 = new Logger('test2'); - - Registry::addLogger($log1, 'log'); - - Registry::addLogger($log2, 'log', true); - - $this->assertSame($log2, Registry::getInstance('log')); - } - - /** - * @expectedException \InvalidArgumentException - * @covers Monolog\Registry::addLogger - */ - public function testFailsOnUnspecifiedReplacement() - { - $log1 = new Logger('test1'); - $log2 = new Logger('test2'); - - Registry::addLogger($log1, 'log'); - - Registry::addLogger($log2, 'log'); - } -} diff --git a/vendor/monolog/monolog/tests/Monolog/TestCase.php b/vendor/monolog/monolog/tests/Monolog/TestCase.php deleted file mode 100644 index 4eb7b4c9e..000000000 --- a/vendor/monolog/monolog/tests/Monolog/TestCase.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Monolog; - -class TestCase extends \PHPUnit_Framework_TestCase -{ - /** - * @return array Record - */ - protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array()) - { - return array( - 'message' => $message, - 'context' => $context, - 'level' => $level, - 'level_name' => Logger::getLevelName($level), - 'channel' => 'test', - 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))), - 'extra' => array(), - ); - } - - /** - * @return array - */ - protected function getMultipleRecords() - { - return array( - $this->getRecord(Logger::DEBUG, 'debug message 1'), - $this->getRecord(Logger::DEBUG, 'debug message 2'), - $this->getRecord(Logger::INFO, 'information'), - $this->getRecord(Logger::WARNING, 'warning'), - $this->getRecord(Logger::ERROR, 'error'), - ); - } - - /** - * @return Monolog\Formatter\FormatterInterface - */ - protected function getIdentityFormatter() - { - $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface'); - $formatter->expects($this->any()) - ->method('format') - ->will($this->returnCallback(function ($record) { return $record['message']; })); - - return $formatter; - } -} diff --git a/vendor/org_heigl/daterange/.gitignore b/vendor/org_heigl/daterange/.gitignore deleted file mode 100644 index 22e8c7bda..000000000 --- a/vendor/org_heigl/daterange/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -build -vendor -phpunit.xml \ No newline at end of file diff --git a/vendor/org_heigl/daterange/.travis.after.sh b/vendor/org_heigl/daterange/.travis.after.sh deleted file mode 100755 index edf649137..000000000 --- a/vendor/org_heigl/daterange/.travis.after.sh +++ /dev/null @@ -1,6 +0,0 @@ -set -x -if [ "$TRAVIS_PHP_VERSION" = '5.6' ] ; then - ./vendor/bin/test-reporter --stdout > codeclimate.json - curl -X POST -d @codeclimate.json -H "Content-Type: application/json" -H "User-Agent: Code Climate (PHP Test Reporter v1.0.1-dev)" https://codeclimate.com/test_reports - php vendor/bin/coveralls -fi diff --git a/vendor/org_heigl/daterange/.travis.install.sh b/vendor/org_heigl/daterange/.travis.install.sh deleted file mode 100755 index 373c5efcb..000000000 --- a/vendor/org_heigl/daterange/.travis.install.sh +++ /dev/null @@ -1,11 +0,0 @@ -set -x -if [ "$TRAVIS_PHP_VERSION" = 'hhvm' ] || [ "$TRAVIS_PHP_VERSION" = 'hhvm-nightly' ] ; then - curl -sS https://getcomposer.org/installer > composer-installer.php - hhvm composer-installer.php - hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 composer.phar update --prefer-source - hhvm -v ResourceLimit.SocketDefaultTimeout=30 -v Http.SlowQueryThreshold=30000 composer.phar install --dev --prefer-source -else - composer self-update - composer update --prefer-source - composer install --dev --prefer-source -fi diff --git a/vendor/org_heigl/daterange/.travis.yml b/vendor/org_heigl/daterange/.travis.yml deleted file mode 100644 index 027e8a2da..000000000 --- a/vendor/org_heigl/daterange/.travis.yml +++ /dev/null @@ -1,30 +0,0 @@ -# Travic-CI-Config file for \Org\Heigl\Hyphenator -# -language: php -php: - - 5.5 - - 5.6 - - 7.0 - - hhvm - - hhvm-nightly - -before_script: - - ./.travis.install.sh - -script: - - ./vendor/bin/phpcs --standard=PSR2 src/ tests/ - - ./vendor/bin/phpunit --configuration=phpunit.travis.xml - -addons: - code_climate: - repo_token: - secure: "cj3x8KfcI9lh4dhQatojQIdZP5cOk2sJBwp3ngmOvdo3TMsrNtJPm426ZHdP/HunOrp3hP2BK6of7gBsXdJSfhRosuViwL1w744BZGAIwt6uOcuvQaJ93iv9yqiNMW43Fk+m2iR7UB/FFTm58W8N8tmAisibO+bhsZxDNyc5Ii8=" - -matrix: - fast_finish : true - allow_failures: - - php: 7.0 - - php: hhvm-nightly - -after_script: - - ./.travis.after.sh \ No newline at end of file diff --git a/vendor/org_heigl/daterange/LICENSE b/vendor/org_heigl/daterange/LICENSE deleted file mode 100644 index f1c9dd69a..000000000 --- a/vendor/org_heigl/daterange/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2015 Andreas Heigl - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. - diff --git a/vendor/org_heigl/daterange/README.md b/vendor/org_heigl/daterange/README.md deleted file mode 100644 index 31e168969..000000000 --- a/vendor/org_heigl/daterange/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# org.heigl.DateRange - -This small library tries to ease printing of date-ranges. - -[![Build Status](https://travis-ci.org/heiglandreas/org.heigl.daterange.svg?branch=master)](https://travis-ci.org/heiglandreas/org.heigl.daterange) -[![Code Climate](https://codeclimate.com/github/heiglandreas/org.heigl.daterange/badges/gpa.svg)](https://codeclimate.com/github/heiglandreas/org.heigl.daterange) -[![Test Coverage](https://codeclimate.com/github/heiglandreas/org.heigl.daterange/badges/coverage.svg)](https://codeclimate.com/github/heiglandreas/org.heigl.daterange) -[![Coverage Status](https://coveralls.io/repos/heiglandreas/org.heigl.daterange/badge.svg?branch=master)](https://coveralls.io/r/heiglandreas/org.heigl.daterange?branch=master) - -## Installation - -Installation is easy via composer. Simply type this in your terminal to add the -DateRange-Library to your ```composer.conf```-file: - - composer require org_heigl/daterange - - -## Usage - -You can then use the DateRange library by creating a DateRange-instance, -setting a format and a separator and then simply calling ```getDateRange()``` -with the start-date and the end date as parameters. - -Simple example: - -```php -setFormat('d.m.Y'); -$dateRange->setSeparator(' - '); -echo $dateRange->getDateRange(new \DateTime('12.3.2015'), new \DateTime('13.4.2015')); -// Will print: 12.03. - 13.04.2014 -echo $dateRange->getDateRange(new \DateTime('12.3.2015'), new \DateTime('13.3.2015')); -// Will print: 12. - 13.03.2014 -``` - -More complex example: - -```php -setFormat('m/d/Y'); -$dateRange->setSeparator(' - '); -echo $dateRange->getDateRange(new \DateTime('12.3.2015'), new \DateTime('13.3.2015')); -// Will print: 3/12/ - 3/13/2014 -``` diff --git a/vendor/org_heigl/daterange/composer.json b/vendor/org_heigl/daterange/composer.json deleted file mode 100644 index 229f5828f..000000000 --- a/vendor/org_heigl/daterange/composer.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name" : "org_heigl/daterange", - "type" : "library", - "description": "Provides a way to display dateranges", - "keywords": ["daterange","date", "datetime", "range"], - "homepage": "http://github.com/heiglandreas/daterange", - "license": "MIT", - "authors": [{ - "name": "Andreas Heigl", - "email": "andreas@heigl.org", - "homepage": "http://andreas.heigl.org", - "role": "Developer" - }], - "require" : { - "php" : ">=5.5" - }, - "minimum-stability": "dev", - "require-dev" : { - "codeclimate/php-test-reporter": "dev-master", - "squizlabs/php_codesniffer": "~2.0@dev", - "mockery/mockery": "~0.9", - "phpunit/phpunit": "~4.7@dev" - }, - "autoload" : { - "psr-4" : { - "Org_Heigl\\DateRange\\" : "src/", - "Org_Heigl\\DateRangeTest\\" : "tests/" - } - } -} diff --git a/vendor/org_heigl/daterange/phpunit.travis.xml b/vendor/org_heigl/daterange/phpunit.travis.xml deleted file mode 100644 index fb6cca3b1..000000000 --- a/vendor/org_heigl/daterange/phpunit.travis.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - tests - - - - - disable - - - - - - - - src - - - - - - - - - diff --git a/vendor/org_heigl/daterange/phpunit.xml.dist b/vendor/org_heigl/daterange/phpunit.xml.dist deleted file mode 100644 index 348a0d38f..000000000 --- a/vendor/org_heigl/daterange/phpunit.xml.dist +++ /dev/null @@ -1,39 +0,0 @@ - - - - tests - - - - - disable - - - - - - - - src - - - - - - - - - - - - - - - - - - diff --git a/vendor/org_heigl/daterange/src/DateRangeFormatter.php b/vendor/org_heigl/daterange/src/DateRangeFormatter.php deleted file mode 100644 index 57eeb1732..000000000 --- a/vendor/org_heigl/daterange/src/DateRangeFormatter.php +++ /dev/null @@ -1,175 +0,0 @@ - - * @copyright ©2015-2015 Andreas Heigl - * @license http://www.opesource.org/licenses/mit-license.php MIT-License - * @version 0.0 - * @since 22.02.15 - * @link https://github.com/heiglandreas/ - */ - -namespace Org_Heigl\DateRange; - -use DateInterval; -use DateTimeInterface; - -class DateRangeFormatter -{ - const YEAR = 0; - const MONTH = 1; - const WEEK = 2; - const DAY = 3; - - private $checks = array( - 'd' => self::DAY, - 'D' => self::DAY, - 'j' => self::DAY, - 'l' => self::DAY, - 'N' => self::DAY, - 'S' => self::DAY, - 'w' => self::DAY, - 'z' => self::DAY, - 'W' => self::WEEK, - 'F' => self::MONTH, - 'm' => self::MONTH, - 'M' => self::MONTH, - 'n' => self::MONTH, - 'o' => self::YEAR, - 'Y' => self::YEAR, - 'y' => self::YEAR, - ); - - protected $format = 'd. m. Y'; - - private $testableParts = array( - self::DAY, self::MONTH, self::YEAR - ); - - protected $combine = ' - '; - - /** - * Set the output-format - * - * This can be a formating string as for the date()-function. - * - * @param string $format - * - * @return self - */ - public function setFormat($format) - { - $this->format = $format; - - $this->setTestableParts(); - - return $this; - } - - /** - * Set the separator - * - * @param string $separator - * - * @return self - */ - public function setSeparator($separator) - { - $this->combine = $separator; - - return $this; - } - - public function setTestableParts() - { - $this->testableParts = array(); - - foreach ($this->checks as $key => $value) { - if (in_array($value, $this->testableParts)) { - continue; - } - - if (preg_match('/(?format)) { - $this->testableParts[] = $value; - } - } - } - - protected function getDiffPoint(DateTimeInterface $start, DateTimeInterface $end) - { - $tester = array( - self::YEAR => 'Y', - self::MONTH => 'n', - self::WEEK => 'W', - self::DAY => 'j', - ); - foreach ($tester as $part => $test) { - if (! in_array($test, $this->testableParts)) { - continue; - } - - if ($start->format($test) != $end->format($test)) { - return $part; - } - } - - return null; - } - - protected function splitFormat($diffPoint) - { - $broke = $stable = array(); - foreach ($this->checks as $check => $mate) { - if ($mate >= $diffPoint) { - $broke[] = $check; - } else { - $stable[] = $check; - } - } - if (! $stable) { - return array($this->format, ''); - } - $regEx = '/(?format, $matches, PREG_OFFSET_CAPTURE)) { - return array($this->format, ''); - } - - $offset = $matches[0][1]; - - return array(substr($this->format, 0, $offset), substr($this->format, $offset)); - } - - public function getDateRange(DateTimeInterface $start, DateTimeInterface $end) - { - $arrays = $this->splitFormat($this->getDiffPoint($start, $end)); - if (! $arrays[1]) { - return $start->format($arrays[0]); - } - $string = ''; - $string .= $start->format($arrays[0]); - $string .= $this->combine; - $string .= $end->format($arrays[0]); - $string .= $end->format($arrays[1]); - - return $string; - } -} diff --git a/vendor/org_heigl/daterange/tests/DateRangeFormatterTest.php b/vendor/org_heigl/daterange/tests/DateRangeFormatterTest.php deleted file mode 100644 index 2d875a845..000000000 --- a/vendor/org_heigl/daterange/tests/DateRangeFormatterTest.php +++ /dev/null @@ -1,184 +0,0 @@ - - * @copyright ©2015-2015 Andreas Heigl - * @license http://www.opesource.org/licenses/mit-license.php MIT-License - * @version 0.0 - * @since 22.02.15 - * @link https://github.com/heiglandreas/ - */ - -namespace Org_Heigl\DateRangeTest; - -use Org_Heigl\DateRange\DateRangeFormatter; -use Org_Heigl\UnitTestHelper; - -class DateRangeFormatterTest extends \PHPUnit_Framework_TestCase -{ - - /** - * @param $start - * @param $end - * @param $interval - * @dataProvider dateIntervalProvider - */ - public function testSettingTestableParts($format, $expected) - { - $formatter = new DateRangeFormatter(); - $formatter->setFormat($format); - - $sweetsThief = function (DateRangeFormatter $formatter) { - return $formatter->testableParts; - }; - - $sweetsThief = \Closure::bind($sweetsThief, null, $formatter); - - $this->assertEquals($expected, $sweetsThief($formatter)); - - } - - public function dateIntervalProvider() - { - return array( - array('d.m.Y', array(3,1,0)), - array('\d.m.\Y', array(1)), - array('qWertz', array(3,2)), - ); - } - - /** - * @param $format - * @param $start - * @param $end - * @param $expected - * @dataProvider gettingDiffPointProvider - */ - public function testGettingDiffPoint($format, $start, $end, $expected) - { - $formatter = new DateRangeFormatter(); - $formatter->setFormat($format); - - $method = UnitTestHelper::getMethod($formatter, 'getDiffPoint'); - $diffPoint = $method->invoke($formatter, new \DateTime($start), new \DateTime($end)); - - $this->assertEquals($expected, $diffPoint); - } - - public function gettingDiffPointProvider() - { - return array( - array('d.m.Y', '12.3.2014', '13.3.2014', DateRangeFormatter::DAY), - array('d.m.Y', '12.3.2014', '13.4.2014', DateRangeFormatter::MONTH), - array('d.m.Y', '12.3.2014', '13.3.2015', DateRangeFormatter::YEAR), - ); - } - - public function testGettingDiffPointWithoutDiff() - { - $formatter = new DateRangeFormatter(); - $formatter->setFormat('d.m.Y'); - - $method = UnitTestHelper::getMethod($formatter, 'getDiffPoint'); - $diffPoint = $method->invoke($formatter, new \DateTime('12.2.2014'), new \DateTime('12.2.2014')); - - $this->assertEquals(null, $diffPoint); - - $formatter->setFormat('H:i:s'); - $diffPoint = $method->invoke($formatter, new \DateTime('12.2.2014'), new \DateTime('12.2.2014')); - $this->assertEquals(null, $diffPoint); - - - } - - /** - * @param $format - * @param $diffPoint - * @param $expected - * @dataProvider splittingFormatProvider - * - */ - public function testSplittingFormat($format, $diffPoint, $expected) - { - $formatter = new DateRangeFormatter(); - $formatter->setFormat($format); - - $method = UnitTestHelper::getMethod($formatter, 'splitFormat'); - $splitFormat = $method->invoke($formatter, $diffPoint); - - $this->assertEquals($expected, $splitFormat); - } - - public function splittingFormatProvider() - { - return array( - array('d.m.Y', DateRangeFormatter::DAY, array('d.','m.Y')), - array('d.m.Y', DateRangeFormatter::MONTH, array('d.m.','Y')), - array('d.m.Y', DateRangeFormatter::YEAR, array('d.m.Y','')), - array('m/d/Y', DateRangeFormatter::DAY, array('m/d/','Y')), - ); - } - - public function testSplittingWrongFormat() - { - $formatter = new DateRangeFormatter(); - $formatter->setFormat('H:i:s'); - - $method = UnitTestHelper::getMethod($formatter, 'splitFormat'); - $splitFormat = $method->invoke($formatter, DateRangeFormatter::DAY); - - $this->assertEquals(array('H:i:s', ''), $splitFormat); - - } - - /** - * @param $format - * @param $start - * @param $end - * @param $result - * @dataProvider gettingDateDiffProvider - */ - public function testGettingDateDiff($format, $start, $end, $result) - { - $formatter = new DateRangeFormatter(); - $formatter->setFormat($format); - - $this->assertEquals($result, $formatter->getDateRange(new \DateTime($start), new \DateTime($end))); - } - - public function gettingDateDiffProvider() - { - return array( - array('d.m.Y', '12.2.2014', '13.2.2014', '12. - 13.02.2014'), - array('m/d/Y', '12.2.2014', '13.2.2014', '02/12/ - 02/13/2014'), - array('d.m.Y', '12.2.2014', '12.2.2014', '12.02.2014'), - ); - } - - public function testSettingSeparator() - { - $formatter = new DateRangeFormatter(); - $this->assertAttributeEquals(' - ', 'combine', $formatter); - $this->assertSame($formatter, $formatter->setSeparator(' until ')); - $this->assertAttributeEquals(' until ', 'combine', $formatter); - } -} diff --git a/vendor/org_heigl/daterange/tests/UnitTestHelper.php b/vendor/org_heigl/daterange/tests/UnitTestHelper.php deleted file mode 100644 index 1a8d860e1..000000000 --- a/vendor/org_heigl/daterange/tests/UnitTestHelper.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @copyright ©2015-2015 Andreas Heigl - * @license http://www.opesource.org/licenses/mit-license.php MIT-License - * @version 0.0 - * @since 02.03.15 - * @link https://github.com/heiglandreas/ - */ - -namespace Org_Heigl; - -class UnitTestHelper -{ - /** - * Access protected or private methods - * - * use the following code to access any protected or private class method - * $obj = new MyClass(); - * $method = UnitTestHelper::getMethod($obj, 'nameOfMethod'); - * $result = $method->invoke('your',method,array('arguments')); - * - * @param Object|string $obj - * @param string $name - * - * @return method - */ - public static function getMethod($obj, $name) - { - $class = new \ReflectionClass($obj); - $method = $class->getMethod($name); - $method->setAccessible(true); - return $method; - } -} diff --git a/vendor/org_heigl/daterange/tests/bootstrap.php b/vendor/org_heigl/daterange/tests/bootstrap.php deleted file mode 100644 index 18ef2ee90..000000000 --- a/vendor/org_heigl/daterange/tests/bootstrap.php +++ /dev/null @@ -1,42 +0,0 @@ - - * @copyright ©2013-2013 Andreas Heigl - * @license http://www.opesource.org/licenses/mit-license.php MIT-License - * @version 0.0 - * @since 02.04.13 - * @link https://github.com/heiglandreas/ - */ - -ini_set('date.timezone', 'Europe/Berlin'); -ini_set('memory_limit', '512M'); - -// Ensure library/ is on include_path -set_include_path(implode(PATH_SEPARATOR, array( - realpath(__DIR__ . '/../lib'), - get_include_path(), -))); - -mb_internal_encoding('UTF-8'); -require_once 'vendor/autoload.php'; -require_once __DIR__ . '/UnitTestHelper.php'; diff --git a/vendor/predis/predis/.gitignore b/vendor/predis/predis/.gitignore deleted file mode 100644 index dacaf3ad2..000000000 --- a/vendor/predis/predis/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*.tgz -*.phar -phpunit.xml -package.xml -composer.lock -experiments/ -vendor/ diff --git a/vendor/predis/predis/.travis.yml b/vendor/predis/predis/.travis.yml deleted file mode 100644 index 0842b04d3..000000000 --- a/vendor/predis/predis/.travis.yml +++ /dev/null @@ -1,13 +0,0 @@ -language: php -php: - - 5.3 - - 5.4 - - 5.5 -branches: - except: - - v0.5 - - v0.6 - - php5.2_backport - - documentation -services: redis-server -script: phpunit -c phpunit.xml.travisci diff --git a/vendor/predis/predis/CHANGELOG.NAMING.md b/vendor/predis/predis/CHANGELOG.NAMING.md deleted file mode 100644 index 2edcaa2c9..000000000 --- a/vendor/predis/predis/CHANGELOG.NAMING.md +++ /dev/null @@ -1,53 +0,0 @@ -# Namespaces, interfaces and classes renamed in Predis v0.8 # -____________________________________________ - -Some namespaces, interfaces and classes in Predis v0.8 have been renamed to follow a common rule inspired -by the naming conventions adopted by the Symfony2 project. This is a list of all the changes: - -### Renamed namespaces ### - - - `Predis\Network` => `Predis\Connection` - - `Predis\Profiles` => `Predis\Profile` - - `Predis\Iterators` => `Predis\Iterator` - - `Predis\Options` => `Predis\Option` - - `Predis\Commands` => `Predis\Command` - - `Predis\Commands\Processors` => `Predis\Command\Processor` - -### Renamed interfaces ### - - - `Predis\IReplyObject` => `Predis\ResponseObjectInterface` - - `Predis\IRedisServerError` => `Predis\ResponseErrorInterface` - - `Predis\Options\IOption` => `Predis\Option\OptionInterface` - - `Predis\Options\IClientOptions` => `Predis\Option\ClientOptionsInterface` - - `Predis\Profile\IServerProfile` => `Predis\Profile\ServerProfileInterface` - - `Predis\Pipeline\IPipelineExecutor` => `Predis\Pipeline\PipelineExecutorInterface` - - `Predis\Distribution\INodeKeyGenerator` => `Predis\Distribution\HashGeneratorInterface` - - `Predis\Distribution\IDistributionStrategy` => `Predis\Distribution\DistributionStrategyInterface` - - `Predis\Protocol\IProtocolProcessor` => `Predis\Protocol\ProtocolInterface` - - `Predis\Protocol\IResponseReader` => `Predis\Protocol\ResponseReaderInterface` - - `Predis\Protocol\IResponseHandler` => `Predis\Protocol\ResponseHandlerInterface` - - `Predis\Protocol\ICommandSerializer` => `Predis\Protocol\CommandSerializerInterface` - - `Predis\Protocol\IComposableProtocolProcessor` => `Predis\Protocol\ComposableProtocolInterface` - - `Predis\Network\IConnection` => `Predis\Connection\ConnectionInterface` - - `Predis\Network\IConnectionSingle` => `Predis\Connection\SingleConnectionInterface` - - `Predis\Network\IConnectionComposable` => `Predis\Connection\ComposableConnectionInterface` - - `Predis\Network\IConnectionCluster` => `Predis\Connection\ClusterConnectionInterface` - - `Predis\Network\IConnectionReplication` => `Predis\Connection\ReplicationConnectionInterface` - - `Predis\Commands\ICommand` => `Predis\Command\CommandInterface` - - `Predis\Commands\IPrefixable` => `Predis\Command\PrefixableCommandInterface` - - `Predis\Command\Processor\ICommandProcessor` => `Predis\Command\Processor\CommandProcessorInterface` - - `Predis\Command\Processor\ICommandProcessorChain` => `Predis\Command\Processor\CommandProcessorChainInterface` - - `Predis\Command\Processor\IProcessingSupport` => `Predis\Command\Processor\CommandProcessingInterface` - -### Renamed classes ### - - - `Predis\Commands\Command` => `Predis\Command\AbstractCommand` - - `Predis\Network\ConnectionBase` => `Predis\Connection\AbstractConnection` - -### Classes or interfaces moved to different namespaces ### - - - `Predis\MonitorContext` => `Predis\Monitor\MonitorContext` - - `Predis\ConnectionParameters` => `Predis\Connection\ConnectionParameters` - - `Predis\ConnectionParametersInterface` => `Predis\Connection\ConnectionParametersInterface` - - `Predis\ConnectionFactory` => `Predis\Connection\ConnectionFactory` - - `Predis\ConnectionFactoryInterface` => `Predis\Connection\ConnectionFactoryInterface` diff --git a/vendor/predis/predis/CHANGELOG.md b/vendor/predis/predis/CHANGELOG.md deleted file mode 100644 index 6b161a292..000000000 --- a/vendor/predis/predis/CHANGELOG.md +++ /dev/null @@ -1,620 +0,0 @@ -v0.8.5 (2014-01-16) -================================================================================ - -- Added `2.8` in the server profiles aliases list for Redis 2.8. `2.6` is still - the default server profile and `dev` now targets Redis 3.0. - -- Added `SCAN`, `SSCAN`, `ZSCAN`, `HSCAN` to the server profile for Redis 2.8. - -- Implemented PHP iterators for incremental iterations over Redis collections: - - - keyspace (cursor-based iterator using `SCAN`) - - sets (cursor-based iterator using `SSCAN`) - - sorted sets (cursor-based iterator using `ZSCAN`) - - hashes (cursor-based iterator using `HSCAN`) - - lists (plain iterator using `LRANGE`) - -- It is now possible to execute "raw commands" using `Predis\Command\RawCommand` - and a variable list of command arguments. Input arguments are not filtered and - responses are not parsed, which means arguments must follow the signature of - the command as defined by Redis and complex responses are left untouched. - -- URI parsing for connection parameters has been improved and has slightly less - overhead when the number of fields in the querystring grows. New features are: - - - Parsing does not break when value of a field contains one or more "=". - - Repeated fieldnames using [] produce an array of values. - - Empty or incomplete "key=value" pairs result in an empty string for "key". - -- Various improvements and fixes to the redis-cluster connection backend: - - - __FIX__: the `ASKING` command is sent upon -ASK redirections. - - An updated slots-map can be fetched from nodes using the `CLUSTER NODES` - command. By default this is a manual operation but can be enabled to get - automatically done upon -MOVED redirections. - - It is possible to specify a common set of connection parameters that are - applied to connections created on the fly upon redirections to nodes not - part of the initial pool. - -- List of deprecated methods: - - - `Predis\Client::multiExec()`: superseded by `Predis\Client::transaction()` - and to be removed in the next major release. - - `Predis\Client::pubSub()`: superseded by `Predis\Client::pubSubLoop()` and - to be removed in the next major release. This change was needed due to the - recently introduced `PUBSUB` command in Redis 2.8. - - -v0.8.4 (2013-07-27) -================================================================================ - -- Added `DUMP` and `RESTORE` to the server profile for Redis 2.6. - -- Connection exceptions now report basic host details in their messages. - -- Allow `Predis\Connection\PhpiredisConnection` to use a random IP when a host - actually has several IPs (ISSUE #116). - -- __FIX__: allow `HMSET` when using a cluster of Redis nodes with client-side - sharding or redis-cluster (ISSUE #106). - -- __FIX__: set `WITHSCORES` modifer for `ZRANGE`, `ZREVRANGE`, `ZRANGEBYSCORE` - and `ZREVRANGEBYSCORE` only when the options array passed to these commands - has `WITHSCORES` set to `true` (ISSUE #107). - -- __FIX__: scripted commands falling back from `EVALSHA` to `EVAL` resulted in - PHP errors when using a prefixed client (ISSUE #109). - -- __FIX__: `Predis\PubSub\DispatcherLoop` now works properly when using key - prefixing (ISSUE #114). - - -v0.8.3 (2013-02-18) -================================================================================ - -- Added `CLIENT SETNAME` and `CLIENT GETNAME` (ISSUE #102). - -- Implemented the `Predis\Connection\PhpiredisStreamConnection` class using the - `phpiredis` extension like `Predis\Connection\PhpiredisStreamConnection`, but - without requiring the `socket` extension since it relies on PHP's streams. - -- Added support for the TCP_NODELAY flag via the `tcp_nodelay` parameter for - stream-based connections, namely `Predis\Connection\StreamConnection` and - `Predis\Connection\PhpiredisStreamConnection` (requires PHP >= 5.4.0). - -- Updated the aggregated connection class for redis-cluster to work with 16384 - hash slots instead of 4096 to reflect the recent change from redis unstable - ([see this commit](https://github.com/antirez/redis/commit/ebd666d)). - -- The constructor of `Predis\Client` now accepts a callable as first argument - returning `Predis\Connection\ConnectionInterface`. Users can create their - own self-contained strategies to create and set up the underlying connection. - -- Users should return `0` from `Predis\Command\ScriptedCommand::getKeysCount()` - instead of `FALSE` to indicate that all of the arguments of a Lua script must - be used to populate `ARGV[]`. This does not represent a breaking change. - -- The `Predis\Helpers` class has been deprecated and it will be removed in - future releases. - - -v0.8.2 (2013-02-03) -================================================================================ - -- Added `Predis\Session\SessionHandler` to make it easy to store PHP sessions - on Redis using Predis. Please note that this class needs either PHP >= 5.4.0 - or a polyfill for PHP's `SessionHandlerInterface`. - -- Added the ability to get the default value of a client option directly from - `Predis\Option\ClientOption` using the `getDefault()` method by passing the - option name or its instance. - -- __FIX__: the standard pipeline executor was not using the response parser - methods associated to commands to process raw responses (ISSUE #101). - - -v0.8.1 (2013-01-19) -================================================================================ - -- The `connections` client option can now accept a callable object returning - an instance of `Predis\Connection\ConnectionFactoryInterface`. - -- Client options accepting callable objects as factories now pass their actual - instance to the callable as the second argument. - -- `Predis\Command\Processor\KeyPrefixProcessor` can now be directly casted to - string to obtain the current prefix, useful with string interpolation. - -- Added an optional callable argument to `Predis\Cluster\Distribution\HashRing` - and `Predis\Cluster\Distribution\KetamaPureRing` constructor that can be used - to customize how the distributor should extract the connection hash when - initializing the nodes distribution (ISSUE #36). - -- Correctly handle `TTL` and `PTTL` returning -2 on non existing keys starting - with Redis 2.8. - -- __FIX__: a missing use directive in `Predis\Transaction\MultiExecContext` - caused PHP errors when Redis did not return `+QUEUED` replies to commands - when inside a MULTI / EXEC context. - -- __FIX__: the `parseResponse()` method implemented for a scripted command was - ignored when retrying to execute a Lua script by falling back to `EVAL` after - a `-NOSCRIPT` error (ISSUE #94). - -- __FIX__: when subclassing `Predis\Client` the `getClientFor()` method returns - a new instance of the subclass instead of a new instance of `Predis\Client`. - - -v0.8.0 (2012-10-23) -================================================================================ - -- The default server profile for Redis is now `2.6`. - -- Certain connection parameters have been renamed: - - - `connection_async` is now `async_connect` - - `connection_timeout` is now `timeout` - - `connection_persistent` is now `persistent` - -- The `throw_errors` connection parameter has been removed and replaced by the - new `exceptions` client option since exceptions on `-ERR` replies returned by - Redis are not generated by connection classes anymore but instead are thrown - by the client class and other abstractions such as pipeline contexts. - -- Added smart support for redis-cluster (Redis v3.0) in addition to the usual - cluster implementation that uses client-side sharding. - -- Various namespaces and classes have been renamed to follow rules inspired by - the Symfony2 naming conventions. - -- The second argument of the constructor of `Predis\Client` does not accept - strings or instances of `Predis\Profile\ServerProfileInterface` anymore. - To specify a server profile you must explicitly set `profile` in the array - of client options. - -- `Predis\Command\ScriptedCommand` internally relies on `EVALSHA` instead of - `EVAL` thus avoiding to send Lua scripts bodies on each request. The client - automatically resends the command falling back to `EVAL` when Redis returns a - `-NOSCRIPT` error. Automatic fallback to `EVAL` does not work with pipelines, - inside a `MULTI / EXEC` context or with plain `EVALSHA` commands. - -- Complex responses are no more parsed by connection classes as they must be - processed by consumer classes using the handler associated to the issued - command. This means that executing commands directly on connections only - returns simple Redis types, but nothing changes when using `Predis\Client` - or the provided abstractions for pipelines and transactions. - -- Iterators for multi-bulk replies now skip the response parsing method of the - command that generated the response and are passed directly to user code. - Pipeline and transaction objects still consume automatically iterators. - -- Cluster and replication connections now extend a new common interface, - `Predis\Connection\AggregatedConnectionInterface`. - -- `Predis\Connection\MasterSlaveReplication` now uses an external strategy - class to handle the logic for checking readable / writable commands and Lua - scripts. - -- Command pipelines have been optimized for both speed and code cleanness, but - at the cost of bringing a breaking change in the signature of the interface - for pipeline executors. - -- Added a new pipeline executor that sends commands wrapped in a MULTI / EXEC - context to make the execution atomic: if a pipeline fails at a certain point - then the whole pipeline is discarded. - -- The key-hashing mechanism for commands is now handled externally and is no - more a competence of each command class. This change is neeeded to support - both client-side sharding and Redis cluster. - -- `Predis\Options\Option` is now abstract, see `Predis\Option\AbstractOption`. - - -v0.7.3 (2012-06-01) -================================================================================ - -- New commands available in the Redis v2.6 profile (dev): `BITOP`, `BITCOUNT`. - -- When the number of keys `Predis\Commands\ScriptedCommand` is negative, Predis - will count from the end of the arguments list to calculate the actual number - of keys that will be interpreted as elements for `KEYS` by the underlying - `EVAL` command. - -- __FIX__: `examples\CustomDistributionStrategy.php` had a mistyped constructor - call and produced a bad distribution due to an error as pointed in ISSUE #63. - This bug is limited to the above mentioned example and does not affect the - classes implemented in the `Predis\Distribution` namespace. - -- __FIX__: `Predis\Commands\ServerEvalSHA::getScriptHash()` was calculating the - hash while it just needs to return the first argument of the command. - -- __FIX__: `Predis\Autoloader` has been modified to allow cascading autoloaders - for the `Predis` namespace. - - -v0.7.2 (2012-04-01) -================================================================================ - -- Added `2.6` in the server profiles aliases list for the upcoming Redis 2.6. - `2.4` is still the default server profile. `dev` now targets Redis 2.8. - -- Connection instances can be serialized and unserialized using `serialize()` - and `unserialize()`. This is handy in certain scenarios such as client-side - clustering or replication to lower the overhead of initializing a connection - object with many sub-connections since unserializing them can be up to 5x - times faster. - -- Reworked the default autoloader to make it faster. It is also possible to - prepend it in PHP's autoload stack. - -- __FIX__: fixed parsing of the payload returned by `MONITOR` with Redis 2.6. - - -v0.7.1 (2011-12-27) -================================================================================ - -- The PEAR channel on PearHub has been deprecated in favour of `pear.nrk.io`. - -- Miscellaneous minor fixes. - -- Added transparent support for master / slave replication configurations where - write operations are performed on the master server and read operations are - routed to one of the slaves. Please refer to ISSUE #21 for a bit of history - and more details about replication support in Predis. - -- The `profile` client option now accepts a callable object used to initialize - a new instance of `Predis\Profiles\IServerProfile`. - -- Exposed a method for MULTI / EXEC contexts that adds the ability to execute - instances of Redis commands against transaction objects. - - -v0.7.0 (2011-12-11) -================================================================================ - -- Predis now adheres to the PSR-0 standard which means that there is no more a - single file holding all the classes of the library, but multiple files (one - for each class). You can use any PSR-0 compatible autoloader to load Predis - or just leverage the default one shipped with the library by requiring the - `Predis/Autoloader.php` and call `Predis\Autoloader::register()`. - -- The default server profile for Redis is now 2.4. The `dev` profile supports - all the features of Redis 2.6 (currently unstable) such as Lua scripting. - -- Support for long aliases (method names) for Redis commands has been dropped. - -- Redis 1.0 is no more supported. From now on Predis will use only the unified - protocol to serialize commands. - -- It is possible to prefix keys transparently on a client-level basis with the - new `prefix` client option. - -- An external connection factory is used to initialize new connection instances - and developers can now register their own connection classes using the new - `connections` client option. - -- It is possible to connect locally to Redis using UNIX domain sockets. Just - use `unix:///path/to/redis.sock` or a named array just like in the following - example: `array('scheme' => 'unix', 'path' => '/path/to/redis.sock');`. - -- If the `phpiredis` extension is loaded by PHP, it is now possible to use an - alternative connection class that leverages it to make Predis faster on many - cases, especially when dealing with big multibulk replies, with the the only - downside that persistent connections are not supported. Please refer to the - documentation to see how to activate this class using the new `connections` - client option. - -- Predis is capable to talk with Webdis, albeit with some limitations such as - the lack of pipelining and transactions, just by using the `http` scheme in - in the connection parameters. All is needed is PHP with the `curl` and the - `phpiredis` extensions loaded. - -- Way too many changes in the public API to make a list here, we just tried to - make all the Redis commands compatible with previous releases of v0.6 so that - you do not have to worry if you are simply using Predis as a client. Probably - the only breaking changes that should be mentioned here are: - - - `throw_on_error` has been renamed to `throw_errors` and it is a connection - parameter instead of a client option, along with `iterable_multibulk`. - - - `key_distribution` has been removed from the client options. To customize - the distribution strategy you must provide a callable object to the new - `cluster` client option to configure and then return a new instance of - `Predis\Network\IConnectionCluster`. - - - `Predis\Client::create()` has been removed. Just use the constructor to set - up a new instance of `Predis\Client`. - - - `Predis\Client::pipelineSafe()` was deprecated in Predis v0.6.1 and now has - finally removed. Use `Predis\Client::pipeline(array('safe' => true))`. - - - `Predis\Client::rawCommand()` has been removed due to inconsistencies with - the underlying connection abstractions. You can still get the raw resource - out of a connection with `Predis\Network\IConnectionSingle::getResource()` - so that you can talk directly with Redis. - -- The `Predis\MultiBulkCommand` class has been merged into `Predis\Command` and - thus removed. Serialization of commands is now a competence of connections. - -- The `Predis\IConnection` interface has been splitted into two new interfaces: - `Predis\Network\IConnectionSingle` and `Predis\Network\IConnectionCluster`. - -- The constructor of `Predis\Client` now accepts more type of arguments such as - instances of `Predis\IConnectionParameters` and `Predis\Network\IConnection`. - - -v0.6.6 (2011-04-01) -================================================================================ - -- Switched to Redis 2.2 as the default server profile (there are no changes - that would break compatibility with previous releases). Long command names - are no more supported by default but if you need them you can still require - `Predis_Compatibility.php` to avoid breaking compatibility. - -- Added a `VERSION` constant to `Predis\Client`. - -- Some performance improvements for multibulk replies (parsing them is about - 16% faster than the previous version). A few core classes have been heavily - optimized to reduce overhead when creating new instances. - -- Predis now uses by default a new protocol reader, more lightweight and - faster than the default handler-based one. Users can revert to the old - protocol reader with the `reader` client option set to `composable`. - This client option can also accept custom reader classes implementing the - new `Predis\IResponseReader` interface. - -- Added support for connecting to Redis using UNIX domain sockets (ISSUE #25). - -- The `read_write_timeout` connection parameter can now be set to 0 or false - to disable read and write timeouts on connections. The old behaviour of -1 - is still intact. - -- `ZUNIONSTORE` and `ZINTERSTORE` can accept an array to specify a list of the - source keys to be used to populate the destination key. - -- `MGET`, `SINTER`, `SUNION` and `SDIFF` can accept an array to specify a list - of keys. `SINTERSTORE`, `SUNIONSTORE` and `SDIFFSTORE` can also accept an - array to specify the list of source keys. - -- `SUBSCRIBE` and `PSUBSCRIBE` can accept a list of channels for subscription. - -- __FIX__: some client-side clean-ups for `MULTI/EXEC` were handled incorrectly - in a couple of corner cases (ISSUE #27). - - -v0.6.5 (2011-02-12) -================================================================================ - -- __FIX__: due to an untested internal change introduced in v0.6.4, a wrong - handling of bulk reads of zero-length values was producing protocol - desynchronization errors (ISSUE #20). - - -v0.6.4 (2011-02-12) -================================================================================ - -- Various performance improvements (15% ~ 25%) especially when dealing with - long multibulk replies or when using clustered connections. - -- Added the `on_retry` option to `Predis\MultiExecBlock` that can be used to - specify an external callback (or any callable object) that gets invoked - whenever a transaction is aborted by the server. - -- Added inline (p)subscribtion via options when initializing an instance of - `Predis\PubSubContext`. - - -v0.6.3 (2011-01-01) -================================================================================ - -- New commands available in the Redis v2.2 profile (dev): - - Strings: `SETRANGE`, `GETRANGE`, `SETBIT`, `GETBIT` - - Lists : `BRPOPLPUSH` - -- The abstraction for `MULTI/EXEC` transactions has been dramatically improved - by providing support for check-and-set (CAS) operations when using Redis >= - 2.2. Aborted transactions can also be optionally replayed in automatic up - to a user-defined number of times, after which a `Predis\AbortedMultiExec` - exception is thrown. - - -v0.6.2 (2010-11-28) -================================================================================ - -- Minor internal improvements and clean ups. - -- New commands available in the Redis v2.2 profile (dev): - - Strings: `STRLEN` - - Lists : `LINSERT`, `RPUSHX`, `LPUSHX` - - ZSets : `ZREVRANGEBYSCORE` - - Misc. : `PERSIST` - -- WATCH also accepts a single array parameter with the keys that should be - monitored during a transaction. - -- Improved the behaviour of `Predis\MultiExecBlock` in certain corner cases. - -- Improved parameters checking for the SORT command. - -- __FIX__: the `STORE` parameter for the `SORT` command didn't work correctly - when using `0` as the target key (ISSUE #13). - -- __FIX__: the methods for `UNWATCH` and `DISCARD` do not break anymore method - chaining with `Predis\MultiExecBlock`. - - -v0.6.1 (2010-07-11) -================================================================================ - -- Minor internal improvements and clean ups. - -- New commands available in the Redis v2.2 profile (dev): - - Misc. : `WATCH`, `UNWATCH` - -- Optional modifiers for `ZRANGE`, `ZREVRANGE` and `ZRANGEBYSCORE` queries are - supported using an associative array passed as the last argument of their - respective methods. - -- The `LIMIT` modifier for `ZRANGEBYSCORE` can be specified using either: - - an indexed array: `array($offset, $count)` - - an associative array: `array('offset' => $offset, 'count' => $count)` - -- The method `Predis\Client::__construct()` now accepts also instances of - `Predis\ConnectionParameters`. - -- `Predis\MultiExecBlock` and `Predis\PubSubContext` now throw an exception - when trying to create their instances using a profile that does not - support the required Redis commands or when the client is connected to - a cluster of connections. - -- Various improvements to `Predis\MultiExecBlock`: - - fixes and more consistent behaviour across various usage cases. - - support for `WATCH` and `UNWATCH` when using the current development - profile (Redis v2.2) and aborted transactions. - -- New signature for `Predis\Client::multiExec()` which is now able to accept - an array of options for the underlying instance of `Predis\MultiExecBlock`. - Backwards compatibility with previous releases of Predis is ensured. - -- New signature for `Predis\Client::pipeline()` which is now able to accept - an array of options for the underlying instance of Predis\CommandPipeline. - Backwards compatibility with previous releases of Predis is ensured. - The method `Predis\Client::pipelineSafe()` is to be considered deprecated. - -- __FIX__: The `WEIGHT` modifier for `ZUNIONSTORE` and `ZINTERSTORE` was - handled incorrectly with more than two weights specified. - - -v0.6.0 (2010-05-24) -================================================================================ - -- Switched to the new multi-bulk request protocol for all of the commands - in the Redis 1.2 and Redis 2.0 profiles. Inline and bulk requests are now - deprecated as they will be removed in future releases of Redis. - -- The default server profile is `2.0` (targeting Redis 2.0.x). If you are - using older versions of Redis, it is highly recommended that you specify - which server profile the client should use (e.g. `1.2` when connecting - to instances of Redis 1.2.x). - -- Support for Redis 1.0 is now optional and it is provided by requiring - 'Predis_Compatibility.php' before creating an instance of `Predis\Client`. - -- New commands added to the Redis 2.0 profile since Predis 0.5.1: - - Strings: `SETEX`, `APPEND`, `SUBSTR` - - ZSets : `ZCOUNT`, `ZRANK`, `ZUNIONSTORE`, `ZINTERSTORE`, `ZREMBYRANK`, - `ZREVRANK` - - Hashes : `HSET`, `HSETNX`, `HMSET`, `HINCRBY`, `HGET`, `HMGET`, `HDEL`, - `HEXISTS`, `HLEN`, `HKEYS`, `HVALS`, `HGETALL` - - PubSub : `PUBLISH`, `SUBSCRIBE`, `UNSUBSCRIBE` - - Misc. : `DISCARD`, `CONFIG` - -- Introduced client-level options with the new `Predis\ClientOptions` class. - Options can be passed to the constructor of `Predis\Client` in its second - argument as an array or an instance of `Predis\ClientOptions`. For brevity's - sake and compatibility with older versions, the constructor still accepts - an instance of `Predis\RedisServerProfile` in its second argument. The - currently supported client options are: - - - `profile` [default: `2.0` as of Predis 0.6.0]: specifies which server - profile to use when connecting to Redis. This option accepts an instance - of `Predis\RedisServerProfile` or a string that indicates the version. - - - `key_distribution` [default: `Predis\Distribution\HashRing`]: specifies - which key distribution strategy to use to distribute keys among the - servers that compose a cluster. This option accepts an instance of - `Predis\Distribution\IDistributionStrategy` so that users can implement - their own key distribution strategy. `Predis\Distribution\KetamaPureRing` - is an alternative distribution strategy providing a pure-PHP implementation - of the same algorithm used by libketama. - - - `throw_on_error` [default: `TRUE`]: server errors can optionally be handled - "silently": instead of throwing an exception, the client returns an error - response type. - - - `iterable_multibulk` [EXPERIMENTAL - default: `FALSE`]: in addition to the - classic way of fetching a whole multibulk reply into an array, the client - can now optionally stream a multibulk reply down to the user code by using - PHP iterators. It is just a little bit slower, but it can save a lot of - memory in certain scenarios. - -- New parameters for connections: - - - `alias` [default: not set]: every connection can now be identified by an - alias that is useful to get a specific connections when connected to a - cluster of Redis servers. - - `weight` [default: not set]: allows to balance keys asymmetrically across - multiple servers. This is useful when you have servers with different - amounts of memory to distribute the load of your keys accordingly. - - `connection_async` [default: `FALSE`]: estabilish connections to servers - in a non-blocking way, so that the client is not blocked while the socket - resource performs the actual connection. - - `connection_persistent` [default: `FALSE`]: the underlying socket resource - is left open when a script ends its lifecycle. Persistent connections can - lead to unpredictable or strange behaviours, so they should be used with - extreme care. - -- Introduced the `Predis\Pipeline\IPipelineExecutor` interface. Classes that - implements this interface are used internally by the `Predis\CommandPipeline` - class to change the behaviour of the pipeline when writing/reading commands - from one or multiple servers. Here is the list of the default executors: - - - `Predis\Pipeline\StandardExecutor`: exceptions generated by server errors - might be thrown depending on the options passed to the client (see the - `throw_on_error` client option). Instead, protocol or network errors always - throw exceptions. This is the default executor for single and clustered - connections and shares the same behaviour of Predis 0.5.x. - - `Predis\Pipeline\SafeExecutor`: exceptions generated by server, protocol - or network errors are not thrown but returned in the response array as - instances of `Predis\ResponseError` or `Predis\CommunicationException`. - - `Predis\Pipeline\SafeClusterExecutor`: this executor shares the same - behaviour of `Predis\Pipeline\SafeExecutor` but it is geared towards - clustered connections. - -- Support for PUB/SUB is handled by the new `Predis\PubSubContext` class, which - could also be used to build a callback dispatcher for PUB/SUB scenarios. - -- When connected to a cluster of connections, it is now possible to get a - new `Predis\Client` instance for a single connection of the cluster by - passing its alias/index to the new `Predis\Client::getClientFor()` method. - -- `Predis\CommandPipeline` and `Predis\MultiExecBlock` return their instances - when invokink commands, thus allowing method chaining in pipelines and - multi-exec blocks. - -- `Predis\MultiExecBlock` can handle the new `DISCARD` command. - -- Connections now support float values for the `connection_timeout` parameter - to express timeouts with a microsecond resolution. - -- __FIX__: TCP connections now respect the read/write timeout parameter when - reading the payload of server responses. Previously, `stream_get_contents()` - was being used internally to read data from a connection but it looks like - PHP does not honour the specified timeout for socket streams when inside - this function. - -- __FIX__: The `GET` parameter for the `SORT` command now accepts also multiple - key patterns by passing an array of strings. (ISSUE #1). - -* __FIX__: Replies to the `DEL` command return the number of elements deleted - by the server and not 0 or 1 interpreted as a boolean response. (ISSUE #4). - - -v0.5.1 (2010-01-23) -================================================================================ - -* `RPOPLPUSH` has been changed from bulk command to inline command in Redis - 1.2.1, so `ListPopLastPushHead` now extends `InlineCommand`. The old behavior - is still available via the `ListPopLastPushHeadBulk` class so that you can - override the server profile if you need the old (and uncorrect) behaviour - when connecting to a Redis 1.2.0 instance. - -* Added missing support for `BGREWRITEAOF` for Redis >= 1.2.0. - -* Implemented a factory method for the `RedisServerProfile` class to ease the - creation of new server profile instances based on a version string. - - -v0.5.0 (2010-01-09) -================================================================================ -* First versioned release of Predis diff --git a/vendor/predis/predis/CONTRIBUTING.md b/vendor/predis/predis/CONTRIBUTING.md deleted file mode 100644 index 8da3339d1..000000000 --- a/vendor/predis/predis/CONTRIBUTING.md +++ /dev/null @@ -1,44 +0,0 @@ -## Filing bug reports ## - -Bugs or feature requests can be posted on the [GitHub issues](http://github.com/nrk/predis/issues) -section of the project. - -When reporting bugs, in addition to the obvious description of your issue you __must__ always provide -some essential information about your environment such as: - - 1. version of Predis (check the `VERSION` file or the `Predis\Client::VERSION` constant). - 2. version of Redis (check `redis_version` returned by [`INFO`](http://redis.io/commands/info)). - 3. version of PHP. - 4. name and version of the operating system. - 5. when possible, a small snippet of code that reproduces the issue. - -__Think about it__: we do not have a crystal ball and cannot predict things or peer into the unknown -so please provide as much details as possible to help us isolating issues and fix them. - -__Never__ use GitHub issues to post generic questions about Predis! When you have questions about -how Predis works or how it can be used, please just hop me an email and I will get back to you as -soon as possible. - - -## Contributing code ## - -If you want to work on Predis, it is highly recommended that you first run the test suite in order -to check that everything is OK and report strange behaviours or bugs. When modifying Predis please -make sure that no warnings or notices are emitted by PHP running the interpreter in your development -environment with the `error_reporting` variable set to `E_ALL | E_STRICT`. - -The recommended way to contribute to Predis is to fork the project on GitHub, create topic branches -on your newly created repository to fix bugs or add new features (possibly with tests covering your -modifications) and then open a pull request with a description of the applied changes. Obviously you -can use any other Git hosting provider of your preference. - -We always aim for consistency in our code base so you should follow basic coding rules as defined by -[PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md) -and [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) -and stick with the conventions used in Predis to name classes and interfaces. Indentation should be -done with 4 spaces and code should be wrapped at 100 columns (please try to stay within this limit -even if the above mentioned official coding guidelines set the soft limit to 120 columns). - -Please follow these [commit guidelines](http://git-scm.com/book/ch5-2.html#Commit-Guidelines) when -committing your code to Git and always write a meaningful (not necessarily extended) description of -your changes before opening pull requests. diff --git a/vendor/predis/predis/FAQ.md b/vendor/predis/predis/FAQ.md deleted file mode 100644 index 607a42c9e..000000000 --- a/vendor/predis/predis/FAQ.md +++ /dev/null @@ -1,169 +0,0 @@ -# Some frequently asked questions about Predis # -________________________________________________ - -### What is the point of Predis? ### - -The main point of Predis is about offering a highly customizable and extensible client for Redis, -that can be easily extended by developers while still being reasonabily fast. With Predis you can -swap almost any class with your own custom implementation: you can have custom connection classes, -new distribution strategies for client-side sharding, or handlers to replace or add Redis commands. -All of this can be achieved without messing with the source code of the library and directly in your -own application. Given the fast pace at which Redis is developed and adds new features, this can be -a great asset since it allows developers to add new and still missing features or commands or change -the standard behaviour of the library without the need to break dependencies in production code (at -least to some degree). - -### Does Predis support UNIX domain sockets and persistent connections? ### - -Yes. Obviously persistent connections actually work only when using PHP configured as a persistent -process reused by the web server (see [PHP-FPM](http://php-fpm.org)). - -### Does Predis support transparent (de)serialization of values? ### - -No and it will not ever do that by default. The reason behind this decision is that serialization is -usually something that developers prefer to customize depending on their needs and can not be easily -generalized when using Redis because of the many possible access patterns for your data. This does -not mean that it is impossible to have such a feature since you can leverage the extensibility of -this library to define your own serialization-aware commands. You can find more details about how to -do that [on this issue](http://github.com/nrk/predis/issues/29#issuecomment-1202624). - -### How can I force Predis to connect to Redis before sending any command? ### - -Explicitly connecting to Redis is usually not needed since the client initializes connections lazily -only when they are needed. Admittedly, this behavior can be inconvenient in certain scenarios when -you absolutely need to perform an upfront check to determine if the server is up and running and -eventually catch exceptions on failures. Forcing the client to open the underlying connection can be -done by invoking `Predis\Client::connect()`: - -```php -$client = new Predis\Client(); - -try { - $client->connect(); -} catch (Predis\Connection\ConnectionException $exception) { - // We could not connect to Redis! Your handling code goes here. -} - -$client->info(); -``` - -### How Predis abstracts Redis commands? ### - -The approach used to implement Redis commands is quite simple: by default each command follows the -same signature as defined on the [Redis documentation](http://redis.io/commands) which makes things -pretty easy if you already know how Redis works or you need to look up how to use certain commands. -Alternatively, variadic commands can accept an array for keys or values (depending on the command) -instead of a list of arguments. Commands such as [`RPUSH`](http://redis.io/commands/rpush) and -[`HMSET`](http://redis.io/commands/hmset) are great examples: - -```php -$client->rpush('my:list', 'value1', 'value2', 'value3'); // plain method arguments -$client->rpush('my:list', ['value1', 'value2', 'value3']); // single argument array - -$client->hmset('my:hash', 'field1', 'value1', 'field2', 'value2'); // plain method arguments -$client->hmset('my:hash', ['field1'=>'value1', 'field2'=>'value2']); // single named array -``` - -An exception to this rule is [`SORT`](http://redis.io/commands/sort) for which modifiers are passed -[using a named array](tests/Predis/Command/KeySortTest.php#L54-L75). - - -# Speaking about performances... # -_________________________________________________ - - -### Predis is a pure-PHP implementation: it can not be fast enough! ### - -It really depends, but most of the times the answer is: _yes, it is fast enough_. I will give you a -couple of easy numbers with a simple test that uses a single client and is executed by PHP 5.5.6 -against a local instance of Redis 2.8 that runs under Ubuntu 13.10 on a Intel Q6600: - -``` -21000 SET/sec using 12 bytes for both key and value. -21000 GET/sec while retrieving the very same values. -0.130 seconds to fetch 30000 keys using _KEYS *_. -``` - -How does it compare with [__phpredis__](http://github.com/nicolasff/phpredis), a nice C extension -providing an efficient client for Redis? - -``` -30100 SET/sec using 12 bytes for both key and value -29400 GET/sec while retrieving the very same values -0.035 seconds to fetch 30000 keys using "KEYS *"". -``` - -Wow __phpredis__ seems much faster! Well, we are comparing a C extension with a pure-PHP library so -lower numbers are quite expected but there is a fundamental flaw in them: is this really how you are -going to use Redis in your application? Are you really going to send thousands of commands using a -for-loop on each page request using a single client instance? If so... well I guess you are probably -doing something wrong. Also, if you need to `SET` or `GET` multiple keys you should definitely use -commands such as `MSET` and `MGET`. You can also use pipelining to get more performances when this -technique can be used. - -There is one more thing: we have tested the overhead of Predis by connecting on a localhost instance -of Redis but how these numbers change when we hit the physical network by connecting to remote Redis -instances? - -``` -Using Predis: -3200 SET/sec using 12 bytes for both key and value -3200 GET/sec while retrieving the very same values -0.132 seconds to fetch 30000 keys using "KEYS *". - -Using phpredis: -3500 SET/sec using 12 bytes for both key and value -3500 GET/sec while retrieving the very same values -0.045 seconds to fetch 30000 keys using "KEYS *". -``` - -There you go, you get almost the same average numbers and the reason is simple: network latency is a -real performance killer and you cannot do (almost) anything about that. As a disclaimer, remember -that we are measuring the overhead of client libraries implementations and the effects of network -round-trip times, so we are not really measuring how fast Redis is. Redis shines best with thousands -of concurrent clients doing requests! Also, actual performances should be measured according to how -your application will use Redis. - -### I am convinced, but performances for multi-bulk responses are still worse ### - -Fair enough, but there is an option available if you need even more speed and consists on installing -__[phpiredis](http://github.com/nrk/phpiredis)__ (note the additional _i_ in the name) and let the -client use it. __phpiredis__ is another C extension that wraps __hiredis__ (the official C client -library for Redis) with a thin layer exposing its features to PHP. You can then choose between two -different connection classes: - - - `Predis\Connection\PhpiredisStreamConnection` (using native PHP streams). - - `Predis\Connection\PhpiredisConnection` (requires `ext-socket`). - -You will now get the benefits of a faster protocol serializer and parser just by adding a couple of -lines of code: - -```php -$client = new Predis\Client('tcp://127.0.0.1', array( - 'connections' => array( - 'tcp' => 'Predis\Connection\PhpiredisStreamConnection', - 'unix' => 'Predis\Connection\PhpiredisConnection', - ), -)); -``` - -Dead simple. Nothing changes in the way you use the library in your application. So how fast is it -our basic benchmark script now? There are not much improvements for inline or short bulk responses -like the ones returned by `SET` and `GET`, but the speed for parsing multi-bulk responses is now on -par with phpredis: - -``` -Fatching 30000 keys with _KEYS *_ using Predis paired with phpiredis:: - -0.035 seconds from a local Redis instance -0.047 seconds from a remote Redis instance -``` - -### If I need an extension to get better performances, why not using phpredis? ### - -Good question. Generically speaking if you need absolute uber-speed using Redis on the localhost and -you do not care about abstractions built around some Redis features such as MULTI / EXEC, or if you -do not need any kind of extensibility or guaranteed backwards compatibility with different versions -of Redis (Predis currently supports from 1.2 up to 2.8 and the current development version), then -using __phpredis__ makes absolutely sense. Otherwise, Predis is perfect for the job and by adding -__phpiredis__ you can get a nice speed bump almost for free. diff --git a/vendor/predis/predis/LICENSE b/vendor/predis/predis/LICENSE deleted file mode 100644 index dd35c2351..000000000 --- a/vendor/predis/predis/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2009-2014 Daniele Alessandri - -Permission is hereby granted, free of charge, to any person -obtaining a copy of this software and associated documentation -files (the "Software"), to deal in the Software without -restriction, including without limitation the rights to use, -copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following -conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/predis/predis/README.md b/vendor/predis/predis/README.md deleted file mode 100644 index f502aa094..000000000 --- a/vendor/predis/predis/README.md +++ /dev/null @@ -1,325 +0,0 @@ -# Predis # - -[![Latest Stable Version](https://poser.pugx.org/predis/predis/v/stable.png)](https://packagist.org/packages/predis/predis) -[![Total Downloads](https://poser.pugx.org/predis/predis/downloads.png)](https://packagist.org/packages/predis/predis) - -Predis is a flexible and feature-complete [Redis](http://redis.io) client library for PHP >= 5.3. - -By default Predis does not require any additional C extension, but it can be optionally paired with -[phpiredis](https://github.com/nrk/phpiredis) to lower the overhead of serializing and parsing the -Redis protocol. An asynchronous implementation of the client, albeit experimental, is also available -through [Predis\Async](https://github.com/nrk/predis-async). - -More details about the project can be found in our [frequently asked questions](FAQ.md) section or -on the online [wiki](https://github.com/nrk/predis/wiki). - - -## Main features ## - -- Wide range of Redis versions supported (from __1.2__ to __2.8__ and unstable) using profiles. -- Clustering via client-side sharding using consistent hashing or custom distributors. -- Smart support for [redis-cluster](http://redis.io/topics/cluster-spec) (Redis >= 3.0). -- Support for master-slave replication configurations (write on master, read from slaves). -- Transparent key prefixing for all Redis commands. -- Command pipelining (works on both single and aggregate connections). -- Abstraction for Redis transactions (Redis >= 2.0) supporting CAS operations (Redis >= 2.2). -- Abstraction for Lua scripting (Redis >= 2.6) with automatic switching between `EVALSHA` or `EVAL`. -- Abstraction for `SCAN`, `SSCAN`, `ZSCAN` and `HSCAN` (Redis >= 2.8) based on PHP iterators. -- Connections to Redis are established lazily by the client upon the first command. -- Support for both TCP/IP and UNIX domain sockets and persistent connections. -- Support for [Webdis](http://webd.is) (both `ext-curl` and `ext-phpiredis` are needed). -- Support for custom connection classes for providing different network or protocol backends. -- Flexible system for defining and registering custom sets of supported commands or profiles. - - -## How to use Predis ## - -Predis is available on [Packagist](http://packagist.org/packages/predis/predis) which allows a quick -installation using [Composer](http://packagist.org/about-composer). Alternatively, the library can -be found on our [own PEAR channel](http://pear.nrk.io) for a more traditional installation via PEAR. -Ultimately, archives of each release are [available on GitHub](https://github.com/nrk/predis/tags). - - -### Loading the library ### - -Predis relies on the autoloading features of PHP to load its files when needed and complies with the -[PSR-0 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-0.md) which makes -it compatible with most PHP frameworks. Autoloading is handled automatically when dependencies are -managed using Composer, but you can also leverage its own autoloader if you are going to use it in a -project or script without any PSR-0 compliant autoloading facility: - -```php -// Prepend a base path if Predis is not available in your "include_path". -require 'Predis/Autoloader.php'; - -Predis\Autoloader::register(); -``` - -It is possible to easily create a [phar](http://www.php.net/manual/en/intro.phar.php) archive from -the repository just by launching `bin/create-phar`. The generated phar contains a stub defining an -autoloader function for Predis, so you just need to require the phar to start using the library. -Alternatively, it is also possible to generate one single PHP file that holds every class like older -versions of Predis by launching `bin/create-single-file`, but this practice __is not__ encouraged. - - -### Connecting to Redis ### - -When not specifying any connection parameter to create a new client, Predis assumes `127.0.0.1` and -`6379` as the default host and port and uses a connection timeout of 5 seconds: - -```php -$client = new Predis\Client(); -$client->set('foo', 'bar'); -$value = $client->get('foo'); -``` - -Connection parameters can be supplied either in the form of URI strings or named arrays. While the -latter is the preferred way to supply parameters, URI strings can be useful for quick configurations -or when parameters are read from a non-structured source: - -```php -// Named array of connection parameters: -$client = new Predis\Client([ - 'scheme' => 'tcp', - 'host' => '10.0.0.1', - 'port' => 6379, -]); - -// Same set of parameters, but using an URI string: -$client = new Predis\Client('tcp://10.0.0.1:6379'); -``` - -When an array of connections parameters is provided, Predis automatically works in clustering mode -using client-side sharding. Both named arrays and URI strings can be mixed for providing each node -configuration: - -```php -$client = new Predis\Client([ - 'tcp://10.0.0.1?alias=first-node', - ['host' => '10.0.0.2', 'alias' => 'second-node'], -]); -``` - -The actual list of supported connection parameters can vary depending on each connection backend so -it is recommended to refer to their specific documentation for details. - - -### Client configuration ### - -Various aspects of the client can be easily configured by passing options to the second argument of -`Predis\Client::__construct()`. Options are managed using a mini DI-alike container and their values -are usually lazily initialized only when needed. Predis by default supports the following options: - - - `profile`: which profile to use in order to match a specific version of Redis. - - `prefix`: a prefix string that is automatically applied to keys found in commands. - - `exceptions`: whether the client should throw or return responses upon Redis errors. - - `connections`: connection backends or a connection factory to be used by the client. - - `cluster`: which backend to use for clustering (predis, redis or custom configuration). - - `replication`: which backend to use for replication (predis or custom configuration). - -Users can provide custom option values, they are stored in the options container and can be accessed -later through the library. - - -### Aggregate connections ### - -Predis is able to aggregate multiple connections which is the base for clustering and replication. -By default the client implements clustering using either client-side sharding (default) or a Redis -backed solution using [redis-cluster](http://redis.io/topics/cluster-tutorial). As for replication, -Predis can handle single-master and multiple-slaves setups by executing read operations on slaves -and switching to the master for write operations. The replication behaviour is fully configurable. - - -### Command pipelines ### - -Pipelining can help with performances when many commands need to be sent to a server by reducing the -latency introduced by network round-trip timings. Pipelining also works with aggregate connections. -The client can execute the pipeline inside a callable block or return a pipeline instance with the -ability to chain commands thanks to its fluent interface: - -```php -// Executes a pipeline inside a given callable block: -$responses = $client->pipeline(function ($pipe) { - for ($i = 0; $i < 1000; $i++) { - $pipe->set("key:$i", str_pad($i, 4, '0', 0)); - $pipe->get("key:$i"); - } -}); - -// Returns a pipeline instance with fluent interface: -$responses = $client->pipeline()->set('foo', 'bar')->get('foo')->execute(); -``` - - -### Transactions ### - -The client provides an abstraction for Redis transactions based on `MULTI` and `EXEC` with a similar -interface to command pipelines: - -```php -// Executes a transaction inside a given callable block: -$responses = $client->transaction(function ($tx) { - $tx->set('foo', 'bar'); - $tx->get('foo'); -}); - -// Returns a transaction instance with fluent interface: -$responses = $client->transaction()->set('foo', 'bar')->get('foo')->execute(); -``` - -This abstraction can perform check-and-set operations thanks to `WATCH` and `UNWATCH` and provides -automatic retries of transactions aborted by Redis when `WATCH`ed keys are touched. For an example -of a transaction using CAS you can see [the following example](examples/TransactionWithCAS.php). - -__NOTE__: the method `transaction()` is available since `v0.8.5`, older versions used `multiExec()` -for the same purpose but it has been deprecated and will be removed in the next major release. - - -### Customizable connection backends ### - -Predis can use different connection backends to connect to Redis. Two of them leverage a third party -extension such as [phpiredis](https://github.com/nrk/phpiredis) resulting in major performance gains -especially when dealing with big multibulk responses. While one is based on PHP streams, the other -is based on socket resources provided by `ext-socket`. Both support TCP/IP or UNIX domain sockets: - -```php -$client = new Predis\Client('tcp://127.0.0.1', [ - 'connections' => [ - 'tcp' => 'Predis\Connection\PhpiredisStreamConnection', // PHP streams - 'unix' => 'Predis\Connection\PhpiredisConnection', // ext-socket - ], -]); -``` - -Developers can create their own connection classes to add support for new network backends, extend -existing ones or provide completely different implementations. Connection classes must implement -`Predis\Connection\SingleConnectionInterface` or extend `Predis\Connection\AbstractConnection`: - -```php -class MyConnectionClass implements Predis\Connection\SingleConnectionInterface -{ - // Implementation goes here... -} - -// Use MyConnectionClass to handle connections for the `tcp` scheme: -$client = new Predis\Client('tcp://127.0.0.1', [ - 'connections' => ['tcp' => 'MyConnectionClass'], -]); -``` - -For a more in-depth insight on how to create new connection backends you can refer to the actual -implementation of the standard connection classes available in the `Predis\Connection` namespace. - - -### Adding support for new commands ### - -While we try to update Predis to stay up to date with all the commands available in Redis, you might -prefer to stick with an older version of the library or provide a different way to filter arguments -or parse responses for specific commands. To achieve that, Predis provides the ability to implement -new command classes to define or override commands in the server profiles used by the client: - -```php -// Define a new command by extending Predis\Command\AbstractCommand: -class BrandNewRedisCommand extends Predis\Command\AbstractCommand -{ - public function getId() - { - return 'NEWCMD'; - } -} - -// Inject your command in the current profile: -$client = new Predis\Client(); -$client->getProfile()->defineCommand('newcmd', 'BrandNewRedisCommand'); - -$response = $client->newcmd(); -``` - - -### Scriptable commands ### - -A scriptable command is just an abstraction for [Lua scripting](http://redis.io/commands/eval) that -aims to simplify the usage of scripting with Redis >= 2.6. Scriptable commands can be registered in -the server profile used by the client and are accessible as if they were plain Redis commands, but -they define a Lua script that gets transmitted to Redis for remote execution. Internally, scriptable -commands use by default [EVALSHA](http://redis.io/commands/evalsha) and identify a Lua script by its -SHA1 hash to save bandwidth but [EVAL](http://redis.io/commands/eval) is automatically preferred as -a fall back when needed: - -```php -// Define a new scriptable command by extending Predis\Command\ScriptedCommand: -class ListPushRandomValue extends Predis\Command\ScriptedCommand -{ - public function getKeysCount() - { - return 1; - } - - public function getScript() - { - return <<getProfile()->defineCommand('lpushrand', 'ListPushRandomValue'); - -$response = $client->lpushrand('random_values', $seed = mt_rand()); -``` - - -## Development ## - - -### Reporting bugs and contributing code ### - -Contributions to Predis are highly appreciated either in the form of pull requests for new features, -bug fixes, or just bug reports. We only ask you to adhere to a [basic set of rules](CONTRIBUTING.md) -before submitting your changes or filing bugs on the issue tracker to make it easier for everyone to -stay consistent while working on the project. - - -### Test suite ### - -__ATTENTION__: Do not ever run the test suite shipped with Predis against instances of Redis running -in production environments or containing data you are interested in! - -Predis has a comprehensive test suite covering every aspect of the library. This test suite performs -integration tests against a running instance of Redis (>= 2.4.0 is required) to verify the correct -behaviour of the implementation of each command and automatically skips commands not defined in the -specified Redis profile. If you do not have Redis up and running, integration tests can be disabled. -By default the test suite is configured to execute integration tests using the profile for Redis 2.6 -but can optionally target a Redis instance built from `2.8` or `unstable` branches by modifying the -`phpunit.xml` file and setting `REDIS_SERVER_VERSION` respectively to `2.8` or `dev` so that the -correct server profile will be used. You can refer to [the tests README](tests/README.md) for more -detailed information about testing Predis. - -Predis uses Travis CI for continuous integration and the history for past and current builds can be -found [on its project page](http://travis-ci.org/nrk/predis). - - -## Other ## - - -### Project related links ### - -- [Source code](https://github.com/nrk/predis) -- [Wiki](https://wiki.github.com/nrk/predis) -- [Issue tracker](https://github.com/nrk/predis/issues) -- [PEAR channel](http://pear.nrk.io) - - -### Author ### - -- [Daniele Alessandri](mailto:suppakilla@gmail.com) ([twitter](http://twitter.com/JoL1hAHN)) - - -### License ### - -The code for Predis is distributed under the terms of the MIT license (see [LICENSE](LICENSE)). diff --git a/vendor/predis/predis/VERSION b/vendor/predis/predis/VERSION deleted file mode 100644 index 7ada0d303..000000000 --- a/vendor/predis/predis/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.8.5 diff --git a/vendor/predis/predis/autoload.php b/vendor/predis/predis/autoload.php deleted file mode 100644 index be08eb1f6..000000000 --- a/vendor/predis/predis/autoload.php +++ /dev/null @@ -1,14 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require __DIR__.'/lib/Predis/Autoloader.php'; - -Predis\Autoloader::register(); diff --git a/vendor/predis/predis/bin/create-command-test b/vendor/predis/predis/bin/create-command-test deleted file mode 100755 index f69b0729a..000000000 --- a/vendor/predis/predis/bin/create-command-test +++ /dev/null @@ -1,271 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// -------------------------------------------------------------------------- // -// This script can be used to automatically generate a file with the scheleton -// of a test case to test a Redis command by specifying the name of the class -// in the Predis\Command namespace (only classes in this namespace are valid). -// For example, to generate a test case for SET (which is represented by the -// Predis\Command\StringSet class): -// -// $ ./bin/generate-command-test.php --class=StringSet -// -// Here is a list of optional arguments: -// -// --realm: each command has its own realm (commands that operate on strings, -// lists, sets and such) but while this realm is usually inferred from the name -// of the specified class, sometimes it can be useful to override it with a -// custom one. -// -// --output: write the generated test case to the specified path instead of -// the default one. -// -// --overwrite: pre-existing test files are not overwritten unless this option -// is explicitly specified. -// -------------------------------------------------------------------------- // - -use Predis\Command\CommandInterface; -use Predis\Command\PrefixableCommandInterface; - -class CommandTestCaseGenerator -{ - private $options; - - public function __construct(Array $options) - { - if (!isset($options['class'])) { - throw new RuntimeException("Missing 'class' option."); - } - $this->options = $options; - } - - public static function fromCommandLine() - { - $parameters = array( - 'c:' => 'class:', - 'r::' => 'realm::', - 'o::' => 'output::', - 'x::' => 'overwrite::' - ); - - $getops = getopt(implode(array_keys($parameters)), $parameters); - - $options = array( - 'overwrite' => false, - 'tests' => __DIR__.'/../tests', - ); - - foreach ($getops as $option => $value) { - switch ($option) { - case 'c': - case 'class': - $options['class'] = $value; - break; - - case 'r': - case 'realm': - $options['realm'] = $value; - break; - - case 'o': - case 'output': - $options['output'] = $value; - break; - - case 'x': - case 'overwrite': - $options['overwrite'] = true; - break; - } - } - - if (!isset($options['class'])) { - throw new RuntimeException("Missing 'class' option."); - } - - $options['fqn'] = "Predis\\Command\\{$options['class']}"; - $options['path'] = "Predis/Command/{$options['class']}.php"; - - $source = __DIR__.'/../lib/'.$options['path']; - if (!file_exists($source)) { - throw new RuntimeException("Cannot find class file for {$options['fqn']} in $source."); - } - - if (!isset($options['output'])) { - $options['output'] = sprintf("%s/%s", $options['tests'], str_replace('.php', 'Test.php', $options['path'])); - } - - return new self($options); - } - - protected function getTestRealm() - { - if (isset($this->options['realm'])) { - if (!$this->options['realm']) { - throw new RuntimeException('Invalid value for realm has been sepcified (empty).'); - } - return $this->options['realm']; - } - - $fqnParts = explode('\\', $this->options['fqn']); - $class = array_pop($fqnParts); - list($realm,) = preg_split('/([[:upper:]][[:lower:]]+)/', $class, 2, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY); - - return strtolower($realm); - } - - public function generate() - { - $reflection = new ReflectionClass($class = $this->options['fqn']); - - if (!$reflection->isInstantiable()) { - throw new RuntimeException("Class $class must be instantiable, abstract classes or interfaces are not allowed."); - } - if (!$reflection->implementsInterface('Predis\Command\CommandInterface')) { - throw new RuntimeException("Class $class must implement Predis\Command\CommandInterface."); - } - - $instance = $reflection->newInstance(); - $buffer = $this->getTestCaseBuffer($instance); - - return $buffer; - } - - public function save() - { - $options = $this->options; - if (file_exists($options['output']) && !$options['overwrite']) { - throw new RuntimeException("File {$options['output']} already exist. Specify the --overwrite option to overwrite the existing file."); - } - file_put_contents($options['output'], $this->generate()); - } - - protected function getTestCaseBuffer(CommandInterface $instance) - { - $id = $instance->getId(); - $fqn = get_class($instance); - $fqnParts = explode('\\', $fqn); - $class = array_pop($fqnParts) . "Test"; - $realm = $this->getTestRealm(); - - $buffer =<< - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-$realm - */ -class $class extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return '$fqn'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return '$id'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - \$this->markTestIncomplete('This test has not been implemented yet.'); - - \$arguments = array(/* add arguments */); - \$expected = array(/* add arguments */); - - \$command = \$this->getCommand(); - \$command->setArguments(\$arguments); - - \$this->assertSame(\$expected, \$command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - \$this->markTestIncomplete('This test has not been implemented yet.'); - - \$raw = null; - \$expected = null; - - \$command = \$this->getCommand(); - - \$this->assertSame(\$expected, \$command->parseResponse(\$raw)); - } - -PHP; - - if ($instance instanceof PrefixableCommandInterface) { - $buffer .=<<markTestIncomplete('This test has not been implemented yet.'); - - \$arguments = array(/* add arguments */); - \$expected = array(/* add arguments */); - - \$command = \$this->getCommandWithArgumentsArray(\$arguments); - \$command->prefixKeys('prefix:'); - - \$this->assertSame(\$expected, \$command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - \$command = \$this->getCommand(); - \$command->prefixKeys('prefix:'); - - \$this->assertSame(array(), \$command->getArguments()); - } - -PHP; - } - - return "$buffer}\n"; - } -} - -// ------------------------------------------------------------------------- // - -require __DIR__.'/../autoload.php'; - -$generator = CommandTestCaseGenerator::fromCommandLine(); -$generator->save(); diff --git a/vendor/predis/predis/bin/create-pear b/vendor/predis/predis/bin/create-pear deleted file mode 100755 index 9d989e114..000000000 --- a/vendor/predis/predis/bin/create-pear +++ /dev/null @@ -1,53 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// -------------------------------------------------------------------------- // -// In order to be able to execute this script to create a PEAR package of Predis -// both `onion` and `pear` must be available and executable in your $PATH. -// -------------------------------------------------------------------------- // - -function executeWithBackup($file, $callback) -{ - $exception = null; - $backup = "$file.backup"; - - copy($file, $backup); - - try { - call_user_func($callback, $file); - } catch (Exception $exception) { - // NOOP - } - - unlink($file); - rename($backup, $file); - - if ($exception) { - throw $exception; - } -} - -function buildPackage() -{ - passthru('onion build && pear -q package && rm package.xml'); -} - -executeWithBackup(__DIR__.'/../phpunit.xml.dist', function ($file) { - $cfg = new SimpleXMLElement($file, null, true); - - $cfg[0]['bootstrap'] = str_replace('tests/', '', $cfg[0]['bootstrap']); - $cfg->testsuites->testsuite->directory = str_replace('tests/', '', $cfg->testsuites->testsuite->directory); - - $cfg->saveXml($file); - - buildPackage(); -}); diff --git a/vendor/predis/predis/bin/create-phar b/vendor/predis/predis/bin/create-phar deleted file mode 100755 index fe0d31b26..000000000 --- a/vendor/predis/predis/bin/create-phar +++ /dev/null @@ -1,71 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// -------------------------------------------------------------------------- // -// In order to be able to execute this script to create a Phar archive of Predis, -// the Phar module must be loaded and the "phar.readonly" directive php.ini must -// be set to "off". You can change the values in the $options array to customize -// the creation of the Phar archive to better suit your needs. -// -------------------------------------------------------------------------- // - -$options = array( - 'name' => 'predis', - 'project_path' => __DIR__ . '/../lib/', - 'compression' => Phar::NONE, - 'append_version' => true, -); - -function getPharFilename($options) -{ - $filename = $options['name']; - - // NOTE: do not consider "append_version" with Phar compression do to a bug in - // Phar::compress() when renaming phar archives containing dots in their name. - if ($options['append_version'] && $options['compression'] === Phar::NONE) { - $versionFile = @fopen(__DIR__ . '/../VERSION', 'r'); - - if ($versionFile === false) { - throw new Exception("Could not locate the VERSION file."); - } - - $version = trim(fgets($versionFile)); - fclose($versionFile); - $filename .= "_$version"; - } - - return "$filename.phar"; -} - -function getPharStub($options) -{ - return <<compress($options['compression']); -$phar->setStub(getPharStub($options)); -$phar->buildFromDirectory($options['project_path']); diff --git a/vendor/predis/predis/bin/create-single-file b/vendor/predis/predis/bin/create-single-file deleted file mode 100755 index 8a7998876..000000000 --- a/vendor/predis/predis/bin/create-single-file +++ /dev/null @@ -1,663 +0,0 @@ -#!/usr/bin/env php - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -// -------------------------------------------------------------------------- // -// This script can be used to automatically glue all the .php files of Predis -// into a single monolithic script file that can be used without an autoloader, -// just like the other previous versions of the library. -// -// Much of its complexity is due to the fact that we cannot simply join PHP -// files, but namespaces and classes definitions must follow a precise order -// when dealing with subclassing and inheritance. -// -// The current implementation is pretty nave, but it should do for now. -// -------------------------------------------------------------------------- // - -class CommandLine -{ - public static function getOptions() - { - $parameters = array( - 's:' => 'source:', - 'o:' => 'output:', - 'e:' => 'exclude:', - 'E:' => 'exclude-classes:', - ); - - $getops = getopt(implode(array_keys($parameters)), $parameters); - - $options = array( - 'source' => __DIR__ . "/../lib/", - 'output' => PredisFile::NS_ROOT . '.php', - 'exclude' => array(), - ); - - foreach ($getops as $option => $value) { - switch ($option) { - case 's': - case 'source': - $options['source'] = $value; - break; - - case 'o': - case 'output': - $options['output'] = $value; - break; - - case 'E': - case 'exclude-classes': - $options['exclude'] = @file($value, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: $value; - break; - - case 'e': - case 'exclude': - $options['exclude'] = is_array($value) ? $value : array($value); - break; - } - } - - return $options; - } -} - -class PredisFile -{ - const NS_ROOT = 'Predis'; - - private $namespaces; - - public function __construct() - { - $this->namespaces = array(); - } - - public static function from($libraryPath, Array $exclude = array()) - { - $nsroot = self::NS_ROOT; - $predisFile = new PredisFile(); - $libIterator = new RecursiveDirectoryIterator("$libraryPath$nsroot"); - - foreach (new RecursiveIteratorIterator($libIterator) as $classFile) - { - if (!$classFile->isFile()) { - continue; - } - - $namespace = strtr(str_replace($libraryPath, '', $classFile->getPath()), '/', '\\'); - - if (in_array(sprintf('%s\\%s', $namespace, $classFile->getBasename('.php')), $exclude)) { - continue; - } - - $phpNamespace = $predisFile->getNamespace($namespace); - - if ($phpNamespace === false) { - $phpNamespace = new PhpNamespace($namespace); - $predisFile->addNamespace($phpNamespace); - } - - $phpClass = new PhpClass($phpNamespace, $classFile); - } - - return $predisFile; - } - - public function addNamespace(PhpNamespace $namespace) - { - if (isset($this->namespaces[(string)$namespace])) { - throw new InvalidArgumentException("Duplicated namespace"); - } - $this->namespaces[(string)$namespace] = $namespace; - } - - public function getNamespaces() - { - return $this->namespaces; - } - - public function getNamespace($namespace) - { - if (!isset($this->namespaces[$namespace])) { - return false; - } - - return $this->namespaces[$namespace]; - } - - public function getClassByFQN($classFqn) - { - if (($nsLastPos = strrpos($classFqn, '\\')) !== false) { - $namespace = $this->getNamespace(substr($classFqn, 0, $nsLastPos)); - if ($namespace === false) { - return null; - } - $className = substr($classFqn, $nsLastPos + 1); - - return $namespace->getClass($className); - } - - return null; - } - - private function calculateDependencyScores(&$classes, $fqn) - { - if (!isset($classes[$fqn])) { - $classes[$fqn] = 0; - } - - $classes[$fqn] += 1; - - if (($phpClass = $this->getClassByFQN($fqn)) === null) { - throw new RuntimeException( - "Cannot found the class $fqn which is required by other subclasses. Are you missing a file?" - ); - } - - foreach ($phpClass->getDependencies() as $fqn) { - $this->calculateDependencyScores($classes, $fqn); - } - } - - private function getDependencyScores() - { - $classes = array(); - - foreach ($this->getNamespaces() as $phpNamespace) { - foreach ($phpNamespace->getClasses() as $phpClass) { - $this->calculateDependencyScores($classes, $phpClass->getFQN()); - } - } - - return $classes; - } - - private function getOrderedNamespaces($dependencyScores) - { - $namespaces = array_fill_keys(array_unique( - array_map( - function ($fqn) { return PhpNamespace::extractName($fqn); }, - array_keys($dependencyScores) - ) - ), 0); - - foreach ($dependencyScores as $classFqn => $score) { - $namespaces[PhpNamespace::extractName($classFqn)] += $score; - } - - arsort($namespaces); - - return array_keys($namespaces); - } - - private function getOrderedClasses(PhpNamespace $phpNamespace, $classes) - { - $nsClassesFQNs = array_map(function ($cl) { return $cl->getFQN(); }, $phpNamespace->getClasses()); - $nsOrderedClasses = array(); - - foreach ($nsClassesFQNs as $nsClassFQN) { - $nsOrderedClasses[$nsClassFQN] = $classes[$nsClassFQN]; - } - - arsort($nsOrderedClasses); - - return array_keys($nsOrderedClasses); - } - - public function getPhpCode() - { - $buffer = array("getDependencyScores(); - $namespaces = $this->getOrderedNamespaces($classes); - - foreach ($namespaces as $namespace) { - $phpNamespace = $this->getNamespace($namespace); - - // generate namespace directive - $buffer[] = $phpNamespace->getPhpCode(); - $buffer[] = "\n"; - - // generate use directives - $useDirectives = $phpNamespace->getUseDirectives(); - if (count($useDirectives) > 0) { - $buffer[] = $useDirectives->getPhpCode(); - $buffer[] = "\n"; - } - - // generate classes bodies - $nsClasses = $this->getOrderedClasses($phpNamespace, $classes); - foreach ($nsClasses as $classFQN) { - $buffer[] = $this->getClassByFQN($classFQN)->getPhpCode(); - $buffer[] = "\n\n"; - } - - $buffer[] = "/* " . str_repeat("-", 75) . " */"; - $buffer[] = "\n\n"; - } - - return implode($buffer); - } - - public function saveTo($outputFile) - { - // TODO: add more sanity checks - if ($outputFile === null || $outputFile === '') { - throw new InvalidArgumentException('You must specify a valid output file'); - } - file_put_contents($outputFile, $this->getPhpCode()); - } -} - -class PhpNamespace implements IteratorAggregate -{ - private $namespace; - private $classes; - - public function __construct($namespace) - { - $this->namespace = $namespace; - $this->classes = array(); - $this->useDirectives = new PhpUseDirectives($this); - } - - public static function extractName($fqn) - { - $nsSepLast = strrpos($fqn, '\\'); - if ($nsSepLast === false) { - return $fqn; - } - $ns = substr($fqn, 0, $nsSepLast); - - return $ns !== '' ? $ns : null; - } - - public function addClass(PhpClass $class) - { - $this->classes[$class->getName()] = $class; - } - - public function getClass($className) - { - if (isset($this->classes[$className])) { - return $this->classes[$className]; - } - } - - public function getClasses() - { - return array_values($this->classes); - } - - public function getIterator() - { - return new \ArrayIterator($this->getClasses()); - } - - public function getUseDirectives() - { - return $this->useDirectives; - } - - public function getPhpCode() - { - return "namespace $this->namespace;\n"; - } - - public function __toString() - { - return $this->namespace; - } -} - -class PhpUseDirectives implements Countable, IteratorAggregate -{ - private $use; - private $aliases; - private $reverseAliases; - private $namespace; - - public function __construct(PhpNamespace $namespace) - { - $this->namespace = $namespace; - $this->use = array(); - $this->aliases = array(); - $this->reverseAliases = array(); - } - - public function add($use, $as = null) - { - if (in_array($use, $this->use)) { - return; - } - - $rename = null; - $this->use[] = $use; - $aliasedClassName = $as ?: PhpClass::extractName($use); - - if (isset($this->aliases[$aliasedClassName])) { - $parentNs = $this->getParentNamespace(); - - if ($parentNs && false !== $pos = strrpos($parentNs, '\\')) { - $parentNs = substr($parentNs, $pos); - } - - $newAlias = "{$parentNs}_{$aliasedClassName}"; - $rename = (object) array( - 'namespace' => $this->namespace, - 'from' => $aliasedClassName, - 'to' => $newAlias, - ); - - $this->aliases[$newAlias] = $use; - $as = $newAlias; - } else { - $this->aliases[$aliasedClassName] = $use; - } - - if ($as !== null) { - $this->reverseAliases[$use] = $as; - } - - return $rename; - } - - public function getList() - { - return $this->use; - } - - public function getIterator() - { - return new \ArrayIterator($this->getList()); - } - - public function getPhpCode() - { - $reverseAliases = $this->reverseAliases; - - $reducer = function ($str, $use) use ($reverseAliases) { - if (isset($reverseAliases[$use])) { - return $str .= "use $use as {$reverseAliases[$use]};\n"; - } else { - return $str .= "use $use;\n"; - } - }; - - return array_reduce($this->getList(), $reducer, ''); - } - - public function getNamespace() - { - return $this->namespace; - } - - public function getParentNamespace() - { - if (false !== $pos = strrpos($this->namespace, '\\')) { - return substr($this->namespace, 0, $pos); - } - - return ''; - } - - public function getFQN($className) - { - if (($nsSepFirst = strpos($className, '\\')) === false) { - if (isset($this->aliases[$className])) { - return $this->aliases[$className]; - } - - return (string)$this->getNamespace() . "\\$className"; - } - - if ($nsSepFirst != 0) { - throw new InvalidArgumentException("Partially qualified names are not supported"); - } - - return $className; - } - - public function count() - { - return count($this->use); - } -} - -class PhpClass -{ - const LICENSE_HEADER = << - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ -LICENSE; - - private $namespace; - private $file; - private $body; - private $implements; - private $extends; - private $name; - - public function __construct(PhpNamespace $namespace, SplFileInfo $classFile) - { - $this->namespace = $namespace; - $this->file = $classFile; - $this->implements = array(); - $this->extends = array(); - - $this->extractData(); - $namespace->addClass($this); - } - - public static function extractName($fqn) - { - $nsSepLast = strrpos($fqn, '\\'); - if ($nsSepLast === false) { - return $fqn; - } - - return substr($fqn, $nsSepLast + 1); - } - - private function extractData() - { - $renames = array(); - $useDirectives = $this->getNamespace()->getUseDirectives(); - - $useExtractor = function ($m) use ($useDirectives, &$renames) { - array_shift($m); - - if (isset($m[1])) { - $m[1] = str_replace(" as ", '', $m[1]); - } - - if ($rename = call_user_func_array(array($useDirectives, 'add'), $m)) { - $renames[] = $rename; - } - }; - - $classBuffer = stream_get_contents(fopen($this->getFile()->getPathname(), 'r')); - - $classBuffer = str_replace(self::LICENSE_HEADER, '', $classBuffer); - - $classBuffer = preg_replace('/<\?php\s?\\n\s?/', '', $classBuffer); - $classBuffer = preg_replace('/\s?\?>\n?/ms', '', $classBuffer); - $classBuffer = preg_replace('/namespace\s+[\w\d_\\\\]+;\s?/', '', $classBuffer); - $classBuffer = preg_replace_callback('/use\s+([\w\d_\\\\]+)(\s+as\s+.*)?;\s?\n?/', $useExtractor, $classBuffer); - - foreach ($renames as $rename) { - $classBuffer = str_replace($rename->from, $rename->to, $classBuffer); - } - - $this->body = trim($classBuffer); - - $this->extractHierarchy(); - } - - private function extractHierarchy() - { - $implements = array(); - $extends = array(); - - $extractor = function ($iterator, $callback) { - $className = ''; - $iterator->seek($iterator->key() + 1); - - while ($iterator->valid()) { - $token = $iterator->current(); - - if (is_string($token)) { - if (preg_match('/\s?,\s?/', $token)) { - $callback(trim($className)); - $className = ''; - } else if ($token == '{') { - $callback(trim($className)); - return; - } - } - - switch ($token[0]) { - case T_NS_SEPARATOR: - $className .= '\\'; - break; - - case T_STRING: - $className .= $token[1]; - break; - - case T_IMPLEMENTS: - case T_EXTENDS: - $callback(trim($className)); - $iterator->seek($iterator->key() - 1); - return; - } - - $iterator->next(); - } - }; - - $tokens = token_get_all("getPhpCode())); - $iterator = new ArrayIterator($tokens); - - while ($iterator->valid()) { - $token = $iterator->current(); - if (is_string($token)) { - $iterator->next(); - continue; - } - - switch ($token[0]) { - case T_CLASS: - case T_INTERFACE: - $iterator->seek($iterator->key() + 2); - $tk = $iterator->current(); - $this->name = $tk[1]; - break; - - case T_IMPLEMENTS: - $extractor($iterator, function ($fqn) use (&$implements) { - $implements[] = $fqn; - }); - break; - - case T_EXTENDS: - $extractor($iterator, function ($fqn) use (&$extends) { - $extends[] = $fqn; - }); - break; - } - - $iterator->next(); - } - - $this->implements = $this->guessFQN($implements); - $this->extends = $this->guessFQN($extends); - } - - public function guessFQN($classes) - { - $useDirectives = $this->getNamespace()->getUseDirectives(); - return array_map(array($useDirectives, 'getFQN'), $classes); - } - - public function getImplementedInterfaces($all = false) - { - if ($all) { - return $this->implements; - } - - return array_filter( - $this->implements, - function ($cn) { return strpos($cn, 'Predis\\') === 0; } - ); - } - - public function getExtendedClasses($all = false) - { - if ($all) { - return $this->extemds; - } - - return array_filter( - $this->extends, - function ($cn) { return strpos($cn, 'Predis\\') === 0; } - ); - } - - public function getDependencies($all = false) - { - return array_merge( - $this->getImplementedInterfaces($all), - $this->getExtendedClasses($all) - ); - } - - public function getNamespace() - { - return $this->namespace; - } - - public function getFile() - { - return $this->file; - } - - public function getName() - { - return $this->name; - } - - public function getFQN() - { - return (string)$this->getNamespace() . '\\' . $this->name; - } - - public function getPhpCode() - { - return $this->body; - } - - public function __toString() - { - return "class " . $this->getName() . '{ ... }'; - } -} - -/* -------------------------------------------------------------------------- */ - -$options = CommandLine::getOptions(); -$predisFile = PredisFile::from($options['source'], $options['exclude']); -$predisFile->saveTo($options['output']); diff --git a/vendor/predis/predis/composer.json b/vendor/predis/predis/composer.json deleted file mode 100644 index 3b1c2fde5..000000000 --- a/vendor/predis/predis/composer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "predis/predis", - "type": "library", - "description": "Flexible and feature-complete PHP client library for Redis", - "keywords": ["nosql", "redis", "predis"], - "homepage": "http://github.com/nrk/predis", - "license": "MIT", - "authors": [ - { - "name": "Daniele Alessandri", - "email": "suppakilla@gmail.com", - "homepage": "http://clorophilla.net" - } - ], - "require": { - "php": ">=5.3.2" - }, - "suggest": { - "ext-phpiredis": "Allows faster serialization and deserialization of the Redis protocol", - "ext-curl": "Allows access to Webdis when paired with phpiredis" - }, - "autoload": { - "psr-0": {"Predis": "lib/"} - } -} diff --git a/vendor/predis/predis/examples/CustomDistributionStrategy.php b/vendor/predis/predis/examples/CustomDistributionStrategy.php deleted file mode 100644 index 052b6c03c..000000000 --- a/vendor/predis/predis/examples/CustomDistributionStrategy.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// Developers can customize the distribution strategy used by the client -// to distribute keys among a cluster of servers simply by creating a class -// that implements Predis\Distribution\DistributionStrategyInterface. - -use Predis\Connection\PredisCluster; -use Predis\Cluster\Distribution\DistributionStrategyInterface; -use Predis\Cluster\Hash\HashGeneratorInterface; - -class NaiveDistributionStrategy implements DistributionStrategyInterface, HashGeneratorInterface -{ - private $nodes; - private $nodesCount; - - public function __construct() - { - $this->nodes = array(); - $this->nodesCount = 0; - } - - public function add($node, $weight = null) - { - $this->nodes[] = $node; - $this->nodesCount++; - } - - public function remove($node) - { - $this->nodes = array_filter($this->nodes, function ($n) use ($node) { - return $n !== $node; - }); - - $this->nodesCount = count($this->nodes); - } - - public function get($key) - { - if (0 === $count = $this->nodesCount) { - throw new RuntimeException('No connections'); - } - - return $this->nodes[$count > 1 ? abs($key % $count) : 0]; - } - - public function hash($value) - { - return crc32($value); - } - - public function getHashGenerator() - { - return $this; - } -} - -$options = array( - 'cluster' => function () { - $distributor = new NaiveDistributionStrategy(); - $cluster = new PredisCluster($distributor); - - return $cluster; - }, -); - -$client = new Predis\Client($multiple_servers, $options); - -for ($i = 0; $i < 100; $i++) { - $client->set("key:$i", str_pad($i, 4, '0', 0)); - $client->get("key:$i"); -} - -$server1 = $client->getClientFor('first')->info(); -$server2 = $client->getClientFor('second')->info(); - -printf("Server '%s' has %d keys while server '%s' has %d keys.\n", - 'first', $server1['db15']['keys'], 'second', $server2['db15']['keys'] -); diff --git a/vendor/predis/predis/examples/DispatcherLoop.php b/vendor/predis/predis/examples/DispatcherLoop.php deleted file mode 100644 index f5b8a990a..000000000 --- a/vendor/predis/predis/examples/DispatcherLoop.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -/* -This is a basic example on how to use the Predis\DispatcherLoop class. - -To see this example in action you can just use redis-cli and publish some -messages to the 'events' and 'control' channel, e.g.: - -./redis-cli -PUBLISH events first -PUBLISH events second -PUBLISH events third -PUBLISH control terminate_dispatcher -*/ - -// Create a client and disable r/w timeout on the socket -$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); - -// Create a Predis\DispatcherLoop instance and attach a bunch of callbacks. -$dispatcher = new Predis\PubSub\DispatcherLoop($client); - -// Demonstrate how to use a callable class as a callback for Predis\DispatcherLoop. -class EventsListener implements Countable -{ - private $events; - - public function __construct() - { - $this->events = array(); - } - - public function count() - { - return count($this->events); - } - - public function getEvents() - { - return $this->events; - } - - public function __invoke($payload) - { - $this->events[] = $payload; - } -} - -// Attach our callable class to the dispatcher. -$dispatcher->attachCallback('events', ($events = new EventsListener())); - -// Attach a function to control the dispatcher loop termination with a message. -$dispatcher->attachCallback('control', function ($payload) use ($dispatcher) { - if ($payload === 'terminate_dispatcher') { - $dispatcher->stop(); - } -}); - -// Run the dispatcher loop until the callback attached to the 'control' channel -// receives 'terminate_dispatcher' as a message. -$dispatcher->run(); - -// Display our achievements! -echo "We received {$events->count()} messages!\n"; - -// Say goodbye :-) -$info = $client->info(); -print_r("Goodbye from Redis v{$info['redis_version']}!\n"); diff --git a/vendor/predis/predis/examples/KeyPrefixes.php b/vendor/predis/predis/examples/KeyPrefixes.php deleted file mode 100644 index 4979676d9..000000000 --- a/vendor/predis/predis/examples/KeyPrefixes.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// Predis ships with a KeyPrefixProcessor class that is used to transparently -// prefix each key before sending commands to Redis, even for complex commands -// such as SORT, ZUNIONSTORE and ZINTERSTORE. Key prefixes are useful to create -// user-level namespaces for you keyspace, thus eliminating the need for separate -// logical databases. - -$client = new Predis\Client($single_server, array('prefix' => 'nrk:')); - -$client->mset(array('foo' => 'bar', 'lol' => 'wut')); -var_dump($client->mget('foo', 'lol')); -/* -array(2) { - [0]=> string(3) "bar" - [1]=> string(3) "wut" -} -*/ - -var_dump($client->keys('*')); -/* -array(2) { - [0]=> string(7) "nrk:foo" - [1]=> string(7) "nrk:lol" -} -*/ diff --git a/vendor/predis/predis/examples/MasterSlaveReplication.php b/vendor/predis/predis/examples/MasterSlaveReplication.php deleted file mode 100644 index df7e16c3a..000000000 --- a/vendor/predis/predis/examples/MasterSlaveReplication.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// Predis supports master / slave replication scenarios where write operations are -// performed on the master server and read operations are executed against one of -// the slaves. The behaviour of commands or EVAL scripts can be customized at will. -// As soon as a write operation is performed, all the subsequent requests (reads -// or writes) will be served by the master server. -// -// This example must be executed with the second Redis server acting as the slave -// of the first one using the SLAVEOF command. -// - -$parameters = array( - 'tcp://127.0.0.1:6379?database=15&alias=master', - 'tcp://127.0.0.1:6380?database=15&alias=slave', -); - -$options = array('replication' => true); - -$client = new Predis\Client($parameters, $options); - -// Read operation. -$exists = $client->exists('foo') ? 'yes' : 'no'; -$current = $client->getConnection()->getCurrent()->getParameters(); -echo "Does 'foo' exist on {$current->alias}? $exists.\n"; - -// Write operation. -$client->set('foo', 'bar'); -$current = $client->getConnection()->getCurrent()->getParameters(); -echo "Now 'foo' has been set to 'bar' on {$current->alias}!\n"; - -// Read operation. -$bar = $client->get('foo'); -$current = $client->getConnection()->getCurrent()->getParameters(); -echo "We just fetched 'foo' from {$current->alias} and its value is '$bar'.\n"; - -/* OUTPUT: -Does 'foo' exist on slave? yes. -Now 'foo' has been set to 'bar' on master! -We just fetched 'foo' from master and its value is 'bar'. -*/ diff --git a/vendor/predis/predis/examples/MasterSlaveReplicationComplex.php b/vendor/predis/predis/examples/MasterSlaveReplicationComplex.php deleted file mode 100644 index 786d595c5..000000000 --- a/vendor/predis/predis/examples/MasterSlaveReplicationComplex.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// Predis allows to set Lua scripts as read-only operations in the context of -// replication. This works for both EVAL and EVALSHA and also for the client-side -// abstraction built upon them (Predis\Command\ScriptedCommand). This example -// shows a slightly more complex configuration that injects a new scripted command -// in the server profile used by the new client instance and marks it marks it as -// a read-only operation for replication so that it will be executed on slaves. - -use Predis\Command\ScriptedCommand; -use Predis\Connection\MasterSlaveReplication; -use Predis\Profile\ServerProfile; -use Predis\Replication\ReplicationStrategy; - -// ------------------------------------------------------------------------- // - -// Define a new scripted command that returns all the fields -// of a variable number of hashes with a single roundtrip. - -class HashMultipleGetAll extends ScriptedCommand { - const BODY = << function ($options, $option) { - $profile = $options->getDefault($option); - $profile->defineCommand('hmgetall', 'HashMultipleGetAll'); - - return $profile; - }, - 'replication' => function ($options) { - $strategy = new ReplicationStrategy(); - $strategy->setScriptReadOnly(HashMultipleGetAll::BODY); - - $replication = new MasterSlaveReplication($strategy); - - return $replication; - }, -); - -// ------------------------------------------------------------------------- // - -$client = new Predis\Client($parameters, $options); - -// Execute the following commands on the master server using redis-cli: -// $ ./redis-cli HMSET metavars foo bar hoge piyo -// $ ./redis-cli HMSET servers master host1 slave host2 - -$hashes = $client->hmgetall('metavars', 'servers'); - -$replication = $client->getConnection(); -$stillOnSlave = $replication->getCurrent() === $replication->getConnectionById('slave'); - -echo "Is still on slave? ", $stillOnSlave ? 'YES' : 'NO', "!\n"; -var_export($hashes); diff --git a/vendor/predis/predis/examples/MonitorContext.php b/vendor/predis/predis/examples/MonitorContext.php deleted file mode 100644 index e1cad7425..000000000 --- a/vendor/predis/predis/examples/MonitorContext.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// This is a basic example on how to use the Predis\MonitorContext class. -// You can use redis-cli to send commands to the same Redis instance your client is -// connected to, and then type "ECHO QUIT_MONITOR" in redis-cli when you want to -// exit the monitor loop and terminate this script in a graceful way. - -// Create a client and disable r/w timeout on the socket. -$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); - -// Use only one instance of DateTime, we will update the timestamp later. -$timestamp = new DateTime(); - -foreach (($monitor = $client->monitor()) as $event) { - $timestamp->setTimestamp((int) $event->timestamp); - - // If we notice a ECHO command with the message QUIT_MONITOR, we close the - // monitor context and then break the loop. - if ($event->command === 'ECHO' && $event->arguments === '"QUIT_MONITOR"') { - echo "Exiting the monitor loop...\n"; - $monitor->closeContext(); - break; - } - - echo "* Received {$event->command} on DB {$event->database} at {$timestamp->format(DateTime::W3C)}\n"; - if (isset($event->arguments)) { - echo " Arguments: {$event->arguments}\n"; - } -} - -// Say goodbye :-) -$info = $client->info(); -print_r("Goodbye from Redis v{$info['redis_version']}!\n"); diff --git a/vendor/predis/predis/examples/MultiBulkReplyIterators.php b/vendor/predis/predis/examples/MultiBulkReplyIterators.php deleted file mode 100644 index 27c51b958..000000000 --- a/vendor/predis/predis/examples/MultiBulkReplyIterators.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// Operations such as LRANGE, ZRANGE and others can potentially generate replies -// containing a huge number of items. In some corner cases, such replies might -// end up exhausting the maximum allowed memory allocated for a PHP process. -// Multibulk iterators can be handy because they allow you to stream multibulk -// replies using plain old PHP iterators, making it possible to iterate them with -// a classic `foreach` loop and avoiding to consume an excessive amount of memory. -// -// PS: please note that multibulk iterators are supported only by the standard -// connection backend class (Predis\Connection\StreamConnection) and not the -// phpiredis-based one (Predis\Connection\PhpiredisConnection). - -// Create a client and force the connection to use iterable multibulk responses. -$client = new Predis\Client($single_server + array('iterable_multibulk' => true)); - -// Prepare an hash with some fields and their respective values. -$client->hmset('metavars', array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut')); - -// By default multibulk iterators iterate over the reply as a list of items... -foreach ($client->hgetall('metavars') as $index => $item) { - echo "[$index] $item\n"; -} - -/* OUTPUT: -[0] foo -[1] bar -[2] hoge -[3] piyo -[4] lol -[5] wut -*/ - -// ... but certain multibulk replies are better represented as lists of tuples. -foreach ($client->hgetall('metavars')->asTuple() as $index => $kv) { - list($key, $value) = $kv; - - echo "[$index] $key => $value\n"; -} - -/* OUTPUT: -[0] foo => bar -[1] hoge => piyo -[2] lol => wut -*/ diff --git a/vendor/predis/predis/examples/MultipleSetAndGet.php b/vendor/predis/predis/examples/MultipleSetAndGet.php deleted file mode 100644 index 864f8273a..000000000 --- a/vendor/predis/predis/examples/MultipleSetAndGet.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// redis can set keys and their relative values in one go -// using MSET, then the same values can be retrieved with -// a single command using MGET. - -$mkv = array( - 'usr:0001' => 'First user', - 'usr:0002' => 'Second user', - 'usr:0003' => 'Third user' -); - -$client = new Predis\Client($single_server); - -$client->mset($mkv); -$retval = $client->mget(array_keys($mkv)); - -print_r($retval); - -/* OUTPUT: -Array -( - [0] => First user - [1] => Second user - [2] => Third user -) -*/ diff --git a/vendor/predis/predis/examples/PipelineContext.php b/vendor/predis/predis/examples/PipelineContext.php deleted file mode 100644 index 57fa63846..000000000 --- a/vendor/predis/predis/examples/PipelineContext.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// When you have a whole set of consecutive commands to send to -// a redis server, you can use a pipeline to improve performances. - -$client = new Predis\Client($single_server); - -$replies = $client->pipeline(function ($pipe) { - $pipe->ping(); - $pipe->flushdb(); - $pipe->incrby('counter', 10); - $pipe->incrby('counter', 30); - $pipe->exists('counter'); - $pipe->get('counter'); - $pipe->mget('does_not_exist', 'counter'); -}); - -print_r($replies); - -/* OUTPUT: -Array -( - [0] => 1 - [1] => 1 - [2] => 10 - [3] => 40 - [4] => 1 - [5] => 40 - [6] => Array - ( - [0] => - [1] => 40 - ) - -) -*/ diff --git a/vendor/predis/predis/examples/PubSubContext.php b/vendor/predis/predis/examples/PubSubContext.php deleted file mode 100644 index 42428c375..000000000 --- a/vendor/predis/predis/examples/PubSubContext.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// Redis 2.0 features new commands that allow clients to subscribe for -// events published on certain channels (PUBSUB). - -// Create a client and disable r/w timeout on the socket -$client = new Predis\Client($single_server + array('read_write_timeout' => 0)); - -// Initialize a new pubsub context -$pubsub = $client->pubSubLoop(); - -// Subscribe to your channels -$pubsub->subscribe('control_channel', 'notifications'); - -// Start processing the pubsup messages. Open a terminal and use redis-cli -// to push messages to the channels. Examples: -// ./redis-cli PUBLISH notifications "this is a test" -// ./redis-cli PUBLISH control_channel quit_loop -foreach ($pubsub as $message) { - switch ($message->kind) { - case 'subscribe': - echo "Subscribed to {$message->channel}\n"; - break; - - case 'message': - if ($message->channel == 'control_channel') { - if ($message->payload == 'quit_loop') { - echo "Aborting pubsub loop...\n"; - $pubsub->unsubscribe(); - } else { - echo "Received an unrecognized command: {$message->payload}.\n"; - } - } else { - echo "Received the following message from {$message->channel}:\n", - " {$message->payload}\n\n"; - } - break; - } -} - -// Always unset the pubsub context instance when you are done! The -// class destructor will take care of cleanups and prevent protocol -// desynchronizations between the client and the server. -unset($pubsub); - -// Say goodbye :-) -$info = $client->info(); -print_r("Goodbye from Redis v{$info['redis_version']}!\n"); diff --git a/vendor/predis/predis/examples/RedisCollectionsIterators.php b/vendor/predis/predis/examples/RedisCollectionsIterators.php deleted file mode 100644 index c3278c2ff..000000000 --- a/vendor/predis/predis/examples/RedisCollectionsIterators.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -use Predis\Collection\Iterator; - -// Redis 2.8 features new commands allowing clients to incrementally -// iterate over collections without blocking the server like it happens -// when a command such as KEYS is executed on a Redis instance storing -// millions of keys. These commands are SCAN (iterates over the keyspace), -// SSCAN (iterates over members of a set), ZSCAN (iterates over members -// and ranks of a sorted set) and HSCAN (iterates over fields and values -// of an hash). Predis provides a specialized abstraction for each command -// based on SPL iterators making it possible to easily consume SCAN-based -// iterations in your PHP code. -// -// See http://redis.io/commands/scan for more details. -// - -// Create a client using `2.8` as a server profile (needs Redis 2.8!) -$client = new Predis\Client($single_server, array('profile' => '2.8')); - -// Prepare some keys for our example -$client->del('predis:set', 'predis:zset', 'predis:hash'); -for ($i = 0; $i < 5; $i++) { - $client->sadd('predis:set', "member:$i"); - $client->zadd('predis:zset', -$i, "member:$i"); - $client->hset('predis:hash', "field:$i", "value:$i"); -} - -// === Keyspace iterator based on SCAN === -echo 'Scan the keyspace matching only our prefixed keys:', PHP_EOL; -foreach (new Iterator\Keyspace($client, 'predis:*') as $key) { - echo " - $key", PHP_EOL; -} - -/* OUTPUT -Scan the keyspace matching only our prefixed keys: - - predis:zset - - predis:set - - predis:hash -*/ - -// === Set iterator based on SSCAN === -echo 'Scan members of `predis:set`:', PHP_EOL; -foreach (new Iterator\SetKey($client, 'predis:set') as $member) { - echo " - $member", PHP_EOL; -} - -/* OUTPUT -Scan members of `predis:set`: - - member:1 - - member:4 - - member:0 - - member:3 - - member:2 -*/ - -// === Sorted set iterator based on ZSCAN === -echo 'Scan members and ranks of `predis:zset`:', PHP_EOL; -foreach (new Iterator\SortedSetKey($client, 'predis:zset') as $member => $rank) { - echo " - $member [rank: $rank]", PHP_EOL; -} - -/* OUTPUT -Scan members and ranks of `predis:zset`: - - member:4 [rank: -4] - - member:3 [rank: -3] - - member:2 [rank: -2] - - member:1 [rank: -1] - - member:0 [rank: 0] -*/ - -// === Hash iterator based on HSCAN === -echo 'Scan fields and values of `predis:hash`:', PHP_EOL; -foreach (new Iterator\HashKey($client, 'predis:hash') as $field => $value) { - echo " - $field => $value", PHP_EOL; -} - -/* OUTPUT -Scan fields and values of `predis:hash`: - - field:0 => value:0 - - field:1 => value:1 - - field:2 => value:2 - - field:3 => value:3 - - field:4 => value:4 -*/ diff --git a/vendor/predis/predis/examples/ServerSideScripting.php b/vendor/predis/predis/examples/ServerSideScripting.php deleted file mode 100644 index ac236e60f..000000000 --- a/vendor/predis/predis/examples/ServerSideScripting.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// This example will not work with versions of Redis < 2.6. -// -// Additionally to the EVAL command defined in the current development profile, the new -// Predis\Command\ScriptedCommand base class can be used to build an higher abstraction -// for our "scripted" commands so that they will appear just like any other command on -// the client-side. This is a quick example used to implement INCREX. - -use Predis\Command\ScriptedCommand; - -class IncrementExistingKeysBy extends ScriptedCommand -{ - public function getKeysCount() - { - // Tell Predis to use all the arguments but the last one as arguments - // for KEYS. The last one will be used to populate ARGV. - return -1; - } - - public function getScript() - { - return -<<getProfile()->defineCommand('increxby', 'IncrementExistingKeysBy'); - -$client->mset('foo', 10, 'foobar', 100); - -var_export($client->increxby('foo', 'foofoo', 'foobar', 50)); - -/* -array ( - 0 => 60, - 1 => NULL, - 2 => 150, -) -*/ diff --git a/vendor/predis/predis/examples/SessionHandler.php b/vendor/predis/predis/examples/SessionHandler.php deleted file mode 100644 index 0ff6c9522..000000000 --- a/vendor/predis/predis/examples/SessionHandler.php +++ /dev/null @@ -1,39 +0,0 @@ -= 5.4 but can be used on PHP 5.3 if a polyfill for -// SessionHandlerInterface (see http://www.php.net/class.sessionhandlerinterface.php) -// is provided either by you or an external package like `symfony/http-foundation`. - -if (!interface_exists('SessionHandlerInterface')) { - die("ATTENTION: the session handler implemented by Predis needs PHP >= 5.4.0 or a polyfill ". - "for \SessionHandlerInterface either provided by you or an external package.\n"); -} - -// Instantiate a new client just like you would normally do. We'll prefix our session keys here. -$client = new Predis\Client($single_server, array('prefix' => 'sessions:')); - -// Set `gc_maxlifetime` so that a session will be expired after 5 seconds since last access. -$handler = new Predis\Session\SessionHandler($client, array('gc_maxlifetime' => 5)); - -// Register our session handler (it uses `session_set_save_handler()` internally). -$handler->register(); - -// Set a fixed session ID just for the sake of our example. -session_id('example_session_id'); - -session_start(); - -if (isset($_SESSION['foo'])) { - echo "Session has `foo` set to {$_SESSION['foo']}\n"; -} else { - $_SESSION['foo'] = $value = mt_rand(); - echo "Empty session, `foo` has been set with $value\n"; -} diff --git a/vendor/predis/predis/examples/SharedConfigurations.php b/vendor/predis/predis/examples/SharedConfigurations.php deleted file mode 100644 index 20ca6b5b4..000000000 --- a/vendor/predis/predis/examples/SharedConfigurations.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require __DIR__.'/../autoload.php'; - -$single_server = array( - 'host' => '127.0.0.1', - 'port' => 6379, - 'database' => 15 -); - -$multiple_servers = array( - array( - 'host' => '127.0.0.1', - 'port' => 6379, - 'database' => 15, - 'alias' => 'first', - ), - array( - 'host' => '127.0.0.1', - 'port' => 6380, - 'database' => 15, - 'alias' => 'second', - ), -); diff --git a/vendor/predis/predis/examples/SimpleDebuggableConnection.php b/vendor/predis/predis/examples/SimpleDebuggableConnection.php deleted file mode 100644 index 0d9e4b54d..000000000 --- a/vendor/predis/predis/examples/SimpleDebuggableConnection.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -use Predis\Command\CommandInterface; -use Predis\Connection\StreamConnection; - -class SimpleDebuggableConnection extends StreamConnection -{ - private $tstart = 0; - private $debugBuffer = array(); - - public function connect() - { - $this->tstart = microtime(true); - - parent::connect(); - } - - private function storeDebug(CommandInterface $command, $direction) - { - $firtsArg = $command->getArgument(0); - $timestamp = round(microtime(true) - $this->tstart, 4); - - $debug = $command->getId(); - $debug .= isset($firtsArg) ? " $firtsArg " : ' '; - $debug .= "$direction $this"; - $debug .= " [{$timestamp}s]"; - - $this->debugBuffer[] = $debug; - } - - public function writeCommand(CommandInterface $command) - { - parent::writeCommand($command); - - $this->storeDebug($command, '->'); - } - - public function readResponse(CommandInterface $command) - { - $reply = parent::readResponse($command); - $this->storeDebug($command, '<-'); - - return $reply; - } - - public function getDebugBuffer() - { - return $this->debugBuffer; - } -} - -$options = array( - 'connections' => array( - 'tcp' => 'SimpleDebuggableConnection', - ), -); - -$client = new Predis\Client($single_server, $options); -$client->set('foo', 'bar'); -$client->get('foo'); -$client->info(); - -print_r($client->getConnection()->getDebugBuffer()); - -/* OUTPUT: -Array -( - [0] => SELECT 15 -> 127.0.0.1:6379 [0.0008s] - [1] => SELECT 15 <- 127.0.0.1:6379 [0.0012s] - [2] => SET foo -> 127.0.0.1:6379 [0.0014s] - [3] => SET foo <- 127.0.0.1:6379 [0.0014s] - [4] => GET foo -> 127.0.0.1:6379 [0.0016s] - [5] => GET foo <- 127.0.0.1:6379 [0.0018s] - [6] => INFO -> 127.0.0.1:6379 [0.002s] - [7] => INFO <- 127.0.0.1:6379 [0.0025s] -) -*/ diff --git a/vendor/predis/predis/examples/SimpleSetAndGet.php b/vendor/predis/predis/examples/SimpleSetAndGet.php deleted file mode 100644 index 30820533a..000000000 --- a/vendor/predis/predis/examples/SimpleSetAndGet.php +++ /dev/null @@ -1,25 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// simple set and get scenario - -$client = new Predis\Client($single_server); - -$client->set('library', 'predis'); -$retval = $client->get('library'); - -var_dump($retval); - -/* OUTPUT -string(6) "predis" -*/ diff --git a/vendor/predis/predis/examples/TransactionWithCAS.php b/vendor/predis/predis/examples/TransactionWithCAS.php deleted file mode 100644 index 785a9db57..000000000 --- a/vendor/predis/predis/examples/TransactionWithCAS.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -require 'SharedConfigurations.php'; - -// This is an implementation of an atomic client-side ZPOP using the support for -// check-and-set (CAS) operations with MULTI/EXEC transactions, as described in -// "WATCH explained" from http://redis.io/topics/transactions -// -// First, populate your database with a tiny sample data set: -// -// ./redis-cli -// SELECT 15 -// ZADD zset 1 a -// ZADD zset 2 b -// ZADD zset 3 c - -function zpop($client, $key) -{ - $element = null; - $options = array( - 'cas' => true, // Initialize with support for CAS operations - 'watch' => $key, // Key that needs to be WATCHed to detect changes - 'retry' => 3, // Number of retries on aborted transactions, after - // which the client bails out with an exception. - ); - - $client->transaction($options, function ($tx) use ($key, &$element) { - @list($element) = $tx->zrange($key, 0, 0); - - if (isset($element)) { - $tx->multi(); // With CAS, MULTI *must* be explicitly invoked. - $tx->zrem($key, $element); - } - }); - - return $element; -} - -$client = new Predis\Client($single_server); -$zpopped = zpop($client, 'zset'); - -echo isset($zpopped) ? "ZPOPed $zpopped" : "Nothing to ZPOP!", "\n"; diff --git a/vendor/predis/predis/lib/Predis/Autoloader.php b/vendor/predis/predis/lib/Predis/Autoloader.php deleted file mode 100644 index ff5c1ef49..000000000 --- a/vendor/predis/predis/lib/Predis/Autoloader.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Implements a lightweight PSR-0 compliant autoloader. - * - * @author Eric Naeseth - * @author Daniele Alessandri - */ -class Autoloader -{ - private $directory; - private $prefix; - private $prefixLength; - - /** - * @param string $baseDirectory Base directory where the source files are located. - */ - public function __construct($baseDirectory = __DIR__) - { - $this->directory = $baseDirectory; - $this->prefix = __NAMESPACE__ . '\\'; - $this->prefixLength = strlen($this->prefix); - } - - /** - * Registers the autoloader class with the PHP SPL autoloader. - * - * @param bool $prepend Prepend the autoloader on the stack instead of appending it. - */ - public static function register($prepend = false) - { - spl_autoload_register(array(new self, 'autoload'), true, $prepend); - } - - /** - * Loads a class from a file using its fully qualified name. - * - * @param string $className Fully qualified name of a class. - */ - public function autoload($className) - { - if (0 === strpos($className, $this->prefix)) { - $parts = explode('\\', substr($className, $this->prefixLength)); - $filepath = $this->directory.DIRECTORY_SEPARATOR.implode(DIRECTORY_SEPARATOR, $parts).'.php'; - - if (is_file($filepath)) { - require($filepath); - } - } - } -} diff --git a/vendor/predis/predis/lib/Predis/BasicClientInterface.php b/vendor/predis/predis/lib/Predis/BasicClientInterface.php deleted file mode 100644 index 625f5dc09..000000000 --- a/vendor/predis/predis/lib/Predis/BasicClientInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use Predis\Command\CommandInterface; - -/** - * Defines the interface of a basic client object or abstraction that - * can send commands to Redis. - * - * @author Daniele Alessandri - */ -interface BasicClientInterface -{ - /** - * Executes the specified Redis command. - * - * @param CommandInterface $command A Redis command. - * @return mixed - */ - public function executeCommand(CommandInterface $command); -} diff --git a/vendor/predis/predis/lib/Predis/Client.php b/vendor/predis/predis/lib/Predis/Client.php deleted file mode 100644 index d501df967..000000000 --- a/vendor/predis/predis/lib/Predis/Client.php +++ /dev/null @@ -1,465 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use Predis\Command\CommandInterface; -use Predis\Command\ScriptedCommand; -use Predis\Connection\AggregatedConnectionInterface; -use Predis\Connection\ConnectionInterface; -use Predis\Connection\ConnectionFactoryInterface; -use Predis\Monitor\MonitorContext; -use Predis\Option\ClientOptions; -use Predis\Option\ClientOptionsInterface; -use Predis\Pipeline\PipelineContext; -use Predis\PubSub\PubSubContext; -use Predis\Transaction\MultiExecContext; - -/** - * Main class that exposes the most high-level interface to interact with Redis. - * - * @author Daniele Alessandri - */ -class Client implements ClientInterface -{ - const VERSION = '0.8.5'; - - private $options; - private $profile; - private $connection; - - /** - * Initializes a new client with optional connection parameters and client options. - * - * @param mixed $parameters Connection parameters for one or multiple servers. - * @param mixed $options Options that specify certain behaviours for the client. - */ - public function __construct($parameters = null, $options = null) - { - $this->options = $this->filterOptions($options); - $this->profile = $this->options->profile; - $this->connection = $this->initializeConnection($parameters); - } - - /** - * Creates an instance of Predis\Option\ClientOptions from various types of - * arguments (string, array, Predis\Profile\ServerProfile) or returns the - * passed object if it is an instance of Predis\Option\ClientOptions. - * - * @param mixed $options Client options. - * @return ClientOptions - */ - protected function filterOptions($options) - { - if (!isset($options)) { - return new ClientOptions(); - } - - if (is_array($options)) { - return new ClientOptions($options); - } - - if ($options instanceof ClientOptionsInterface) { - return $options; - } - - throw new \InvalidArgumentException("Invalid type for client options"); - } - - /** - * Initializes one or multiple connection (cluster) objects from various - * types of arguments (string, array) or returns the passed object if it - * implements Predis\Connection\ConnectionInterface. - * - * @param mixed $parameters Connection parameters or instance. - * @return ConnectionInterface - */ - protected function initializeConnection($parameters) - { - if ($parameters instanceof ConnectionInterface) { - return $parameters; - } - - if (is_array($parameters) && isset($parameters[0])) { - $options = $this->options; - $replication = isset($options->replication) && $options->replication; - $connection = $options->{$replication ? 'replication' : 'cluster'}; - - return $options->connections->createAggregated($connection, $parameters); - } - - if (is_callable($parameters)) { - $connection = call_user_func($parameters, $this->options); - - if (!$connection instanceof ConnectionInterface) { - throw new \InvalidArgumentException( - 'Callable parameters must return instances of Predis\Connection\ConnectionInterface' - ); - } - - return $connection; - } - - return $this->options->connections->create($parameters); - } - - /** - * {@inheritdoc} - */ - public function getProfile() - { - return $this->profile; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - return $this->options; - } - - /** - * Returns the connection factory object used by the client. - * - * @return ConnectionFactoryInterface - */ - public function getConnectionFactory() - { - return $this->options->connections; - } - - /** - * Returns a new instance of a client for the specified connection when the - * client is connected to a cluster. The new instance will use the same - * options of the original client. - * - * @param string $connectionID Identifier for the connection. - * @return Client - */ - public function getClientFor($connectionID) - { - if (!$connection = $this->getConnectionById($connectionID)) { - throw new \InvalidArgumentException("Invalid connection ID: '$connectionID'"); - } - - return new static($connection, $this->options); - } - - /** - * Opens the connection to the server. - */ - public function connect() - { - $this->connection->connect(); - } - - /** - * Disconnects from the server. - */ - public function disconnect() - { - $this->connection->disconnect(); - } - - /** - * Disconnects from the server. - * - * This method is an alias of disconnect(). - */ - public function quit() - { - $this->disconnect(); - } - - /** - * Checks if the underlying connection is connected to Redis. - * - * @return bool True means that the connection is open. - * False means that the connection is closed. - */ - public function isConnected() - { - return $this->connection->isConnected(); - } - - /** - * {@inheritdoc} - */ - public function getConnection() - { - return $this->connection; - } - - /** - * Retrieves a single connection out of an aggregated connections instance. - * - * @param string $connectionId Index or alias of the single connection. - * @return Connection\SingleConnectionInterface - */ - public function getConnectionById($connectionId) - { - if (!$this->connection instanceof AggregatedConnectionInterface) { - throw new NotSupportedException('Retrieving connections by ID is supported only when using aggregated connections'); - } - - return $this->connection->getConnectionById($connectionId); - } - - /** - * Creates a Redis command with the specified arguments and sends a request - * to the server. - * - * @param string $commandID Command ID. - * @param array $arguments Arguments for the command. - * @return mixed - */ - public function __call($commandID, $arguments) - { - $command = $this->createCommand($commandID, $arguments); - $response = $this->executeCommand($command); - - return $response; - } - - /** - * {@inheritdoc} - */ - public function createCommand($commandID, $arguments = array()) - { - return $this->profile->createCommand($commandID, $arguments); - } - - /** - * {@inheritdoc} - */ - public function executeCommand(CommandInterface $command) - { - $response = $this->connection->executeCommand($command); - - if ($response instanceof ResponseObjectInterface) { - if ($response instanceof ResponseErrorInterface) { - $response = $this->onResponseError($command, $response); - } - - return $response; - } - - return $command->parseResponse($response); - } - - /** - * Handles -ERR responses returned by Redis. - * - * @param CommandInterface $command The command that generated the error. - * @param ResponseErrorInterface $response The error response instance. - * @return mixed - */ - protected function onResponseError(CommandInterface $command, ResponseErrorInterface $response) - { - if ($command instanceof ScriptedCommand && $response->getErrorType() === 'NOSCRIPT') { - $eval = $this->createCommand('eval'); - $eval->setRawArguments($command->getEvalArguments()); - - $response = $this->executeCommand($eval); - - if (!$response instanceof ResponseObjectInterface) { - $response = $command->parseResponse($response); - } - - return $response; - } - - if ($this->options->exceptions) { - throw new ServerException($response->getMessage()); - } - - return $response; - } - - /** - * Calls the specified initializer method on $this with 0, 1 or 2 arguments. - * - * TODO: Invert $argv and $initializer. - * - * @param array $argv Arguments for the initializer. - * @param string $initializer The initializer method. - * @return mixed - */ - private function sharedInitializer($argv, $initializer) - { - switch (count($argv)) { - case 0: - return $this->$initializer(); - - case 1: - list($arg0) = $argv; - - return is_array($arg0) ? $this->$initializer($arg0) : $this->$initializer(null, $arg0); - - case 2: - list($arg0, $arg1) = $argv; - - return $this->$initializer($arg0, $arg1); - - default: - return $this->$initializer($this, $argv); - } - } - - /** - * Creates a new pipeline context and returns it, or returns the results of - * a pipeline executed inside the optionally provided callable object. - * - * @param mixed ... Options for the context, a callable object, or both. - * @return PipelineContext|array - */ - public function pipeline(/* arguments */) - { - return $this->sharedInitializer(func_get_args(), 'initPipeline'); - } - - /** - * Pipeline context initializer. - * - * @param array $options Options for the context. - * @param mixed $callable Optional callable object used to execute the context. - * @return PipelineContext|array - */ - protected function initPipeline(Array $options = null, $callable = null) - { - $executor = isset($options['executor']) ? $options['executor'] : null; - - if (is_callable($executor)) { - $executor = call_user_func($executor, $this, $options); - } - - $pipeline = new PipelineContext($this, $executor); - $replies = $this->pipelineExecute($pipeline, $callable); - - return $replies; - } - - /** - * Executes a pipeline context when a callable object is passed. - * - * @param PipelineContext $pipeline Pipeline context instance. - * @param mixed $callable Optional callable object used to execute the context. - * @return PipelineContext|array - */ - private function pipelineExecute(PipelineContext $pipeline, $callable) - { - return isset($callable) ? $pipeline->execute($callable) : $pipeline; - } - - /** - * Creates a new transaction context and returns it, or returns the results of - * a transaction executed inside the optionally provided callable object. - * - * @deprecated You should start using the new Client::transaction() method - * as it will replace Client::multiExec() in the next major - * version of the library. - * - * @param mixed ... Options for the context, a callable object, or both. - * @return MultiExecContext|array - */ - public function multiExec(/* arguments */) - { - return $this->sharedInitializer(func_get_args(), 'initMultiExec'); - } - - /** - * Creates a new transaction context and returns it, or returns the results of - * a transaction executed inside the optionally provided callable object. - * - * @param mixed ... Options for the context, a callable object, or both. - * @return MultiExecContext|array - */ - public function transaction(/* arguments */) - { - return $this->sharedInitializer(func_get_args(), 'initMultiExec'); - } - - /** - * Transaction context initializer. - * - * @param array $options Options for the context. - * @param mixed $callable Optional callable object used to execute the context. - * @return MultiExecContext|array - */ - protected function initMultiExec(Array $options = null, $callable = null) - { - $transaction = new MultiExecContext($this, $options ?: array()); - - return isset($callable) ? $transaction->execute($callable) : $transaction; - } - - /** - * Creates a new Publish / Subscribe context and returns it, or executes it - * inside the optionally provided callable object. - * - * @deprecated This method will change in the next major release to support - * the new PUBSUB command introduced in Redis 2.8. Please use - * Client::pubSubLoop() to create Predis\PubSub\PubSubContext - * instances from now on. - * - * @param mixed ... Options for the context, a callable object, or both. - * @return PubSubContext|array - */ - public function pubSub(/* arguments */) - { - return call_user_func_array(array($this, 'pubSubLoop'), func_get_args()); - } - - /** - * Creates a new Publish / Subscribe context and returns it, or executes it - * inside the optionally provided callable object. - * - * @param mixed ... Options for the context, a callable object, or both. - * @return PubSubContext|array - */ - public function pubSubLoop(/* arguments */) - { - return $this->sharedInitializer(func_get_args(), 'initPubSub'); - } - - /** - * Publish / Subscribe context initializer. - * - * @param array $options Options for the context. - * @param mixed $callable Optional callable object used to execute the context. - * @return PubSubContext - */ - protected function initPubSub(Array $options = null, $callable = null) - { - $pubsub = new PubSubContext($this, $options); - - if (!isset($callable)) { - return $pubsub; - } - - foreach ($pubsub as $message) { - if (call_user_func($callable, $pubsub, $message) === false) { - $pubsub->closeContext(); - } - } - } - - /** - * Returns a new monitor context. - * - * @return MonitorContext - */ - public function monitor() - { - return new MonitorContext($this); - } -} diff --git a/vendor/predis/predis/lib/Predis/ClientException.php b/vendor/predis/predis/lib/Predis/ClientException.php deleted file mode 100644 index 6c07aaf0d..000000000 --- a/vendor/predis/predis/lib/Predis/ClientException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Exception class that identifies client-side errors. - * - * @author Daniele Alessandri - */ -class ClientException extends PredisException -{ -} diff --git a/vendor/predis/predis/lib/Predis/ClientInterface.php b/vendor/predis/predis/lib/Predis/ClientInterface.php deleted file mode 100644 index b4b3d47af..000000000 --- a/vendor/predis/predis/lib/Predis/ClientInterface.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use Predis\Connection\ConnectionInterface; -use Predis\Option\ClientOptionsInterface; -use Predis\Profile\ServerProfileInterface; - -/** - * Interface defining the most important parts needed to create an - * high-level Redis client object that can interact with other - * building blocks of Predis. - * - * @author Daniele Alessandri - */ -interface ClientInterface extends BasicClientInterface -{ - /** - * Returns the server profile used by the client. - * - * @return ServerProfileInterface - */ - public function getProfile(); - - /** - * Returns the client options specified upon initialization. - * - * @return ClientOptionsInterface - */ - public function getOptions(); - - /** - * Opens the connection to the server. - */ - public function connect(); - - /** - * Disconnects from the server. - */ - public function disconnect(); - - /** - * Returns the underlying connection instance. - * - * @return ConnectionInterface - */ - public function getConnection(); - - /** - * Creates a new instance of the specified Redis command. - * - * @param string $method The name of a Redis command. - * @param array $arguments The arguments for the command. - * @return Command\CommandInterface - */ - public function createCommand($method, $arguments = array()); -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/CommandHashStrategyInterface.php b/vendor/predis/predis/lib/Predis/Cluster/CommandHashStrategyInterface.php deleted file mode 100644 index 810700b6d..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/CommandHashStrategyInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster; - -use Predis\Command\CommandInterface; - -/** - * Interface for classes defining the strategy used to calculate an hash - * out of keys extracted from supported commands. - * - * This is mostly useful to support clustering via client-side sharding. - * - * @author Daniele Alessandri - */ -interface CommandHashStrategyInterface -{ - /** - * Returns the hash for the given command using the specified algorithm, or null - * if the command cannot be hashed. - * - * @param CommandInterface $command Command to be hashed. - * @return int - */ - public function getHash(CommandInterface $command); - - /** - * Returns the hash for the given key using the specified algorithm. - * - * @param string $key Key to be hashed. - * @return string - */ - public function getKeyHash($key); -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php b/vendor/predis/predis/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php deleted file mode 100644 index 639541230..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/Distribution/DistributionStrategyInterface.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Distribution; - -use Predis\Cluster\Hash\HashGeneratorInterface; - -/** - * A distributor implements the logic to automatically distribute - * keys among several nodes for client-side sharding. - * - * @author Daniele Alessandri - */ -interface DistributionStrategyInterface -{ - /** - * Adds a node to the distributor with an optional weight. - * - * @param mixed $node Node object. - * @param int $weight Weight for the node. - */ - public function add($node, $weight = null); - - /** - * Removes a node from the distributor. - * - * @param mixed $node Node object. - */ - public function remove($node); - - /** - * Gets a node from the distributor using the computed hash of a key. - * - * @param mixed $key - * @return mixed - */ - public function get($key); - - /** - * Returns the underlying hash generator instance. - * - * @return HashGeneratorInterface - */ - public function getHashGenerator(); -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Distribution/EmptyRingException.php b/vendor/predis/predis/lib/Predis/Cluster/Distribution/EmptyRingException.php deleted file mode 100644 index ed08ca3eb..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/Distribution/EmptyRingException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Distribution; - -/** - * Exception class that identifies empty rings. - * - * @author Daniele Alessandri - */ -class EmptyRingException extends \Exception -{ -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Distribution/HashRing.php b/vendor/predis/predis/lib/Predis/Cluster/Distribution/HashRing.php deleted file mode 100644 index b8dd12ab5..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/Distribution/HashRing.php +++ /dev/null @@ -1,246 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Distribution; - -use Predis\Cluster\Hash\HashGeneratorInterface; - -/** - * This class implements an hashring-based distributor that uses the same - * algorithm of memcache to distribute keys in a cluster using client-side - * sharding. - * - * @author Daniele Alessandri - * @author Lorenzo Castelli - */ -class HashRing implements DistributionStrategyInterface, HashGeneratorInterface -{ - const DEFAULT_REPLICAS = 128; - const DEFAULT_WEIGHT = 100; - - private $ring; - private $ringKeys; - private $ringKeysCount; - private $replicas; - private $nodeHashCallback; - private $nodes = array(); - - /** - * @param int $replicas Number of replicas in the ring. - * @param mixed $nodeHashCallback Callback returning the string used to calculate the hash of a node. - */ - public function __construct($replicas = self::DEFAULT_REPLICAS, $nodeHashCallback = null) - { - $this->replicas = $replicas; - $this->nodeHashCallback = $nodeHashCallback; - } - - /** - * Adds a node to the ring with an optional weight. - * - * @param mixed $node Node object. - * @param int $weight Weight for the node. - */ - public function add($node, $weight = null) - { - // In case of collisions in the hashes of the nodes, the node added - // last wins, thus the order in which nodes are added is significant. - $this->nodes[] = array('object' => $node, 'weight' => (int) $weight ?: $this::DEFAULT_WEIGHT); - $this->reset(); - } - - /** - * {@inheritdoc} - */ - public function remove($node) - { - // A node is removed by resetting the ring so that it's recreated from - // scratch, in order to reassign possible hashes with collisions to the - // right node according to the order in which they were added in the - // first place. - for ($i = 0; $i < count($this->nodes); ++$i) { - if ($this->nodes[$i]['object'] === $node) { - array_splice($this->nodes, $i, 1); - $this->reset(); - break; - } - } - } - - /** - * Resets the distributor. - */ - private function reset() - { - unset( - $this->ring, - $this->ringKeys, - $this->ringKeysCount - ); - } - - /** - * Returns the initialization status of the distributor. - * - * @return bool - */ - private function isInitialized() - { - return isset($this->ringKeys); - } - - /** - * Calculates the total weight of all the nodes in the distributor. - * - * @return int - */ - private function computeTotalWeight() - { - $totalWeight = 0; - - foreach ($this->nodes as $node) { - $totalWeight += $node['weight']; - } - - return $totalWeight; - } - - /** - * Initializes the distributor. - */ - private function initialize() - { - if ($this->isInitialized()) { - return; - } - - if (!$this->nodes) { - throw new EmptyRingException('Cannot initialize empty hashring'); - } - - $this->ring = array(); - $totalWeight = $this->computeTotalWeight(); - $nodesCount = count($this->nodes); - - foreach ($this->nodes as $node) { - $weightRatio = $node['weight'] / $totalWeight; - $this->addNodeToRing($this->ring, $node, $nodesCount, $this->replicas, $weightRatio); - } - - ksort($this->ring, SORT_NUMERIC); - $this->ringKeys = array_keys($this->ring); - $this->ringKeysCount = count($this->ringKeys); - } - - /** - * Implements the logic needed to add a node to the hashring. - * - * @param array $ring Source hashring. - * @param mixed $node Node object to be added. - * @param int $totalNodes Total number of nodes. - * @param int $replicas Number of replicas in the ring. - * @param float $weightRatio Weight ratio for the node. - */ - protected function addNodeToRing(&$ring, $node, $totalNodes, $replicas, $weightRatio) - { - $nodeObject = $node['object']; - $nodeHash = $this->getNodeHash($nodeObject); - $replicas = (int) round($weightRatio * $totalNodes * $replicas); - - for ($i = 0; $i < $replicas; $i++) { - $key = crc32("$nodeHash:$i"); - $ring[$key] = $nodeObject; - } - } - - /** - * {@inheritdoc} - */ - protected function getNodeHash($nodeObject) - { - if ($this->nodeHashCallback === null) { - return (string) $nodeObject; - } - - return call_user_func($this->nodeHashCallback, $nodeObject); - } - - /** - * Calculates the hash for the specified value. - * - * @param string $value Input value. - * @return int - */ - public function hash($value) - { - return crc32($value); - } - - /** - * {@inheritdoc} - */ - public function get($key) - { - return $this->ring[$this->getNodeKey($key)]; - } - - /** - * Calculates the corrisponding key of a node distributed in the hashring. - * - * @param int $key Computed hash of a key. - * @return int - */ - private function getNodeKey($key) - { - $this->initialize(); - $ringKeys = $this->ringKeys; - $upper = $this->ringKeysCount - 1; - $lower = 0; - - while ($lower <= $upper) { - $index = ($lower + $upper) >> 1; - $item = $ringKeys[$index]; - - if ($item > $key) { - $upper = $index - 1; - } elseif ($item < $key) { - $lower = $index + 1; - } else { - return $item; - } - } - - return $ringKeys[$this->wrapAroundStrategy($upper, $lower, $this->ringKeysCount)]; - } - - /** - * Implements a strategy to deal with wrap-around errors during binary searches. - * - * @param int $upper - * @param int $lower - * @param int $ringKeysCount - * @return int - */ - protected function wrapAroundStrategy($upper, $lower, $ringKeysCount) - { - // Binary search for the last item in ringkeys with a value less or - // equal to the key. If no such item exists, return the last item. - return $upper >= 0 ? $upper : $ringKeysCount - 1; - } - - /** - * {@inheritdoc} - */ - public function getHashGenerator() - { - return $this; - } -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Distribution/KetamaPureRing.php b/vendor/predis/predis/lib/Predis/Cluster/Distribution/KetamaPureRing.php deleted file mode 100644 index 9edbe4df4..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/Distribution/KetamaPureRing.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Distribution; - -/** - * This class implements an hashring-based distributor that uses the same - * algorithm of libketama to distribute keys in a cluster using client-side - * sharding. - * - * @author Daniele Alessandri - * @author Lorenzo Castelli - */ -class KetamaPureRing extends HashRing -{ - const DEFAULT_REPLICAS = 160; - - /** - * @param mixed $nodeHashCallback Callback returning the string used to calculate the hash of a node. - */ - public function __construct($nodeHashCallback = null) - { - parent::__construct($this::DEFAULT_REPLICAS, $nodeHashCallback); - } - - /** - * {@inheritdoc} - */ - protected function addNodeToRing(&$ring, $node, $totalNodes, $replicas, $weightRatio) - { - $nodeObject = $node['object']; - $nodeHash = $this->getNodeHash($nodeObject); - $replicas = (int) floor($weightRatio * $totalNodes * ($replicas / 4)); - - for ($i = 0; $i < $replicas; $i++) { - $unpackedDigest = unpack('V4', md5("$nodeHash-$i", true)); - - foreach ($unpackedDigest as $key) { - $ring[$key] = $nodeObject; - } - } - } - - /** - * {@inheritdoc} - */ - public function hash($value) - { - $hash = unpack('V', md5($value, true)); - - return $hash[1]; - } - - /** - * {@inheritdoc} - */ - protected function wrapAroundStrategy($upper, $lower, $ringKeysCount) - { - // Binary search for the first item in _ringkeys with a value greater - // or equal to the key. If no such item exists, return the first item. - return $lower < $ringKeysCount ? $lower : 0; - } -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Hash/CRC16HashGenerator.php b/vendor/predis/predis/lib/Predis/Cluster/Hash/CRC16HashGenerator.php deleted file mode 100644 index f4c17f2d7..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/Hash/CRC16HashGenerator.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Hash; - -/** - * This class implements the CRC-CCITT-16 algorithm used by redis-cluster. - * - * @author Daniele Alessandri - */ -class CRC16HashGenerator implements HashGeneratorInterface -{ - private static $CCITT_16 = array( - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, - 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, - 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, - 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, - 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, - 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, - 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, - 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, - 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, - 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, - 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, - 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, - 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, - 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, - 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, - 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, - 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, - 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, - 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, - 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, - 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, - 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, - 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0, - ); - - /** - * {@inheritdoc} - */ - public function hash($value) - { - // CRC-CCITT-16 algorithm - $crc = 0; - $CCITT_16 = self::$CCITT_16; - $strlen = strlen($value); - - for ($i = 0; $i < $strlen; $i++) { - $crc = (($crc << 8) ^ $CCITT_16[($crc >> 8) ^ ord($value[$i])]) & 0xFFFF; - } - - return $crc; - } -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/Hash/HashGeneratorInterface.php b/vendor/predis/predis/lib/Predis/Cluster/Hash/HashGeneratorInterface.php deleted file mode 100644 index 62e46cf7d..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/Hash/HashGeneratorInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Hash; - -/** - * A generator of node keys implements the logic used to calculate the hash of - * a key to distribute the respective operations among nodes. - * - * @author Daniele Alessandri - */ -interface HashGeneratorInterface -{ - /** - * Generates an hash that is used by the distributor algorithm - * - * @param string $value Value used to generate the hash. - * @return int - */ - public function hash($value); -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/PredisClusterHashStrategy.php b/vendor/predis/predis/lib/Predis/Cluster/PredisClusterHashStrategy.php deleted file mode 100644 index 46d8f1a25..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/PredisClusterHashStrategy.php +++ /dev/null @@ -1,389 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster; - -use Predis\Cluster\Hash\HashGeneratorInterface; -use Predis\Command\CommandInterface; -use Predis\Command\ScriptedCommand; - -/** - * Default class used by Predis for client-side sharding to calculate - * hashes out of keys of supported commands. - * - * @author Daniele Alessandri - */ -class PredisClusterHashStrategy implements CommandHashStrategyInterface -{ - private $commands; - private $hashGenerator; - - /** - * @param HashGeneratorInterface $hashGenerator Hash generator instance. - */ - public function __construct(HashGeneratorInterface $hashGenerator) - { - $this->commands = $this->getDefaultCommands(); - $this->hashGenerator = $hashGenerator; - } - - /** - * Returns the default map of supported commands with their handlers. - * - * @return array - */ - protected function getDefaultCommands() - { - $keyIsFirstArgument = array($this, 'getKeyFromFirstArgument'); - $keysAreAllArguments = array($this, 'getKeyFromAllArguments'); - - return array( - /* commands operating on the key space */ - 'EXISTS' => $keyIsFirstArgument, - 'DEL' => $keysAreAllArguments, - 'TYPE' => $keyIsFirstArgument, - 'EXPIRE' => $keyIsFirstArgument, - 'EXPIREAT' => $keyIsFirstArgument, - 'PERSIST' => $keyIsFirstArgument, - 'PEXPIRE' => $keyIsFirstArgument, - 'PEXPIREAT' => $keyIsFirstArgument, - 'TTL' => $keyIsFirstArgument, - 'PTTL' => $keyIsFirstArgument, - 'SORT' => $keyIsFirstArgument, // TODO - 'DUMP' => $keyIsFirstArgument, - 'RESTORE' => $keyIsFirstArgument, - - /* commands operating on string values */ - 'APPEND' => $keyIsFirstArgument, - 'DECR' => $keyIsFirstArgument, - 'DECRBY' => $keyIsFirstArgument, - 'GET' => $keyIsFirstArgument, - 'GETBIT' => $keyIsFirstArgument, - 'MGET' => $keysAreAllArguments, - 'SET' => $keyIsFirstArgument, - 'GETRANGE' => $keyIsFirstArgument, - 'GETSET' => $keyIsFirstArgument, - 'INCR' => $keyIsFirstArgument, - 'INCRBY' => $keyIsFirstArgument, - 'SETBIT' => $keyIsFirstArgument, - 'SETEX' => $keyIsFirstArgument, - 'MSET' => array($this, 'getKeyFromInterleavedArguments'), - 'MSETNX' => array($this, 'getKeyFromInterleavedArguments'), - 'SETNX' => $keyIsFirstArgument, - 'SETRANGE' => $keyIsFirstArgument, - 'STRLEN' => $keyIsFirstArgument, - 'SUBSTR' => $keyIsFirstArgument, - 'BITOP' => array($this, 'getKeyFromBitOp'), - 'BITCOUNT' => $keyIsFirstArgument, - - /* commands operating on lists */ - 'LINSERT' => $keyIsFirstArgument, - 'LINDEX' => $keyIsFirstArgument, - 'LLEN' => $keyIsFirstArgument, - 'LPOP' => $keyIsFirstArgument, - 'RPOP' => $keyIsFirstArgument, - 'RPOPLPUSH' => $keysAreAllArguments, - 'BLPOP' => array($this, 'getKeyFromBlockingListCommands'), - 'BRPOP' => array($this, 'getKeyFromBlockingListCommands'), - 'BRPOPLPUSH' => array($this, 'getKeyFromBlockingListCommands'), - 'LPUSH' => $keyIsFirstArgument, - 'LPUSHX' => $keyIsFirstArgument, - 'RPUSH' => $keyIsFirstArgument, - 'RPUSHX' => $keyIsFirstArgument, - 'LRANGE' => $keyIsFirstArgument, - 'LREM' => $keyIsFirstArgument, - 'LSET' => $keyIsFirstArgument, - 'LTRIM' => $keyIsFirstArgument, - - /* commands operating on sets */ - 'SADD' => $keyIsFirstArgument, - 'SCARD' => $keyIsFirstArgument, - 'SDIFF' => $keysAreAllArguments, - 'SDIFFSTORE' => $keysAreAllArguments, - 'SINTER' => $keysAreAllArguments, - 'SINTERSTORE' => $keysAreAllArguments, - 'SUNION' => $keysAreAllArguments, - 'SUNIONSTORE' => $keysAreAllArguments, - 'SISMEMBER' => $keyIsFirstArgument, - 'SMEMBERS' => $keyIsFirstArgument, - 'SSCAN' => $keyIsFirstArgument, - 'SPOP' => $keyIsFirstArgument, - 'SRANDMEMBER' => $keyIsFirstArgument, - 'SREM' => $keyIsFirstArgument, - - /* commands operating on sorted sets */ - 'ZADD' => $keyIsFirstArgument, - 'ZCARD' => $keyIsFirstArgument, - 'ZCOUNT' => $keyIsFirstArgument, - 'ZINCRBY' => $keyIsFirstArgument, - 'ZINTERSTORE' => array($this, 'getKeyFromZsetAggregationCommands'), - 'ZRANGE' => $keyIsFirstArgument, - 'ZRANGEBYSCORE' => $keyIsFirstArgument, - 'ZRANK' => $keyIsFirstArgument, - 'ZREM' => $keyIsFirstArgument, - 'ZREMRANGEBYRANK' => $keyIsFirstArgument, - 'ZREMRANGEBYSCORE' => $keyIsFirstArgument, - 'ZREVRANGE' => $keyIsFirstArgument, - 'ZREVRANGEBYSCORE' => $keyIsFirstArgument, - 'ZREVRANK' => $keyIsFirstArgument, - 'ZSCORE' => $keyIsFirstArgument, - 'ZUNIONSTORE' => array($this, 'getKeyFromZsetAggregationCommands'), - 'ZSCAN' => $keyIsFirstArgument, - - /* commands operating on hashes */ - 'HDEL' => $keyIsFirstArgument, - 'HEXISTS' => $keyIsFirstArgument, - 'HGET' => $keyIsFirstArgument, - 'HGETALL' => $keyIsFirstArgument, - 'HMGET' => $keyIsFirstArgument, - 'HMSET' => $keyIsFirstArgument, - 'HINCRBY' => $keyIsFirstArgument, - 'HINCRBYFLOAT' => $keyIsFirstArgument, - 'HKEYS' => $keyIsFirstArgument, - 'HLEN' => $keyIsFirstArgument, - 'HSET' => $keyIsFirstArgument, - 'HSETNX' => $keyIsFirstArgument, - 'HVALS' => $keyIsFirstArgument, - 'HSCAN' => $keyIsFirstArgument, - - /* scripting */ - 'EVAL' => array($this, 'getKeyFromScriptingCommands'), - 'EVALSHA' => array($this, 'getKeyFromScriptingCommands'), - ); - } - - /** - * Returns the list of IDs for the supported commands. - * - * @return array - */ - public function getSupportedCommands() - { - return array_keys($this->commands); - } - - /** - * Sets an handler for the specified command ID. - * - * The signature of the callback must have a single parameter - * of type Predis\Command\CommandInterface. - * - * When the callback argument is omitted or NULL, the previously - * associated handler for the specified command ID is removed. - * - * @param string $commandId The ID of the command to be handled. - * @param mixed $callback A valid callable object or NULL. - */ - public function setCommandHandler($commandId, $callback = null) - { - $commandId = strtoupper($commandId); - - if (!isset($callback)) { - unset($this->commands[$commandId]); - - return; - } - - if (!is_callable($callback)) { - throw new \InvalidArgumentException("Callback must be a valid callable object or NULL"); - } - - $this->commands[$commandId] = $callback; - } - - /** - * Extracts the key from the first argument of a command instance. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromFirstArgument(CommandInterface $command) - { - return $command->getArgument(0); - } - - /** - * Extracts the key from a command with multiple keys only when all keys - * in the arguments array produce the same hash. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromAllArguments(CommandInterface $command) - { - $arguments = $command->getArguments(); - - if ($this->checkSameHashForKeys($arguments)) { - return $arguments[0]; - } - } - - /** - * Extracts the key from a command with multiple keys only when all keys - * in the arguments array produce the same hash. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromInterleavedArguments(CommandInterface $command) - { - $arguments = $command->getArguments(); - $keys = array(); - - for ($i = 0; $i < count($arguments); $i += 2) { - $keys[] = $arguments[$i]; - } - - if ($this->checkSameHashForKeys($keys)) { - return $arguments[0]; - } - } - - /** - * Extracts the key from BLPOP and BRPOP commands. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromBlockingListCommands(CommandInterface $command) - { - $arguments = $command->getArguments(); - - if ($this->checkSameHashForKeys(array_slice($arguments, 0, count($arguments) - 1))) { - return $arguments[0]; - } - } - - /** - * Extracts the key from BITOP command. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromBitOp(CommandInterface $command) - { - $arguments = $command->getArguments(); - - if ($this->checkSameHashForKeys(array_slice($arguments, 1, count($arguments)))) { - return $arguments[1]; - } - } - - /** - * Extracts the key from ZINTERSTORE and ZUNIONSTORE commands. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromZsetAggregationCommands(CommandInterface $command) - { - $arguments = $command->getArguments(); - $keys = array_merge(array($arguments[0]), array_slice($arguments, 2, $arguments[1])); - - if ($this->checkSameHashForKeys($keys)) { - return $arguments[0]; - } - } - - /** - * Extracts the key from EVAL and EVALSHA commands. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromScriptingCommands(CommandInterface $command) - { - if ($command instanceof ScriptedCommand) { - $keys = $command->getKeys(); - } else { - $keys = array_slice($args = $command->getArguments(), 2, $args[1]); - } - - if ($keys && $this->checkSameHashForKeys($keys)) { - return $keys[0]; - } - } - - /** - * {@inheritdoc} - */ - public function getHash(CommandInterface $command) - { - $hash = $command->getHash(); - - if (!isset($hash) && isset($this->commands[$cmdID = $command->getId()])) { - $key = call_user_func($this->commands[$cmdID], $command); - - if (isset($key)) { - $hash = $this->getKeyHash($key); - $command->setHash($hash); - } - } - - return $hash; - } - - /** - * {@inheritdoc} - */ - public function getKeyHash($key) - { - $key = $this->extractKeyTag($key); - $hash = $this->hashGenerator->hash($key); - - return $hash; - } - - /** - * Checks if the specified array of keys will generate the same hash. - * - * @param array $keys Array of keys. - * @return bool - */ - protected function checkSameHashForKeys(Array $keys) - { - if (!$count = count($keys)) { - return false; - } - - $currentKey = $this->extractKeyTag($keys[0]); - - for ($i = 1; $i < $count; $i++) { - $nextKey = $this->extractKeyTag($keys[$i]); - - if ($currentKey !== $nextKey) { - return false; - } - - $currentKey = $nextKey; - } - - return true; - } - - /** - * Returns only the hashable part of a key (delimited by "{...}"), or the - * whole key if a key tag is not found in the string. - * - * @param string $key A key. - * @return string - */ - protected function extractKeyTag($key) - { - if (false !== $start = strpos($key, '{')) { - if (false !== $end = strpos($key, '}', $start)) { - $key = substr($key, ++$start, $end - $start); - } - } - - return $key; - } -} diff --git a/vendor/predis/predis/lib/Predis/Cluster/RedisClusterHashStrategy.php b/vendor/predis/predis/lib/Predis/Cluster/RedisClusterHashStrategy.php deleted file mode 100644 index a048c4ae8..000000000 --- a/vendor/predis/predis/lib/Predis/Cluster/RedisClusterHashStrategy.php +++ /dev/null @@ -1,292 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster; - -use Predis\Cluster\Hash\CRC16HashGenerator; -use Predis\Command\CommandInterface; -use Predis\Command\ScriptedCommand; - -/** - * Default class used by Predis to calculate hashes out of keys of - * commands supported by redis-cluster. - * - * @author Daniele Alessandri - */ -class RedisClusterHashStrategy implements CommandHashStrategyInterface -{ - private $commands; - private $hashGenerator; - - /** - * - */ - public function __construct() - { - $this->commands = $this->getDefaultCommands(); - $this->hashGenerator = new CRC16HashGenerator(); - } - - /** - * Returns the default map of supported commands with their handlers. - * - * @return array - */ - protected function getDefaultCommands() - { - $keyIsFirstArgument = array($this, 'getKeyFromFirstArgument'); - - return array( - /* commands operating on the key space */ - 'EXISTS' => $keyIsFirstArgument, - 'DEL' => array($this, 'getKeyFromAllArguments'), - 'TYPE' => $keyIsFirstArgument, - 'EXPIRE' => $keyIsFirstArgument, - 'EXPIREAT' => $keyIsFirstArgument, - 'PERSIST' => $keyIsFirstArgument, - 'PEXPIRE' => $keyIsFirstArgument, - 'PEXPIREAT' => $keyIsFirstArgument, - 'TTL' => $keyIsFirstArgument, - 'PTTL' => $keyIsFirstArgument, - 'SORT' => $keyIsFirstArgument, // TODO - - /* commands operating on string values */ - 'APPEND' => $keyIsFirstArgument, - 'DECR' => $keyIsFirstArgument, - 'DECRBY' => $keyIsFirstArgument, - 'GET' => $keyIsFirstArgument, - 'GETBIT' => $keyIsFirstArgument, - 'MGET' => array($this, 'getKeyFromAllArguments'), - 'SET' => $keyIsFirstArgument, - 'GETRANGE' => $keyIsFirstArgument, - 'GETSET' => $keyIsFirstArgument, - 'INCR' => $keyIsFirstArgument, - 'INCRBY' => $keyIsFirstArgument, - 'SETBIT' => $keyIsFirstArgument, - 'SETEX' => $keyIsFirstArgument, - 'MSET' => array($this, 'getKeyFromInterleavedArguments'), - 'MSETNX' => array($this, 'getKeyFromInterleavedArguments'), - 'SETNX' => $keyIsFirstArgument, - 'SETRANGE' => $keyIsFirstArgument, - 'STRLEN' => $keyIsFirstArgument, - 'SUBSTR' => $keyIsFirstArgument, - 'BITCOUNT' => $keyIsFirstArgument, - - /* commands operating on lists */ - 'LINSERT' => $keyIsFirstArgument, - 'LINDEX' => $keyIsFirstArgument, - 'LLEN' => $keyIsFirstArgument, - 'LPOP' => $keyIsFirstArgument, - 'RPOP' => $keyIsFirstArgument, - 'BLPOP' => array($this, 'getKeyFromBlockingListCommands'), - 'BRPOP' => array($this, 'getKeyFromBlockingListCommands'), - 'LPUSH' => $keyIsFirstArgument, - 'LPUSHX' => $keyIsFirstArgument, - 'RPUSH' => $keyIsFirstArgument, - 'RPUSHX' => $keyIsFirstArgument, - 'LRANGE' => $keyIsFirstArgument, - 'LREM' => $keyIsFirstArgument, - 'LSET' => $keyIsFirstArgument, - 'LTRIM' => $keyIsFirstArgument, - - /* commands operating on sets */ - 'SADD' => $keyIsFirstArgument, - 'SCARD' => $keyIsFirstArgument, - 'SISMEMBER' => $keyIsFirstArgument, - 'SMEMBERS' => $keyIsFirstArgument, - 'SSCAN' => $keyIsFirstArgument, - 'SPOP' => $keyIsFirstArgument, - 'SRANDMEMBER' => $keyIsFirstArgument, - 'SREM' => $keyIsFirstArgument, - - /* commands operating on sorted sets */ - 'ZADD' => $keyIsFirstArgument, - 'ZCARD' => $keyIsFirstArgument, - 'ZCOUNT' => $keyIsFirstArgument, - 'ZINCRBY' => $keyIsFirstArgument, - 'ZRANGE' => $keyIsFirstArgument, - 'ZRANGEBYSCORE' => $keyIsFirstArgument, - 'ZRANK' => $keyIsFirstArgument, - 'ZREM' => $keyIsFirstArgument, - 'ZREMRANGEBYRANK' => $keyIsFirstArgument, - 'ZREMRANGEBYSCORE' => $keyIsFirstArgument, - 'ZREVRANGE' => $keyIsFirstArgument, - 'ZREVRANGEBYSCORE' => $keyIsFirstArgument, - 'ZREVRANK' => $keyIsFirstArgument, - 'ZSCORE' => $keyIsFirstArgument, - 'ZSCAN' => $keyIsFirstArgument, - - /* commands operating on hashes */ - 'HDEL' => $keyIsFirstArgument, - 'HEXISTS' => $keyIsFirstArgument, - 'HGET' => $keyIsFirstArgument, - 'HGETALL' => $keyIsFirstArgument, - 'HMGET' => $keyIsFirstArgument, - 'HMSET' => $keyIsFirstArgument, - 'HINCRBY' => $keyIsFirstArgument, - 'HINCRBYFLOAT' => $keyIsFirstArgument, - 'HKEYS' => $keyIsFirstArgument, - 'HLEN' => $keyIsFirstArgument, - 'HSET' => $keyIsFirstArgument, - 'HSETNX' => $keyIsFirstArgument, - 'HVALS' => $keyIsFirstArgument, - 'HSCAN' => $keyIsFirstArgument, - - /* scripting */ - 'EVAL' => array($this, 'getKeyFromScriptingCommands'), - 'EVALSHA' => array($this, 'getKeyFromScriptingCommands'), - ); - } - - /** - * Returns the list of IDs for the supported commands. - * - * @return array - */ - public function getSupportedCommands() - { - return array_keys($this->commands); - } - - /** - * Sets an handler for the specified command ID. - * - * The signature of the callback must have a single parameter - * of type Predis\Command\CommandInterface. - * - * When the callback argument is omitted or NULL, the previously - * associated handler for the specified command ID is removed. - * - * @param string $commandId The ID of the command to be handled. - * @param mixed $callback A valid callable object or NULL. - */ - public function setCommandHandler($commandId, $callback = null) - { - $commandId = strtoupper($commandId); - - if (!isset($callback)) { - unset($this->commands[$commandId]); - - return; - } - - if (!is_callable($callback)) { - throw new \InvalidArgumentException("Callback must be a valid callable object or NULL"); - } - - $this->commands[$commandId] = $callback; - } - - /** - * Extracts the key from the first argument of a command instance. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromFirstArgument(CommandInterface $command) - { - return $command->getArgument(0); - } - - /** - * Extracts the key from a command that can accept multiple keys ensuring - * that only one key is actually specified to comply with redis-cluster. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromAllArguments(CommandInterface $command) - { - $arguments = $command->getArguments(); - - if (count($arguments) === 1) { - return $arguments[0]; - } - } - - /** - * Extracts the key from a command that can accept multiple keys ensuring - * that only one key is actually specified to comply with redis-cluster. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromInterleavedArguments(CommandInterface $command) - { - $arguments = $command->getArguments(); - - if (count($arguments) === 2) { - return $arguments[0]; - } - } - - /** - * Extracts the key from BLPOP and BRPOP commands ensuring that only one key - * is actually specified to comply with redis-cluster. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromBlockingListCommands(CommandInterface $command) - { - $arguments = $command->getArguments(); - - if (count($arguments) === 2) { - return $arguments[0]; - } - } - - /** - * Extracts the key from EVAL and EVALSHA commands. - * - * @param CommandInterface $command Command instance. - * @return string - */ - protected function getKeyFromScriptingCommands(CommandInterface $command) - { - if ($command instanceof ScriptedCommand) { - $keys = $command->getKeys(); - } else { - $keys = array_slice($args = $command->getArguments(), 2, $args[1]); - } - - if (count($keys) === 1) { - return $keys[0]; - } - } - - /** - * {@inheritdoc} - */ - public function getHash(CommandInterface $command) - { - $hash = $command->getHash(); - - if (!isset($hash) && isset($this->commands[$cmdID = $command->getId()])) { - $key = call_user_func($this->commands[$cmdID], $command); - - if (isset($key)) { - $hash = $this->hashGenerator->hash($key); - $command->setHash($hash); - } - } - - return $hash; - } - - /** - * {@inheritdoc} - */ - public function getKeyHash($key) - { - return $this->hashGenerator->hash($key); - } -} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/CursorBasedIterator.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/CursorBasedIterator.php deleted file mode 100644 index 787cd17eb..000000000 --- a/vendor/predis/predis/lib/Predis/Collection/Iterator/CursorBasedIterator.php +++ /dev/null @@ -1,189 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use Iterator; -use Predis\ClientInterface; -use Predis\NotSupportedException; - -/** - * Provides the base implementation for a fully-rewindable PHP iterator - * that can incrementally iterate over cursor-based collections stored - * on Redis using commands in the `SCAN` family. - * - * Given their incremental nature with multiple fetches, these kind of - * iterators offer limited guarantees about the returned elements because - * the collection can change several times during the iteration process. - * - * @see http://redis.io/commands/scan - * - * @author Daniele Alessandri - */ -abstract class CursorBasedIterator implements Iterator -{ - protected $client; - protected $match; - protected $count; - - protected $valid; - protected $fetchmore; - protected $elements; - protected $cursor; - protected $position; - protected $current; - - /** - * @param ClientInterface $client Client connected to Redis. - * @param string $match Pattern to match during the server-side iteration. - * @param int $count Hints used by Redis to compute the number of results per iteration. - */ - public function __construct(ClientInterface $client, $match = null, $count = null) - { - $this->client = $client; - $this->match = $match; - $this->count = $count; - - $this->reset(); - } - - /** - * Ensures that the client instance supports the specified Redis - * command required to fetch elements from the server to perform - * the iteration. - * - * @param ClientInterface $client Client connected to Redis. - * @param string $commandID Command ID. - */ - protected function requiredCommand(ClientInterface $client, $commandID) - { - if (!$client->getProfile()->supportsCommand($commandID)) { - throw new NotSupportedException("The specified server profile does not support the `$commandID` command."); - } - } - - /** - * Resets the inner state of the iterator. - */ - protected function reset() - { - $this->valid = true; - $this->fetchmore = true; - $this->elements = array(); - $this->cursor = 0; - $this->position = -1; - $this->current = null; - } - - /** - * Returns an array of options for the `SCAN` command. - * - * @return array - */ - protected function getScanOptions() - { - $options = array(); - - if (strlen($this->match) > 0) { - $options['MATCH'] = $this->match; - } - - if ($this->count > 0) { - $options['COUNT'] = $this->count; - } - - return $options; - } - - /** - * Fetches a new set of elements from the remote collection, - * effectively advancing the iteration process. - * - * @return array - */ - abstract protected function executeCommand(); - - /** - * Populates the local buffer of elements fetched from the - * server during the iteration. - */ - protected function fetch() - { - list($cursor, $elements) = $this->executeCommand(); - - if (!$cursor) { - $this->fetchmore = false; - } - - $this->cursor = $cursor; - $this->elements = $elements; - } - - /** - * Extracts next values for key() and current(). - */ - protected function extractNext() - { - $this->position++; - $this->current = array_shift($this->elements); - } - - /** - * {@inheritdoc} - */ - public function rewind() - { - $this->reset(); - $this->next(); - } - - /** - * {@inheritdoc} - */ - public function current() - { - return $this->current; - } - - /** - * {@inheritdoc} - */ - public function key() - { - return $this->position; - } - - /** - * {@inheritdoc} - */ - public function next() - { - if (!$this->elements && $this->fetchmore) { - $this->fetch(); - } - - if ($this->elements) { - $this->extractNext(); - } elseif ($this->cursor) { - $this->next(); - } else { - $this->valid = false; - } - } - - /** - * {@inheritdoc} - */ - public function valid() - { - return $this->valid; - } -} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/HashKey.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/HashKey.php deleted file mode 100644 index 6fa3d9b9c..000000000 --- a/vendor/predis/predis/lib/Predis/Collection/Iterator/HashKey.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use Predis\ClientInterface; - -/** - * Abstracts the iteration of fields and values of an hash - * by leveraging the HSCAN command (Redis >= 2.8) wrapped - * in a fully-rewindable PHP iterator. - * - * @author Daniele Alessandri - * @link http://redis.io/commands/scan - */ -class HashKey extends CursorBasedIterator -{ - protected $key; - - /** - * {@inheritdoc} - */ - public function __construct(ClientInterface $client, $key, $match = null, $count = null) - { - $this->requiredCommand($client, 'HSCAN'); - - parent::__construct($client, $match, $count); - - $this->key = $key; - } - - /** - * {@inheritdoc} - */ - protected function executeCommand() - { - return $this->client->hscan($this->key, $this->cursor, $this->getScanOptions()); - } - - /** - * {@inheritdoc} - */ - protected function extractNext() - { - $this->position = key($this->elements); - $this->current = array_shift($this->elements); - } -} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/Keyspace.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/Keyspace.php deleted file mode 100644 index 8000063f4..000000000 --- a/vendor/predis/predis/lib/Predis/Collection/Iterator/Keyspace.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use Predis\ClientInterface; - -/** - * Abstracts the iteration of the keyspace on a Redis instance - * by leveraging the SCAN command (Redis >= 2.8) wrapped in a - * fully-rewindable PHP iterator. - * - * @author Daniele Alessandri - * @link http://redis.io/commands/scan - */ -class Keyspace extends CursorBasedIterator -{ - /** - * {@inheritdoc} - */ - public function __construct(ClientInterface $client, $match = null, $count = null) - { - $this->requiredCommand($client, 'SCAN'); - - parent::__construct($client, $match, $count); - } - - /** - * {@inheritdoc} - */ - protected function executeCommand() - { - return $this->client->scan($this->cursor, $this->getScanOptions()); - } -} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/ListKey.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/ListKey.php deleted file mode 100644 index 8e3a76dcd..000000000 --- a/vendor/predis/predis/lib/Predis/Collection/Iterator/ListKey.php +++ /dev/null @@ -1,174 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use InvalidArgumentException; -use Iterator; -use Predis\ClientInterface; -use Predis\NotSupportedException; - -/** - * Abstracts the iteration of items stored in a list by leveraging the LRANGE - * command wrapped in a fully-rewindable PHP iterator. - * - * This iterator tries to emulate the behaviour of cursor-based iterators based - * on the SCAN-family of commands introduced in Redis <= 2.8, meaning that due - * to its incremental nature with multiple fetches it can only offer limited - * guarantees on the returned elements because the collection can change several - * times (trimmed, deleted, overwritten) during the iteration process. - * - * @author Daniele Alessandri - * @link http://redis.io/commands/lrange - */ -class ListKey implements Iterator -{ - protected $client; - protected $count; - protected $key; - - protected $valid; - protected $fetchmore; - protected $elements; - protected $position; - protected $current; - - /** - * @param ClientInterface $client Client connected to Redis. - * @param string $key Redis list key. - * @param int $count Number of items retrieved on each fetch operation. - */ - public function __construct(ClientInterface $client, $key, $count = 10) - { - $this->requiredCommand($client, 'LRANGE'); - - if ((false === $count = filter_var($count, FILTER_VALIDATE_INT)) || $count < 0) { - throw new InvalidArgumentException('The $count argument must be a positive integer.'); - } - - $this->client = $client; - $this->key = $key; - $this->count = $count; - - $this->reset(); - } - - /** - * Ensures that the client instance supports the specified Redis - * command required to fetch elements from the server to perform - * the iteration. - * - * @param ClientInterface $client Client connected to Redis. - * @param string $commandID Command ID. - */ - protected function requiredCommand(ClientInterface $client, $commandID) - { - if (!$client->getProfile()->supportsCommand($commandID)) { - throw new NotSupportedException("The specified server profile does not support the `$commandID` command."); - } - } - - /** - * Resets the inner state of the iterator. - */ - protected function reset() - { - $this->valid = true; - $this->fetchmore = true; - $this->elements = array(); - $this->position = -1; - $this->current = null; - } - - /** - * Fetches a new set of elements from the remote collection, - * effectively advancing the iteration process. - * - * @return array - */ - protected function executeCommand() - { - return $this->client->lrange($this->key, $this->position + 1, $this->position + $this->count); - } - - /** - * Populates the local buffer of elements fetched from the - * server during the iteration. - */ - protected function fetch() - { - $elements = $this->executeCommand(); - - if (count($elements) < $this->count) { - $this->fetchmore = false; - } - - $this->elements = $elements; - } - - /** - * Extracts next values for key() and current(). - */ - protected function extractNext() - { - $this->position++; - $this->current = array_shift($this->elements); - } - - /** - * {@inheritdoc} - */ - public function rewind() - { - $this->reset(); - $this->next(); - } - - /** - * {@inheritdoc} - */ - public function current() - { - return $this->current; - } - - /** - * {@inheritdoc} - */ - public function key() - { - return $this->position; - } - - /** - * {@inheritdoc} - */ - public function next() - { - if (!$this->elements && $this->fetchmore) { - $this->fetch(); - } - - if ($this->elements) { - $this->extractNext(); - } else { - $this->valid = false; - } - } - - /** - * {@inheritdoc} - */ - public function valid() - { - return $this->valid; - } -} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/SetKey.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/SetKey.php deleted file mode 100644 index 224c24f68..000000000 --- a/vendor/predis/predis/lib/Predis/Collection/Iterator/SetKey.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use Predis\ClientInterface; - -/** - * Abstracts the iteration of members stored in a set by - * leveraging the SSCAN command (Redis >= 2.8) wrapped in - * a fully-rewindable PHP iterator. - * - * @author Daniele Alessandri - * @link http://redis.io/commands/scan - */ -class SetKey extends CursorBasedIterator -{ - protected $key; - - /** - * {@inheritdoc} - */ - public function __construct(ClientInterface $client, $key, $match = null, $count = null) - { - $this->requiredCommand($client, 'SSCAN'); - - parent::__construct($client, $match, $count); - - $this->key = $key; - } - - /** - * {@inheritdoc} - */ - protected function executeCommand() - { - return $this->client->sscan($this->key, $this->cursor, $this->getScanOptions()); - } -} diff --git a/vendor/predis/predis/lib/Predis/Collection/Iterator/SortedSetKey.php b/vendor/predis/predis/lib/Predis/Collection/Iterator/SortedSetKey.php deleted file mode 100644 index a774813b1..000000000 --- a/vendor/predis/predis/lib/Predis/Collection/Iterator/SortedSetKey.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use Predis\ClientInterface; - -/** - * Abstracts the iteration of members stored in a sorted set - * by leveraging the ZSCAN command (Redis >= 2.8) wrapped in - * a fully-rewindable PHP iterator. - * - * @author Daniele Alessandri - * @link http://redis.io/commands/scan - */ -class SortedSetKey extends CursorBasedIterator -{ - protected $key; - - /** - * {@inheritdoc} - */ - public function __construct(ClientInterface $client, $key, $match = null, $count = null) - { - $this->requiredCommand($client, 'ZSCAN'); - - parent::__construct($client, $match, $count); - - $this->key = $key; - } - - /** - * {@inheritdoc} - */ - protected function executeCommand() - { - return $this->client->zscan($this->key, $this->cursor, $this->getScanOptions()); - } - - /** - * {@inheritdoc} - */ - protected function extractNext() - { - $element = array_shift($this->elements); - - $this->position = $element[0]; - $this->current = $element[1]; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/AbstractCommand.php b/vendor/predis/predis/lib/Predis/Command/AbstractCommand.php deleted file mode 100644 index 5bd2a1925..000000000 --- a/vendor/predis/predis/lib/Predis/Command/AbstractCommand.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * Base class for Redis commands. - * - * @author Daniele Alessandri - */ -abstract class AbstractCommand implements CommandInterface -{ - private $hash; - private $arguments = array(); - - /** - * Returns a filtered array of the arguments. - * - * @param array $arguments List of arguments. - * @return array - */ - protected function filterArguments(Array $arguments) - { - return $arguments; - } - - /** - * {@inheritdoc} - */ - public function setArguments(Array $arguments) - { - $this->arguments = $this->filterArguments($arguments); - unset($this->hash); - } - - /** - * {@inheritdoc} - */ - public function setRawArguments(Array $arguments) - { - $this->arguments = $arguments; - unset($this->hash); - } - - /** - * {@inheritdoc} - */ - public function getArguments() - { - return $this->arguments; - } - - /** - * {@inheritdoc} - */ - public function getArgument($index) - { - if (isset($this->arguments[$index])) { - return $this->arguments[$index]; - } - } - - /** - * {@inheritdoc} - */ - public function setHash($hash) - { - $this->hash = $hash; - } - - /** - * {@inheritdoc} - */ - public function getHash() - { - if (isset($this->hash)) { - return $this->hash; - } - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return $data; - } - - /** - * Helper function used to reduce a list of arguments to a string. - * - * @param string $accumulator Temporary string. - * @param string $argument Current argument. - * @return string - */ - protected function toStringArgumentReducer($accumulator, $argument) - { - if (strlen($argument) > 32) { - $argument = substr($argument, 0, 32) . '[...]'; - } - - $accumulator .= " $argument"; - - return $accumulator; - } - - /** - * Returns a partial string representation of the command with its arguments. - * - * @return string - */ - public function __toString() - { - return array_reduce( - $this->getArguments(), - array($this, 'toStringArgumentReducer'), - $this->getId() - ); - } - - /** - * Normalizes the arguments array passed to a Redis command. - * - * @param array $arguments Arguments for a command. - * @return array - */ - public static function normalizeArguments(Array $arguments) - { - if (count($arguments) === 1 && is_array($arguments[0])) { - return $arguments[0]; - } - - return $arguments; - } - - /** - * Normalizes the arguments array passed to a variadic Redis command. - * - * @param array $arguments Arguments for a command. - * @return array - */ - public static function normalizeVariadic(Array $arguments) - { - if (count($arguments) === 2 && is_array($arguments[1])) { - return array_merge(array($arguments[0]), $arguments[1]); - } - - return $arguments; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/CommandInterface.php b/vendor/predis/predis/lib/Predis/Command/CommandInterface.php deleted file mode 100644 index ae62f01b1..000000000 --- a/vendor/predis/predis/lib/Predis/Command/CommandInterface.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * Defines an abstraction representing a Redis command. - * @author Daniele Alessandri - */ -interface CommandInterface -{ - /** - * Gets the ID of a Redis command. - * - * @return string - */ - public function getId(); - - /** - * Set the hash for the command. - * - * @param int $hash Calculated hash. - */ - public function setHash($hash); - - /** - * Returns the hash of the command. - * - * @return int - */ - public function getHash(); - - /** - * Sets the arguments for the command. - * - * @param array $arguments List of arguments. - */ - public function setArguments(Array $arguments); - - /** - * Sets the raw arguments for the command without processing them. - * - * @param array $arguments List of arguments. - */ - public function setRawArguments(Array $arguments); - - /** - * Gets the arguments of the command. - * - * @return array - */ - public function getArguments(); - - /** - * Gets the argument of the command at the specified index. - * - * @param int $index Index of the desired argument. - * @return mixed - */ - public function getArgument($index); - - /** - * Parses a reply buffer and returns a PHP object. - * - * @param string $data Binary string containing the whole reply. - * @return mixed - */ - public function parseResponse($data); -} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionAuth.php b/vendor/predis/predis/lib/Predis/Command/ConnectionAuth.php deleted file mode 100644 index de0d3ee8d..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ConnectionAuth.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/auth - * @author Daniele Alessandri - */ -class ConnectionAuth extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'AUTH'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionEcho.php b/vendor/predis/predis/lib/Predis/Command/ConnectionEcho.php deleted file mode 100644 index dd9d072a7..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ConnectionEcho.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/echo - * @author Daniele Alessandri - */ -class ConnectionEcho extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ECHO'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionPing.php b/vendor/predis/predis/lib/Predis/Command/ConnectionPing.php deleted file mode 100644 index cf29416a7..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ConnectionPing.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/ping - * @author Daniele Alessandri - */ -class ConnectionPing extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PING'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return $data === 'PONG' ? true : false; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionQuit.php b/vendor/predis/predis/lib/Predis/Command/ConnectionQuit.php deleted file mode 100644 index 641cc3564..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ConnectionQuit.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/quit - * @author Daniele Alessandri - */ -class ConnectionQuit extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'QUIT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ConnectionSelect.php b/vendor/predis/predis/lib/Predis/Command/ConnectionSelect.php deleted file mode 100644 index 51b96b771..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ConnectionSelect.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/select - * @author Daniele Alessandri - */ -class ConnectionSelect extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SELECT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashDelete.php b/vendor/predis/predis/lib/Predis/Command/HashDelete.php deleted file mode 100644 index 958467866..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashDelete.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hdel - * @author Daniele Alessandri - */ -class HashDelete extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HDEL'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeVariadic($arguments); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashExists.php b/vendor/predis/predis/lib/Predis/Command/HashExists.php deleted file mode 100644 index a9d620a09..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashExists.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hexists - * @author Daniele Alessandri - */ -class HashExists extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HEXISTS'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashGet.php b/vendor/predis/predis/lib/Predis/Command/HashGet.php deleted file mode 100644 index b18583af4..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashGet.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hget - * @author Daniele Alessandri - */ -class HashGet extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HGET'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashGetAll.php b/vendor/predis/predis/lib/Predis/Command/HashGetAll.php deleted file mode 100644 index 51a745f70..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashGetAll.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hgetall - * @author Daniele Alessandri - */ -class HashGetAll extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HGETALL'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - $result = array(); - - for ($i = 0; $i < count($data); $i++) { - $result[$data[$i]] = $data[++$i]; - } - - return $result; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashGetMultiple.php b/vendor/predis/predis/lib/Predis/Command/HashGetMultiple.php deleted file mode 100644 index d5334898e..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashGetMultiple.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hmget - * @author Daniele Alessandri - */ -class HashGetMultiple extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HMGET'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeVariadic($arguments); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashIncrementBy.php b/vendor/predis/predis/lib/Predis/Command/HashIncrementBy.php deleted file mode 100644 index 1c43e6374..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashIncrementBy.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hincrby - * @author Daniele Alessandri - */ -class HashIncrementBy extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HINCRBY'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashIncrementByFloat.php b/vendor/predis/predis/lib/Predis/Command/HashIncrementByFloat.php deleted file mode 100644 index 759705886..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashIncrementByFloat.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hincrbyfloat - * @author Daniele Alessandri - */ -class HashIncrementByFloat extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HINCRBYFLOAT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashKeys.php b/vendor/predis/predis/lib/Predis/Command/HashKeys.php deleted file mode 100644 index 279f09a97..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashKeys.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hkeys - * @author Daniele Alessandri - */ -class HashKeys extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HKEYS'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashLength.php b/vendor/predis/predis/lib/Predis/Command/HashLength.php deleted file mode 100644 index b2a59c0ae..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashLength.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hlen - * @author Daniele Alessandri - */ -class HashLength extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HLEN'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashScan.php b/vendor/predis/predis/lib/Predis/Command/HashScan.php deleted file mode 100644 index d1efc255d..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashScan.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hscan - * @author Daniele Alessandri - */ -class HashScan extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HSCAN'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 3 && is_array($arguments[2])) { - $options = $this->prepareOptions(array_pop($arguments)); - $arguments = array_merge($arguments, $options); - } - - return $arguments; - } - - /** - * Returns a list of options and modifiers compatible with Redis. - * - * @param array $options List of options. - * @return array - */ - protected function prepareOptions($options) - { - $options = array_change_key_case($options, CASE_UPPER); - $normalized = array(); - - if (!empty($options['MATCH'])) { - $normalized[] = 'MATCH'; - $normalized[] = $options['MATCH']; - } - - if (!empty($options['COUNT'])) { - $normalized[] = 'COUNT'; - $normalized[] = $options['COUNT']; - } - - return $normalized; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - if (is_array($data)) { - $data[0] = (int) $data[0]; - $fields = $data[1]; - $result = array(); - - for ($i = 0; $i < count($fields); $i++) { - $result[$fields[$i]] = $fields[++$i]; - } - - $data[1] = $result; - } - - return $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashSet.php b/vendor/predis/predis/lib/Predis/Command/HashSet.php deleted file mode 100644 index 588afc408..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashSet.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hset - * @author Daniele Alessandri - */ -class HashSet extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HSET'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashSetMultiple.php b/vendor/predis/predis/lib/Predis/Command/HashSetMultiple.php deleted file mode 100644 index f84485fc3..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashSetMultiple.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hmset - * @author Daniele Alessandri - */ -class HashSetMultiple extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HMSET'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 2 && is_array($arguments[1])) { - $flattenedKVs = array($arguments[0]); - $args = $arguments[1]; - - foreach ($args as $k => $v) { - $flattenedKVs[] = $k; - $flattenedKVs[] = $v; - } - - return $flattenedKVs; - } - - return $arguments; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashSetPreserve.php b/vendor/predis/predis/lib/Predis/Command/HashSetPreserve.php deleted file mode 100644 index 3e9890aa2..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashSetPreserve.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hsetnx - * @author Daniele Alessandri - */ -class HashSetPreserve extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HSETNX'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/HashValues.php b/vendor/predis/predis/lib/Predis/Command/HashValues.php deleted file mode 100644 index fec31167d..000000000 --- a/vendor/predis/predis/lib/Predis/Command/HashValues.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/hvals - * @author Daniele Alessandri - */ -class HashValues extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'HVALS'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyDelete.php b/vendor/predis/predis/lib/Predis/Command/KeyDelete.php deleted file mode 100644 index 4e43141c4..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyDelete.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/del - * @author Daniele Alessandri - */ -class KeyDelete extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'DEL'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeArguments($arguments); - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyDump.php b/vendor/predis/predis/lib/Predis/Command/KeyDump.php deleted file mode 100644 index 55cb90b6d..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyDump.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/dump - * @author Daniele Alessandri - */ -class KeyDump extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'DUMP'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyExists.php b/vendor/predis/predis/lib/Predis/Command/KeyExists.php deleted file mode 100644 index 7f877cdb7..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyExists.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/exists - * @author Daniele Alessandri - */ -class KeyExists extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'EXISTS'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyExpire.php b/vendor/predis/predis/lib/Predis/Command/KeyExpire.php deleted file mode 100644 index 9db8e0297..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyExpire.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/expire - * @author Daniele Alessandri - */ -class KeyExpire extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'EXPIRE'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyExpireAt.php b/vendor/predis/predis/lib/Predis/Command/KeyExpireAt.php deleted file mode 100644 index 1f6db38ff..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyExpireAt.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/expireat - * @author Daniele Alessandri - */ -class KeyExpireAt extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'EXPIREAT'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyKeys.php b/vendor/predis/predis/lib/Predis/Command/KeyKeys.php deleted file mode 100644 index 3b973edd2..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyKeys.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/keys - * @author Daniele Alessandri - */ -class KeyKeys extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'KEYS'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyKeysV12x.php b/vendor/predis/predis/lib/Predis/Command/KeyKeysV12x.php deleted file mode 100644 index 2e0d3c92f..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyKeysV12x.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/keys - * @author Daniele Alessandri - * @deprecated - */ -class KeyKeysV12x extends KeyKeys -{ - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return explode(' ', $data); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyMove.php b/vendor/predis/predis/lib/Predis/Command/KeyMove.php deleted file mode 100644 index 9e2a64daf..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyMove.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/move - * @author Daniele Alessandri - */ -class KeyMove extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'MOVE'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyPersist.php b/vendor/predis/predis/lib/Predis/Command/KeyPersist.php deleted file mode 100644 index 5c6b23cf9..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyPersist.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/persist - * @author Daniele Alessandri - */ -class KeyPersist extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PERSIST'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpire.php b/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpire.php deleted file mode 100644 index 3fb867876..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpire.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/pexpire - * @author Daniele Alessandri - */ -class KeyPreciseExpire extends KeyExpire -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PEXPIRE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpireAt.php b/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpireAt.php deleted file mode 100644 index 14697f2af..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyPreciseExpireAt.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/pexpireat - * @author Daniele Alessandri - */ -class KeyPreciseExpireAt extends KeyExpireAt -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PEXPIREAT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyPreciseTimeToLive.php b/vendor/predis/predis/lib/Predis/Command/KeyPreciseTimeToLive.php deleted file mode 100644 index 92e3a029e..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyPreciseTimeToLive.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/pttl - * @author Daniele Alessandri - */ -class KeyPreciseTimeToLive extends KeyTimeToLive -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PTTL'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyRandom.php b/vendor/predis/predis/lib/Predis/Command/KeyRandom.php deleted file mode 100644 index 520a368cd..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyRandom.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/randomkey - * @author Daniele Alessandri - */ -class KeyRandom extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'RANDOMKEY'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return $data !== '' ? $data : null; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyRename.php b/vendor/predis/predis/lib/Predis/Command/KeyRename.php deleted file mode 100644 index 49af1ffed..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyRename.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/rename - * @author Daniele Alessandri - */ -class KeyRename extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'RENAME'; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyRenamePreserve.php b/vendor/predis/predis/lib/Predis/Command/KeyRenamePreserve.php deleted file mode 100644 index 1db8b7dac..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyRenamePreserve.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/renamenx - * @author Daniele Alessandri - */ -class KeyRenamePreserve extends KeyRename -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'RENAMENX'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyRestore.php b/vendor/predis/predis/lib/Predis/Command/KeyRestore.php deleted file mode 100644 index 623cef6dd..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyRestore.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/restore - * @author Daniele Alessandri - */ -class KeyRestore extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'RESTORE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyScan.php b/vendor/predis/predis/lib/Predis/Command/KeyScan.php deleted file mode 100644 index 8b68bae35..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyScan.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/scan - * @author Daniele Alessandri - */ -class KeyScan extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SCAN'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 2 && is_array($arguments[1])) { - $options = $this->prepareOptions(array_pop($arguments)); - $arguments = array_merge($arguments, $options); - } - - return $arguments; - } - - /** - * Returns a list of options and modifiers compatible with Redis. - * - * @param array $options List of options. - * @return array - */ - protected function prepareOptions($options) - { - $options = array_change_key_case($options, CASE_UPPER); - $normalized = array(); - - if (!empty($options['MATCH'])) { - $normalized[] = 'MATCH'; - $normalized[] = $options['MATCH']; - } - - if (!empty($options['COUNT'])) { - $normalized[] = 'COUNT'; - $normalized[] = $options['COUNT']; - } - - return $normalized; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - if (is_array($data)) { - $data[0] = (int) $data[0]; - } - - return $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeySort.php b/vendor/predis/predis/lib/Predis/Command/KeySort.php deleted file mode 100644 index 549469a84..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeySort.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sort - * @author Daniele Alessandri - */ -class KeySort extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SORT'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 1) { - return $arguments; - } - - $query = array($arguments[0]); - $sortParams = array_change_key_case($arguments[1], CASE_UPPER); - - if (isset($sortParams['BY'])) { - $query[] = 'BY'; - $query[] = $sortParams['BY']; - } - - if (isset($sortParams['GET'])) { - $getargs = $sortParams['GET']; - - if (is_array($getargs)) { - foreach ($getargs as $getarg) { - $query[] = 'GET'; - $query[] = $getarg; - } - } else { - $query[] = 'GET'; - $query[] = $getargs; - } - } - - if (isset($sortParams['LIMIT']) && - is_array($sortParams['LIMIT']) && - count($sortParams['LIMIT']) == 2) { - - $query[] = 'LIMIT'; - $query[] = $sortParams['LIMIT'][0]; - $query[] = $sortParams['LIMIT'][1]; - } - - if (isset($sortParams['SORT'])) { - $query[] = strtoupper($sortParams['SORT']); - } - - if (isset($sortParams['ALPHA']) && $sortParams['ALPHA'] == true) { - $query[] = 'ALPHA'; - } - - if (isset($sortParams['STORE'])) { - $query[] = 'STORE'; - $query[] = $sortParams['STORE']; - } - - return $query; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - if ($arguments = $this->getArguments()) { - $arguments[0] = "$prefix{$arguments[0]}"; - - if (($count = count($arguments)) > 1) { - for ($i = 1; $i < $count; $i++) { - switch ($arguments[$i]) { - case 'BY': - case 'STORE': - $arguments[$i] = "$prefix{$arguments[++$i]}"; - break; - - case 'GET': - $value = $arguments[++$i]; - if ($value !== '#') { - $arguments[$i] = "$prefix$value"; - } - break; - - case 'LIMIT'; - $i += 2; - break; - } - } - } - - $this->setRawArguments($arguments); - } - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyTimeToLive.php b/vendor/predis/predis/lib/Predis/Command/KeyTimeToLive.php deleted file mode 100644 index 103885a60..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyTimeToLive.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/ttl - * @author Daniele Alessandri - */ -class KeyTimeToLive extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'TTL'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/KeyType.php b/vendor/predis/predis/lib/Predis/Command/KeyType.php deleted file mode 100644 index b2baf9b41..000000000 --- a/vendor/predis/predis/lib/Predis/Command/KeyType.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/type - * @author Daniele Alessandri - */ -class KeyType extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'TYPE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListIndex.php b/vendor/predis/predis/lib/Predis/Command/ListIndex.php deleted file mode 100644 index 9762ebf8f..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListIndex.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/lindex - * @author Daniele Alessandri - */ -class ListIndex extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LINDEX'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListInsert.php b/vendor/predis/predis/lib/Predis/Command/ListInsert.php deleted file mode 100644 index 289f9b457..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListInsert.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/linsert - * @author Daniele Alessandri - */ -class ListInsert extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LINSERT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListLength.php b/vendor/predis/predis/lib/Predis/Command/ListLength.php deleted file mode 100644 index c46dad4f6..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListLength.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/llen - * @author Daniele Alessandri - */ -class ListLength extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LLEN'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopFirst.php b/vendor/predis/predis/lib/Predis/Command/ListPopFirst.php deleted file mode 100644 index f1afc4e41..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPopFirst.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/lpop - * @author Daniele Alessandri - */ -class ListPopFirst extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LPOP'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopFirstBlocking.php b/vendor/predis/predis/lib/Predis/Command/ListPopFirstBlocking.php deleted file mode 100644 index 0ada46757..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPopFirstBlocking.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/blpop - * @author Daniele Alessandri - */ -class ListPopFirstBlocking extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'BLPOP'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 2 && is_array($arguments[0])) { - list($arguments, $timeout) = $arguments; - array_push($arguments, $timeout); - } - - return $arguments; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::skipLast($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopLast.php b/vendor/predis/predis/lib/Predis/Command/ListPopLast.php deleted file mode 100644 index a161f9083..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPopLast.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/rpop - * @author Daniele Alessandri - */ -class ListPopLast extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'RPOP'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopLastBlocking.php b/vendor/predis/predis/lib/Predis/Command/ListPopLastBlocking.php deleted file mode 100644 index fc3d4214c..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPopLastBlocking.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/brpop - * @author Daniele Alessandri - */ -class ListPopLastBlocking extends ListPopFirstBlocking -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'BRPOP'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHead.php b/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHead.php deleted file mode 100644 index 761b61248..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHead.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/rpoplpush - * @author Daniele Alessandri - */ -class ListPopLastPushHead extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'RPOPLPUSH'; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHeadBlocking.php b/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHeadBlocking.php deleted file mode 100644 index 3ef140717..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPopLastPushHeadBlocking.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/brpoplpush - * @author Daniele Alessandri - */ -class ListPopLastPushHeadBlocking extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'BRPOPLPUSH'; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::skipLast($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPushHead.php b/vendor/predis/predis/lib/Predis/Command/ListPushHead.php deleted file mode 100644 index 6dcb61bac..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPushHead.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/lpush - * @author Daniele Alessandri - */ -class ListPushHead extends ListPushTail -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LPUSH'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPushHeadX.php b/vendor/predis/predis/lib/Predis/Command/ListPushHeadX.php deleted file mode 100644 index 2cb671ecb..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPushHeadX.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/lpushx - * @author Daniele Alessandri - */ -class ListPushHeadX extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LPUSHX'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPushTail.php b/vendor/predis/predis/lib/Predis/Command/ListPushTail.php deleted file mode 100644 index 6a0f2e0b2..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPushTail.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/rpush - * @author Daniele Alessandri - */ -class ListPushTail extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'RPUSH'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeVariadic($arguments); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListPushTailX.php b/vendor/predis/predis/lib/Predis/Command/ListPushTailX.php deleted file mode 100644 index af42a52f3..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListPushTailX.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/rpushx - * @author Daniele Alessandri - */ -class ListPushTailX extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'RPUSHX'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListRange.php b/vendor/predis/predis/lib/Predis/Command/ListRange.php deleted file mode 100644 index 2b2e945e3..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListRange.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/lrange - * @author Daniele Alessandri - */ -class ListRange extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LRANGE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListRemove.php b/vendor/predis/predis/lib/Predis/Command/ListRemove.php deleted file mode 100644 index 98f885401..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListRemove.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/lrem - * @author Daniele Alessandri - */ -class ListRemove extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LREM'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListSet.php b/vendor/predis/predis/lib/Predis/Command/ListSet.php deleted file mode 100644 index 0ea1ee732..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListSet.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/lset - * @author Daniele Alessandri - */ -class ListSet extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LSET'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ListTrim.php b/vendor/predis/predis/lib/Predis/Command/ListTrim.php deleted file mode 100644 index 80d73e5b4..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ListTrim.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/ltrim - * @author Daniele Alessandri - */ -class ListTrim extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LTRIM'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/PrefixHelpers.php b/vendor/predis/predis/lib/Predis/Command/PrefixHelpers.php deleted file mode 100644 index 83e2e9a6d..000000000 --- a/vendor/predis/predis/lib/Predis/Command/PrefixHelpers.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * Class that defines a few helpers method for prefixing keys. - * - * @author Daniele Alessandri - */ -class PrefixHelpers -{ - /** - * Applies the specified prefix only the first argument. - * - * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. - */ - public static function first(CommandInterface $command, $prefix) - { - if ($arguments = $command->getArguments()) { - $arguments[0] = "$prefix{$arguments[0]}"; - $command->setRawArguments($arguments); - } - } - - /** - * Applies the specified prefix to all the arguments. - * - * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. - */ - public static function all(CommandInterface $command, $prefix) - { - if ($arguments = $command->getArguments()) { - foreach ($arguments as &$key) { - $key = "$prefix$key"; - } - - $command->setRawArguments($arguments); - } - } - - /** - * Applies the specified prefix only to even arguments in the list. - * - * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. - */ - public static function interleaved(CommandInterface $command, $prefix) - { - if ($arguments = $command->getArguments()) { - $length = count($arguments); - - for ($i = 0; $i < $length; $i += 2) { - $arguments[$i] = "$prefix{$arguments[$i]}"; - } - - $command->setRawArguments($arguments); - } - } - - /** - * Applies the specified prefix to all the arguments but the first one. - * - * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. - */ - public static function skipFirst(CommandInterface $command, $prefix) - { - if ($arguments = $command->getArguments()) { - $length = count($arguments); - - for ($i = 1; $i < $length; $i++) { - $arguments[$i] = "$prefix{$arguments[$i]}"; - } - - $command->setRawArguments($arguments); - } - } - - /** - * Applies the specified prefix to all the arguments but the last one. - * - * @param CommandInterface $command Command instance. - * @param string $prefix Prefix string. - */ - public static function skipLast(CommandInterface $command, $prefix) - { - if ($arguments = $command->getArguments()) { - $length = count($arguments); - - for ($i = 0; $i < $length - 1; $i++) { - $arguments[$i] = "$prefix{$arguments[$i]}"; - } - - $command->setRawArguments($arguments); - } - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/PrefixableCommand.php b/vendor/predis/predis/lib/Predis/Command/PrefixableCommand.php deleted file mode 100644 index 7112e87d4..000000000 --- a/vendor/predis/predis/lib/Predis/Command/PrefixableCommand.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * Base class for Redis commands with prefixable keys. - * - * @author Daniele Alessandri - */ -abstract class PrefixableCommand extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - if ($arguments = $this->getArguments()) { - $arguments[0] = "$prefix{$arguments[0]}"; - $this->setRawArguments($arguments); - } - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/PrefixableCommandInterface.php b/vendor/predis/predis/lib/Predis/Command/PrefixableCommandInterface.php deleted file mode 100644 index acb99a225..000000000 --- a/vendor/predis/predis/lib/Predis/Command/PrefixableCommandInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * Defines a command whose keys can be prefixed. - * - * @author Daniele Alessandri - */ -interface PrefixableCommandInterface -{ - /** - * Prefixes all the keys found in the arguments of the command. - * - * @param string $prefix String used to prefix the keys. - */ - public function prefixKeys($prefix); -} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php deleted file mode 100644 index 376d4651c..000000000 --- a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessingInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command\Processor; - -/** - * Defines an object that can process commands using command processors. - * - * @author Daniele Alessandri - */ -interface CommandProcessingInterface -{ - /** - * Associates a command processor. - * - * @param CommandProcessorInterface $processor The command processor. - */ - public function setProcessor(CommandProcessorInterface $processor); - - /** - * Returns the associated command processor. - * - * @return CommandProcessorInterface - */ - public function getProcessor(); -} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorChainInterface.php b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorChainInterface.php deleted file mode 100644 index 2985ac91c..000000000 --- a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorChainInterface.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command\Processor; - -/** - * A command processor chain processes a command using multiple chained command - * processor before it is sent to Redis. - * - * @author Daniele Alessandri - */ -interface CommandProcessorChainInterface extends CommandProcessorInterface, \IteratorAggregate, \Countable -{ - /** - * Adds a command processor. - * - * @param CommandProcessorInterface $processor A command processor. - */ - public function add(CommandProcessorInterface $processor); - - /** - * Removes a command processor from the chain. - * - * @param CommandProcessorInterface $processor A command processor. - */ - public function remove(CommandProcessorInterface $processor); - - /** - * Returns an ordered list of the command processors in the chain. - * - * @return array - */ - public function getProcessors(); -} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorInterface.php b/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorInterface.php deleted file mode 100644 index e23eade0b..000000000 --- a/vendor/predis/predis/lib/Predis/Command/Processor/CommandProcessorInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command\Processor; - -use Predis\Command\CommandInterface; - -/** - * A command processor processes commands before they are sent to Redis. - * - * @author Daniele Alessandri - */ -interface CommandProcessorInterface -{ - /** - * Processes a Redis command. - * - * @param CommandInterface $command Redis command. - */ - public function process(CommandInterface $command); -} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/KeyPrefixProcessor.php b/vendor/predis/predis/lib/Predis/Command/Processor/KeyPrefixProcessor.php deleted file mode 100644 index ed0d17fa2..000000000 --- a/vendor/predis/predis/lib/Predis/Command/Processor/KeyPrefixProcessor.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command\Processor; - -use Predis\Command\CommandInterface; -use Predis\Command\PrefixableCommandInterface; - -/** - * Command processor that is used to prefix the keys contained in the arguments - * of a Redis command. - * - * @author Daniele Alessandri - */ -class KeyPrefixProcessor implements CommandProcessorInterface -{ - private $prefix; - - /** - * @param string $prefix Prefix for the keys. - */ - public function __construct($prefix) - { - $this->setPrefix($prefix); - } - - /** - * Sets a prefix that is applied to all the keys. - * - * @param string $prefix Prefix for the keys. - */ - public function setPrefix($prefix) - { - $this->prefix = $prefix; - } - - /** - * Gets the current prefix. - * - * @return string - */ - public function getPrefix() - { - return $this->prefix; - } - - /** - * {@inheritdoc} - */ - public function process(CommandInterface $command) - { - if ($command instanceof PrefixableCommandInterface && $command->getArguments()) { - $command->prefixKeys($this->prefix); - } - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->getPrefix(); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/Processor/ProcessorChain.php b/vendor/predis/predis/lib/Predis/Command/Processor/ProcessorChain.php deleted file mode 100644 index fb4b109ba..000000000 --- a/vendor/predis/predis/lib/Predis/Command/Processor/ProcessorChain.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command\Processor; - -use Predis\Command\CommandInterface; - -/** - * Default implementation of a command processors chain. - * - * @author Daniele Alessandri - */ -class ProcessorChain implements CommandProcessorChainInterface, \ArrayAccess -{ - private $processors = array(); - - /** - * @param array $processors List of instances of CommandProcessorInterface. - */ - public function __construct($processors = array()) - { - foreach ($processors as $processor) { - $this->add($processor); - } - } - - /** - * {@inheritdoc} - */ - public function add(CommandProcessorInterface $processor) - { - $this->processors[] = $processor; - } - - /** - * {@inheritdoc} - */ - public function remove(CommandProcessorInterface $processor) - { - if (false !== $index = array_search($processor, $this->processors, true)) { - unset($this[$index]); - } - } - - /** - * {@inheritdoc} - */ - public function process(CommandInterface $command) - { - for ($i = 0; $i < $count = count($this->processors); $i++) { - $this->processors[$i]->process($command); - } - } - - /** - * {@inheritdoc} - */ - public function getProcessors() - { - return $this->processors; - } - - /** - * Returns an iterator over the list of command processor in the chain. - * - * @return \ArrayIterator - */ - public function getIterator() - { - return new \ArrayIterator($this->processors); - } - - /** - * Returns the number of command processors in the chain. - * - * @return int - */ - public function count() - { - return count($this->processors); - } - - /** - * {@inheritdoc} - */ - public function offsetExists($index) - { - return isset($this->processors[$index]); - } - - /** - * {@inheritdoc} - */ - public function offsetGet($index) - { - return $this->processors[$index]; - } - - /** - * {@inheritdoc} - */ - public function offsetSet($index, $processor) - { - if (!$processor instanceof CommandProcessorInterface) { - throw new \InvalidArgumentException( - 'A processor chain can hold only instances of classes implementing '. - 'the Predis\Command\Processor\CommandProcessorInterface interface' - ); - } - - $this->processors[$index] = $processor; - } - - /** - * {@inheritdoc} - */ - public function offsetUnset($index) - { - unset($this->processors[$index]); - $this->processors = array_values($this->processors); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubPublish.php b/vendor/predis/predis/lib/Predis/Command/PubSubPublish.php deleted file mode 100644 index b2ecce512..000000000 --- a/vendor/predis/predis/lib/Predis/Command/PubSubPublish.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/publish - * @author Daniele Alessandri - */ -class PubSubPublish extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PUBLISH'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubSubscribe.php b/vendor/predis/predis/lib/Predis/Command/PubSubSubscribe.php deleted file mode 100644 index eb8be6503..000000000 --- a/vendor/predis/predis/lib/Predis/Command/PubSubSubscribe.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/subscribe - * @author Daniele Alessandri - */ -class PubSubSubscribe extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SUBSCRIBE'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeArguments($arguments); - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubSubscribeByPattern.php b/vendor/predis/predis/lib/Predis/Command/PubSubSubscribeByPattern.php deleted file mode 100644 index 7629e6df3..000000000 --- a/vendor/predis/predis/lib/Predis/Command/PubSubSubscribeByPattern.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/psubscribe - * @author Daniele Alessandri - */ -class PubSubSubscribeByPattern extends PubSubSubscribe -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PSUBSCRIBE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribe.php b/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribe.php deleted file mode 100644 index ba70fe4de..000000000 --- a/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribe.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/unsubscribe - * @author Daniele Alessandri - */ -class PubSubUnsubscribe extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'UNSUBSCRIBE'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeArguments($arguments); - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribeByPattern.php b/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribeByPattern.php deleted file mode 100644 index f846e6583..000000000 --- a/vendor/predis/predis/lib/Predis/Command/PubSubUnsubscribeByPattern.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/punsubscribe - * @author Daniele Alessandri - */ -class PubSubUnsubscribeByPattern extends PubSubUnsubscribe -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PUNSUBSCRIBE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/RawCommand.php b/vendor/predis/predis/lib/Predis/Command/RawCommand.php deleted file mode 100644 index 6afa736c6..000000000 --- a/vendor/predis/predis/lib/Predis/Command/RawCommand.php +++ /dev/null @@ -1,157 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -use InvalidArgumentException; - -/** - * Class for generic "anonymous" Redis commands. - * - * This command class does not filter input arguments or parse responses, but - * can be used to leverage the standard Predis API to execute any command simply - * by providing the needed arguments following the command signature as defined - * by Redis in its documentation. - * - * @author Daniele Alessandri - */ -class RawCommand implements CommandInterface -{ - private $hash; - private $commandID; - private $arguments; - - public function __construct(array $arguments) - { - if (!$arguments) { - throw new InvalidArgumentException("Arguments array is missing the command ID"); - } - - $this->commandID = strtoupper(array_shift($arguments)); - $this->arguments = $arguments; - } - - /** - * Creates a new raw command using a variadic method. - * - * @param string $commandID Redis command ID. - * @param string ... Arguments list for the command. - * @return CommandInterface - */ - public static function create($commandID /* [ $arg, ... */) - { - $arguments = func_get_args(); - $command = new self($arguments); - - return $command; - } - - /** - * {@inheritdoc} - */ - public function getId() - { - return $this->commandID; - } - - /** - * {@inheritdoc} - */ - public function setArguments(array $arguments) - { - $this->arguments = $arguments; - unset($this->hash); - } - - /** - * {@inheritdoc} - */ - public function setRawArguments(array $arguments) - { - $this->setArguments($arguments); - } - - /** - * {@inheritdoc} - */ - public function getArguments() - { - return $this->arguments; - } - - /** - * {@inheritdoc} - */ - public function getArgument($index) - { - if (isset($this->arguments[$index])) { - return $this->arguments[$index]; - } - } - - /** - * {@inheritdoc} - */ - public function setHash($hash) - { - $this->hash = $hash; - } - - /** - * {@inheritdoc} - */ - public function getHash() - { - if (isset($this->hash)) { - return $this->hash; - } - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return $data; - } - - /** - * Helper function used to reduce a list of arguments to a string. - * - * @param string $accumulator Temporary string. - * @param string $argument Current argument. - * @return string - */ - protected function toStringArgumentReducer($accumulator, $argument) - { - if (strlen($argument) > 32) { - $argument = substr($argument, 0, 32) . '[...]'; - } - - $accumulator .= " $argument"; - - return $accumulator; - } - - /** - * Returns a partial string representation of the command with its arguments. - * - * @return string - */ - public function __toString() - { - return array_reduce( - $this->getArguments(), - array($this, 'toStringArgumentReducer'), - $this->getId() - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ScriptedCommand.php b/vendor/predis/predis/lib/Predis/Command/ScriptedCommand.php deleted file mode 100644 index 67855c03f..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ScriptedCommand.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * Base class used to implement an higher level abstraction for "virtual" - * commands based on EVAL. - * - * @link http://redis.io/commands/eval - * @author Daniele Alessandri - */ -abstract class ScriptedCommand extends ServerEvalSHA -{ - /** - * Gets the body of a Lua script. - * - * @return string - */ - abstract public function getScript(); - - /** - * Specifies the number of arguments that should be considered as keys. - * - * The default behaviour for the base class is to return 0 to indicate that - * all the elements of the arguments array should be considered as keys, but - * subclasses can enforce a static number of keys. - * - * @return int - */ - protected function getKeysCount() - { - return 0; - } - - /** - * Returns the elements from the arguments that are identified as keys. - * - * @return array - */ - public function getKeys() - { - return array_slice($this->getArguments(), 2, $this->getKeysCount()); - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (($numkeys = $this->getKeysCount()) && $numkeys < 0) { - $numkeys = count($arguments) + $numkeys; - } - - return array_merge(array(sha1($this->getScript()), (int) $numkeys), $arguments); - } - - /** - * @return array - */ - public function getEvalArguments() - { - $arguments = $this->getArguments(); - $arguments[0] = $this->getScript(); - - return $arguments; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerBackgroundRewriteAOF.php b/vendor/predis/predis/lib/Predis/Command/ServerBackgroundRewriteAOF.php deleted file mode 100644 index c4b400784..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerBackgroundRewriteAOF.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/bgrewriteaof - * @author Daniele Alessandri - */ -class ServerBackgroundRewriteAOF extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'BGREWRITEAOF'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return $data == 'Background append only file rewriting started'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerBackgroundSave.php b/vendor/predis/predis/lib/Predis/Command/ServerBackgroundSave.php deleted file mode 100644 index 5993201c3..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerBackgroundSave.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/bgsave - * @author Daniele Alessandri - */ -class ServerBackgroundSave extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'BGSAVE'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return $data === 'Background saving started' ? true : $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerClient.php b/vendor/predis/predis/lib/Predis/Command/ServerClient.php deleted file mode 100644 index ca145794d..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerClient.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/client-list - * @link http://redis.io/commands/client-kill - * @link http://redis.io/commands/client-getname - * @link http://redis.io/commands/client-setname - * @author Daniele Alessandri - */ -class ServerClient extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'CLIENT'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - $args = array_change_key_case($this->getArguments(), CASE_UPPER); - - switch (strtoupper($args[0])) { - case 'LIST': - return $this->parseClientList($data); - case 'KILL': - case 'GETNAME': - case 'SETNAME': - default: - return $data; - } - } - - /** - * Parses the reply buffer and returns the list of clients returned by - * the CLIENT LIST command. - * - * @param string $data Reply buffer - * @return array - */ - protected function parseClientList($data) - { - $clients = array(); - - foreach (explode("\n", $data, -1) as $clientData) { - $client = array(); - - foreach (explode(' ', $clientData) as $kv) { - @list($k, $v) = explode('=', $kv); - $client[$k] = $v; - } - - $clients[] = $client; - } - - return $clients; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerConfig.php b/vendor/predis/predis/lib/Predis/Command/ServerConfig.php deleted file mode 100644 index f63215c0a..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerConfig.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/config-set - * @link http://redis.io/commands/config-get - * @link http://redis.io/commands/config-resetstat - * @link http://redis.io/commands/config-rewrite - * @author Daniele Alessandri - */ -class ServerConfig extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'CONFIG'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - if (is_array($data)) { - $result = array(); - - for ($i = 0; $i < count($data); $i++) { - $result[$data[$i]] = $data[++$i]; - } - - return $result; - } - - return $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerDatabaseSize.php b/vendor/predis/predis/lib/Predis/Command/ServerDatabaseSize.php deleted file mode 100644 index 51dcac63c..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerDatabaseSize.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/dbsize - * @author Daniele Alessandri - */ -class ServerDatabaseSize extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'DBSIZE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerEval.php b/vendor/predis/predis/lib/Predis/Command/ServerEval.php deleted file mode 100644 index 0c1f18288..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerEval.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/eval - * @author Daniele Alessandri - */ -class ServerEval extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'EVAL'; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - if ($arguments = $this->getArguments()) { - for ($i = 2; $i < $arguments[1] + 2; $i++) { - $arguments[$i] = "$prefix{$arguments[$i]}"; - } - - $this->setRawArguments($arguments); - } - } - - /** - * Calculates the SHA1 hash of the body of the script. - * - * @return string SHA1 hash. - */ - public function getScriptHash() - { - return sha1($this->getArgument(0)); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerEvalSHA.php b/vendor/predis/predis/lib/Predis/Command/ServerEvalSHA.php deleted file mode 100644 index a670390fe..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerEvalSHA.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/evalsha - * @author Daniele Alessandri - */ -class ServerEvalSHA extends ServerEval -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'EVALSHA'; - } - - /** - * Returns the SHA1 hash of the body of the script. - * - * @return string SHA1 hash. - */ - public function getScriptHash() - { - return $this->getArgument(0); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerFlushAll.php b/vendor/predis/predis/lib/Predis/Command/ServerFlushAll.php deleted file mode 100644 index a50218c76..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerFlushAll.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/flushall - * @author Daniele Alessandri - */ -class ServerFlushAll extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'FLUSHALL'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerFlushDatabase.php b/vendor/predis/predis/lib/Predis/Command/ServerFlushDatabase.php deleted file mode 100644 index 8b6b6a202..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerFlushDatabase.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/flushdb - * @author Daniele Alessandri - */ -class ServerFlushDatabase extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'FLUSHDB'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerInfo.php b/vendor/predis/predis/lib/Predis/Command/ServerInfo.php deleted file mode 100644 index 899b16b14..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerInfo.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/info - * @author Daniele Alessandri - */ -class ServerInfo extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'INFO'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - $info = array(); - $infoLines = preg_split('/\r?\n/', $data); - - foreach ($infoLines as $row) { - @list($k, $v) = explode(':', $row); - - if ($row === '' || !isset($v)) { - continue; - } - - if (!preg_match('/^db\d+$/', $k)) { - if ($k === 'allocation_stats') { - $info[$k] = $this->parseAllocationStats($v); - continue; - } - - $info[$k] = $v; - } else { - $info[$k] = $this->parseDatabaseStats($v); - } - } - - return $info; - } - - /** - * Parses the reply buffer and extracts the statistics of each logical DB. - * - * @param string $str Reply buffer. - * @return array - */ - protected function parseDatabaseStats($str) - { - $db = array(); - - foreach (explode(',', $str) as $dbvar) { - list($dbvk, $dbvv) = explode('=', $dbvar); - $db[trim($dbvk)] = $dbvv; - } - - return $db; - } - - /** - * Parses the reply buffer and extracts the allocation statistics. - * - * @param string $str Reply buffer. - * @return array - */ - protected function parseAllocationStats($str) - { - $stats = array(); - - foreach (explode(',', $str) as $kv) { - @list($size, $objects, $extra) = explode('=', $kv); - - // hack to prevent incorrect values when parsing the >=256 key - if (isset($extra)) { - $size = ">=$objects"; - $objects = $extra; - } - - $stats[$size] = $objects; - } - - return $stats; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerInfoV26x.php b/vendor/predis/predis/lib/Predis/Command/ServerInfoV26x.php deleted file mode 100644 index 457fe30f0..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerInfoV26x.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/info - * @author Daniele Alessandri - */ -class ServerInfoV26x extends ServerInfo -{ - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - $info = array(); - $current = null; - $infoLines = preg_split('/\r?\n/', $data); - - if (isset($infoLines[0]) && $infoLines[0][0] !== '#') { - return parent::parseResponse($data); - } - - foreach ($infoLines as $row) { - if ($row === '') { - continue; - } - - if (preg_match('/^# (\w+)$/', $row, $matches)) { - $info[$matches[1]] = array(); - $current = &$info[$matches[1]]; - continue; - } - - list($k, $v) = explode(':', $row); - - if (!preg_match('/^db\d+$/', $k)) { - if ($k === 'allocation_stats') { - $current[$k] = $this->parseAllocationStats($v); - continue; - } - - $current[$k] = $v; - } else { - $current[$k] = $this->parseDatabaseStats($v); - } - } - - return $info; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerLastSave.php b/vendor/predis/predis/lib/Predis/Command/ServerLastSave.php deleted file mode 100644 index 33a1e93c5..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerLastSave.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/lastsave - * @author Daniele Alessandri - */ -class ServerLastSave extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'LASTSAVE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerMonitor.php b/vendor/predis/predis/lib/Predis/Command/ServerMonitor.php deleted file mode 100644 index 7f4a83fde..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerMonitor.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/monitor - * @author Daniele Alessandri - */ -class ServerMonitor extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'MONITOR'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerObject.php b/vendor/predis/predis/lib/Predis/Command/ServerObject.php deleted file mode 100644 index 989fbd776..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerObject.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/object - * @author Daniele Alessandri - */ -class ServerObject extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'OBJECT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerSave.php b/vendor/predis/predis/lib/Predis/Command/ServerSave.php deleted file mode 100644 index 6dd3c797b..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerSave.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/save - * @author Daniele Alessandri - */ -class ServerSave extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SAVE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerScript.php b/vendor/predis/predis/lib/Predis/Command/ServerScript.php deleted file mode 100644 index 5b668665c..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerScript.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/script - * @author Daniele Alessandri - */ -class ServerScript extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SCRIPT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerShutdown.php b/vendor/predis/predis/lib/Predis/Command/ServerShutdown.php deleted file mode 100644 index b0278b03b..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerShutdown.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/shutdown - * @author Daniele Alessandri - */ -class ServerShutdown extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SHUTDOWN'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerSlaveOf.php b/vendor/predis/predis/lib/Predis/Command/ServerSlaveOf.php deleted file mode 100644 index 94f9f696c..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerSlaveOf.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/slaveof - * @author Daniele Alessandri - */ -class ServerSlaveOf extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SLAVEOF'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 0 || $arguments[0] === 'NO ONE') { - return array('NO', 'ONE'); - } - - return $arguments; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerSlowlog.php b/vendor/predis/predis/lib/Predis/Command/ServerSlowlog.php deleted file mode 100644 index ad4155f28..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerSlowlog.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/slowlog - * @author Daniele Alessandri - */ -class ServerSlowlog extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SLOWLOG'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - if (is_array($data)) { - $log = array(); - - foreach ($data as $index => $entry) { - $log[$index] = array( - 'id' => $entry[0], - 'timestamp' => $entry[1], - 'duration' => $entry[2], - 'command' => $entry[3], - ); - } - - return $log; - } - - return $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ServerTime.php b/vendor/predis/predis/lib/Predis/Command/ServerTime.php deleted file mode 100644 index 179763791..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ServerTime.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/time - * @author Daniele Alessandri - */ -class ServerTime extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'TIME'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetAdd.php b/vendor/predis/predis/lib/Predis/Command/SetAdd.php deleted file mode 100644 index f03e02bdd..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetAdd.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sadd - * @author Daniele Alessandri - */ -class SetAdd extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SADD'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeVariadic($arguments); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetCardinality.php b/vendor/predis/predis/lib/Predis/Command/SetCardinality.php deleted file mode 100644 index 8e6e48e01..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetCardinality.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/scard - * @author Daniele Alessandri - */ -class SetCardinality extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SCARD'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetDifference.php b/vendor/predis/predis/lib/Predis/Command/SetDifference.php deleted file mode 100644 index 14d3f211e..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetDifference.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sdiff - * @author Daniele Alessandri - */ -class SetDifference extends SetIntersection -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SDIFF'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetDifferenceStore.php b/vendor/predis/predis/lib/Predis/Command/SetDifferenceStore.php deleted file mode 100644 index 1fae8b7ab..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetDifferenceStore.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sdiffstore - * @author Daniele Alessandri - */ -class SetDifferenceStore extends SetIntersectionStore -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SDIFFSTORE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetIntersection.php b/vendor/predis/predis/lib/Predis/Command/SetIntersection.php deleted file mode 100644 index c6590d232..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetIntersection.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sinter - * @author Daniele Alessandri - */ -class SetIntersection extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SINTER'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeArguments($arguments); - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetIntersectionStore.php b/vendor/predis/predis/lib/Predis/Command/SetIntersectionStore.php deleted file mode 100644 index 4e764e0dd..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetIntersectionStore.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sinterstore - * @author Daniele Alessandri - */ -class SetIntersectionStore extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SINTERSTORE'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 2 && is_array($arguments[1])) { - return array_merge(array($arguments[0]), $arguments[1]); - } - - return $arguments; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetIsMember.php b/vendor/predis/predis/lib/Predis/Command/SetIsMember.php deleted file mode 100644 index 077352098..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetIsMember.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sismember - * @author Daniele Alessandri - */ -class SetIsMember extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SISMEMBER'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetMembers.php b/vendor/predis/predis/lib/Predis/Command/SetMembers.php deleted file mode 100644 index 3ebef0a11..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetMembers.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/smembers - * @author Daniele Alessandri - */ -class SetMembers extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SMEMBERS'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetMove.php b/vendor/predis/predis/lib/Predis/Command/SetMove.php deleted file mode 100644 index 01678ec70..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetMove.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/smove - * @author Daniele Alessandri - */ -class SetMove extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SMOVE'; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::skipLast($this, $prefix); - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetPop.php b/vendor/predis/predis/lib/Predis/Command/SetPop.php deleted file mode 100644 index ebfec0cce..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetPop.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/spop - * @author Daniele Alessandri - */ -class SetPop extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SPOP'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetRandomMember.php b/vendor/predis/predis/lib/Predis/Command/SetRandomMember.php deleted file mode 100644 index a6b6062ea..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetRandomMember.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/srandmember - * @author Daniele Alessandri - */ -class SetRandomMember extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SRANDMEMBER'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetRemove.php b/vendor/predis/predis/lib/Predis/Command/SetRemove.php deleted file mode 100644 index f7cb57725..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetRemove.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/srem - * @author Daniele Alessandri - */ -class SetRemove extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SREM'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeVariadic($arguments); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetScan.php b/vendor/predis/predis/lib/Predis/Command/SetScan.php deleted file mode 100644 index 27b6de2b9..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetScan.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sscan - * @author Daniele Alessandri - */ -class SetScan extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SSCAN'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 3 && is_array($arguments[2])) { - $options = $this->prepareOptions(array_pop($arguments)); - $arguments = array_merge($arguments, $options); - } - - return $arguments; - } - - /** - * Returns a list of options and modifiers compatible with Redis. - * - * @param array $options List of options. - * @return array - */ - protected function prepareOptions($options) - { - $options = array_change_key_case($options, CASE_UPPER); - $normalized = array(); - - if (!empty($options['MATCH'])) { - $normalized[] = 'MATCH'; - $normalized[] = $options['MATCH']; - } - - if (!empty($options['COUNT'])) { - $normalized[] = 'COUNT'; - $normalized[] = $options['COUNT']; - } - - return $normalized; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - if (is_array($data)) { - $data[0] = (int) $data[0]; - } - - return $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetUnion.php b/vendor/predis/predis/lib/Predis/Command/SetUnion.php deleted file mode 100644 index c9f322b2e..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetUnion.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sunion - * @author Daniele Alessandri - */ -class SetUnion extends SetIntersection -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SUNION'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/SetUnionStore.php b/vendor/predis/predis/lib/Predis/Command/SetUnionStore.php deleted file mode 100644 index daf66c33b..000000000 --- a/vendor/predis/predis/lib/Predis/Command/SetUnionStore.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/sunionstore - * @author Daniele Alessandri - */ -class SetUnionStore extends SetIntersectionStore -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SUNIONSTORE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringAppend.php b/vendor/predis/predis/lib/Predis/Command/StringAppend.php deleted file mode 100644 index 8d1461480..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringAppend.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/append - * @author Daniele Alessandri - */ -class StringAppend extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'APPEND'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringBitCount.php b/vendor/predis/predis/lib/Predis/Command/StringBitCount.php deleted file mode 100644 index 19d534b0a..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringBitCount.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/bitcount - * @author Daniele Alessandri - */ -class StringBitCount extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'BITCOUNT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringBitOp.php b/vendor/predis/predis/lib/Predis/Command/StringBitOp.php deleted file mode 100644 index 0236bb17d..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringBitOp.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/bitop - * @author Daniele Alessandri - */ -class StringBitOp extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'BITOP'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 3 && is_array($arguments[2])) { - list($operation, $destination, ) = $arguments; - $arguments = $arguments[2]; - array_unshift($arguments, $operation, $destination); - } - - return $arguments; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::skipFirst($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringDecrement.php b/vendor/predis/predis/lib/Predis/Command/StringDecrement.php deleted file mode 100644 index 0e45cd0db..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringDecrement.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/decr - * @author Daniele Alessandri - */ -class StringDecrement extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'DECR'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringDecrementBy.php b/vendor/predis/predis/lib/Predis/Command/StringDecrementBy.php deleted file mode 100644 index e716e0ebd..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringDecrementBy.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/decrby - * @author Daniele Alessandri - */ -class StringDecrementBy extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'DECRBY'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGet.php b/vendor/predis/predis/lib/Predis/Command/StringGet.php deleted file mode 100644 index 851c7100a..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringGet.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/get - * @author Daniele Alessandri - */ -class StringGet extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'GET'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGetBit.php b/vendor/predis/predis/lib/Predis/Command/StringGetBit.php deleted file mode 100644 index 954c39fdb..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringGetBit.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/getbit - * @author Daniele Alessandri - */ -class StringGetBit extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'GETBIT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGetMultiple.php b/vendor/predis/predis/lib/Predis/Command/StringGetMultiple.php deleted file mode 100644 index 71d918728..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringGetMultiple.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/mget - * @author Daniele Alessandri - */ -class StringGetMultiple extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'MGET'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeArguments($arguments); - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGetRange.php b/vendor/predis/predis/lib/Predis/Command/StringGetRange.php deleted file mode 100644 index aed485367..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringGetRange.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/getrange - * @author Daniele Alessandri - */ -class StringGetRange extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'GETRANGE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringGetSet.php b/vendor/predis/predis/lib/Predis/Command/StringGetSet.php deleted file mode 100644 index d4b8e2303..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringGetSet.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/getset - * @author Daniele Alessandri - */ -class StringGetSet extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'GETSET'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringIncrement.php b/vendor/predis/predis/lib/Predis/Command/StringIncrement.php deleted file mode 100644 index 4848afcbc..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringIncrement.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/incr - * @author Daniele Alessandri - */ -class StringIncrement extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'INCR'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringIncrementBy.php b/vendor/predis/predis/lib/Predis/Command/StringIncrementBy.php deleted file mode 100644 index 7fa31880a..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringIncrementBy.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/incrby - * @author Daniele Alessandri - */ -class StringIncrementBy extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'INCRBY'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringIncrementByFloat.php b/vendor/predis/predis/lib/Predis/Command/StringIncrementByFloat.php deleted file mode 100644 index 7e14dff39..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringIncrementByFloat.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/incrbyfloat - * @author Daniele Alessandri - */ -class StringIncrementByFloat extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'INCRBYFLOAT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringPreciseSetExpire.php b/vendor/predis/predis/lib/Predis/Command/StringPreciseSetExpire.php deleted file mode 100644 index da2cbadbf..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringPreciseSetExpire.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/psetex - * @author Daniele Alessandri - */ -class StringPreciseSetExpire extends StringSetExpire -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'PSETEX'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSet.php b/vendor/predis/predis/lib/Predis/Command/StringSet.php deleted file mode 100644 index eb3739b3f..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringSet.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/set - * @author Daniele Alessandri - */ -class StringSet extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SET'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetBit.php b/vendor/predis/predis/lib/Predis/Command/StringSetBit.php deleted file mode 100644 index a92b41851..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringSetBit.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/setbit - * @author Daniele Alessandri - */ -class StringSetBit extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SETBIT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetExpire.php b/vendor/predis/predis/lib/Predis/Command/StringSetExpire.php deleted file mode 100644 index c235e2bf1..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringSetExpire.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/setex - * @author Daniele Alessandri - */ -class StringSetExpire extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SETEX'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetMultiple.php b/vendor/predis/predis/lib/Predis/Command/StringSetMultiple.php deleted file mode 100644 index cda5157e6..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringSetMultiple.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/mset - * @author Daniele Alessandri - */ -class StringSetMultiple extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'MSET'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 1 && is_array($arguments[0])) { - $flattenedKVs = array(); - $args = $arguments[0]; - - foreach ($args as $k => $v) { - $flattenedKVs[] = $k; - $flattenedKVs[] = $v; - } - - return $flattenedKVs; - } - - return $arguments; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::interleaved($this, $prefix); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetMultiplePreserve.php b/vendor/predis/predis/lib/Predis/Command/StringSetMultiplePreserve.php deleted file mode 100644 index 961422d99..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringSetMultiplePreserve.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/msetnx - * @author Daniele Alessandri - */ -class StringSetMultiplePreserve extends StringSetMultiple -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'MSETNX'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetPreserve.php b/vendor/predis/predis/lib/Predis/Command/StringSetPreserve.php deleted file mode 100644 index d6e4a8135..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringSetPreserve.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/setnx - * @author Daniele Alessandri - */ -class StringSetPreserve extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SETNX'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSetRange.php b/vendor/predis/predis/lib/Predis/Command/StringSetRange.php deleted file mode 100644 index da30f32df..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringSetRange.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/setrange - * @author Daniele Alessandri - */ -class StringSetRange extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SETRANGE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringStrlen.php b/vendor/predis/predis/lib/Predis/Command/StringStrlen.php deleted file mode 100644 index 1b839add3..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringStrlen.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/strlen - * @author Daniele Alessandri - */ -class StringStrlen extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'STRLEN'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/StringSubstr.php b/vendor/predis/predis/lib/Predis/Command/StringSubstr.php deleted file mode 100644 index 671fc169b..000000000 --- a/vendor/predis/predis/lib/Predis/Command/StringSubstr.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/substr - * @author Daniele Alessandri - */ -class StringSubstr extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'SUBSTR'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionDiscard.php b/vendor/predis/predis/lib/Predis/Command/TransactionDiscard.php deleted file mode 100644 index 67010b072..000000000 --- a/vendor/predis/predis/lib/Predis/Command/TransactionDiscard.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/discard - * @author Daniele Alessandri - */ -class TransactionDiscard extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'DISCARD'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionExec.php b/vendor/predis/predis/lib/Predis/Command/TransactionExec.php deleted file mode 100644 index 5141454f0..000000000 --- a/vendor/predis/predis/lib/Predis/Command/TransactionExec.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/exec - * @author Daniele Alessandri - */ -class TransactionExec extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'EXEC'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionMulti.php b/vendor/predis/predis/lib/Predis/Command/TransactionMulti.php deleted file mode 100644 index 8f4ccf18b..000000000 --- a/vendor/predis/predis/lib/Predis/Command/TransactionMulti.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/multi - * @author Daniele Alessandri - */ -class TransactionMulti extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'MULTI'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionUnwatch.php b/vendor/predis/predis/lib/Predis/Command/TransactionUnwatch.php deleted file mode 100644 index 697e09f96..000000000 --- a/vendor/predis/predis/lib/Predis/Command/TransactionUnwatch.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/unwatch - * @author Daniele Alessandri - */ -class TransactionUnwatch extends AbstractCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'UNWATCH'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/TransactionWatch.php b/vendor/predis/predis/lib/Predis/Command/TransactionWatch.php deleted file mode 100644 index a1dd9a2a1..000000000 --- a/vendor/predis/predis/lib/Predis/Command/TransactionWatch.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/watch - * @author Daniele Alessandri - */ -class TransactionWatch extends AbstractCommand implements PrefixableCommandInterface -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'WATCH'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (isset($arguments[0]) && is_array($arguments[0])) { - return $arguments[0]; - } - - return $arguments; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - PrefixHelpers::all($this, $prefix); - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - return (bool) $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetAdd.php b/vendor/predis/predis/lib/Predis/Command/ZSetAdd.php deleted file mode 100644 index 2dd86da5b..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetAdd.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zadd - * @author Daniele Alessandri - */ -class ZSetAdd extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZADD'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 2 && is_array($arguments[1])) { - $flattened = array($arguments[0]); - - foreach ($arguments[1] as $member => $score) { - $flattened[] = $score; - $flattened[] = $member; - } - - return $flattened; - } - - return $arguments; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetCardinality.php b/vendor/predis/predis/lib/Predis/Command/ZSetCardinality.php deleted file mode 100644 index 4e4432e67..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetCardinality.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zcard - * @author Daniele Alessandri - */ -class ZSetCardinality extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZCARD'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetCount.php b/vendor/predis/predis/lib/Predis/Command/ZSetCount.php deleted file mode 100644 index 2d8aa9ca9..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetCount.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zcount - * @author Daniele Alessandri - */ -class ZSetCount extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZCOUNT'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetIncrementBy.php b/vendor/predis/predis/lib/Predis/Command/ZSetIncrementBy.php deleted file mode 100644 index a32bfabdd..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetIncrementBy.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zincrby - * @author Daniele Alessandri - */ -class ZSetIncrementBy extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZINCRBY'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetIntersectionStore.php b/vendor/predis/predis/lib/Predis/Command/ZSetIntersectionStore.php deleted file mode 100644 index 9f6b10943..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetIntersectionStore.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zinterstore - * @author Daniele Alessandri - */ -class ZSetIntersectionStore extends ZSetUnionStore -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZINTERSTORE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRange.php b/vendor/predis/predis/lib/Predis/Command/ZSetRange.php deleted file mode 100644 index a719fda2a..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetRange.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zrange - * @author Daniele Alessandri - */ -class ZSetRange extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZRANGE'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 4) { - $lastType = gettype($arguments[3]); - - if ($lastType === 'string' && strtoupper($arguments[3]) === 'WITHSCORES') { - // Used for compatibility with older versions - $arguments[3] = array('WITHSCORES' => true); - $lastType = 'array'; - } - - if ($lastType === 'array') { - $options = $this->prepareOptions(array_pop($arguments)); - - return array_merge($arguments, $options); - } - } - - return $arguments; - } - - /** - * Returns a list of options and modifiers compatible with Redis. - * - * @param array $options List of options. - * @return array - */ - protected function prepareOptions($options) - { - $opts = array_change_key_case($options, CASE_UPPER); - $finalizedOpts = array(); - - if (!empty($opts['WITHSCORES'])) { - $finalizedOpts[] = 'WITHSCORES'; - } - - return $finalizedOpts; - } - - /** - * Checks for the presence of the WITHSCORES modifier. - * - * @return bool - */ - protected function withScores() - { - $arguments = $this->getArguments(); - - if (count($arguments) < 4) { - return false; - } - - return strtoupper($arguments[3]) === 'WITHSCORES'; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - if ($this->withScores()) { - $result = array(); - - for ($i = 0; $i < count($data); $i++) { - $result[] = array($data[$i], $data[++$i]); - } - - return $result; - } - - return $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRangeByScore.php b/vendor/predis/predis/lib/Predis/Command/ZSetRangeByScore.php deleted file mode 100644 index cfe73aabf..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetRangeByScore.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zrangebyscore - * @author Daniele Alessandri - */ -class ZSetRangeByScore extends ZSetRange -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZRANGEBYSCORE'; - } - - /** - * {@inheritdoc} - */ - protected function prepareOptions($options) - { - $opts = array_change_key_case($options, CASE_UPPER); - $finalizedOpts = array(); - - if (isset($opts['LIMIT']) && is_array($opts['LIMIT'])) { - $limit = array_change_key_case($opts['LIMIT'], CASE_UPPER); - - $finalizedOpts[] = 'LIMIT'; - $finalizedOpts[] = isset($limit['OFFSET']) ? $limit['OFFSET'] : $limit[0]; - $finalizedOpts[] = isset($limit['COUNT']) ? $limit['COUNT'] : $limit[1]; - } - - return array_merge($finalizedOpts, parent::prepareOptions($options)); - } - - /** - * {@inheritdoc} - */ - protected function withScores() - { - $arguments = $this->getArguments(); - - for ($i = 3; $i < count($arguments); $i++) { - switch (strtoupper($arguments[$i])) { - case 'WITHSCORES': - return true; - - case 'LIMIT': - $i += 2; - break; - } - } - - return false; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRank.php b/vendor/predis/predis/lib/Predis/Command/ZSetRank.php deleted file mode 100644 index 41c2ae2a2..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetRank.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zrank - * @author Daniele Alessandri - */ -class ZSetRank extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZRANK'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRemove.php b/vendor/predis/predis/lib/Predis/Command/ZSetRemove.php deleted file mode 100644 index ae7208d8f..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetRemove.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zrem - * @author Daniele Alessandri - */ -class ZSetRemove extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZREM'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - return self::normalizeVariadic($arguments); - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByRank.php b/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByRank.php deleted file mode 100644 index 45b90284a..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByRank.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zremrangebyrank - * @author Daniele Alessandri - */ -class ZSetRemoveRangeByRank extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZREMRANGEBYRANK'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByScore.php b/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByScore.php deleted file mode 100644 index a2b3ad8d5..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetRemoveRangeByScore.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zremrangebyscore - * @author Daniele Alessandri - */ -class ZSetRemoveRangeByScore extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZREMRANGEBYSCORE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRange.php b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRange.php deleted file mode 100644 index e7344e0a5..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRange.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zrevrange - * @author Daniele Alessandri - */ -class ZSetReverseRange extends ZSetRange -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZREVRANGE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRangeByScore.php b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRangeByScore.php deleted file mode 100644 index cded7c1c0..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRangeByScore.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zrevrangebyscore - * @author Daniele Alessandri - */ -class ZSetReverseRangeByScore extends ZSetRangeByScore -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZREVRANGEBYSCORE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRank.php b/vendor/predis/predis/lib/Predis/Command/ZSetReverseRank.php deleted file mode 100644 index feb104879..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetReverseRank.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zrevrank - * @author Daniele Alessandri - */ -class ZSetReverseRank extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZREVRANK'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetScan.php b/vendor/predis/predis/lib/Predis/Command/ZSetScan.php deleted file mode 100644 index 41d22e54c..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetScan.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zscan - * @author Daniele Alessandri - */ -class ZSetScan extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZSCAN'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - if (count($arguments) === 3 && is_array($arguments[2])) { - $options = $this->prepareOptions(array_pop($arguments)); - $arguments = array_merge($arguments, $options); - } - - return $arguments; - } - - /** - * Returns a list of options and modifiers compatible with Redis. - * - * @param array $options List of options. - * @return array - */ - protected function prepareOptions($options) - { - $options = array_change_key_case($options, CASE_UPPER); - $normalized = array(); - - if (!empty($options['MATCH'])) { - $normalized[] = 'MATCH'; - $normalized[] = $options['MATCH']; - } - - if (!empty($options['COUNT'])) { - $normalized[] = 'COUNT'; - $normalized[] = $options['COUNT']; - } - - return $normalized; - } - - /** - * {@inheritdoc} - */ - public function parseResponse($data) - { - if (is_array($data)) { - $data[0] = (int) $data[0]; - - $members = $data[1]; - $result = array(); - - for ($i = 0; $i < count($members); $i++) { - $result[] = array($members[$i], (float) $members[++$i]); - } - - $data[1] = $result; - } - - return $data; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetScore.php b/vendor/predis/predis/lib/Predis/Command/ZSetScore.php deleted file mode 100644 index 8455e4eff..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetScore.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zscore - * @author Daniele Alessandri - */ -class ZSetScore extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZSCORE'; - } -} diff --git a/vendor/predis/predis/lib/Predis/Command/ZSetUnionStore.php b/vendor/predis/predis/lib/Predis/Command/ZSetUnionStore.php deleted file mode 100644 index 725d2b0c3..000000000 --- a/vendor/predis/predis/lib/Predis/Command/ZSetUnionStore.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @link http://redis.io/commands/zunionstore - * @author Daniele Alessandri - */ -class ZSetUnionStore extends PrefixableCommand -{ - /** - * {@inheritdoc} - */ - public function getId() - { - return 'ZUNIONSTORE'; - } - - /** - * {@inheritdoc} - */ - protected function filterArguments(Array $arguments) - { - $options = array(); - $argc = count($arguments); - - if ($argc > 2 && is_array($arguments[$argc - 1])) { - $options = $this->prepareOptions(array_pop($arguments)); - } - - if (is_array($arguments[1])) { - $arguments = array_merge( - array($arguments[0], count($arguments[1])), - $arguments[1] - ); - } - - return array_merge($arguments, $options); - } - - /** - * Returns a list of options and modifiers compatible with Redis. - * - * @param array $options List of options. - * @return array - */ - private function prepareOptions($options) - { - $opts = array_change_key_case($options, CASE_UPPER); - $finalizedOpts = array(); - - if (isset($opts['WEIGHTS']) && is_array($opts['WEIGHTS'])) { - $finalizedOpts[] = 'WEIGHTS'; - - foreach ($opts['WEIGHTS'] as $weight) { - $finalizedOpts[] = $weight; - } - } - - if (isset($opts['AGGREGATE'])) { - $finalizedOpts[] = 'AGGREGATE'; - $finalizedOpts[] = $opts['AGGREGATE']; - } - - return $finalizedOpts; - } - - /** - * {@inheritdoc} - */ - public function prefixKeys($prefix) - { - if ($arguments = $this->getArguments()) { - $arguments[0] = "$prefix{$arguments[0]}"; - $length = ((int) $arguments[1]) + 2; - - for ($i = 2; $i < $length; $i++) { - $arguments[$i] = "$prefix{$arguments[$i]}"; - } - - $this->setRawArguments($arguments); - } - } -} diff --git a/vendor/predis/predis/lib/Predis/CommunicationException.php b/vendor/predis/predis/lib/Predis/CommunicationException.php deleted file mode 100644 index a44b27dd4..000000000 --- a/vendor/predis/predis/lib/Predis/CommunicationException.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use Predis\Connection\SingleConnectionInterface; - -/** - * Base exception class for network-related errors. - * - * @author Daniele Alessandri - */ -abstract class CommunicationException extends PredisException -{ - private $connection; - - /** - * @param SingleConnectionInterface $connection Connection that generated the exception. - * @param string $message Error message. - * @param int $code Error code. - * @param \Exception $innerException Inner exception for wrapping the original error. - */ - public function __construct( - SingleConnectionInterface $connection, $message = null, $code = null, \Exception $innerException = null - ) { - parent::__construct($message, $code, $innerException); - $this->connection = $connection; - } - - /** - * Gets the connection that generated the exception. - * - * @return SingleConnectionInterface - */ - public function getConnection() - { - return $this->connection; - } - - /** - * Indicates if the receiver should reset the underlying connection. - * - * @return bool - */ - public function shouldResetConnection() - { - return true; - } - - /** - * Offers a generic and reusable method to handle exceptions generated by - * a connection object. - * - * @param CommunicationException $exception Exception. - */ - public static function handle(CommunicationException $exception) - { - if ($exception->shouldResetConnection()) { - $connection = $exception->getConnection(); - - if ($connection->isConnected()) { - $connection->disconnect(); - } - } - - throw $exception; - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php b/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php deleted file mode 100644 index 8ebf05028..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/AbstractConnection.php +++ /dev/null @@ -1,227 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\ClientException; -use Predis\CommunicationException; -use Predis\NotSupportedException; -use Predis\Command\CommandInterface; -use Predis\Protocol\ProtocolException; - -/** - * Base class with the common logic used by connection classes to communicate with Redis. - * - * @author Daniele Alessandri - */ -abstract class AbstractConnection implements SingleConnectionInterface -{ - private $resource; - private $cachedId; - - protected $parameters; - protected $initCmds = array(); - - /** - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - */ - public function __construct(ConnectionParametersInterface $parameters) - { - $this->parameters = $this->checkParameters($parameters); - } - - /** - * Disconnects from the server and destroys the underlying resource when - * PHP's garbage collector kicks in. - */ - public function __destruct() - { - $this->disconnect(); - } - - /** - * Checks some of the parameters used to initialize the connection. - * - * @param ConnectionParametersInterface $parameters Initialization parameters for the connection. - * @return ConnectionParametersInterface - */ - protected function checkParameters(ConnectionParametersInterface $parameters) - { - switch ($parameters->scheme) { - case 'unix': - if (!isset($parameters->path)) { - throw new \InvalidArgumentException('Missing UNIX domain socket path'); - } - - case 'tcp': - return $parameters; - - default: - throw new \InvalidArgumentException("Invalid scheme: {$parameters->scheme}"); - } - } - - /** - * Creates the underlying resource used to communicate with Redis. - * - * @return mixed - */ - abstract protected function createResource(); - - /** - * {@inheritdoc} - */ - public function isConnected() - { - return isset($this->resource); - } - - /** - * {@inheritdoc} - */ - public function connect() - { - if ($this->isConnected()) { - throw new ClientException('Connection already estabilished'); - } - - $this->resource = $this->createResource(); - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - unset($this->resource); - } - - /** - * {@inheritdoc} - */ - public function pushInitCommand(CommandInterface $command) - { - $this->initCmds[] = $command; - } - - /** - * {@inheritdoc} - */ - public function executeCommand(CommandInterface $command) - { - $this->writeCommand($command); - - return $this->readResponse($command); - } - - /** - * {@inheritdoc} - */ - public function readResponse(CommandInterface $command) - { - return $this->read(); - } - - /** - * Helper method to handle connection errors. - * - * @param string $message Error message. - * @param int $code Error code. - */ - protected function onConnectionError($message, $code = null) - { - CommunicationException::handle(new ConnectionException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]", $code)); - } - - /** - * Helper method to handle protocol errors. - * - * @param string $message Error message. - */ - protected function onProtocolError($message) - { - CommunicationException::handle(new ProtocolException($this, "$message [{$this->parameters->scheme}://{$this->getIdentifier()}]")); - } - - /** - * Helper method to handle not supported connection parameters. - * - * @param string $option Name of the option. - * @param mixed $parameters Parameters used to initialize the connection. - */ - protected function onInvalidOption($option, $parameters = null) - { - $class = get_called_class(); - $message = "Invalid option for connection $class: $option"; - - if (isset($parameters)) { - $message .= sprintf(' [%s => %s]', $option, $parameters->{$option}); - } - - throw new NotSupportedException($message); - } - - /** - * {@inheritdoc} - */ - public function getResource() - { - if (isset($this->resource)) { - return $this->resource; - } - - $this->connect(); - - return $this->resource; - } - - /** - * {@inheritdoc} - */ - public function getParameters() - { - return $this->parameters; - } - - /** - * Gets an identifier for the connection. - * - * @return string - */ - protected function getIdentifier() - { - if ($this->parameters->scheme === 'unix') { - return $this->parameters->path; - } - - return "{$this->parameters->host}:{$this->parameters->port}"; - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - if (!isset($this->cachedId)) { - $this->cachedId = $this->getIdentifier(); - } - - return $this->cachedId; - } - - /** - * {@inheritdoc} - */ - public function __sleep() - { - return array('parameters', 'initCmds'); - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/AggregatedConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/AggregatedConnectionInterface.php deleted file mode 100644 index 0b2c156ad..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/AggregatedConnectionInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\Command\CommandInterface; - -/** - * Defines a virtual connection composed by multiple connection objects. - * - * @author Daniele Alessandri - */ -interface AggregatedConnectionInterface extends ConnectionInterface -{ - /** - * Adds a connection instance to the aggregated connection. - * - * @param SingleConnectionInterface $connection Instance of a connection. - */ - public function add(SingleConnectionInterface $connection); - - /** - * Removes the specified connection instance from the aggregated - * connection. - * - * @param SingleConnectionInterface $connection Instance of a connection. - * @return bool Returns true if the connection was in the pool. - */ - public function remove(SingleConnectionInterface $connection); - - /** - * Gets the actual connection instance in charge of the specified command. - * - * @param CommandInterface $command Instance of a Redis command. - * @return SingleConnectionInterface - */ - public function getConnection(CommandInterface $command); - - /** - * Retrieves a connection instance from the aggregated connection - * using an alias. - * - * @param string $connectionId Alias of a connection - * @return SingleConnectionInterface - */ - public function getConnectionById($connectionId); -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ClusterConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/ClusterConnectionInterface.php deleted file mode 100644 index 956ef2c31..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ClusterConnectionInterface.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -/** - * Defines a cluster of Redis servers formed by aggregating multiple - * connection objects. - * - * @author Daniele Alessandri - */ -interface ClusterConnectionInterface extends AggregatedConnectionInterface -{ -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ComposableConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/ComposableConnectionInterface.php deleted file mode 100644 index 8b63536db..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ComposableConnectionInterface.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\Protocol\ProtocolInterface; - -/** - * Defines a connection object used to communicate with a single Redis server - * that leverages an external protocol processor to handle pluggable protocol - * handlers. - * - * @author Daniele Alessandri - */ -interface ComposableConnectionInterface extends SingleConnectionInterface -{ - /** - * Sets the protocol processor used by the connection. - * - * @param ProtocolInterface $protocol Protocol processor. - */ - public function setProtocol(ProtocolInterface $protocol); - - /** - * Gets the protocol processor used by the connection. - */ - public function getProtocol(); - - /** - * Writes a buffer that contains a serialized Redis command. - * - * @param string $buffer Serialized Redis command. - */ - public function writeBytes($buffer); - - /** - * Reads a specified number of bytes from the connection. - * - * @param string - */ - public function readBytes($length); - - /** - * Reads a line from the connection. - * - * @param string - */ - public function readLine(); -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ComposableStreamConnection.php b/vendor/predis/predis/lib/Predis/Connection/ComposableStreamConnection.php deleted file mode 100644 index 0c8630251..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ComposableStreamConnection.php +++ /dev/null @@ -1,135 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\Command\CommandInterface; -use Predis\Protocol\ProtocolInterface; -use Predis\Protocol\Text\TextProtocol; - -/** - * Connection abstraction to Redis servers based on PHP's stream that uses an - * external protocol processor defining the protocol used for the communication. - * - * @author Daniele Alessandri - */ -class ComposableStreamConnection extends StreamConnection implements ComposableConnectionInterface -{ - private $protocol; - - /** - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - * @param ProtocolInterface $protocol A protocol processor. - */ - public function __construct(ConnectionParametersInterface $parameters, ProtocolInterface $protocol = null) - { - $this->parameters = $this->checkParameters($parameters); - $this->protocol = $protocol ?: new TextProtocol(); - } - - /** - * {@inheritdoc} - */ - public function setProtocol(ProtocolInterface $protocol) - { - if ($protocol === null) { - throw new \InvalidArgumentException("The protocol instance cannot be a null value"); - } - - $this->protocol = $protocol; - } - - /** - * {@inheritdoc} - */ - public function getProtocol() - { - return $this->protocol; - } - - /** - * {@inheritdoc} - */ - public function writeBytes($buffer) - { - parent::writeBytes($buffer); - } - - /** - * {@inheritdoc} - */ - public function readBytes($length) - { - if ($length <= 0) { - throw new \InvalidArgumentException('Length parameter must be greater than 0'); - } - - $value = ''; - $socket = $this->getResource(); - - do { - $chunk = fread($socket, $length); - - if ($chunk === false || $chunk === '') { - $this->onConnectionError('Error while reading bytes from the server'); - } - - $value .= $chunk; - } while (($length -= strlen($chunk)) > 0); - - return $value; - } - - /** - * {@inheritdoc} - */ - public function readLine() - { - $value = ''; - $socket = $this->getResource(); - - do { - $chunk = fgets($socket); - - if ($chunk === false || $chunk === '') { - $this->onConnectionError('Error while reading line from the server'); - } - - $value .= $chunk; - } while (substr($value, -2) !== "\r\n"); - - return substr($value, 0, -2); - } - - /** - * {@inheritdoc} - */ - public function writeCommand(CommandInterface $command) - { - $this->protocol->write($this, $command); - } - - /** - * {@inheritdoc} - */ - public function read() - { - return $this->protocol->read($this); - } - - /** - * {@inheritdoc} - */ - public function __sleep() - { - return array_diff(array_merge(parent::__sleep(), array('protocol')), array('mbiterable')); - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionException.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionException.php deleted file mode 100644 index ef2e9d73a..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ConnectionException.php +++ /dev/null @@ -1,23 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\CommunicationException; - -/** - * Exception class that identifies connection-related errors. - * - * @author Daniele Alessandri - */ -class ConnectionException extends CommunicationException -{ -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionFactory.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionFactory.php deleted file mode 100644 index 1023adbcc..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ConnectionFactory.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\Profile\ServerProfileInterface; - -/** - * Provides a default factory for Redis connections that maps URI schemes - * to connection classes implementing Predis\Connection\SingleConnectionInterface. - * - * @author Daniele Alessandri - */ -class ConnectionFactory implements ConnectionFactoryInterface -{ - protected $schemes; - protected $profile; - - /** - * Initializes a new instance of the default connection factory class used by Predis. - * - * @param ServerProfileInterface $profile Server profile used to initialize new connections. - */ - public function __construct(ServerProfileInterface $profile = null) - { - $this->schemes = $this->getDefaultSchemes(); - $this->profile = $profile; - } - - /** - * Returns a named array that maps URI schemes to connection classes. - * - * @return array Map of URI schemes and connection classes. - */ - protected function getDefaultSchemes() - { - return array( - 'tcp' => 'Predis\Connection\StreamConnection', - 'unix' => 'Predis\Connection\StreamConnection', - 'http' => 'Predis\Connection\WebdisConnection', - ); - } - - /** - * Checks if the provided argument represents a valid connection class - * implementing Predis\Connection\SingleConnectionInterface. Optionally, - * callable objects are used for lazy initialization of connection objects. - * - * @param mixed $initializer FQN of a connection class or a callable for lazy initialization. - * @return mixed - */ - protected function checkInitializer($initializer) - { - if (is_callable($initializer)) { - return $initializer; - } - - $initializerReflection = new \ReflectionClass($initializer); - - if (!$initializerReflection->isSubclassOf('Predis\Connection\SingleConnectionInterface')) { - throw new \InvalidArgumentException( - 'A connection initializer must be a valid connection class or a callable object' - ); - } - - return $initializer; - } - - /** - * {@inheritdoc} - */ - public function define($scheme, $initializer) - { - $this->schemes[$scheme] = $this->checkInitializer($initializer); - } - - /** - * {@inheritdoc} - */ - public function undefine($scheme) - { - unset($this->schemes[$scheme]); - } - - /** - * {@inheritdoc} - */ - public function create($parameters) - { - if (!$parameters instanceof ConnectionParametersInterface) { - $parameters = new ConnectionParameters($parameters ?: array()); - } - - $scheme = $parameters->scheme; - - if (!isset($this->schemes[$scheme])) { - throw new \InvalidArgumentException("Unknown connection scheme: $scheme"); - } - - $initializer = $this->schemes[$scheme]; - - if (is_callable($initializer)) { - $connection = call_user_func($initializer, $parameters, $this); - } else { - $connection = new $initializer($parameters); - $this->prepareConnection($connection); - } - - if (!$connection instanceof SingleConnectionInterface) { - throw new \InvalidArgumentException( - 'Objects returned by connection initializers must implement ' . - 'Predis\Connection\SingleConnectionInterface' - ); - } - - return $connection; - } - - /** - * {@inheritdoc} - */ - public function createAggregated(AggregatedConnectionInterface $connection, Array $parameters) - { - foreach ($parameters as $node) { - $connection->add($node instanceof SingleConnectionInterface ? $node : $this->create($node)); - } - - return $connection; - } - - /** - * Prepares a connection object after its initialization. - * - * @param SingleConnectionInterface $connection Instance of a connection object. - */ - protected function prepareConnection(SingleConnectionInterface $connection) - { - if (isset($this->profile)) { - $parameters = $connection->getParameters(); - - if (isset($parameters->password)) { - $command = $this->profile->createCommand('auth', array($parameters->password)); - $connection->pushInitCommand($command); - } - - if (isset($parameters->database)) { - $command = $this->profile->createCommand('select', array($parameters->database)); - $connection->pushInitCommand($command); - } - } - } - - /** - * Sets the server profile used to create initialization commands for connections. - * - * @param ServerProfileInterface $profile Server profile instance. - */ - public function setProfile(ServerProfileInterface $profile) - { - $this->profile = $profile; - } - - /** - * Returns the server profile used to create initialization commands for connections. - * - * @return ServerProfileInterface - */ - public function getProfile() - { - return $this->profile; - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionFactoryInterface.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionFactoryInterface.php deleted file mode 100644 index 8bade2bfd..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ConnectionFactoryInterface.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -/** - * Interface that must be implemented by classes that provide their own mechanism - * to create and initialize new instances of Predis\Connection\SingleConnectionInterface. - * - * @author Daniele Alessandri - */ -interface ConnectionFactoryInterface -{ - /** - * Defines or overrides the connection class identified by a scheme prefix. - * - * @param string $scheme URI scheme identifying the connection class. - * @param mixed $initializer FQN of a connection class or a callable object for lazy initialization. - */ - public function define($scheme, $initializer); - - /** - * Undefines the connection identified by a scheme prefix. - * - * @param string $scheme Parameters for the connection. - */ - public function undefine($scheme); - - /** - * Creates a new connection object. - * - * @param mixed $parameters Parameters for the connection. - * @return SingleConnectionInterface - */ - public function create($parameters); - - /** - * Prepares an aggregation of connection objects. - * - * @param AggregatedConnectionInterface $cluster Instance of an aggregated connection class. - * @param array $parameters List of parameters for each connection object. - * @return AggregatedConnectionInterface - */ - public function createAggregated(AggregatedConnectionInterface $cluster, Array $parameters); -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionInterface.php deleted file mode 100644 index 1f51b0a19..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ConnectionInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\Command\CommandInterface; - -/** - * Defines a connection object used to communicate with one or multiple - * Redis servers. - * - * @author Daniele Alessandri - */ -interface ConnectionInterface -{ - /** - * Opens the connection. - */ - public function connect(); - - /** - * Closes the connection. - */ - public function disconnect(); - - /** - * Returns if the connection is open. - * - * @return bool - */ - public function isConnected(); - - /** - * Write a Redis command on the connection. - * - * @param CommandInterface $command Instance of a Redis command. - */ - public function writeCommand(CommandInterface $command); - - /** - * Reads the reply for a Redis command from the connection. - * - * @param CommandInterface $command Instance of a Redis command. - * @return mixed - */ - public function readResponse(CommandInterface $command); - - /** - * Writes a Redis command to the connection and reads back the reply. - * - * @param CommandInterface $command Instance of a Redis command. - * @return mixed - */ - public function executeCommand(CommandInterface $command); -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionParameters.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionParameters.php deleted file mode 100644 index b91d3af9c..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ConnectionParameters.php +++ /dev/null @@ -1,183 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\ClientException; - -/** - * Handles parsing and validation of connection parameters. - * - * @author Daniele Alessandri - */ -class ConnectionParameters implements ConnectionParametersInterface -{ - private $parameters; - - private static $defaults = array( - 'scheme' => 'tcp', - 'host' => '127.0.0.1', - 'port' => 6379, - 'timeout' => 5.0, - ); - - /** - * @param string|array $parameters Connection parameters in the form of an URI string or a named array. - */ - public function __construct($parameters = array()) - { - if (!is_array($parameters)) { - $parameters = self::parseURI($parameters); - } - - $this->parameters = $this->filter($parameters) + $this->getDefaults(); - } - - /** - * Returns some default parameters with their values. - * - * @return array - */ - protected function getDefaults() - { - return self::$defaults; - } - - /** - * Returns cast functions for user-supplied parameter values. - * - * @return array - */ - protected function getValueCasters() - { - return array( - 'port' => 'self::castInteger', - 'async_connect' => 'self::castBoolean', - 'persistent' => 'self::castBoolean', - 'timeout' => 'self::castFloat', - 'read_write_timeout' => 'self::castFloat', - 'iterable_multibulk' => 'self::castBoolean', - ); - } - - /** - * Validates value as boolean. - * - * @param mixed $value Input value. - * @return bool - */ - private static function castBoolean($value) - { - return (bool) $value; - } - - /** - * Validates value as float. - * - * @param mixed $value Input value. - * @return float - */ - private static function castFloat($value) - { - return (float) $value; - } - - /** - * Validates value as integer. - * - * @param mixed $value Input value. - * @return int - */ - private static function castInteger($value) - { - return (int) $value; - } - - /** - * Parses an URI string and returns an array of connection parameters. - * - * @param string $uri Connection string. - * @return array - */ - public static function parseURI($uri) - { - if (stripos($uri, 'unix') === 0) { - // Hack to support URIs for UNIX sockets with minimal effort. - $uri = str_ireplace('unix:///', 'unix://localhost/', $uri); - } - - if (!($parsed = @parse_url($uri)) || !isset($parsed['host'])) { - throw new ClientException("Invalid URI: $uri"); - } - - if (isset($parsed['query'])) { - parse_str($parsed['query'], $queryarray); - unset($parsed['query']); - - $parsed = array_merge($parsed, $queryarray); - } - - return $parsed; - } - - /** - * Validates and converts each value of the connection parameters array. - * - * @param array $parameters Connection parameters. - * @return array - */ - private function filter(Array $parameters) - { - if ($parameters) { - $casters = array_intersect_key($this->getValueCasters(), $parameters); - - foreach ($casters as $parameter => $caster) { - $parameters[$parameter] = call_user_func($caster, $parameters[$parameter]); - } - } - - return $parameters; - } - - /** - * {@inheritdoc} - */ - public function __get($parameter) - { - if (isset($this->{$parameter})) { - return $this->parameters[$parameter]; - } - } - - /** - * {@inheritdoc} - */ - public function __isset($parameter) - { - return isset($this->parameters[$parameter]); - } - - /** - * {@inheritdoc} - */ - public function toArray() - { - return $this->parameters; - } - - /** - * {@inheritdoc} - */ - public function __sleep() - { - return array('parameters'); - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ConnectionParametersInterface.php b/vendor/predis/predis/lib/Predis/Connection/ConnectionParametersInterface.php deleted file mode 100644 index 37282178c..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ConnectionParametersInterface.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -/** - * Interface that must be implemented by classes that provide their own mechanism - * to parse and handle connection parameters. - * - * @author Daniele Alessandri - */ -interface ConnectionParametersInterface -{ - /** - * Checks if the specified parameters is set. - * - * @param string $parameter Name of the parameter. - * @return bool - */ - public function __isset($parameter); - - /** - * Returns the value of the specified parameter. - * - * @param string $parameter Name of the parameter. - * @return mixed - */ - public function __get($parameter); - - /** - * Returns an array representation of the connection parameters. - * - * @return array - */ - public function toArray(); -} diff --git a/vendor/predis/predis/lib/Predis/Connection/MasterSlaveReplication.php b/vendor/predis/predis/lib/Predis/Connection/MasterSlaveReplication.php deleted file mode 100644 index 91c8de464..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/MasterSlaveReplication.php +++ /dev/null @@ -1,261 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\Command\CommandInterface; -use Predis\Replication\ReplicationStrategy; - -/** - * Aggregated connection class used by to handle replication with a - * group of servers in a master/slave configuration. - * - * @author Daniele Alessandri - */ -class MasterSlaveReplication implements ReplicationConnectionInterface -{ - protected $strategy; - protected $master; - protected $slaves; - protected $current; - - /** - * - */ - public function __construct(ReplicationStrategy $strategy = null) - { - $this->slaves = array(); - $this->strategy = $strategy ?: new ReplicationStrategy(); - } - - /** - * Checks if one master and at least one slave have been defined. - */ - protected function check() - { - if (!isset($this->master) || !$this->slaves) { - throw new \RuntimeException('Replication needs a master and at least one slave.'); - } - } - - /** - * Resets the connection state. - */ - protected function reset() - { - $this->current = null; - } - - /** - * {@inheritdoc} - */ - public function add(SingleConnectionInterface $connection) - { - $alias = $connection->getParameters()->alias; - - if ($alias === 'master') { - $this->master = $connection; - } else { - $this->slaves[$alias ?: count($this->slaves)] = $connection; - } - - $this->reset(); - } - - /** - * {@inheritdoc} - */ - public function remove(SingleConnectionInterface $connection) - { - if ($connection->getParameters()->alias === 'master') { - $this->master = null; - $this->reset(); - - return true; - } else { - if (($id = array_search($connection, $this->slaves, true)) !== false) { - unset($this->slaves[$id]); - $this->reset(); - - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getConnection(CommandInterface $command) - { - if ($this->current === null) { - $this->check(); - $this->current = $this->strategy->isReadOperation($command) ? $this->pickSlave() : $this->master; - - return $this->current; - } - - if ($this->current === $this->master) { - return $this->current; - } - - if (!$this->strategy->isReadOperation($command)) { - $this->current = $this->master; - } - - return $this->current; - } - - /** - * {@inheritdoc} - */ - public function getConnectionById($connectionId) - { - if ($connectionId === 'master') { - return $this->master; - } - - if (isset($this->slaves[$connectionId])) { - return $this->slaves[$connectionId]; - } - - return null; - } - - /** - * {@inheritdoc} - */ - public function switchTo($connection) - { - $this->check(); - - if (!$connection instanceof SingleConnectionInterface) { - $connection = $this->getConnectionById($connection); - } - if ($connection !== $this->master && !in_array($connection, $this->slaves, true)) { - throw new \InvalidArgumentException('The specified connection is not valid.'); - } - - $this->current = $connection; - } - - /** - * {@inheritdoc} - */ - public function getCurrent() - { - return $this->current; - } - - /** - * {@inheritdoc} - */ - public function getMaster() - { - return $this->master; - } - - /** - * {@inheritdoc} - */ - public function getSlaves() - { - return array_values($this->slaves); - } - - /** - * Returns the underlying replication strategy. - * - * @return ReplicationStrategy - */ - public function getReplicationStrategy() - { - return $this->strategy; - } - - /** - * Returns a random slave. - * - * @return SingleConnectionInterface - */ - protected function pickSlave() - { - return $this->slaves[array_rand($this->slaves)]; - } - - /** - * {@inheritdoc} - */ - public function isConnected() - { - return $this->current ? $this->current->isConnected() : false; - } - - /** - * {@inheritdoc} - */ - public function connect() - { - if ($this->current === null) { - $this->check(); - $this->current = $this->pickSlave(); - } - - $this->current->connect(); - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - if ($this->master) { - $this->master->disconnect(); - } - - foreach ($this->slaves as $connection) { - $connection->disconnect(); - } - } - - /** - * {@inheritdoc} - */ - public function writeCommand(CommandInterface $command) - { - $this->getConnection($command)->writeCommand($command); - } - - /** - * {@inheritdoc} - */ - public function readResponse(CommandInterface $command) - { - return $this->getConnection($command)->readResponse($command); - } - - /** - * {@inheritdoc} - */ - public function executeCommand(CommandInterface $command) - { - return $this->getConnection($command)->executeCommand($command); - } - - /** - * {@inheritdoc} - */ - public function __sleep() - { - return array('master', 'slaves', 'strategy'); - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/PhpiredisConnection.php b/vendor/predis/predis/lib/Predis/Connection/PhpiredisConnection.php deleted file mode 100644 index c37654883..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/PhpiredisConnection.php +++ /dev/null @@ -1,393 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\NotSupportedException; -use Predis\ResponseError; -use Predis\ResponseQueued; -use Predis\Command\CommandInterface; - -/** - * This class provides the implementation of a Predis connection that uses the - * PHP socket extension for network communication and wraps the phpiredis C - * extension (PHP bindings for hiredis) to parse the Redis protocol. Everything - * is highly experimental (even the very same phpiredis since it is quite new), - * so use it at your own risk. - * - * This class is mainly intended to provide an optional low-overhead alternative - * for processing replies from Redis compared to the standard pure-PHP classes. - * Differences in speed when dealing with short inline replies are practically - * nonexistent, the actual speed boost is for long multibulk replies when this - * protocol processor can parse and return replies very fast. - * - * For instructions on how to build and install the phpiredis extension, please - * consult the repository of the project. - * - * The connection parameters supported by this class are: - * - * - scheme: it can be either 'tcp' or 'unix'. - * - host: hostname or IP address of the server. - * - port: TCP port of the server. - * - path: path of a UNIX domain socket when scheme is 'unix'. - * - timeout: timeout to perform the connection. - * - read_write_timeout: timeout of read / write operations. - * - * @link http://github.com/nrk/phpiredis - * @author Daniele Alessandri - */ -class PhpiredisConnection extends AbstractConnection -{ - const ERR_MSG_EXTENSION = 'The %s extension must be loaded in order to be able to use this connection class'; - - private $reader; - - /** - * {@inheritdoc} - */ - public function __construct(ConnectionParametersInterface $parameters) - { - $this->checkExtensions(); - $this->initializeReader(); - - parent::__construct($parameters); - } - - /** - * Disconnects from the server and destroys the underlying resource and the - * protocol reader resource when PHP's garbage collector kicks in. - */ - public function __destruct() - { - phpiredis_reader_destroy($this->reader); - - parent::__destruct(); - } - - /** - * Checks if the socket and phpiredis extensions are loaded in PHP. - */ - private function checkExtensions() - { - if (!function_exists('socket_create')) { - throw new NotSupportedException(sprintf(self::ERR_MSG_EXTENSION, 'socket')); - } - if (!function_exists('phpiredis_reader_create')) { - throw new NotSupportedException(sprintf(self::ERR_MSG_EXTENSION, 'phpiredis')); - } - } - - /** - * {@inheritdoc} - */ - protected function checkParameters(ConnectionParametersInterface $parameters) - { - if (isset($parameters->iterable_multibulk)) { - $this->onInvalidOption('iterable_multibulk', $parameters); - } - if (isset($parameters->persistent)) { - $this->onInvalidOption('persistent', $parameters); - } - - return parent::checkParameters($parameters); - } - - /** - * Initializes the protocol reader resource. - */ - private function initializeReader() - { - $reader = phpiredis_reader_create(); - - phpiredis_reader_set_status_handler($reader, $this->getStatusHandler()); - phpiredis_reader_set_error_handler($reader, $this->getErrorHandler()); - - $this->reader = $reader; - } - - /** - * Gets the handler used by the protocol reader to handle status replies. - * - * @return \Closure - */ - private function getStatusHandler() - { - return function ($payload) { - switch ($payload) { - case 'OK': - return true; - - case 'QUEUED': - return new ResponseQueued(); - - default: - return $payload; - } - }; - } - - /** - * Gets the handler used by the protocol reader to handle Redis errors. - * - * @return \Closure - */ - private function getErrorHandler() - { - return function ($errorMessage) { - return new ResponseError($errorMessage); - }; - } - - /** - * Helper method used to throw exceptions on socket errors. - */ - private function emitSocketError() - { - $errno = socket_last_error(); - $errstr = socket_strerror($errno); - - $this->disconnect(); - - $this->onConnectionError(trim($errstr), $errno); - } - - /** - * {@inheritdoc} - */ - protected function createResource() - { - $parameters = $this->parameters; - - $isUnix = $this->parameters->scheme === 'unix'; - $domain = $isUnix ? AF_UNIX : AF_INET; - $protocol = $isUnix ? 0 : SOL_TCP; - - $socket = @call_user_func('socket_create', $domain, SOCK_STREAM, $protocol); - if (!is_resource($socket)) { - $this->emitSocketError(); - } - - $this->setSocketOptions($socket, $parameters); - - return $socket; - } - - /** - * Sets options on the socket resource from the connection parameters. - * - * @param resource $socket Socket resource. - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - */ - private function setSocketOptions($socket, ConnectionParametersInterface $parameters) - { - if ($parameters->scheme !== 'tcp') { - return; - } - - if (!socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1)) { - $this->emitSocketError(); - } - - if (!socket_set_option($socket, SOL_SOCKET, SO_REUSEADDR, 1)) { - $this->emitSocketError(); - } - - if (isset($parameters->read_write_timeout)) { - $rwtimeout = $parameters->read_write_timeout; - $timeoutSec = floor($rwtimeout); - $timeoutUsec = ($rwtimeout - $timeoutSec) * 1000000; - - $timeout = array( - 'sec' => $timeoutSec, - 'usec' => $timeoutUsec, - ); - - if (!socket_set_option($socket, SOL_SOCKET, SO_SNDTIMEO, $timeout)) { - $this->emitSocketError(); - } - - if (!socket_set_option($socket, SOL_SOCKET, SO_RCVTIMEO, $timeout)) { - $this->emitSocketError(); - } - } - } - - /** - * Gets the address from the connection parameters. - * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - * @return string - */ - protected static function getAddress(ConnectionParametersInterface $parameters) - { - if ($parameters->scheme === 'unix') { - return $parameters->path; - } - - $host = $parameters->host; - - if (ip2long($host) === false) { - if (false === $addresses = gethostbynamel($host)) { - return false; - } - - return $addresses[array_rand($addresses)]; - } - - return $host; - } - - /** - * Opens the actual connection to the server with a timeout. - * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - * @return string - */ - private function connectWithTimeout(ConnectionParametersInterface $parameters) - { - if (false === $host = self::getAddress($parameters)) { - $this->onConnectionError("Cannot resolve the address of '$parameters->host'."); - } - - $socket = $this->getResource(); - - socket_set_nonblock($socket); - - if (@socket_connect($socket, $host, $parameters->port) === false) { - $error = socket_last_error(); - if ($error != SOCKET_EINPROGRESS && $error != SOCKET_EALREADY) { - $this->emitSocketError(); - } - } - - socket_set_block($socket); - - $null = null; - $selectable = array($socket); - - $timeout = $parameters->timeout; - $timeoutSecs = floor($timeout); - $timeoutUSecs = ($timeout - $timeoutSecs) * 1000000; - - $selected = socket_select($selectable, $selectable, $null, $timeoutSecs, $timeoutUSecs); - - if ($selected === 2) { - $this->onConnectionError('Connection refused', SOCKET_ECONNREFUSED); - } - if ($selected === 0) { - $this->onConnectionError('Connection timed out', SOCKET_ETIMEDOUT); - } - if ($selected === false) { - $this->emitSocketError(); - } - } - - /** - * {@inheritdoc} - */ - public function connect() - { - parent::connect(); - - $this->connectWithTimeout($this->parameters); - - if ($this->initCmds) { - $this->sendInitializationCommands(); - } - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - if ($this->isConnected()) { - socket_close($this->getResource()); - parent::disconnect(); - } - } - - /** - * Sends the initialization commands to Redis when the connection is opened. - */ - private function sendInitializationCommands() - { - foreach ($this->initCmds as $command) { - $this->writeCommand($command); - } - foreach ($this->initCmds as $command) { - $this->readResponse($command); - } - } - - /** - * {@inheritdoc} - */ - protected function write($buffer) - { - $socket = $this->getResource(); - - while (($length = strlen($buffer)) > 0) { - $written = socket_write($socket, $buffer, $length); - - if ($length === $written) { - return; - } - if ($written === false) { - $this->onConnectionError('Error while writing bytes to the server'); - } - - $buffer = substr($buffer, $written); - } - } - - /** - * {@inheritdoc} - */ - public function read() - { - $socket = $this->getResource(); - $reader = $this->reader; - - while (($state = phpiredis_reader_get_state($reader)) === PHPIREDIS_READER_STATE_INCOMPLETE) { - if (@socket_recv($socket, $buffer, 4096, 0) === false || $buffer === '') { - $this->emitSocketError(); - } - - phpiredis_reader_feed($reader, $buffer); - } - - if ($state === PHPIREDIS_READER_STATE_COMPLETE) { - return phpiredis_reader_get_reply($reader); - } else { - $this->onProtocolError(phpiredis_reader_get_error($reader)); - } - } - - /** - * {@inheritdoc} - */ - public function writeCommand(CommandInterface $command) - { - $cmdargs = $command->getArguments(); - array_unshift($cmdargs, $command->getId()); - $this->write(phpiredis_format_command($cmdargs)); - } - - /** - * {@inheritdoc} - */ - public function __wakeup() - { - $this->checkExtensions(); - $this->initializeReader(); - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/PhpiredisStreamConnection.php b/vendor/predis/predis/lib/Predis/Connection/PhpiredisStreamConnection.php deleted file mode 100644 index 286e5226d..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/PhpiredisStreamConnection.php +++ /dev/null @@ -1,196 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\NotSupportedException; -use Predis\ResponseError; -use Predis\ResponseQueued; -use Predis\Command\CommandInterface; - -/** - * This class provides the implementation of a Predis connection that uses PHP's - * streams for network communication and wraps the phpiredis C extension (PHP - * bindings for hiredis) to parse and serialize the Redis protocol. Everything - * is highly experimental (even the very same phpiredis since it is quite new), - * so use it at your own risk. - * - * This class is mainly intended to provide an optional low-overhead alternative - * for processing replies from Redis compared to the standard pure-PHP classes. - * Differences in speed when dealing with short inline replies are practically - * nonexistent, the actual speed boost is for long multibulk replies when this - * protocol processor can parse and return replies very fast. - * - * For instructions on how to build and install the phpiredis extension, please - * consult the repository of the project. - * - * The connection parameters supported by this class are: - * - * - scheme: it can be either 'tcp' or 'unix'. - * - host: hostname or IP address of the server. - * - port: TCP port of the server. - * - path: path of a UNIX domain socket when scheme is 'unix'. - * - timeout: timeout to perform the connection. - * - read_write_timeout: timeout of read / write operations. - * - async_connect: performs the connection asynchronously. - * - tcp_nodelay: enables or disables Nagle's algorithm for coalescing. - * - persistent: the connection is left intact after a GC collection. - * - * @link https://github.com/nrk/phpiredis - * @author Daniele Alessandri - */ -class PhpiredisStreamConnection extends StreamConnection -{ - private $reader; - - /** - * {@inheritdoc} - */ - public function __construct(ConnectionParametersInterface $parameters) - { - $this->checkExtensions(); - $this->initializeReader(); - - parent::__construct($parameters); - } - - /** - * {@inheritdoc} - */ - public function __destruct() - { - phpiredis_reader_destroy($this->reader); - - parent::__destruct(); - } - - /** - * Checks if the phpiredis extension is loaded in PHP. - */ - protected function checkExtensions() - { - if (!function_exists('phpiredis_reader_create')) { - throw new NotSupportedException( - 'The phpiredis extension must be loaded in order to be able to use this connection class' - ); - } - } - - /** - * {@inheritdoc} - */ - protected function checkParameters(ConnectionParametersInterface $parameters) - { - if (isset($parameters->iterable_multibulk)) { - $this->onInvalidOption('iterable_multibulk', $parameters); - } - - return parent::checkParameters($parameters); - } - - /** - * Initializes the protocol reader resource. - */ - protected function initializeReader() - { - $reader = phpiredis_reader_create(); - - phpiredis_reader_set_status_handler($reader, $this->getStatusHandler()); - phpiredis_reader_set_error_handler($reader, $this->getErrorHandler()); - - $this->reader = $reader; - } - - /** - * Gets the handler used by the protocol reader to handle status replies. - * - * @return \Closure - */ - protected function getStatusHandler() - { - return function ($payload) { - switch ($payload) { - case 'OK': - return true; - - case 'QUEUED': - return new ResponseQueued(); - - default: - return $payload; - } - }; - } - - /** - * Gets the handler used by the protocol reader to handle Redis errors. - * - * @return \Closure - */ - protected function getErrorHandler() - { - return function ($errorMessage) { - return new ResponseError($errorMessage); - }; - } - - /** - * {@inheritdoc} - */ - public function read() - { - $socket = $this->getResource(); - $reader = $this->reader; - - while (PHPIREDIS_READER_STATE_INCOMPLETE === $state = phpiredis_reader_get_state($reader)) { - $buffer = fread($socket, 4096); - - if ($buffer === false || $buffer === '') { - $this->onConnectionError('Error while reading bytes from the server'); - } - - phpiredis_reader_feed($reader, $buffer); - } - - if ($state === PHPIREDIS_READER_STATE_COMPLETE) { - return phpiredis_reader_get_reply($reader); - } else { - $this->onProtocolError(phpiredis_reader_get_error($reader)); - } - } - - /** - * {@inheritdoc} - */ - public function writeCommand(CommandInterface $command) - { - $cmdargs = $command->getArguments(); - array_unshift($cmdargs, $command->getId()); - $this->writeBytes(phpiredis_format_command($cmdargs)); - } - - /** - * {@inheritdoc} - */ - public function __sleep() - { - return array_diff(parent::__sleep(), array('mbiterable')); - } - - /** - * {@inheritdoc} - */ - public function __wakeup() - { - $this->checkExtensions(); - $this->initializeReader(); - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/PredisCluster.php b/vendor/predis/predis/lib/Predis/Connection/PredisCluster.php deleted file mode 100644 index eb756f2aa..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/PredisCluster.php +++ /dev/null @@ -1,232 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\Cluster\CommandHashStrategyInterface; -use Predis\NotSupportedException; -use Predis\Cluster\PredisClusterHashStrategy; -use Predis\Cluster\Distribution\DistributionStrategyInterface; -use Predis\Cluster\Distribution\HashRing; -use Predis\Command\CommandInterface; - -/** - * Abstraction for a cluster of aggregated connections to various Redis servers - * implementing client-side sharding based on pluggable distribution strategies. - * - * @author Daniele Alessandri - * @todo Add the ability to remove connections from pool. - */ -class PredisCluster implements ClusterConnectionInterface, \IteratorAggregate, \Countable -{ - private $pool; - private $strategy; - private $distributor; - - /** - * @param DistributionStrategyInterface $distributor Distribution strategy used by the cluster. - */ - public function __construct(DistributionStrategyInterface $distributor = null) - { - $distributor = $distributor ?: new HashRing(); - - $this->pool = array(); - $this->strategy = new PredisClusterHashStrategy($distributor->getHashGenerator()); - $this->distributor = $distributor; - } - - /** - * {@inheritdoc} - */ - public function isConnected() - { - foreach ($this->pool as $connection) { - if ($connection->isConnected()) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function connect() - { - foreach ($this->pool as $connection) { - $connection->connect(); - } - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - foreach ($this->pool as $connection) { - $connection->disconnect(); - } - } - - /** - * {@inheritdoc} - */ - public function add(SingleConnectionInterface $connection) - { - $parameters = $connection->getParameters(); - - if (isset($parameters->alias)) { - $this->pool[$parameters->alias] = $connection; - } else { - $this->pool[] = $connection; - } - - $weight = isset($parameters->weight) ? $parameters->weight : null; - $this->distributor->add($connection, $weight); - } - - /** - * {@inheritdoc} - */ - public function remove(SingleConnectionInterface $connection) - { - if (($id = array_search($connection, $this->pool, true)) !== false) { - unset($this->pool[$id]); - $this->distributor->remove($connection); - - return true; - } - - return false; - } - - /** - * Removes a connection instance using its alias or index. - * - * @param string $connectionId Alias or index of a connection. - * @return bool Returns true if the connection was in the pool. - */ - public function removeById($connectionId) - { - if ($connection = $this->getConnectionById($connectionId)) { - return $this->remove($connection); - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function getConnection(CommandInterface $command) - { - $hash = $this->strategy->getHash($command); - - if (!isset($hash)) { - throw new NotSupportedException("Cannot use {$command->getId()} with a cluster of connections"); - } - - $node = $this->distributor->get($hash); - - return $node; - } - - /** - * {@inheritdoc} - */ - public function getConnectionById($connectionId) - { - return isset($this->pool[$connectionId]) ? $this->pool[$connectionId] : null; - } - - /** - * Retrieves a connection instance from the cluster using a key. - * - * @param string $key Key of a Redis value. - * @return SingleConnectionInterface - */ - public function getConnectionByKey($key) - { - $hash = $this->strategy->getKeyHash($key); - $node = $this->distributor->get($hash); - - return $node; - } - - /** - * Returns the underlying command hash strategy used to hash - * commands by their keys. - * - * @return CommandHashStrategyInterface - */ - public function getCommandHashStrategy() - { - return $this->strategy; - } - - /** - * {@inheritdoc} - */ - public function count() - { - return count($this->pool); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new \ArrayIterator($this->pool); - } - - /** - * {@inheritdoc} - */ - public function writeCommand(CommandInterface $command) - { - $this->getConnection($command)->writeCommand($command); - } - - /** - * {@inheritdoc} - */ - public function readResponse(CommandInterface $command) - { - return $this->getConnection($command)->readResponse($command); - } - - /** - * {@inheritdoc} - */ - public function executeCommand(CommandInterface $command) - { - return $this->getConnection($command)->executeCommand($command); - } - - /** - * Executes the specified Redis command on all the nodes of a cluster. - * - * @param CommandInterface $command A Redis command. - * @return array - */ - public function executeCommandOnNodes(CommandInterface $command) - { - $replies = array(); - - foreach ($this->pool as $connection) { - $replies[] = $connection->executeCommand($command); - } - - return $replies; - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/RedisCluster.php b/vendor/predis/predis/lib/Predis/Connection/RedisCluster.php deleted file mode 100644 index b7e324999..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/RedisCluster.php +++ /dev/null @@ -1,526 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use ArrayIterator; -use Countable; -use IteratorAggregate; -use OutOfBoundsException; -use Predis\NotSupportedException; -use Predis\ResponseErrorInterface; -use Predis\Cluster\CommandHashStrategyInterface; -use Predis\Cluster\RedisClusterHashStrategy; -use Predis\Command\CommandInterface; -use Predis\Command\RawCommand; - -/** - * Abstraction for a Redis-backed cluster of nodes (Redis >= 3.0.0). - * - * This connection backend offers smart support for redis-cluster by handling - * automatic slots map (re)generation upon -MOVE or -ASK responses returned by - * Redis when redirecting a client to a different node. - * - * The cluster can be pre-initialized using only a subset of the actual nodes in - * the cluster, Predis will do the rest by adjusting the slots map and creating - * the missing underlying connection instances on the fly. - * - * It is possible to pre-associate connections to a slots range with the "slots" - * parameter in the form "$first-$last". This can greatly reduce runtime node - * guessing and redirections. - * - * It is also possible to ask for the full and updated slots map directly to one - * of the nodes and optionally enable such a behaviour upon -MOVED redirections. - * Asking for the cluster configuration to Redis is actually done by issuing a - * CLUSTER NODES command to a random node in the pool. - * - * @author Daniele Alessandri - */ -class RedisCluster implements ClusterConnectionInterface, IteratorAggregate, Countable -{ - private $askClusterNodes = false; - private $defaultParameters = array(); - private $pool = array(); - private $slots = array(); - private $slotsMap; - private $strategy; - private $connections; - - /** - * @param ConnectionFactoryInterface $connections Connection factory object. - */ - public function __construct(ConnectionFactoryInterface $connections = null) - { - $this->strategy = new RedisClusterHashStrategy(); - $this->connections = $connections ?: new ConnectionFactory(); - } - - /** - * {@inheritdoc} - */ - public function isConnected() - { - foreach ($this->pool as $connection) { - if ($connection->isConnected()) { - return true; - } - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function connect() - { - if ($connection = $this->getRandomConnection()) { - $connection->connect(); - } - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - foreach ($this->pool as $connection) { - $connection->disconnect(); - } - } - - /** - * {@inheritdoc} - */ - public function add(SingleConnectionInterface $connection) - { - $this->pool[(string) $connection] = $connection; - unset($this->slotsMap); - } - - /** - * {@inheritdoc} - */ - public function remove(SingleConnectionInterface $connection) - { - if (false !== $id = array_search($connection, $this->pool, true)) { - unset( - $this->pool[$id], - $this->slotsMap - ); - - return true; - } - - return false; - } - - /** - * Removes a connection instance by using its identifier. - * - * @param string $connectionID Connection identifier. - * @return bool True if the connection was in the pool. - */ - public function removeById($connectionID) - { - if (isset($this->pool[$connectionID])) { - unset( - $this->pool[$connectionID], - $this->slotsMap - ); - - return true; - } - - return false; - } - - /** - * Generates the current slots map by guessing the cluster configuration out - * of the connection parameters of the connections in the pool. - * - * Generation is based on the same algorithm used by Redis to generate the - * cluster, so it is most effective when all of the connections supplied on - * initialization have the "slots" parameter properly set accordingly to the - * current cluster configuration. - */ - public function buildSlotsMap() - { - $this->slotsMap = array(); - - foreach ($this->pool as $connectionID => $connection) { - $parameters = $connection->getParameters(); - - if (!isset($parameters->slots)) { - continue; - } - - $slots = explode('-', $parameters->slots, 2); - $this->setSlots($slots[0], $slots[1], $connectionID); - } - } - - /** - * Generates the current slots map by fetching the cluster configuration to - * one of the nodes by leveraging the CLUSTER NODES command. - */ - public function askClusterNodes() - { - if (!$connection = $this->getRandomConnection()) { - return array(); - } - - $cmdCluster = RawCommand::create('CLUSTER', 'NODES'); - $response = $connection->executeCommand($cmdCluster); - - $nodes = explode("\n", $response, -1); - $count = count($nodes); - - for ($i = 0; $i < $count; $i++) { - $node = explode(' ', $nodes[$i], 9); - $slots = explode('-', $node[8], 2); - - if ($node[1] === ':0') { - $this->setSlots($slots[0], $slots[1], (string) $connection); - } else { - $this->setSlots($slots[0], $slots[1], $node[1]); - } - } - } - - /** - * Returns the current slots map for the cluster. - * - * @return array - */ - public function getSlotsMap() - { - if (!isset($this->slotsMap)) { - $this->slotsMap = array(); - } - - return $this->slotsMap; - } - - /** - * Pre-associates a connection to a slots range to avoid runtime guessing. - * - * @param int $first Initial slot of the range. - * @param int $last Last slot of the range. - * @param SingleConnectionInterface|string $connection ID or connection instance. - */ - public function setSlots($first, $last, $connection) - { - if ($first < 0x0000 || $first > 0x3FFF || - $last < 0x0000 || $last > 0x3FFF || - $last < $first - ) { - throw new OutOfBoundsException( - "Invalid slot range for $connection: [$first-$last]" - ); - } - - $slots = array_fill($first, $last - $first + 1, (string) $connection); - $this->slotsMap = $this->getSlotsMap() + $slots; - } - - /** - * Guesses the correct node associated to a given slot using a precalculated - * slots map, falling back to the same logic used by Redis to initialize a - * cluster (best-effort). - * - * @param int $slot Slot index. - * @return string Connection ID. - */ - protected function guessNode($slot) - { - if (!isset($this->slotsMap)) { - $this->buildSlotsMap(); - } - - if (isset($this->slotsMap[$slot])) { - return $this->slotsMap[$slot]; - } - - $count = count($this->pool); - $index = min((int) ($slot / (int) (16384 / $count)), $count - 1); - $nodes = array_keys($this->pool); - - return $nodes[$index]; - } - - /** - * Creates a new connection instance from the given connection ID. - * - * @param string $connectionID Identifier for the connection. - * @return SingleConnectionInterface - */ - protected function createConnection($connectionID) - { - $host = explode(':', $connectionID, 2); - - $parameters = array_merge($this->defaultParameters, array( - 'host' => $host[0], - 'port' => $host[1], - )); - - $connection = $this->connections->create($parameters); - - return $connection; - } - - /** - * {@inheritdoc} - */ - public function getConnection(CommandInterface $command) - { - $hash = $this->strategy->getHash($command); - - if (!isset($hash)) { - throw new NotSupportedException( - "Cannot use {$command->getId()} with redis-cluster" - ); - } - - $slot = $hash & 0x3FFF; - - if (isset($this->slots[$slot])) { - return $this->slots[$slot]; - } else { - return $this->getConnectionBySlot($slot); - } - } - - /** - * Returns the connection currently associated to a given slot. - * - * @param int $slot Slot index. - * @return SingleConnectionInterface - */ - public function getConnectionBySlot($slot) - { - if ($slot < 0x0000 || $slot > 0x3FFF) { - throw new OutOfBoundsException("Invalid slot [$slot]"); - } - - if (isset($this->slots[$slot])) { - return $this->slots[$slot]; - } - - $connectionID = $this->guessNode($slot); - - if (!$connection = $this->getConnectionById($connectionID)) { - $connection = $this->createConnection($connectionID); - $this->pool[$connectionID] = $connection; - } - - return $this->slots[$slot] = $connection; - } - - /** - * {@inheritdoc} - */ - public function getConnectionById($connectionID) - { - if (isset($this->pool[$connectionID])) { - return $this->pool[$connectionID]; - } - } - - /** - * Returns a random connection from the pool. - * - * @return SingleConnectionInterface - */ - protected function getRandomConnection() - { - if ($this->pool) { - return $this->pool[array_rand($this->pool)]; - } - } - - /** - * Permanently associates the connection instance to a new slot. - * The connection is added to the connections pool if not yet included. - * - * @param SingleConnectionInterface $connection Connection instance. - * @param int $slot Target slot index. - */ - protected function move(SingleConnectionInterface $connection, $slot) - { - $this->pool[(string) $connection] = $connection; - $this->slots[(int) $slot] = $connection; - } - - /** - * Handles -ERR responses returned by Redis. - * - * @param CommandInterface $command Command that generated the -ERR response. - * @param ResponseErrorInterface $error Redis error response object. - * @return mixed - */ - protected function onErrorResponse(CommandInterface $command, ResponseErrorInterface $error) - { - $details = explode(' ', $error->getMessage(), 2); - - switch ($details[0]) { - case 'MOVED': - return $this->onMovedResponse($command, $details[1]); - - case 'ASK': - return $this->onAskResponse($command, $details[1]); - - default: - return $error; - } - } - - /** - * Handles -MOVED responses by executing again the command against the node - * indicated by the Redis response. - * - * @param CommandInterface $command Command that generated the -MOVED response. - * @param string $details Parameters of the -MOVED response. - * @return mixed - */ - protected function onMovedResponse(CommandInterface $command, $details) - { - list($slot, $connectionID) = explode(' ', $details, 2); - - if (!$connection = $this->getConnectionById($connectionID)) { - $connection = $this->createConnection($connectionID); - } - - if ($this->askClusterNodes) { - $this->askClusterNodes(); - } - - $this->move($connection, $slot); - $response = $this->executeCommand($command); - - return $response; - } - - /** - * Handles -ASK responses by executing again the command against the node - * indicated by the Redis response. - * - * @param CommandInterface $command Command that generated the -ASK response. - * @param string $details Parameters of the -ASK response. - * @return mixed - */ - protected function onAskResponse(CommandInterface $command, $details) - { - list($slot, $connectionID) = explode(' ', $details, 2); - - if (!$connection = $this->getConnectionById($connectionID)) { - $connection = $this->createConnection($connectionID); - } - - $connection->executeCommand(RawCommand::create('ASKING')); - $response = $connection->executeCommand($command); - - return $response; - } - - /** - * {@inheritdoc} - */ - public function writeCommand(CommandInterface $command) - { - $this->getConnection($command)->writeCommand($command); - } - - /** - * {@inheritdoc} - */ - public function readResponse(CommandInterface $command) - { - return $this->getConnection($command)->readResponse($command); - } - - /** - * {@inheritdoc} - */ - public function executeCommand(CommandInterface $command) - { - $connection = $this->getConnection($command); - $response = $connection->executeCommand($command); - - if ($response instanceof ResponseErrorInterface) { - return $this->onErrorResponse($command, $response); - } - - return $response; - } - - /** - * {@inheritdoc} - */ - public function count() - { - return count($this->pool); - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - return new ArrayIterator(array_values($this->pool)); - } - - /** - * Returns the underlying hash strategy used to hash commands by their keys. - * - * @return CommandHashStrategyInterface - */ - public function getCommandHashStrategy() - { - return $this->strategy; - } - - /** - * Enables automatic fetching of the current slots map from one of the nodes - * using the CLUSTER NODES command. This option is disabled by default but - * asking the current slots map to Redis upon -MOVE responses may reduce - * overhead by eliminating the trial-and-error nature of the node guessing - * procedure, mostly when targeting many keys that would end up in a lot of - * redirections. - * - * The slots map can still be manually fetched using the askClusterNodes() - * method whether or not this option is enabled. - * - * @param bool $value Enable or disable the use of CLUSTER NODES. - */ - public function enableClusterNodes($value) - { - $this->askClusterNodes = (bool) $value; - } - - /** - * Sets a default array of connection parameters to be applied when creating - * new connection instances on the fly when they are not part of the initial - * pool supplied upon cluster initialization. - * - * These parameters are not applied to connections added to the pool using - * the add() method. - * - * @param array $parameters Array of connection parameters. - */ - public function setDefaultParameters(array $parameters) - { - $this->defaultParameters = array_merge( - $this->defaultParameters, - $parameters ?: array() - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/ReplicationConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/ReplicationConnectionInterface.php deleted file mode 100644 index 7142dfae9..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/ReplicationConnectionInterface.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -/** - * Defines a group of Redis servers in a master/slave replication configuration. - * - * @author Daniele Alessandri - */ -interface ReplicationConnectionInterface extends AggregatedConnectionInterface -{ - /** - * Switches the internal connection object being used. - * - * @param string $connection Alias of a connection - */ - public function switchTo($connection); - - /** - * Retrieves the connection object currently being used. - * - * @return SingleConnectionInterface - */ - public function getCurrent(); - - /** - * Retrieves the connection object to the master Redis server. - * - * @return SingleConnectionInterface - */ - public function getMaster(); - - /** - * Retrieves a list of connection objects to slaves Redis servers. - * - * @return SingleConnectionInterface - */ - public function getSlaves(); -} diff --git a/vendor/predis/predis/lib/Predis/Connection/SingleConnectionInterface.php b/vendor/predis/predis/lib/Predis/Connection/SingleConnectionInterface.php deleted file mode 100644 index 9b080c2bf..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/SingleConnectionInterface.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\Command\CommandInterface; - -/** - * Defines a connection object used to communicate with a single Redis server. - * - * @author Daniele Alessandri - */ -interface SingleConnectionInterface extends ConnectionInterface -{ - /** - * Returns a string representation of the connection. - * - * @return string - */ - public function __toString(); - - /** - * Returns the underlying resource used to communicate with a Redis server. - * - * @return mixed - */ - public function getResource(); - - /** - * Gets the parameters used to initialize the connection object. - * - * @return ConnectionParametersInterface - */ - public function getParameters(); - - /** - * Pushes the instance of a Redis command to the queue of commands executed - * when the actual connection to a server is estabilished. - * - * @param CommandInterface $command Instance of a Redis command. - */ - public function pushInitCommand(CommandInterface $command); - - /** - * Reads a reply from the server. - * - * @return mixed - */ - public function read(); -} diff --git a/vendor/predis/predis/lib/Predis/Connection/StreamConnection.php b/vendor/predis/predis/lib/Predis/Connection/StreamConnection.php deleted file mode 100644 index a42788b2d..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/StreamConnection.php +++ /dev/null @@ -1,307 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\ResponseError; -use Predis\ResponseQueued; -use Predis\Command\CommandInterface; -use Predis\Iterator\MultiBulkResponseSimple; - -/** - * Standard connection to Redis servers implemented on top of PHP's streams. - * The connection parameters supported by this class are: - * - * - scheme: it can be either 'tcp' or 'unix'. - * - host: hostname or IP address of the server. - * - port: TCP port of the server. - * - path: path of a UNIX domain socket when scheme is 'unix'. - * - timeout: timeout to perform the connection. - * - read_write_timeout: timeout of read / write operations. - * - async_connect: performs the connection asynchronously. - * - tcp_nodelay: enables or disables Nagle's algorithm for coalescing. - * - persistent: the connection is left intact after a GC collection. - * - iterable_multibulk: multibulk replies treated as iterable objects. - * - * @author Daniele Alessandri - */ -class StreamConnection extends AbstractConnection -{ - private $mbiterable; - - /** - * {@inheritdoc} - */ - public function __construct(ConnectionParametersInterface $parameters) - { - $this->mbiterable = (bool) $parameters->iterable_multibulk; - - parent::__construct($parameters); - } - - /** - * Disconnects from the server and destroys the underlying resource when - * PHP's garbage collector kicks in only if the connection has not been - * marked as persistent. - */ - public function __destruct() - { - if (isset($this->parameters) && !$this->parameters->persistent) { - $this->disconnect(); - } - } - - /** - * {@inheritdoc} - */ - protected function createResource() - { - $parameters = $this->parameters; - $initializer = "{$parameters->scheme}StreamInitializer"; - - return $this->$initializer($parameters); - } - - /** - * Initializes a TCP stream resource. - * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - * @return resource - */ - private function tcpStreamInitializer(ConnectionParametersInterface $parameters) - { - $uri = "tcp://{$parameters->host}:{$parameters->port}"; - $flags = STREAM_CLIENT_CONNECT; - - if (isset($parameters->async_connect) && $parameters->async_connect) { - $flags |= STREAM_CLIENT_ASYNC_CONNECT; - } - - if (isset($parameters->persistent) && $parameters->persistent) { - $flags |= STREAM_CLIENT_PERSISTENT; - $uri .= strpos($path = $parameters->path, '/') === 0 ? $path : "/$path"; - } - - $resource = @stream_socket_client($uri, $errno, $errstr, $parameters->timeout, $flags); - - if (!$resource) { - $this->onConnectionError(trim($errstr), $errno); - } - - if (isset($parameters->read_write_timeout)) { - $rwtimeout = $parameters->read_write_timeout; - $rwtimeout = $rwtimeout > 0 ? $rwtimeout : -1; - $timeoutSeconds = floor($rwtimeout); - $timeoutUSeconds = ($rwtimeout - $timeoutSeconds) * 1000000; - stream_set_timeout($resource, $timeoutSeconds, $timeoutUSeconds); - } - - if (isset($parameters->tcp_nodelay) && version_compare(PHP_VERSION, '5.4.0') >= 0) { - $socket = socket_import_stream($resource); - socket_set_option($socket, SOL_TCP, TCP_NODELAY, (int) $parameters->tcp_nodelay); - } - - return $resource; - } - - /** - * Initializes a UNIX stream resource. - * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - * @return resource - */ - private function unixStreamInitializer(ConnectionParametersInterface $parameters) - { - $uri = "unix://{$parameters->path}"; - $flags = STREAM_CLIENT_CONNECT; - - if ($parameters->persistent) { - $flags |= STREAM_CLIENT_PERSISTENT; - } - - $resource = @stream_socket_client($uri, $errno, $errstr, $parameters->timeout, $flags); - - if (!$resource) { - $this->onConnectionError(trim($errstr), $errno); - } - - return $resource; - } - - /** - * {@inheritdoc} - */ - public function connect() - { - parent::connect(); - - if ($this->initCmds) { - $this->sendInitializationCommands(); - } - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - if ($this->isConnected()) { - fclose($this->getResource()); - parent::disconnect(); - } - } - - /** - * Sends the initialization commands to Redis when the connection is opened. - */ - private function sendInitializationCommands() - { - foreach ($this->initCmds as $command) { - $this->writeCommand($command); - } - foreach ($this->initCmds as $command) { - $this->readResponse($command); - } - } - - /** - * Performs a write operation on the stream of the buffer containing a - * command serialized with the Redis wire protocol. - * - * @param string $buffer Redis wire protocol representation of a command. - */ - protected function writeBytes($buffer) - { - $socket = $this->getResource(); - - while (($length = strlen($buffer)) > 0) { - $written = fwrite($socket, $buffer); - - if ($length === $written) { - return; - } - if ($written === false || $written === 0) { - $this->onConnectionError('Error while writing bytes to the server'); - } - - $buffer = substr($buffer, $written); - } - } - - /** - * {@inheritdoc} - */ - public function read() - { - $socket = $this->getResource(); - $chunk = fgets($socket); - - if ($chunk === false || $chunk === '') { - $this->onConnectionError('Error while reading line from the server'); - } - - $prefix = $chunk[0]; - $payload = substr($chunk, 1, -2); - - switch ($prefix) { - case '+': - switch ($payload) { - case 'OK': - return true; - - case 'QUEUED': - return new ResponseQueued(); - - default: - return $payload; - } - - case '$': - $size = (int) $payload; - if ($size === -1) { - return null; - } - - $bulkData = ''; - $bytesLeft = ($size += 2); - - do { - $chunk = fread($socket, min($bytesLeft, 4096)); - - if ($chunk === false || $chunk === '') { - $this->onConnectionError('Error while reading bytes from the server'); - } - - $bulkData .= $chunk; - $bytesLeft = $size - strlen($bulkData); - } while ($bytesLeft > 0); - - return substr($bulkData, 0, -2); - - case '*': - $count = (int) $payload; - - if ($count === -1) { - return null; - } - if ($this->mbiterable) { - return new MultiBulkResponseSimple($this, $count); - } - - $multibulk = array(); - - for ($i = 0; $i < $count; $i++) { - $multibulk[$i] = $this->read(); - } - - return $multibulk; - - case ':': - return (int) $payload; - - case '-': - return new ResponseError($payload); - - default: - $this->onProtocolError("Unknown prefix: '$prefix'"); - } - } - - /** - * {@inheritdoc} - */ - public function writeCommand(CommandInterface $command) - { - $commandId = $command->getId(); - $arguments = $command->getArguments(); - - $cmdlen = strlen($commandId); - $reqlen = count($arguments) + 1; - - $buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandId}\r\n"; - - for ($i = 0, $reqlen--; $i < $reqlen; $i++) { - $argument = $arguments[$i]; - $arglen = strlen($argument); - $buffer .= "\${$arglen}\r\n{$argument}\r\n"; - } - - $this->writeBytes($buffer); - } - - /** - * {@inheritdoc} - */ - public function __sleep() - { - return array_merge(parent::__sleep(), array('mbiterable')); - } -} diff --git a/vendor/predis/predis/lib/Predis/Connection/WebdisConnection.php b/vendor/predis/predis/lib/Predis/Connection/WebdisConnection.php deleted file mode 100644 index b8972686c..000000000 --- a/vendor/predis/predis/lib/Predis/Connection/WebdisConnection.php +++ /dev/null @@ -1,335 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use Predis\NotSupportedException; -use Predis\ResponseError; -use Predis\Command\CommandInterface; -use Predis\Connection\ConnectionException; -use Predis\Protocol\ProtocolException; - -/** - * This class implements a Predis connection that actually talks with Webdis - * instead of connecting directly to Redis. It relies on the cURL extension to - * communicate with the web server and the phpiredis extension to parse the - * protocol of the replies returned in the http response bodies. - * - * Some features are not yet available or they simply cannot be implemented: - * - Pipelining commands. - * - Publish / Subscribe. - * - MULTI / EXEC transactions (not yet supported by Webdis). - * - * The connection parameters supported by this class are: - * - * - scheme: must be 'http'. - * - host: hostname or IP address of the server. - * - port: TCP port of the server. - * - timeout: timeout to perform the connection. - * - user: username for authentication. - * - pass: password for authentication. - * - * @link http://webd.is - * @link http://github.com/nicolasff/webdis - * @link http://github.com/seppo0010/phpiredis - * @author Daniele Alessandri - */ -class WebdisConnection implements SingleConnectionInterface -{ - const ERR_MSG_EXTENSION = 'The %s extension must be loaded in order to be able to use this connection class'; - - private $parameters; - private $resource; - private $reader; - - /** - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - */ - public function __construct(ConnectionParametersInterface $parameters) - { - $this->checkExtensions(); - - if ($parameters->scheme !== 'http') { - throw new \InvalidArgumentException("Invalid scheme: {$parameters->scheme}"); - } - - $this->parameters = $parameters; - $this->resource = $this->initializeCurl($parameters); - $this->reader = $this->initializeReader($parameters); - } - - /** - * Frees the underlying cURL and protocol reader resources when PHP's - * garbage collector kicks in. - */ - public function __destruct() - { - curl_close($this->resource); - phpiredis_reader_destroy($this->reader); - } - - /** - * Helper method used to throw on unsupported methods. - */ - private function throwNotSupportedException($function) - { - $class = __CLASS__; - throw new NotSupportedException("The method $class::$function() is not supported"); - } - - /** - * Checks if the cURL and phpiredis extensions are loaded in PHP. - */ - private function checkExtensions() - { - if (!function_exists('curl_init')) { - throw new NotSupportedException(sprintf(self::ERR_MSG_EXTENSION, 'curl')); - } - - if (!function_exists('phpiredis_reader_create')) { - throw new NotSupportedException(sprintf(self::ERR_MSG_EXTENSION, 'phpiredis')); - } - } - - /** - * Initializes cURL. - * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - * @return resource - */ - private function initializeCurl(ConnectionParametersInterface $parameters) - { - $options = array( - CURLOPT_FAILONERROR => true, - CURLOPT_CONNECTTIMEOUT_MS => $parameters->timeout * 1000, - CURLOPT_URL => "{$parameters->scheme}://{$parameters->host}:{$parameters->port}", - CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, - CURLOPT_POST => true, - CURLOPT_WRITEFUNCTION => array($this, 'feedReader'), - ); - - if (isset($parameters->user, $parameters->pass)) { - $options[CURLOPT_USERPWD] = "{$parameters->user}:{$parameters->pass}"; - } - - curl_setopt_array($resource = curl_init(), $options); - - return $resource; - } - - /** - * Initializes phpiredis' protocol reader. - * - * @param ConnectionParametersInterface $parameters Parameters used to initialize the connection. - * @return resource - */ - private function initializeReader(ConnectionParametersInterface $parameters) - { - $reader = phpiredis_reader_create(); - - phpiredis_reader_set_status_handler($reader, $this->getStatusHandler()); - phpiredis_reader_set_error_handler($reader, $this->getErrorHandler()); - - return $reader; - } - - /** - * Gets the handler used by the protocol reader to handle status replies. - * - * @return \Closure - */ - protected function getStatusHandler() - { - return function ($payload) { - return $payload === 'OK' ? true : $payload; - }; - } - - /** - * Gets the handler used by the protocol reader to handle Redis errors. - * - * @return \Closure - */ - protected function getErrorHandler() - { - return function ($errorMessage) { - return new ResponseError($errorMessage); - }; - } - - /** - * Feeds phpredis' reader resource with the data read from the network. - * - * @param resource $resource Reader resource. - * @param string $buffer Buffer with the reply read from the network. - * @return int - */ - protected function feedReader($resource, $buffer) - { - phpiredis_reader_feed($this->reader, $buffer); - - return strlen($buffer); - } - - /** - * {@inheritdoc} - */ - public function connect() - { - // NOOP - } - - /** - * {@inheritdoc} - */ - public function disconnect() - { - // NOOP - } - - /** - * {@inheritdoc} - */ - public function isConnected() - { - return true; - } - - /** - * Checks if the specified command is supported by this connection class. - * - * @param CommandInterface $command The instance of a Redis command. - * @return string - */ - protected function getCommandId(CommandInterface $command) - { - switch (($commandId = $command->getId())) { - case 'AUTH': - case 'SELECT': - case 'MULTI': - case 'EXEC': - case 'WATCH': - case 'UNWATCH': - case 'DISCARD': - case 'MONITOR': - throw new NotSupportedException("Disabled command: {$command->getId()}"); - - default: - return $commandId; - } - } - - /** - * {@inheritdoc} - */ - public function writeCommand(CommandInterface $command) - { - $this->throwNotSupportedException(__FUNCTION__); - } - - /** - * {@inheritdoc} - */ - public function readResponse(CommandInterface $command) - { - $this->throwNotSupportedException(__FUNCTION__); - } - - /** - * {@inheritdoc} - */ - public function executeCommand(CommandInterface $command) - { - $resource = $this->resource; - $commandId = $this->getCommandId($command); - - if ($arguments = $command->getArguments()) { - $arguments = implode('/', array_map('urlencode', $arguments)); - $serializedCommand = "$commandId/$arguments.raw"; - } else { - $serializedCommand = "$commandId.raw"; - } - - curl_setopt($resource, CURLOPT_POSTFIELDS, $serializedCommand); - - if (curl_exec($resource) === false) { - $error = curl_error($resource); - $errno = curl_errno($resource); - throw new ConnectionException($this, trim($error), $errno); - } - - if (phpiredis_reader_get_state($this->reader) !== PHPIREDIS_READER_STATE_COMPLETE) { - throw new ProtocolException($this, phpiredis_reader_get_error($this->reader)); - } - - return phpiredis_reader_get_reply($this->reader); - } - - /** - * {@inheritdoc} - */ - public function getResource() - { - return $this->resource; - } - - /** - * {@inheritdoc} - */ - public function getParameters() - { - return $this->parameters; - } - - /** - * {@inheritdoc} - */ - public function pushInitCommand(CommandInterface $command) - { - $this->throwNotSupportedException(__FUNCTION__); - } - - /** - * {@inheritdoc} - */ - public function read() - { - $this->throwNotSupportedException(__FUNCTION__); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return "{$this->parameters->host}:{$this->parameters->port}"; - } - - /** - * {@inheritdoc} - */ - public function __sleep() - { - return array('parameters'); - } - - /** - * {@inheritdoc} - */ - public function __wakeup() - { - $this->checkExtensions(); - $parameters = $this->getParameters(); - - $this->resource = $this->initializeCurl($parameters); - $this->reader = $this->initializeReader($parameters); - } -} diff --git a/vendor/predis/predis/lib/Predis/ExecutableContextInterface.php b/vendor/predis/predis/lib/Predis/ExecutableContextInterface.php deleted file mode 100644 index 1cb1e83b2..000000000 --- a/vendor/predis/predis/lib/Predis/ExecutableContextInterface.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Defines the interface of a basic client object or abstraction that - * can send commands to Redis. - * - * @author Daniele Alessandri - */ -interface ExecutableContextInterface -{ - /** - * Starts the execution of the context. - * - * @param mixed $callable Optional callback for execution. - * @return array - */ - public function execute($callable = null); -} diff --git a/vendor/predis/predis/lib/Predis/Helpers.php b/vendor/predis/predis/lib/Predis/Helpers.php deleted file mode 100644 index 064f72d28..000000000 --- a/vendor/predis/predis/lib/Predis/Helpers.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Defines a few helper methods. - * - * @author Daniele Alessandri - * @deprecated Deprecated since v0.8.3. - */ -class Helpers -{ - /** - * Offers a generic and reusable method to handle exceptions generated by - * a connection object. - * - * @deprecated Deprecated since v0.8.3 - moved in Predis\CommunicationException::handle() - * @param CommunicationException $exception Exception. - */ - public static function onCommunicationException(CommunicationException $exception) - { - if ($exception->shouldResetConnection()) { - $connection = $exception->getConnection(); - - if ($connection->isConnected()) { - $connection->disconnect(); - } - } - - throw $exception; - } - - /** - * Normalizes the arguments array passed to a Redis command. - * - * @deprecated Deprecated since v0.8.3 - moved in Predis\Command\AbstractCommand::normalizeArguments() - * @param array $arguments Arguments for a command. - * @return array - */ - public static function filterArrayArguments(Array $arguments) - { - if (count($arguments) === 1 && is_array($arguments[0])) { - return $arguments[0]; - } - - return $arguments; - } - - /** - * Normalizes the arguments array passed to a variadic Redis command. - * - * @deprecated Deprecated since v0.8.3 - moved in Predis\Command\AbstractCommand::normalizeVariadic() - * @param array $arguments Arguments for a command. - * @return array - */ - public static function filterVariadicValues(Array $arguments) - { - if (count($arguments) === 2 && is_array($arguments[1])) { - return array_merge(array($arguments[0]), $arguments[1]); - } - - return $arguments; - } -} diff --git a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponse.php b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponse.php deleted file mode 100644 index 317a006cd..000000000 --- a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponse.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Iterator; - -use Predis\ResponseObjectInterface; - -/** - * Iterator that abstracts the access to multibulk replies and allows - * them to be consumed by user's code in a streaming fashion. - * - * @author Daniele Alessandri - */ -abstract class MultiBulkResponse implements \Iterator, \Countable, ResponseObjectInterface -{ - protected $position; - protected $current; - protected $replySize; - - /** - * {@inheritdoc} - */ - public function rewind() - { - // NOOP - } - - /** - * {@inheritdoc} - */ - public function current() - { - return $this->current; - } - - /** - * {@inheritdoc} - */ - public function key() - { - return $this->position; - } - - /** - * {@inheritdoc} - */ - public function next() - { - if (++$this->position < $this->replySize) { - $this->current = $this->getValue(); - } - - return $this->position; - } - - /** - * {@inheritdoc} - */ - public function valid() - { - return $this->position < $this->replySize; - } - - /** - * Returns the number of items of the whole multibulk reply. - * - * This method should be used to get the size of the current multibulk - * reply without using iterator_count, which actually consumes the - * iterator to calculate the size (rewinding is not supported). - * - * @return int - */ - public function count() - { - return $this->replySize; - } - - /** - * Returns the current position of the iterator. - * - * @return int - */ - public function getPosition() - { - return $this->position; - } - - /** - * {@inheritdoc} - */ - abstract protected function getValue(); -} diff --git a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseSimple.php b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseSimple.php deleted file mode 100644 index f3e7440a9..000000000 --- a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseSimple.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Iterator; - -use Predis\Connection\SingleConnectionInterface; - -/** - * Streams a multibulk reply. - * - * @author Daniele Alessandri - */ -class MultiBulkResponseSimple extends MultiBulkResponse -{ - private $connection; - - /** - * @param SingleConnectionInterface $connection Connection to Redis. - * @param int $size Number of elements of the multibulk reply. - */ - public function __construct(SingleConnectionInterface $connection, $size) - { - $this->connection = $connection; - $this->position = 0; - $this->current = $size > 0 ? $this->getValue() : null; - $this->replySize = $size; - } - - /** - * Handles the synchronization of the client with the Redis protocol - * then PHP's garbage collector kicks in (e.g. then the iterator goes - * out of the scope of a foreach). - */ - public function __destruct() - { - $this->sync(true); - } - - /** - * Synchronizes the client with the queued elements that have not been - * read from the connection by consuming the rest of the multibulk reply, - * or simply by dropping the connection. - * - * @param bool $drop True to synchronize the client by dropping the connection. - * False to synchronize the client by consuming the multibulk reply. - */ - public function sync($drop = false) - { - if ($drop == true) { - if ($this->valid()) { - $this->position = $this->replySize; - $this->connection->disconnect(); - } - } else { - while ($this->valid()) { - $this->next(); - } - } - } - - /** - * Reads the next item of the multibulk reply from the server. - * - * @return mixed - */ - protected function getValue() - { - return $this->connection->read(); - } - - /** - * Returns an iterator that reads the multi-bulk response as - * list of tuples. - * - * @return MultiBulkResponseTuple - */ - public function asTuple() - { - return new MultiBulkResponseTuple($this); - } -} diff --git a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseTuple.php b/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseTuple.php deleted file mode 100644 index 39d7828f6..000000000 --- a/vendor/predis/predis/lib/Predis/Iterator/MultiBulkResponseTuple.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Iterator; - -/** - * Abstracts the access to a streamable list of tuples represented - * as a multibulk reply that alternates keys and values. - * - * @author Daniele Alessandri - */ -class MultiBulkResponseTuple extends MultiBulkResponse implements \OuterIterator -{ - private $iterator; - - /** - * @param MultiBulkResponseSimple $iterator Multibulk reply iterator. - */ - public function __construct(MultiBulkResponseSimple $iterator) - { - $this->checkPreconditions($iterator); - - $virtualSize = count($iterator) / 2; - $this->iterator = $iterator; - $this->position = $iterator->getPosition(); - $this->current = $virtualSize > 0 ? $this->getValue() : null; - $this->replySize = $virtualSize; - } - - /** - * Checks for valid preconditions. - * - * @param MultiBulkResponseSimple $iterator Multibulk reply iterator. - */ - protected function checkPreconditions(MultiBulkResponseSimple $iterator) - { - if ($iterator->getPosition() !== 0) { - throw new \RuntimeException('Cannot initialize a tuple iterator with an already initiated iterator'); - } - - if (($size = count($iterator)) % 2 !== 0) { - throw new \UnexpectedValueException("Invalid reply size for a tuple iterator [$size]"); - } - } - - /** - * {@inheritdoc} - */ - public function getInnerIterator() - { - return $this->iterator; - } - - /** - * {@inheritdoc} - */ - public function __destruct() - { - $this->iterator->sync(true); - } - - /** - * {@inheritdoc} - */ - protected function getValue() - { - $k = $this->iterator->current(); - $this->iterator->next(); - - $v = $this->iterator->current(); - $this->iterator->next(); - - return array($k, $v); - } -} diff --git a/vendor/predis/predis/lib/Predis/Monitor/MonitorContext.php b/vendor/predis/predis/lib/Predis/Monitor/MonitorContext.php deleted file mode 100644 index 73c1bcad9..000000000 --- a/vendor/predis/predis/lib/Predis/Monitor/MonitorContext.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Monitor; - -use Predis\ClientInterface; -use Predis\NotSupportedException; -use Predis\Connection\AggregatedConnectionInterface; - -/** - * Client-side abstraction of a Redis MONITOR context. - * - * @author Daniele Alessandri - */ -class MonitorContext implements \Iterator -{ - private $client; - private $isValid; - private $position; - - /** - * @param ClientInterface $client Client instance used by the context. - */ - public function __construct(ClientInterface $client) - { - $this->checkCapabilities($client); - $this->client = $client; - $this->openContext(); - } - - /** - * Automatically closes the context when PHP's garbage collector kicks in. - */ - public function __destruct() - { - $this->closeContext(); - } - - /** - * Checks if the passed client instance satisfies the required conditions - * needed to initialize a monitor context. - * - * @param ClientInterface $client Client instance used by the context. - */ - private function checkCapabilities(ClientInterface $client) - { - if ($client->getConnection() instanceof AggregatedConnectionInterface) { - throw new NotSupportedException('Cannot initialize a monitor context when using aggregated connections'); - } - if ($client->getProfile()->supportsCommand('monitor') === false) { - throw new NotSupportedException('The current profile does not support the MONITOR command'); - } - } - - /** - * Initializes the context and sends the MONITOR command to the server. - */ - protected function openContext() - { - $this->isValid = true; - $monitor = $this->client->createCommand('monitor'); - $this->client->executeCommand($monitor); - } - - /** - * Closes the context. Internally this is done by disconnecting from server - * since there is no way to terminate the stream initialized by MONITOR. - */ - public function closeContext() - { - $this->client->disconnect(); - $this->isValid = false; - } - - /** - * {@inheritdoc} - */ - public function rewind() - { - // NOOP - } - - /** - * Returns the last message payload retrieved from the server. - * - * @return Object - */ - public function current() - { - return $this->getValue(); - } - - /** - * {@inheritdoc} - */ - public function key() - { - return $this->position; - } - - /** - * {@inheritdoc} - */ - public function next() - { - $this->position++; - } - - /** - * Checks if the the context is still in a valid state to continue. - * - * @return bool - */ - public function valid() - { - return $this->isValid; - } - - /** - * Waits for a new message from the server generated by MONITOR and - * returns it when available. - * - * @return Object - */ - private function getValue() - { - $database = 0; - $client = null; - $event = $this->client->getConnection()->read(); - - $callback = function ($matches) use (&$database, &$client) { - if (2 === $count = count($matches)) { - // Redis <= 2.4 - $database = (int) $matches[1]; - } - - if (4 === $count) { - // Redis >= 2.6 - $database = (int) $matches[2]; - $client = $matches[3]; - } - - return ' '; - }; - - $event = preg_replace_callback('/ \(db (\d+)\) | \[(\d+) (.*?)\] /', $callback, $event, 1); - @list($timestamp, $command, $arguments) = explode(' ', $event, 3); - - return (object) array( - 'timestamp' => (float) $timestamp, - 'database' => $database, - 'client' => $client, - 'command' => substr($command, 1, -1), - 'arguments' => $arguments, - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/NotSupportedException.php b/vendor/predis/predis/lib/Predis/NotSupportedException.php deleted file mode 100644 index 631b820a2..000000000 --- a/vendor/predis/predis/lib/Predis/NotSupportedException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Exception class generated when trying to use features not - * supported by certain classes or abstractions. - * - * @author Daniele Alessandri - */ -class NotSupportedException extends PredisException -{ -} diff --git a/vendor/predis/predis/lib/Predis/Option/AbstractOption.php b/vendor/predis/predis/lib/Predis/Option/AbstractOption.php deleted file mode 100644 index 92506cd50..000000000 --- a/vendor/predis/predis/lib/Predis/Option/AbstractOption.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -/** - * Implements a client option. - * - * @author Daniele Alessandri - */ -abstract class AbstractOption implements OptionInterface -{ - /** - * {@inheritdoc} - */ - public function filter(ClientOptionsInterface $options, $value) - { - return $value; - } - - /** - * {@inheritdoc} - */ - public function getDefault(ClientOptionsInterface $options) - { - return null; - } - - /** - * {@inheritdoc} - */ - public function __invoke(ClientOptionsInterface $options, $value) - { - if (isset($value)) { - return $this->filter($options, $value); - } - - return $this->getDefault($options); - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientCluster.php b/vendor/predis/predis/lib/Predis/Option/ClientCluster.php deleted file mode 100644 index fca9796e5..000000000 --- a/vendor/predis/predis/lib/Predis/Option/ClientCluster.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use Predis\Connection\ClusterConnectionInterface; -use Predis\Connection\PredisCluster; -use Predis\Connection\RedisCluster; - -/** - * Option class that returns a connection cluster to be used by a client. - * - * @author Daniele Alessandri - */ -class ClientCluster extends AbstractOption -{ - /** - * Checks if the specified value is a valid instance of ClusterConnectionInterface. - * - * @param ClusterConnectionInterface $cluster Instance of a connection cluster. - * @return ClusterConnectionInterface - */ - protected function checkInstance($cluster) - { - if (!$cluster instanceof ClusterConnectionInterface) { - throw new \InvalidArgumentException('Instance of Predis\Connection\ClusterConnectionInterface expected'); - } - - return $cluster; - } - - /** - * {@inheritdoc} - */ - public function filter(ClientOptionsInterface $options, $value) - { - if (is_callable($value)) { - return $this->checkInstance(call_user_func($value, $options, $this)); - } - - $initializer = $this->getInitializer($options, $value); - - return $this->checkInstance($initializer()); - } - - /** - * Returns an initializer for the specified FQN or type. - * - * @param string $fqnOrType Type of cluster or FQN of a class implementing ClusterConnectionInterface. - * @param ClientOptionsInterface $options Instance of the client options. - * @return \Closure - */ - protected function getInitializer(ClientOptionsInterface $options, $fqnOrType) - { - switch ($fqnOrType) { - case 'predis': - return function () { - return new PredisCluster(); - }; - - case 'redis': - return function () use ($options) { - $connectionFactory = $options->connections; - $cluster = new RedisCluster($connectionFactory); - - return $cluster; - }; - - default: - // TODO: we should not even allow non-string values here. - if (is_string($fqnOrType) && !class_exists($fqnOrType)) { - throw new \InvalidArgumentException("Class $fqnOrType does not exist"); - } - - return function () use ($fqnOrType) { - return new $fqnOrType(); - }; - } - } - - /** - * {@inheritdoc} - */ - public function getDefault(ClientOptionsInterface $options) - { - return new PredisCluster(); - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientConnectionFactory.php b/vendor/predis/predis/lib/Predis/Option/ClientConnectionFactory.php deleted file mode 100644 index e671e5223..000000000 --- a/vendor/predis/predis/lib/Predis/Option/ClientConnectionFactory.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use Predis\Connection\ConnectionFactory; -use Predis\Connection\ConnectionFactoryInterface; - -/** - * Option class that returns a connection factory to be used by a client. - * - * @author Daniele Alessandri - */ -class ClientConnectionFactory extends AbstractOption -{ - /** - * {@inheritdoc} - */ - public function filter(ClientOptionsInterface $options, $value) - { - if ($value instanceof ConnectionFactoryInterface) { - return $value; - } - - if (is_array($value)) { - $factory = $this->getDefault($options); - - foreach ($value as $scheme => $initializer) { - $factory->define($scheme, $initializer); - } - - return $factory; - } - - if (is_callable($value)) { - $factory = call_user_func($value, $options, $this); - - if (!$factory instanceof ConnectionFactoryInterface) { - throw new \InvalidArgumentException('Instance of Predis\Connection\ConnectionFactoryInterface expected'); - } - - return $factory; - } - - if (@class_exists($value)) { - $factory = new $value(); - - if (!$factory instanceof ConnectionFactoryInterface) { - throw new \InvalidArgumentException("Class $value must be an instance of Predis\Connection\ConnectionFactoryInterface"); - } - - return $factory; - } - - throw new \InvalidArgumentException('Invalid value for the connections option'); - } - - /** - * {@inheritdoc} - */ - public function getDefault(ClientOptionsInterface $options) - { - return new ConnectionFactory($options->profile); - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientExceptions.php b/vendor/predis/predis/lib/Predis/Option/ClientExceptions.php deleted file mode 100644 index ad422dad4..000000000 --- a/vendor/predis/predis/lib/Predis/Option/ClientExceptions.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -/** - * Option class used to specify if the client should throw server exceptions. - * - * @author Daniele Alessandri - */ -class ClientExceptions extends AbstractOption -{ - /** - * {@inheritdoc} - */ - public function filter(ClientOptionsInterface $options, $value) - { - return (bool) $value; - } - - /** - * {@inheritdoc} - */ - public function getDefault(ClientOptionsInterface $options) - { - return true; - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientOptions.php b/vendor/predis/predis/lib/Predis/Option/ClientOptions.php deleted file mode 100644 index e579041a0..000000000 --- a/vendor/predis/predis/lib/Predis/Option/ClientOptions.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -/** - * Class that manages client options with filtering and conversion. - * - * @author Daniele Alessandri - */ -class ClientOptions implements ClientOptionsInterface -{ - private $handlers; - private $defined; - private $options = array(); - - /** - * @param array $options Array of client options. - */ - public function __construct(Array $options = array()) - { - $this->handlers = $this->initialize($options); - $this->defined = array_fill_keys(array_keys($options), true); - } - - /** - * Ensures that the default options are initialized. - * - * @return array - */ - protected function getDefaultOptions() - { - return array( - 'profile' => new ClientProfile(), - 'connections' => new ClientConnectionFactory(), - 'cluster' => new ClientCluster(), - 'replication' => new ClientReplication(), - 'prefix' => new ClientPrefix(), - 'exceptions' => new ClientExceptions(), - ); - } - - /** - * Initializes client options handlers. - * - * @param array $options List of client options values. - * @return array - */ - protected function initialize(Array $options) - { - $handlers = $this->getDefaultOptions(); - - foreach ($options as $option => $value) { - if (isset($handlers[$option])) { - $handler = $handlers[$option]; - $handlers[$option] = function ($options) use ($handler, $value) { - return $handler->filter($options, $value); - }; - } else { - $this->options[$option] = $value; - } - } - - return $handlers; - } - - /** - * Checks if the specified option is set. - * - * @param string $option Name of the option. - * @return bool - */ - public function __isset($option) - { - return isset($this->defined[$option]); - } - - /** - * Returns the value of the specified option. - * - * @param string $option Name of the option. - * @return mixed - */ - public function __get($option) - { - if (isset($this->options[$option])) { - return $this->options[$option]; - } - - if (isset($this->handlers[$option])) { - $handler = $this->handlers[$option]; - $value = $handler instanceof OptionInterface ? $handler->getDefault($this) : $handler($this); - $this->options[$option] = $value; - - return $value; - } - } - - /** - * Returns the default value for the specified option. - * - * @param string|OptionInterface $option Name or instance of the option. - * @return mixed - */ - public function getDefault($option) - { - if ($option instanceof OptionInterface) { - return $option->getDefault($this); - } - - $options = $this->getDefaultOptions(); - - if (isset($options[$option])) { - return $options[$option]->getDefault($this); - } - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientOptionsInterface.php b/vendor/predis/predis/lib/Predis/Option/ClientOptionsInterface.php deleted file mode 100644 index 543e18a76..000000000 --- a/vendor/predis/predis/lib/Predis/Option/ClientOptionsInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -/** - * Marker interface defining a client options bag. - * - * @author Daniele Alessandri - */ -interface ClientOptionsInterface -{ -} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientPrefix.php b/vendor/predis/predis/lib/Predis/Option/ClientPrefix.php deleted file mode 100644 index 01a166a1a..000000000 --- a/vendor/predis/predis/lib/Predis/Option/ClientPrefix.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use Predis\Command\Processor\KeyPrefixProcessor; - -/** - * Option class that handles the prefixing of keys in commands. - * - * @author Daniele Alessandri - */ -class ClientPrefix extends AbstractOption -{ - /** - * {@inheritdoc} - */ - public function filter(ClientOptionsInterface $options, $value) - { - return new KeyPrefixProcessor($value); - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientProfile.php b/vendor/predis/predis/lib/Predis/Option/ClientProfile.php deleted file mode 100644 index 660066d38..000000000 --- a/vendor/predis/predis/lib/Predis/Option/ClientProfile.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use Predis\Profile\ServerProfile; -use Predis\Profile\ServerProfileInterface; - -/** - * Option class that handles server profiles to be used by a client. - * - * @author Daniele Alessandri - */ -class ClientProfile extends AbstractOption -{ - /** - * {@inheritdoc} - */ - public function filter(ClientOptionsInterface $options, $value) - { - if (is_string($value)) { - $value = ServerProfile::get($value); - - if (isset($options->prefix)) { - $value->setProcessor($options->prefix); - } - } - - if (is_callable($value)) { - $value = call_user_func($value, $options, $this); - } - - if (!$value instanceof ServerProfileInterface) { - throw new \InvalidArgumentException('Invalid value for the profile option'); - } - - return $value; - } - - /** - * {@inheritdoc} - */ - public function getDefault(ClientOptionsInterface $options) - { - $profile = ServerProfile::getDefault(); - - if (isset($options->prefix)) { - $profile->setProcessor($options->prefix); - } - - return $profile; - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/ClientReplication.php b/vendor/predis/predis/lib/Predis/Option/ClientReplication.php deleted file mode 100644 index ad7030833..000000000 --- a/vendor/predis/predis/lib/Predis/Option/ClientReplication.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use Predis\Connection\MasterSlaveReplication; -use Predis\Connection\ReplicationConnectionInterface; - -/** - * Option class that returns a replication connection be used by a client. - * - * @author Daniele Alessandri - */ -class ClientReplication extends AbstractOption -{ - /** - * Checks if the specified value is a valid instance of ReplicationConnectionInterface. - * - * @param ReplicationConnectionInterface $connection Instance of a replication connection. - * @return ReplicationConnectionInterface - */ - protected function checkInstance($connection) - { - if (!$connection instanceof ReplicationConnectionInterface) { - throw new \InvalidArgumentException('Instance of Predis\Connection\ReplicationConnectionInterface expected'); - } - - return $connection; - } - - /** - * {@inheritdoc} - */ - public function filter(ClientOptionsInterface $options, $value) - { - if (is_callable($value)) { - $connection = call_user_func($value, $options, $this); - - if (!$connection instanceof ReplicationConnectionInterface) { - throw new \InvalidArgumentException('Instance of Predis\Connection\ReplicationConnectionInterface expected'); - } - - return $connection; - } - - if (is_string($value)) { - if (!class_exists($value)) { - throw new \InvalidArgumentException("Class $value does not exist"); - } - - if (!($connection = new $value()) instanceof ReplicationConnectionInterface) { - throw new \InvalidArgumentException('Instance of Predis\Connection\ReplicationConnectionInterface expected'); - } - - return $connection; - } - - if ($value == true) { - return $this->getDefault($options); - } - } - - /** - * {@inheritdoc} - */ - public function getDefault(ClientOptionsInterface $options) - { - return new MasterSlaveReplication(); - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/CustomOption.php b/vendor/predis/predis/lib/Predis/Option/CustomOption.php deleted file mode 100644 index 848c8b949..000000000 --- a/vendor/predis/predis/lib/Predis/Option/CustomOption.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -/** - * Implements a generic class used to dynamically define a client option. - * - * @author Daniele Alessandri - */ -class CustomOption implements OptionInterface -{ - private $filter; - private $default; - - /** - * @param array $options List of options - */ - public function __construct(Array $options = array()) - { - $this->filter = $this->ensureCallable($options, 'filter'); - $this->default = $this->ensureCallable($options, 'default'); - } - - /** - * Checks if the specified value in the options array is a callable object. - * - * @param array $options Array of options - * @param string $key Target option. - */ - private function ensureCallable($options, $key) - { - if (!isset($options[$key])) { - return; - } - - if (is_callable($callable = $options[$key])) { - return $callable; - } - - throw new \InvalidArgumentException("The parameter $key must be callable"); - } - - /** - * {@inheritdoc} - */ - public function filter(ClientOptionsInterface $options, $value) - { - if (isset($value)) { - if ($this->filter === null) { - return $value; - } - - return call_user_func($this->filter, $options, $value); - } - } - - /** - * {@inheritdoc} - */ - public function getDefault(ClientOptionsInterface $options) - { - if (!isset($this->default)) { - return; - } - - return call_user_func($this->default, $options); - } - - /** - * {@inheritdoc} - */ - public function __invoke(ClientOptionsInterface $options, $value) - { - if (isset($value)) { - return $this->filter($options, $value); - } - - return $this->getDefault($options); - } -} diff --git a/vendor/predis/predis/lib/Predis/Option/OptionInterface.php b/vendor/predis/predis/lib/Predis/Option/OptionInterface.php deleted file mode 100644 index 29e8165df..000000000 --- a/vendor/predis/predis/lib/Predis/Option/OptionInterface.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -/** - * Interface that defines a client option. - * - * @author Daniele Alessandri - */ -interface OptionInterface -{ - /** - * Filters (and optionally converts) the passed value. - * - * @param ClientOptionsInterface $options Options container. - * @param mixed $value Input value. - * @return mixed - */ - public function filter(ClientOptionsInterface $options, $value); - - /** - * Returns a default value for the option. - * - * @param ClientOptionsInterface $options Options container. - * @return mixed - */ - public function getDefault(ClientOptionsInterface $options); - - /** - * Filters a value and, if no value is specified, returns the default one - * defined by the option. - * - * @param ClientOptionsInterface $options Options container. - * @param mixed $value Input value. - * @return mixed - */ - public function __invoke(ClientOptionsInterface $options, $value); -} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/FireAndForgetExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/FireAndForgetExecutor.php deleted file mode 100644 index 3e04799bd..000000000 --- a/vendor/predis/predis/lib/Predis/Pipeline/FireAndForgetExecutor.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use SplQueue; -use Predis\Connection\ConnectionInterface; -use Predis\Connection\ReplicationConnectionInterface; - -/** - * Implements a pipeline executor strategy that writes a list of commands to - * the connection object but does not read back their replies. - * - * @author Daniele Alessandri - */ -class FireAndForgetExecutor implements PipelineExecutorInterface -{ - /** - * Allows the pipeline executor to perform operations on the - * connection before starting to execute the commands stored - * in the pipeline. - * - * @param ConnectionInterface $connection Connection instance. - */ - protected function checkConnection(ConnectionInterface $connection) - { - if ($connection instanceof ReplicationConnectionInterface) { - $connection->switchTo('master'); - } - } - - /** - * {@inheritdoc} - */ - public function execute(ConnectionInterface $connection, SplQueue $commands) - { - $this->checkConnection($connection); - - while (!$commands->isEmpty()) { - $connection->writeCommand($commands->dequeue()); - } - - $connection->disconnect(); - - return array(); - } -} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/MultiExecExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/MultiExecExecutor.php deleted file mode 100644 index 5f6c09e41..000000000 --- a/vendor/predis/predis/lib/Predis/Pipeline/MultiExecExecutor.php +++ /dev/null @@ -1,168 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use Iterator; -use SplQueue; -use Predis\ClientException; -use Predis\ResponseErrorInterface; -use Predis\ResponseObjectInterface; -use Predis\ServerException; -use Predis\Connection\ConnectionInterface; -use Predis\Connection\SingleConnectionInterface; -use Predis\Profile\ServerProfile; -use Predis\Profile\ServerProfileInterface; - -/** - * Implements a pipeline executor that wraps the whole pipeline - * in a MULTI / EXEC context to make sure that it is executed - * correctly. - * - * @author Daniele Alessandri - */ -class MultiExecExecutor implements PipelineExecutorInterface -{ - protected $profile; - - /** - * - */ - public function __construct(ServerProfileInterface $profile = null) - { - $this->setProfile($profile ?: ServerProfile::getDefault()); - } - - /** - * Allows the pipeline executor to perform operations on the - * connection before starting to execute the commands stored - * in the pipeline. - * - * @param ConnectionInterface $connection Connection instance. - */ - protected function checkConnection(ConnectionInterface $connection) - { - if (!$connection instanceof SingleConnectionInterface) { - $class = __CLASS__; - throw new ClientException("$class can be used only with single connections"); - } - } - - /** - * {@inheritdoc} - */ - public function execute(ConnectionInterface $connection, SplQueue $commands) - { - $this->checkConnection($connection); - - $cmd = $this->profile->createCommand('multi'); - $connection->executeCommand($cmd); - - foreach ($commands as $command) { - $connection->writeCommand($command); - } - - foreach ($commands as $command) { - $response = $connection->readResponse($command); - - if ($response instanceof ResponseErrorInterface) { - $cmd = $this->profile->createCommand('discard'); - $connection->executeCommand($cmd); - - throw new ServerException($response->getMessage()); - } - } - - $cmd = $this->profile->createCommand('exec'); - $responses = $connection->executeCommand($cmd); - - if (!isset($responses)) { - throw new ClientException('The underlying transaction has been aborted by the server'); - } - - if (count($responses) !== count($commands)) { - throw new ClientException("Invalid number of replies [expected: ".count($commands)." - actual: ".count($responses)."]"); - } - - $consumer = $responses instanceof Iterator ? 'consumeIteratorResponse' : 'consumeArrayResponse'; - - return $this->$consumer($commands, $responses); - } - - /** - * Consumes an iterator response returned by EXEC. - * - * @param SplQueue $commands Pipelined commands - * @param Iterator $responses Responses returned by EXEC. - * @return array - */ - protected function consumeIteratorResponse(SplQueue $commands, Iterator $responses) - { - $values = array(); - - foreach ($responses as $response) { - $command = $commands->dequeue(); - - if ($response instanceof ResponseObjectInterface) { - if ($response instanceof Iterator) { - $response = iterator_to_array($response); - $values[] = $command->parseResponse($response); - } else { - $values[] = $response; - } - } else { - $values[] = $command->parseResponse($response); - } - } - - return $values; - } - - /** - * Consumes an array response returned by EXEC. - * - * @param SplQueue $commands Pipelined commands - * @param Array $responses Responses returned by EXEC. - * @return array - */ - protected function consumeArrayResponse(SplQueue $commands, Array &$responses) - { - $size = count($commands); - $values = array(); - - for ($i = 0; $i < $size; $i++) { - $command = $commands->dequeue(); - $response = $responses[$i]; - - if ($response instanceof ResponseObjectInterface) { - $values[$i] = $response; - } else { - $values[$i] = $command->parseResponse($response); - } - - unset($responses[$i]); - } - - return $values; - } - - /** - * @param ServerProfileInterface $profile Server profile. - */ - public function setProfile(ServerProfileInterface $profile) - { - if (!$profile->supportsCommands(array('multi', 'exec', 'discard'))) { - throw new ClientException('The specified server profile must support MULTI, EXEC and DISCARD.'); - } - - $this->profile = $profile; - } -} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/PipelineContext.php b/vendor/predis/predis/lib/Predis/Pipeline/PipelineContext.php deleted file mode 100644 index ce14a0ce6..000000000 --- a/vendor/predis/predis/lib/Predis/Pipeline/PipelineContext.php +++ /dev/null @@ -1,189 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use SplQueue; -use Predis\BasicClientInterface; -use Predis\ClientException; -use Predis\ClientInterface; -use Predis\ExecutableContextInterface; -use Predis\Command\CommandInterface; - -/** - * Abstraction of a pipeline context where write and read operations - * of commands and their replies over the network are pipelined. - * - * @author Daniele Alessandri - */ -class PipelineContext implements BasicClientInterface, ExecutableContextInterface -{ - private $client; - private $executor; - private $pipeline; - - private $replies = array(); - private $running = false; - - /** - * @param ClientInterface $client Client instance used by the context. - * @param PipelineExecutorInterface $executor Pipeline executor instace. - */ - public function __construct(ClientInterface $client, PipelineExecutorInterface $executor = null) - { - $this->client = $client; - $this->executor = $executor ?: $this->createExecutor($client); - $this->pipeline = new SplQueue(); - } - - /** - * Returns a pipeline executor depending on the kind of the underlying - * connection and the passed options. - * - * @param ClientInterface $client Client instance used by the context. - * @return PipelineExecutorInterface - */ - protected function createExecutor(ClientInterface $client) - { - $options = $client->getOptions(); - - if (isset($options->exceptions)) { - return new StandardExecutor($options->exceptions); - } - - return new StandardExecutor(); - } - - /** - * Queues a command into the pipeline buffer. - * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. - * @return $this - */ - public function __call($method, $arguments) - { - $command = $this->client->createCommand($method, $arguments); - $this->recordCommand($command); - - return $this; - } - - /** - * Queues a command instance into the pipeline buffer. - * - * @param CommandInterface $command Command to queue in the buffer. - */ - protected function recordCommand(CommandInterface $command) - { - $this->pipeline->enqueue($command); - } - - /** - * Queues a command instance into the pipeline buffer. - * - * @param CommandInterface $command Command to queue in the buffer. - * @return $this - */ - public function executeCommand(CommandInterface $command) - { - $this->recordCommand($command); - - return $this; - } - - /** - * Flushes the buffer that holds the queued commands. - * - * @param bool $send Specifies if the commands in the buffer should be sent to Redis. - * @return PipelineContext - */ - public function flushPipeline($send = true) - { - if ($send && !$this->pipeline->isEmpty()) { - $connection = $this->client->getConnection(); - $replies = $this->executor->execute($connection, $this->pipeline); - $this->replies = array_merge($this->replies, $replies); - } else { - $this->pipeline = new SplQueue(); - } - - return $this; - } - - /** - * Marks the running status of the pipeline. - * - * @param bool $bool True if the pipeline is running. - * False if the pipeline is not running. - */ - private function setRunning($bool) - { - if ($bool === true && $this->running === true) { - throw new ClientException("This pipeline is already opened"); - } - - $this->running = $bool; - } - - /** - * Handles the actual execution of the whole pipeline. - * - * @param mixed $callable Optional callback for execution. - * @return array - */ - public function execute($callable = null) - { - if ($callable && !is_callable($callable)) { - throw new \InvalidArgumentException('Argument passed must be a callable object'); - } - - $this->setRunning(true); - $pipelineBlockException = null; - - try { - if ($callable !== null) { - call_user_func($callable, $this); - } - $this->flushPipeline(); - } catch (\Exception $exception) { - $pipelineBlockException = $exception; - } - - $this->setRunning(false); - - if ($pipelineBlockException !== null) { - throw $pipelineBlockException; - } - - return $this->replies; - } - - /** - * Returns the underlying client instance used by the pipeline object. - * - * @return ClientInterface - */ - public function getClient() - { - return $this->client; - } - - /** - * Returns the underlying pipeline executor used by the pipeline object. - * - * @return PipelineExecutorInterface - */ - public function getExecutor() - { - return $this->executor; - } -} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/PipelineExecutorInterface.php b/vendor/predis/predis/lib/Predis/Pipeline/PipelineExecutorInterface.php deleted file mode 100644 index 74b7d414c..000000000 --- a/vendor/predis/predis/lib/Predis/Pipeline/PipelineExecutorInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use SplQueue; -use Predis\Connection\ConnectionInterface; - -/** - * Defines a strategy to write a list of commands to the network - * and read back their replies. - * - * @author Daniele Alessandri - */ -interface PipelineExecutorInterface -{ - /** - * Writes a list of commands to the network and reads back their replies. - * - * @param ConnectionInterface $connection Connection to Redis. - * @param SplQueue $commands Commands queued for execution. - * @return array - */ - public function execute(ConnectionInterface $connection, SplQueue $commands); -} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/SafeClusterExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/SafeClusterExecutor.php deleted file mode 100644 index b3622309b..000000000 --- a/vendor/predis/predis/lib/Predis/Pipeline/SafeClusterExecutor.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use SplQueue; -use Predis\CommunicationException; -use Predis\Connection\ConnectionInterface; - -/** - * Implements a pipeline executor strategy for connection clusters that does - * not fail when an error is encountered, but adds the returned error in the - * replies array. - * - * @author Daniele Alessandri - */ -class SafeClusterExecutor implements PipelineExecutorInterface -{ - /** - * {@inheritdoc} - */ - public function execute(ConnectionInterface $connection, SplQueue $commands) - { - $size = count($commands); - $values = array(); - $connectionExceptions = array(); - - foreach ($commands as $command) { - $cmdConnection = $connection->getConnection($command); - - if (isset($connectionExceptions[spl_object_hash($cmdConnection)])) { - continue; - } - - try { - $cmdConnection->writeCommand($command); - } catch (CommunicationException $exception) { - $connectionExceptions[spl_object_hash($cmdConnection)] = $exception; - } - } - - for ($i = 0; $i < $size; $i++) { - $command = $commands->dequeue(); - - $cmdConnection = $connection->getConnection($command); - $connectionObjectHash = spl_object_hash($cmdConnection); - - if (isset($connectionExceptions[$connectionObjectHash])) { - $values[$i] = $connectionExceptions[$connectionObjectHash]; - continue; - } - - try { - $response = $cmdConnection->readResponse($command); - $values[$i] = $response instanceof \Iterator ? iterator_to_array($response) : $response; - } catch (CommunicationException $exception) { - $values[$i] = $exception; - $connectionExceptions[$connectionObjectHash] = $exception; - } - } - - return $values; - } -} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/SafeExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/SafeExecutor.php deleted file mode 100644 index 2d693c01b..000000000 --- a/vendor/predis/predis/lib/Predis/Pipeline/SafeExecutor.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use SplQueue; -use Predis\CommunicationException; -use Predis\Connection\ConnectionInterface; - -/** - * Implements a pipeline executor strategy that does not fail when an error is - * encountered, but adds the returned error in the replies array. - * - * @author Daniele Alessandri - */ -class SafeExecutor implements PipelineExecutorInterface -{ - /** - * {@inheritdoc} - */ - public function execute(ConnectionInterface $connection, SplQueue $commands) - { - $size = count($commands); - $values = array(); - - foreach ($commands as $command) { - try { - $connection->writeCommand($command); - } catch (CommunicationException $exception) { - return array_fill(0, $size, $exception); - } - } - - for ($i = 0; $i < $size; $i++) { - $command = $commands->dequeue(); - - try { - $response = $connection->readResponse($command); - $values[$i] = $response instanceof \Iterator ? iterator_to_array($response) : $response; - } catch (CommunicationException $exception) { - $toAdd = count($commands) - count($values); - $values = array_merge($values, array_fill(0, $toAdd, $exception)); - break; - } - } - - return $values; - } -} diff --git a/vendor/predis/predis/lib/Predis/Pipeline/StandardExecutor.php b/vendor/predis/predis/lib/Predis/Pipeline/StandardExecutor.php deleted file mode 100644 index dd1e04343..000000000 --- a/vendor/predis/predis/lib/Predis/Pipeline/StandardExecutor.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use Iterator; -use SplQueue; -use Predis\ResponseErrorInterface; -use Predis\ResponseObjectInterface; -use Predis\ServerException; -use Predis\Command\CommandInterface; -use Predis\Connection\ConnectionInterface; -use Predis\Connection\ReplicationConnectionInterface; - -/** - * Implements the standard pipeline executor strategy used - * to write a list of commands and read their replies over - * a connection to Redis. - * - * @author Daniele Alessandri - */ -class StandardExecutor implements PipelineExecutorInterface -{ - protected $exceptions; - - /** - * @param bool $exceptions Specifies if the executor should throw exceptions on server errors. - */ - public function __construct($exceptions = true) - { - $this->exceptions = (bool) $exceptions; - } - - /** - * Allows the pipeline executor to perform operations on the - * connection before starting to execute the commands stored - * in the pipeline. - * - * @param ConnectionInterface $connection Connection instance. - */ - protected function checkConnection(ConnectionInterface $connection) - { - if ($connection instanceof ReplicationConnectionInterface) { - $connection->switchTo('master'); - } - } - - /** - * Handles a response object. - * - * @param ConnectionInterface $connection - * @param CommandInterface $command - * @param ResponseObjectInterface $response - * @return mixed - */ - protected function onResponseObject(ConnectionInterface $connection, CommandInterface $command, ResponseObjectInterface $response) - { - if ($response instanceof ResponseErrorInterface) { - return $this->onResponseError($connection, $response); - } - - if ($response instanceof Iterator) { - return $command->parseResponse(iterator_to_array($response)); - } - - return $response; - } - - /** - * Handles -ERR responses returned by Redis. - * - * @param ConnectionInterface $connection The connection that returned the error. - * @param ResponseErrorInterface $response The error response instance. - * @return ResponseErrorInterface - */ - protected function onResponseError(ConnectionInterface $connection, ResponseErrorInterface $response) - { - if (!$this->exceptions) { - return $response; - } - - // Force disconnection to prevent protocol desynchronization. - $connection->disconnect(); - $message = $response->getMessage(); - - throw new ServerException($message); - } - - /** - * {@inheritdoc} - */ - public function execute(ConnectionInterface $connection, SplQueue $commands) - { - $this->checkConnection($connection); - - foreach ($commands as $command) { - $connection->writeCommand($command); - } - - $values = array(); - - while (!$commands->isEmpty()) { - $command = $commands->dequeue(); - $response = $connection->readResponse($command); - - if ($response instanceof ResponseObjectInterface) { - $values[] = $this->onResponseObject($connection, $command, $response); - } else { - $values[] = $command->parseResponse($response); - } - } - - return $values; - } -} diff --git a/vendor/predis/predis/lib/Predis/PredisException.php b/vendor/predis/predis/lib/Predis/PredisException.php deleted file mode 100644 index 122bde16d..000000000 --- a/vendor/predis/predis/lib/Predis/PredisException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Base exception class for Predis-related errors. - * - * @author Daniele Alessandri - */ -abstract class PredisException extends \Exception -{ -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerProfile.php b/vendor/predis/predis/lib/Predis/Profile/ServerProfile.php deleted file mode 100644 index 75462faad..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerProfile.php +++ /dev/null @@ -1,228 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -use Predis\ClientException; -use Predis\Command\Processor\CommandProcessingInterface; -use Predis\Command\Processor\CommandProcessorInterface; - -/** - * Base class that implements common functionalities of server profiles. - * - * @author Daniele Alessandri - */ -abstract class ServerProfile implements ServerProfileInterface, CommandProcessingInterface -{ - private static $profiles; - - private $commands; - private $processor; - - /** - * - */ - public function __construct() - { - $this->commands = $this->getSupportedCommands(); - } - - /** - * Returns a map of all the commands supported by the profile and their - * actual PHP classes. - * - * @return array - */ - abstract protected function getSupportedCommands(); - - /** - * Returns the default server profile. - * - * @return ServerProfileInterface - */ - public static function getDefault() - { - return self::get('default'); - } - - /** - * Returns the development server profile. - * - * @return ServerProfileInterface - */ - public static function getDevelopment() - { - return self::get('dev'); - } - - /** - * Returns a map of all the server profiles supported by default and their - * actual PHP classes. - * - * @return array - */ - private static function getDefaultProfiles() - { - return array( - '1.2' => 'Predis\Profile\ServerVersion12', - '2.0' => 'Predis\Profile\ServerVersion20', - '2.2' => 'Predis\Profile\ServerVersion22', - '2.4' => 'Predis\Profile\ServerVersion24', - '2.6' => 'Predis\Profile\ServerVersion26', - '2.8' => 'Predis\Profile\ServerVersion28', - 'default' => 'Predis\Profile\ServerVersion26', - 'dev' => 'Predis\Profile\ServerVersionNext', - ); - } - - /** - * Registers a new server profile. - * - * @param string $alias Profile version or alias. - * @param string $profileClass FQN of a class implementing Predis\Profile\ServerProfileInterface. - */ - public static function define($alias, $profileClass) - { - if (!isset(self::$profiles)) { - self::$profiles = self::getDefaultProfiles(); - } - - $profileReflection = new \ReflectionClass($profileClass); - - if (!$profileReflection->isSubclassOf('Predis\Profile\ServerProfileInterface')) { - throw new \InvalidArgumentException("Cannot register '$profileClass' as it is not a valid profile class"); - } - - self::$profiles[$alias] = $profileClass; - } - - /** - * Returns the specified server profile. - * - * @param string $version Profile version or alias. - * @return ServerProfileInterface - */ - public static function get($version) - { - if (!isset(self::$profiles)) { - self::$profiles = self::getDefaultProfiles(); - } - - if (!isset(self::$profiles[$version])) { - throw new ClientException("Unknown server profile: $version"); - } - - $profile = self::$profiles[$version]; - - return new $profile(); - } - - /** - * {@inheritdoc} - */ - public function supportsCommands(Array $commands) - { - foreach ($commands as $command) { - if (!$this->supportsCommand($command)) { - return false; - } - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function supportsCommand($command) - { - return isset($this->commands[strtolower($command)]); - } - - /** - * Returns the FQN of the class that represent the specified command ID - * registered in the current server profile. - * - * @param string $command Command ID. - * @return string - */ - public function getCommandClass($command) - { - if (isset($this->commands[$command = strtolower($command)])) { - return $this->commands[$command]; - } - } - - /** - * {@inheritdoc} - */ - public function createCommand($method, $arguments = array()) - { - $method = strtolower($method); - - if (!isset($this->commands[$method])) { - throw new ClientException("'$method' is not a registered Redis command"); - } - - $commandClass = $this->commands[$method]; - $command = new $commandClass(); - $command->setArguments($arguments); - - if (isset($this->processor)) { - $this->processor->process($command); - } - - return $command; - } - - /** - * Defines a new commands in the server profile. - * - * @param string $alias Command ID. - * @param string $command FQN of a class implementing Predis\Command\CommandInterface. - */ - public function defineCommand($alias, $command) - { - $commandReflection = new \ReflectionClass($command); - - if (!$commandReflection->isSubclassOf('Predis\Command\CommandInterface')) { - throw new \InvalidArgumentException("Cannot register '$command' as it is not a valid Redis command"); - } - - $this->commands[strtolower($alias)] = $command; - } - - /** - * {@inheritdoc} - */ - public function setProcessor(CommandProcessorInterface $processor = null) - { - $this->processor = $processor; - } - - /** - * {@inheritdoc} - */ - public function getProcessor() - { - return $this->processor; - } - - /** - * Returns the version of server profile as its string representation. - * - * @return string - */ - public function __toString() - { - return $this->getVersion(); - } -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerProfileInterface.php b/vendor/predis/predis/lib/Predis/Profile/ServerProfileInterface.php deleted file mode 100644 index ea9a8a0e2..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerProfileInterface.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -use Predis\Command\CommandInterface; - -/** - * A server profile defines features and commands supported by certain - * versions of Redis. Instances of Predis\Client should use a server - * profile matching the version of Redis in use. - * - * @author Daniele Alessandri - */ -interface ServerProfileInterface -{ - /** - * Gets a profile version corresponding to a Redis version. - * - * @return string - */ - public function getVersion(); - - /** - * Checks if the profile supports the specified command. - * - * @param string $command Command ID. - * @return bool - */ - public function supportsCommand($command); - - /** - * Checks if the profile supports the specified list of commands. - * - * @param array $commands List of command IDs. - * @return string - */ - public function supportsCommands(Array $commands); - - /** - * Creates a new command instance. - * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. - * @return CommandInterface - */ - public function createCommand($method, $arguments = array()); -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion12.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion12.php deleted file mode 100644 index 4e339a7c5..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerVersion12.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * Server profile for Redis v1.2.x. - * - * @author Daniele Alessandri - */ -class ServerVersion12 extends ServerProfile -{ - /** - * {@inheritdoc} - */ - public function getVersion() - { - return '1.2'; - } - - /** - * {@inheritdoc} - */ - public function getSupportedCommands() - { - return array( - /* ---------------- Redis 1.2 ---------------- */ - - /* commands operating on the key space */ - 'exists' => 'Predis\Command\KeyExists', - 'del' => 'Predis\Command\KeyDelete', - 'type' => 'Predis\Command\KeyType', - 'keys' => 'Predis\Command\KeyKeysV12x', - 'randomkey' => 'Predis\Command\KeyRandom', - 'rename' => 'Predis\Command\KeyRename', - 'renamenx' => 'Predis\Command\KeyRenamePreserve', - 'expire' => 'Predis\Command\KeyExpire', - 'expireat' => 'Predis\Command\KeyExpireAt', - 'ttl' => 'Predis\Command\KeyTimeToLive', - 'move' => 'Predis\Command\KeyMove', - 'sort' => 'Predis\Command\KeySort', - - /* commands operating on string values */ - 'set' => 'Predis\Command\StringSet', - 'setnx' => 'Predis\Command\StringSetPreserve', - 'mset' => 'Predis\Command\StringSetMultiple', - 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', - 'get' => 'Predis\Command\StringGet', - 'mget' => 'Predis\Command\StringGetMultiple', - 'getset' => 'Predis\Command\StringGetSet', - 'incr' => 'Predis\Command\StringIncrement', - 'incrby' => 'Predis\Command\StringIncrementBy', - 'decr' => 'Predis\Command\StringDecrement', - 'decrby' => 'Predis\Command\StringDecrementBy', - - /* commands operating on lists */ - 'rpush' => 'Predis\Command\ListPushTail', - 'lpush' => 'Predis\Command\ListPushHead', - 'llen' => 'Predis\Command\ListLength', - 'lrange' => 'Predis\Command\ListRange', - 'ltrim' => 'Predis\Command\ListTrim', - 'lindex' => 'Predis\Command\ListIndex', - 'lset' => 'Predis\Command\ListSet', - 'lrem' => 'Predis\Command\ListRemove', - 'lpop' => 'Predis\Command\ListPopFirst', - 'rpop' => 'Predis\Command\ListPopLast', - 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', - - /* commands operating on sets */ - 'sadd' => 'Predis\Command\SetAdd', - 'srem' => 'Predis\Command\SetRemove', - 'spop' => 'Predis\Command\SetPop', - 'smove' => 'Predis\Command\SetMove', - 'scard' => 'Predis\Command\SetCardinality', - 'sismember' => 'Predis\Command\SetIsMember', - 'sinter' => 'Predis\Command\SetIntersection', - 'sinterstore' => 'Predis\Command\SetIntersectionStore', - 'sunion' => 'Predis\Command\SetUnion', - 'sunionstore' => 'Predis\Command\SetUnionStore', - 'sdiff' => 'Predis\Command\SetDifference', - 'sdiffstore' => 'Predis\Command\SetDifferenceStore', - 'smembers' => 'Predis\Command\SetMembers', - 'srandmember' => 'Predis\Command\SetRandomMember', - - /* commands operating on sorted sets */ - 'zadd' => 'Predis\Command\ZSetAdd', - 'zincrby' => 'Predis\Command\ZSetIncrementBy', - 'zrem' => 'Predis\Command\ZSetRemove', - 'zrange' => 'Predis\Command\ZSetRange', - 'zrevrange' => 'Predis\Command\ZSetReverseRange', - 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', - 'zcard' => 'Predis\Command\ZSetCardinality', - 'zscore' => 'Predis\Command\ZSetScore', - 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', - - /* connection related commands */ - 'ping' => 'Predis\Command\ConnectionPing', - 'auth' => 'Predis\Command\ConnectionAuth', - 'select' => 'Predis\Command\ConnectionSelect', - 'echo' => 'Predis\Command\ConnectionEcho', - 'quit' => 'Predis\Command\ConnectionQuit', - - /* remote server control commands */ - 'info' => 'Predis\Command\ServerInfo', - 'slaveof' => 'Predis\Command\ServerSlaveOf', - 'monitor' => 'Predis\Command\ServerMonitor', - 'dbsize' => 'Predis\Command\ServerDatabaseSize', - 'flushdb' => 'Predis\Command\ServerFlushDatabase', - 'flushall' => 'Predis\Command\ServerFlushAll', - 'save' => 'Predis\Command\ServerSave', - 'bgsave' => 'Predis\Command\ServerBackgroundSave', - 'lastsave' => 'Predis\Command\ServerLastSave', - 'shutdown' => 'Predis\Command\ServerShutdown', - 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion20.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion20.php deleted file mode 100644 index 4fae3f9ee..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerVersion20.php +++ /dev/null @@ -1,173 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * Server profile for Redis v2.0.x. - * - * @author Daniele Alessandri - */ -class ServerVersion20 extends ServerProfile -{ - /** - * {@inheritdoc} - */ - public function getVersion() - { - return '2.0'; - } - - /** - * {@inheritdoc} - */ - public function getSupportedCommands() - { - return array( - /* ---------------- Redis 1.2 ---------------- */ - - /* commands operating on the key space */ - 'exists' => 'Predis\Command\KeyExists', - 'del' => 'Predis\Command\KeyDelete', - 'type' => 'Predis\Command\KeyType', - 'keys' => 'Predis\Command\KeyKeys', - 'randomkey' => 'Predis\Command\KeyRandom', - 'rename' => 'Predis\Command\KeyRename', - 'renamenx' => 'Predis\Command\KeyRenamePreserve', - 'expire' => 'Predis\Command\KeyExpire', - 'expireat' => 'Predis\Command\KeyExpireAt', - 'ttl' => 'Predis\Command\KeyTimeToLive', - 'move' => 'Predis\Command\KeyMove', - 'sort' => 'Predis\Command\KeySort', - - /* commands operating on string values */ - 'set' => 'Predis\Command\StringSet', - 'setnx' => 'Predis\Command\StringSetPreserve', - 'mset' => 'Predis\Command\StringSetMultiple', - 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', - 'get' => 'Predis\Command\StringGet', - 'mget' => 'Predis\Command\StringGetMultiple', - 'getset' => 'Predis\Command\StringGetSet', - 'incr' => 'Predis\Command\StringIncrement', - 'incrby' => 'Predis\Command\StringIncrementBy', - 'decr' => 'Predis\Command\StringDecrement', - 'decrby' => 'Predis\Command\StringDecrementBy', - - /* commands operating on lists */ - 'rpush' => 'Predis\Command\ListPushTail', - 'lpush' => 'Predis\Command\ListPushHead', - 'llen' => 'Predis\Command\ListLength', - 'lrange' => 'Predis\Command\ListRange', - 'ltrim' => 'Predis\Command\ListTrim', - 'lindex' => 'Predis\Command\ListIndex', - 'lset' => 'Predis\Command\ListSet', - 'lrem' => 'Predis\Command\ListRemove', - 'lpop' => 'Predis\Command\ListPopFirst', - 'rpop' => 'Predis\Command\ListPopLast', - 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', - - /* commands operating on sets */ - 'sadd' => 'Predis\Command\SetAdd', - 'srem' => 'Predis\Command\SetRemove', - 'spop' => 'Predis\Command\SetPop', - 'smove' => 'Predis\Command\SetMove', - 'scard' => 'Predis\Command\SetCardinality', - 'sismember' => 'Predis\Command\SetIsMember', - 'sinter' => 'Predis\Command\SetIntersection', - 'sinterstore' => 'Predis\Command\SetIntersectionStore', - 'sunion' => 'Predis\Command\SetUnion', - 'sunionstore' => 'Predis\Command\SetUnionStore', - 'sdiff' => 'Predis\Command\SetDifference', - 'sdiffstore' => 'Predis\Command\SetDifferenceStore', - 'smembers' => 'Predis\Command\SetMembers', - 'srandmember' => 'Predis\Command\SetRandomMember', - - /* commands operating on sorted sets */ - 'zadd' => 'Predis\Command\ZSetAdd', - 'zincrby' => 'Predis\Command\ZSetIncrementBy', - 'zrem' => 'Predis\Command\ZSetRemove', - 'zrange' => 'Predis\Command\ZSetRange', - 'zrevrange' => 'Predis\Command\ZSetReverseRange', - 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', - 'zcard' => 'Predis\Command\ZSetCardinality', - 'zscore' => 'Predis\Command\ZSetScore', - 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', - - /* connection related commands */ - 'ping' => 'Predis\Command\ConnectionPing', - 'auth' => 'Predis\Command\ConnectionAuth', - 'select' => 'Predis\Command\ConnectionSelect', - 'echo' => 'Predis\Command\ConnectionEcho', - 'quit' => 'Predis\Command\ConnectionQuit', - - /* remote server control commands */ - 'info' => 'Predis\Command\ServerInfo', - 'slaveof' => 'Predis\Command\ServerSlaveOf', - 'monitor' => 'Predis\Command\ServerMonitor', - 'dbsize' => 'Predis\Command\ServerDatabaseSize', - 'flushdb' => 'Predis\Command\ServerFlushDatabase', - 'flushall' => 'Predis\Command\ServerFlushAll', - 'save' => 'Predis\Command\ServerSave', - 'bgsave' => 'Predis\Command\ServerBackgroundSave', - 'lastsave' => 'Predis\Command\ServerLastSave', - 'shutdown' => 'Predis\Command\ServerShutdown', - 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - - /* ---------------- Redis 2.0 ---------------- */ - - /* commands operating on string values */ - 'setex' => 'Predis\Command\StringSetExpire', - 'append' => 'Predis\Command\StringAppend', - 'substr' => 'Predis\Command\StringSubstr', - - /* commands operating on lists */ - 'blpop' => 'Predis\Command\ListPopFirstBlocking', - 'brpop' => 'Predis\Command\ListPopLastBlocking', - - /* commands operating on sorted sets */ - 'zunionstore' => 'Predis\Command\ZSetUnionStore', - 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', - 'zcount' => 'Predis\Command\ZSetCount', - 'zrank' => 'Predis\Command\ZSetRank', - 'zrevrank' => 'Predis\Command\ZSetReverseRank', - 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', - - /* commands operating on hashes */ - 'hset' => 'Predis\Command\HashSet', - 'hsetnx' => 'Predis\Command\HashSetPreserve', - 'hmset' => 'Predis\Command\HashSetMultiple', - 'hincrby' => 'Predis\Command\HashIncrementBy', - 'hget' => 'Predis\Command\HashGet', - 'hmget' => 'Predis\Command\HashGetMultiple', - 'hdel' => 'Predis\Command\HashDelete', - 'hexists' => 'Predis\Command\HashExists', - 'hlen' => 'Predis\Command\HashLength', - 'hkeys' => 'Predis\Command\HashKeys', - 'hvals' => 'Predis\Command\HashValues', - 'hgetall' => 'Predis\Command\HashGetAll', - - /* transactions */ - 'multi' => 'Predis\Command\TransactionMulti', - 'exec' => 'Predis\Command\TransactionExec', - 'discard' => 'Predis\Command\TransactionDiscard', - - /* publish - subscribe */ - 'subscribe' => 'Predis\Command\PubSubSubscribe', - 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', - 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', - 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', - 'publish' => 'Predis\Command\PubSubPublish', - - /* remote server control commands */ - 'config' => 'Predis\Command\ServerConfig', - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion22.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion22.php deleted file mode 100644 index 2fe4fca94..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerVersion22.php +++ /dev/null @@ -1,202 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * Server profile for Redis v2.2.x. - * - * @author Daniele Alessandri - */ -class ServerVersion22 extends ServerProfile -{ - /** - * {@inheritdoc} - */ - public function getVersion() - { - return '2.2'; - } - - /** - * {@inheritdoc} - */ - public function getSupportedCommands() - { - return array( - /* ---------------- Redis 1.2 ---------------- */ - - /* commands operating on the key space */ - 'exists' => 'Predis\Command\KeyExists', - 'del' => 'Predis\Command\KeyDelete', - 'type' => 'Predis\Command\KeyType', - 'keys' => 'Predis\Command\KeyKeys', - 'randomkey' => 'Predis\Command\KeyRandom', - 'rename' => 'Predis\Command\KeyRename', - 'renamenx' => 'Predis\Command\KeyRenamePreserve', - 'expire' => 'Predis\Command\KeyExpire', - 'expireat' => 'Predis\Command\KeyExpireAt', - 'ttl' => 'Predis\Command\KeyTimeToLive', - 'move' => 'Predis\Command\KeyMove', - 'sort' => 'Predis\Command\KeySort', - - /* commands operating on string values */ - 'set' => 'Predis\Command\StringSet', - 'setnx' => 'Predis\Command\StringSetPreserve', - 'mset' => 'Predis\Command\StringSetMultiple', - 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', - 'get' => 'Predis\Command\StringGet', - 'mget' => 'Predis\Command\StringGetMultiple', - 'getset' => 'Predis\Command\StringGetSet', - 'incr' => 'Predis\Command\StringIncrement', - 'incrby' => 'Predis\Command\StringIncrementBy', - 'decr' => 'Predis\Command\StringDecrement', - 'decrby' => 'Predis\Command\StringDecrementBy', - - /* commands operating on lists */ - 'rpush' => 'Predis\Command\ListPushTail', - 'lpush' => 'Predis\Command\ListPushHead', - 'llen' => 'Predis\Command\ListLength', - 'lrange' => 'Predis\Command\ListRange', - 'ltrim' => 'Predis\Command\ListTrim', - 'lindex' => 'Predis\Command\ListIndex', - 'lset' => 'Predis\Command\ListSet', - 'lrem' => 'Predis\Command\ListRemove', - 'lpop' => 'Predis\Command\ListPopFirst', - 'rpop' => 'Predis\Command\ListPopLast', - 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', - - /* commands operating on sets */ - 'sadd' => 'Predis\Command\SetAdd', - 'srem' => 'Predis\Command\SetRemove', - 'spop' => 'Predis\Command\SetPop', - 'smove' => 'Predis\Command\SetMove', - 'scard' => 'Predis\Command\SetCardinality', - 'sismember' => 'Predis\Command\SetIsMember', - 'sinter' => 'Predis\Command\SetIntersection', - 'sinterstore' => 'Predis\Command\SetIntersectionStore', - 'sunion' => 'Predis\Command\SetUnion', - 'sunionstore' => 'Predis\Command\SetUnionStore', - 'sdiff' => 'Predis\Command\SetDifference', - 'sdiffstore' => 'Predis\Command\SetDifferenceStore', - 'smembers' => 'Predis\Command\SetMembers', - 'srandmember' => 'Predis\Command\SetRandomMember', - - /* commands operating on sorted sets */ - 'zadd' => 'Predis\Command\ZSetAdd', - 'zincrby' => 'Predis\Command\ZSetIncrementBy', - 'zrem' => 'Predis\Command\ZSetRemove', - 'zrange' => 'Predis\Command\ZSetRange', - 'zrevrange' => 'Predis\Command\ZSetReverseRange', - 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', - 'zcard' => 'Predis\Command\ZSetCardinality', - 'zscore' => 'Predis\Command\ZSetScore', - 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', - - /* connection related commands */ - 'ping' => 'Predis\Command\ConnectionPing', - 'auth' => 'Predis\Command\ConnectionAuth', - 'select' => 'Predis\Command\ConnectionSelect', - 'echo' => 'Predis\Command\ConnectionEcho', - 'quit' => 'Predis\Command\ConnectionQuit', - - /* remote server control commands */ - 'info' => 'Predis\Command\ServerInfo', - 'slaveof' => 'Predis\Command\ServerSlaveOf', - 'monitor' => 'Predis\Command\ServerMonitor', - 'dbsize' => 'Predis\Command\ServerDatabaseSize', - 'flushdb' => 'Predis\Command\ServerFlushDatabase', - 'flushall' => 'Predis\Command\ServerFlushAll', - 'save' => 'Predis\Command\ServerSave', - 'bgsave' => 'Predis\Command\ServerBackgroundSave', - 'lastsave' => 'Predis\Command\ServerLastSave', - 'shutdown' => 'Predis\Command\ServerShutdown', - 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - - /* ---------------- Redis 2.0 ---------------- */ - - /* commands operating on string values */ - 'setex' => 'Predis\Command\StringSetExpire', - 'append' => 'Predis\Command\StringAppend', - 'substr' => 'Predis\Command\StringSubstr', - - /* commands operating on lists */ - 'blpop' => 'Predis\Command\ListPopFirstBlocking', - 'brpop' => 'Predis\Command\ListPopLastBlocking', - - /* commands operating on sorted sets */ - 'zunionstore' => 'Predis\Command\ZSetUnionStore', - 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', - 'zcount' => 'Predis\Command\ZSetCount', - 'zrank' => 'Predis\Command\ZSetRank', - 'zrevrank' => 'Predis\Command\ZSetReverseRank', - 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', - - /* commands operating on hashes */ - 'hset' => 'Predis\Command\HashSet', - 'hsetnx' => 'Predis\Command\HashSetPreserve', - 'hmset' => 'Predis\Command\HashSetMultiple', - 'hincrby' => 'Predis\Command\HashIncrementBy', - 'hget' => 'Predis\Command\HashGet', - 'hmget' => 'Predis\Command\HashGetMultiple', - 'hdel' => 'Predis\Command\HashDelete', - 'hexists' => 'Predis\Command\HashExists', - 'hlen' => 'Predis\Command\HashLength', - 'hkeys' => 'Predis\Command\HashKeys', - 'hvals' => 'Predis\Command\HashValues', - 'hgetall' => 'Predis\Command\HashGetAll', - - /* transactions */ - 'multi' => 'Predis\Command\TransactionMulti', - 'exec' => 'Predis\Command\TransactionExec', - 'discard' => 'Predis\Command\TransactionDiscard', - - /* publish - subscribe */ - 'subscribe' => 'Predis\Command\PubSubSubscribe', - 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', - 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', - 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', - 'publish' => 'Predis\Command\PubSubPublish', - - /* remote server control commands */ - 'config' => 'Predis\Command\ServerConfig', - - /* ---------------- Redis 2.2 ---------------- */ - - /* commands operating on the key space */ - 'persist' => 'Predis\Command\KeyPersist', - - /* commands operating on string values */ - 'strlen' => 'Predis\Command\StringStrlen', - 'setrange' => 'Predis\Command\StringSetRange', - 'getrange' => 'Predis\Command\StringGetRange', - 'setbit' => 'Predis\Command\StringSetBit', - 'getbit' => 'Predis\Command\StringGetBit', - - /* commands operating on lists */ - 'rpushx' => 'Predis\Command\ListPushTailX', - 'lpushx' => 'Predis\Command\ListPushHeadX', - 'linsert' => 'Predis\Command\ListInsert', - 'brpoplpush' => 'Predis\Command\ListPopLastPushHeadBlocking', - - /* commands operating on sorted sets */ - 'zrevrangebyscore' => 'Predis\Command\ZSetReverseRangeByScore', - - /* transactions */ - 'watch' => 'Predis\Command\TransactionWatch', - 'unwatch' => 'Predis\Command\TransactionUnwatch', - - /* remote server control commands */ - 'object' => 'Predis\Command\ServerObject', - 'slowlog' => 'Predis\Command\ServerSlowlog', - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php deleted file mode 100644 index 455d5b6d8..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerVersion24.php +++ /dev/null @@ -1,207 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * Server profile for Redis v2.4.x. - * - * @author Daniele Alessandri - */ -class ServerVersion24 extends ServerProfile -{ - /** - * {@inheritdoc} - */ - public function getVersion() - { - return '2.4'; - } - - /** - * {@inheritdoc} - */ - public function getSupportedCommands() - { - return array( - /* ---------------- Redis 1.2 ---------------- */ - - /* commands operating on the key space */ - 'exists' => 'Predis\Command\KeyExists', - 'del' => 'Predis\Command\KeyDelete', - 'type' => 'Predis\Command\KeyType', - 'keys' => 'Predis\Command\KeyKeys', - 'randomkey' => 'Predis\Command\KeyRandom', - 'rename' => 'Predis\Command\KeyRename', - 'renamenx' => 'Predis\Command\KeyRenamePreserve', - 'expire' => 'Predis\Command\KeyExpire', - 'expireat' => 'Predis\Command\KeyExpireAt', - 'ttl' => 'Predis\Command\KeyTimeToLive', - 'move' => 'Predis\Command\KeyMove', - 'sort' => 'Predis\Command\KeySort', - - /* commands operating on string values */ - 'set' => 'Predis\Command\StringSet', - 'setnx' => 'Predis\Command\StringSetPreserve', - 'mset' => 'Predis\Command\StringSetMultiple', - 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', - 'get' => 'Predis\Command\StringGet', - 'mget' => 'Predis\Command\StringGetMultiple', - 'getset' => 'Predis\Command\StringGetSet', - 'incr' => 'Predis\Command\StringIncrement', - 'incrby' => 'Predis\Command\StringIncrementBy', - 'decr' => 'Predis\Command\StringDecrement', - 'decrby' => 'Predis\Command\StringDecrementBy', - - /* commands operating on lists */ - 'rpush' => 'Predis\Command\ListPushTail', - 'lpush' => 'Predis\Command\ListPushHead', - 'llen' => 'Predis\Command\ListLength', - 'lrange' => 'Predis\Command\ListRange', - 'ltrim' => 'Predis\Command\ListTrim', - 'lindex' => 'Predis\Command\ListIndex', - 'lset' => 'Predis\Command\ListSet', - 'lrem' => 'Predis\Command\ListRemove', - 'lpop' => 'Predis\Command\ListPopFirst', - 'rpop' => 'Predis\Command\ListPopLast', - 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', - - /* commands operating on sets */ - 'sadd' => 'Predis\Command\SetAdd', - 'srem' => 'Predis\Command\SetRemove', - 'spop' => 'Predis\Command\SetPop', - 'smove' => 'Predis\Command\SetMove', - 'scard' => 'Predis\Command\SetCardinality', - 'sismember' => 'Predis\Command\SetIsMember', - 'sinter' => 'Predis\Command\SetIntersection', - 'sinterstore' => 'Predis\Command\SetIntersectionStore', - 'sunion' => 'Predis\Command\SetUnion', - 'sunionstore' => 'Predis\Command\SetUnionStore', - 'sdiff' => 'Predis\Command\SetDifference', - 'sdiffstore' => 'Predis\Command\SetDifferenceStore', - 'smembers' => 'Predis\Command\SetMembers', - 'srandmember' => 'Predis\Command\SetRandomMember', - - /* commands operating on sorted sets */ - 'zadd' => 'Predis\Command\ZSetAdd', - 'zincrby' => 'Predis\Command\ZSetIncrementBy', - 'zrem' => 'Predis\Command\ZSetRemove', - 'zrange' => 'Predis\Command\ZSetRange', - 'zrevrange' => 'Predis\Command\ZSetReverseRange', - 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', - 'zcard' => 'Predis\Command\ZSetCardinality', - 'zscore' => 'Predis\Command\ZSetScore', - 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', - - /* connection related commands */ - 'ping' => 'Predis\Command\ConnectionPing', - 'auth' => 'Predis\Command\ConnectionAuth', - 'select' => 'Predis\Command\ConnectionSelect', - 'echo' => 'Predis\Command\ConnectionEcho', - 'quit' => 'Predis\Command\ConnectionQuit', - - /* remote server control commands */ - 'info' => 'Predis\Command\ServerInfo', - 'slaveof' => 'Predis\Command\ServerSlaveOf', - 'monitor' => 'Predis\Command\ServerMonitor', - 'dbsize' => 'Predis\Command\ServerDatabaseSize', - 'flushdb' => 'Predis\Command\ServerFlushDatabase', - 'flushall' => 'Predis\Command\ServerFlushAll', - 'save' => 'Predis\Command\ServerSave', - 'bgsave' => 'Predis\Command\ServerBackgroundSave', - 'lastsave' => 'Predis\Command\ServerLastSave', - 'shutdown' => 'Predis\Command\ServerShutdown', - 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - - /* ---------------- Redis 2.0 ---------------- */ - - /* commands operating on string values */ - 'setex' => 'Predis\Command\StringSetExpire', - 'append' => 'Predis\Command\StringAppend', - 'substr' => 'Predis\Command\StringSubstr', - - /* commands operating on lists */ - 'blpop' => 'Predis\Command\ListPopFirstBlocking', - 'brpop' => 'Predis\Command\ListPopLastBlocking', - - /* commands operating on sorted sets */ - 'zunionstore' => 'Predis\Command\ZSetUnionStore', - 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', - 'zcount' => 'Predis\Command\ZSetCount', - 'zrank' => 'Predis\Command\ZSetRank', - 'zrevrank' => 'Predis\Command\ZSetReverseRank', - 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', - - /* commands operating on hashes */ - 'hset' => 'Predis\Command\HashSet', - 'hsetnx' => 'Predis\Command\HashSetPreserve', - 'hmset' => 'Predis\Command\HashSetMultiple', - 'hincrby' => 'Predis\Command\HashIncrementBy', - 'hget' => 'Predis\Command\HashGet', - 'hmget' => 'Predis\Command\HashGetMultiple', - 'hdel' => 'Predis\Command\HashDelete', - 'hexists' => 'Predis\Command\HashExists', - 'hlen' => 'Predis\Command\HashLength', - 'hkeys' => 'Predis\Command\HashKeys', - 'hvals' => 'Predis\Command\HashValues', - 'hgetall' => 'Predis\Command\HashGetAll', - - /* transactions */ - 'multi' => 'Predis\Command\TransactionMulti', - 'exec' => 'Predis\Command\TransactionExec', - 'discard' => 'Predis\Command\TransactionDiscard', - - /* publish - subscribe */ - 'subscribe' => 'Predis\Command\PubSubSubscribe', - 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', - 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', - 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', - 'publish' => 'Predis\Command\PubSubPublish', - - /* remote server control commands */ - 'config' => 'Predis\Command\ServerConfig', - - /* ---------------- Redis 2.2 ---------------- */ - - /* commands operating on the key space */ - 'persist' => 'Predis\Command\KeyPersist', - - /* commands operating on string values */ - 'strlen' => 'Predis\Command\StringStrlen', - 'setrange' => 'Predis\Command\StringSetRange', - 'getrange' => 'Predis\Command\StringGetRange', - 'setbit' => 'Predis\Command\StringSetBit', - 'getbit' => 'Predis\Command\StringGetBit', - - /* commands operating on lists */ - 'rpushx' => 'Predis\Command\ListPushTailX', - 'lpushx' => 'Predis\Command\ListPushHeadX', - 'linsert' => 'Predis\Command\ListInsert', - 'brpoplpush' => 'Predis\Command\ListPopLastPushHeadBlocking', - - /* commands operating on sorted sets */ - 'zrevrangebyscore' => 'Predis\Command\ZSetReverseRangeByScore', - - /* transactions */ - 'watch' => 'Predis\Command\TransactionWatch', - 'unwatch' => 'Predis\Command\TransactionUnwatch', - - /* remote server control commands */ - 'object' => 'Predis\Command\ServerObject', - 'slowlog' => 'Predis\Command\ServerSlowlog', - - /* ---------------- Redis 2.4 ---------------- */ - - /* remote server control commands */ - 'client' => 'Predis\Command\ServerClient', - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion26.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion26.php deleted file mode 100644 index 875f40958..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerVersion26.php +++ /dev/null @@ -1,233 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * Server profile for Redis v2.6.x. - * - * @author Daniele Alessandri - */ -class ServerVersion26 extends ServerProfile -{ - /** - * {@inheritdoc} - */ - public function getVersion() - { - return '2.6'; - } - - /** - * {@inheritdoc} - */ - public function getSupportedCommands() - { - return array( - /* ---------------- Redis 1.2 ---------------- */ - - /* commands operating on the key space */ - 'exists' => 'Predis\Command\KeyExists', - 'del' => 'Predis\Command\KeyDelete', - 'type' => 'Predis\Command\KeyType', - 'keys' => 'Predis\Command\KeyKeys', - 'randomkey' => 'Predis\Command\KeyRandom', - 'rename' => 'Predis\Command\KeyRename', - 'renamenx' => 'Predis\Command\KeyRenamePreserve', - 'expire' => 'Predis\Command\KeyExpire', - 'expireat' => 'Predis\Command\KeyExpireAt', - 'ttl' => 'Predis\Command\KeyTimeToLive', - 'move' => 'Predis\Command\KeyMove', - 'sort' => 'Predis\Command\KeySort', - 'dump' => 'Predis\Command\KeyDump', - 'restore' => 'Predis\Command\KeyRestore', - - /* commands operating on string values */ - 'set' => 'Predis\Command\StringSet', - 'setnx' => 'Predis\Command\StringSetPreserve', - 'mset' => 'Predis\Command\StringSetMultiple', - 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', - 'get' => 'Predis\Command\StringGet', - 'mget' => 'Predis\Command\StringGetMultiple', - 'getset' => 'Predis\Command\StringGetSet', - 'incr' => 'Predis\Command\StringIncrement', - 'incrby' => 'Predis\Command\StringIncrementBy', - 'decr' => 'Predis\Command\StringDecrement', - 'decrby' => 'Predis\Command\StringDecrementBy', - - /* commands operating on lists */ - 'rpush' => 'Predis\Command\ListPushTail', - 'lpush' => 'Predis\Command\ListPushHead', - 'llen' => 'Predis\Command\ListLength', - 'lrange' => 'Predis\Command\ListRange', - 'ltrim' => 'Predis\Command\ListTrim', - 'lindex' => 'Predis\Command\ListIndex', - 'lset' => 'Predis\Command\ListSet', - 'lrem' => 'Predis\Command\ListRemove', - 'lpop' => 'Predis\Command\ListPopFirst', - 'rpop' => 'Predis\Command\ListPopLast', - 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', - - /* commands operating on sets */ - 'sadd' => 'Predis\Command\SetAdd', - 'srem' => 'Predis\Command\SetRemove', - 'spop' => 'Predis\Command\SetPop', - 'smove' => 'Predis\Command\SetMove', - 'scard' => 'Predis\Command\SetCardinality', - 'sismember' => 'Predis\Command\SetIsMember', - 'sinter' => 'Predis\Command\SetIntersection', - 'sinterstore' => 'Predis\Command\SetIntersectionStore', - 'sunion' => 'Predis\Command\SetUnion', - 'sunionstore' => 'Predis\Command\SetUnionStore', - 'sdiff' => 'Predis\Command\SetDifference', - 'sdiffstore' => 'Predis\Command\SetDifferenceStore', - 'smembers' => 'Predis\Command\SetMembers', - 'srandmember' => 'Predis\Command\SetRandomMember', - - /* commands operating on sorted sets */ - 'zadd' => 'Predis\Command\ZSetAdd', - 'zincrby' => 'Predis\Command\ZSetIncrementBy', - 'zrem' => 'Predis\Command\ZSetRemove', - 'zrange' => 'Predis\Command\ZSetRange', - 'zrevrange' => 'Predis\Command\ZSetReverseRange', - 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', - 'zcard' => 'Predis\Command\ZSetCardinality', - 'zscore' => 'Predis\Command\ZSetScore', - 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', - - /* connection related commands */ - 'ping' => 'Predis\Command\ConnectionPing', - 'auth' => 'Predis\Command\ConnectionAuth', - 'select' => 'Predis\Command\ConnectionSelect', - 'echo' => 'Predis\Command\ConnectionEcho', - 'quit' => 'Predis\Command\ConnectionQuit', - - /* remote server control commands */ - 'info' => 'Predis\Command\ServerInfoV26x', - 'slaveof' => 'Predis\Command\ServerSlaveOf', - 'monitor' => 'Predis\Command\ServerMonitor', - 'dbsize' => 'Predis\Command\ServerDatabaseSize', - 'flushdb' => 'Predis\Command\ServerFlushDatabase', - 'flushall' => 'Predis\Command\ServerFlushAll', - 'save' => 'Predis\Command\ServerSave', - 'bgsave' => 'Predis\Command\ServerBackgroundSave', - 'lastsave' => 'Predis\Command\ServerLastSave', - 'shutdown' => 'Predis\Command\ServerShutdown', - 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - - /* ---------------- Redis 2.0 ---------------- */ - - /* commands operating on string values */ - 'setex' => 'Predis\Command\StringSetExpire', - 'append' => 'Predis\Command\StringAppend', - 'substr' => 'Predis\Command\StringSubstr', - - /* commands operating on lists */ - 'blpop' => 'Predis\Command\ListPopFirstBlocking', - 'brpop' => 'Predis\Command\ListPopLastBlocking', - - /* commands operating on sorted sets */ - 'zunionstore' => 'Predis\Command\ZSetUnionStore', - 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', - 'zcount' => 'Predis\Command\ZSetCount', - 'zrank' => 'Predis\Command\ZSetRank', - 'zrevrank' => 'Predis\Command\ZSetReverseRank', - 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', - - /* commands operating on hashes */ - 'hset' => 'Predis\Command\HashSet', - 'hsetnx' => 'Predis\Command\HashSetPreserve', - 'hmset' => 'Predis\Command\HashSetMultiple', - 'hincrby' => 'Predis\Command\HashIncrementBy', - 'hget' => 'Predis\Command\HashGet', - 'hmget' => 'Predis\Command\HashGetMultiple', - 'hdel' => 'Predis\Command\HashDelete', - 'hexists' => 'Predis\Command\HashExists', - 'hlen' => 'Predis\Command\HashLength', - 'hkeys' => 'Predis\Command\HashKeys', - 'hvals' => 'Predis\Command\HashValues', - 'hgetall' => 'Predis\Command\HashGetAll', - - /* transactions */ - 'multi' => 'Predis\Command\TransactionMulti', - 'exec' => 'Predis\Command\TransactionExec', - 'discard' => 'Predis\Command\TransactionDiscard', - - /* publish - subscribe */ - 'subscribe' => 'Predis\Command\PubSubSubscribe', - 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', - 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', - 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', - 'publish' => 'Predis\Command\PubSubPublish', - - /* remote server control commands */ - 'config' => 'Predis\Command\ServerConfig', - - /* ---------------- Redis 2.2 ---------------- */ - - /* commands operating on the key space */ - 'persist' => 'Predis\Command\KeyPersist', - - /* commands operating on string values */ - 'strlen' => 'Predis\Command\StringStrlen', - 'setrange' => 'Predis\Command\StringSetRange', - 'getrange' => 'Predis\Command\StringGetRange', - 'setbit' => 'Predis\Command\StringSetBit', - 'getbit' => 'Predis\Command\StringGetBit', - - /* commands operating on lists */ - 'rpushx' => 'Predis\Command\ListPushTailX', - 'lpushx' => 'Predis\Command\ListPushHeadX', - 'linsert' => 'Predis\Command\ListInsert', - 'brpoplpush' => 'Predis\Command\ListPopLastPushHeadBlocking', - - /* commands operating on sorted sets */ - 'zrevrangebyscore' => 'Predis\Command\ZSetReverseRangeByScore', - - /* transactions */ - 'watch' => 'Predis\Command\TransactionWatch', - 'unwatch' => 'Predis\Command\TransactionUnwatch', - - /* remote server control commands */ - 'object' => 'Predis\Command\ServerObject', - 'slowlog' => 'Predis\Command\ServerSlowlog', - - /* ---------------- Redis 2.4 ---------------- */ - - /* remote server control commands */ - 'client' => 'Predis\Command\ServerClient', - - /* ---------------- Redis 2.6 ---------------- */ - - /* commands operating on the key space */ - 'pttl' => 'Predis\Command\KeyPreciseTimeToLive', - 'pexpire' => 'Predis\Command\KeyPreciseExpire', - 'pexpireat' => 'Predis\Command\KeyPreciseExpireAt', - - /* commands operating on string values */ - 'psetex' => 'Predis\Command\StringPreciseSetExpire', - 'incrbyfloat' => 'Predis\Command\StringIncrementByFloat', - 'bitop' => 'Predis\Command\StringBitOp', - 'bitcount' => 'Predis\Command\StringBitCount', - - /* commands operating on hashes */ - 'hincrbyfloat' => 'Predis\Command\HashIncrementByFloat', - - /* scripting */ - 'eval' => 'Predis\Command\ServerEval', - 'evalsha' => 'Predis\Command\ServerEvalSHA', - 'script' => 'Predis\Command\ServerScript', - - /* remote server control commands */ - 'time' => 'Predis\Command\ServerTime', - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersion28.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersion28.php deleted file mode 100644 index df4598bb9..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerVersion28.php +++ /dev/null @@ -1,247 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * Server profile for Redis v2.8.x. - * - * @author Daniele Alessandri - */ -class ServerVersion28 extends ServerProfile -{ - /** - * {@inheritdoc} - */ - public function getVersion() - { - return '2.8'; - } - - /** - * {@inheritdoc} - */ - public function getSupportedCommands() - { - return array( - /* ---------------- Redis 1.2 ---------------- */ - - /* commands operating on the key space */ - 'exists' => 'Predis\Command\KeyExists', - 'del' => 'Predis\Command\KeyDelete', - 'type' => 'Predis\Command\KeyType', - 'keys' => 'Predis\Command\KeyKeys', - 'randomkey' => 'Predis\Command\KeyRandom', - 'rename' => 'Predis\Command\KeyRename', - 'renamenx' => 'Predis\Command\KeyRenamePreserve', - 'expire' => 'Predis\Command\KeyExpire', - 'expireat' => 'Predis\Command\KeyExpireAt', - 'ttl' => 'Predis\Command\KeyTimeToLive', - 'move' => 'Predis\Command\KeyMove', - 'sort' => 'Predis\Command\KeySort', - 'dump' => 'Predis\Command\KeyDump', - 'restore' => 'Predis\Command\KeyRestore', - - /* commands operating on string values */ - 'set' => 'Predis\Command\StringSet', - 'setnx' => 'Predis\Command\StringSetPreserve', - 'mset' => 'Predis\Command\StringSetMultiple', - 'msetnx' => 'Predis\Command\StringSetMultiplePreserve', - 'get' => 'Predis\Command\StringGet', - 'mget' => 'Predis\Command\StringGetMultiple', - 'getset' => 'Predis\Command\StringGetSet', - 'incr' => 'Predis\Command\StringIncrement', - 'incrby' => 'Predis\Command\StringIncrementBy', - 'decr' => 'Predis\Command\StringDecrement', - 'decrby' => 'Predis\Command\StringDecrementBy', - - /* commands operating on lists */ - 'rpush' => 'Predis\Command\ListPushTail', - 'lpush' => 'Predis\Command\ListPushHead', - 'llen' => 'Predis\Command\ListLength', - 'lrange' => 'Predis\Command\ListRange', - 'ltrim' => 'Predis\Command\ListTrim', - 'lindex' => 'Predis\Command\ListIndex', - 'lset' => 'Predis\Command\ListSet', - 'lrem' => 'Predis\Command\ListRemove', - 'lpop' => 'Predis\Command\ListPopFirst', - 'rpop' => 'Predis\Command\ListPopLast', - 'rpoplpush' => 'Predis\Command\ListPopLastPushHead', - - /* commands operating on sets */ - 'sadd' => 'Predis\Command\SetAdd', - 'srem' => 'Predis\Command\SetRemove', - 'spop' => 'Predis\Command\SetPop', - 'smove' => 'Predis\Command\SetMove', - 'scard' => 'Predis\Command\SetCardinality', - 'sismember' => 'Predis\Command\SetIsMember', - 'sinter' => 'Predis\Command\SetIntersection', - 'sinterstore' => 'Predis\Command\SetIntersectionStore', - 'sunion' => 'Predis\Command\SetUnion', - 'sunionstore' => 'Predis\Command\SetUnionStore', - 'sdiff' => 'Predis\Command\SetDifference', - 'sdiffstore' => 'Predis\Command\SetDifferenceStore', - 'smembers' => 'Predis\Command\SetMembers', - 'srandmember' => 'Predis\Command\SetRandomMember', - - /* commands operating on sorted sets */ - 'zadd' => 'Predis\Command\ZSetAdd', - 'zincrby' => 'Predis\Command\ZSetIncrementBy', - 'zrem' => 'Predis\Command\ZSetRemove', - 'zrange' => 'Predis\Command\ZSetRange', - 'zrevrange' => 'Predis\Command\ZSetReverseRange', - 'zrangebyscore' => 'Predis\Command\ZSetRangeByScore', - 'zcard' => 'Predis\Command\ZSetCardinality', - 'zscore' => 'Predis\Command\ZSetScore', - 'zremrangebyscore' => 'Predis\Command\ZSetRemoveRangeByScore', - - /* connection related commands */ - 'ping' => 'Predis\Command\ConnectionPing', - 'auth' => 'Predis\Command\ConnectionAuth', - 'select' => 'Predis\Command\ConnectionSelect', - 'echo' => 'Predis\Command\ConnectionEcho', - 'quit' => 'Predis\Command\ConnectionQuit', - - /* remote server control commands */ - 'info' => 'Predis\Command\ServerInfoV26x', - 'slaveof' => 'Predis\Command\ServerSlaveOf', - 'monitor' => 'Predis\Command\ServerMonitor', - 'dbsize' => 'Predis\Command\ServerDatabaseSize', - 'flushdb' => 'Predis\Command\ServerFlushDatabase', - 'flushall' => 'Predis\Command\ServerFlushAll', - 'save' => 'Predis\Command\ServerSave', - 'bgsave' => 'Predis\Command\ServerBackgroundSave', - 'lastsave' => 'Predis\Command\ServerLastSave', - 'shutdown' => 'Predis\Command\ServerShutdown', - 'bgrewriteaof' => 'Predis\Command\ServerBackgroundRewriteAOF', - - /* ---------------- Redis 2.0 ---------------- */ - - /* commands operating on string values */ - 'setex' => 'Predis\Command\StringSetExpire', - 'append' => 'Predis\Command\StringAppend', - 'substr' => 'Predis\Command\StringSubstr', - - /* commands operating on lists */ - 'blpop' => 'Predis\Command\ListPopFirstBlocking', - 'brpop' => 'Predis\Command\ListPopLastBlocking', - - /* commands operating on sorted sets */ - 'zunionstore' => 'Predis\Command\ZSetUnionStore', - 'zinterstore' => 'Predis\Command\ZSetIntersectionStore', - 'zcount' => 'Predis\Command\ZSetCount', - 'zrank' => 'Predis\Command\ZSetRank', - 'zrevrank' => 'Predis\Command\ZSetReverseRank', - 'zremrangebyrank' => 'Predis\Command\ZSetRemoveRangeByRank', - - /* commands operating on hashes */ - 'hset' => 'Predis\Command\HashSet', - 'hsetnx' => 'Predis\Command\HashSetPreserve', - 'hmset' => 'Predis\Command\HashSetMultiple', - 'hincrby' => 'Predis\Command\HashIncrementBy', - 'hget' => 'Predis\Command\HashGet', - 'hmget' => 'Predis\Command\HashGetMultiple', - 'hdel' => 'Predis\Command\HashDelete', - 'hexists' => 'Predis\Command\HashExists', - 'hlen' => 'Predis\Command\HashLength', - 'hkeys' => 'Predis\Command\HashKeys', - 'hvals' => 'Predis\Command\HashValues', - 'hgetall' => 'Predis\Command\HashGetAll', - - /* transactions */ - 'multi' => 'Predis\Command\TransactionMulti', - 'exec' => 'Predis\Command\TransactionExec', - 'discard' => 'Predis\Command\TransactionDiscard', - - /* publish - subscribe */ - 'subscribe' => 'Predis\Command\PubSubSubscribe', - 'unsubscribe' => 'Predis\Command\PubSubUnsubscribe', - 'psubscribe' => 'Predis\Command\PubSubSubscribeByPattern', - 'punsubscribe' => 'Predis\Command\PubSubUnsubscribeByPattern', - 'publish' => 'Predis\Command\PubSubPublish', - - /* remote server control commands */ - 'config' => 'Predis\Command\ServerConfig', - - /* ---------------- Redis 2.2 ---------------- */ - - /* commands operating on the key space */ - 'persist' => 'Predis\Command\KeyPersist', - - /* commands operating on string values */ - 'strlen' => 'Predis\Command\StringStrlen', - 'setrange' => 'Predis\Command\StringSetRange', - 'getrange' => 'Predis\Command\StringGetRange', - 'setbit' => 'Predis\Command\StringSetBit', - 'getbit' => 'Predis\Command\StringGetBit', - - /* commands operating on lists */ - 'rpushx' => 'Predis\Command\ListPushTailX', - 'lpushx' => 'Predis\Command\ListPushHeadX', - 'linsert' => 'Predis\Command\ListInsert', - 'brpoplpush' => 'Predis\Command\ListPopLastPushHeadBlocking', - - /* commands operating on sorted sets */ - 'zrevrangebyscore' => 'Predis\Command\ZSetReverseRangeByScore', - - /* transactions */ - 'watch' => 'Predis\Command\TransactionWatch', - 'unwatch' => 'Predis\Command\TransactionUnwatch', - - /* remote server control commands */ - 'object' => 'Predis\Command\ServerObject', - 'slowlog' => 'Predis\Command\ServerSlowlog', - - /* ---------------- Redis 2.4 ---------------- */ - - /* remote server control commands */ - 'client' => 'Predis\Command\ServerClient', - - /* ---------------- Redis 2.6 ---------------- */ - - /* commands operating on the key space */ - 'pttl' => 'Predis\Command\KeyPreciseTimeToLive', - 'pexpire' => 'Predis\Command\KeyPreciseExpire', - 'pexpireat' => 'Predis\Command\KeyPreciseExpireAt', - - /* commands operating on string values */ - 'psetex' => 'Predis\Command\StringPreciseSetExpire', - 'incrbyfloat' => 'Predis\Command\StringIncrementByFloat', - 'bitop' => 'Predis\Command\StringBitOp', - 'bitcount' => 'Predis\Command\StringBitCount', - - /* commands operating on hashes */ - 'hincrbyfloat' => 'Predis\Command\HashIncrementByFloat', - - /* scripting */ - 'eval' => 'Predis\Command\ServerEval', - 'evalsha' => 'Predis\Command\ServerEvalSHA', - 'script' => 'Predis\Command\ServerScript', - - /* remote server control commands */ - 'time' => 'Predis\Command\ServerTime', - - /* ---------------- Redis 2.8 ---------------- */ - - /* commands operating on the key space */ - 'scan' => 'Predis\Command\KeyScan', - - /* commands operating on sets */ - 'sscan' => 'Predis\Command\SetScan', - - /* commands operating on sorted sets */ - 'zscan' => 'Predis\Command\ZSetScan', - - /* commands operating on hashes */ - 'hscan' => 'Predis\Command\HashScan', - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/Profile/ServerVersionNext.php b/vendor/predis/predis/lib/Predis/Profile/ServerVersionNext.php deleted file mode 100644 index e98c35490..000000000 --- a/vendor/predis/predis/lib/Predis/Profile/ServerVersionNext.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * Server profile for the current unstable version of Redis. - * - * @author Daniele Alessandri - */ -class ServerVersionNext extends ServerVersion28 -{ - /** - * {@inheritdoc} - */ - public function getVersion() - { - return '3.0'; - } - - /** - * {@inheritdoc} - */ - public function getSupportedCommands() - { - return array_merge(parent::getSupportedCommands(), array()); - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/CommandSerializerInterface.php b/vendor/predis/predis/lib/Predis/Protocol/CommandSerializerInterface.php deleted file mode 100644 index f57f1ad6c..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/CommandSerializerInterface.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol; - -use Predis\Command\CommandInterface; - -/** - * Interface that defines a custom serializer for Redis commands. - * - * @author Daniele Alessandri - */ -interface CommandSerializerInterface -{ - /** - * Serializes a Redis command. - * - * @param CommandInterface $command Redis command. - * @return string - */ - public function serialize(CommandInterface $command); -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ComposableProtocolInterface.php b/vendor/predis/predis/lib/Predis/Protocol/ComposableProtocolInterface.php deleted file mode 100644 index 56990a0e0..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/ComposableProtocolInterface.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol; - -/** - * Interface that defines a customizable protocol processor that serializes - * Redis commands and parses replies returned by the server to PHP objects - * using a pluggable set of classes defining the underlying wire protocol. - * - * @author Daniele Alessandri - */ -interface ComposableProtocolInterface extends ProtocolInterface -{ - /** - * Sets the command serializer to be used by the protocol processor. - * - * @param CommandSerializerInterface $serializer Command serializer. - */ - public function setSerializer(CommandSerializerInterface $serializer); - - /** - * Returns the command serializer used by the protocol processor. - * - * @return CommandSerializerInterface - */ - public function getSerializer(); - - /** - * Sets the response reader to be used by the protocol processor. - * - * @param ResponseReaderInterface $reader Response reader. - */ - public function setReader(ResponseReaderInterface $reader); - - /** - * Returns the response reader used by the protocol processor. - * - * @return ResponseReaderInterface - */ - public function getReader(); -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ProtocolException.php b/vendor/predis/predis/lib/Predis/Protocol/ProtocolException.php deleted file mode 100644 index 65390219c..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/ProtocolException.php +++ /dev/null @@ -1,24 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol; - -use Predis\CommunicationException; - -/** - * Exception class that identifies errors encountered while - * handling the Redis wire protocol. - * - * @author Daniele Alessandri - */ -class ProtocolException extends CommunicationException -{ -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ProtocolInterface.php b/vendor/predis/predis/lib/Predis/Protocol/ProtocolInterface.php deleted file mode 100644 index cebe0e546..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/ProtocolInterface.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol; - -use Predis\Command\CommandInterface; -use Predis\Connection\ComposableConnectionInterface; - -/** - * Interface that defines a protocol processor that serializes Redis commands - * and parses replies returned by the server to PHP objects. - * - * @author Daniele Alessandri - */ -interface ProtocolInterface extends ResponseReaderInterface -{ - /** - * Writes a Redis command on the specified connection. - * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param CommandInterface $command Redis command. - */ - public function write(ComposableConnectionInterface $connection, CommandInterface $command); - - /** - * Sets the options for the protocol processor. - * - * @param string $option Name of the option. - * @param mixed $value Value of the option. - */ - public function setOption($option, $value); -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ResponseHandlerInterface.php b/vendor/predis/predis/lib/Predis/Protocol/ResponseHandlerInterface.php deleted file mode 100644 index 7900fe652..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/ResponseHandlerInterface.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol; - -use Predis\Connection\ComposableConnectionInterface; - -/** - * Interface that defines an handler able to parse a reply. - * - * @author Daniele Alessandri - */ -interface ResponseHandlerInterface -{ - /** - * Parses a type of reply returned by Redis and reads more data from the - * connection if needed. - * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $payload Initial payload of the reply. - * @return mixed - */ - public function handle(ComposableConnectionInterface $connection, $payload); -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/ResponseReaderInterface.php b/vendor/predis/predis/lib/Predis/Protocol/ResponseReaderInterface.php deleted file mode 100644 index a89cb750b..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/ResponseReaderInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol; - -use Predis\Connection\ComposableConnectionInterface; - -/** - * Interface that defines a response reader able to parse replies returned by - * Redis and deserialize them to PHP objects. - * - * @author Daniele Alessandri - */ -interface ResponseReaderInterface -{ - /** - * Reads replies from a connection to Redis and deserializes them. - * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @return mixed - */ - public function read(ComposableConnectionInterface $connection); -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ComposableTextProtocol.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ComposableTextProtocol.php deleted file mode 100644 index 142999062..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/ComposableTextProtocol.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\Command\CommandInterface; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Protocol\ResponseReaderInterface; -use Predis\Protocol\CommandSerializerInterface; -use Predis\Protocol\ComposableProtocolInterface; - -/** - * Implements a customizable protocol processor that uses the standard Redis - * wire protocol to serialize Redis commands and parse replies returned by - * the server using a pluggable set of classes. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class ComposableTextProtocol implements ComposableProtocolInterface -{ - private $serializer; - private $reader; - - /** - * @param array $options Set of options used to initialize the protocol processor. - */ - public function __construct(Array $options = array()) - { - $this->setSerializer(new TextCommandSerializer()); - $this->setReader(new TextResponseReader()); - - if (count($options) > 0) { - $this->initializeOptions($options); - } - } - - /** - * Initializes the protocol processor using a set of options. - * - * @param array $options Set of options. - */ - private function initializeOptions(Array $options) - { - foreach ($options as $k => $v) { - $this->setOption($k, $v); - } - } - - /** - * {@inheritdoc} - */ - public function setOption($option, $value) - { - switch ($option) { - case 'iterable_multibulk': - $handler = $value ? new ResponseMultiBulkStreamHandler() : new ResponseMultiBulkHandler(); - $this->reader->setHandler(TextProtocol::PREFIX_MULTI_BULK, $handler); - break; - - default: - throw new \InvalidArgumentException("The option $option is not supported by the current protocol"); - } - } - - /** - * {@inheritdoc} - */ - public function serialize(CommandInterface $command) - { - return $this->serializer->serialize($command); - } - - /** - * {@inheritdoc} - */ - public function write(ComposableConnectionInterface $connection, CommandInterface $command) - { - $connection->writeBytes($this->serializer->serialize($command)); - } - - /** - * {@inheritdoc} - */ - public function read(ComposableConnectionInterface $connection) - { - return $this->reader->read($connection); - } - - /** - * {@inheritdoc} - */ - public function setSerializer(CommandSerializerInterface $serializer) - { - $this->serializer = $serializer; - } - - /** - * {@inheritdoc} - */ - public function getSerializer() - { - return $this->serializer; - } - - /** - * {@inheritdoc} - */ - public function setReader(ResponseReaderInterface $reader) - { - $this->reader = $reader; - } - - /** - * {@inheritdoc} - */ - public function getReader() - { - return $this->reader; - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseBulkHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseBulkHandler.php deleted file mode 100644 index 29792cc7d..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseBulkHandler.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Protocol\ProtocolException; -use Predis\Protocol\ResponseHandlerInterface; - -/** - * Implements a response handler for bulk replies using the standard wire - * protocol defined by Redis. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class ResponseBulkHandler implements ResponseHandlerInterface -{ - /** - * Handles a bulk reply returned by Redis. - * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $lengthString Bytes size of the bulk reply. - * @return string - */ - public function handle(ComposableConnectionInterface $connection, $lengthString) - { - $length = (int) $lengthString; - - if ("$length" !== $lengthString) { - CommunicationException::handle(new ProtocolException( - $connection, "Cannot parse '$lengthString' as bulk length" - )); - } - - if ($length >= 0) { - return substr($connection->readBytes($length + 2), 0, -2); - } - - if ($length == -1) { - return null; - } - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseErrorHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseErrorHandler.php deleted file mode 100644 index a1e27d334..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseErrorHandler.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\ResponseError; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Protocol\ResponseHandlerInterface; - -/** - * Implements a response handler for error replies using the standard wire - * protocol defined by Redis. - * - * This handler returns a reply object to notify the user that an error has - * occurred on the server. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class ResponseErrorHandler implements ResponseHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(ComposableConnectionInterface $connection, $errorMessage) - { - return new ResponseError($errorMessage); - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseIntegerHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseIntegerHandler.php deleted file mode 100644 index 866a25f11..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseIntegerHandler.php +++ /dev/null @@ -1,49 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Protocol\ProtocolException; -use Predis\Protocol\ResponseHandlerInterface; - -/** - * Implements a response handler for integer replies using the standard wire - * protocol defined by Redis. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class ResponseIntegerHandler implements ResponseHandlerInterface -{ - /** - * Handles an integer reply returned by Redis. - * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $number String representation of an integer. - * @return int - */ - public function handle(ComposableConnectionInterface $connection, $number) - { - if (is_numeric($number)) { - return (int) $number; - } - - if ($number !== 'nil') { - CommunicationException::handle(new ProtocolException( - $connection, "Cannot parse '$number' as numeric response" - )); - } - - return null; - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php deleted file mode 100644 index 06bffad27..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkHandler.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Protocol\ProtocolException; -use Predis\Protocol\ResponseHandlerInterface; - -/** - * Implements a response handler for multi-bulk replies using the standard - * wire protocol defined by Redis. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class ResponseMultiBulkHandler implements ResponseHandlerInterface -{ - /** - * Handles a multi-bulk reply returned by Redis. - * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $lengthString Number of items in the multi-bulk reply. - * @return array - */ - public function handle(ComposableConnectionInterface $connection, $lengthString) - { - $length = (int) $lengthString; - - if ("$length" !== $lengthString) { - CommunicationException::handle(new ProtocolException( - $connection, "Cannot parse '$lengthString' as multi-bulk length" - )); - } - - if ($length === -1) { - return null; - } - - $list = array(); - - if ($length > 0) { - $handlersCache = array(); - $reader = $connection->getProtocol()->getReader(); - - for ($i = 0; $i < $length; $i++) { - $header = $connection->readLine(); - $prefix = $header[0]; - - if (isset($handlersCache[$prefix])) { - $handler = $handlersCache[$prefix]; - } else { - $handler = $reader->getHandler($prefix); - $handlersCache[$prefix] = $handler; - } - - $list[$i] = $handler->handle($connection, substr($header, 1)); - } - } - - return $list; - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php deleted file mode 100644 index bed3eda93..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseMultiBulkStreamHandler.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Iterator\MultiBulkResponseSimple; -use Predis\Protocol\ProtocolException; -use Predis\Protocol\ResponseHandlerInterface; - -/** - * Implements a response handler for iterable multi-bulk replies using the - * standard wire protocol defined by Redis. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class ResponseMultiBulkStreamHandler implements ResponseHandlerInterface -{ - /** - * Handles a multi-bulk reply returned by Redis in a streamable fashion. - * - * @param ComposableConnectionInterface $connection Connection to Redis. - * @param string $lengthString Number of items in the multi-bulk reply. - * @return MultiBulkResponseSimple - */ - public function handle(ComposableConnectionInterface $connection, $lengthString) - { - $length = (int) $lengthString; - - if ("$length" != $lengthString) { - CommunicationException::handle(new ProtocolException( - $connection, "Cannot parse '$lengthString' as multi-bulk length" - )); - } - - return new MultiBulkResponseSimple($connection, $length); - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseStatusHandler.php b/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseStatusHandler.php deleted file mode 100644 index 978996a32..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/ResponseStatusHandler.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\ResponseQueued; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Protocol\ResponseHandlerInterface; - -/** - * Implements a response handler for status replies using the standard wire - * protocol defined by Redis. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class ResponseStatusHandler implements ResponseHandlerInterface -{ - /** - * {@inheritdoc} - */ - public function handle(ComposableConnectionInterface $connection, $status) - { - switch ($status) { - case 'OK': - return true; - - case 'QUEUED': - return new ResponseQueued(); - - default: - return $status; - } - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/TextCommandSerializer.php b/vendor/predis/predis/lib/Predis/Protocol/Text/TextCommandSerializer.php deleted file mode 100644 index faa27c058..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/TextCommandSerializer.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\Command\CommandInterface; -use Predis\Protocol\CommandSerializerInterface; - -/** - * Implements a pluggable command serializer using the standard wire protocol - * defined by Redis. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class TextCommandSerializer implements CommandSerializerInterface -{ - /** - * {@inheritdoc} - */ - public function serialize(CommandInterface $command) - { - $commandId = $command->getId(); - $arguments = $command->getArguments(); - - $cmdlen = strlen($commandId); - $reqlen = count($arguments) + 1; - - $buffer = "*{$reqlen}\r\n\${$cmdlen}\r\n{$commandId}\r\n"; - - for ($i = 0, $reqlen--; $i < $reqlen; $i++) { - $argument = $arguments[$i]; - $arglen = strlen($argument); - $buffer .= "\${$arglen}\r\n{$argument}\r\n"; - } - - return $buffer; - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/TextProtocol.php b/vendor/predis/predis/lib/Predis/Protocol/Text/TextProtocol.php deleted file mode 100644 index eef07044e..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/TextProtocol.php +++ /dev/null @@ -1,137 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\CommunicationException; -use Predis\ResponseError; -use Predis\ResponseQueued; -use Predis\Command\CommandInterface; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Iterator\MultiBulkResponseSimple; -use Predis\Protocol\ProtocolException; -use Predis\Protocol\ProtocolInterface; - -/** - * Implements a protocol processor for the standard wire protocol defined by Redis. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class TextProtocol implements ProtocolInterface -{ - const NEWLINE = "\r\n"; - const OK = 'OK'; - const ERROR = 'ERR'; - const QUEUED = 'QUEUED'; - const NULL = 'nil'; - - const PREFIX_STATUS = '+'; - const PREFIX_ERROR = '-'; - const PREFIX_INTEGER = ':'; - const PREFIX_BULK = '$'; - const PREFIX_MULTI_BULK = '*'; - - const BUFFER_SIZE = 4096; - - private $mbiterable; - private $serializer; - - /** - * - */ - public function __construct() - { - $this->mbiterable = false; - $this->serializer = new TextCommandSerializer(); - } - - /** - * {@inheritdoc} - */ - public function write(ComposableConnectionInterface $connection, CommandInterface $command) - { - $connection->writeBytes($this->serializer->serialize($command)); - } - - /** - * {@inheritdoc} - */ - public function read(ComposableConnectionInterface $connection) - { - $chunk = $connection->readLine(); - $prefix = $chunk[0]; - $payload = substr($chunk, 1); - - switch ($prefix) { - case '+': - switch ($payload) { - case 'OK': - return true; - - case 'QUEUED': - return new ResponseQueued(); - - default: - return $payload; - } - - case '$': - $size = (int) $payload; - if ($size === -1) { - return null; - } - - return substr($connection->readBytes($size + 2), 0, -2); - - case '*': - $count = (int) $payload; - - if ($count === -1) { - return null; - } - if ($this->mbiterable) { - return new MultiBulkResponseSimple($connection, $count); - } - - $multibulk = array(); - - for ($i = 0; $i < $count; $i++) { - $multibulk[$i] = $this->read($connection); - } - - return $multibulk; - - case ':': - return (int) $payload; - - case '-': - return new ResponseError($payload); - - default: - CommunicationException::handle(new ProtocolException( - $connection, "Unknown prefix: '$prefix'" - )); - } - } - - /** - * {@inheritdoc} - */ - public function setOption($option, $value) - { - switch ($option) { - case 'iterable_multibulk': - $this->mbiterable = (bool) $value; - break; - } - } -} diff --git a/vendor/predis/predis/lib/Predis/Protocol/Text/TextResponseReader.php b/vendor/predis/predis/lib/Predis/Protocol/Text/TextResponseReader.php deleted file mode 100644 index ab02f3aa8..000000000 --- a/vendor/predis/predis/lib/Predis/Protocol/Text/TextResponseReader.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use Predis\CommunicationException; -use Predis\Connection\ComposableConnectionInterface; -use Predis\Protocol\ProtocolException; -use Predis\Protocol\ResponseHandlerInterface; -use Predis\Protocol\ResponseReaderInterface; - -/** - * Implements a pluggable response reader using the standard wire protocol - * defined by Redis. - * - * @link http://redis.io/topics/protocol - * @author Daniele Alessandri - */ -class TextResponseReader implements ResponseReaderInterface -{ - private $handlers; - - /** - * - */ - public function __construct() - { - $this->handlers = $this->getDefaultHandlers(); - } - - /** - * Returns the default set of response handlers for all the type of replies - * that can be returned by Redis. - */ - private function getDefaultHandlers() - { - return array( - TextProtocol::PREFIX_STATUS => new ResponseStatusHandler(), - TextProtocol::PREFIX_ERROR => new ResponseErrorHandler(), - TextProtocol::PREFIX_INTEGER => new ResponseIntegerHandler(), - TextProtocol::PREFIX_BULK => new ResponseBulkHandler(), - TextProtocol::PREFIX_MULTI_BULK => new ResponseMultiBulkHandler(), - ); - } - - /** - * Sets a response handler for a certain prefix that identifies a type of - * reply that can be returned by Redis. - * - * @param string $prefix Identifier for a type of reply. - * @param ResponseHandlerInterface $handler Response handler for the reply. - */ - public function setHandler($prefix, ResponseHandlerInterface $handler) - { - $this->handlers[$prefix] = $handler; - } - - /** - * Returns the response handler associated to a certain type of reply that - * can be returned by Redis. - * - * @param string $prefix Identifier for a type of reply. - * @return ResponseHandlerInterface - */ - public function getHandler($prefix) - { - if (isset($this->handlers[$prefix])) { - return $this->handlers[$prefix]; - } - } - - /** - * {@inheritdoc} - */ - public function read(ComposableConnectionInterface $connection) - { - $header = $connection->readLine(); - - if ($header === '') { - $this->protocolError($connection, 'Unexpected empty header'); - } - - $prefix = $header[0]; - - if (!isset($this->handlers[$prefix])) { - $this->protocolError($connection, "Unknown prefix: '$prefix'"); - } - - $handler = $this->handlers[$prefix]; - - return $handler->handle($connection, substr($header, 1)); - } - - /** - * Helper method used to handle a protocol error generated while reading a - * reply from a connection to Redis. - * - * @param ComposableConnectionInterface $connection Connection to Redis that generated the error. - * @param string $message Error message. - */ - private function protocolError(ComposableConnectionInterface $connection, $message) - { - CommunicationException::handle(new ProtocolException($connection, $message)); - } -} diff --git a/vendor/predis/predis/lib/Predis/PubSub/AbstractPubSubContext.php b/vendor/predis/predis/lib/Predis/PubSub/AbstractPubSubContext.php deleted file mode 100644 index d1e83deec..000000000 --- a/vendor/predis/predis/lib/Predis/PubSub/AbstractPubSubContext.php +++ /dev/null @@ -1,206 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\PubSub; - -/** - * Client-side abstraction of a Publish / Subscribe context. - * - * @author Daniele Alessandri - */ -abstract class AbstractPubSubContext implements \Iterator -{ - const SUBSCRIBE = 'subscribe'; - const UNSUBSCRIBE = 'unsubscribe'; - const PSUBSCRIBE = 'psubscribe'; - const PUNSUBSCRIBE = 'punsubscribe'; - const MESSAGE = 'message'; - const PMESSAGE = 'pmessage'; - - const STATUS_VALID = 1; // 0b0001 - const STATUS_SUBSCRIBED = 2; // 0b0010 - const STATUS_PSUBSCRIBED = 4; // 0b0100 - - private $position = null; - private $statusFlags = self::STATUS_VALID; - - /** - * Automatically closes the context when PHP's garbage collector kicks in. - */ - public function __destruct() - { - $this->closeContext(true); - } - - /** - * Checks if the specified flag is valid in the state of the context. - * - * @param int $value Flag. - * @return bool - */ - protected function isFlagSet($value) - { - return ($this->statusFlags & $value) === $value; - } - - /** - * Subscribes to the specified channels. - * - * @param mixed $channel,... One or more channel names. - */ - public function subscribe($channel /*, ... */) - { - $this->writeCommand(self::SUBSCRIBE, func_get_args()); - $this->statusFlags |= self::STATUS_SUBSCRIBED; - } - - /** - * Unsubscribes from the specified channels. - * - * @param string ... One or more channel names. - */ - public function unsubscribe(/* ... */) - { - $this->writeCommand(self::UNSUBSCRIBE, func_get_args()); - } - - /** - * Subscribes to the specified channels using a pattern. - * - * @param mixed $pattern,... One or more channel name patterns. - */ - public function psubscribe($pattern /* ... */) - { - $this->writeCommand(self::PSUBSCRIBE, func_get_args()); - $this->statusFlags |= self::STATUS_PSUBSCRIBED; - } - - /** - * Unsubscribes from the specified channels using a pattern. - * - * @param string ... One or more channel name patterns. - */ - public function punsubscribe(/* ... */) - { - $this->writeCommand(self::PUNSUBSCRIBE, func_get_args()); - } - - /** - * Closes the context by unsubscribing from all the subscribed channels. - * Optionally, the context can be forcefully closed by dropping the - * underlying connection. - * - * @param bool $force Forcefully close the context by closing the connection. - * @return bool Returns false if there are no pending messages. - */ - public function closeContext($force = false) - { - if (!$this->valid()) { - return false; - } - - if ($force) { - $this->invalidate(); - $this->disconnect(); - } else { - if ($this->isFlagSet(self::STATUS_SUBSCRIBED)) { - $this->unsubscribe(); - } - if ($this->isFlagSet(self::STATUS_PSUBSCRIBED)) { - $this->punsubscribe(); - } - } - - return !$force; - } - - /** - * Closes the underlying connection on forced disconnection. - */ - abstract protected function disconnect(); - - /** - * Writes a Redis command on the underlying connection. - * - * @param string $method ID of the command. - * @param array $arguments List of arguments. - */ - abstract protected function writeCommand($method, $arguments); - - /** - * {@inheritdoc} - */ - public function rewind() - { - // NOOP - } - - /** - * Returns the last message payload retrieved from the server and generated - * by one of the active subscriptions. - * - * @return array - */ - public function current() - { - return $this->getValue(); - } - - /** - * {@inheritdoc} - */ - public function key() - { - return $this->position; - } - - /** - * {@inheritdoc} - */ - public function next() - { - if ($this->valid()) { - $this->position++; - } - - return $this->position; - } - - /** - * Checks if the the context is still in a valid state to continue. - * - * @return bool - */ - public function valid() - { - $isValid = $this->isFlagSet(self::STATUS_VALID); - $subscriptionFlags = self::STATUS_SUBSCRIBED | self::STATUS_PSUBSCRIBED; - $hasSubscriptions = ($this->statusFlags & $subscriptionFlags) > 0; - - return $isValid && $hasSubscriptions; - } - - /** - * Resets the state of the context. - */ - protected function invalidate() - { - $this->statusFlags = 0; // 0b0000; - } - - /** - * Waits for a new message from the server generated by one of the active - * subscriptions and returns it when available. - * - * @return array - */ - abstract protected function getValue(); -} diff --git a/vendor/predis/predis/lib/Predis/PubSub/DispatcherLoop.php b/vendor/predis/predis/lib/Predis/PubSub/DispatcherLoop.php deleted file mode 100644 index c35b70758..000000000 --- a/vendor/predis/predis/lib/Predis/PubSub/DispatcherLoop.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\PubSub; - -use Predis\ClientInterface; - -/** - * Method-dispatcher loop built around the client-side abstraction of a Redis - * Publish / Subscribe context. - * - * @author Daniele Alessandri - */ -class DispatcherLoop -{ - private $pubSubContext; - - protected $callbacks; - protected $defaultCallback; - protected $subscriptionCallback; - - /** - * @param ClientInterface $client Client instance used by the context. - */ - public function __construct(ClientInterface $client) - { - $this->callbacks = array(); - $this->pubSubContext = $client->pubSubLoop(); - } - - /** - * Checks if the passed argument is a valid callback. - * - * @param mixed $callable A callback. - */ - protected function validateCallback($callable) - { - if (!is_callable($callable)) { - throw new \InvalidArgumentException("A valid callable object must be provided"); - } - } - - /** - * Returns the underlying Publish / Subscribe context. - * - * @return PubSubContext - */ - public function getPubSubContext() - { - return $this->pubSubContext; - } - - /** - * Sets a callback that gets invoked upon new subscriptions. - * - * @param mixed $callable A callback. - */ - public function subscriptionCallback($callable = null) - { - if (isset($callable)) { - $this->validateCallback($callable); - } - - $this->subscriptionCallback = $callable; - } - - /** - * Sets a callback that gets invoked when a message is received on a - * channel that does not have an associated callback. - * - * @param mixed $callable A callback. - */ - public function defaultCallback($callable = null) - { - if (isset($callable)) { - $this->validateCallback($callable); - } - - $this->subscriptionCallback = $callable; - } - - /** - * Binds a callback to a channel. - * - * @param string $channel Channel name. - * @param Callable $callback A callback. - */ - public function attachCallback($channel, $callback) - { - $callbackName = $this->getPrefixKeys() . $channel; - - $this->validateCallback($callback); - $this->callbacks[$callbackName] = $callback; - $this->pubSubContext->subscribe($channel); - } - - /** - * Stops listening to a channel and removes the associated callback. - * - * @param string $channel Redis channel. - */ - public function detachCallback($channel) - { - $callbackName = $this->getPrefixKeys() . $channel; - - if (isset($this->callbacks[$callbackName])) { - unset($this->callbacks[$callbackName]); - $this->pubSubContext->unsubscribe($channel); - } - } - - /** - * Starts the dispatcher loop. - */ - public function run() - { - foreach ($this->pubSubContext as $message) { - $kind = $message->kind; - - if ($kind !== PubSubContext::MESSAGE && $kind !== PubSubContext::PMESSAGE) { - if (isset($this->subscriptionCallback)) { - $callback = $this->subscriptionCallback; - call_user_func($callback, $message); - } - - continue; - } - - if (isset($this->callbacks[$message->channel])) { - $callback = $this->callbacks[$message->channel]; - call_user_func($callback, $message->payload); - } elseif (isset($this->defaultCallback)) { - $callback = $this->defaultCallback; - call_user_func($callback, $message); - } - } - } - - /** - * Terminates the dispatcher loop. - */ - public function stop() - { - $this->pubSubContext->closeContext(); - } - - /** - * Return the prefix of the keys - * - * @return string - */ - protected function getPrefixKeys() - { - $options = $this->pubSubContext->getClient()->getOptions(); - - if (isset($options->prefix)) { - return $options->prefix->getPrefix(); - } - - return ''; - } -} diff --git a/vendor/predis/predis/lib/Predis/PubSub/PubSubContext.php b/vendor/predis/predis/lib/Predis/PubSub/PubSubContext.php deleted file mode 100644 index c01f3c0b4..000000000 --- a/vendor/predis/predis/lib/Predis/PubSub/PubSubContext.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\PubSub; - -use Predis\ClientException; -use Predis\ClientInterface; -use Predis\Command\AbstractCommand as Command; -use Predis\NotSupportedException; -use Predis\Connection\AggregatedConnectionInterface; - -/** - * Client-side abstraction of a Publish / Subscribe context. - * - * @author Daniele Alessandri - */ -class PubSubContext extends AbstractPubSubContext -{ - private $client; - private $options; - - /** - * @param ClientInterface $client Client instance used by the context. - * @param array $options Options for the context initialization. - */ - public function __construct(ClientInterface $client, Array $options = null) - { - $this->checkCapabilities($client); - $this->options = $options ?: array(); - $this->client = $client; - - $this->genericSubscribeInit('subscribe'); - $this->genericSubscribeInit('psubscribe'); - } - - /** - * Returns the underlying client instance used by the pub/sub iterator. - * - * @return ClientInterface - */ - public function getClient() - { - return $this->client; - } - - /** - * Checks if the passed client instance satisfies the required conditions - * needed to initialize a Publish / Subscribe context. - * - * @param ClientInterface $client Client instance used by the context. - */ - private function checkCapabilities(ClientInterface $client) - { - if ($client->getConnection() instanceof AggregatedConnectionInterface) { - throw new NotSupportedException('Cannot initialize a PUB/SUB context when using aggregated connections'); - } - - $commands = array('publish', 'subscribe', 'unsubscribe', 'psubscribe', 'punsubscribe'); - - if ($client->getProfile()->supportsCommands($commands) === false) { - throw new NotSupportedException('The current profile does not support PUB/SUB related commands'); - } - } - - /** - * This method shares the logic to handle both SUBSCRIBE and PSUBSCRIBE. - * - * @param string $subscribeAction Type of subscription. - */ - private function genericSubscribeInit($subscribeAction) - { - if (isset($this->options[$subscribeAction])) { - $this->$subscribeAction($this->options[$subscribeAction]); - } - } - - /** - * {@inheritdoc} - */ - protected function writeCommand($method, $arguments) - { - $arguments = Command::normalizeArguments($arguments); - $command = $this->client->createCommand($method, $arguments); - $this->client->getConnection()->writeCommand($command); - } - - /** - * {@inheritdoc} - */ - protected function disconnect() - { - $this->client->disconnect(); - } - - /** - * {@inheritdoc} - */ - protected function getValue() - { - $response = $this->client->getConnection()->read(); - - switch ($response[0]) { - case self::SUBSCRIBE: - case self::UNSUBSCRIBE: - case self::PSUBSCRIBE: - case self::PUNSUBSCRIBE: - if ($response[2] === 0) { - $this->invalidate(); - } - // The missing break here is intentional as we must process - // subscriptions and unsubscriptions as standard messages. - - case self::MESSAGE: - return (object) array( - 'kind' => $response[0], - 'channel' => $response[1], - 'payload' => $response[2], - ); - - case self::PMESSAGE: - return (object) array( - 'kind' => $response[0], - 'pattern' => $response[1], - 'channel' => $response[2], - 'payload' => $response[3], - ); - - default: - $message = "Received an unknown message type {$response[0]} inside of a pubsub context"; - throw new ClientException($message); - } - } -} diff --git a/vendor/predis/predis/lib/Predis/Replication/ReplicationStrategy.php b/vendor/predis/predis/lib/Predis/Replication/ReplicationStrategy.php deleted file mode 100644 index 2c4c9ab2d..000000000 --- a/vendor/predis/predis/lib/Predis/Replication/ReplicationStrategy.php +++ /dev/null @@ -1,223 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Replication; - -use Predis\NotSupportedException; -use Predis\Command\CommandInterface; - -/** - * Defines a strategy for master/reply replication. - * - * @author Daniele Alessandri - */ -class ReplicationStrategy -{ - protected $disallowed; - protected $readonly; - protected $readonlySHA1; - - /** - * - */ - public function __construct() - { - $this->disallowed = $this->getDisallowedOperations(); - $this->readonly = $this->getReadOnlyOperations(); - $this->readonlySHA1 = array(); - } - - /** - * Returns if the specified command performs a read-only operation - * against a key stored on Redis. - * - * @param CommandInterface $command Instance of Redis command. - * @return bool - */ - public function isReadOperation(CommandInterface $command) - { - if (isset($this->disallowed[$id = $command->getId()])) { - throw new NotSupportedException("The command $id is not allowed in replication mode"); - } - - if (isset($this->readonly[$id])) { - if (true === $readonly = $this->readonly[$id]) { - return true; - } - - return call_user_func($readonly, $command); - } - - if (($eval = $id === 'EVAL') || $id === 'EVALSHA') { - $sha1 = $eval ? sha1($command->getArgument(0)) : $command->getArgument(0); - - if (isset($this->readonlySHA1[$sha1])) { - if (true === $readonly = $this->readonlySHA1[$sha1]) { - return true; - } - - return call_user_func($readonly, $command); - } - } - - return false; - } - - /** - * Returns if the specified command is disallowed in a master/slave - * replication context. - * - * @param CommandInterface $command Instance of Redis command. - * @return bool - */ - public function isDisallowedOperation(CommandInterface $command) - { - return isset($this->disallowed[$command->getId()]); - } - - /** - * Checks if a SORT command is a readable operation by parsing the arguments - * array of the specified commad instance. - * - * @param CommandInterface $command Instance of Redis command. - * @return bool - */ - protected function isSortReadOnly(CommandInterface $command) - { - $arguments = $command->getArguments(); - - return ($c = count($arguments)) === 1 ? true : $arguments[$c - 2] !== 'STORE'; - } - - /** - * Marks a command as a read-only operation. When the behaviour of a - * command can be decided only at runtime depending on its arguments, - * a callable object can be provided to dynamically check if the passed - * instance of a command performs write operations or not. - * - * @param string $commandID ID of the command. - * @param mixed $readonly A boolean or a callable object. - */ - public function setCommandReadOnly($commandID, $readonly = true) - { - $commandID = strtoupper($commandID); - - if ($readonly) { - $this->readonly[$commandID] = $readonly; - } else { - unset($this->readonly[$commandID]); - } - } - - /** - * Marks a Lua script for EVAL and EVALSHA as a read-only operation. When - * the behaviour of a script can be decided only at runtime depending on - * its arguments, a callable object can be provided to dynamically check - * if the passed instance of EVAL or EVALSHA performs write operations or - * not. - * - * @param string $script Body of the Lua script. - * @param mixed $readonly A boolean or a callable object. - */ - public function setScriptReadOnly($script, $readonly = true) - { - $sha1 = sha1($script); - - if ($readonly) { - $this->readonlySHA1[$sha1] = $readonly; - } else { - unset($this->readonlySHA1[$sha1]); - } - } - - /** - * Returns the default list of disallowed commands. - * - * @return array - */ - protected function getDisallowedOperations() - { - return array( - 'SHUTDOWN' => true, - 'INFO' => true, - 'DBSIZE' => true, - 'LASTSAVE' => true, - 'CONFIG' => true, - 'MONITOR' => true, - 'SLAVEOF' => true, - 'SAVE' => true, - 'BGSAVE' => true, - 'BGREWRITEAOF' => true, - 'SLOWLOG' => true, - ); - } - - /** - * Returns the default list of commands performing read-only operations. - * - * @return array - */ - protected function getReadOnlyOperations() - { - return array( - 'EXISTS' => true, - 'TYPE' => true, - 'KEYS' => true, - 'SCAN' => true, - 'RANDOMKEY' => true, - 'TTL' => true, - 'GET' => true, - 'MGET' => true, - 'SUBSTR' => true, - 'STRLEN' => true, - 'GETRANGE' => true, - 'GETBIT' => true, - 'LLEN' => true, - 'LRANGE' => true, - 'LINDEX' => true, - 'SCARD' => true, - 'SISMEMBER' => true, - 'SINTER' => true, - 'SUNION' => true, - 'SDIFF' => true, - 'SMEMBERS' => true, - 'SSCAN' => true, - 'SRANDMEMBER' => true, - 'ZRANGE' => true, - 'ZREVRANGE' => true, - 'ZRANGEBYSCORE' => true, - 'ZREVRANGEBYSCORE' => true, - 'ZCARD' => true, - 'ZSCORE' => true, - 'ZCOUNT' => true, - 'ZRANK' => true, - 'ZREVRANK' => true, - 'ZSCAN' => true, - 'HGET' => true, - 'HMGET' => true, - 'HEXISTS' => true, - 'HLEN' => true, - 'HKEYS' => true, - 'HVALS' => true, - 'HGETALL' => true, - 'HSCAN' => true, - 'PING' => true, - 'AUTH' => true, - 'SELECT' => true, - 'ECHO' => true, - 'QUIT' => true, - 'OBJECT' => true, - 'BITCOUNT' => true, - 'TIME' => true, - 'SORT' => array($this, 'isSortReadOnly'), - ); - } -} diff --git a/vendor/predis/predis/lib/Predis/ResponseError.php b/vendor/predis/predis/lib/Predis/ResponseError.php deleted file mode 100644 index 0ab9a8a7e..000000000 --- a/vendor/predis/predis/lib/Predis/ResponseError.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Represents an error returned by Redis (-ERR replies) during the execution - * of a command on the server. - * - * @author Daniele Alessandri - */ -class ResponseError implements ResponseErrorInterface -{ - private $message; - - /** - * @param string $message Error message returned by Redis - */ - public function __construct($message) - { - $this->message = $message; - } - - /** - * {@inheritdoc} - */ - public function getMessage() - { - return $this->message; - } - - /** - * {@inheritdoc} - */ - public function getErrorType() - { - list($errorType, ) = explode(' ', $this->getMessage(), 2); - - return $errorType; - } - - /** - * Converts the object to its string representation. - * - * @return string - */ - public function __toString() - { - return $this->getMessage(); - } -} diff --git a/vendor/predis/predis/lib/Predis/ResponseErrorInterface.php b/vendor/predis/predis/lib/Predis/ResponseErrorInterface.php deleted file mode 100644 index 8c1a00543..000000000 --- a/vendor/predis/predis/lib/Predis/ResponseErrorInterface.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Represents an error returned by Redis (replies identified by "-" in the - * Redis response protocol) during the execution of an operation on the server. - * - * @author Daniele Alessandri - */ -interface ResponseErrorInterface extends ResponseObjectInterface -{ - /** - * Returns the error message - * - * @return string - */ - public function getMessage(); - - /** - * Returns the error type (e.g. ERR, ASK, MOVED) - * - * @return string - */ - public function getErrorType(); -} diff --git a/vendor/predis/predis/lib/Predis/ResponseObjectInterface.php b/vendor/predis/predis/lib/Predis/ResponseObjectInterface.php deleted file mode 100644 index ba81783e7..000000000 --- a/vendor/predis/predis/lib/Predis/ResponseObjectInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Represents a complex reply object from Redis. - * - * @author Daniele Alessandri - */ -interface ResponseObjectInterface -{ -} diff --git a/vendor/predis/predis/lib/Predis/ResponseQueued.php b/vendor/predis/predis/lib/Predis/ResponseQueued.php deleted file mode 100644 index a843269b8..000000000 --- a/vendor/predis/predis/lib/Predis/ResponseQueued.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Represents a +QUEUED response returned by Redis as a reply to each command - * executed inside a MULTI/ EXEC transaction. - * - * @author Daniele Alessandri - */ -class ResponseQueued implements ResponseObjectInterface -{ - /** - * Converts the object to its string representation. - * - * @return string - */ - public function __toString() - { - return 'QUEUED'; - } - - /** - * Returns the value of the specified property. - * - * @param string $property Name of the property. - * @return mixed - */ - public function __get($property) - { - return $property === 'queued'; - } - - /** - * Checks if the specified property is set. - * - * @param string $property Name of the property. - * @return bool - */ - public function __isset($property) - { - return $property === 'queued'; - } -} diff --git a/vendor/predis/predis/lib/Predis/ServerException.php b/vendor/predis/predis/lib/Predis/ServerException.php deleted file mode 100644 index 0a60c7e41..000000000 --- a/vendor/predis/predis/lib/Predis/ServerException.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -/** - * Exception class that identifies server-side Redis errors. - * - * @author Daniele Alessandri - */ -class ServerException extends PredisException implements ResponseErrorInterface -{ - /** - * Gets the type of the error returned by Redis. - * - * @return string - */ - public function getErrorType() - { - list($errorType, ) = explode(' ', $this->getMessage(), 2); - - return $errorType; - } - - /** - * Converts the exception to an instance of ResponseError. - * - * @return ResponseError - */ - public function toResponseError() - { - return new ResponseError($this->getMessage()); - } -} diff --git a/vendor/predis/predis/lib/Predis/Session/SessionHandler.php b/vendor/predis/predis/lib/Predis/Session/SessionHandler.php deleted file mode 100644 index dc4e4be38..000000000 --- a/vendor/predis/predis/lib/Predis/Session/SessionHandler.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Session; - -use SessionHandlerInterface; -use Predis\ClientInterface; - -/** - * Session handler class that relies on Predis\Client to store PHP's sessions - * data into one or multiple Redis servers. - * - * This class is mostly intended for PHP 5.4 but it can be used under PHP 5.3 provided - * that a polyfill for `SessionHandlerInterface` is defined by either you or an external - * package such as `symfony/http-foundation`. - * - * @author Daniele Alessandri - */ -class SessionHandler implements SessionHandlerInterface -{ - protected $client; - protected $ttl; - - /** - * @param ClientInterface $client Fully initialized client instance. - * @param array $options Session handler options. - */ - public function __construct(ClientInterface $client, Array $options = array()) - { - $this->client = $client; - $this->ttl = (int) (isset($options['gc_maxlifetime']) ? $options['gc_maxlifetime'] : ini_get('session.gc_maxlifetime')); - } - - /** - * Registers the handler instance as the current session handler. - */ - public function register() - { - if (version_compare(PHP_VERSION, '5.4.0') >= 0) { - session_set_save_handler($this, true); - } else { - session_set_save_handler( - array($this, 'open'), - array($this, 'close'), - array($this, 'read'), - array($this, 'write'), - array($this, 'destroy'), - array($this, 'gc') - ); - } - } - - /** - * {@inheritdoc} - */ - public function open($save_path, $session_id) - { - // NOOP - return true; - } - - /** - * {@inheritdoc} - */ - public function close() - { - // NOOP - return true; - } - - /** - * {@inheritdoc} - */ - public function gc($maxlifetime) - { - // NOOP - return true; - } - - /** - * {@inheritdoc} - */ - public function read($session_id) - { - if ($data = $this->client->get($session_id)) { - return $data; - } - - return ''; - } - /** - * {@inheritdoc} - */ - public function write($session_id, $session_data) - { - $this->client->setex($session_id, $this->ttl, $session_data); - - return true; - } - - /** - * {@inheritdoc} - */ - public function destroy($session_id) - { - $this->client->del($session_id); - - return true; - } - - /** - * Returns the underlying client instance. - * - * @return ClientInterface - */ - public function getClient() - { - return $this->client; - } - - /** - * Returns the session max lifetime value. - * - * @return int - */ - public function getMaxLifeTime() - { - return $this->ttl; - } -} diff --git a/vendor/predis/predis/lib/Predis/Transaction/AbortedMultiExecException.php b/vendor/predis/predis/lib/Predis/Transaction/AbortedMultiExecException.php deleted file mode 100644 index 81eed8b82..000000000 --- a/vendor/predis/predis/lib/Predis/Transaction/AbortedMultiExecException.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Transaction; - -use Predis\PredisException; - -/** - * Exception class that identifies MULTI / EXEC transactions aborted by Redis. - * - * @author Daniele Alessandri - */ -class AbortedMultiExecException extends PredisException -{ - private $transaction; - - /** - * @param MultiExecContext $transaction Transaction that generated the exception. - * @param string $message Error message. - * @param int $code Error code. - */ - public function __construct(MultiExecContext $transaction, $message, $code = null) - { - parent::__construct($message, $code); - $this->transaction = $transaction; - } - - /** - * Returns the transaction that generated the exception. - * - * @return MultiExecContext - */ - public function getTransaction() - { - return $this->transaction; - } -} diff --git a/vendor/predis/predis/lib/Predis/Transaction/MultiExecContext.php b/vendor/predis/predis/lib/Predis/Transaction/MultiExecContext.php deleted file mode 100644 index 52fcaa7c5..000000000 --- a/vendor/predis/predis/lib/Predis/Transaction/MultiExecContext.php +++ /dev/null @@ -1,449 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Transaction; - -use SplQueue; -use Predis\BasicClientInterface; -use Predis\ClientException; -use Predis\ClientInterface; -use Predis\CommunicationException; -use Predis\ExecutableContextInterface; -use Predis\NotSupportedException; -use Predis\ResponseErrorInterface; -use Predis\ResponseQueued; -use Predis\ServerException; -use Predis\Command\CommandInterface; -use Predis\Connection\AggregatedConnectionInterface; -use Predis\Protocol\ProtocolException; - -/** - * Client-side abstraction of a Redis transaction based on MULTI / EXEC. - * - * @author Daniele Alessandri - */ -class MultiExecContext implements BasicClientInterface, ExecutableContextInterface -{ - const STATE_RESET = 0; // 0b00000 - const STATE_INITIALIZED = 1; // 0b00001 - const STATE_INSIDEBLOCK = 2; // 0b00010 - const STATE_DISCARDED = 4; // 0b00100 - const STATE_CAS = 8; // 0b01000 - const STATE_WATCH = 16; // 0b10000 - - private $state; - private $canWatch; - - protected $client; - protected $options; - protected $commands; - - /** - * @param ClientInterface $client Client instance used by the context. - * @param array $options Options for the context initialization. - */ - public function __construct(ClientInterface $client, Array $options = null) - { - $this->checkCapabilities($client); - $this->options = $options ?: array(); - $this->client = $client; - $this->reset(); - } - - /** - * Sets the internal state flags. - * - * @param int $flags Set of flags - */ - protected function setState($flags) - { - $this->state = $flags; - } - - /** - * Gets the internal state flags. - * - * @return int - */ - protected function getState() - { - return $this->state; - } - - /** - * Sets one or more flags. - * - * @param int $flags Set of flags - */ - protected function flagState($flags) - { - $this->state |= $flags; - } - - /** - * Resets one or more flags. - * - * @param int $flags Set of flags - */ - protected function unflagState($flags) - { - $this->state &= ~$flags; - } - - /** - * Checks is a flag is set. - * - * @param int $flags Flag - * @return bool - */ - protected function checkState($flags) - { - return ($this->state & $flags) === $flags; - } - - /** - * Checks if the passed client instance satisfies the required conditions - * needed to initialize a transaction context. - * - * @param ClientInterface $client Client instance used by the context. - */ - private function checkCapabilities(ClientInterface $client) - { - if ($client->getConnection() instanceof AggregatedConnectionInterface) { - throw new NotSupportedException('Cannot initialize a MULTI/EXEC context when using aggregated connections'); - } - - $profile = $client->getProfile(); - - if ($profile->supportsCommands(array('multi', 'exec', 'discard')) === false) { - throw new NotSupportedException('The current profile does not support MULTI, EXEC and DISCARD'); - } - - $this->canWatch = $profile->supportsCommands(array('watch', 'unwatch')); - } - - /** - * Checks if WATCH and UNWATCH are supported by the server profile. - */ - private function isWatchSupported() - { - if ($this->canWatch === false) { - throw new NotSupportedException('The current profile does not support WATCH and UNWATCH'); - } - } - - /** - * Resets the state of a transaction. - */ - protected function reset() - { - $this->setState(self::STATE_RESET); - $this->commands = new SplQueue(); - } - - /** - * Initializes a new transaction. - */ - protected function initialize() - { - if ($this->checkState(self::STATE_INITIALIZED)) { - return; - } - - $options = $this->options; - - if (isset($options['cas']) && $options['cas']) { - $this->flagState(self::STATE_CAS); - } - if (isset($options['watch'])) { - $this->watch($options['watch']); - } - - $cas = $this->checkState(self::STATE_CAS); - $discarded = $this->checkState(self::STATE_DISCARDED); - - if (!$cas || ($cas && $discarded)) { - $this->client->multi(); - - if ($discarded) { - $this->unflagState(self::STATE_CAS); - } - } - - $this->unflagState(self::STATE_DISCARDED); - $this->flagState(self::STATE_INITIALIZED); - } - - /** - * Dynamically invokes a Redis command with the specified arguments. - * - * @param string $method Command ID. - * @param array $arguments Arguments for the command. - * @return mixed - */ - public function __call($method, $arguments) - { - $command = $this->client->createCommand($method, $arguments); - $response = $this->executeCommand($command); - - return $response; - } - - /** - * Executes the specified Redis command. - * - * @param CommandInterface $command Command instance. - * @return $this|mixed - */ - public function executeCommand(CommandInterface $command) - { - $this->initialize(); - $response = $this->client->executeCommand($command); - - if ($this->checkState(self::STATE_CAS)) { - return $response; - } - - if (!$response instanceof ResponseQueued) { - $this->onProtocolError('The server did not respond with a QUEUED status reply'); - } - - $this->commands->enqueue($command); - - return $this; - } - - /** - * Executes WATCH on one or more keys. - * - * @param string|array $keys One or more keys. - * @return mixed - */ - public function watch($keys) - { - $this->isWatchSupported(); - - if ($this->checkState(self::STATE_INITIALIZED) && !$this->checkState(self::STATE_CAS)) { - throw new ClientException('WATCH after MULTI is not allowed'); - } - - $reply = $this->client->watch($keys); - $this->flagState(self::STATE_WATCH); - - return $reply; - } - - /** - * Finalizes the transaction on the server by executing MULTI on the server. - * - * @return MultiExecContext - */ - public function multi() - { - if ($this->checkState(self::STATE_INITIALIZED | self::STATE_CAS)) { - $this->unflagState(self::STATE_CAS); - $this->client->multi(); - } else { - $this->initialize(); - } - - return $this; - } - - /** - * Executes UNWATCH. - * - * @return MultiExecContext - */ - public function unwatch() - { - $this->isWatchSupported(); - $this->unflagState(self::STATE_WATCH); - $this->__call('unwatch', array()); - - return $this; - } - - /** - * Resets a transaction by UNWATCHing the keys that are being WATCHed and - * DISCARDing the pending commands that have been already sent to the server. - * - * @return MultiExecContext - */ - public function discard() - { - if ($this->checkState(self::STATE_INITIALIZED)) { - $command = $this->checkState(self::STATE_CAS) ? 'unwatch' : 'discard'; - $this->client->$command(); - $this->reset(); - $this->flagState(self::STATE_DISCARDED); - } - - return $this; - } - - /** - * Executes the whole transaction. - * - * @return mixed - */ - public function exec() - { - return $this->execute(); - } - - /** - * Checks the state of the transaction before execution. - * - * @param mixed $callable Callback for execution. - */ - private function checkBeforeExecution($callable) - { - if ($this->checkState(self::STATE_INSIDEBLOCK)) { - throw new ClientException("Cannot invoke 'execute' or 'exec' inside an active client transaction block"); - } - - if ($callable) { - if (!is_callable($callable)) { - throw new \InvalidArgumentException('Argument passed must be a callable object'); - } - - if (!$this->commands->isEmpty()) { - $this->discard(); - throw new ClientException('Cannot execute a transaction block after using fluent interface'); - } - } - - if (isset($this->options['retry']) && !isset($callable)) { - $this->discard(); - throw new \InvalidArgumentException('Automatic retries can be used only when a transaction block is provided'); - } - } - - /** - * Handles the actual execution of the whole transaction. - * - * @param mixed $callable Optional callback for execution. - * @return array - */ - public function execute($callable = null) - { - $this->checkBeforeExecution($callable); - - $reply = null; - $values = array(); - $attempts = isset($this->options['retry']) ? (int) $this->options['retry'] : 0; - - do { - if ($callable !== null) { - $this->executeTransactionBlock($callable); - } - - if ($this->commands->isEmpty()) { - if ($this->checkState(self::STATE_WATCH)) { - $this->discard(); - } - - return null; - } - - $reply = $this->client->exec(); - - if ($reply === null) { - if ($attempts === 0) { - $message = 'The current transaction has been aborted by the server'; - throw new AbortedMultiExecException($this, $message); - } - - $this->reset(); - - if (isset($this->options['on_retry']) && is_callable($this->options['on_retry'])) { - call_user_func($this->options['on_retry'], $this, $attempts); - } - - continue; - } - - break; - } while ($attempts-- > 0); - - $exec = $reply instanceof \Iterator ? iterator_to_array($reply) : $reply; - $commands = $this->commands; - - $size = count($exec); - if ($size !== count($commands)) { - $this->onProtocolError("EXEC returned an unexpected number of replies"); - } - - $clientOpts = $this->client->getOptions(); - $useExceptions = isset($clientOpts->exceptions) ? $clientOpts->exceptions : true; - - for ($i = 0; $i < $size; $i++) { - $commandReply = $exec[$i]; - - if ($commandReply instanceof ResponseErrorInterface && $useExceptions) { - $message = $commandReply->getMessage(); - throw new ServerException($message); - } - - if ($commandReply instanceof \Iterator) { - $commandReply = iterator_to_array($commandReply); - } - - $values[$i] = $commands->dequeue()->parseResponse($commandReply); - } - - return $values; - } - - /** - * Passes the current transaction context to a callable block for execution. - * - * @param mixed $callable Callback. - */ - protected function executeTransactionBlock($callable) - { - $blockException = null; - $this->flagState(self::STATE_INSIDEBLOCK); - - try { - call_user_func($callable, $this); - } catch (CommunicationException $exception) { - $blockException = $exception; - } catch (ServerException $exception) { - $blockException = $exception; - } catch (\Exception $exception) { - $blockException = $exception; - $this->discard(); - } - - $this->unflagState(self::STATE_INSIDEBLOCK); - - if ($blockException !== null) { - throw $blockException; - } - } - - /** - * Helper method that handles protocol errors encountered inside a transaction. - * - * @param string $message Error message. - */ - private function onProtocolError($message) - { - // Since a MULTI/EXEC block cannot be initialized when using aggregated - // connections, we can safely assume that Predis\Client::getConnection() - // will always return an instance of Predis\Connection\SingleConnectionInterface. - CommunicationException::handle(new ProtocolException( - $this->client->getConnection(), $message - )); - } -} diff --git a/vendor/predis/predis/package.ini b/vendor/predis/predis/package.ini deleted file mode 100644 index 06f3e97dd..000000000 --- a/vendor/predis/predis/package.ini +++ /dev/null @@ -1,37 +0,0 @@ -; This file is meant to be used with Onion http://c9s.github.com/Onion/ -; For instructions on how to build a PEAR package of Predis please follow -; the instructions at this URL: -; -; https://github.com/c9s/Onion#a-quick-tutorial-for-building-pear-package -; - -[package] -name = "Predis" -desc = "Flexible and feature-complete PHP client library for Redis" -homepage = "http://github.com/nrk/predis" -license = "MIT" -version = "0.8.5" -stability = "stable" -channel = "pear.nrk.io" - -author = "Daniele Alessandri \"nrk\" " - -[require] -php = ">= 5.3.2" -pearinstaller = "1.4.1" - -[roles] -*.xml.dist = test -*.md = doc -LICENSE = doc -lib = php - -[optional phpiredis] -hint = "Add support for faster protocol handling with phpiredis" -extensions[] = socket -extensions[] = phpiredis - -[optional webdis] -hint = "Add support for Webdis" -extensions[] = curl -extensions[] = phpiredis diff --git a/vendor/predis/predis/phpunit.xml.dist b/vendor/predis/predis/phpunit.xml.dist deleted file mode 100644 index 1a6a012b3..000000000 --- a/vendor/predis/predis/phpunit.xml.dist +++ /dev/null @@ -1,39 +0,0 @@ - - - - - - tests/Predis/ - - - - - - ext-phpiredis - ext-curl - realm-webdis - - - - - - - - - - lib/Predis/ - - - - - - - - - - - - - - - diff --git a/vendor/predis/predis/phpunit.xml.travisci b/vendor/predis/predis/phpunit.xml.travisci deleted file mode 100644 index a74297e58..000000000 --- a/vendor/predis/predis/phpunit.xml.travisci +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - tests/Predis/ - - - - - - ext-phpiredis - ext-curl - realm-webdis - - - - - - - - - - lib/Predis/ - - - - - - - - - - - - - - - - - - - diff --git a/vendor/predis/predis/tests/PHPUnit/ArrayHasSameValuesConstraint.php b/vendor/predis/predis/tests/PHPUnit/ArrayHasSameValuesConstraint.php deleted file mode 100644 index 13035bb64..000000000 --- a/vendor/predis/predis/tests/PHPUnit/ArrayHasSameValuesConstraint.php +++ /dev/null @@ -1,58 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -/** - * Constraint that accepts arrays with the same elements but different order. - */ -class ArrayHasSameValuesConstraint extends PHPUnit_Framework_Constraint -{ - protected $array; - - /** - * @param array $array - */ - public function __construct($array) - { - $this->array = $array; - } - - /** - * {@inheritdoc} - */ - public function matches($other) - { - if (count($this->array) !== count($other)) { - return false; - } - - if (array_diff($this->array, $other)) { - return false; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function toString() - { - return 'two arrays contain the same elements.'; - } - - /** - * {@inheritdoc} - */ - protected function failureDescription($other) - { - return $this->toString(); - } -} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisCommandTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisCommandTestCase.php deleted file mode 100644 index 8dc08cc92..000000000 --- a/vendor/predis/predis/tests/PHPUnit/PredisCommandTestCase.php +++ /dev/null @@ -1,127 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -use PredisTestCase; -use Predis\Client; - -/** - * - */ -abstract class PredisCommandTestCase extends PredisTestCase -{ - /** - * Returns the expected command. - * - * @return CommandInterface|string Instance or FQN of the expected command. - */ - abstract protected function getExpectedCommand(); - - /** - * Returns the expected command ID. - * - * @return string - */ - abstract protected function getExpectedId(); - - /** - * Returns a new command instance. - * - * @return CommandInterface - */ - public function getCommand() - { - $command = $this->getExpectedCommand(); - - return $command instanceof CommandInterface ? $command : new $command(); - } - - /** - * Returns a new client instance. - * - * @param bool $flushdb Flush selected database before returning the client. - * @return Client - */ - public function getClient($flushdb = true) - { - $profile = $this->getProfile(); - - if (!$profile->supportsCommand($id = $this->getExpectedId())) { - $this->markTestSkipped( - "The profile {$profile->getVersion()} does not support command {$id}" - ); - } - - $client = $this->createClient(null, null, $flushdb); - - return $client; - } - - /** - * Returns wether the command is prefixable or not. - * - * @return bool - */ - protected function isPrefixable() - { - return $this->getCommand() instanceof PrefixableCommandInterface; - } - - /** - * Returns a new command instance with the specified arguments. - * - * @param ... List of arguments for the command. - * @return CommandInterface - */ - protected function getCommandWithArguments(/* arguments */) - { - return $this->getCommandWithArgumentsArray(func_get_args()); - } - - /** - * Returns a new command instance with the specified arguments. - * - * @param array $arguments Arguments for the command. - * @return CommandInterface - */ - protected function getCommandWithArgumentsArray(Array $arguments) - { - $command = $this->getCommand(); - $command->setArguments($arguments); - - return $command; - } - - /** - * @group disconnected - */ - public function testCommandId() - { - $command = $this->getCommand(); - - $this->assertInstanceOf('Predis\Command\CommandInterface', $command); - $this->assertEquals($this->getExpectedId(), $command->getId()); - } - - /** - * @group disconnected - */ - public function testRawArguments() - { - $expected = array('1st', '2nd', '3rd', '4th'); - - $command = $this->getCommand(); - $command->setRawArguments($expected); - - $this->assertSame($expected, $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisConnectionTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisConnectionTestCase.php deleted file mode 100644 index 0ac65451e..000000000 --- a/vendor/predis/predis/tests/PHPUnit/PredisConnectionTestCase.php +++ /dev/null @@ -1,333 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use PredisTestCase; -use Predis\Profile\ServerProfile; - -/** - * @group realm-connection - */ -abstract class PredisConnectionTestCase extends PredisTestCase -{ - /** - * @group disconnected - * @group slow - * @expectedException Predis\Connection\ConnectionException - */ - public function testThrowExceptionWhenUnableToConnect() - { - $parameters = array('host' => '169.254.10.10', 'timeout' => 0.5); - $connection = $this->getConnection($profile, false, $parameters); - $connection->executeCommand($this->getProfile()->createCommand('ping')); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testConnectForcesConnection() - { - $connection = $this->getConnection(); - - $this->assertFalse($connection->isConnected()); - $connection->connect(); - $this->assertTrue($connection->isConnected()); - } - - /** - * @group connected - * @expectedException Predis\ClientException - * @expectedExceptionMessage Connection already estabilished - */ - public function testThrowsExceptionOnConnectWhenAlreadyConnected() - { - $connection = $this->getConnection(); - - $connection->connect(); - $connection->connect(); - } - - /** - * @group connected - */ - public function testDisconnectForcesDisconnection() - { - $connection = $this->getConnection(); - - $connection->connect(); - $this->assertTrue($connection->isConnected()); - - $connection->disconnect(); - $this->assertFalse($connection->isConnected()); - } - - /** - * @group disconnected - */ - public function testDoesNotThrowExceptionOnDisconnectWhenAlreadyDisconnected() - { - $connection = $this->getConnection(); - - $this->assertFalse($connection->isConnected()); - $connection->disconnect(); - $this->assertFalse($connection->isConnected()); - } - - /** - * @group connected - */ - public function testGetResourceForcesConnection() - { - $connection = $this->getConnection(); - - $this->assertFalse($connection->isConnected()); - $this->assertInternalType('resource', $connection->getResource()); - $this->assertTrue($connection->isConnected()); - } - - /** - * @group connected - */ - public function testSendingCommandForcesConnection() - { - $connection = $this->getConnection($profile); - $cmdPing = $profile->createCommand('ping'); - - $this->assertSame('PONG', $connection->executeCommand($cmdPing)); - $this->assertTrue($connection->isConnected()); - } - - /** - * @group connected - */ - public function testExecutesCommandOnServer() - { - $connection = $this->getConnection($profile); - - $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); - $cmdPing->expects($this->never()) - ->method('parseResponse'); - - $this->assertSame('PONG', $connection->executeCommand($cmdPing)); - } - - /** - * @group connected - */ - public function testWritesCommandToServer() - { - $connection = $this->getConnection($profile); - - $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); - $cmdPing->expects($this->never()) - ->method('parseResponse'); - - $connection->writeCommand($cmdPing); - $connection->disconnect(); - } - - /** - * @group connected - */ - public function testReadsCommandFromServer() - { - $connection = $this->getConnection($profile); - - $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); - $cmdPing->expects($this->never()) - ->method('parseResponse'); - - $connection->writeCommand($cmdPing); - $this->assertSame('PONG', $connection->readResponse($cmdPing)); - } - - /** - * @group connected - */ - public function testIsAbleToWriteMultipleCommandsAndReadThemBackForPipelining() - { - $connection = $this->getConnection($profile); - - $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('parseResponse')); - $cmdPing->expects($this->never()) - ->method('parseResponse'); - - $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('parseResponse')); - $cmdEcho->setArguments(array('ECHOED')); - $cmdEcho->expects($this->never()) - ->method('parseResponse'); - - $connection = $this->getConnection(); - - $connection->writeCommand($cmdPing); - $connection->writeCommand($cmdEcho); - - $this->assertSame('PONG', $connection->readResponse($cmdPing)); - $this->assertSame('ECHOED', $connection->readResponse($cmdEcho)); - } - - /** - * @group connected - */ - public function testSendsInitializationCommandsOnConnection() - { - $connection = $this->getConnection($profile, true); - - $cmdPing = $this->getMock($profile->getCommandClass('ping'), array('getArguments')); - $cmdPing->expects($this->once()) - ->method('getArguments') - ->will($this->returnValue(array())); - - $cmdEcho = $this->getMock($profile->getCommandClass('echo'), array('getArguments')); - $cmdEcho->expects($this->once()) - ->method('getArguments') - ->will($this->returnValue(array('ECHOED'))); - - $connection->pushInitCommand($cmdPing); - $connection->pushInitCommand($cmdEcho); - - $connection->connect(); - } - - /** - * @group connected - */ - public function testReadsStatusReplies() - { - $connection = $this->getConnection($profile, true); - - $connection->writeCommand($profile->createCommand('set', array('foo', 'bar'))); - $this->assertTrue($connection->read()); - - $connection->writeCommand($profile->createCommand('ping')); - $this->assertSame('PONG', $connection->read()); - - $connection->writeCommand($profile->createCommand('multi')); - $connection->writeCommand($profile->createCommand('ping')); - $this->assertTrue($connection->read()); - $this->assertInstanceOf('Predis\ResponseQueued', $connection->read()); - } - - /** - * @group connected - */ - public function testReadsBulkReplies() - { - $connection = $this->getConnection($profile, true); - - $connection->executeCommand($profile->createCommand('set', array('foo', 'bar'))); - - $connection->writeCommand($profile->createCommand('get', array('foo'))); - $this->assertSame('bar', $connection->read()); - - $connection->writeCommand($profile->createCommand('get', array('hoge'))); - $this->assertNull($connection->read()); - } - - /** - * @group connected - */ - public function testReadsIntegerReplies() - { - $connection = $this->getConnection($profile, true); - - $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); - $connection->writeCommand($profile->createCommand('llen', array('metavars'))); - - $this->assertSame(3, $connection->read()); - } - - /** - * @group connected - */ - public function testReadsErrorRepliesAsResponseErrorObjects() - { - $connection = $this->getConnection($profile, true); - - $connection->executeCommand($profile->createCommand('set', array('foo', 'bar'))); - $connection->writeCommand($profile->createCommand('rpush', array('foo', 'baz'))); - - $this->assertInstanceOf('Predis\ResponseError', $error = $connection->read()); - $this->assertRegExp('/[ERR|WRONGTYPE] Operation against a key holding the wrong kind of value/', $error->getMessage()); - } - - /** - * @group connected - */ - public function testReadsMultibulkRepliesAsArrays() - { - $connection = $this->getConnection($profile, true); - - $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); - $connection->writeCommand($profile->createCommand('lrange', array('metavars', 0, -1))); - - $this->assertSame(array('foo', 'hoge', 'lol'), $connection->read()); - } - - /** - * @group connected - * @group slow - * @expectedException Predis\Connection\ConnectionException - */ - public function testThrowsExceptionOnConnectionTimeout() - { - $connection = $this->getConnection($_, false, array('host' => '169.254.10.10', 'timeout' => 0.5)); - - $connection->connect(); - } - - /** - * @group connected - * @group slow - * @expectedException Predis\Connection\ConnectionException - */ - public function testThrowsExceptionOnReadWriteTimeout() - { - $connection = $this->getConnection($profile, true, array('read_write_timeout' => 0.5)); - - $connection->executeCommand($profile->createCommand('brpop', array('foo', 3))); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a named array with the default connection parameters and their values. - * - * @return Array Default connection parameters. - */ - protected function getDefaultParametersArray() - { - return array( - 'scheme' => 'tcp', - 'host' => REDIS_SERVER_HOST, - 'port' => REDIS_SERVER_PORT, - 'database' => REDIS_SERVER_DBNUM, - 'read_write_timeout' => 2, - ); - } - - /** - * Returns a new instance of a connection instance. - * - * @param ServerProfile $profile Reference to the server profile instance. - * @param bool $initialize Push default initialization commands (SELECT and FLUSHDB). - * @param array $parameters Additional connection parameters. - * @return StreamConnection - */ - abstract protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()); -} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisDistributorTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisDistributorTestCase.php deleted file mode 100644 index 29e06aaa8..000000000 --- a/vendor/predis/predis/tests/PHPUnit/PredisDistributorTestCase.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Distribution; - -use PredisTestCase; - -/** - * - */ -abstract class PredisDistributorTestCase extends PredisTestCase -{ - /** - * Returns a new instance of the tested distributor. - * - * @return Predis\Cluster\Distribution\DistributionStrategyInterface - */ - abstract protected function getDistributorInstance(); - - /** - * Returns a list of nodes from the hashring. - * - * @param DistributionStrategyInterface $ring Hashring instance. - * @param int $iterations Number of nodes to fetch. - * @return array Nodes from the hashring. - */ - protected function getNodes(DistributionStrategyInterface $ring, $iterations = 10) - { - $nodes = array(); - - for ($i = 0; $i < $iterations; $i++) { - $key = $ring->hash($i * $i); - $nodes[] = $ring->get($key); - } - - return $nodes; - } - - /** - * @group disconnected - */ - public function testEmptyRingThrowsException() - { - $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException'); - - $ring = $this->getDistributorInstance(); - $ring->get('nodekey'); - } - - /** - * @group disconnected - */ - public function testRemoveOnEmptyRingDoesNotThrowException() - { - $ring = $this->getDistributorInstance(); - - $this->assertNull($ring->remove('node')); - } -} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisProfileTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisProfileTestCase.php deleted file mode 100644 index b5d46f64c..000000000 --- a/vendor/predis/predis/tests/PHPUnit/PredisProfileTestCase.php +++ /dev/null @@ -1,81 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -use PredisTestCase; - -/** - * - */ -abstract class PredisProfileTestCase extends PredisTestCase -{ - /** - * Returns a new instance of the tested profile. - * - * @param string $version Version of Redis. - * @return ServerProfileInterface - */ - protected function getProfile($version = null) - { - $this->markTestIncomplete("Server profile must be defined in ".get_class($this)); - } - - /** - * Returns the expected version string for the tested profile. - * - * @return string Version string. - */ - abstract protected function getExpectedVersion(); - - /** - * Returns the expected list of commands supported by the tested profile. - * - * @return array List of supported commands. - */ - abstract protected function getExpectedCommands(); - - /** - * Returns the list of commands supported by the current - * server profile. - * - * @param ServerProfileInterface $profile Server profile instance. - * @return array - */ - protected function getCommands(ServerProfileInterface $profile) - { - $commands = $profile->getSupportedCommands(); - - return array_keys($commands); - } - - /** - * @group disconnected - */ - public function testGetVersion() - { - $profile = $this->getProfile(); - - $this->assertEquals($this->getExpectedVersion(), $profile->getVersion()); - } - - /** - * @group disconnected - */ - public function testSupportedCommands() - { - $profile = $this->getProfile(); - $expected = $this->getExpectedCommands(); - $commands = $this->getCommands($profile); - - $this->assertSame($expected, $commands); - } -} diff --git a/vendor/predis/predis/tests/PHPUnit/PredisTestCase.php b/vendor/predis/predis/tests/PHPUnit/PredisTestCase.php deleted file mode 100644 index 9b24928d9..000000000 --- a/vendor/predis/predis/tests/PHPUnit/PredisTestCase.php +++ /dev/null @@ -1,240 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Predis\Client; -use Predis\Command\CommandInterface; -use Predis\Connection\ConnectionParameters; -use Predis\Profile\ServerProfile; -use Predis\Profile\ServerProfileInterface; - -/** - * Base test case class for the Predis test suite. - */ -abstract class PredisTestCase extends PHPUnit_Framework_TestCase -{ - /** - * Verifies that a Redis command is a valid Predis\Command\CommandInterface - * instance with the specified ID and command arguments. - * - * @param string|CommandInterface $command Expected command or command ID. - * @param array $arguments Expected command arguments. - * @return RedisCommandConstraint - */ - public function isRedisCommand($command = null, array $arguments = null) - { - return new RedisCommandConstraint($command, $arguments); - } - - /** - * Verifies that a Redis command is a valid Predis\Command\CommandInterface - * instance with the specified ID and command arguments. The comparison does - * not check for identity when passing a Predis\Command\CommandInterface - * instance for $expected. - * - * @param array|string|CommandInterface $expected Expected command. - * @param mixed $actual Actual command. - * @param string $message Optional assertion message. - */ - public function assertRedisCommand($expected, $actual, $message = '') - { - if (is_array($expected)) { - @list($command, $arguments) = $expected; - } else { - $command = $expected; - $arguments = null; - } - - $this->assertThat($actual, new RedisCommandConstraint($command, $arguments), $message); - } - - /** - * Asserts that two arrays have the same values, even if with different order. - * - * @param array $expected Expected array. - * @param array $actual Actual array. - * @param string $message Optional assertion message. - */ - public function assertSameValues(array $expected, array $actual, $message = '') - { - $this->assertThat($actual, new ArrayHasSameValuesConstraint($expected), $message); - } - - /** - * Returns a named array with the default connection parameters and their values. - * - * @return array Default connection parameters. - */ - protected function getDefaultParametersArray() - { - return array( - 'scheme' => 'tcp', - 'host' => REDIS_SERVER_HOST, - 'port' => REDIS_SERVER_PORT, - 'database' => REDIS_SERVER_DBNUM, - ); - } - - /** - * Returns a named array with the default client options and their values. - * - * @return array Default connection parameters. - */ - protected function getDefaultOptionsArray() - { - return array( - 'profile' => REDIS_SERVER_VERSION, - ); - } - - /** - * Returns a named array with the default connection parameters merged with - * the specified additional parameters. - * - * @param array $additional Additional connection parameters. - * @return array Connection parameters. - */ - protected function getParametersArray(array $additional) - { - return array_merge($this->getDefaultParametersArray(), $additional); - } - - /** - * Returns a new instance of connection parameters. - * - * @param array $additional Additional connection parameters. - * @return Connection\ConnectionParameters Default connection parameters. - */ - protected function getParameters($additional = array()) - { - $parameters = array_merge($this->getDefaultParametersArray(), $additional); - $parameters = new ConnectionParameters($parameters); - - return $parameters; - } - - /** - * Returns a new instance of server profile. - * - * @param string $version Redis profile. - * @return ServerProfileInterface - */ - protected function getProfile($version = null) - { - return ServerProfile::get($version ?: REDIS_SERVER_VERSION); - } - - /** - * Returns a new client instance. - * - * @param array $parameters Additional connection parameters. - * @param array $options Additional client options. - * @param bool $flushdb Flush selected database before returning the client. - * @return Client - */ - protected function createClient(array $parameters = null, array $options = null, $flushdb = true) - { - $parameters = array_merge( - $this->getDefaultParametersArray(), - $parameters ?: array() - ); - - $options = array_merge( - array( - 'profile' => $this->getProfile(), - ), - $options ?: array() - ); - - $client = new Client($parameters, $options); - $client->connect(); - - if ($flushdb) { - $client->flushdb(); - } - - return $client; - } - - /** - * @param string $expectedVersion Expected redis version. - * @param string $operator Comparison operator. - * @param callable $callback Callback for matching version. - * @throws PHPUnit_Framework_SkippedTestError When expected redis version is not met. - */ - protected function executeOnRedisVersion($expectedVersion, $operator, $callback) - { - $client = $this->createClient(null, null, true); - $info = array_change_key_case($client->info()); - - if (isset($info['server']['redis_version'])) { - // Redis >= 2.6 - $version = $info['server']['redis_version']; - } elseif (isset($info['redis_version'])) { - // Redis < 2.6 - $version = $info['redis_version']; - } else { - throw new RuntimeException('Unable to retrieve server info'); - } - - $comparation = version_compare($version, $expectedVersion); - - if ($match = eval("return $comparation $operator 0;")) { - call_user_func($callback, $this, $version); - } - - return $match; - } - - /** - * @param string $expectedVersion Expected redis version. - * @param string $operator Comparison operator. - * @param callable $callback Callback for matching version. - * @throws PHPUnit_Framework_SkippedTestError When expected redis version is not met. - */ - protected function executeOnProfileVersion($expectedVersion, $operator, $callback) - { - $profile = $this->getProfile(); - $comparation = version_compare($version = $profile->getVersion(), $expectedVersion); - - if ($match = eval("return $comparation $operator 0;")) { - call_user_func($callback, $this, $version); - } - - return $match; - } - - /** - * @param string $expectedVersion Expected redis version. - * @param string $message Optional message. - * @param bool $remote Based on local profile or remote redis version. - * @throws RuntimeException when unable to retrieve server info or redis version - * @throws \PHPUnit_Framework_SkippedTestError when expected redis version is not met - */ - public function markTestSkippedOnRedisVersionBelow($expectedVersion, $message = '', $remote = true) - { - $callback = function ($test, $version) use ($message, $expectedVersion) { - $test->markTestSkipped($message ?: "Test requires Redis $expectedVersion, current is $version."); - }; - - $method = $remote ? 'executeOnRedisVersion' : 'executeOnProfileVersion'; - $this->$method($expectedVersion, '<', $callback); - } - - /** - * Sleep the test case with microseconds resolution. - * - * @param float $seconds Seconds to sleep. - */ - protected function sleep($seconds) - { - usleep($seconds * 1000000); - } -} diff --git a/vendor/predis/predis/tests/PHPUnit/RedisCommandConstraint.php b/vendor/predis/predis/tests/PHPUnit/RedisCommandConstraint.php deleted file mode 100644 index 7bf6bc701..000000000 --- a/vendor/predis/predis/tests/PHPUnit/RedisCommandConstraint.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -use Predis\Command\CommandInterface; - -/** - * Constraint that verifies a redis command. - */ -class RedisCommandConstraint extends PHPUnit_Framework_Constraint -{ - protected $commandID; - protected $arguments; - - /** - * @param string|CommandInterface $command Expected command ID or instance. - * @param array $arguments Expected command arguments. - */ - public function __construct($command = null, array $arguments = null) - { - if ($command instanceof CommandInterface) { - $this->commandID = strtoupper($command->getId()); - $this->arguments = $arguments ?: $command->getArguments(); - } else { - $this->commandID = strtoupper($command); - $this->arguments = $arguments; - } - } - - /** - * {@inheritdoc} - */ - public function matches($other) - { - if (!$other instanceof CommandInterface) { - return false; - } - - if ($this->commandID && strtoupper($other->getId()) !== $this->commandID) { - return false; - } - - if ($this->arguments !== null) { - $otherArguments = $other->getArguments(); - - if (count($this->arguments) !== count($otherArguments)) { - return false; - } - - for ($i = 0; $i < count($this->arguments); $i++) { - if (((string) $this->arguments[$i]) !== ((string) $otherArguments[$i])) { - return false; - } - } - } - - return true; - } - - /** - * {@inheritdoc} - * - * @todo Improve output using diff when expected and actual arguments of a - * command do not match. - */ - public function toString() - { - $string = 'is a Redis command'; - - if ($this->commandID) { - $string .= " with ID '{$this->commandID}'"; - } - - if ($this->arguments) { - $string .= " and the following arguments:\n\n"; - $string .= PHPUnit_Util_Type::export($this->arguments); - } - - return $string; - } - - /** - * {@inheritdoc} - */ - protected function failureDescription($other) - { - $string = is_object($other) ? get_class($other) : $other; - - return "$string {$this->toString()}"; - } -} diff --git a/vendor/predis/predis/tests/Predis/ClientExceptionTest.php b/vendor/predis/predis/tests/Predis/ClientExceptionTest.php deleted file mode 100644 index 734714953..000000000 --- a/vendor/predis/predis/tests/Predis/ClientExceptionTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use PredisTestCase; - -/** - * - */ -class ClientExceptionTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExceptionMessage() - { - $message = 'This is a client exception.'; - - $this->setExpectedException('Predis\ClientException', $message); - - throw new ClientException($message); - } - - /** - * @group disconnected - */ - public function testExceptionClass() - { - $exception = new ClientException(); - - $this->assertInstanceOf('Predis\ClientException', $exception); - $this->assertInstanceOf('Predis\PredisException', $exception); - } -} diff --git a/vendor/predis/predis/tests/Predis/ClientTest.php b/vendor/predis/predis/tests/Predis/ClientTest.php deleted file mode 100644 index 314e47c73..000000000 --- a/vendor/predis/predis/tests/Predis/ClientTest.php +++ /dev/null @@ -1,777 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use PredisTestCase; -use Predis\Connection\ConnectionFactory; -use Predis\Connection\MasterSlaveReplication; -use Predis\Connection\PredisCluster; -use Predis\Profile\ServerProfile; - -/** - * - */ -class ClientTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testConstructorWithoutArguments() - { - $client = new Client(); - - $connection = $client->getConnection(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - - $parameters = $connection->getParameters(); - $this->assertSame($parameters->host, '127.0.0.1'); - $this->assertSame($parameters->port, 6379); - - $options = $client->getOptions(); - $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); - - $this->assertFalse($client->isConnected()); - } - - /** - * @group disconnected - */ - public function testConstructorWithNullArgument() - { - $client = new Client(null); - - $connection = $client->getConnection(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - - $parameters = $connection->getParameters(); - $this->assertSame($parameters->host, '127.0.0.1'); - $this->assertSame($parameters->port, 6379); - - $options = $client->getOptions(); - $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); - - $this->assertFalse($client->isConnected()); - } - - /** - * @group disconnected - */ - public function testConstructorWithNullAndNullArguments() - { - $client = new Client(null, null); - - $connection = $client->getConnection(); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - - $parameters = $connection->getParameters(); - $this->assertSame($parameters->host, '127.0.0.1'); - $this->assertSame($parameters->port, 6379); - - $options = $client->getOptions(); - $this->assertSame($options->profile->getVersion(), ServerProfile::getDefault()->getVersion()); - - $this->assertFalse($client->isConnected()); - } - - /** - * @group disconnected - */ - public function testConstructorWithArrayArgument() - { - $client = new Client($arg1 = array('host' => 'localhost', 'port' => 7000)); - - $parameters = $client->getConnection()->getParameters(); - $this->assertSame($parameters->host, $arg1['host']); - $this->assertSame($parameters->port, $arg1['port']); - } - - /** - * @group disconnected - */ - public function testConstructorWithArrayOfArrayArgument() - { - $arg1 = array( - array('host' => 'localhost', 'port' => 7000), - array('host' => 'localhost', 'port' => 7001), - ); - - $client = new Client($arg1); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); - } - - /** - * @group disconnected - */ - public function testConstructorWithStringArgument() - { - $client = new Client('tcp://localhost:7000'); - - $parameters = $client->getConnection()->getParameters(); - $this->assertSame($parameters->host, 'localhost'); - $this->assertSame($parameters->port, 7000); - } - - /** - * @group disconnected - */ - public function testConstructorWithArrayOfStringArgument() - { - $client = new Client($arg1 = array('tcp://localhost:7000', 'tcp://localhost:7001')); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); - } - - /** - * @group disconnected - */ - public function testConstructorWithArrayOfConnectionsArgument() - { - $connection1 = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection2 = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $client = new Client(array($connection1, $connection2)); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); - $this->assertSame($connection1, $cluster->getConnectionById(0)); - $this->assertSame($connection2, $cluster->getConnectionById(1)); - } - - /** - * @group disconnected - */ - public function testConstructorWithConnectionArgument() - { - $factory = new ConnectionFactory(); - $connection = $factory->create('tcp://localhost:7000'); - - $client = new Client($connection); - - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $client->getConnection()); - $this->assertSame($connection, $client->getConnection()); - - $parameters = $client->getConnection()->getParameters(); - $this->assertSame($parameters->host, 'localhost'); - $this->assertSame($parameters->port, 7000); - } - - /** - * @group disconnected - */ - public function testConstructorWithClusterArgument() - { - $cluster = new PredisCluster(); - - $factory = new ConnectionFactory(); - $factory->createAggregated($cluster, array('tcp://localhost:7000', 'tcp://localhost:7001')); - - $client = new Client($cluster); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $client->getConnection()); - $this->assertSame($cluster, $client->getConnection()); - } - - /** - * @group disconnected - */ - public function testConstructorWithReplicationArgument() - { - $replication = new MasterSlaveReplication(); - - $factory = new ConnectionFactory(); - $factory->createAggregated($replication, array('tcp://host1?alias=master', 'tcp://host2?alias=slave')); - - $client = new Client($replication); - - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $client->getConnection()); - $this->assertSame($replication, $client->getConnection()); - } - - /** - * @group disconnected - */ - public function testConstructorWithCallableArgument() - { - $connection = $this->getMock('Predis\Connection\ConnectionInterface'); - - $callable = $this->getMock('stdClass', array('__invoke')); - $callable->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Option\ClientOptions')) - ->will($this->returnValue($connection)); - - $client = new Client($callable); - - $this->assertSame($connection, $client->getConnection()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Callable parameters must return instances of Predis\Connection\ConnectionInterface - */ - public function testConstructorWithCallableArgumentButInvalidReturnType() - { - $wrongType = $this->getMock('stdClass'); - - $callable = $this->getMock('stdClass', array('__invoke')); - $callable->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Option\ClientOptions')) - ->will($this->returnValue($wrongType)); - - $client = new Client($callable); - } - - /** - * @group disconnected - */ - public function testConstructorWithNullAndArrayArgument() - { - $factory = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); - - $arg2 = array('profile' => '2.0', 'prefix' => 'prefix:', 'connections' => $factory); - $client = new Client(null, $arg2); - - $profile = $client->getProfile(); - $this->assertSame($profile->getVersion(), ServerProfile::get('2.0')->getVersion()); - $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); - $this->assertSame('prefix:', $profile->getProcessor()->getPrefix()); - - $this->assertSame($factory, $client->getConnectionFactory()); - } - - /** - * @group disconnected - */ - public function testConstructorWithArrayAndOptionReplicationArgument() - { - $arg1 = array('tcp://host1?alias=master', 'tcp://host2?alias=slave'); - $arg2 = array('replication' => true); - $client = new Client($arg1, $arg2); - - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $connection = $client->getConnection()); - $this->assertSame('host1', $connection->getConnectionById('master')->getParameters()->host); - $this->assertSame('host2', $connection->getConnectionById('slave')->getParameters()->host); - } - - /** - * @group disconnected - */ - public function testConnectAndDisconnect() - { - $connection = $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->once())->method('connect'); - $connection->expects($this->once())->method('disconnect'); - - $client = new Client($connection); - $client->connect(); - $client->disconnect(); - } - - /** - * @group disconnected - */ - public function testIsConnectedChecksConnectionState() - { - $connection = $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->once())->method('isConnected'); - - $client = new Client($connection); - $client->isConnected(); - } - - /** - * @group disconnected - */ - public function testQuitIsAliasForDisconnect() - { - $connection = $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->once())->method('disconnect'); - - $client = new Client($connection); - $client->quit(); - } - - /** - * @group disconnected - */ - public function testCreatesNewCommandUsingSpecifiedProfile() - { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); - - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); - $profile->expects($this->once()) - ->method('createCommand') - ->with('ping', array()) - ->will($this->returnValue($ping)); - - $client = new Client(null, array('profile' => $profile)); - $this->assertSame($ping, $client->createCommand('ping', array())); - } - - /** - * @group disconnected - */ - public function testExecuteCommandReturnsParsedReplies() - { - $profile = ServerProfile::getDefault(); - - $ping = $profile->createCommand('ping', array()); - $hgetall = $profile->createCommand('hgetall', array('metavars', 'foo', 'hoge')); - - $connection= $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->at(0)) - ->method('executeCommand') - ->with($ping) - ->will($this->returnValue('PONG')); - $connection->expects($this->at(1)) - ->method('executeCommand') - ->with($hgetall) - ->will($this->returnValue(array('foo', 'bar', 'hoge', 'piyo'))); - - $client = new Client($connection); - - $this->assertTrue($client->executeCommand($ping)); - $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo'), $client->executeCommand($hgetall)); - } - - /** - * @group disconnected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testExecuteCommandThrowsExceptionOnRedisError() - { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); - $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); - - $connection= $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->once()) - ->method('executeCommand') - ->will($this->returnValue($expectedResponse)); - - $client = new Client($connection); - $client->executeCommand($ping); - } - - /** - * @group disconnected - */ - public function testExecuteCommandReturnsErrorResponseOnRedisError() - { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); - $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); - - $connection= $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->once()) - ->method('executeCommand') - ->will($this->returnValue($expectedResponse)); - - $client = new Client($connection, array('exceptions' => false)); - $response = $client->executeCommand($ping); - - $this->assertSame($response, $expectedResponse); - } - - /** - * @group disconnected - */ - public function testCallingRedisCommandExecutesInstanceOfCommand() - { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); - - $connection = $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->once()) - ->method('executeCommand') - ->with($this->isInstanceOf('Predis\Command\ConnectionPing')) - ->will($this->returnValue('PONG')); - - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); - $profile->expects($this->once()) - ->method('createCommand') - ->with('ping', array()) - ->will($this->returnValue($ping)); - - $options = array('profile' => $profile); - $client = $this->getMock('Predis\Client', null, array($connection, $options)); - - $this->assertTrue($client->ping()); - } - - /** - * @group disconnected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testCallingRedisCommandThrowsExceptionOnServerError() - { - $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); - - $connection = $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->once()) - ->method('executeCommand') - ->with($this->isInstanceOf('Predis\Command\ConnectionPing')) - ->will($this->returnValue($expectedResponse)); - - $client = new Client($connection); - $client->ping(); - } - - /** - * @group disconnected - */ - public function testCallingRedisCommandReturnsErrorResponseOnRedisError() - { - $expectedResponse = new ResponseError('ERR Operation against a key holding the wrong kind of value'); - - $connection = $this->getMock('Predis\Connection\ConnectionInterface'); - $connection->expects($this->once()) - ->method('executeCommand') - ->with($this->isInstanceOf('Predis\Command\ConnectionPing')) - ->will($this->returnValue($expectedResponse)); - - $client = new Client($connection, array('exceptions' => false)); - $response = $client->ping(); - - $this->assertSame($response, $expectedResponse); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - * @expectedExceptionMessage 'invalidcommand' is not a registered Redis command - */ - public function testThrowsExceptionOnNonRegisteredRedisCommand() - { - $client = new Client(); - $client->invalidCommand(); - } - - /** - * @group disconnected - */ - public function testGetConnectionFromAggregatedConnectionWithAlias() - { - $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02')); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node01 = $client->getConnectionById('node01')); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node02 = $client->getConnectionById('node02')); - - $this->assertSame('host1', $node01->getParameters()->host); - $this->assertSame('host2', $node02->getParameters()->host); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage Retrieving connections by ID is supported only when using aggregated connections - */ - public function testGetConnectionByIdWorksOnlyWithAggregatedConnections() - { - $client = new Client(); - - $client->getConnectionById('node01'); - } - - /** - * @group disconnected - */ - public function testCreateClientWithConnectionFromAggregatedConnection() - { - $client = new Client(array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'), array('prefix' => 'pfx:')); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster = $client->getConnection()); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node01 = $client->getConnectionById('node01')); - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $node02 = $client->getConnectionById('node02')); - - $clientNode02 = $client->getClientFor('node02'); - - $this->assertInstanceOf('Predis\Client', $clientNode02); - $this->assertSame($node02, $clientNode02->getConnection()); - $this->assertSame($client->getOptions(), $clientNode02->getOptions()); - } - - /** - * @group disconnected - */ - public function testGetClientForReturnsInstanceOfSubclass() - { - $nodes = array('tcp://host1?alias=node01', 'tcp://host2?alias=node02'); - $client = $this->getMock('Predis\Client', array('dummy'), array($nodes), 'SubclassedClient'); - - $this->assertInstanceOf('SubclassedClient', $client->getClientFor('node02')); - } - - /** - * @group disconnected - */ - public function testPipelineWithoutArgumentsReturnsPipelineContext() - { - $client = new Client(); - - $this->assertInstanceOf('Predis\Pipeline\PipelineContext', $client->pipeline()); - } - - /** - * @group disconnected - */ - public function testPipelineWithArrayReturnsPipelineContextWithOptions() - { - $client = new Client(); - $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); - - $options = array('executor' => $executor); - $this->assertInstanceOf('Predis\Pipeline\PipelineContext', $pipeline = $client->pipeline($options)); - $this->assertSame($executor, $pipeline->getExecutor()); - - $options = array('executor' => function ($client, $options) use ($executor) { return $executor; }); - $this->assertInstanceOf('Predis\Pipeline\PipelineContext', $pipeline = $client->pipeline($options)); - $this->assertSame($executor, $pipeline->getExecutor()); - } - - /** - * @group disconnected - */ - public function testPipelineWithCallableExecutesPipeline() - { - $callable = $this->getMock('stdClass', array('__invoke')); - $callable->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Pipeline\PipelineContext')); - - $client = new Client(); - $client->pipeline($callable); - } - - /** - * @group disconnected - */ - public function testPipelineWithArrayAndCallableExecutesPipelineWithOptions() - { - $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); - $options = array('executor' => $executor); - - $test = $this; - $mockCallback = function ($pipeline) use ($executor, $test) { - $reflection = new \ReflectionProperty($pipeline, 'executor'); - $reflection->setAccessible(true); - - $test->assertSame($executor, $reflection->getValue($pipeline)); - }; - - $callable = $this->getMock('stdClass', array('__invoke')); - $callable->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Pipeline\PipelineContext')) - ->will($this->returnCallback($mockCallback)); - - $client = new Client(); - $client->pipeline($options, $callable); - } - - /** - * @group disconnected - */ - public function testPubSubLoopWithoutArgumentsReturnsPubSubContext() - { - $client = new Client(); - - $this->assertInstanceOf('Predis\PubSub\PubSubContext', $client->pubSubLoop()); - } - - /** - * @group disconnected - */ - public function testPubSubLoopWithArrayReturnsPubSubContextWithOptions() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $options = array('subscribe' => 'channel'); - - $client = new Client($connection); - - $this->assertInstanceOf('Predis\PubSub\PubSubContext', $pubsub = $client->pubSubLoop($options)); - - $reflection = new \ReflectionProperty($pubsub, 'options'); - $reflection->setAccessible(true); - - $this->assertSame($options, $reflection->getValue($pubsub)); - } - - /** - * @group disconnected - */ - public function testPubSubLoopWithArrayAndCallableExecutesPubSub() - { - // NOTE: we use a subscribe count of 0 in the fake message to trick - // the context and to make it think that it can be closed - // since there are no more subscriptions active. - - $message = array('subscribe', 'channel', 0); - $options = array('subscribe' => 'channel'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once()) - ->method('read') - ->will($this->returnValue($message)); - - $callable = $this->getMock('stdClass', array('__invoke')); - $callable->expects($this->once()) - ->method('__invoke'); - - $client = new Client($connection); - $client->pubSubLoop($options, $callable); - } - - /** - * @group disconnected - */ - public function testPubSubIsAliasForPubSubLoop() - { - $client = new Client(); - - $this->assertInstanceOf('Predis\PubSub\PubSubContext', $client->pubSub()); - } - - /** - * @group disconnected - */ - public function testMultiExecWithoutArgumentsReturnsMultiExecContext() - { - $client = new Client(); - - $this->assertInstanceOf('Predis\Transaction\MultiExecContext', $client->multiExec()); - } - - /** - * @group disconnected - */ - public function testMethodTransactionIsAliasForMethodMultiExec() - { - $client = new Client(); - - $this->assertInstanceOf('Predis\Transaction\MultiExecContext', $client->transaction()); - } - - /** - * @group disconnected - */ - public function testMultiExecWithArrayReturnsMultiExecContextWithOptions() - { - $options = array('cas' => true, 'retry' => 3); - - $client = new Client(); - - $this->assertInstanceOf('Predis\Transaction\MultiExecContext', $tx = $client->multiExec($options)); - - $reflection = new \ReflectionProperty($tx, 'options'); - $reflection->setAccessible(true); - - $this->assertSame($options, $reflection->getValue($tx)); - } - - /** - * @group disconnected - */ - public function testMultiExecWithArrayAndCallableExecutesMultiExec() - { - // NOTE: we use CAS since testing the actual MULTI/EXEC context - // here is not the point. - $options = array('cas' => true, 'retry' => 3); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once()) - ->method('executeCommand') - ->will($this->returnValue(new ResponseQueued())); - - $txCallback = function ($tx) { - $tx->ping(); - }; - - $callable = $this->getMock('stdClass', array('__invoke')); - $callable->expects($this->once()) - ->method('__invoke') - ->will($this->returnCallback($txCallback)); - - $client = new Client($connection); - $client->multiExec($options, $callable); - } - - /** - * @group disconnected - */ - public function testMonitorReturnsMonitorContext() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $client = new Client($connection); - - $this->assertInstanceOf('Predis\Monitor\MonitorContext', $monitor = $client->monitor()); - } - - /** - * @group disconnected - */ - public function testClientResendScriptedCommandUsingEvalOnNoScriptErrors() - { - $command = $this->getMockForAbstractClass('Predis\Command\ScriptedCommand', array(), '', true, true, true, array('parseResponse')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue('return redis.call(\'exists\', KEYS[1])')); - $command->expects($this->once()) - ->method('parseResponse') - ->with('OK') - ->will($this->returnValue(true)); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->at(0)) - ->method('executeCommand') - ->with($command) - ->will($this->returnValue(new ResponseError('NOSCRIPT'))); - $connection->expects($this->at(1)) - ->method('executeCommand') - ->with($this->isInstanceOf('Predis\Command\ServerEval')) - ->will($this->returnValue('OK')); - - $client = new Client($connection); - - $this->assertTrue($client->executeCommand($command)); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns an URI string representation of the specified connection parameters. - * - * @param Array $parameters Array of connection parameters. - * @return String URI string. - */ - protected function getParametersString(Array $parameters) - { - $defaults = $this->getDefaultParametersArray(); - - $scheme = isset($parameters['scheme']) ? $parameters['scheme'] : $defaults['scheme']; - $host = isset($parameters['host']) ? $parameters['host'] : $defaults['host']; - $port = isset($parameters['port']) ? $parameters['port'] : $defaults['port']; - - unset($parameters['scheme'], $parameters['host'], $parameters['port']); - $uriString = "$scheme://$host:$port/?"; - - foreach ($parameters as $k => $v) { - $uriString .= "$k=$v&"; - } - - return $uriString; - } -} diff --git a/vendor/predis/predis/tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php b/vendor/predis/predis/tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php deleted file mode 100644 index 379e78e5a..000000000 --- a/vendor/predis/predis/tests/Predis/Cluster/Distribution/EmptyRingExceptionTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Distribution; - -use PredisTestCase; - -/** - * @todo Not really useful right now. - */ -class EmptyRingExceptionTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExceptionMessage() - { - $message = 'Empty Ring'; - $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException', $message); - - throw new EmptyRingException($message); - } -} diff --git a/vendor/predis/predis/tests/Predis/Cluster/Distribution/HashRingTest.php b/vendor/predis/predis/tests/Predis/Cluster/Distribution/HashRingTest.php deleted file mode 100644 index efa09f3db..000000000 --- a/vendor/predis/predis/tests/Predis/Cluster/Distribution/HashRingTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Distribution; - -/** - * @todo To be improved. - */ -class HashRingTest extends PredisDistributorTestCase -{ - /** - * {@inheritdoc} - */ - public function getDistributorInstance() - { - return new HashRing(); - } - - /** - * @group disconnected - */ - public function testHash() - { - $ring = $this->getDistributorInstance(); - - $this->assertEquals(crc32('foobar'), $ring->hash('foobar')); - } - - /** - * @group disconnected - */ - public function testSingleNodeInRing() - { - $node = '127.0.0.1:7000'; - - $ring = $this->getDistributorInstance(); - $ring->add($node); - - $expected = array_fill(0, 20, $node); - $actual = $this->getNodes($ring, 20); - - $this->assertSame($expected, $actual); - } - - /** - * @group disconnected - */ - public function testMultipleNodesInRing() - { - $nodes = array( - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7002', - ); - - $ring = $this->getDistributorInstance(); - foreach ($nodes as $node) { - $ring->add($node); - } - - $expected = array( - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7002', - '127.0.0.1:7002', - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7002', - '127.0.0.1:7002', - '127.0.0.1:7002', - '127.0.0.1:7002', - '127.0.0.1:7000', - '127.0.0.1:7002', - '127.0.0.1:7002', - '127.0.0.1:7002', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7002', - ); - - $actual = $this->getNodes($ring, 20); - - $this->assertSame($expected, $actual); - } - - /** - * @group disconnected - */ - public function testSubsequendAddAndRemoveFromRing() - { - $ring = $this->getDistributorInstance(); - - $expected1 = array_fill(0, 10, '127.0.0.1:7000'); - $expected3 = array_fill(0, 10, '127.0.0.1:7001'); - $expected2 = array( - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - ); - - $ring->add('127.0.0.1:7000'); - $actual1 = $this->getNodes($ring, 10); - - $ring->add('127.0.0.1:7001'); - $actual2 = $this->getNodes($ring, 10); - - $ring->remove('127.0.0.1:7000'); - $actual3 = $this->getNodes($ring, 10); - - $this->assertSame($expected1, $actual1); - $this->assertSame($expected2, $actual2); - $this->assertSame($expected3, $actual3); - } - - /** - * @todo This tests should be moved in Predis\Cluster\Distribution\DistributionStrategyTestCase - * @group disconnected - */ - public function testCallbackToGetNodeHash() - { - $node = '127.0.0.1:7000'; - $replicas = HashRing::DEFAULT_REPLICAS; - $callable = $this->getMock('stdClass', array('__invoke')); - - $callable->expects($this->once()) - ->method('__invoke') - ->with($node) - ->will($this->returnValue($node)); - - $ring = new HashRing($replicas, $callable); - $ring->add($node); - - $this->getNodes($ring); - } -} diff --git a/vendor/predis/predis/tests/Predis/Cluster/Distribution/KetamaPureRingTest.php b/vendor/predis/predis/tests/Predis/Cluster/Distribution/KetamaPureRingTest.php deleted file mode 100644 index b3b1415d0..000000000 --- a/vendor/predis/predis/tests/Predis/Cluster/Distribution/KetamaPureRingTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster\Distribution; - -/** - * @todo To be improved. - */ -class KetamaPureRingTest extends PredisDistributorTestCase -{ - /** - * {@inheritdoc} - */ - public function getDistributorInstance() - { - return new KetamaPureRing(); - } - - /** - * @group disconnected - */ - public function testHash() - { - $ring = $this->getDistributorInstance(); - list(, $hash) = unpack('V', md5('foobar', true)); - - $this->assertEquals($hash, $ring->hash('foobar')); - } - - /** - * @group disconnected - */ - public function testSingleNodeInRing() - { - $node = '127.0.0.1:7000'; - - $ring = $this->getDistributorInstance(); - $ring->add($node); - - $expected = array_fill(0, 20, $node); - $actual = $this->getNodes($ring, 20); - - $this->assertSame($expected, $actual); - } - - /** - * @group disconnected - */ - public function testMultipleNodesInRing() - { - $nodes = array( - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7002', - ); - - $ring = $this->getDistributorInstance(); - foreach ($nodes as $node) { - $ring->add($node); - } - - $expected = array( - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7002', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7002', - '127.0.0.1:7000', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7002', - '127.0.0.1:7000', - '127.0.0.1:7002', - '127.0.0.1:7001', - '127.0.0.1:7002', - ); - - $actual = $this->getNodes($ring, 20); - - $this->assertSame($expected, $actual); - } - - /** - * @group disconnected - */ - public function testSubsequendAddAndRemoveFromRing() - { - $ring = $this->getDistributorInstance(); - - $expected1 = array_fill(0, 10, '127.0.0.1:7000'); - $expected3 = array_fill(0, 10, '127.0.0.1:7001'); - $expected2 = array( - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7001', - '127.0.0.1:7000', - '127.0.0.1:7001', - ); - - $ring->add('127.0.0.1:7000'); - $actual1 = $this->getNodes($ring, 10); - - $ring->add('127.0.0.1:7001'); - $actual2 = $this->getNodes($ring, 10); - - $ring->remove('127.0.0.1:7000'); - $actual3 = $this->getNodes($ring, 10); - - $this->assertSame($expected1, $actual1); - $this->assertSame($expected2, $actual2); - $this->assertSame($expected3, $actual3); - } - - /** - * @todo This tests should be moved in Predis\Cluster\Distribution\DistributionStrategyTestCase - * @group disconnected - */ - public function testCallbackToGetNodeHash() - { - $node = '127.0.0.1:7000'; - $callable = $this->getMock('stdClass', array('__invoke')); - - $callable->expects($this->once()) - ->method('__invoke') - ->with($node) - ->will($this->returnValue($node)); - - $ring = new KetamaPureRing($callable); - $ring->add($node); - - $this->getNodes($ring); - } -} diff --git a/vendor/predis/predis/tests/Predis/Cluster/PredisClusterHashStrategyTest.php b/vendor/predis/predis/tests/Predis/Cluster/PredisClusterHashStrategyTest.php deleted file mode 100644 index b9bdb9c7d..000000000 --- a/vendor/predis/predis/tests/Predis/Cluster/PredisClusterHashStrategyTest.php +++ /dev/null @@ -1,374 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster; - -use PredisTestCase; -use Predis\Cluster\Distribution\HashRing; -use Predis\Profile\ServerProfile; - -/** - * - */ -class PredisClusterHashStrategyTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testSupportsKeyTags() - { - // NOTE: 32 and 64 bits PHP runtimes can produce different hash values. - $expected = PHP_INT_SIZE == 4 ? -1938594527 : 2356372769; - - $strategy = $this->getHashStrategy(); - - $this->assertSame($expected, $strategy->getKeyHash('{foo}')); - $this->assertSame($expected, $strategy->getKeyHash('{foo}:bar')); - $this->assertSame($expected, $strategy->getKeyHash('{foo}:baz')); - $this->assertSame($expected, $strategy->getKeyHash('bar:{foo}:bar')); - - $this->assertSame(0, $strategy->getKeyHash('')); - $this->assertSame(0, $strategy->getKeyHash('{}')); - } - - /** - * @group disconnected - */ - public function testSupportedCommands() - { - $strategy = $this->getHashStrategy(); - - $this->assertSame($this->getExpectedCommands(), $strategy->getSupportedCommands()); - } - - /** - * @group disconnected - */ - public function testReturnsNullOnUnsupportedCommand() - { - $strategy = $this->getHashStrategy(); - $command = ServerProfile::getDevelopment()->createCommand('ping'); - - $this->assertNull($strategy->getHash($command)); - } - - /** - * @group disconnected - */ - public function testFirstKeyCommands() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('key'); - - foreach ($this->getExpectedCommands('keys-first') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testAllKeysCommands() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('{key}:1', '{key}:2', '{key}:3', '{key}:4'); - - foreach ($this->getExpectedCommands('keys-all') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testInterleavedKeysCommands() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('{key}:1', 'value1', '{key}:2', 'value2'); - - foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForBlockingListCommands() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('{key}:1', '{key}:2', 10); - - foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForZsetAggregationCommands() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('{key}:destination', 2, '{key}:1', '{key}:1', array('aggregate' => 'SUM')); - - foreach ($this->getExpectedCommands('keys-zaggregated') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForBitOpCommand() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('AND', '{key}:destination', '{key}:src:1', '{key}:src:2'); - - foreach ($this->getExpectedCommands('keys-bitop') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForScriptCommand() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('%SCRIPT%', 2, '{key}:1', '{key}:2', 'value1', 'value2'); - - foreach ($this->getExpectedCommands('keys-script') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForScriptedCommand() - { - $strategy = $this->getHashStrategy(); - $arguments = array('{key}:1', '{key}:2', 'value1', 'value2'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue('return true')); - $command->expects($this->exactly(2)) - ->method('getKeysCount') - ->will($this->returnValue(2)); - $command->setArguments($arguments); - - $this->assertNotNull($strategy->getHash($command), "Scripted Command [{$command->getId()}]"); - } - - /** - * @group disconnected - */ - public function testUnsettingCommandHandler() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - - $strategy->setCommandHandler('set'); - $strategy->setCommandHandler('get', null); - - $command = $profile->createCommand('set', array('key', 'value')); - $this->assertNull($strategy->getHash($command)); - - $command = $profile->createCommand('get', array('key')); - $this->assertNull($strategy->getHash($command)); - } - - /** - * @group disconnected - */ - public function testSettingCustomCommandHandler() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - - $callable = $this->getMock('stdClass', array('__invoke')); - $callable->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Command\CommandInterface')) - ->will($this->returnValue('key')); - - $strategy->setCommandHandler('get', $callable); - - $command = $profile->createCommand('get', array('key')); - $this->assertNotNull($strategy->getHash($command)); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Creates the default hash strategy object. - * - * @return CommandHashStrategyInterface - */ - protected function getHashStrategy() - { - $distributor = new HashRing(); - $hashGenerator = $distributor->getHashGenerator(); - $strategy = new PredisClusterHashStrategy($hashGenerator); - - return $strategy; - } - - /** - * Returns the list of expected supported commands. - * - * @param string $type Optional type of command (based on its keys) - * @return array - */ - protected function getExpectedCommands($type = null) - { - $commands = array( - /* commands operating on the key space */ - 'EXISTS' => 'keys-first', - 'DEL' => 'keys-all', - 'TYPE' => 'keys-first', - 'EXPIRE' => 'keys-first', - 'EXPIREAT' => 'keys-first', - 'PERSIST' => 'keys-first', - 'PEXPIRE' => 'keys-first', - 'PEXPIREAT' => 'keys-first', - 'TTL' => 'keys-first', - 'PTTL' => 'keys-first', - 'SORT' => 'keys-first', // TODO - 'DUMP' => 'keys-first', - 'RESTORE' => 'keys-first', - - /* commands operating on string values */ - 'APPEND' => 'keys-first', - 'DECR' => 'keys-first', - 'DECRBY' => 'keys-first', - 'GET' => 'keys-first', - 'GETBIT' => 'keys-first', - 'MGET' => 'keys-all', - 'SET' => 'keys-first', - 'GETRANGE' => 'keys-first', - 'GETSET' => 'keys-first', - 'INCR' => 'keys-first', - 'INCRBY' => 'keys-first', - 'SETBIT' => 'keys-first', - 'SETEX' => 'keys-first', - 'MSET' => 'keys-interleaved', - 'MSETNX' => 'keys-interleaved', - 'SETNX' => 'keys-first', - 'SETRANGE' => 'keys-first', - 'STRLEN' => 'keys-first', - 'SUBSTR' => 'keys-first', - 'BITOP' => 'keys-bitop', - 'BITCOUNT' => 'keys-first', - - /* commands operating on lists */ - 'LINSERT' => 'keys-first', - 'LINDEX' => 'keys-first', - 'LLEN' => 'keys-first', - 'LPOP' => 'keys-first', - 'RPOP' => 'keys-first', - 'RPOPLPUSH' => 'keys-all', - 'BLPOP' => 'keys-blockinglist', - 'BRPOP' => 'keys-blockinglist', - 'BRPOPLPUSH' => 'keys-blockinglist', - 'LPUSH' => 'keys-first', - 'LPUSHX' => 'keys-first', - 'RPUSH' => 'keys-first', - 'RPUSHX' => 'keys-first', - 'LRANGE' => 'keys-first', - 'LREM' => 'keys-first', - 'LSET' => 'keys-first', - 'LTRIM' => 'keys-first', - - /* commands operating on sets */ - 'SADD' => 'keys-first', - 'SCARD' => 'keys-first', - 'SDIFF' => 'keys-all', - 'SDIFFSTORE' => 'keys-all', - 'SINTER' => 'keys-all', - 'SINTERSTORE' => 'keys-all', - 'SUNION' => 'keys-all', - 'SUNIONSTORE' => 'keys-all', - 'SISMEMBER' => 'keys-first', - 'SMEMBERS' => 'keys-first', - 'SSCAN' => 'keys-first', - 'SPOP' => 'keys-first', - 'SRANDMEMBER' => 'keys-first', - 'SREM' => 'keys-first', - - /* commands operating on sorted sets */ - 'ZADD' => 'keys-first', - 'ZCARD' => 'keys-first', - 'ZCOUNT' => 'keys-first', - 'ZINCRBY' => 'keys-first', - 'ZINTERSTORE' => 'keys-zaggregated', - 'ZRANGE' => 'keys-first', - 'ZRANGEBYSCORE' => 'keys-first', - 'ZRANK' => 'keys-first', - 'ZREM' => 'keys-first', - 'ZREMRANGEBYRANK' => 'keys-first', - 'ZREMRANGEBYSCORE' => 'keys-first', - 'ZREVRANGE' => 'keys-first', - 'ZREVRANGEBYSCORE' => 'keys-first', - 'ZREVRANK' => 'keys-first', - 'ZSCORE' => 'keys-first', - 'ZUNIONSTORE' => 'keys-zaggregated', - 'ZSCAN' => 'keys-first', - - /* commands operating on hashes */ - 'HDEL' => 'keys-first', - 'HEXISTS' => 'keys-first', - 'HGET' => 'keys-first', - 'HGETALL' => 'keys-first', - 'HMGET' => 'keys-first', - 'HMSET' => 'keys-first', - 'HINCRBY' => 'keys-first', - 'HINCRBYFLOAT' => 'keys-first', - 'HKEYS' => 'keys-first', - 'HLEN' => 'keys-first', - 'HSET' => 'keys-first', - 'HSETNX' => 'keys-first', - 'HVALS' => 'keys-first', - 'HSCAN' => 'keys-first', - - /* scripting */ - 'EVAL' => 'keys-script', - 'EVALSHA' => 'keys-script', - ); - - if (isset($type)) { - $commands = array_filter($commands, function ($expectedType) use ($type) { - return $expectedType === $type; - }); - } - - return array_keys($commands); - } -} diff --git a/vendor/predis/predis/tests/Predis/Cluster/RedisClusterHashStrategyTest.php b/vendor/predis/predis/tests/Predis/Cluster/RedisClusterHashStrategyTest.php deleted file mode 100644 index 3bc349381..000000000 --- a/vendor/predis/predis/tests/Predis/Cluster/RedisClusterHashStrategyTest.php +++ /dev/null @@ -1,367 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Cluster; - -use PredisTestCase; -use Predis\Profile\ServerProfile; - -/** - * - */ -class RedisClusterHashStrategyTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testDoesNotSupportKeyTags() - { - $strategy = $this->getHashStrategy(); - - $this->assertSame(35910, $strategy->getKeyHash('{foo}')); - $this->assertSame(60032, $strategy->getKeyHash('{foo}:bar')); - $this->assertSame(27528, $strategy->getKeyHash('{foo}:baz')); - $this->assertSame(34064, $strategy->getKeyHash('bar:{foo}:bar')); - } - - /** - * @group disconnected - */ - public function testSupportedCommands() - { - $strategy = $this->getHashStrategy(); - - $this->assertSame($this->getExpectedCommands(), $strategy->getSupportedCommands()); - } - - /** - * @group disconnected - */ - public function testReturnsNullOnUnsupportedCommand() - { - $strategy = $this->getHashStrategy(); - $command = ServerProfile::getDevelopment()->createCommand('ping'); - - $this->assertNull($strategy->getHash($command)); - } - - /** - * @group disconnected - */ - public function testFirstKeyCommands() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('key'); - - foreach ($this->getExpectedCommands('keys-first') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testAllKeysCommandsWithOneKey() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('key'); - - foreach ($this->getExpectedCommands('keys-all') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testAllKeysCommandsWithMoreKeys() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('key1', 'key2'); - - foreach ($this->getExpectedCommands('keys-all') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testInterleavedKeysCommandsWithOneKey() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('key:1', 'value1'); - - foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testInterleavedKeysCommandsWithMoreKeys() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('key:1', 'value1', 'key:2', 'value2'); - - foreach ($this->getExpectedCommands('keys-interleaved') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForBlockingListCommandsWithOneKey() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('key:1', 10); - - foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForBlockingListCommandsWithMoreKeys() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('key:1', 'key:2', 10); - - foreach ($this->getExpectedCommands('keys-blockinglist') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForScriptCommand() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - $arguments = array('%SCRIPT%', 1, 'key:1', 'value1'); - - foreach ($this->getExpectedCommands('keys-script') as $commandID) { - $command = $profile->createCommand($commandID, $arguments); - $this->assertNotNull($strategy->getHash($command), $commandID); - } - } - - /** - * @group disconnected - */ - public function testKeysForScriptedCommand() - { - $strategy = $this->getHashStrategy(); - $arguments = array('key:1', 'value1'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue('return true')); - $command->expects($this->exactly(2)) - ->method('getKeysCount') - ->will($this->returnValue(1)); - $command->setArguments($arguments); - - $this->assertNotNull($strategy->getHash($command), "Scripted Command [{$command->getId()}]"); - } - - /** - * @group disconnected - */ - public function testUnsettingCommandHandler() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - - $strategy->setCommandHandler('set'); - $strategy->setCommandHandler('get', null); - - $command = $profile->createCommand('set', array('key', 'value')); - $this->assertNull($strategy->getHash($command)); - - $command = $profile->createCommand('get', array('key')); - $this->assertNull($strategy->getHash($command)); - } - - /** - * @group disconnected - */ - public function testSettingCustomCommandHandler() - { - $strategy = $this->getHashStrategy(); - $profile = ServerProfile::getDevelopment(); - - $callable = $this->getMock('stdClass', array('__invoke')); - $callable->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Command\CommandInterface')) - ->will($this->returnValue('key')); - - $strategy->setCommandHandler('get', $callable); - - $command = $profile->createCommand('get', array('key')); - $this->assertNotNull($strategy->getHash($command)); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Creates the default hash strategy object. - * - * @return CommandHashStrategyInterface - */ - protected function getHashStrategy() - { - $strategy = new RedisClusterHashStrategy(); - - return $strategy; - } - - /** - * Returns the list of expected supported commands. - * - * @param string $type Optional type of command (based on its keys) - * @return array - */ - protected function getExpectedCommands($type = null) - { - $commands = array( - /* commands operating on the key space */ - 'EXISTS' => 'keys-first', - 'DEL' => 'keys-all', - 'TYPE' => 'keys-first', - 'EXPIRE' => 'keys-first', - 'EXPIREAT' => 'keys-first', - 'PERSIST' => 'keys-first', - 'PEXPIRE' => 'keys-first', - 'PEXPIREAT' => 'keys-first', - 'TTL' => 'keys-first', - 'PTTL' => 'keys-first', - 'SORT' => 'keys-first', // TODO - - /* commands operating on string values */ - 'APPEND' => 'keys-first', - 'DECR' => 'keys-first', - 'DECRBY' => 'keys-first', - 'GET' => 'keys-first', - 'GETBIT' => 'keys-first', - 'MGET' => 'keys-all', - 'SET' => 'keys-first', - 'GETRANGE' => 'keys-first', - 'GETSET' => 'keys-first', - 'INCR' => 'keys-first', - 'INCRBY' => 'keys-first', - 'SETBIT' => 'keys-first', - 'SETEX' => 'keys-first', - 'MSET' => 'keys-interleaved', - 'MSETNX' => 'keys-interleaved', - 'SETNX' => 'keys-first', - 'SETRANGE' => 'keys-first', - 'STRLEN' => 'keys-first', - 'SUBSTR' => 'keys-first', - 'BITCOUNT' => 'keys-first', - - /* commands operating on lists */ - 'LINSERT' => 'keys-first', - 'LINDEX' => 'keys-first', - 'LLEN' => 'keys-first', - 'LPOP' => 'keys-first', - 'RPOP' => 'keys-first', - 'BLPOP' => 'keys-blockinglist', - 'BRPOP' => 'keys-blockinglist', - 'LPUSH' => 'keys-first', - 'LPUSHX' => 'keys-first', - 'RPUSH' => 'keys-first', - 'RPUSHX' => 'keys-first', - 'LRANGE' => 'keys-first', - 'LREM' => 'keys-first', - 'LSET' => 'keys-first', - 'LTRIM' => 'keys-first', - - /* commands operating on sets */ - 'SADD' => 'keys-first', - 'SCARD' => 'keys-first', - 'SISMEMBER' => 'keys-first', - 'SMEMBERS' => 'keys-first', - 'SSCAN' => 'keys-first', - 'SPOP' => 'keys-first', - 'SRANDMEMBER' => 'keys-first', - 'SREM' => 'keys-first', - - /* commands operating on sorted sets */ - 'ZADD' => 'keys-first', - 'ZCARD' => 'keys-first', - 'ZCOUNT' => 'keys-first', - 'ZINCRBY' => 'keys-first', - 'ZRANGE' => 'keys-first', - 'ZRANGEBYSCORE' => 'keys-first', - 'ZRANK' => 'keys-first', - 'ZREM' => 'keys-first', - 'ZREMRANGEBYRANK' => 'keys-first', - 'ZREMRANGEBYSCORE' => 'keys-first', - 'ZREVRANGE' => 'keys-first', - 'ZREVRANGEBYSCORE' => 'keys-first', - 'ZREVRANK' => 'keys-first', - 'ZSCORE' => 'keys-first', - 'ZSCAN' => 'keys-first', - - /* commands operating on hashes */ - 'HDEL' => 'keys-first', - 'HEXISTS' => 'keys-first', - 'HGET' => 'keys-first', - 'HGETALL' => 'keys-first', - 'HMGET' => 'keys-first', - 'HMSET' => 'keys-first', - 'HINCRBY' => 'keys-first', - 'HINCRBYFLOAT' => 'keys-first', - 'HKEYS' => 'keys-first', - 'HLEN' => 'keys-first', - 'HSET' => 'keys-first', - 'HSETNX' => 'keys-first', - 'HVALS' => 'keys-first', - 'HSCAN' => 'keys-first', - - /* scripting */ - 'EVAL' => 'keys-script', - 'EVALSHA' => 'keys-script', - ); - - if (isset($type)) { - $commands = array_filter($commands, function ($expectedType) use ($type) { - return $expectedType === $type; - }); - } - - return array_keys($commands); - } -} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/HashKeyTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/HashKeyTest.php deleted file mode 100644 index 4c22a83db..000000000 --- a/vendor/predis/predis/tests/Predis/Collection/Iterator/HashKeyTest.php +++ /dev/null @@ -1,480 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use PredisTestCase; -use Predis\Client; -use Predis\Profile\ServerProfile; - -/** - * @group realm-iterators - */ -class HashKeyTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The specified server profile does not support the `HSCAN` command. - */ - public function testThrowsExceptionOnInvalidServerProfile() - { - $client = $this->getMock('Predis\ClientInterface'); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.0'))); - - $iterator = new HashKey($client, 'key:hash'); - } - - /** - * @group disconnected - */ - public function testIterationWithNoResults() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->once()) - ->method('hscan') - ->with('key:hash', 0, array()) - ->will($this->returnValue(array(0, array()))); - - $iterator = new HashKey($client, 'key:hash'); - - $iterator->rewind(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnSingleFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->once()) - ->method('hscan') - ->with('key:hash', 0, array()) - ->will($this->returnValue(array(0, array( - 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', 'field:3rd' => 'value:3rd', - )))); - - $iterator = new HashKey($client, 'key:hash'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:3rd', $iterator->current()); - $this->assertSame('field:3rd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array()) - ->will($this->returnValue(array(2, array( - 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', - )))); - $client->expects($this->at(2)) - ->method('hscan') - ->with('key:hash', 2, array()) - ->will($this->returnValue(array(0, array( - 'field:3rd' => 'value:3rd', - )))); - - $iterator = new HashKey($client, 'key:hash'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:3rd', $iterator->current()); - $this->assertSame('field:3rd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetchesAndHoleInFirstFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array()) - ->will($this->returnValue(array(4, array()))); - $client->expects($this->at(2)) - ->method('hscan') - ->with('key:hash', 4, array()) - ->will($this->returnValue(array(0, array( - 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', - )))); - - $iterator = new HashKey($client, 'key:hash'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetchesAndHoleInMidFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array()) - ->will($this->returnValue(array(2, array( - 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', - )))); - $client->expects($this->at(2)) - ->method('hscan') - ->with('key:hash', 2, array()) - ->will($this->returnValue(array(5, array()))); - $client->expects($this->at(3)) - ->method('hscan') - ->with('key:hash', 5, array()) - ->will($this->returnValue(array(0, array( - 'field:3rd' => 'value:3rd', - )))); - - $iterator = new HashKey($client, 'key:hash'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:3rd', $iterator->current()); - $this->assertSame('field:3rd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionMatch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array('MATCH' => 'field:*')) - ->will($this->returnValue(array(2, array( - 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', - )))); - - $iterator = new HashKey($client, 'key:hash', 'field:*'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionMatchOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array('MATCH' => 'field:*')) - ->will($this->returnValue(array(1, array( - 'field:1st' => 'value:1st', - )))); - $client->expects($this->at(2)) - ->method('hscan') - ->with('key:hash', 1, array('MATCH' => 'field:*')) - ->will($this->returnValue(array(0, array( - 'field:2nd' => 'value:2nd', - )))); - - $iterator = new HashKey($client, 'key:hash', 'field:*'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionCount() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array('COUNT' => 2)) - ->will($this->returnValue(array(0, array( - 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', - )))); - - $iterator = new HashKey($client, 'key:hash', null, 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionCountOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array('COUNT' => 1)) - ->will($this->returnValue(array(1, array( - 'field:1st' => 'value:1st', - )))); - $client->expects($this->at(2)) - ->method('hscan') - ->with('key:hash', 1, array('COUNT' => 1)) - ->will($this->returnValue(array(0, array( - 'field:2nd' => 'value:2nd', - )))); - - $iterator = new HashKey($client, 'key:hash', null, 1); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionsMatchAndCount() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array('MATCH' => 'field:*', 'COUNT' => 2)) - ->will($this->returnValue(array(0, array( - 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', - )))); - - $iterator = new HashKey($client, 'key:hash', 'field:*', 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionsMatchAndCountOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('hscan') - ->with('key:hash', 0, array('MATCH' => 'field:*', 'COUNT' => 1)) - ->will($this->returnValue(array(1, array( - 'field:1st' => 'value:1st', - )))); - $client->expects($this->at(2)) - ->method('hscan') - ->with('key:hash', 1, array('MATCH' => 'field:*', 'COUNT' => 1)) - ->will($this->returnValue(array(0, array( - 'field:2nd' => 'value:2nd', - )))); - - $iterator = new HashKey($client, 'key:hash', 'field:*', 1); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationRewindable() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'hscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->exactly(2)) - ->method('hscan') - ->with('key:hash', 0, array()) - ->will($this->returnValue(array(0, array( - 'field:1st' => 'value:1st', 'field:2nd' => 'value:2nd', - )))); - - $iterator = new HashKey($client, 'key:hash'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:1st', $iterator->current()); - $this->assertSame('field:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('value:2nd', $iterator->current()); - $this->assertSame('field:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/KeyspaceTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/KeyspaceTest.php deleted file mode 100644 index 70b4a79ab..000000000 --- a/vendor/predis/predis/tests/Predis/Collection/Iterator/KeyspaceTest.php +++ /dev/null @@ -1,448 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use PredisTestCase; -use Predis\Client; -use Predis\Profile\ServerProfile; - -/** - * @group realm-iterators - */ -class KeyspaceTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The specified server profile does not support the `SCAN` command. - */ - public function testThrowsExceptionOnInvalidServerProfile() - { - $client = $this->getMock('Predis\ClientInterface'); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.0'))); - - $iterator = new Keyspace($client); - } - - /** - * @group disconnected - */ - public function testIterationWithNoResults() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->once()) - ->method('scan') - ->with(0, array()) - ->will($this->returnValue(array(0, array()))); - - $iterator = new Keyspace($client); - - $iterator->rewind(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnSingleFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->once()) - ->method('scan') - ->with(0, array()) - ->will($this->returnValue(array(0, array('key:1st', 'key:2nd', 'key:3rd')))); - - $iterator = new Keyspace($client); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:3rd', $iterator->current()); - $this->assertSame(2, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array()) - ->will($this->returnValue(array(2, array('key:1st', 'key:2nd')))); - $client->expects($this->at(2)) - ->method('scan') - ->with(2, array()) - ->will($this->returnValue(array(0, array('key:3rd')))); - - $iterator = new Keyspace($client); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:3rd', $iterator->current()); - $this->assertSame(2, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetchesAndHoleInFirstFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array()) - ->will($this->returnValue(array(4, array()))); - $client->expects($this->at(2)) - ->method('scan') - ->with(4, array()) - ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - - $iterator = new Keyspace($client); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetchesAndHoleInMidFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array()) - ->will($this->returnValue(array(2, array('key:1st', 'key:2nd')))); - $client->expects($this->at(2)) - ->method('scan') - ->with(2, array()) - ->will($this->returnValue(array(5, array()))); - $client->expects($this->at(3)) - ->method('scan') - ->with(5, array()) - ->will($this->returnValue(array(0, array('key:3rd')))); - - $iterator = new Keyspace($client); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:3rd', $iterator->current()); - $this->assertSame(2, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionMatch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array('MATCH' => 'key:*')) - ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - - $iterator = new Keyspace($client, 'key:*'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionMatchOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array('MATCH' => 'key:*')) - ->will($this->returnValue(array(1, array('key:1st')))); - $client->expects($this->at(2)) - ->method('scan') - ->with(1, array('MATCH' => 'key:*')) - ->will($this->returnValue(array(0, array('key:2nd')))); - - $iterator = new Keyspace($client, 'key:*'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionCount() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array('COUNT' => 2)) - ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - - $iterator = new Keyspace($client, null, 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionCountOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array('COUNT' => 1)) - ->will($this->returnValue(array(1, array('key:1st')))); - $client->expects($this->at(2)) - ->method('scan') - ->with(1, array('COUNT' => 1)) - ->will($this->returnValue(array(0, array('key:2nd')))); - - $iterator = new Keyspace($client, null, 1); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionsMatchAndCount() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array('MATCH' => 'key:*', 'COUNT' => 2)) - ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - - $iterator = new Keyspace($client, 'key:*', 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionsMatchAndCountOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('scan') - ->with(0, array('MATCH' => 'key:*', 'COUNT' => 1)) - ->will($this->returnValue(array(1, array('key:1st')))); - $client->expects($this->at(2)) - ->method('scan') - ->with(1, array('MATCH' => 'key:*', 'COUNT' => 1)) - ->will($this->returnValue(array(0, array('key:2nd')))); - - $iterator = new Keyspace($client, 'key:*', 1); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationRewindable() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'scan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->exactly(2)) - ->method('scan') - ->with(0, array()) - ->will($this->returnValue(array(0, array('key:1st', 'key:2nd')))); - - $iterator = new Keyspace($client); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('key:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1, $iterator->key()); - $this->assertSame('key:2nd', $iterator->current()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/ListKeyTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/ListKeyTest.php deleted file mode 100644 index a0470d344..000000000 --- a/vendor/predis/predis/tests/Predis/Collection/Iterator/ListKeyTest.php +++ /dev/null @@ -1,248 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use PredisTestCase; -use Predis\Client; -use Predis\Profile\ServerProfile; - -/** - * @group realm-iterators - */ -class ListKeyTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testIterationWithNoResults() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); - $client->expects($this->once()) - ->method('lrange') - ->with('key:list', 0, 9) - ->will($this->returnValue(array())); - - $iterator = new ListKey($client, 'key:list'); - - $iterator->rewind(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnSingleFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); - $client->expects($this->once()) - ->method('lrange') - ->with('key:list', 0, 9) - ->will($this->returnValue(array('item:1', 'item:2', 'item:3'))); - - $iterator = new ListKey($client, 'key:list'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:1', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:2', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:3', $iterator->current()); - $this->assertSame(2, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); - $client->expects($this->at(1)) - ->method('lrange') - ->with('key:list', 0, 9) - ->will($this->returnValue(array( - 'item:1', 'item:2', 'item:3', 'item:4', 'item:5', 'item:6', 'item:7', 'item:8', 'item:9', 'item:10' - ))); - $client->expects($this->at(2)) - ->method('lrange') - ->with('key:list', 10, 19) - ->will($this->returnValue(array('item:11', 'item:12'))); - - $iterator = new ListKey($client, 'key:list'); - - for ($i = 1, $iterator->rewind(); $i <= 12; $i++, $iterator->next()) { - $this->assertTrue($iterator->valid()); - $this->assertSame("item:$i", $iterator->current()); - $this->assertSame($i - 1, $iterator->key()); - } - - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage The $count argument must be a positive integer. - */ - public function testThrowsExceptionOnConstructorWithNonIntegerCountParameter() - { - $client = $this->getMock('Predis\ClientInterface'); - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); - - $iterator = new ListKey($client, 'key:list', 'wrong'); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage The $count argument must be a positive integer. - */ - public function testThrowsExceptionOnConstructorWithNegativeCountParameter() - { - $client = $this->getMock('Predis\ClientInterface'); - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); - - $iterator = new ListKey($client, 'key:list', 'wrong'); - } - - /** - * @group disconnected - */ - public function testIterationWithCountParameter() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); - $client->expects($this->at(1)) - ->method('lrange') - ->with('key:list', 0, 4) - ->will($this->returnValue(array('item:1', 'item:2'))); - - $iterator = new ListKey($client, 'key:list', 5); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:1', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:2', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithCountParameterOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); - $client->expects($this->at(1)) - ->method('lrange') - ->with('key:list', 0, 1) - ->will($this->returnValue(array('item:1', 'item:2'))); - $client->expects($this->at(2)) - ->method('lrange') - ->with('key:list', 2, 3) - ->will($this->returnValue(array('item:3'))); - - $iterator = new ListKey($client, 'key:list', 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:1', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:2', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:3', $iterator->current()); - $this->assertSame(2, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationRewindable() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'lrange')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::getDefault())); - $client->expects($this->exactly(2)) - ->method('lrange') - ->with('key:list', 0, 9) - ->will($this->returnValue(array('item:1', 'item:2'))); - - $iterator = new ListKey($client, 'key:list'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:1', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('item:1', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1, $iterator->key()); - $this->assertSame('item:2', $iterator->current()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/SetKeyTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/SetKeyTest.php deleted file mode 100644 index e8f89816a..000000000 --- a/vendor/predis/predis/tests/Predis/Collection/Iterator/SetKeyTest.php +++ /dev/null @@ -1,448 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use PredisTestCase; -use Predis\Client; -use Predis\Profile\ServerProfile; - -/** - * @group realm-iterators - */ -class SetKeyTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The specified server profile does not support the `SSCAN` command. - */ - public function testThrowsExceptionOnInvalidServerProfile() - { - $client = $this->getMock('Predis\ClientInterface'); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.0'))); - - $iterator = new SetKey($client, 'key:set'); - } - - /** - * @group disconnected - */ - public function testIterationWithNoResults() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->once()) - ->method('sscan') - ->with('key:set', 0, array()) - ->will($this->returnValue(array(0, array()))); - - $iterator = new SetKey($client, 'key:set'); - - $iterator->rewind(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnSingleFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->once()) - ->method('sscan') - ->with('key:set', 0, array()) - ->will($this->returnValue(array(0, array('member:1st', 'member:2nd', 'member:3rd')))); - - $iterator = new SetKey($client, 'key:set'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:3rd', $iterator->current()); - $this->assertSame(2, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array()) - ->will($this->returnValue(array(2, array('member:1st', 'member:2nd')))); - $client->expects($this->at(2)) - ->method('sscan') - ->with('key:set', 2, array()) - ->will($this->returnValue(array(0, array('member:3rd')))); - - $iterator = new SetKey($client, 'key:set'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:3rd', $iterator->current()); - $this->assertSame(2, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetchesAndHoleInFirstFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array()) - ->will($this->returnValue(array(4, array()))); - $client->expects($this->at(2)) - ->method('sscan') - ->with('key:set', 4, array()) - ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - - $iterator = new SetKey($client, 'key:set'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetchesAndHoleInMidFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array()) - ->will($this->returnValue(array(2, array('member:1st', 'member:2nd')))); - $client->expects($this->at(2)) - ->method('sscan') - ->with('key:set', 2, array()) - ->will($this->returnValue(array(5, array()))); - $client->expects($this->at(3)) - ->method('sscan') - ->with('key:set', 5, array()) - ->will($this->returnValue(array(0, array('member:3rd')))); - - $iterator = new SetKey($client, 'key:set'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:3rd', $iterator->current()); - $this->assertSame(2, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionMatch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array('MATCH' => 'member:*')) - ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - - $iterator = new SetKey($client, 'key:set', 'member:*'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionMatchOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array('MATCH' => 'member:*')) - ->will($this->returnValue(array(1, array('member:1st')))); - $client->expects($this->at(2)) - ->method('sscan') - ->with('key:set', 1, array('MATCH' => 'member:*')) - ->will($this->returnValue(array(0, array('member:2nd')))); - - $iterator = new SetKey($client, 'key:set', 'member:*'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionCount() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array('COUNT' => 2)) - ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - - $iterator = new SetKey($client, 'key:set', null, 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionCountOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array('COUNT' => 1)) - ->will($this->returnValue(array(1, array('member:1st')))); - $client->expects($this->at(2)) - ->method('sscan') - ->with('key:set', 1, array('COUNT' => 1)) - ->will($this->returnValue(array(0, array('member:2nd')))); - - $iterator = new SetKey($client, 'key:set', null, 1); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionsMatchAndCount() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) - ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - - $iterator = new SetKey($client, 'key:set', 'member:*', 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionsMatchAndCountOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('sscan') - ->with('key:set', 0, array('MATCH' => 'member:*', 'COUNT' => 1)) - ->will($this->returnValue(array(1, array('member:1st')))); - $client->expects($this->at(2)) - ->method('sscan') - ->with('key:set', 1, array('MATCH' => 'member:*', 'COUNT' => 1)) - ->will($this->returnValue(array(0, array('member:2nd')))); - - $iterator = new SetKey($client, 'key:set', 'member:*', 1); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationRewindable() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'sscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->exactly(2)) - ->method('sscan') - ->with('key:set', 0, array()) - ->will($this->returnValue(array(0, array('member:1st', 'member:2nd')))); - - $iterator = new SetKey($client, 'key:set'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:1st', $iterator->current()); - $this->assertSame(0, $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame('member:2nd', $iterator->current()); - $this->assertSame(1, $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Collection/Iterator/SortedSetKeyTest.php b/vendor/predis/predis/tests/Predis/Collection/Iterator/SortedSetKeyTest.php deleted file mode 100644 index 955a69973..000000000 --- a/vendor/predis/predis/tests/Predis/Collection/Iterator/SortedSetKeyTest.php +++ /dev/null @@ -1,480 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Collection\Iterator; - -use PredisTestCase; -use Predis\Client; -use Predis\Profile\ServerProfile; - -/** - * @group realm-iterators - */ -class SortedSetTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The specified server profile does not support the `ZSCAN` command. - */ - public function testThrowsExceptionOnInvalidServerProfile() - { - $client = $this->getMock('Predis\ClientInterface'); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.0'))); - - $iterator = new SortedSetKey($client, 'key:zset'); - } - - /** - * @group disconnected - */ - public function testIterationWithNoResults() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->once()) - ->method('zscan') - ->with('key:zset', 0, array()) - ->will($this->returnValue(array(0, array()))); - - $iterator = new SortedSetKey($client, 'key:zset'); - - $iterator->rewind(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnSingleFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->once()) - ->method('zscan') - ->with('key:zset', 0, array()) - ->will($this->returnValue(array(0, array( - array('member:1st', 1.0), array('member:2nd', 2.0), array('member:3rd', 3.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(3.0, $iterator->current()); - $this->assertSame('member:3rd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array()) - ->will($this->returnValue(array(2, array( - array('member:1st', 1.0), array('member:2nd', 2.0), - )))); - $client->expects($this->at(2)) - ->method('zscan') - ->with('key:zset', 2, array()) - ->will($this->returnValue(array(0, array( - array('member:3rd', 3.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(3.0, $iterator->current()); - $this->assertSame('member:3rd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetchesAndHoleInFirstFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array()) - ->will($this->returnValue(array(4, array()))); - $client->expects($this->at(2)) - ->method('zscan') - ->with('key:zset', 4, array()) - ->will($this->returnValue(array(0, array( - array('member:1st', 1.0), array('member:2nd', 2.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationOnMultipleFetchesAndHoleInMidFetch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array()) - ->will($this->returnValue(array(2, array( - array('member:1st', 1.0), array('member:2nd', 2.0), - )))); - $client->expects($this->at(2)) - ->method('zscan') - ->with('key:zset', 2, array()) - ->will($this->returnValue(array(5, array()))); - $client->expects($this->at(3)) - ->method('zscan') - ->with('key:zset', 5, array()) - ->will($this->returnValue(array(0, array( - array('member:3rd', 3.0) - )))); - - $iterator = new SortedSetKey($client, 'key:zset'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(3.0, $iterator->current()); - $this->assertSame('member:3rd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionMatch() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array('MATCH' => 'member:*')) - ->will($this->returnValue(array(2, array( - array('member:1st', 1.0), array('member:2nd', 2.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset', 'member:*'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionMatchOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array('MATCH' => 'member:*')) - ->will($this->returnValue(array(1, array( - array('member:1st', 1.0), - )))); - $client->expects($this->at(2)) - ->method('zscan') - ->with('key:zset', 1, array('MATCH' => 'member:*')) - ->will($this->returnValue(array(0, array( - array('member:2nd', 2.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset', 'member:*'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionCount() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array('COUNT' => 2)) - ->will($this->returnValue(array(0, array( - array('member:1st', 1.0), array('member:2nd', 2.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset', null, 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionCountOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array('COUNT' => 1)) - ->will($this->returnValue(array(1, array( - array('member:1st', 1.0), - )))); - $client->expects($this->at(2)) - ->method('zscan') - ->with('key:zset', 1, array('COUNT' => 1)) - ->will($this->returnValue(array(0, array( - array('member:2nd', 2.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset', null, 1); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionsMatchAndCount() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 2)) - ->will($this->returnValue(array(0, array( - array('member:1st', 1.0), array('member:2nd', 2.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset', 'member:*', 2); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationWithOptionsMatchAndCountOnMultipleFetches() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->at(1)) - ->method('zscan') - ->with('key:zset', 0, array('MATCH' => 'member:*', 'COUNT' => 1)) - ->will($this->returnValue(array(1, array( - array('member:1st', 1.0), - )))); - $client->expects($this->at(2)) - ->method('zscan') - ->with('key:zset', 1, array('MATCH' => 'member:*', 'COUNT' => 1)) - ->will($this->returnValue(array(0, array( - array('member:2nd', 2.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset', 'member:*', 1); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } - - /** - * @group disconnected - */ - public function testIterationRewindable() - { - $client = $this->getMock('Predis\Client', array('getProfile', 'zscan')); - - $client->expects($this->any()) - ->method('getProfile') - ->will($this->returnValue(ServerProfile::get('2.8'))); - $client->expects($this->exactly(2)) - ->method('zscan') - ->with('key:zset', 0, array()) - ->will($this->returnValue(array(0, array( - array('member:1st', 1.0), array('member:2nd', 2.0), - )))); - - $iterator = new SortedSetKey($client, 'key:zset'); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->rewind(); - $this->assertTrue($iterator->valid()); - $this->assertSame(1.0, $iterator->current()); - $this->assertSame('member:1st', $iterator->key()); - - $iterator->next(); - $this->assertTrue($iterator->valid()); - $this->assertSame(2.0, $iterator->current()); - $this->assertSame('member:2nd', $iterator->key()); - - $iterator->next(); - $this->assertFalse($iterator->valid()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/CommandTest.php b/vendor/predis/predis/tests/Predis/Command/CommandTest.php deleted file mode 100644 index 627aada65..000000000 --- a/vendor/predis/predis/tests/Predis/Command/CommandTest.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -use PredisTestCase; - -/** - * - */ -class CommandTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testImplementsCorrectInterface() - { - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - - $this->assertInstanceOf('Predis\Command\CommandInterface', $command); - } - - /** - * @group disconnected - */ - public function testGetEmptyArguments() - { - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - - $this->assertEmpty($command->getArguments()); - } - - /** - * @group disconnected - */ - public function testSetRawArguments() - { - $arguments = array('1st', '2nd', '3rd'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->setRawArguments($arguments); - - $this->assertEquals($arguments, $command->getArguments()); - } - - /** - * @group disconnected - * - * @todo Since AbstractCommand::filterArguments is protected we cannot set an expectation - * for it when AbstractCommand::setArguments() is invoked. I wonder how we can do that. - */ - public function testSetArguments() - { - $arguments = array('1st', '2nd', '3rd'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->setArguments($arguments); - - $this->assertEquals($arguments, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testGetArgumentAtIndex() - { - $arguments = array('1st', '2nd', '3rd'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->setArguments($arguments); - - $this->assertEquals($arguments[0], $command->getArgument(0)); - $this->assertEquals($arguments[2], $command->getArgument(2)); - $this->assertNull($command->getArgument(10)); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $response = 'response-buffer'; - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - - $this->assertEquals($response, $command->parseResponse($response)); - } - - /** - * @group disconnected - */ - public function testSetAndGetHash() - { - $hash = "key-hash"; - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->setRawArguments(array('key')); - - $this->assertNull($command->getHash()); - - $command->setHash($hash); - $this->assertSame($hash, $command->getHash()); - - $command->setArguments(array('key')); - $this->assertNull($command->getHash()); - - $command->setHash($hash); - $command->setRawArguments(array('key')); - $this->assertNull($command->getHash()); - } - /** - * @group disconnected - */ - public function testToString() - { - $expected = 'SET key value'; - $arguments = array('key', 'value'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->expects($this->once())->method('getId')->will($this->returnValue('SET')); - - $command->setRawArguments($arguments); - - $this->assertEquals($expected, (string) $command); - } - - /** - * @group disconnected - */ - public function testToStringWithLongArguments() - { - $expected = 'SET key abcdefghijklmnopqrstuvwxyz012345[...]'; - $arguments = array('key', 'abcdefghijklmnopqrstuvwxyz0123456789'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->expects($this->once())->method('getId')->will($this->returnValue('SET')); - - $command->setRawArguments($arguments); - - $this->assertEquals($expected, (string) $command); - } - - /** - * @group disconnected - */ - public function testNormalizeArguments() - { - $arguments = array('arg1', 'arg2', 'arg3', 'arg4'); - - $this->assertSame($arguments, AbstractCommand::normalizeArguments($arguments)); - $this->assertSame($arguments, AbstractCommand::normalizeArguments(array($arguments))); - - $arguments = array(array(), array()); - $this->assertSame($arguments, AbstractCommand::normalizeArguments($arguments)); - - $arguments = array(new \stdClass()); - $this->assertSame($arguments, AbstractCommand::normalizeArguments($arguments)); - } - - /** - * @group disconnected - */ - public function testNormalizeVariadic() - { - $arguments = array('key', 'value1', 'value2', 'value3'); - - $this->assertSame($arguments, AbstractCommand::normalizeVariadic($arguments)); - $this->assertSame($arguments, AbstractCommand::normalizeVariadic(array('key', array('value1', 'value2', 'value3')))); - - $arguments = array(new \stdClass()); - $this->assertSame($arguments, AbstractCommand::normalizeVariadic($arguments)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionAuthTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionAuthTest.php deleted file mode 100644 index 6248a32ad..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ConnectionAuthTest.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-connection - */ -class ConnectionAuthTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ConnectionAuth'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'AUTH'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('password'); - $expected = array('password'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = null; - $expected = null; - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionEchoTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionEchoTest.php deleted file mode 100644 index 3d506c7ae..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ConnectionEchoTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-connection - */ -class ConnectionEchoTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ConnectionEcho'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ECHO'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('message'); - $expected = array('message'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = 'message'; - $expected = 'message'; - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group connected - */ - public function testAlwaysReturnsThePassedMessage() - { - $redis = $this->getClient(); - - $message = 'Can you hear me?'; - - $this->assertSame($message, $redis->echo($message)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionPingTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionPingTest.php deleted file mode 100644 index 725337dac..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ConnectionPingTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-connection - */ -class ConnectionPingTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ConnectionPing'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PING'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array(); - $expected = array(); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse('PONG')); - } - - /** - * @group connected - */ - public function testAlwaysReturnsTrue() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->ping()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionQuitTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionQuitTest.php deleted file mode 100644 index 1be47a54c..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ConnectionQuitTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-connection - */ -class ConnectionQuitTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ConnectionQuit'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'QUIT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array(); - $expected = array(); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(true)); - } - - /** - * @group connected - */ - public function testReturnsTrueWhenClosingConnection() - { - $redis = $this->getClient(); - $command = $this->getCommand(); - - $this->assertTrue($redis->executeCommand($command)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ConnectionSelectTest.php b/vendor/predis/predis/tests/Predis/Command/ConnectionSelectTest.php deleted file mode 100644 index 6e253fa82..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ConnectionSelectTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-connection - */ -class ConnectionSelectTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ConnectionSelect'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SELECT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array(10); - $expected = array(10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(true)); - } - - /** - * @group connected - */ - public function testCanSelectDifferentDatabase() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->select(REDIS_SERVER_DBNUM - 1)); - $this->assertFalse($redis->exists('foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR invalid DB index - */ - public function testThrowsExceptionOnUnexpectedDatabase() - { - $redis = $this->getClient(); - - $redis->select(100000000); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashDeleteTest.php b/vendor/predis/predis/tests/Predis/Command/HashDeleteTest.php deleted file mode 100644 index e904f0a9f..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashDeleteTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashDeleteTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashDelete'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HDEL'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field1', 'field2', 'field3'); - $expected = array('key', 'field1', 'field2', 'field3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsFieldsAsSingleArray() - { - $arguments = array('key', array('field1', 'field2', 'field3')); - $expected = array('key', 'field1', 'field2', 'field3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field1', 'field2', 'field3'); - $expected = array('prefix:key', 'field1', 'field2', 'field3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testDeletesSpecifiedFieldsFromHash() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - - $this->assertSame(2, $redis->hdel('metavars', 'foo', 'hoge')); - $this->assertSame(0, $redis->hdel('metavars', 'foofoo')); - $this->assertSame(0, $redis->hdel('unknown', 'foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hdel('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashExistsTest.php b/vendor/predis/predis/tests/Predis/Command/HashExistsTest.php deleted file mode 100644 index a7975a609..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashExistsTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashExistsTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashExists'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HEXISTS'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field'); - $expected = array('key', 'field'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertFalse($command->parseResponse(0)); - $this->assertTrue($command->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field'); - $expected = array('prefix:key', 'field'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsExistenceOfSpecifiedField() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo'); - - $this->assertTrue($redis->hexists('metavars', 'foo')); - $this->assertFalse($redis->hexists('metavars', 'lol')); - $this->assertFalse($redis->hexists('unknown', 'foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hexists('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashGetAllTest.php b/vendor/predis/predis/tests/Predis/Command/HashGetAllTest.php deleted file mode 100644 index b24b52bf3..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashGetAllTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashGetAllTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashGetAll'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HGETALL'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - $expected = array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsAllTheFieldsAndTheirValues() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - - $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); - $this->assertSame(array(), $redis->hgetall('unknown')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hgetall('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashGetMultipleTest.php b/vendor/predis/predis/tests/Predis/Command/HashGetMultipleTest.php deleted file mode 100644 index d013bdca3..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashGetMultipleTest.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashGetMultipleTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashGetMultiple'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HMGET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field1', 'field2', 'field3'); - $expected = array('key', 'field1', 'field2', 'field3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsFieldsAsSingleArray() - { - $arguments = array('key', array('field1', 'field2', 'field3')); - $expected = array('key', 'field1', 'field2', 'field3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('bar', 'piyo', 'wut'); - $expected = array('bar', 'piyo', 'wut'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field1', 'field2', 'field3'); - $expected = array('prefix:key', 'field1', 'field2', 'field3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsValuesOfSpecifiedFields() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - - $this->assertSame(array('bar', 'piyo', null), $redis->hmget('metavars', 'foo', 'hoge', 'unknown')); - $this->assertSame(array('bar', 'bar'), $redis->hmget('metavars', 'foo', 'foo')); - $this->assertSame(array(null, null), $redis->hmget('metavars', 'unknown', 'unknown')); - $this->assertSame(array(null, null), $redis->hmget('unknown', 'foo', 'hoge')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hmget('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashGetTest.php b/vendor/predis/predis/tests/Predis/Command/HashGetTest.php deleted file mode 100644 index 236844706..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashGetTest.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashGetTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashGet'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HGET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field'); - $expected = array('key', 'field'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('value', $this->getCommand()->parseResponse('value')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field'); - $expected = array('prefix:key', 'field'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsValueOfSpecifiedField() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo'); - - $this->assertSame('bar', $redis->hget('metavars', 'foo')); - $this->assertNull($redis->hget('metavars', 'lol')); - $this->assertNull($redis->hget('unknown', 'foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hget('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashIncrementByFloatTest.php b/vendor/predis/predis/tests/Predis/Command/HashIncrementByFloatTest.php deleted file mode 100644 index 8e78c97d7..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashIncrementByFloatTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashIncrementByFloatTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashIncrementByFloat'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HINCRBYFLOAT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field', 10.5); - $expected = array('key', 'field', 10.5); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(10.5, $this->getCommand()->parseResponse(10.5)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field', 10.5); - $expected = array('prefix:key', 'field', 10.5); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testIncrementsValueOfFieldByFloat() - { - $redis = $this->getClient(); - - $this->assertSame('10.5', $redis->hincrbyfloat('metavars', 'foo', 10.5)); - $this->assertSame('10.001', $redis->hincrbyfloat('metavars', 'hoge', 10.001)); - $this->assertSame('11', $redis->hincrbyfloat('metavars', 'hoge', 0.999)); - $this->assertSame(array('foo' => '10.5', 'hoge' => '11'), $redis->hgetall('metavars')); - } - - /** - * @group connected - */ - public function testDecrementsValueOfFieldByFloat() - { - $redis = $this->getClient(); - - $this->assertSame('-10.5', $redis->hincrbyfloat('metavars', 'foo', -10.5)); - $this->assertSame('-10.001', $redis->hincrbyfloat('metavars', 'hoge', -10.001)); - $this->assertSame('-11', $redis->hincrbyfloat('metavars', 'hoge', -0.999)); - $this->assertSame(array('foo' => '-10.5', 'hoge' => '-11'), $redis->hgetall('metavars')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR hash value is not a valid float - */ - public function testThrowsExceptionOnStringField() - { - $redis = $this->getClient(); - - $redis->hset('metavars', 'foo', 'bar'); - $redis->hincrbyfloat('metavars', 'foo', 10.0); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hincrbyfloat('foo', 'bar', 10.5); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashIncrementByTest.php b/vendor/predis/predis/tests/Predis/Command/HashIncrementByTest.php deleted file mode 100644 index 79d63be21..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashIncrementByTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashIncrementByTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashIncrementBy'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HINCRBY'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field', 10); - $expected = array('key', 'field', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(10, $this->getCommand()->parseResponse(10)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field', 10); - $expected = array('prefix:key', 'field', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testIncrementsValueOfFieldByInteger() - { - $redis = $this->getClient(); - - $this->assertSame(10, $redis->hincrby('metavars', 'foo', 10)); - $this->assertSame(5, $redis->hincrby('metavars', 'hoge', 5)); - $this->assertSame(15, $redis->hincrby('metavars', 'hoge', 10)); - $this->assertSame(array('foo' => '10', 'hoge' => '15'), $redis->hgetall('metavars')); - } - - /** - * @group connected - */ - public function testDecrementsValueOfFieldByInteger() - { - $redis = $this->getClient(); - - $this->assertSame(-10, $redis->hincrby('metavars', 'foo', -10)); - $this->assertSame(-5, $redis->hincrby('metavars', 'hoge', -5)); - $this->assertSame(-15, $redis->hincrby('metavars', 'hoge', -10)); - $this->assertSame(array('foo' => '-10', 'hoge' => '-15'), $redis->hgetall('metavars')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR hash value is not an integer - */ - public function testThrowsExceptionOnStringField() - { - $redis = $this->getClient(); - - $redis->hset('metavars', 'foo', 'bar'); - $redis->hincrby('metavars', 'foo', 10); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hincrby('foo', 'bar', 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashKeysTest.php b/vendor/predis/predis/tests/Predis/Command/HashKeysTest.php deleted file mode 100644 index 36e6d9468..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashKeysTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashKeysTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashKeys'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HKEYS'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('foo', 'hoge', 'lol'); - $expected = array('foo', 'hoge', 'lol'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsKeysOfHash() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - - $this->assertSame(array('foo', 'hoge', 'lol'), $redis->hkeys('metavars')); - $this->assertSame(array(), $redis->hkeys('unknown')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hkeys('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashLengthTest.php b/vendor/predis/predis/tests/Predis/Command/HashLengthTest.php deleted file mode 100644 index 1599cd921..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashLengthTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashLengthTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashLength'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HLEN'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsLengthOfHash() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - - $this->assertSame(3, $redis->hlen('metavars')); - $this->assertSame(0, $redis->hlen('unknown')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hlen('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashScanTest.php b/vendor/predis/predis/tests/Predis/Command/HashScanTest.php deleted file mode 100644 index 228860386..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashScanTest.php +++ /dev/null @@ -1,161 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashScanTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashScan'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HSCAN'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); - $expected = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsBasicUsage() - { - $arguments = array('key', 0); - $expected = array('key', 0); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithOptionsArray() - { - $arguments = array('key', 0, array('match' => 'field:*', 'count' => 10)); - $expected = array('key', 0, 'MATCH', 'field:*', 'COUNT', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('3', array('field:1', '1', 'field:2', '2', 'field:3', '3')); - $expected = array(3, array('field:1' => '1', 'field:2' => '2', 'field:3' => '3')); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', '0', 'MATCH', 'field:*', 'COUNT', 10); - $expected = array('prefix:key', '0', 'MATCH', 'field:*', 'COUNT', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testScanWithoutMatch() - { - $expectedFields = array('field:one', 'field:two', 'field:three', 'field:four'); - $expectedValues = array('one', 'two', 'three', 'four'); - - $redis = $this->getClient(); - $redis->hmset('key', array_combine($expectedFields, $expectedValues)); - - $response = $redis->hscan('key', 0); - - $this->assertSame(0, $response[0]); - $this->assertSame($expectedFields, array_keys($response[1])); - $this->assertSame($expectedValues, array_values($response[1])); - } - - /** - * @group connected - */ - public function testScanWithMatchingMembers() - { - $redis = $this->getClient(); - $redis->hmset('key', array('field:one' => 'one', 'field:two' => 'two', 'field:three' => 'three', 'field:four' => 'four')); - - $response = $redis->hscan('key', 0, 'MATCH', 'field:t*'); - - $this->assertSame(array('field:two', 'field:three'), array_keys($response[1])); - $this->assertSame(array('two', 'three'), array_values($response[1])); - } - - /** - * @group connected - */ - public function testScanWithNoMatchingMembers() - { - $redis = $this->getClient(); - $redis->hmset('key', array('field:one' => 'one', 'field:two' => 'two', 'field:three' => 'three', 'field:four' => 'four')); - - $response = $redis->hscan('key', 0, 'MATCH', 'nofield:*'); - - $this->assertSame(0, $response[0]); - $this->assertEmpty($response[1]); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashSetMultipleTest.php b/vendor/predis/predis/tests/Predis/Command/HashSetMultipleTest.php deleted file mode 100644 index 9a7379b36..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashSetMultipleTest.php +++ /dev/null @@ -1,135 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashSetMultipleTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashSetMultiple'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HMSET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field1', 'value1', 'field2', 'value2'); - $expected = array('key', 'field1', 'value1', 'field2', 'value2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsFieldsValuesAsSingleArray() - { - $arguments = array('key', array('field1' => 'value1', 'field2' => 'value2')); - $expected = array('key', 'field1', 'value1', 'field2', 'value2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field1', 'value1', 'field2', 'value2'); - $expected = array('prefix:key', 'field1', 'value1', 'field2', 'value2'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testSetsSpecifiedFieldsOfHash() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo')); - $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo'), $redis->hgetall('metavars')); - - $this->assertTrue($redis->hmset('metavars', 'foo', 'barbar', 'lol', 'wut')); - $this->assertSame(array('foo' => 'barbar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); - } - - /** - * @group connected - */ - public function testSetsTheSpecifiedFie() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - - $this->assertSame(array('foo' => 'bar', 'hoge' => 'piyo', 'lol' => 'wut'), $redis->hgetall('metavars')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'bar'); - $redis->hmset('metavars', 'foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashSetPreserveTest.php b/vendor/predis/predis/tests/Predis/Command/HashSetPreserveTest.php deleted file mode 100644 index c8367bc43..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashSetPreserveTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashSetPreserveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashSetPreserve'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HSETNX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field', 'value'); - $expected = array('key', 'field', 'value'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field', 'value'); - $expected = array('prefix:key', 'field', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testSetsNewFieldsAndPreserversExistingOnes() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->hsetnx('metavars', 'foo', 'bar')); - $this->assertTrue($redis->hsetnx('metavars', 'hoge', 'piyo')); - $this->assertFalse($redis->hsetnx('metavars', 'foo', 'barbar')); - - $this->assertSame(array('bar', 'piyo'), $redis->hmget('metavars', 'foo', 'hoge')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->hsetnx('metavars', 'foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashSetTest.php b/vendor/predis/predis/tests/Predis/Command/HashSetTest.php deleted file mode 100644 index e51778679..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashSetTest.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashSetTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashSet'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HSET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'field', 'value'); - $expected = array('key', 'field', 'value'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'field', 'value'); - $expected = array('prefix:key', 'field', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testSetsValueOfSpecifiedField() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->hset('metavars', 'foo', 'bar')); - $this->assertTrue($redis->hset('metavars', 'hoge', 'piyo')); - - $this->assertSame(array('bar', 'piyo'), $redis->hmget('metavars', 'foo', 'hoge')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->hset('metavars', 'foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/HashValuesTest.php b/vendor/predis/predis/tests/Predis/Command/HashValuesTest.php deleted file mode 100644 index 7bae8caf1..000000000 --- a/vendor/predis/predis/tests/Predis/Command/HashValuesTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-hash - */ -class HashValuesTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\HashValues'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'HVALS'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('foo', 'hoge', 'lol'); - $expected = array('foo', 'hoge', 'lol'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsValuesOfHash() - { - $redis = $this->getClient(); - - $redis->hmset('metavars', 'foo', 'bar', 'hoge', 'piyo', 'lol', 'wut'); - - $this->assertSame(array('bar', 'piyo', 'wut'), $redis->hvals('metavars')); - $this->assertSame(array(), $redis->hvals('unknown')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->hvals('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyDeleteTest.php b/vendor/predis/predis/tests/Predis/Command/KeyDeleteTest.php deleted file mode 100644 index 2e9bd9222..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyDeleteTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyDeleteTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyDelete'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'DEL'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertSame(10, $command->parseResponse(10)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsNumberOfDeletedKeys() - { - $redis = $this->getClient(); - - $this->assertSame(0, $redis->del('foo')); - - $redis->set('foo', 'bar'); - $this->assertSame(1, $redis->del('foo')); - - $redis->set('foo', 'bar'); - $this->assertSame(1, $redis->del('foo', 'hoge')); - - $redis->set('foo', 'bar'); - $redis->set('hoge', 'piyo'); - $this->assertSame(2, $redis->del('foo', 'hoge')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyDumpTest.php b/vendor/predis/predis/tests/Predis/Command/KeyDumpTest.php deleted file mode 100644 index c9adcf239..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyDumpTest.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyDumpTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyDump'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'DUMP'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("; - $expected = "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("; - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyExistsTest.php b/vendor/predis/predis/tests/Predis/Command/KeyExistsTest.php deleted file mode 100644 index eedf05449..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyExistsTest.php +++ /dev/null @@ -1,106 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyExistsTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyExists'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'EXISTS'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsTrueIfKeyExists() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $this->assertTrue($redis->exists('foo')); - } - - /** - * @group connected - */ - public function testReturnsFalseIfKeyDoesNotExist() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->exists('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyExpireAtTest.php b/vendor/predis/predis/tests/Predis/Command/KeyExpireAtTest.php deleted file mode 100644 index 9208b0eec..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyExpireAtTest.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyExpireAtTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyExpireAt'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'EXPIREAT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'ttl'); - $expected = array('key', 'ttl'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsFalseOnNonExistingKeys() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->expireat('foo', 2)); - } - - /** - * @medium - * @group connected - * @group slow - */ - public function testCanExpireKeys() - { - $redis = $this->getClient(); - - $now = time(); - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->expireat('foo', $now + 1)); - $this->assertLessThanOrEqual(1, $redis->ttl('foo')); - - $this->sleep(2); - - $this->assertFalse($redis->exists('foo')); - } - - /** - * @group connected - */ - public function testDeletesKeysOnPastUnixTime() - { - $redis = $this->getClient(); - - $now = time(); - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->expireat('foo', $now - 100)); - $this->assertFalse($redis->exists('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyExpireTest.php b/vendor/predis/predis/tests/Predis/Command/KeyExpireTest.php deleted file mode 100644 index 71e9fdd5c..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyExpireTest.php +++ /dev/null @@ -1,143 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyExpireTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyExpire'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'EXPIRE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'ttl'); - $expected = array('key', 'ttl'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsFalseOnNonExistingKeys() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->expire('foo', 2)); - } - - /** - * @medium - * @group connected - * @group slow - */ - public function testCanExpireKeys() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->expire('foo', 1)); - $this->assertSame(1, $redis->ttl('foo')); - - $this->sleep(2.0); - - $this->assertFalse($redis->exists('foo')); - } - - /** - * @medium - * @group connected - * @group slow - */ - public function testConsistencyWithTTL() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->expire('foo', 10)); - $this->sleep(1.5); - $this->assertLessThan(10, $redis->ttl('foo')); - } - - /** - * @group connected - */ - public function testDeletesKeysOnNegativeTTL() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->expire('foo', -10)); - $this->assertFalse($redis->exists('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyKeysTest.php b/vendor/predis/predis/tests/Predis/Command/KeyKeysTest.php deleted file mode 100644 index ec37d99ab..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyKeysTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyKeysTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyKeys'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'KEYS'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('pattern:*'); - $expected = array('pattern:*'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('key1', 'key2', 'key3'); - $parsed = array('key1', 'key2', 'key3'); - - $this->assertSame($parsed, $this->getCommand()->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('pattern'); - $expected = array('prefix:pattern'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsArrayOfMatchingKeys() - { - $keys = array('aaa' => 1, 'aba' => 2, 'aca' => 3); - $keysNS = array('metavar:foo' => 'bar', 'metavar:hoge' => 'piyo'); - $keysAll = array_merge($keys, $keysNS); - - $redis = $this->getClient(); - $redis->mset($keysAll); - - $this->assertSame(array(), $redis->keys('nomatch:*')); - $this->assertSameValues(array_keys($keysNS), $redis->keys('metavar:*')); - $this->assertSameValues(array_keys($keysAll), $redis->keys('*')); - $this->assertSameValues(array_keys($keys), $redis->keys('a?a')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyKeysV12xTest.php b/vendor/predis/predis/tests/Predis/Command/KeyKeysV12xTest.php deleted file mode 100644 index 9313adfa5..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyKeysV12xTest.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * We only perform disconnected tests for this commands because - * it is too old (Redis v1.2) and expects a different response - * format. - * - * @group commands - * @group realm-key - */ -class KeyKeysV12xTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyKeysV12x'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'KEYS'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('pattern:*'); - $expected = array('pattern:*'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = 'key1 key2 key3'; - $parsed = array('key1', 'key2', 'key3'); - - $this->assertSame($parsed, $this->getCommand()->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('pattern'); - $expected = array('prefix:pattern'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyMoveTest.php b/vendor/predis/predis/tests/Predis/Command/KeyMoveTest.php deleted file mode 100644 index 8aa8ad44b..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyMoveTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyMoveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyMove'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'MOVE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 10); - $expected = array('key', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'db'); - $expected = array('prefix:key', 'db'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - * @todo This test fails if REDIS_SERVER_DBNUM is 0. - */ - public function testMovesKeysToDifferentDatabases() - { - $db = REDIS_SERVER_DBNUM - 1; - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->move('foo', $db)); - $this->assertFalse($redis->exists('foo')); - - $redis->select($db); - $this->assertTrue($redis->exists('foo')); - - $redis->del('foo'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR index out of range - */ - public function testThrowsExceptionOnInvalidDatabases() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $redis->move('foo', 100000000); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyPersistTest.php b/vendor/predis/predis/tests/Predis/Command/KeyPersistTest.php deleted file mode 100644 index 495c953a1..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyPersistTest.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyPersistTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyPersist'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PERSIST'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testRemovesExpireFromKey() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->expire('foo', 10); - - $this->assertTrue($redis->persist('foo')); - $this->assertSame(-1, $redis->ttl('foo')); - } - - /** - * @group connected - */ - public function testReturnsFalseOnNonExpiringKeys() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertFalse($redis->persist('foo')); - } - - /** - * @group connected - */ - public function testReturnsFalseOnNonExistentKeys() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->persist('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireAtTest.php b/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireAtTest.php deleted file mode 100644 index ed0c30087..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireAtTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyPreciseExpireAtTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyPreciseExpireAt'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PEXPIREAT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 100); - $expected = array('key', 100); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @medium - * @group connected - * @group slow - */ - public function testCanExpireKeys() - { - $ttl = 1.5; - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->pexpireat('foo', time() + $ttl * 1000)); - $this->assertLessThan($ttl * 1000, $redis->pttl('foo')); - - $this->sleep($ttl + 0.5); - - $this->assertFalse($redis->exists('foo')); - } - - /** - * @group connected - */ - public function testDeletesKeysOnPastUnixTime() - { - $redis = $this->getClient(); - - $now = time(); - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->expireat('foo', time() - 100000)); - $this->assertFalse($redis->exists('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireTest.php b/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireTest.php deleted file mode 100644 index 7fd12ab77..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyPreciseExpireTest.php +++ /dev/null @@ -1,144 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyPreciseExpireTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyPreciseExpire'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PEXPIRE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 100); - $expected = array('key', 100); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsFalseOnNonExistingKeys() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->pexpire('foo', 20000)); - } - - /** - * @medium - * @group connected - * @group slow - */ - public function testCanExpireKeys() - { - $ttl = 1 * 1000; - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->pexpire('foo', $ttl)); - - $this->sleep(1.2); - $this->assertFalse($redis->exists('foo')); - } - - /** - * @group connected - * @group slow - */ - public function testConsistencyWithTTL() - { - $ttl = 1 * 1000; - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->pexpire('foo', $ttl)); - - $this->sleep(0.5); - $this->assertLessThanOrEqual($ttl, $redis->pttl('foo')); - $this->assertGreaterThan($ttl - 800, $redis->pttl('foo')); - } - - /** - * @group connected - */ - public function testDeletesKeysOnNegativeTTL() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->pexpire('foo', -10000)); - $this->assertFalse($redis->exists('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyPreciseTimeToLiveTest.php b/vendor/predis/predis/tests/Predis/Command/KeyPreciseTimeToLiveTest.php deleted file mode 100644 index 1cc394501..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyPreciseTimeToLiveTest.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyPreciseTimeToLiveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyPreciseTimeToLive'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PTTL'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 10); - $expected = array('key', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertSame(100, $command->parseResponse(100)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 10); - $expected = array('prefix:key', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsTTL() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->expire('foo', 10); - - $this->assertLessThanOrEqual(10000, $redis->pttl('foo')); - } - - /** - * @group connected - */ - public function testReturnsLessThanZeroOnNonExpiringKeys() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $this->assertSame(-1, $redis->pttl('foo')); - } - - /** - * @group connected - * @todo PTTL changed in Redis >= 2.8 to return -2 on non existing keys, we - * should handle this case with a better solution than the current one. - */ - public function testReturnsLessThanZeroOnNonExistingKeys() - { - $redis = $this->getClient(); - - $this->assertLessThanOrEqual(-1, $redis->pttl('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyRandomTest.php b/vendor/predis/predis/tests/Predis/Command/KeyRandomTest.php deleted file mode 100644 index 5a2dd8805..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyRandomTest.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyRandomTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyRandom'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'RANDOMKEY'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array(); - $expected = array(); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = 'key'; - $expected = 'key'; - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group connected - */ - public function testReturnsFalseOnNonExpiringKeys() - { - $keys = array('key:1' => 1, 'key:2' => 2, 'key:3' => 3); - - $redis = $this->getClient(); - $redis->mset($keys); - - $this->assertContains($redis->randomkey(), array_keys($keys)); - } - - /** - * @group connected - */ - public function testReturnsNullOnEmptyDatabase() - { - $redis = $this->getClient(); - - $this->assertNull($redis->randomkey()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyRenamePreserveTest.php b/vendor/predis/predis/tests/Predis/Command/KeyRenamePreserveTest.php deleted file mode 100644 index 9a549c861..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyRenamePreserveTest.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyRenamePreserveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyRenamePreserve'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'RENAMENX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'newkey'); - $expected = array('key', 'newkey'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(1)); - $this->assertFalse($this->getCommand()->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'newkey'); - $expected = array('prefix:key', 'prefix:newkey'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testRenamesKeys() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->renamenx('foo', 'foofoo')); - $this->assertFalse($redis->exists('foo')); - $this->assertTrue($redis->exists('foofoo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR no such key - */ - public function testReturnsFalseOnNonExistingKeys() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->renamenx('foo', 'foobar')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyRenameTest.php b/vendor/predis/predis/tests/Predis/Command/KeyRenameTest.php deleted file mode 100644 index 5d8e59ae4..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyRenameTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyRenameTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyRename'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'RENAME'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'newkey'); - $expected = array('key', 'newkey'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'newkey'); - $expected = array('prefix:key', 'prefix:newkey'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testRenamesKeys() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->rename('foo', 'foofoo')); - $this->assertFalse($redis->exists('foo')); - $this->assertTrue($redis->exists('foofoo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR no such key - */ - public function testThrowsExceptionOnNonExistingKeys() - { - $redis = $this->getClient(); - - $redis->rename('foo', 'foobar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyRestoreTest.php b/vendor/predis/predis/tests/Predis/Command/KeyRestoreTest.php deleted file mode 100644 index 95b2d3dc3..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyRestoreTest.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyRestoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyRestore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'RESTORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); - $expected = array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); - $expected = array('prefix:key', 0, "\x00\xC0\n\x06\x00\xF8r?\xC5\xFB\xFB_("); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyScanTest.php b/vendor/predis/predis/tests/Predis/Command/KeyScanTest.php deleted file mode 100644 index 62d36d7a3..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyScanTest.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyScanTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyScan'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SCAN'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array(0, 'MATCH', 'key:*', 'COUNT', 5); - $expected = array(0, 'MATCH', 'key:*', 'COUNT', 5); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsBasicUsage() - { - $arguments = array(0); - $expected = array(0); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithOptionsArray() - { - $arguments = array(0, array('match' => 'key:*', 'count' => 5)); - $expected = array(0, 'MATCH', 'key:*', 'COUNT', 5); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('3', array('key:1', 'key:2', 'key:3')); - $expected = array(3, array('key:1', 'key:2', 'key:3')); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group connected - */ - public function testScanWithoutMatch() - { - $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); - - $redis = $this->getClient(); - $redis->mset($kvs); - - $response = $redis->scan(0); - - $this->assertSameValues(array_keys($kvs), $response[1]); - } - - /** - * @group connected - */ - public function testScanWithMatchingKeys() - { - $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); - - $redis = $this->getClient(); - $redis->mset($kvs); - - $response = $redis->scan(0, 'MATCH', 'key:t*'); - - $this->assertSameValues(array('key:two', 'key:three'), $response[1]); - } - - /** - * @group connected - */ - public function testScanWithNoMatchingKeys() - { - $kvs = array('key:one' => 'one', 'key:two' => 'two', 'key:three' => 'three', 'key:four' => 'four'); - - $redis = $this->getClient(); - $redis->mset($kvs); - - $response = $redis->scan(0, 'MATCH', 'nokey:*'); - - $this->assertSame(0, $response[0]); - $this->assertEmpty($response[1]); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeySortTest.php b/vendor/predis/predis/tests/Predis/Command/KeySortTest.php deleted file mode 100644 index d1862d5c0..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeySortTest.php +++ /dev/null @@ -1,279 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeySortTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeySort'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SORT'; - } - - /** - * Utility method to to an LPUSH of some unordered values on a key. - * - * @param Predis\Client $redis Redis client instance. - * @param string $key Target key - * @return array - */ - protected function lpushUnorderedList(Predis\Client $redis, $key) - { - $list = array(2, 100, 3, 1, 30, 10); - $redis->lpush($key, $list); - - return $list; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $modifiers = array( - 'by' => 'by_key_*', - 'limit' => array(1, 4), - 'get' => array('object_*', '#'), - 'sort' => 'asc', - 'alpha' => true, - 'store' => 'destination_key', - ); - $arguments = array('key', $modifiers); - - $expected = array( - 'key', 'BY', 'by_key_*', 'GET', 'object_*', 'GET', '#', - 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'destination_key' - ); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertEquals($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testGetModifierCanBeString() - { - $arguments = array('key', array('get' => '#')); - $expected = array('key', 'GET', '#'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('value1', 'value2', 'value3'); - $expected = array('value1', 'value2', 'value3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $modifiers = array( - 'by' => 'by_key_*', - 'limit' => array(1, 4), - 'get' => array('object_*', '#'), - 'sort' => 'asc', - 'alpha' => true, - 'store' => 'destination_key', - ); - $arguments = array('key', $modifiers); - - $expected = array( - 'prefix:key', 'BY', 'prefix:by_key_*', 'GET', 'prefix:object_*', 'GET', '#', - 'LIMIT', 1, 4, 'ASC', 'ALPHA', 'STORE', 'prefix:destination_key' - ); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testBasicSort() - { - $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); - - $this->assertEquals(array(1, 2, 3, 10, 30, 100), $redis->sort('list:unordered')); - } - - /** - * @group connected - */ - public function testSortWithAscOrDescModifier() - { - $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); - - $this->assertEquals( - array(100, 30, 10, 3, 2, 1), - $redis->sort('list:unordered', array( - 'sort' => 'desc', - )) - ); - - $this->assertEquals( - array(1, 2, 3, 10, 30, 100), - $redis->sort('list:unordered', array( - 'sort' => 'asc', - )) - ); - } - - /** - * @group connected - */ - public function testSortWithLimitModifier() - { - $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); - - $this->assertEquals( - array(1, 2, 3), - $redis->sort('list:unordered', array( - 'limit' => array(0, 3), - )) - ); - - $this->assertEquals( - array(10, 30), - $redis->sort('list:unordered', array( - 'limit' => array(3, 2) - )) - ); - } - - /** - * @group connected - */ - public function testSortWithAlphaModifier() - { - $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); - - $this->assertEquals( - array(1, 10, 100, 2, 3, 30), - $redis->sort('list:unordered', array( - 'alpha' => true - )) - ); - } - - /** - * @group connected - */ - public function testSortWithStoreModifier() - { - $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); - - $this->assertEquals( - count($unordered), - $redis->sort('list:unordered', array( - 'store' => 'list:ordered' - )) - ); - - $this->assertEquals(array(1, 2, 3, 10, 30, 100), $redis->lrange('list:ordered', 0, -1)); - } - - /** - * @group connected - */ - public function testSortWithCombinedModifiers() - { - $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); - - $this->assertEquals( - array(30, 10, 3, 2), - $redis->sort('list:unordered', array( - 'alpha' => false, - 'sort' => 'desc', - 'limit' => array(1, 4) - )) - ); - } - - /** - * @group connected - */ - public function testSortWithGetModifiers() - { - $redis = $this->getClient(); - $redis->lpush('list:unordered', $unordered = array(2, 100, 3, 1, 30, 10)); - - $redis->rpush('list:uids', $uids = array(1003, 1001, 1002, 1000)); - $redis->mset($sortget = array( - 'uid:1000' => 'foo', 'uid:1001' => 'bar', - 'uid:1002' => 'hoge', 'uid:1003' => 'piyo', - )); - - $this->assertEquals(array_values($sortget), $redis->sort('list:uids', array('get' => 'uid:*'))); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->sort('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyTimeToLiveTest.php b/vendor/predis/predis/tests/Predis/Command/KeyTimeToLiveTest.php deleted file mode 100644 index 98aca39ef..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyTimeToLiveTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyTimeToLiveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyTimeToLive'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'TTL'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 10); - $expected = array('key', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertSame(100, $command->parseResponse(100)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 10); - $expected = array('prefix:key', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsTTL() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->expire('foo', 10); - - $this->assertSame(10, $redis->ttl('foo')); - } - - /** - * @group connected - */ - public function testReturnsLessThanZeroOnNonExpiringKeys() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $this->assertSame(-1, $redis->ttl('foo')); - } - - /** - * @group connected - */ - public function testReturnsLessThanZeroOnNonExistingKeys() - { - $this->executeOnRedisVersion('2.8.0', '<', function ($test) { - $test->assertSame(-1, $test->getClient()->ttl('foo')); - }); - - $this->executeOnRedisVersion('2.8.0', '>=', function ($test) { - $test->assertSame(-2, $test->getClient()->ttl('foo')); - }); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/KeyTypeTest.php b/vendor/predis/predis/tests/Predis/Command/KeyTypeTest.php deleted file mode 100644 index 870dbfede..000000000 --- a/vendor/predis/predis/tests/Predis/Command/KeyTypeTest.php +++ /dev/null @@ -1,107 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-key - */ -class KeyTypeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\KeyType'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'TYPE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('type', $this->getCommand()->parseResponse('type')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsTypeOfKey() - { - $redis = $this->getClient(); - - $this->assertSame('none', $redis->type('type:keydoesnotexist')); - - $redis->set('type:string', 'foobar'); - $this->assertSame('string', $redis->type('type:string')); - - $redis->lpush('type:list', 'foobar'); - $this->assertSame('list', $redis->type('type:list')); - - $redis->sadd('type:set', 'foobar'); - $this->assertSame('set', $redis->type('type:set')); - - $redis->zadd('type:zset', 0, 'foobar'); - $this->assertSame('zset', $redis->type('type:zset')); - - $redis->hset('type:hash', 'foo', 'bar'); - $this->assertSame('hash', $redis->type('type:hash')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListIndexTest.php b/vendor/predis/predis/tests/Predis/Command/ListIndexTest.php deleted file mode 100644 index 623c02d04..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListIndexTest.php +++ /dev/null @@ -1,124 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListIndexTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListIndex'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LINDEX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 1); - $expected = array('key', 1); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(0, $this->getCommand()->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 1); - $expected = array('prefix:key', 1); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsElementAtIndex() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e'); - - $this->assertSame('a', $redis->lindex('letters', 0)); - $this->assertSame('c', $redis->lindex('letters', 2)); - $this->assertNull($redis->lindex('letters', 100)); - } - - /** - * @group connected - */ - public function testReturnsElementAtNegativeIndex() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e'); - - $this->assertSame('a', $redis->lindex('letters', -0)); - $this->assertSame('c', $redis->lindex('letters', -3)); - $this->assertSame('e', $redis->lindex('letters', -1)); - $this->assertNull($redis->lindex('letters', -100)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->lindex('foo', 0); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListInsertTest.php b/vendor/predis/predis/tests/Predis/Command/ListInsertTest.php deleted file mode 100644 index 20dcd0e79..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListInsertTest.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListInsertTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListInsert'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LINSERT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'before', 'value1', 'value2'); - $expected = array('key', 'before', 'value1', 'value2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'before', 'value1', 'value2'); - $expected = array('prefix:key', 'before', 'value1', 'value2'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsLengthOfListAfterInser() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'c', 'e'); - - $this->assertSame(4, $redis->linsert('letters', 'before', 'c', 'b')); - $this->assertSame(5, $redis->linsert('letters', 'after', 'c', 'd')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testReturnsNegativeLengthOnFailedInsert() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'c', 'e'); - - $this->assertSame(-1, $redis->linsert('letters', 'before', 'n', 'm')); - $this->assertSame(-1, $redis->linsert('letters', 'after', 'o', 'p')); - } - - /** - * @group connected - */ - public function testReturnsZeroLengthOnNonExistingList() - { - $redis = $this->getClient(); - - $this->assertSame(0, $redis->linsert('letters', 'after', 'a', 'b')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->linsert('foo', 'BEFORE', 'bar', 'baz'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListLengthTest.php b/vendor/predis/predis/tests/Predis/Command/ListLengthTest.php deleted file mode 100644 index 7fac2c0d2..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListLengthTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListLengthTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListLength'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LLEN'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsLengthOfList() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c'); - $this->assertSame(3, $redis->llen('letters')); - - $redis->rpush('letters', 'd', 'e', 'f'); - $this->assertSame(6, $redis->llen('letters')); - } - - /** - * @group connected - */ - public function testReturnsZeroLengthOnNonExistingList() - { - $redis = $this->getClient(); - - $this->assertSame(0, $redis->llen('letters')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->llen('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopFirstBlockingTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopFirstBlockingTest.php deleted file mode 100644 index 140b3b0ac..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPopFirstBlockingTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - * @todo Testing blocking pop operations against Redis using PHP is - * tricky, so we will skip these kind of tests for now. - */ -class ListPopFirstBlockingTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPopFirstBlocking'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'BLPOP'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key1', 'key2', 'key3', 10); - $expected = array('key1', 'key2', 'key3', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsKeysAsSingleArray() - { - $arguments = array(array('key1', 'key2', 'key3'), 10); - $expected = array('key1', 'key2', 'key3', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('key', 'value'); - $expected = array('key', 'value'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key1', 'key2', 'key3', 10); - $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopFirstTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopFirstTest.php deleted file mode 100644 index b95d1c563..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPopFirstTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListPopFirstTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPopFirst'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LPOP'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('element', $this->getCommand()->parseResponse('element')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testPopsTheFirstElementFromList() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd'); - - $this->assertSame('a', $redis->lpop('letters')); - $this->assertSame('b', $redis->lpop('letters')); - $this->assertSame(array('c', 'd'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testReturnsNullOnEmptyList() - { - $redis = $this->getClient(); - - $this->assertNull($redis->lpop('letters')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->lpop('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopLastBlockingTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopLastBlockingTest.php deleted file mode 100644 index 4b9fce108..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPopLastBlockingTest.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - * @todo Testing blocking pop operations against Redis using PHP is - * tricky, so we will skip these kind of tests for now. - */ -class ListPopLastBlockingTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPopLastBlocking'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'BRPOP'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key1', 'key2', 'key3', 10); - $expected = array('key1', 'key2', 'key3', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsKeysAsSingleArray() - { - $arguments = array(array('key1', 'key2', 'key3'), 10); - $expected = array('key1', 'key2', 'key3', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('key', 'value'); - $expected = array('key', 'value'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key1', 'key2', 'key3', 10); - $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadBlockingTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadBlockingTest.php deleted file mode 100644 index 2835a5255..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadBlockingTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - * @todo Testing blocking pop operations against Redis using PHP is - * tricky, so we will skip these kind of tests for now. - */ -class ListPopLastPushHeadBlockingTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPopLastPushHeadBlocking'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'BRPOPLPUSH'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key:source', 'key:destination', 10); - $expected = array('key:source', 'key:destination', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('element', $this->getCommand()->parseResponse('element')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key:source', 'key:destination', 10); - $expected = array('prefix:key:source', 'prefix:key:destination', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadTest.php deleted file mode 100644 index f6a350c44..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPopLastPushHeadTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListPopLastPushHeadTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPopLastPushHead'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'RPOPLPUSH'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key:source', 'key:destination'); - $expected = array('key:source', 'key:destination'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('element', $this->getCommand()->parseResponse('element')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key:source', 'key:destination'); - $expected = array('prefix:key:source', 'prefix:key:destination'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsElementPoppedFromSourceAndPushesToDestination() - { - $redis = $this->getClient(); - - $redis->rpush('letters:source', 'a', 'b', 'c'); - - $this->assertSame('c', $redis->rpoplpush('letters:source', 'letters:destination')); - $this->assertSame('b', $redis->rpoplpush('letters:source', 'letters:destination')); - $this->assertSame('a', $redis->rpoplpush('letters:source', 'letters:destination')); - - $this->assertSame(array(), $redis->lrange('letters:source', 0, -1)); - $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters:destination', 0, -1)); - } - - /** - * @group connected - */ - public function testReturnsElementPoppedFromSourceAndPushesToSelf() - { - $redis = $this->getClient(); - - $redis->rpush('letters:source', 'a', 'b', 'c'); - - $this->assertSame('c', $redis->rpoplpush('letters:source', 'letters:source')); - $this->assertSame('b', $redis->rpoplpush('letters:source', 'letters:source')); - $this->assertSame('a', $redis->rpoplpush('letters:source', 'letters:source')); - - $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters:source', 0, -1)); - } - - /** - * @group connected - */ - public function testReturnsNullOnEmptySource() - { - $redis = $this->getClient(); - - $this->assertNull($redis->rpoplpush('key:source', 'key:destination')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongTypeOfSourceKey() - { - $redis = $this->getClient(); - - $redis->set('key:source', 'foo'); - $redis->rpoplpush('key:source', 'key:destination'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongTypeOfDestinationKey() - { - $redis = $this->getClient(); - - $redis->rpush('key:source', 'foo'); - $redis->set('key:destination', 'bar'); - - $redis->rpoplpush('key:source', 'key:destination'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPopLastTest.php b/vendor/predis/predis/tests/Predis/Command/ListPopLastTest.php deleted file mode 100644 index fd25bd1dd..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPopLastTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListPopLastTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPopLast'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'RPOP'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('element', $this->getCommand()->parseResponse('element')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testPopsTheLastElementFromList() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd'); - - $this->assertSame('d', $redis->rpop('letters')); - $this->assertSame('c', $redis->rpop('letters')); - $this->assertSame(array('a', 'b'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testReturnsNullOnEmptyList() - { - $redis = $this->getClient(); - - $this->assertNull($redis->rpop('letters')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->rpop('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPushHeadTest.php b/vendor/predis/predis/tests/Predis/Command/ListPushHeadTest.php deleted file mode 100644 index acb2c292b..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPushHeadTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListPushHeadTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPushHead'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LPUSH'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'value1', 'value2', 'value3'); - $expected = array('key', 'value1', 'value2', 'value3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsValuesAsSingleArray() - { - $arguments = array('key', array('value1', 'value2', 'value3')); - $expected = array('key', 'value1', 'value2', 'value3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value1', 'value2', 'value3'); - $expected = array('prefix:key', 'value1', 'value2', 'value3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testPushesElementsToHeadOfList() - { - $redis = $this->getClient(); - - // NOTE: List push operations return the list length since Redis commit 520b5a3 - $this->assertSame(1, $redis->lpush('metavars', 'foo')); - $this->assertSame(2, $redis->lpush('metavars', 'hoge')); - $this->assertSame(array('hoge', 'foo'), $redis->lrange('metavars', 0, -1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->lpush('metavars', 'hoge'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPushHeadXTest.php b/vendor/predis/predis/tests/Predis/Command/ListPushHeadXTest.php deleted file mode 100644 index c37698cb5..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPushHeadXTest.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListPushHeadXTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPushHeadX'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LPUSHX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'value'); - $expected = array('key', 'value'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testPushesElementsToHeadOfExistingList() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - - $this->assertSame(2, $redis->lpushx('metavars', 'hoge')); - $this->assertSame(array('hoge', 'foo'), $redis->lrange('metavars', 0, -1)); - } - - /** - * @group connected - */ - public function testDoesNotPushElementOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(0, $redis->lpushx('metavars', 'foo')); - $this->assertSame(0, $redis->lpushx('metavars', 'hoge')); - $this->assertFalse($redis->exists('metavars')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->lpushx('metavars', 'hoge'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPushTailTest.php b/vendor/predis/predis/tests/Predis/Command/ListPushTailTest.php deleted file mode 100644 index 70731f115..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPushTailTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListPushTailTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPushTail'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'RPUSH'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'value1', 'value2', 'value3'); - $expected = array('key', 'value1', 'value2', 'value3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsValuesAsSingleArray() - { - $arguments = array('key', array('value1', 'value2', 'value3')); - $expected = array('key', 'value1', 'value2', 'value3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value1', 'value2', 'value3'); - $expected = array('prefix:key', 'value1', 'value2', 'value3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testPushesElementsToHeadOfList() - { - $redis = $this->getClient(); - - // NOTE: List push operations return the list length since Redis commit 520b5a3 - $this->assertSame(1, $redis->rpush('metavars', 'foo')); - $this->assertSame(2, $redis->rpush('metavars', 'hoge')); - $this->assertSame(array('foo', 'hoge'), $redis->lrange('metavars', 0, -1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->rpush('metavars', 'hoge'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListPushTailXTest.php b/vendor/predis/predis/tests/Predis/Command/ListPushTailXTest.php deleted file mode 100644 index 30b968c8f..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListPushTailXTest.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListPushTailXTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListPushTailX'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'RPUSHX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'value'); - $expected = array('key', 'value'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testPushesElementsToHeadOfExistingList() - { - $redis = $this->getClient(); - - $redis->rpush('metavars', 'foo'); - - $this->assertSame(2, $redis->rpushx('metavars', 'hoge')); - $this->assertSame(array('foo', 'hoge'), $redis->lrange('metavars', 0, -1)); - } - - /** - * @group connected - */ - public function testDoesNotPushElementOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(0, $redis->rpushx('metavars', 'foo')); - $this->assertSame(0, $redis->rpushx('metavars', 'hoge')); - $this->assertFalse($redis->exists('metavars')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->rpushx('metavars', 'hoge'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListRangeTest.php b/vendor/predis/predis/tests/Predis/Command/ListRangeTest.php deleted file mode 100644 index f70b0b83f..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListRangeTest.php +++ /dev/null @@ -1,163 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListRangeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListRange'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LRANGE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, -1); - $expected = array('key', 0, -1); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('value1', 'value2', 'value3'); - $expected = array('value1', 'value2', 'value3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 0, -1); - $expected = array('prefix:key', 0, -1); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsListSliceWithPositiveStartAndStop() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertSame(array('a', 'b', 'c', 'd'), $redis->lrange('letters', 0, 3)); - $this->assertSame(array('e', 'f', 'g', 'h'), $redis->lrange('letters', 4, 7)); - $this->assertSame(array('a', 'b'), $redis->lrange('letters', 0, 1)); - $this->assertSame(array('a'), $redis->lrange('letters', 0, 0)); - } - - /** - * @group connected - */ - public function testReturnsListSliceWithPositiveStartAndNegativeStop() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', 0, -1)); - $this->assertSame(array('f'), $redis->lrange('letters', 5, -5)); - $this->assertSame(array(), $redis->lrange('letters', 7, -5)); - } - - /** - * @group connected - */ - public function testReturnsListSliceWithNegativeStartAndStop() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertSame(array('f'), $redis->lrange('letters', -5, -5)); - } - - /** - * @group connected - */ - public function testHandlesStartAndStopOverflow() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', -100, 100)); - } - - /** - * @group connected - */ - public function testReturnsEmptyArrayOnNonExistingList() - { - $redis = $this->getClient(); - - $this->assertSame(array(), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->lrange('metavars', 0, -1); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListRemoveTest.php b/vendor/predis/predis/tests/Predis/Command/ListRemoveTest.php deleted file mode 100644 index 6711e00b8..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListRemoveTest.php +++ /dev/null @@ -1,147 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListRemoveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListRemove'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LREM'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 1, 'value'); - $expected = array('key', 1, 'value'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 1, 'value'); - $expected = array('prefix:key', 1, 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testRemovesMatchingElementsFromHeadToTail() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); - - $this->assertSame(2, $redis->lrem('letters', 2, '_')); - $this->assertSame(array('a', 'b', 'c', '_', 'd', '_'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testRemovesMatchingElementsFromTailToHead() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); - - $this->assertSame(2, $redis->lrem('letters', -2, '_')); - $this->assertSame(array('a', '_', 'b', '_', 'c', 'd'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testRemovesAllMatchingElements() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', '_', 'b', '_', 'c', '_', 'd', '_'); - - $this->assertSame(4, $redis->lrem('letters', 0, '_')); - $this->assertSame(array('a', 'b', 'c', 'd'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testReturnsZeroOnNonMatchingElementsOrEmptyList() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd'); - - $this->assertSame(0, $redis->lrem('letters', 0, 'z')); - $this->assertSame(0, $redis->lrem('digits', 0, 100)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->lrem('metavars', 0, 0); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListSetTest.php b/vendor/predis/predis/tests/Predis/Command/ListSetTest.php deleted file mode 100644 index 8647b46b7..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListSetTest.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListSetTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListSet'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LSET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 'value'); - $expected = array('key', 0, 'value'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 0, 'value'); - $expected = array('prefix:key', 0, 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testSetsElementAtSpecifiedIndex() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c'); - - $this->assertTrue($redis->lset('letters', 1, 'B')); - $this->assertSame(array('a', 'B', 'c'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR index out of range - */ - public function testThrowsExceptionOnIndexOutOfRange() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c'); - $redis->lset('letters', 21, 'z'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->lset('metavars', 0, 'hoge'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ListTrimTest.php b/vendor/predis/predis/tests/Predis/Command/ListTrimTest.php deleted file mode 100644 index 1e1c3996c..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ListTrimTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-list - */ -class ListTrimTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ListTrim'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LTRIM'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 1); - $expected = array('key', 0, 1); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 0, 1); - $expected = array('prefix:key', 0, 1); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testTrimsListWithPositiveStartAndStop() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertTrue($redis->ltrim('letters', 0, 2)); - $this->assertSame(array('a', 'b', 'c'), $redis->lrange('letters', 0, -1)); - - $redis->flushdb(); - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertTrue($redis->ltrim('letters', 5, 9)); - $this->assertSame(array('f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testTrimsListWithPositiveStartAndNegativeStop() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertTrue($redis->ltrim('letters', 0, -6)); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testTrimsListWithNegativeStartAndStop() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertTrue($redis->ltrim('letters', -5, -5)); - $this->assertSame(array('f'), $redis->lrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testHandlesStartAndStopOverflow() - { - $redis = $this->getClient(); - - $redis->rpush('letters', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'); - - $this->assertTrue($redis->ltrim('letters', -100, 100)); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'l'), $redis->lrange('letters', -100, 100)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->ltrim('metavars', 0, 1); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/PrefixHelpersTest.php b/vendor/predis/predis/tests/Predis/Command/PrefixHelpersTest.php deleted file mode 100644 index ae5a8d341..000000000 --- a/vendor/predis/predis/tests/Predis/Command/PrefixHelpersTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -use PredisTestCase; - -/** - * - */ -class PrefixHelpersTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testPrefixFirst() - { - $arguments = array('1st', '2nd', '3rd', '4th'); - $expected = array('prefix:1st', '2nd', '3rd', '4th'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->setRawArguments($arguments); - - PrefixHelpers::first($command, 'prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixAll() - { - $arguments = array('1st', '2nd', '3rd', '4th'); - $expected = array('prefix:1st', 'prefix:2nd', 'prefix:3rd', 'prefix:4th'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->setRawArguments($arguments); - - PrefixHelpers::all($command, 'prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixInterleaved() - { - $arguments = array('1st', '2nd', '3rd', '4th'); - $expected = array('prefix:1st', '2nd', 'prefix:3rd', '4th'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->setRawArguments($arguments); - - PrefixHelpers::interleaved($command, 'prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixSkipLast() - { - $arguments = array('1st', '2nd', '3rd', '4th'); - $expected = array('prefix:1st', 'prefix:2nd', 'prefix:3rd', '4th'); - - $command = $this->getMockForAbstractClass('Predis\Command\AbstractCommand'); - $command->setRawArguments($arguments); - - PrefixHelpers::skipLast($command, 'prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/PrefixableCommandTest.php b/vendor/predis/predis/tests/Predis/Command/PrefixableCommandTest.php deleted file mode 100644 index 0da66628a..000000000 --- a/vendor/predis/predis/tests/Predis/Command/PrefixableCommandTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -use PredisTestCase; - -/** - * - */ -class PrefixableCommandTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testImplementsCorrectInterface() - { - $command = $this->getMockForAbstractClass('Predis\Command\PrefixableCommand'); - - $this->assertInstanceOf('Predis\Command\PrefixableCommandInterface', $command); - $this->assertInstanceOf('Predis\Command\CommandInterface', $command); - } - - /** - * @group disconnected - */ - public function testAddPrefixToFirstArgument() - { - $command = $this->getMockForAbstractClass('Predis\Command\PrefixableCommand'); - $command->setRawArguments(array('key', 'value')); - $command->prefixKeys('prefix:'); - - $this->assertSame(array('prefix:key', 'value'), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testDoesNotBreakOnEmptyArguments() - { - $command = $this->getMockForAbstractClass('Predis\Command\PrefixableCommand'); - $command->prefixKeys('prefix:'); - - $this->assertEmpty($command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php b/vendor/predis/predis/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php deleted file mode 100644 index 10c3fd9b1..000000000 --- a/vendor/predis/predis/tests/Predis/Command/Processor/KeyPrefixProcessorTest.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command\Processor; - -use PredisTestCase; - -/** - * - */ -class KeyPrefixProcessorTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testConstructorWithPrefix() - { - $prefix = 'prefix:'; - $processor = new KeyPrefixProcessor($prefix); - - $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $processor); - $this->assertEquals($prefix, $processor->getPrefix()); - } - - /** - * @group disconnected - */ - public function testChangePrefix() - { - $prefix1 = 'prefix:'; - $prefix2 = 'prefix:new:'; - - $processor = new KeyPrefixProcessor($prefix1); - $this->assertEquals($prefix1, $processor->getPrefix()); - - $processor->setPrefix($prefix2); - $this->assertEquals($prefix2, $processor->getPrefix()); - } - - /** - * @group disconnected - */ - public function testProcessPrefixableCommands() - { - $prefix = 'prefix:'; - - $command = $this->getMock('Predis\Command\PrefixableCommand'); - $command->expects($this->once()) - ->method('prefixKeys') - ->with($prefix); - $command->expects($this->once()) - ->method('getArguments') - ->will($this->returnValue('key')); - - $processor = new KeyPrefixProcessor($prefix); - - $processor->process($command); - } - - /** - * @group disconnected - */ - public function testSkipPrefixableCommandsWithNoArguments() - { - $prefix = 'prefix:'; - - $command = $this->getMock('Predis\Command\PrefixableCommand'); - $command->expects($this->never()) - ->method('prefixKeys'); - - $processor = new KeyPrefixProcessor($prefix); - - $processor->process($command); - } - - /** - * @group disconnected - */ - public function testSkipNotPrefixableCommands() - { - $prefix = 'prefix:'; - $unprefixed = 'key'; - $expected = "$prefix$unprefixed"; - - $command = $this->getMock('Predis\Command\CommandInterface'); - $command->expects($this->never())->method('prefixKeys'); - - $processor = new KeyPrefixProcessor($prefix); - - $processor->process($command); - } - - /** - * @group disconnected - */ - public function testInstanceCanBeCastedToString() - { - $prefix = 'prefix:'; - $processor = new KeyPrefixProcessor($prefix); - - $this->assertEquals($prefix, (string) $processor); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/Processor/ProcessorChainTest.php b/vendor/predis/predis/tests/Predis/Command/Processor/ProcessorChainTest.php deleted file mode 100644 index 55264f5f6..000000000 --- a/vendor/predis/predis/tests/Predis/Command/Processor/ProcessorChainTest.php +++ /dev/null @@ -1,170 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command\Processor; - -use PredisTestCase; - -/** - * - */ -class ProcessorChainTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testConstructor() - { - $chain = new ProcessorChain(); - - $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $chain); - $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorChainInterface', $chain); - $this->assertEmpty($chain->getProcessors()); - } - - /** - * @group disconnected - */ - public function testConstructorWithProcessorsArray() - { - $processors = array( - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - ); - - $chain = new ProcessorChain($processors); - - $this->assertSame($processors, $chain->getProcessors()); - } - - /** - * @group disconnected - */ - public function testCountProcessors() - { - $processors = array( - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - ); - - $chain = new ProcessorChain($processors); - - $this->assertEquals(2, $chain->count()); - } - - /** - * @group disconnected - */ - public function testAddProcessors() - { - $processors = array( - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - ); - - $chain = new ProcessorChain(); - $chain->add($processors[0]); - $chain->add($processors[1]); - - $this->assertSame($processors, $chain->getProcessors()); - } - - /** - * @group disconnected - */ - public function testAddMoreProcessors() - { - $processors1 = array( - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - ); - - $processors2 = array( - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - ); - - $chain = new ProcessorChain($processors1); - $chain->add($processors2[0]); - $chain->add($processors2[1]); - - $this->assertSame(array_merge($processors1, $processors2), $chain->getProcessors()); - } - - /** - * @group disconnected - */ - public function testRemoveProcessors() - { - $processors = array( - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - ); - - $chain = new ProcessorChain($processors); - - $chain->remove($processors[0]); - $this->assertSame(array($processors[1]), $chain->getProcessors()); - - $chain->remove($processors[1]); - $this->assertEmpty($chain->getProcessors()); - } - - /** - * @group disconnected - */ - public function testRemoveProcessorNotInChain() - { - $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - $processors = array( - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - $this->getMock('Predis\Command\Processor\CommandProcessorInterface'), - ); - - $chain = new ProcessorChain($processors); - $chain->remove($processor); - - $this->assertSame($processors, $chain->getProcessors()); - } - - /** - * @group disconnected - */ - public function testRemoveProcessorFromEmptyChain() - { - $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - - $chain = new ProcessorChain(); - $this->assertEmpty($chain->getProcessors()); - - $chain->remove($processor); - $this->assertEmpty($chain->getProcessors()); - } - - /** - * @group disconnected - */ - public function testProcessChain() - { - $command = $this->getMock('Predis\Command\CommandInterface'); - - $processor1 = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - $processor1->expects($this->once())->method('process')->with($command); - - $processor2 = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - $processor2->expects($this->once())->method('process')->with($command); - - $processors = array($processor1, $processor2); - - $chain = new ProcessorChain($processors); - $chain->process($command); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubPublishTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubPublishTest.php deleted file mode 100644 index 3196f1881..000000000 --- a/vendor/predis/predis/tests/Predis/Command/PubSubPublishTest.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-pubsub - */ -class PubSubPublishTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\PubSubPublish'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PUBLISH'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('channel', 'message'); - $expected = array('channel', 'message'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('channel', 'message'); - $expected = array('prefix:channel', 'message'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testPublishesMessagesToChannel() - { - $redis1 = $this->getClient(); - $redis2 = $this->getClient(); - - $redis1->subscribe('channel:foo'); - - $this->assertSame(1, $redis2->publish('channel:foo', 'bar')); - $this->assertSame(0, $redis2->publish('channel:hoge', 'piyo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeByPatternTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeByPatternTest.php deleted file mode 100644 index f384206b1..000000000 --- a/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeByPatternTest.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-pubsub - */ -class PubSubSubscribeByPatternTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\PubSubSubscribeByPattern'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PSUBSCRIBE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('channel:foo:*', 'channel:hoge:*'); - $expected = array('channel:foo:*', 'channel:hoge:*'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('channel:foo:*', 'channel:hoge:*')); - $expected = array('channel:foo:*', 'channel:hoge:*'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('psubscribe', 'channel:*', 1); - $expected = array('psubscribe', 'channel:*', 1); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('channel:foo:*', 'channel:hoge:*'); - $expected = array('prefix:channel:foo:*', 'prefix:channel:hoge:*'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsTheFirstPsubscribedChannelDetails() - { - $redis = $this->getClient(); - - $this->assertSame(array('psubscribe', 'channel:*', 1), $redis->psubscribe('channel:*')); - } - - /** - * @group connected - */ - public function testCanSendPsubscribeAfterPsubscribe() - { - $redis = $this->getClient(); - - $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); - $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); - } - - /** - * @group connected - */ - public function testCanSendSubscribeAfterPsubscribe() - { - $redis = $this->getClient(); - - $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); - $this->assertSame(array('subscribe', 'channel:foo:bar', 2), $redis->subscribe('channel:foo:bar')); - } - - /** - * @group connected - */ - public function testCanSendUnsubscribeAfterPsubscribe() - { - $redis = $this->getClient(); - - $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); - $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); - $this->assertSame(array('unsubscribe', 'channel:foo:bar', 2), $redis->unsubscribe('channel:foo:bar')); - } - - /** - * @group connected - */ - public function testCanSendPunsubscribeAfterPsubscribe() - { - $redis = $this->getClient(); - - $this->assertSame(array('psubscribe', 'channel:foo:*', 1), $redis->psubscribe('channel:foo:*')); - $this->assertSame(array('psubscribe', 'channel:hoge:*', 2), $redis->psubscribe('channel:hoge:*')); - $this->assertSame(array('punsubscribe', 'channel:*:*', 2), $redis->punsubscribe('channel:*:*')); - } - - /** - * @group connected - */ - public function testCanSendQuitAfterPsubscribe() - { - $redis = $this->getClient(); - $quit = $this->getProfile()->createCommand('quit'); - - $this->assertSame(array('subscribe', 'channel1', 1), $redis->subscribe('channel1')); - $this->assertTrue($redis->executeCommand($quit)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / QUIT allowed in this context - */ - public function testCannotSendOtherCommandsAfterPsubscribe() - { - $redis = $this->getClient(); - - $redis->psubscribe('channel:*'); - $redis->set('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeTest.php deleted file mode 100644 index 47f02fdea..000000000 --- a/vendor/predis/predis/tests/Predis/Command/PubSubSubscribeTest.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-pubsub - */ -class PubSubSubscribeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\PubSubSubscribe'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SUBSCRIBE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('channel:foo', 'channel:bar'); - $expected = array('channel:foo', 'channel:bar'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('channel:foo', 'channel:bar')); - $expected = array('channel:foo', 'channel:bar'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('subscribe', 'channel', 1); - $expected = array('subscribe', 'channel', 1); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array(array('channel:foo', 'channel:bar')); - $expected = array('prefix:channel:foo', 'prefix:channel:bar'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsTheFirstSubscribedChannelDetails() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel', 1), $redis->subscribe('channel')); - } - - /** - * @group connected - */ - public function testCanSendSubscribeAfterSubscribe() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - } - - /** - * @group connected - */ - public function testCanSendPsubscribeAfterSubscribe() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('psubscribe', 'channel:*', 2), $redis->psubscribe('channel:*')); - } - - /** - * @group connected - */ - public function testCanSendUnsubscribeAfterSubscribe() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - $this->assertSame(array('unsubscribe', 'channel:foo', 1), $redis->unsubscribe('channel:foo')); - } - - /** - * @group connected - */ - public function testCanSendPunsubscribeAfterSubscribe() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - $this->assertSame(array('punsubscribe', 'channel:*', 2), $redis->punsubscribe('channel:*')); - } - - /** - * @group connected - */ - public function testCanSendQuitAfterSubscribe() - { - $redis = $this->getClient(); - $quit = $this->getProfile()->createCommand('quit'); - - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertTrue($redis->executeCommand($quit)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR only (P)SUBSCRIBE / (P)UNSUBSCRIBE / QUIT allowed in this context - */ - public function testCannotSendOtherCommandsAfterSubscribe() - { - $redis = $this->getClient(); - - $redis->subscribe('channel:foo'); - $redis->set('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeByPatternTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeByPatternTest.php deleted file mode 100644 index bbb1923e4..000000000 --- a/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeByPatternTest.php +++ /dev/null @@ -1,150 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-pubsub - */ -class PubSubUnsubscribeByPatternTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\PubSubUnsubscribeByPattern'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PUNSUBSCRIBE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('channel:foo:*', 'channel:bar:*'); - $expected = array('channel:foo:*', 'channel:bar:*'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('channel:foo:*', 'channel:bar:*')); - $expected = array('channel:foo:*', 'channel:bar:*'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('punsubscribe', 'channel:*', 1); - $expected = array('punsubscribe', 'channel:*', 1); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array(array('channel:foo:*', 'channel:bar:*')); - $expected = array('prefix:channel:foo:*', 'prefix:channel:bar:*'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testDoesNotSwitchToSubscribeMode() - { - $redis = $this->getClient(); - - $this->assertSame(array('punsubscribe', 'channel:*', 0), $redis->punsubscribe('channel:*')); - $this->assertSame('echoed', $redis->echo('echoed')); - } - - /** - * @group connected - */ - public function testUnsubscribesFromNotSubscribedChannels() - { - $redis = $this->getClient(); - - $this->assertSame(array('punsubscribe', 'channel:*', 0), $redis->punsubscribe('channel:*')); - } - - /** - * @group connected - */ - public function testUnsubscribesFromSubscribedChannels() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - $this->assertSame(array('punsubscribe', 'channel:*', 2), $redis->punsubscribe('channel:*')); - } - - /** - * @group connected - * @todo Disabled for now, must investigate why this test hangs on PUNSUBSCRIBE. - */ - public function __testUnsubscribesFromAllSubscribedChannels() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - - $this->assertSame(array('punsubscribe', 'channel:foo', 1), $redis->punsubscribe()); - $this->assertSame(array('punsubscribe', 'channel:bar', 0), $redis->getConnection()->read()); - $this->assertSame('echoed', $redis->echo('echoed')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeTest.php b/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeTest.php deleted file mode 100644 index c93927df0..000000000 --- a/vendor/predis/predis/tests/Predis/Command/PubSubUnsubscribeTest.php +++ /dev/null @@ -1,150 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-pubsub - */ -class PubSubUnsubscribeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\PubSubUnsubscribe'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'UNSUBSCRIBE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('channel1', 'channel2', 'channel3'); - $expected = array('channel1', 'channel2', 'channel3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('channel1', 'channel2', 'channel3')); - $expected = array('channel1', 'channel2', 'channel3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('unsubscribe', 'channel', 1); - $expected = array('unsubscribe', 'channel', 1); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array(array('channel1', 'channel2', 'channel3')); - $expected = array('prefix:channel1', 'prefix:channel2', 'prefix:channel3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testDoesNotSwitchToSubscribeMode() - { - $redis = $this->getClient(); - - $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); - $this->assertSame('echoed', $redis->echo('echoed')); - } - - /** - * @group connected - */ - public function testUnsubscribesFromNotSubscribedChannels() - { - $redis = $this->getClient(); - - $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); - } - - /** - * @group connected - */ - public function testUnsubscribesFromSubscribedChannels() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel', 1), $redis->subscribe('channel')); - $this->assertSame(array('unsubscribe', 'channel', 0), $redis->unsubscribe('channel')); - } - - /** - * @group connected - */ - public function testUnsubscribesFromAllSubscribedChannels() - { - $redis = $this->getClient(); - - $this->assertSame(array('subscribe', 'channel:foo', 1), $redis->subscribe('channel:foo')); - $this->assertSame(array('subscribe', 'channel:bar', 2), $redis->subscribe('channel:bar')); - - list($_, $unsubscribed1, $_) = $redis->unsubscribe(); - list($_, $unsubscribed2, $_) = $redis->getConnection()->read(); - $this->assertSameValues(array('channel:foo', 'channel:bar'), array($unsubscribed1, $unsubscribed2)); - - $this->assertSame('echoed', $redis->echo('echoed')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/RawCommandTest.php b/vendor/predis/predis/tests/Predis/Command/RawCommandTest.php deleted file mode 100644 index 9a758dc45..000000000 --- a/vendor/predis/predis/tests/Predis/Command/RawCommandTest.php +++ /dev/null @@ -1,151 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -use PredisTestCase; - -/** - * - */ -class RawCommandTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testConstructorWithCommandID() - { - $commandID = 'PING'; - $command = new RawCommand(array($commandID)); - - $this->assertSame($commandID, $command->getId()); - $this->assertEmpty($command->getArguments()); - } - - /** - * @group disconnected - */ - public function testConstructorWithCommandIDAndArguments() - { - $commandID = 'SET'; - $commandArgs = array('foo', 'bar'); - - $command = new RawCommand(array_merge((array) $commandID, $commandArgs)); - - $this->assertSame($commandID, $command->getId()); - $this->assertSame($commandArgs, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testStaticCreate() - { - $command = RawCommand::create('SET'); - $this->assertSame('SET', $command->getId()); - $this->assertEmpty($command->getArguments()); - - $command = RawCommand::create('SET', 'foo', 'bar'); - $this->assertSame('SET', $command->getId()); - $this->assertSame(array('foo', 'bar'), $command->getArguments()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Arguments array is missing the command ID - */ - public function testExceptionOnMissingCommandID() - { - $command = new RawCommand(array()); - } - - /** - * @group disconnected - * @expectedException PHPUnit_Framework_Error_Warning - * @expectedExceptionMessage Missing argument 1 for Predis\Command\RawCommand::create() - */ - public function testPHPWarningOnMissingCommandIDWithStaticCreate() - { - RawCommand::create(); - } - - /** - * @group disconnected - */ - public function testSetArguments() - { - $commandID = 'SET'; - $command = new RawCommand(array($commandID)); - - $command->setArguments($commandArgs = array('foo', 'bar')); - $this->assertSame($commandArgs, $command->getArguments()); - - $command->setArguments($commandArgs = array('hoge', 'piyo')); - $this->assertSame($commandArgs, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testSetRawArguments() - { - $commandID = 'SET'; - $command = new RawCommand(array($commandID)); - - $command->setRawArguments($commandArgs = array('foo', 'bar')); - $this->assertSame($commandArgs, $command->getArguments()); - - $command->setRawArguments($commandArgs = array('hoge', 'piyo')); - $this->assertSame($commandArgs, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testSetAndGetHash() - { - $hash = "key-hash"; - $arguments = array('SET', 'key', 'value'); - $command = new RawCommand($arguments); - - $this->assertNull($command->getHash()); - - $command->setHash($hash); - $this->assertSame($hash, $command->getHash()); - - $command->setArguments(array('hoge', 'piyo')); - $this->assertNull($command->getHash()); - } - - /** - * @group disconnected - */ - public function testNormalizesCommandIdentifiersToUppercase() - { - $command = new RawCommand(array('set', 'key', 'value')); - - $this->assertSame('SET', $command->getId()); - } - - /** - * @group disconnected - */ - public function testToString() - { - $arguments = array('SET', 'key', 'value'); - $expected = implode(' ', $arguments); - - $command = new RawCommand($arguments); - - $this->assertEquals($expected, (string) $command); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ScriptedCommandTest.php b/vendor/predis/predis/tests/Predis/Command/ScriptedCommandTest.php deleted file mode 100644 index b37092812..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ScriptedCommandTest.php +++ /dev/null @@ -1,200 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -use PredisTestCase; - -/** - * @group realm-scripting - */ -class ScriptedCommandTest extends PredisTestCase -{ - const LUA_SCRIPT = 'return { KEYS[1], KEYS[2], ARGV[1], ARGV[2] }'; - const LUA_SCRIPT_SHA1 = '6e07f61f502e36d123fe28523076af588f5c315e'; - - /** - * @group disconnected - */ - public function testGetArguments() - { - $arguments = array('key1', 'key2', 'value1', 'value2'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->once()) - ->method('getKeysCount') - ->will($this->returnValue(2)); - $command->setArguments($arguments); - - $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 2), $arguments), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testGetArgumentsWithNegativeKeysCount() - { - $arguments = array('key1', 'key2', 'value1', 'value2'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->once()) - ->method('getKeysCount') - ->will($this->returnValue(-2)); - $command->setArguments($arguments); - - $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 2), $arguments), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testGetArgumentsWithZeroKeysCount() - { - $arguments = array('value1', 'value2', 'value3'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->once()) - ->method('getKeysCount') - ->will($this->returnValue(0)); - $command->setArguments($arguments); - - $this->assertSame(array_merge(array(self::LUA_SCRIPT_SHA1, 0), $arguments), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testGetKeys() - { - $arguments = array('key1', 'key2', 'value1', 'value2'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->exactly(2)) - ->method('getKeysCount') - ->will($this->returnValue(2)); - $command->setArguments($arguments); - - $this->assertSame(array('key1', 'key2'), $command->getKeys()); - } - - /** - * @group disconnected - */ - public function testGetKeysWithZeroKeysCount() - { - $arguments = array('value1', 'value2', 'value3'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->exactly(2)) - ->method('getKeysCount') - ->will($this->returnValue(0)); - $command->setArguments($arguments); - - $this->assertSame(array(), $command->getKeys()); - } - - /** - * @group disconnected - */ - public function testGetKeysWithNegativeKeysCount() - { - $arguments = array('key1', 'key2', 'value1', 'value2'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->exactly(2)) - ->method('getKeysCount') - ->will($this->returnValue(-2)); - $command->setArguments($arguments); - - $this->assertSame(array('key1', 'key2'), $command->getKeys()); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('foo', 'hoge', 'bar', 'piyo'); - $expected = array('prefix:foo', 'prefix:hoge'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->exactly(2)) - ->method('getKeysCount') - ->will($this->returnValue(2)); - $command->setArguments($arguments); - - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getKeys()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysWithNegativeKeysCount() - { - $arguments = array('foo', 'hoge', 'bar', 'piyo'); - $expected = array('prefix:foo', 'prefix:hoge'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->exactly(2)) - ->method('getKeysCount') - ->will($this->returnValue(-2)); - $command->setArguments($arguments); - - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getKeys()); - } - - /** - * @group disconnected - */ - public function testGetScriptHash() - { - $arguments = array('key1', 'key2', 'value1', 'value2'); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript', 'getKeysCount')); - $command->expects($this->once()) - ->method('getScript') - ->will($this->returnValue(self::LUA_SCRIPT)); - $command->expects($this->once()) - ->method('getKeysCount') - ->will($this->returnValue(2)); - $command->setArguments($arguments); - - $this->assertSame(self::LUA_SCRIPT_SHA1, $command->getScriptHash()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerBackgroundRewriteAOFTest.php b/vendor/predis/predis/tests/Predis/Command/ServerBackgroundRewriteAOFTest.php deleted file mode 100644 index 9706f1125..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerBackgroundRewriteAOFTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerBackgroundRewriteAOFTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerBackgroundRewriteAOF'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'BGREWRITEAOF'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerBackgroundSaveTest.php b/vendor/predis/predis/tests/Predis/Command/ServerBackgroundSaveTest.php deleted file mode 100644 index 54d3b2fd1..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerBackgroundSaveTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerBackgroundSaveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerBackgroundSave'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'BGSAVE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerClientTest.php b/vendor/predis/predis/tests/Predis/Command/ServerClientTest.php deleted file mode 100644 index db053de51..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerClientTest.php +++ /dev/null @@ -1,221 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerClientTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerClient'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'CLIENT'; - } - - /** - * @group disconnected - */ - public function testFilterArgumentsOfClientKill() - { - $arguments = array('kill', '127.0.0.1:45393'); - $expected = array('kill', '127.0.0.1:45393'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsOfClientList() - { - $arguments = array('list'); - $expected = array('list'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsOfClientGetname() - { - $arguments = $expected = array('getname'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsOfClientSetname() - { - $arguments = $expected = array('setname', 'connection-a'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponseOfClientKill() - { - $command = $this->getCommand(); - $command->setArguments(array('kill')); - - $this->assertSame(true, $command->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testParseResponseOfClientList() - { - $command = $this->getCommand(); - $command->setArguments(array('list')); - - $raw =<<'127.0.0.1:45393','fd'=>'6','idle'=>'0','flags'=>'N','db'=>'0','sub'=>'0','psub'=>'0'), - array('addr'=>'127.0.0.1:45394','fd'=>'7','idle'=>'0','flags'=>'N','db'=>'0','sub'=>'0','psub'=>'0'), - array('addr'=>'127.0.0.1:45395','fd'=>'8','idle'=>'0','flags'=>'N','db'=>'0','sub'=>'0','psub'=>'0'), - ); - - $this->assertSame($parsed, $command->parseResponse($raw)); - } - - /** - * @group connected - */ - public function testReturnsListOfConnectedClients() - { - $redis = $this->getClient(); - - $this->assertInternalType('array', $clients = $redis->client('LIST')); - $this->assertGreaterThanOrEqual(1, count($clients)); - $this->assertInternalType('array', $clients[0]); - $this->assertArrayHasKey('addr', $clients[0]); - $this->assertArrayHasKey('fd', $clients[0]); - $this->assertArrayHasKey('idle', $clients[0]); - $this->assertArrayHasKey('flags', $clients[0]); - $this->assertArrayHasKey('db', $clients[0]); - $this->assertArrayHasKey('sub', $clients[0]); - $this->assertArrayHasKey('psub', $clients[0]); - } - - /** - * @group connected - */ - public function testGetsNameOfConnection() - { - $this->markTestSkippedOnRedisVersionBelow('2.6.9'); - - $redis = $this->getClient(); - $clientName = $redis->client('GETNAME'); - $this->assertNull($clientName); - - $expectedConnectionName = 'foo-bar'; - $this->assertTrue($redis->client('SETNAME', $expectedConnectionName)); - $this->assertEquals($expectedConnectionName, $redis->client('GETNAME')); - } - - /** - * @group connected - */ - public function testSetsNameOfConnection() - { - $this->markTestSkippedOnRedisVersionBelow('2.6.9'); - - $redis = $this->getClient(); - - $expectedConnectionName = 'foo-baz'; - $this->assertTrue($redis->client('SETNAME', $expectedConnectionName)); - $this->assertEquals($expectedConnectionName, $redis->client('GETNAME')); - } - - /** - * @return array - */ - public function invalidConnectionNameProvider() - { - return array( - array('foo space'), - array('foo \n'), - array('foo $'), - ); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @dataProvider invalidConnectionNameProvider - */ - public function testInvalidSetNameOfConnection($invalidConnectionName) - { - $this->markTestSkippedOnRedisVersionBelow('2.6.9'); - - $redis = $this->getClient(); - $redis->client('SETNAME', $invalidConnectionName); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptioOnWrongModifier() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->client('FOO')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR No such client - */ - public function testThrowsExceptionWhenKillingUnknownClient() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->client('KILL', '127.0.0.1:65535')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerConfigTest.php b/vendor/predis/predis/tests/Predis/Command/ServerConfigTest.php deleted file mode 100644 index e27e0927e..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerConfigTest.php +++ /dev/null @@ -1,171 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerConfigTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerConfig'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'CONFIG'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('GET', 'slowlog'); - $expected = array('GET', 'slowlog'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponseOfConfigGet() - { - $raw = array('slowlog-log-slower-than','10000','slowlog-max-len','64','loglevel','verbose'); - $expected = array( - 'slowlog-log-slower-than' => '10000', - 'slowlog-max-len' => '64', - 'loglevel' => 'verbose', - ); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testParseResponseOfConfigSet() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testParseResponseOfConfigResetstat() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(true)); - } - - /** - * @group connected - */ - public function testReturnsListOfConfigurationValues() - { - $redis = $this->getClient(); - - $this->assertInternalType('array', $configs = $redis->config('GET', '*')); - $this->assertGreaterThan(1, count($configs)); - $this->assertArrayHasKey('loglevel', $configs); - $this->assertArrayHasKey('appendonly', $configs); - $this->assertArrayHasKey('dbfilename', $configs); - } - - /** - * @group connected - */ - public function testReturnsListOfOneConfigurationEntry() - { - $redis = $this->getClient(); - - $this->assertInternalType('array', $configs = $redis->config('GET', 'dbfilename')); - $this->assertEquals(1, count($configs)); - $this->assertArrayHasKey('dbfilename', $configs); - } - - /** - * @group connected - */ - public function testReturnsEmptyListOnUnknownConfigurationEntry() - { - $redis = $this->getClient(); - - $this->assertSame(array(), $redis->config('GET', 'foobar')); - } - - /** - * @group connected - */ - public function testReturnsTrueOnSuccessfulConfiguration() - { - $redis = $this->getClient(); - - $previous = $redis->config('GET', 'loglevel'); - - $this->assertTrue($redis->config('SET', 'loglevel', 'notice')); - $this->assertSame(array('loglevel' => 'notice'), $redis->config('GET', 'loglevel')); - - // We set the loglevel configuration to the previous value. - $redis->config('SET', 'loglevel', $previous['loglevel']); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR Unsupported CONFIG parameter: foo - */ - public function testThrowsExceptionWhenSettingUnknownConfiguration() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->config('SET', 'foo', 'bar')); - } - - /** - * @group connected - */ - public function testReturnsTrueOnResetstat() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->config('RESETSTAT')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptionOnUnknownSubcommand() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->config('FOO')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerDatabaseSizeTest.php b/vendor/predis/predis/tests/Predis/Command/ServerDatabaseSizeTest.php deleted file mode 100644 index b984e3739..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerDatabaseSizeTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerDatabaseSizeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerDatabaseSize'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'DBSIZE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(100, $this->getCommand()->parseResponse(100)); - } - - /** - * @group connected - */ - public function testReturnsCurrentSizeOfDatabase() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $this->assertGreaterThan(0, $redis->dbsize()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerEvalSHATest.php b/vendor/predis/predis/tests/Predis/Command/ServerEvalSHATest.php deleted file mode 100644 index 3f523171c..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerEvalSHATest.php +++ /dev/null @@ -1,136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-scripting - */ -class ServerEvalSHATest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerEvalSHA'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'EVALSHA'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('9d0c0826bde023cc39eebaaf832c32a890f3b088', 1, 'foo', 'bar'); - $expected = array('9d0c0826bde023cc39eebaaf832c32a890f3b088', 1, 'foo', 'bar'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertSame('bar', $this->getCommand()->parseResponse('bar')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $sha1 = 'a42059b356c875f0717db19a51f6aaca9ae659ea'; - - $arguments = array($sha1, 2, 'foo', 'hoge', 'bar', 'piyo'); - $expected = array($sha1, 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testGetScriptHash() - { - $command = $this->getCommandWithArgumentsArray(array($sha1 = sha1('return true')), 0); - $this->assertSame($sha1, $command->getScriptHash()); - } - - /** - * @group connected - */ - public function testExecutesSpecifiedLuaScript() - { - $redis = $this->getClient(); - - $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; - $sha1 = sha1($lua); - $result = array('foo', 'hoge', 'bar', 'piyo'); - - $this->assertSame($result, $redis->eval($lua, 2, 'foo', 'hoge', 'bar', 'piyo')); - $this->assertSame($result, $redis->evalsha($sha1, 2, 'foo', 'hoge', 'bar', 'piyo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptionOnWrongNumberOfKeys() - { - $redis = $this->getClient(); - - $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; - $sha1 = sha1($lua); - - $redis->eval($lua, 2, 'foo', 'hoge', 'bar', 'piyo'); - $redis->evalsha($sha1, 3, 'foo', 'hoge'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptionOnInvalidScript() - { - $redis = $this->getClient(); - - $redis->evalsha('ffffffffffffffffffffffffffffffffffffffff', 0); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerEvalTest.php b/vendor/predis/predis/tests/Predis/Command/ServerEvalTest.php deleted file mode 100644 index 02a1b032c..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerEvalTest.php +++ /dev/null @@ -1,131 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-scripting - */ -class ServerEvalTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerEval'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'EVAL'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('return redis.call("SET", KEYS[1], ARGV[1])', 1, 'foo', 'bar'); - $expected = array('return redis.call("SET", KEYS[1], ARGV[1])', 1, 'foo', 'bar'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertSame('bar', $this->getCommand()->parseResponse('bar')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; - - $arguments = array($lua, 2, 'foo', 'hoge', 'bar', 'piyo'); - $expected = array($lua, 2, 'prefix:foo', 'prefix:hoge', 'bar', 'piyo'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testGetScriptHash() - { - $command = $this->getCommandWithArgumentsArray(array($lua = 'return true', 0)); - $this->assertSame(sha1($lua), $command->getScriptHash()); - } - - /** - * @group connected - */ - public function testExecutesSpecifiedLuaScript() - { - $redis = $this->getClient(); - - $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; - $result = array('foo', 'hoge', 'bar', 'piyo'); - - $this->assertSame($result, $redis->eval($lua, 2, 'foo', 'hoge', 'bar', 'piyo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptionOnWrongNumberOfKeys() - { - $redis = $this->getClient(); - $lua = 'return {KEYS[1],KEYS[2],ARGV[1],ARGV[2]}'; - - $redis->eval($lua, 3, 'foo', 'hoge'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptionOnInvalidScript() - { - $redis = $this->getClient(); - - $redis->eval('invalid', 0); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerFlushAllTest.php b/vendor/predis/predis/tests/Predis/Command/ServerFlushAllTest.php deleted file mode 100644 index 6122e5d30..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerFlushAllTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerFlushAllTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerFlushAll'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'FLUSHALL'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerFlushDatabaseTest.php b/vendor/predis/predis/tests/Predis/Command/ServerFlushDatabaseTest.php deleted file mode 100644 index cb206f824..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerFlushDatabaseTest.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerFlushDatabaseTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerFlushDatabase'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'FLUSHDB'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group connected - */ - public function testFlushesTheEntireLogicalDatabase() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertTrue($redis->flushdb()); - $this->assertFalse($redis->exists('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerInfoTest.php b/vendor/predis/predis/tests/Predis/Command/ServerInfoTest.php deleted file mode 100644 index 20c36e878..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerInfoTest.php +++ /dev/null @@ -1,287 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerInfoTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerInfo'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'INFO'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw =<< '2.4.4', - 'redis_git_sha1' => 'bc62bc5e', - 'redis_git_dirty' => '0', - 'arch_bits' => '32', - 'multiplexing_api' => 'epoll', - 'process_id' => '15640', - 'uptime_in_seconds' => '792', - 'uptime_in_days' => '0', - 'lru_clock' => '197890', - 'used_cpu_sys' => '0.08', - 'used_cpu_user' => '0.10', - 'used_cpu_sys_children' => '0.00', - 'used_cpu_user_children' => '0.00', - 'connected_clients' => '1', - 'connected_slaves' => '0', - 'client_longest_output_list' => '0', - 'client_biggest_input_buf' => '0', - 'blocked_clients' => '0', - 'used_memory' => '556156', - 'used_memory_human' => '543.12K', - 'used_memory_rss' => '1396736', - 'used_memory_peak' => '547688', - 'used_memory_peak_human' => '534.85K', - 'mem_fragmentation_ratio' => '2.51', - 'mem_allocator' => 'jemalloc-2.2.1', - 'loading' => '0', - 'aof_enabled' => '0', - 'changes_since_last_save' => '0', - 'bgsave_in_progress' => '0', - 'last_save_time' => '1323183872', - 'bgrewriteaof_in_progress' => '0', - 'total_connections_received' => '2', - 'total_commands_processed' => '1', - 'expired_keys' => '0', - 'evicted_keys' => '0', - 'keyspace_hits' => '0', - 'keyspace_misses' => '0', - 'pubsub_channels' => '0', - 'pubsub_patterns' => '0', - 'latest_fork_usec' => '0', - 'vm_enabled' => '0', - 'role' => 'master', - 'db0' => array('keys' => '2', 'expires' => '0'), - 'db5' => array('keys' => '1', 'expires' => '0'), - ); - - $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testCanParseResponsesFromRedis30() - { - $raw =<< '2.9.0', - 'redis_git_sha1' => '237194b7', - 'redis_git_dirty' => '0', - 'arch_bits' => '32', - 'multiplexing_api' => 'epoll', - 'process_id' => '16620', - 'tcp_port' => '6379', - 'uptime_in_seconds' => '444', - 'uptime_in_days' => '0', - 'lru_clock' => '198040', - 'connected_clients' => '1', - 'client_longest_output_list' => '0', - 'client_biggest_input_buf' => '0', - 'blocked_clients' => '0', - 'used_memory' => '628076', - 'used_memory_human' => '613.36K', - 'used_memory_rss' => '1568768', - 'used_memory_peak' => '570056', - 'used_memory_peak_human' => '556.70K', - 'used_memory_lua' => '14336', - 'mem_fragmentation_ratio' => '2.50', - 'mem_allocator' => 'jemalloc-2.2.1', - 'loading' => '0', - 'aof_enabled' => '0', - 'changes_since_last_save' => '0', - 'bgsave_in_progress' => '0', - 'last_save_time' => '1323185719', - 'bgrewriteaof_in_progress' => '0', - 'total_connections_received' => '4', - 'total_commands_processed' => '3', - 'rejected_connections' => '0', - 'expired_keys' => '0', - 'evicted_keys' => '0', - 'keyspace_hits' => '0', - 'keyspace_misses' => '0', - 'pubsub_channels' => '0', - 'pubsub_patterns' => '0', - 'latest_fork_usec' => '0', - 'role' => 'master', - 'connected_slaves' => '0', - 'used_cpu_sys' => '0.06', - 'used_cpu_user' => '0.06', - 'used_cpu_sys_children' => '0.00', - 'used_cpu_user_children' => '0.00', - 'cluster_enabled' => '0', - 'db0' => array('keys' => '2', 'expires' => '0'), - 'db5' => array('keys' => '1','expires' => '0'), - ); - - $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); - } - - /** - * @group connected - */ - public function testReturnsAnArrayOfInfo() - { - $redis = $this->getClient(); - $command = $this->getCommand(); - - $this->assertInternalType('array', $info = $redis->executeCommand($command)); - $this->assertArrayHasKey('redis_version', $info); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerInfoV26xTest.php b/vendor/predis/predis/tests/Predis/Command/ServerInfoV26xTest.php deleted file mode 100644 index a9a89b688..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerInfoV26xTest.php +++ /dev/null @@ -1,305 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerInfoV26xTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerInfoV26x'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'INFO'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw =<< array( - 'redis_version' => '2.9.0', - 'redis_git_sha1' => '237194b7', - 'redis_git_dirty' => '0', - 'arch_bits' => '32', - 'multiplexing_api' => 'epoll', - 'process_id' => '16620', - 'tcp_port' => '6379', - 'uptime_in_seconds' => '444', - 'uptime_in_days' => '0', - 'lru_clock' => '198040', - ), - 'Clients' => array( - 'connected_clients' => '1', - 'client_longest_output_list' => '0', - 'client_biggest_input_buf' => '0', - 'blocked_clients' => '0', - ), - 'Memory' => array( - 'used_memory' => '628076', - 'used_memory_human' => '613.36K', - 'used_memory_rss' => '1568768', - 'used_memory_peak' => '570056', - 'used_memory_peak_human' => '556.70K', - 'used_memory_lua' => '14336', - 'mem_fragmentation_ratio' => '2.50', - 'mem_allocator' => 'jemalloc-2.2.1', - ), - 'Persistence' => array( - 'loading' => '0', - 'aof_enabled' => '0', - 'changes_since_last_save' => '0', - 'bgsave_in_progress' => '0', - 'last_save_time' => '1323185719', - 'bgrewriteaof_in_progress' => '0', - ), - 'Stats' => array( - 'total_connections_received' => '4', - 'total_commands_processed' => '3', - 'rejected_connections' => '0', - 'expired_keys' => '0', - 'evicted_keys' => '0', - 'keyspace_hits' => '0', - 'keyspace_misses' => '0', - 'pubsub_channels' => '0', - 'pubsub_patterns' => '0', - 'latest_fork_usec' => '0', - ), - 'Replication' => array( - 'role' => 'master', - 'connected_slaves' => '0', - ), - 'CPU' => array( - 'used_cpu_sys' => '0.06', - 'used_cpu_user' => '0.06', - 'used_cpu_sys_children' => '0.00', - 'used_cpu_user_children' => '0.00', - ), - 'Cluster' => array( - 'cluster_enabled' => '0', - ), - 'Keyspace' => array( - 'db0' => array('keys' => '2', 'expires' => '0'), - 'db5' => array('keys' => '1', 'expires' => '0') - ), - ); - - $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testCanParseResponsesFromOlderRedisVersions() - { - $raw =<< '2.4.4', - 'redis_git_sha1' => 'bc62bc5e', - 'redis_git_dirty' => '0', - 'arch_bits' => '32', - 'multiplexing_api' => 'epoll', - 'process_id' => '15640', - 'uptime_in_seconds' => '792', - 'uptime_in_days' => '0', - 'lru_clock' => '197890', - 'used_cpu_sys' => '0.08', - 'used_cpu_user' => '0.10', - 'used_cpu_sys_children' => '0.00', - 'used_cpu_user_children' => '0.00', - 'connected_clients' => '1', - 'connected_slaves' => '0', - 'client_longest_output_list' => '0', - 'client_biggest_input_buf' => '0', - 'blocked_clients' => '0', - 'used_memory' => '556156', - 'used_memory_human' => '543.12K', - 'used_memory_rss' => '1396736', - 'used_memory_peak' => '547688', - 'used_memory_peak_human' => '534.85K', - 'mem_fragmentation_ratio' => '2.51', - 'mem_allocator' => 'jemalloc-2.2.1', - 'loading' => '0', - 'aof_enabled' => '0', - 'changes_since_last_save' => '0', - 'bgsave_in_progress' => '0', - 'last_save_time' => '1323183872', - 'bgrewriteaof_in_progress' => '0', - 'total_connections_received' => '2', - 'total_commands_processed' => '1', - 'expired_keys' => '0', - 'evicted_keys' => '0', - 'keyspace_hits' => '0', - 'keyspace_misses' => '0', - 'pubsub_channels' => '0', - 'pubsub_patterns' => '0', - 'latest_fork_usec' => '0', - 'vm_enabled' => '0', - 'role' => 'master', - 'db0' => array('keys' => '2', 'expires' => '0'), - 'db5' => array('keys' => '1', 'expires' => '0'), - ); - - $this->assertSame($expected, $this->getCommand()->parseResponse($raw)); - } - - /** - * @group connected - */ - public function testReturnsAnArrayOfInfo() - { - $redis = $this->getClient(); - $command = $this->getCommand(); - - $this->assertInternalType('array', $info = $redis->executeCommand($command)); - $this->assertArrayHasKey('redis_version', isset($info['Server']) ? $info['Server'] : $info); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerLastSaveTest.php b/vendor/predis/predis/tests/Predis/Command/ServerLastSaveTest.php deleted file mode 100644 index f0511271c..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerLastSaveTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerLastSaveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerLastSave'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'LASTSAVE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(100, $this->getCommand()->parseResponse(100)); - } - - /** - * @group connected - */ - public function testReturnsIntegerValue() - { - $redis = $this->getClient(); - - $this->assertInternalType('integer', $redis->lastsave()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerMonitorTest.php b/vendor/predis/predis/tests/Predis/Command/ServerMonitorTest.php deleted file mode 100644 index 01bd6aa6e..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerMonitorTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - * @group realm-monitor - */ -class ServerMonitorTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerMonitor'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'MONITOR'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group connected - */ - public function testReturnsTrueAndReadsEventsFromTheConnection() - { - $connection = $this->getClient()->getConnection(); - $command = $this->getCommand(); - - $this->assertTrue($connection->executeCommand($command)); - - // NOTE: Starting with 2.6 Redis does not return the "MONITOR" message after - // +OK to the client that issued the MONITOR command. - if (version_compare($this->getProfile()->getVersion(), '2.4', '<=')) { - $this->assertRegExp('/\d+.\d+(\s?\(db \d+\))? "MONITOR"/', $connection->read()); - } - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerObjectTest.php b/vendor/predis/predis/tests/Predis/Command/ServerObjectTest.php deleted file mode 100644 index 1e4572bec..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerObjectTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerObjectTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerObject'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'OBJECT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('REFCOUNT', 'key'); - $expected = array('REFCOUNT', 'key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('ziplist', $this->getCommand()->parseResponse('ziplist')); - } - - /** - * @group connected - */ - public function testObjectRefcount() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $this->assertInternalType('integer', $redis->object('REFCOUNT', 'foo')); - } - - /** - * @group connected - */ - public function testObjectIdletime() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $this->assertInternalType('integer', $redis->object('IDLETIME', 'foo')); - } - - /** - * @group connected - */ - public function testObjectEncoding() - { - $redis = $this->getClient(); - - $redis->lpush('list:metavars', 'foo', 'bar'); - $this->assertSame('ziplist', $redis->object('ENCODING', 'list:metavars')); - } - - /** - * @group connected - */ - public function testReturnsNullOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertNull($redis->object('REFCOUNT', 'foo')); - $this->assertNull($redis->object('IDLETIME', 'foo')); - $this->assertNull($redis->object('ENCODING', 'foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptionOnInvalidSubcommand() - { - $redis = $this->getClient(); - - $redis->object('INVALID', 'foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerSaveTest.php b/vendor/predis/predis/tests/Predis/Command/ServerSaveTest.php deleted file mode 100644 index fecf1db98..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerSaveTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerSaveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerSave'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SAVE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerScriptTest.php b/vendor/predis/predis/tests/Predis/Command/ServerScriptTest.php deleted file mode 100644 index f03ab781e..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerScriptTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-scripting - */ -class ServerScriptTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerScript'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SCRIPT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('EXISTS', '9d0c0826bde023cc39eebaaf832c32a890f3b088', 'ffffffffffffffffffffffffffffffffffffffff'); - $expected = array('EXISTS', '9d0c0826bde023cc39eebaaf832c32a890f3b088', 'ffffffffffffffffffffffffffffffffffffffff'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group connected - * @todo We should probably convert integers to booleans. - */ - public function testExistsReturnAnArrayOfValues() - { - $redis = $this->getClient(); - - $redis->eval($lua = 'return true', 0); - $sha1 = sha1($lua); - - $this->assertSame(array(1, 0), $redis->script('EXISTS', $sha1, 'ffffffffffffffffffffffffffffffffffffffff')); - } - - /** - * @group connected - */ - public function testLoadReturnsHashOfScripts() - { - $redis = $this->getClient(); - - $lua = 'return true'; - $sha1 = sha1($lua); - - $this->assertSame($sha1, $redis->script('LOAD', $lua)); - } - - /** - * @group connected - */ - public function testFlushesExistingScripts() - { - $redis = $this->getClient(); - - $sha1 = $redis->script('LOAD', 'return true'); - - $this->assertTrue($redis->script('FLUSH')); - $this->assertSame(array(0), $redis->script('EXISTS', $sha1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptionOnInvalidSubcommand() - { - $redis = $this->getClient(); - - $redis->script('INVALID'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerShutdownTest.php b/vendor/predis/predis/tests/Predis/Command/ServerShutdownTest.php deleted file mode 100644 index ced931eeb..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerShutdownTest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerShutdownTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerShutdown'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SHUTDOWN'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerSlaveOfTest.php b/vendor/predis/predis/tests/Predis/Command/ServerSlaveOfTest.php deleted file mode 100644 index f6932ff15..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerSlaveOfTest.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerSlaveOfTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerSlaveOf'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SLAVEOF'; - } - - /** - * @group disconnected - */ - public function testFilterArgumentsHostPortArray() - { - $arguments = array('127.0.0.1', '80'); - $expected = array('127.0.0.1', '80'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsNoOneArray() - { - $arguments = array('NO', 'ONE'); - $expected = array('NO', 'ONE'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsNoOneString() - { - $arguments = array('NO ONE'); - $expected = array('NO', 'ONE'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerSlowlogTest.php b/vendor/predis/predis/tests/Predis/Command/ServerSlowlogTest.php deleted file mode 100644 index 1590a2e7f..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerSlowlogTest.php +++ /dev/null @@ -1,118 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * In order to support the output of SLOWLOG, the backend connection - * must be able to parse nested multibulk replies deeper than 2 levels. - * - * @group commands - * @group realm-server - */ -class ServerSlowlogTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerSlowlog'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SLOWLOG'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('GET', '2'); - $expected = array('GET', '2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array(array(0, 1323163469, 12451, array('SORT', 'list:unordered'))); - $expected = array( - array( - 'id' => 0, - 'timestamp' => 1323163469, - 'duration' => 12451, - 'command' => array('SORT', 'list:unordered'), - ), - ); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group connected - */ - public function testReturnsAnArrayOfLoggedCommands() - { - $redis = $this->getClient(); - - $config = $redis->config('get', 'slowlog-log-slower-than'); - $threshold = array_pop($config); - - $redis->config('set', 'slowlog-log-slower-than', 0); - $redis->set('foo', 'bar'); - - $this->assertInternalType('array', $slowlog = $redis->slowlog('GET')); - $this->assertGreaterThan(0, count($slowlog)); - - $this->assertInternalType('array', $slowlog[0]); - $this->assertGreaterThan(0, $slowlog[0]['id']); - $this->assertGreaterThan(0, $slowlog[0]['timestamp']); - $this->assertGreaterThan(0, $slowlog[0]['duration']); - $this->assertInternalType('array', $slowlog[0]['command']); - - $redis->config('set', 'slowlog-log-slower-than', $threshold); - } - - /** - * @group connected - */ - public function testCanResetTheLog() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->slowlog('RESET')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - */ - public function testThrowsExceptionOnInvalidSubcommand() - { - $redis = $this->getClient(); - - $redis->slowlog('INVALID'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ServerTimeTest.php b/vendor/predis/predis/tests/Predis/Command/ServerTimeTest.php deleted file mode 100644 index 41c583c4f..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ServerTimeTest.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-server - */ -class ServerTimeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ServerTime'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'TIME'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array(); - $expected = array(); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $expected = array(1331114908, 453990); - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($expected)); - } - - /** - * @group connected - */ - public function testReturnsServerTime() - { - $redis = $this->getClient(); - - $this->assertInternalType('array', $time = $redis->time()); - $this->assertInternalType('string', $time[0]); - $this->assertInternalType('string', $time[1]); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetAddTest.php b/vendor/predis/predis/tests/Predis/Command/SetAddTest.php deleted file mode 100644 index 012eb2956..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetAddTest.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetAddTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetAdd'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SADD'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'member1', 'member2', 'member3'); - $expected = array('key', 'member1', 'member2', 'member3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsValuesAsSingleArray() - { - $arguments = array('key', array('member1', 'member2', 'member3')); - $expected = array('key', 'member1', 'member2', 'member3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'member1', 'member2', 'member3'); - $expected = array('prefix:key', 'member1', 'member2', 'member3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testAddsMembersToSet() - { - $redis = $this->getClient(); - - $this->assertSame(1, $redis->sadd('letters', 'a')); - $this->assertSame(2, $redis->sadd('letters', 'b', 'c')); - $this->assertSame(0, $redis->sadd('letters', 'b')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->sadd('metavars', 'hoge'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetCardinalityTest.php b/vendor/predis/predis/tests/Predis/Command/SetCardinalityTest.php deleted file mode 100644 index 4bc34ab83..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetCardinalityTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetCardinalityTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetCardinality'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SCARD'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsNumberOfMembers() - { - $redis = $this->getClient(); - - $redis->sadd('letters', 'a', 'b', 'c', 'd'); - - $this->assertSame(4, $redis->scard('letters')); - } - - /** - * @group connected - */ - public function testReturnsZeroOnEmptySet() - { - $redis = $this->getClient(); - - $this->assertSame(0, $redis->scard('letters')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('metavars', 'foo'); - $redis->scard('metavars'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetDifferenceStoreTest.php b/vendor/predis/predis/tests/Predis/Command/SetDifferenceStoreTest.php deleted file mode 100644 index 440d92489..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetDifferenceStoreTest.php +++ /dev/null @@ -1,140 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetDifferenceStoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetDifferenceStore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SDIFFSTORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('key:destination', 'key:source1', 'key:source:2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsSourceKeysAsSingleArray() - { - $arguments = array('key:destination', array('key:source1', 'key:source:2')); - $expected = array('key:destination', 'key:source1', 'key:source:2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('prefix:key:destination', 'prefix:key:source1', 'prefix:key:source:2'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testStoresMembersOfSetOnSingleSet() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - - $this->assertSame(7, $redis->sdiffstore('letters:destination', 'letters:1st')); - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); - } - - /** - * @group connected - */ - public function testStoresDifferenceOfMultipleSets() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); - $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); - - $this->assertSame(3, $redis->sdiffstore('letters:destination', 'letters:1st', 'letters:2nd')); - $this->assertSameValues(array('b', 'd', 'e'), $redis->smembers('letters:destination')); - - $this->assertSame(1, $redis->sdiffstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); - $this->assertSameValues(array('d'), $redis->smembers('letters:destination')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongTypeOfSourceKey() - { - $redis = $this->getClient(); - - $redis->set('set:source', 'foo'); - $redis->sdiffstore('set:destination', 'set:source'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetDifferenceTest.php b/vendor/predis/predis/tests/Predis/Command/SetDifferenceTest.php deleted file mode 100644 index 0fd326e8e..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetDifferenceTest.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetDifferenceTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetDifference'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SDIFF'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('member1', 'member2', 'member3'); - $expected = array('member1', 'member2', 'member3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsMembersOnSingleKeyOrNonExistingSetForDifference() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sdiff('letters:1st')); - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sdiff('letters:1st', 'letters:2nd')); - } - - /** - * @group connected - */ - public function testReturnsMembersFromDifferenceAmongSets() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); - $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); - - $this->assertSameValues(array('b', 'd', 'e'), $redis->sdiff('letters:1st', 'letters:2nd')); - $this->assertSameValues(array('d'), $redis->sdiff('letters:1st', 'letters:2nd', 'letters:3rd')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('set:foo', 'a'); - $redis->sdiff('set:foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetIntersectionStoreTest.php b/vendor/predis/predis/tests/Predis/Command/SetIntersectionStoreTest.php deleted file mode 100644 index 30e27eda2..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetIntersectionStoreTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetIntersectionStoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetIntersectionStore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SINTERSTORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('key:destination', 'key:source1', 'key:source:2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsSourceKeysAsSingleArray() - { - $arguments = array('key:destination', array('key:source1', 'key:source:2')); - $expected = array('key:destination', 'key:source1', 'key:source:2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('prefix:key:destination', 'prefix:key:source1', 'prefix:key:source:2'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testStoresMembersOfSetOnSingleKey() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - - $this->assertSame(7, $redis->sinterstore('letters:destination', 'letters:1st')); - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); - } - - /** - * @group connected - */ - public function testDoesNotStoreOnNonExistingSetForIntersection() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - - $this->assertSame(0, $redis->sinterstore('letters:destination', 'letters:1st', 'letters:2nd')); - $this->assertFalse($redis->exists('letters:destination')); - } - - /** - * @group connected - */ - public function testStoresIntersectionOfMultipleSets() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); - $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); - - $this->assertSame(4, $redis->sinterstore('letters:destination', 'letters:1st', 'letters:2nd')); - $this->assertSameValues(array('a', 'c', 'f', 'g'), $redis->smembers('letters:destination')); - - $this->assertSame(2, $redis->sinterstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); - $this->assertSameValues(array('a', 'f'), $redis->smembers('letters:destination')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongTypeOfSourceKey() - { - $redis = $this->getClient(); - - $redis->set('set:source', 'foo'); - $redis->sinterstore('set:destination', 'set:source'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetIntersectionTest.php b/vendor/predis/predis/tests/Predis/Command/SetIntersectionTest.php deleted file mode 100644 index b15fcdbaa..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetIntersectionTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetIntersectionTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetIntersection'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SINTER'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('member1', 'member2', 'member3'); - $expected = array('member1', 'member2', 'member3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsMembersOfSetOnSingleKey() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sinter('letters:1st')); - } - - /** - * @group connected - */ - public function testReturnsEmptyArrayOnNonExistingSetForIntersection() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - - $this->assertSameValues(array(), $redis->sinter('letters:1st', 'letters:2nd')); - } - - /** - * @group connected - */ - public function testReturnsMembersFromIntersectionAmongSets() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - $redis->sadd('letters:2nd', 'a', 'c', 'f', 'g'); - $redis->sadd('letters:3rd', 'a', 'b', 'e', 'f'); - - $this->assertSameValues(array('a', 'c', 'f', 'g'), $redis->sinter('letters:1st', 'letters:2nd')); - $this->assertSameValues(array('a', 'f'), $redis->sinter('letters:1st', 'letters:2nd', 'letters:3rd')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('set:foo', 'a'); - $redis->sinter('set:foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetIsMemberTest.php b/vendor/predis/predis/tests/Predis/Command/SetIsMemberTest.php deleted file mode 100644 index c85e8c10b..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetIsMemberTest.php +++ /dev/null @@ -1,121 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetIsMemberTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetIsMember'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SISMEMBER'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'member'); - $expected = array('key', 'member'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'member'); - $expected = array('prefix:key', 'member'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsMemberExistenceInSet() - { - $redis = $this->getClient(); - - $redis->sadd('letters', 'a', 'b', 'c'); - - $this->assertTrue($redis->sismember('letters', 'a')); - $this->assertFalse($redis->sismember('letters', 'z')); - } - - /** - * @group connected - */ - public function testReturnsFalseOnNonExistingSet() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->sismember('letters', 'a')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->sismember('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetMembersTest.php b/vendor/predis/predis/tests/Predis/Command/SetMembersTest.php deleted file mode 100644 index b96a9bfbb..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetMembersTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetMembersTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetMembers'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SMEMBERS'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('member1', 'member2', 'member3'); - $expected = array('member1', 'member2', 'member3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsFalseOnNonExistingSet() - { - $redis = $this->getClient(); - - $redis->sadd('letters', 'a', 'b', 'c', 'd', 'e'); - - $this->assertSameValues(array('a', 'b', 'c', 'd', 'e'), $redis->smembers('letters')); - $this->assertSame(array(), $redis->smembers('digits')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->smembers('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetMoveTest.php b/vendor/predis/predis/tests/Predis/Command/SetMoveTest.php deleted file mode 100644 index 9ed4c2a71..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetMoveTest.php +++ /dev/null @@ -1,129 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetMoveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetMove'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SMOVE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key:source', 'key:destination', 'member'); - $expected = array('key:source', 'key:destination', 'member'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - - $this->assertTrue($command->parseResponse(1)); - $this->assertFalse($command->parseResponse(0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key:source', 'key:destination', 'member'); - $expected = array('prefix:key:source', 'prefix:key:destination', 'member'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsMemberExistenceInSet() - { - $redis = $this->getClient(); - - $redis->sadd('letters:source', 'a', 'b', 'c'); - - $this->assertTrue($redis->smove('letters:source', 'letters:destination', 'b')); - $this->assertFalse($redis->smove('letters:source', 'letters:destination', 'z')); - - $this->assertSameValues(array('a', 'c'), $redis->smembers('letters:source')); - $this->assertSameValues(array('b'), $redis->smembers('letters:destination')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongTypeOfSourceKey() - { - $redis = $this->getClient(); - - $redis->set('set:source', 'foo'); - $redis->sadd('set:destination', 'bar'); - $redis->smove('set:destination', 'set:source', 'foo'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongTypeOfDestinationKey() - { - $redis = $this->getClient(); - - $redis->sadd('set:source', 'foo'); - $redis->set('set:destination', 'bar'); - $redis->smove('set:destination', 'set:source', 'foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetPopTest.php b/vendor/predis/predis/tests/Predis/Command/SetPopTest.php deleted file mode 100644 index f577cb6ac..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetPopTest.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetPopTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetPop'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SPOP'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('member', $this->getCommand()->parseResponse('member')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testPopsRandomMemberFromSet() - { - $redis = $this->getClient(); - - $redis->sadd('letters', 'a', 'b'); - - $this->assertContains($redis->spop('letters'), array('a', 'b')); - $this->assertContains($redis->spop('letters'), array('a', 'b')); - - $this->assertNull($redis->spop('letters')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->spop('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetRandomMemberTest.php b/vendor/predis/predis/tests/Predis/Command/SetRandomMemberTest.php deleted file mode 100644 index 721373079..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetRandomMemberTest.php +++ /dev/null @@ -1,118 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetRandomMemberTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetRandomMember'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SRANDMEMBER'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 1); - $expected = array('key', 1); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('member', $this->getCommand()->parseResponse('member')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsRandomMemberFromSet() - { - $redis = $this->getClient(); - - $redis->sadd('letters', 'a', 'b'); - - $this->assertContains($redis->srandmember('letters'), array('a', 'b')); - $this->assertContains($redis->srandmember('letters'), array('a', 'b')); - - $this->assertSame(2, $redis->scard('letters')); - } - - /** - * @group connected - */ - public function testReturnsNullOnNonExistingSet() - { - $this->assertNull($this->getClient()->srandmember('letters')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->srandmember('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetRemoveTest.php b/vendor/predis/predis/tests/Predis/Command/SetRemoveTest.php deleted file mode 100644 index 5348d72fb..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetRemoveTest.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetRemoveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetRemove'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SREM'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'member1', 'member2', 'member3'); - $expected = array('key', 'member1', 'member2', 'member3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsMembersAsSingleArray() - { - $arguments = array('key', array('member1', 'member2', 'member3')); - $expected = array('key', 'member1', 'member2', 'member3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'member1', 'member2', 'member3'); - $expected = array('prefix:key', 'member1', 'member2', 'member3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testRemovesMembersFromSet() - { - $redis = $this->getClient(); - - $redis->sadd('letters', 'a', 'b', 'c', 'd'); - - $this->assertSame(1, $redis->srem('letters', 'b')); - $this->assertSame(1, $redis->srem('letters', 'd', 'z')); - $this->assertSameValues(array('a', 'c'), $redis->smembers('letters')); - - $this->assertSame(0, $redis->srem('digits', 1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->srem('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetScanTest.php b/vendor/predis/predis/tests/Predis/Command/SetScanTest.php deleted file mode 100644 index 64a4fa4f1..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetScanTest.php +++ /dev/null @@ -1,156 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetScanTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetScan'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SSCAN'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); - $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsBasicUsage() - { - $arguments = array('key', 0); - $expected = array('key', 0); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithOptionsArray() - { - $arguments = array('key', 0, array('match' => 'member:*', 'count' => 10)); - $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('3', array('member:1', 'member:2', 'member:3')); - $expected = array(3, array('member:1', 'member:2', 'member:3')); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', '0', 'MATCH', 'member:*', 'COUNT', 10); - $expected = array('prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testScanWithoutMatch() - { - $redis = $this->getClient(); - $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); - - $response = $redis->sscan('key', 0); - - $this->assertSame(0, $response[0]); - $this->assertSameValues($members, $response[1]); - } - - /** - * @group connected - */ - public function testScanWithMatchingMembers() - { - $redis = $this->getClient(); - $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); - - $response = $redis->sscan('key', 0, 'MATCH', 'member:t*'); - - $this->assertSameValues(array('member:two', 'member:three'), $response[1]); - } - - /** - * @group connected - */ - public function testScanWithNoMatchingMembers() - { - $redis = $this->getClient(); - $redis->sadd('key', $members = array('member:one', 'member:two', 'member:three', 'member:four')); - - $response = $redis->sscan('key', 0, 'MATCH', 'nomember:*'); - - $this->assertSame(0, $response[0]); - $this->assertEmpty($response[1]); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetUnionStoreTest.php b/vendor/predis/predis/tests/Predis/Command/SetUnionStoreTest.php deleted file mode 100644 index 0f4083cb3..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetUnionStoreTest.php +++ /dev/null @@ -1,140 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetUnionStoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetUnionStore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SUNIONSTORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('key:destination', 'key:source1', 'key:source:2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsSourceKeysAsSingleArray() - { - $arguments = array('key:destination', array('key:source1', 'key:source:2')); - $expected = array('key:destination', 'key:source1', 'key:source:2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key:destination', 'key:source1', 'key:source:2'); - $expected = array('prefix:key:destination', 'prefix:key:source1', 'prefix:key:source:2'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testStoresMembersOfSetOnSingleSet() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - - $this->assertSame(7, $redis->sunionstore('letters:destination', 'letters:1st')); - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); - } - - /** - * @group connected - */ - public function testStoresUnionOfMultipleSets() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'b', 'd', 'f'); - $redis->sadd('letters:2nd', 'a', 'c', 'g'); - $redis->sadd('letters:3rd', 'a', 'e', 'f'); - - $this->assertSame(5, $redis->sunionstore('letters:destination', 'letters:2nd', 'letters:3rd')); - $this->assertSameValues(array('a', 'c', 'e', 'f', 'g'), $redis->smembers('letters:destination')); - - $this->assertSame(7, $redis->sunionstore('letters:destination', 'letters:1st', 'letters:2nd', 'letters:3rd')); - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->smembers('letters:destination')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongTypeOfSourceKey() - { - $redis = $this->getClient(); - - $redis->set('set:source', 'foo'); - $redis->sunionstore('set:destination', 'set:source'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/SetUnionTest.php b/vendor/predis/predis/tests/Predis/Command/SetUnionTest.php deleted file mode 100644 index 6f889127a..000000000 --- a/vendor/predis/predis/tests/Predis/Command/SetUnionTest.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-set - */ -class SetUnionTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\SetUnion'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SUNION'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('member1', 'member2', 'member3'); - $expected = array('member1', 'member2', 'member3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsMembersOnSingleKeyOrNonExistingSetForUnion() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'a', 'b', 'c', 'd', 'e', 'f', 'g'); - - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st')); - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st', 'letters:2nd')); - } - - /** - * @group connected - */ - public function testReturnsMembersFromDifferenceAmongSets() - { - $redis = $this->getClient(); - - $redis->sadd('letters:1st', 'b', 'd', 'f'); - $redis->sadd('letters:2nd', 'a', 'c', 'g'); - $redis->sadd('letters:3rd', 'a', 'e', 'f'); - - $this->assertSameValues(array('a', 'c', 'e', 'f', 'g'), $redis->sunion('letters:2nd', 'letters:3rd')); - $this->assertSameValues(array( 'a', 'b', 'c', 'd', 'e', 'f', 'g'), $redis->sunion('letters:1st', 'letters:2nd', 'letters:3rd')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('set:foo', 'a'); - $redis->sunion('set:foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringAppendTest.php b/vendor/predis/predis/tests/Predis/Command/StringAppendTest.php deleted file mode 100644 index 8ed6822d8..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringAppendTest.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringAppendTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringAppend'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'APPEND'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'value'); - $expected = array('key', 'value'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(10, $this->getCommand()->parseResponse(10)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(3, $redis->append('foo', 'bar')); - $this->assertSame('bar', $redis->get('foo')); - } - - /** - * @group connected - */ - public function testReturnsTheLenghtOfTheStringAfterAppend() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertSame(5, $redis->append('foo', '__')); - $this->assertSame(8, $redis->append('foo', 'bar')); - $this->assertSame('bar__bar', $redis->get('foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->append('metavars', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringBitCountTest.php b/vendor/predis/predis/tests/Predis/Command/StringBitCountTest.php deleted file mode 100644 index f765d203a..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringBitCountTest.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringBitCountTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringBitCount'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'BITCOUNT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 10); - $expected = array('key', 0, 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = 10; - $expected = 10; - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 0, 10); - $expected = array('prefix:key', 0, 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsNumberOfBitsSet() - { - $redis = $this->getClient(); - - $redis->setbit('key', 1, 1); - $redis->setbit('key', 10, 1); - $redis->setbit('key', 16, 1); - $redis->setbit('key', 22, 1); - $redis->setbit('key', 32, 1); - - $this->assertSame(5, $redis->bitcount('key'), 'Count bits set (without range)'); - $this->assertSame(3, $redis->bitcount('key', 2, 4), 'Count bits set (with range)'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('key', 'list'); - $redis->bitcount('key'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringBitOpTest.php b/vendor/predis/predis/tests/Predis/Command/StringBitOpTest.php deleted file mode 100644 index 8caf2acc8..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringBitOpTest.php +++ /dev/null @@ -1,202 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringBitOpTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringBitOp'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'BITOP'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('AND', 'key:dst', 'key:01', 'key:02'); - $expected = array('AND', 'key:dst', 'key:01', 'key:02'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsKeysAsSingleArray() - { - $arguments = array('AND', 'key:dst', array('key:01', 'key:02')); - $expected = array('AND', 'key:dst', 'key:01', 'key:02'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = 10; - $expected = 10; - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('AND', 'key:dst', 'key:01', 'key:02'); - $expected = array('AND', 'prefix:key:dst', 'prefix:key:01', 'prefix:key:02'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCanPerformBitwiseAND() - { - $redis = $this->getClient(); - - $redis->set('key:src:1', "h\x80"); - $redis->set('key:src:2', "R"); - - $this->assertSame(2, $redis->bitop('AND', 'key:dst', 'key:src:1', 'key:src:2')); - $this->assertSame("@\x00", $redis->get('key:dst')); - } - - /** - * @group connected - */ - public function testCanPerformBitwiseOR() - { - $redis = $this->getClient(); - - $redis->set('key:src:1', "h\x80"); - $redis->set('key:src:2', "R"); - - $this->assertSame(2, $redis->bitop('OR', 'key:dst', 'key:src:1', 'key:src:2')); - $this->assertSame("z\x80", $redis->get('key:dst')); - } - - /** - * @group connected - */ - public function testCanPerformBitwiseXOR() - { - $redis = $this->getClient(); - - $redis->set('key:src:1', "h\x80"); - $redis->set('key:src:2', "R"); - - $this->assertSame(2, $redis->bitop('XOR', 'key:dst', 'key:src:1', 'key:src:2')); - $this->assertSame(":\x80", $redis->get('key:dst')); - } - - /** - * @group connected - */ - public function testCanPerformBitwiseNOT() - { - $redis = $this->getClient(); - - $redis->set('key:src:1', "h\x80"); - - $this->assertSame(2, $redis->bitop('NOT', 'key:dst', 'key:src:1')); - $this->assertSame("\x97\x7f", $redis->get('key:dst')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR BITOP NOT must be called with a single source key. - */ - public function testBitwiseNOTAcceptsOnlyOneSourceKey() - { - $this->getClient()->bitop('NOT', 'key:dst', 'key:src:1', 'key:src:2'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR syntax error - */ - public function testThrowsExceptionOnInvalidOperation() - { - $this->getClient()->bitop('NOOP', 'key:dst', 'key:src:1', 'key:src:2'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnInvalidSourceKey() - { - $redis = $this->getClient(); - - $redis->lpush('key:src:1', 'list'); - $redis->bitop('AND', 'key:dst', 'key:src:1', 'key:src:2'); - } - - /** - * @group connected - */ - public function testDoesNotThrowExceptionOnInvalidDestinationKey() - { - $redis = $this->getClient(); - - $redis->lpush('key:dst', 'list'); - $redis->bitop('AND', 'key:dst', 'key:src:1', 'key:src:2'); - - $this->assertSame('none', $redis->type('key:dst')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringDecrementByTest.php b/vendor/predis/predis/tests/Predis/Command/StringDecrementByTest.php deleted file mode 100644 index 6529ef592..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringDecrementByTest.php +++ /dev/null @@ -1,145 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringDecrementByTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringDecrementBy'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'DECRBY'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 5); - $expected = array('key', 5); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(5, $this->getCommand()->parseResponse(5)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 5); - $expected = array('prefix:key', 5); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(-10, $redis->decrby('foo', 10)); - $this->assertEquals(-10, $redis->get('foo')); - } - - /** - * @group connected - */ - public function testReturnsTheValueOfTheKeyAfterDecrement() - { - $redis = $this->getClient(); - - $redis->set('foo', 10); - - $this->assertSame(6, $redis->decrby('foo', 4)); - $this->assertSame(0, $redis->decrby('foo', 6)); - $this->assertSame(-25, $redis->decrby('foo', 25)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not an integer or out of range - */ - public function testThrowsExceptionOnDecrementValueNotInteger() - { - $redis = $this->getClient(); - - $redis->decrby('foo', 'bar'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not an integer or out of range - */ - public function testThrowsExceptionOnKeyValueNotInteger() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->decrby('foo', 5); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->decrby('metavars', 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringDecrementTest.php b/vendor/predis/predis/tests/Predis/Command/StringDecrementTest.php deleted file mode 100644 index bc4b14a18..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringDecrementTest.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringDecrementTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringDecrement'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'DECR'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(5, $this->getCommand()->parseResponse(5)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(-1, $redis->decr('foo')); - $this->assertEquals(-1, $redis->get('foo')); - } - - /** - * @group connected - */ - public function testReturnsTheValueOfTheKeyAfterDecrement() - { - $redis = $this->getClient(); - - $redis->set('foo', 1); - - $this->assertSame(0, $redis->decr('foo')); - $this->assertSame(-1, $redis->decr('foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not an integer or out of range - */ - public function testThrowsExceptionOnKeyValueNotInteger() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->decr('foo'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->decr('metavars'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetBitTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetBitTest.php deleted file mode 100644 index 3afb735f9..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringGetBitTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringGetBitTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringGetBit'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'GETBIT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 100); - $expected = array('key', 100); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - $this->assertSame(0, $command->parseResponse(0)); - $this->assertSame(1, $command->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 100); - $expected = array('prefix:key', 100); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCanGetBitsFromString() - { - $redis = $this->getClient(); - - $redis->set('key:binary', "\x80\x00\00\x01"); - - $this->assertSame(1, $redis->getbit('key:binary', 0)); - $this->assertSame(0, $redis->getbit('key:binary', 15)); - $this->assertSame(1, $redis->getbit('key:binary', 31)); - $this->assertSame(0, $redis->getbit('key:binary', 63)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR bit offset is not an integer or out of range - */ - public function testThrowsExceptionOnNegativeOffset() - { - $redis = $this->getClient(); - - $redis->set('key:binary', "\x80\x00\00\x01"); - $redis->getbit('key:binary', -1); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR bit offset is not an integer or out of range - */ - public function testThrowsExceptionOnInvalidOffset() - { - $redis = $this->getClient(); - - $redis->set('key:binary', "\x80\x00\00\x01"); - $redis->getbit('key:binary', 'invalid'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->getbit('metavars', '1'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetMultipleTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetMultipleTest.php deleted file mode 100644 index ad009aac3..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringGetMultipleTest.php +++ /dev/null @@ -1,135 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringGetMultipleTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringGetMultiple'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'MGET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('value1', 'value2', 'value3'); - $expected = array('value1', 'value2', 'value3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsArrayOfValues() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->set('hoge', 'piyo'); - - $this->assertSame(array('bar', 'piyo'), $redis->mget('foo', 'hoge')); - } - - /** - * @group connected - */ - public function testReturnsArrayWithNullValuesOnNonExistingKeys() - { - $redis = $this->getClient(); - - $this->assertSame(array(null, null), $redis->mget('foo', 'hoge')); - } - - /** - * @group connected - */ - public function testDoesNotThrowExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $this->assertSame(array(null), $redis->mget('metavars')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetRangeTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetRangeTest.php deleted file mode 100644 index d7de14b47..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringGetRangeTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringGetRangeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringGetRange'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'GETRANGE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 5, 10); - $expected = array('key', 5, 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('substring',$this->getCommand()->parseResponse('substring')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 5, 10); - $expected = array('prefix:key', 5, 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsSubstring() - { - $redis = $this->getClient(); - - $redis->set('string', 'this is a string'); - - $this->assertSame('this', $redis->getrange('string', 0, 3)); - $this->assertSame('ing', $redis->getrange('string', -3, -1)); - $this->assertSame('this is a string', $redis->getrange('string', 0, -1)); - $this->assertSame('string', $redis->getrange('string', 10, 100)); - - $this->assertSame('t', $redis->getrange('string', 0, 0)); - $this->assertSame('', $redis->getrange('string', -1, 0)); - } - - /** - * @group connected - */ - public function testReturnsEmptyStringOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame('', $redis->getrange('string', 0, 3)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->getrange('metavars', 0, 5); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetSetTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetSetTest.php deleted file mode 100644 index b31a7a4aa..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringGetSetTest.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringGetSetTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringGetSet'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'GETSET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'value'); - $expected = array('key', 'value'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('value', $this->getCommand()->parseResponse('value')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsPreviousValueOfKey() - { - $redis = $this->getClient(); - - $this->assertNull($redis->getset('foo', 'bar')); - $this->assertSame('bar', $redis->getset('foo', 'barbar')); - - $redis->set('hoge', 'piyo'); - $this->assertSame('piyo', $redis->getset('hoge', 'piyopiyo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->getset('metavars', 'foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringGetTest.php b/vendor/predis/predis/tests/Predis/Command/StringGetTest.php deleted file mode 100644 index 75cb9810f..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringGetTest.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringGetTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringGet'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'GET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('foo'); - $expected = array('foo'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('bar', $this->getCommand()->parseResponse('bar')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsStringValue() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->set('foo', 'bar')); - $this->assertEquals('bar', $redis->get('foo')); - } - - /** - * @group connected - */ - public function testReturnsEmptyStringOnEmptyStrings() - { - $redis = $this->getClient(); - - $redis->set('foo', ''); - - $this->assertTrue($redis->exists('foo')); - $this->assertSame('', $redis->get('foo')); - } - - /** - * @group connected - */ - public function testReturnsNullOnNonExistingKeys() - { - $redis = $this->getClient(); - - $this->assertFalse($redis->exists('foo')); - $this->assertNull($redis->get('foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->rpush('metavars', 'foo'); - $redis->get('metavars'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringIncrementByFloatTest.php b/vendor/predis/predis/tests/Predis/Command/StringIncrementByFloatTest.php deleted file mode 100644 index 47d884dde..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringIncrementByFloatTest.php +++ /dev/null @@ -1,145 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringIncrementByFloatTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringIncrementByFloat'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'INCRBYFLOAT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 5.0); - $expected = array('key', 5.0); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(5.0, $this->getCommand()->parseResponse(5.0)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 5.0); - $expected = array('prefix:key', 5.0); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertEquals(10.5, $redis->incrbyfloat('foo', 10.5)); - $this->assertEquals(10.5, $redis->get('foo')); - } - - /** - * @group connected - */ - public function testReturnsTheValueOfTheKeyAfterIncrement() - { - $redis = $this->getClient(); - - $redis->set('foo', 2); - - $this->assertEquals(22.123, $redis->incrbyfloat('foo', 20.123)); - $this->assertEquals(10, $redis->incrbyfloat('foo', -12.123)); - $this->assertEquals(-100.01, $redis->incrbyfloat('foo', -110.01)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not a valid float - */ - public function testThrowsExceptionOnDecrementValueNotFloat() - { - $redis = $this->getClient(); - - $redis->incrbyfloat('foo', 'bar'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not a valid float - */ - public function testThrowsExceptionOnKeyValueNotFloat() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->incrbyfloat('foo', 10.0); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->incrbyfloat('metavars', 10.0); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringIncrementByTest.php b/vendor/predis/predis/tests/Predis/Command/StringIncrementByTest.php deleted file mode 100644 index ef55f5a5d..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringIncrementByTest.php +++ /dev/null @@ -1,145 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringIncrementByTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringIncrementBy'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'INCRBY'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 5); - $expected = array('key', 5); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(5, $this->getCommand()->parseResponse(5)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 5); - $expected = array('prefix:key', 5); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(10, $redis->incrby('foo', 10)); - $this->assertEquals(10, $redis->get('foo')); - } - - /** - * @group connected - */ - public function testReturnsTheValueOfTheKeyAfterIncrement() - { - $redis = $this->getClient(); - - $redis->set('foo', 2); - - $this->assertSame(22, $redis->incrby('foo', 20)); - $this->assertSame(10, $redis->incrby('foo', -12)); - $this->assertSame(-100, $redis->incrby('foo', -110)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not an integer or out of range - */ - public function testThrowsExceptionOnDecrementValueNotInteger() - { - $redis = $this->getClient(); - - $redis->incrby('foo', 'bar'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not an integer or out of range - */ - public function testThrowsExceptionOnKeyValueNotInteger() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->incrby('foo', 10); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->incrby('metavars', 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringIncrementTest.php b/vendor/predis/predis/tests/Predis/Command/StringIncrementTest.php deleted file mode 100644 index b6017c3a0..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringIncrementTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringIncrementTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringIncrement'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'INCR'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(5, $this->getCommand()->parseResponse(5)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(1, $redis->incr('foo')); - $this->assertEquals(1, $redis->get('foo')); - } - - /** - * @group connected - */ - public function testReturnsTheValueOfTheKeyAfterIncrement() - { - $redis = $this->getClient(); - - $redis->set('foo', 2); - - $this->assertSame(3, $redis->incr('foo')); - $this->assertSame(4, $redis->incr('foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->incr('metavars'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringPreciseSetExpireTest.php b/vendor/predis/predis/tests/Predis/Command/StringPreciseSetExpireTest.php deleted file mode 100644 index ca2f18cae..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringPreciseSetExpireTest.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringPreciseSetExpireTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringPreciseSetExpire'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'PSETEX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 10, 'hello'); - $expected = array('key', 10, 'hello'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 10, 'hello'); - $expected = array('prefix:key', 10, 'hello'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyAndSetsTTL() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->psetex('foo', 10000, 'bar')); - $this->assertTrue($redis->exists('foo')); - $this->assertEquals(10, $redis->ttl('foo')); - } - - /** - * @group connected - * @group slow - */ - public function testKeyExpiresAfterTTL() - { - $redis = $this->getClient(); - - $redis->psetex('foo', 50, 'bar'); - $this->sleep(0.5); - $this->assertFalse($redis->exists('foo'));; - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not an integer or out of range - */ - public function testThrowsExceptionOnNonIntegerTTL() - { - $this->getClient()->psetex('foo', 2.5, 'bar'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR invalid expire time in SETEX - * @todo Should not Redis return PSETEX instead of SETEX here? - */ - public function testThrowsExceptionOnZeroTTL() - { - $this->getClient()->psetex('foo', 0, 'bar'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR invalid expire time in SETEX - * @todo Should not Redis return PSETEX instead of SETEX here? - */ - public function testThrowsExceptionOnNegativeTTL() - { - $this->getClient()->psetex('foo', -10000, 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetBitTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetBitTest.php deleted file mode 100644 index 8dda640dd..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringSetBitTest.php +++ /dev/null @@ -1,154 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringSetBitTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringSetBit'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SETBIT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 7, 1); - $expected = array('key', 7, 1); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $command = $this->getCommand(); - $this->assertSame(0, $command->parseResponse(0)); - $this->assertSame(1, $command->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 7, 1); - $expected = array('prefix:key', 7, 1); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCanSetBitsOfStrings() - { - $redis = $this->getClient(); - - $redis->set('key:binary', "\x80\x00\00\x01"); - - $this->assertEquals(1, $redis->setbit('key:binary', 0, 0)); - $this->assertEquals(0, $redis->setbit('key:binary', 0, 0)); - $this->assertEquals("\x00\x00\00\x01", $redis->get('key:binary')); - } - - /** - * @group connected - */ - public function testCreatesNewKeyOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(0, $redis->setbit('key:binary', 31, 1)); - $this->assertSame(0, $redis->setbit('key:binary', 0, 1)); - $this->assertSame(4, $redis->strlen('key:binary')); - $this->assertSame("\x80\x00\00\x01", $redis->get('key:binary')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR bit is not an integer or out of range - */ - public function testThrowsExceptionOnInvalidBitValue() - { - $redis = $this->getClient()->setbit('key:binary', 10, 255); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR bit offset is not an integer or out of range - */ - public function testThrowsExceptionOnNegativeOffset() - { - $redis = $this->getClient()->setbit('key:binary', -1, 1); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR bit offset is not an integer or out of range - */ - public function testThrowsExceptionOnInvalidOffset() - { - $redis = $this->getClient()->setbit('key:binary', 'invalid', 1); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->setbit('metavars', 0, 1); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetExpireTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetExpireTest.php deleted file mode 100644 index 769469b93..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringSetExpireTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringSetExpireTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringSetExpire'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SETEX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 10, 'hello'); - $expected = array('key', 10, 'hello'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 10, 'hello'); - $expected = array('prefix:key', 10, 'hello'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyAndSetsTTL() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->setex('foo', 10, 'bar')); - $this->assertTrue($redis->exists('foo')); - $this->assertEquals(10, $redis->ttl('foo')); - } - - /** - * @medium - * @group connected - * @group slow - */ - public function testKeyExpiresAfterTTL() - { - $redis = $this->getClient(); - - $redis->setex('foo', 1, 'bar'); - $this->sleep(2.0); - $this->assertFalse($redis->exists('foo'));; - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR value is not an integer or out of range - */ - public function testThrowsExceptionOnNonIntegerTTL() - { - $this->getClient()->setex('foo', 2.5, 'bar'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR invalid expire time in SETEX - */ - public function testThrowsExceptionOnZeroTTL() - { - $this->getClient()->setex('foo', 0, 'bar'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR invalid expire time in SETEX - */ - public function testThrowsExceptionOnNegativeTTL() - { - $this->getClient()->setex('foo', -10, 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetMultiplePreserveTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetMultiplePreserveTest.php deleted file mode 100644 index dcb178098..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringSetMultiplePreserveTest.php +++ /dev/null @@ -1,122 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringSetMultiplePreserveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringSetMultiplePreserve'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'MSETNX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('foo', 'bar', 'hoge', 'piyo'); - $expected = array('foo', 'bar', 'hoge', 'piyo'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleNamedArray() - { - $arguments = array(array('foo' => 'bar', 'hoge' => 'piyo')); - $expected = array('foo', 'bar', 'hoge', 'piyo'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(true, $this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('foo', 'bar', 'hoge', 'piyo'); - $expected = array('prefix:foo', 'bar', 'prefix:hoge', 'piyo'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesMultipleKeys() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->msetnx('foo', 'bar', 'hoge', 'piyo')); - $this->assertSame('bar', $redis->get('foo')); - $this->assertSame('piyo', $redis->get('hoge')); - } - - /** - * @group connected - */ - public function testCreatesMultipleKeysAndPreservesExistingOnes() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - - $this->assertFalse($redis->msetnx('foo', 'barbar', 'hoge', 'piyo')); - $this->assertSame('bar', $redis->get('foo')); - $this->assertFalse($redis->exists('hoge')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetMultipleTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetMultipleTest.php deleted file mode 100644 index c1a7f0ee0..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringSetMultipleTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringSetMultipleTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringSetMultiple'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'MSET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('foo', 'bar', 'hoge', 'piyo'); - $expected = array('foo', 'bar', 'hoge', 'piyo'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleNamedArray() - { - $arguments = array(array('foo' => 'bar', 'hoge' => 'piyo')); - $expected = array('foo', 'bar', 'hoge', 'piyo'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(true, $this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('foo', 'bar', 'hoge', 'piyo'); - $expected = array('prefix:foo', 'bar', 'prefix:hoge', 'piyo'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesMultipleKeys() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->mset('foo', 'bar', 'hoge', 'piyo')); - $this->assertSame('bar', $redis->get('foo')); - $this->assertSame('piyo', $redis->get('hoge')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetPreserveTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetPreserveTest.php deleted file mode 100644 index a77c51477..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringSetPreserveTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringSetPreserveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringSetPreserve'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SETNX'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('foo', 'bar'); - $expected = array('foo', 'bar'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testSetStringValue() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->setnx('foo', 'bar')); - $this->assertFalse($redis->setnx('foo', 'barbar')); - $this->assertEquals('bar', $redis->get('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetRangeTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetRangeTest.php deleted file mode 100644 index eafb663a9..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringSetRangeTest.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringSetRangeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringSetRange'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SETRANGE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 5, 'range'); - $expected = array('key', 5, 'range'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(10, $this->getCommand()->parseResponse(10)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 5, 'range'); - $expected = array('prefix:key', 5, 'range'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testCreatesNewKeyOnNonExistingKey() - { - $redis = $this->getClient(); - - $this->assertSame(3, $redis->setrange('foo', 0, 'bar')); - $this->assertSame('bar', $redis->get('foo')); - - $this->assertSame(8, $redis->setrange('hoge', 4, 'piyo')); - $this->assertSame("\x00\x00\x00\x00piyo", $redis->get('hoge')); - } - - /** - * @group connected - */ - public function testOverwritesOrAppendBytesInKeys() - { - $redis = $this->getClient(); - - $redis->set('foo', 'barbar'); - - $this->assertSame(6, $redis->setrange('foo', 3, 'baz')); - $this->assertSame('barbaz', $redis->get('foo')); - - $this->assertEquals(16, $redis->setrange('foo', 10, 'foofoo')); - $this->assertEquals("barbaz\x00\x00\x00\x00foofoo", $redis->get('foo')); - } - - /** - * @group connected - */ - public function testHandlesBinaryData() - { - $redis = $this->getClient(); - - $this->assertSame(4, $redis->setrange('key:binary', 0, pack('i', -2147483648))); - - list($unpacked) = array_values(unpack('i', $redis->get('key:binary'))); - $this->assertEquals(-2147483648, $unpacked); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR offset is out of range - */ - public function testThrowsExceptionOnInvalidOffset() - { - $this->getClient()->setrange('var', -1, 'bogus'); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->setrange('metavars', 3, 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSetTest.php b/vendor/predis/predis/tests/Predis/Command/StringSetTest.php deleted file mode 100644 index 61ca580cd..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringSetTest.php +++ /dev/null @@ -1,94 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringSetTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringSet'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SET'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('foo', 'bar'); - $expected = array('foo', 'bar'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'value'); - $expected = array('prefix:key', 'value'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testSetStringValue() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->set('foo', 'bar')); - $this->assertTrue($redis->exists('foo')); - $this->assertEquals('bar', $redis->get('foo')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringStrlenTest.php b/vendor/predis/predis/tests/Predis/Command/StringStrlenTest.php deleted file mode 100644 index c5c06c580..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringStrlenTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-string - */ -class StringStrlenTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringStrlen'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'STRLEN'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(4, $this->getCommand()->parseResponse(4)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsTheLengthOfString() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $this->assertSame(3, $redis->strlen('foo')); - - $redis->append('foo', 'bar'); - $this->assertSame(6, $redis->strlen('foo')); - } - - /** - * @group connected - */ - public function testReturnsZeroOnNonExistingKeys() - { - $redis = $this->getClient(); - - $this->assertSame(0, $redis->strlen('foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->lpush('metavars', 'foo'); - $redis->strlen('metavars'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/StringSubstrTest.php b/vendor/predis/predis/tests/Predis/Command/StringSubstrTest.php deleted file mode 100644 index 42acf8c7b..000000000 --- a/vendor/predis/predis/tests/Predis/Command/StringSubstrTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * SUBSTR is actually the old name of GETRANGE in version of Redis <= 2.0. - * This command should be considered obsolete and we will perform any kind - * of tests against a Redis server for this one. - * - * @group commands - * @group realm-string - */ -class StringSubstrTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\StringSubstr'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'SUBSTR'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 5, 10); - $expected = array('key', 5, 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('substring',$this->getCommand()->parseResponse('substring')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 5, 10); - $expected = array('prefix:key', 5, 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionDiscardTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionDiscardTest.php deleted file mode 100644 index 1b450c2f2..000000000 --- a/vendor/predis/predis/tests/Predis/Command/TransactionDiscardTest.php +++ /dev/null @@ -1,80 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-transaction - */ -class TransactionDiscardTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\TransactionDiscard'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'DISCARD'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group connected - */ - public function testAbortsTransactionAndRestoresNormalFlow() - { - $redis = $this->getClient(); - - $redis->multi(); - - $this->assertInstanceOf('Predis\ResponseQueued', $redis->set('foo', 'bar')); - $this->assertTrue($redis->discard()); - $this->assertFalse($redis->exists('foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR DISCARD without MULTI - */ - public function testThrowsExceptionWhenCallingOutsideTransaction() - { - $redis = $this->getClient(); - - $redis->discard(); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionExecTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionExecTest.php deleted file mode 100644 index 634bca54e..000000000 --- a/vendor/predis/predis/tests/Predis/Command/TransactionExecTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-transaction - */ -class TransactionExecTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\TransactionExec'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'EXEC'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('tx1', 'tx2'); - $expected = array('tx1', 'tx2'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group connected - */ - public function testExecutesTransactionAndReturnsArrayOfReplies() - { - $redis = $this->getClient(); - - $redis->multi(); - $redis->echo('tx1'); - $redis->echo('tx2'); - - $this->assertSame(array('tx1', 'tx2'), $redis->exec()); - } - - /** - * @group connected - */ - public function testReturnsEmptyArrayOnEmptyTransactions() - { - $redis = $this->getClient(); - - $redis->multi(); - - $this->assertSame(array(), $redis->exec()); - } - - /** - * @group connected - */ - public function testRepliesOfTransactionsAreNotParsed() - { - $redis = $this->getClient(); - - $redis->multi(); - $redis->ping(); - $redis->set('foo', 'bar'); - $redis->exists('foo'); - - $this->assertSame(array('PONG', true, 1), $redis->exec()); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR EXEC without MULTI - */ - public function testThrowsExceptionWhenCallingOutsideTransaction() - { - $redis = $this->getClient(); - - $redis->exec(); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionMultiTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionMultiTest.php deleted file mode 100644 index d7bde8190..000000000 --- a/vendor/predis/predis/tests/Predis/Command/TransactionMultiTest.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-transaction - */ -class TransactionMultiTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\TransactionMulti'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'MULTI'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group connected - */ - public function testInitializesNewTransaction() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->multi()); - $this->assertSame('QUEUED', (string) $redis->echo('tx1')); - $this->assertSame('QUEUED', (string) $redis->echo('tx2')); - } - - /** - * @group connected - */ - public function testActuallyReturnsReplyObjectAbstraction() - { - $redis = $this->getClient(); - - $this->assertTrue($redis->multi()); - $this->assertInstanceOf('Predis\ResponseObjectInterface', $redis->echo('tx1')); - $this->assertInstanceOf('Predis\ResponseQueued', $redis->echo('tx2')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR MULTI calls can not be nested - */ - public function testThrowsExceptionWhenCallingMultiInsideTransaction() - { - $redis = $this->getClient(); - - $redis->multi(); - $redis->multi(); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionUnwatchTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionUnwatchTest.php deleted file mode 100644 index e437587c9..000000000 --- a/vendor/predis/predis/tests/Predis/Command/TransactionUnwatchTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-transaction - */ -class TransactionUnwatchTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\TransactionUnwatch'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'UNWATCH'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $command = $this->getCommand(); - $command->setArguments(array()); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group connected - */ - public function testUnwatchWatchedKeys() - { - $redis1 = $this->getClient(); - $redis2 = $this->getClient(); - - $redis1->set('foo', 'bar'); - $redis1->watch('foo'); - $this->assertTrue($redis1->unwatch()); - $redis1->multi(); - $redis1->get('foo'); - - $redis2->set('foo', 'hijacked'); - - $this->assertSame(array('hijacked'), $redis1->exec()); - } - - /** - * @group connected - */ - public function testCanBeCalledInsideTransaction() - { - $redis = $this->getClient(); - - $redis->multi(); - $this->assertInstanceOf('Predis\ResponseQueued', $redis->unwatch()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/TransactionWatchTest.php b/vendor/predis/predis/tests/Predis/Command/TransactionWatchTest.php deleted file mode 100644 index 494afbecc..000000000 --- a/vendor/predis/predis/tests/Predis/Command/TransactionWatchTest.php +++ /dev/null @@ -1,143 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-transaction - */ -class TransactionWatchTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\TransactionWatch'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'WATCH'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsAsSingleArray() - { - $arguments = array(array('key1', 'key2', 'key3')); - $expected = array('key1', 'key2', 'key3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertTrue($this->getCommand()->parseResponse(true)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key1', 'key2', 'key3'); - $expected = array('prefix:key1', 'prefix:key2', 'prefix:key3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testAbortsTransactionOnExternalWriteOperations() - { - $redis1 = $this->getClient(); - $redis2 = $this->getClient(); - - $redis1->mset('foo', 'bar', 'hoge', 'piyo'); - - $this->assertTrue($redis1->watch('foo', 'hoge')); - $this->assertTrue($redis1->multi()); - $this->assertInstanceOf('Predis\ResponseQueued', $redis1->get('foo')); - $this->assertTrue($redis2->set('foo', 'hijacked')); - $this->assertNull($redis1->exec()); - $this->assertSame('hijacked', $redis1->get('foo')); - } - - /** - * @group connected - */ - public function testCanWatchNotYetExistingKeys() - { - $redis1 = $this->getClient(); - $redis2 = $this->getClient(); - - $this->assertTrue($redis1->watch('foo')); - $this->assertTrue($redis1->multi()); - $this->assertInstanceOf('Predis\ResponseQueued', $redis1->set('foo', 'bar')); - $this->assertTrue($redis2->set('foo', 'hijacked')); - $this->assertNull($redis1->exec()); - $this->assertSame('hijacked', $redis1->get('foo')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR WATCH inside MULTI is not allowed - */ - public function testThrowsExceptionWhenCallingInsideTransaction() - { - $redis = $this->getClient(); - - $redis->multi(); - $redis->watch('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetAddTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetAddTest.php deleted file mode 100644 index 0a4280e27..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetAddTest.php +++ /dev/null @@ -1,134 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetAddTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetAdd'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZADD'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 1, 'member1', 2, 'member2'); - $expected = array('key', 1, 'member1', 2, 'member2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsMembersScoresAsSingleArray() - { - $arguments = array('key', array('member1' => 1, 'member2' => 2)); - $expected = array('key', 1, 'member1', 2, 'member2'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'score1', 'member1', 'score2', 'member2'); - $expected = array('prefix:key', 'score1', 'member1', 'score2', 'member2'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testAddsOrUpdatesMembersOrderingByScore() - { - $redis = $this->getClient(); - - $this->assertSame(5, $redis->zadd('letters', 1, 'a', 2, 'b', 3, 'c', 4, 'd', 5, 'e')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e'), $redis->zrange('letters', 0, -1)); - - $this->assertSame(1, $redis->zadd('letters', 1, 'e', 8, 'c', 6, 'f')); - $this->assertSame(array('a', 'e', 'b', 'd', 'f', 'c'), $redis->zrange('letters', 0, -1)); - } - - /** - * @group connected - */ - public function testAcceptsFloatValuesAsScore() - { - $redis = $this->getClient(); - - $redis->zadd('letters', 0.2, 'b', 0.3, 'a', 0.1, 'c'); - $this->assertSame(array('c', 'b', 'a'), $redis->zrange('letters', 0, -1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zadd('foo', 10, 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetCardinalityTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetCardinalityTest.php deleted file mode 100644 index 2be63fa46..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetCardinalityTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetCardinalityTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetCardinality'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZCARD'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key'); - $expected = array('key'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key'); - $expected = array('prefix:key'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsSizeOfSortedSet() - { - $redis = $this->getClient(); - - $redis->zadd('letters', 1, 'a', 2, 'b', 3, 'c'); - $this->assertSame(3, $redis->zcard('letters')); - - $this->assertSame(0, $redis->zcard('unknown')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zcard('foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetCountTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetCountTest.php deleted file mode 100644 index 03cc696d2..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetCountTest.php +++ /dev/null @@ -1,141 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetCountTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetCount'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZCOUNT'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 10); - $expected = array('key', 0, 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 0, 10); - $expected = array('prefix:key', 0, 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsNumberOfElementsInGivenScoreRange() - { - $redis = $this->getClient(); - - $redis->zadd('letters', 10, 'a', 20, 'b', 30, 'c', 40, 'd', 50, 'e'); - - $this->assertSame(5, $redis->zcount('letters', 0, 100)); - $this->assertSame(5, $redis->zcount('letters', -100, 100)); - $this->assertSame(2, $redis->zcount('letters', 25, 45)); - $this->assertSame(1, $redis->zcount('letters', 20, 20)); - $this->assertSame(0, $redis->zcount('letters', 0, 0)); - - $this->assertSame(0, $redis->zcount('unknown', 0, 100)); - } - - /** - * @group connected - */ - public function testInfinityScoreIntervals() - { - $redis = $this->getClient(); - - $redis->zadd('letters', 10, 'a', 20, 'b', 30, 'c', 40, 'd', 50, 'e'); - - $this->assertSame(3, $redis->zcount('letters', '-inf', 30)); - $this->assertSame(3, $redis->zcount('letters', 30, '+inf')); - $this->assertSame(5, $redis->zcount('letters', '-inf', '+inf')); - } - - /** - * @group connected - */ - public function testExclusiveScoreIntervals() - { - $redis = $this->getClient(); - - $redis->zadd('letters', 10, 'a', 20, 'b', 30, 'c', 40, 'd', 50, 'e'); - - $this->assertSame(2, $redis->zcount('letters', 10, '(30')); - $this->assertSame(2, $redis->zcount('letters', '(10', 30)); - $this->assertSame(1, $redis->zcount('letters', '(10', '(30')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zcount('foo', 0, 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetIncrementByTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetIncrementByTest.php deleted file mode 100644 index ab65a9116..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetIncrementByTest.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetIncrementByTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetIncrementBy'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZINCRBY'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 1.0, 'member'); - $expected = array('key', 1.0, 'member'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame('1', $this->getCommand()->parseResponse('1')); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 1.0, 'member'); - $expected = array('prefix:key', 1.0, 'member'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testIncrementsScoreOfMemberByFloat() - { - $redis = $this->getClient(); - - $this->assertSame('1', $redis->zincrby('letters', 1, 'member')); - $this->assertSame('0', $redis->zincrby('letters', -1, 'member')); - $this->assertSame('0.5', $redis->zincrby('letters', 0.5, 'member')); - $this->assertSame('-10', $redis->zincrby('letters', -10.5, 'member')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zincrby('foo', 1, 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetIntersectionStoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetIntersectionStoreTest.php deleted file mode 100644 index c2c8e1cdf..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetIntersectionStoreTest.php +++ /dev/null @@ -1,201 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetIntersectionStoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetIntersectionStore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZINTERSTORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $modifiers = array( - 'aggregate' => 'sum', - 'weights' => array(10, 100), - ); - $arguments = array('zset:destination', 2, 'zset1', 'zset2', $modifiers); - - $expected = array( - 'zset:destination', 2, 'zset1', 'zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' - ); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsSourceKeysAsSingleArray() - { - $modifiers = array( - 'aggregate' => 'sum', - 'weights' => array(10, 100), - ); - $arguments = array('zset:destination', array('zset1', 'zset2'), $modifiers); - - $expected = array( - 'zset:destination', 2, 'zset1', 'zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' - ); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $modifiers = array( - 'aggregate' => 'sum', - 'weights' => array(10, 100), - ); - $arguments = array('zset:destination', 2, 'zset1', 'zset2', $modifiers); - - $expected = array( - 'prefix:zset:destination', 2, 'prefix:zset1', 'prefix:zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' - ); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testStoresIntersectionInNewSortedSet() - { - $redis = $this->getClient(); - - $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); - $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); - - $this->assertSame(2, $redis->zinterstore('letters:out', 2, 'letters:1st', 'letters:2nd')); - $this->assertSame(array(array('b', '3'), array('c', '5')), $redis->zrange('letters:out', 0, -1, 'withscores')); - - $this->assertSame(0, $redis->zinterstore('letters:out', 2, 'letters:1st', 'letters:void')); - $this->assertSame(0, $redis->zinterstore('letters:out', 2, 'letters:void', 'letters:2nd')); - $this->assertSame(0, $redis->zinterstore('letters:out', 2, 'letters:void', 'letters:void')); - } - - /** - * @group connected - */ - public function testStoresIntersectionWithAggregateModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); - $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); - - $options = array('aggregate' => 'min'); - $this->assertSame(2, $redis->zinterstore('letters:min', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame(array(array('b', '1'), array('c', '2')), $redis->zrange('letters:min', 0, -1, 'withscores')); - - $options = array('aggregate' => 'max'); - $this->assertSame(2, $redis->zinterstore('letters:max', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame(array(array('b', '2'), array('c', '3')), $redis->zrange('letters:max', 0, -1, 'withscores')); - - $options = array('aggregate' => 'sum'); - $this->assertSame(2, $redis->zinterstore('letters:sum', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame(array(array('b', '3'), array('c', '5')), $redis->zrange('letters:sum', 0, -1, 'withscores')); - } - - /** - * @group connected - */ - public function testStoresIntersectionWithWeightsModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); - $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); - - $options = array('weights' => array(2, 3)); - $this->assertSame(2, $redis->zinterstore('letters:out', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame(array(array('b', '7'), array('c', '12')), $redis->zrange('letters:out', 0, -1, 'withscores')); - } - - /** - * @group connected - */ - public function testStoresIntersectionWithCombinedModifiers() - { - $redis = $this->getClient(); - - $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); - $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); - - $options = array('aggregate' => 'max', 'weights' => array(10, 15)); - $this->assertSame(2, $redis->zinterstore('letters:out', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame(array(array('b', '20'), array('c', '30')), $redis->zrange('letters:out', 0, -1, 'withscores')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zinterstore('zset:destination', 1, 'foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRangeByScoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRangeByScoreTest.php deleted file mode 100644 index 6b37a1244..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetRangeByScoreTest.php +++ /dev/null @@ -1,257 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetRangeByScoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetRangeByScore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZRANGEBYSCORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $modifiers = array( - 'withscores' => true, - 'limit' => array(0, 100), - ); - - $arguments = array('zset', 0, 100, $modifiers); - $expected = array('zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithStringWithscores() - { - $arguments = array('zset', 0, 100, 'withscores'); - $expected = array('zset', 0, 100, 'WITHSCORES'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithNamedLimit() - { - $arguments = array('zset', 0, 100, array('limit' => array('offset' => 1, 'count' => 2))); - $expected = array('zset', 0, 100, 'LIMIT', 1, 2); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('element1', 'element2', 'element3'); - $expected = array('element1', 'element2', 'element3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testParseResponseWithScores() - { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array(array('element1', '1'), array('element2', '2'), array('element3', '3')); - - $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $modifiers = array( - 'withscores' => true, - 'limit' => array(0, 100), - ); - - $arguments = array('zset', 0, 100, $modifiers); - $expected = array('prefix:zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue() - { - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsElementsInScoreRange() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(array('a'), $redis->zrangebyscore('letters', -10, -10)); - $this->assertSame(array('c', 'd', 'e', 'f'), $redis->zrangebyscore('letters', 10, 30)); - $this->assertSame(array('d', 'e'), $redis->zrangebyscore('letters', 20, 20)); - $this->assertSame(array(), $redis->zrangebyscore('letters', 30, 0)); - - $this->assertSame(array(), $redis->zrangebyscore('unknown', 0, 30)); - } - - /** - * @group connected - */ - public function testInfinityScoreIntervals() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(array('a', 'b', 'c'), $redis->zrangebyscore('letters', '-inf', 15)); - $this->assertSame(array('d', 'e', 'f'), $redis->zrangebyscore('letters', 15, '+inf')); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrangebyscore('letters', '-inf', '+inf')); - } - - /** - * @group connected - */ - public function testExclusiveScoreIntervals() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(array('c', 'd', 'e'), $redis->zrangebyscore('letters', 10, '(30')); - $this->assertSame(array('d', 'e', 'f'), $redis->zrangebyscore('letters', '(10', 30)); - $this->assertSame(array('d', 'e'), $redis->zrangebyscore('letters', '(10', '(30')); - } - - /** - * @group connected - */ - public function testRangeWithWithscoresModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array(array('c', '10'), array('d', '20'), array('e', '20')); - - $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, 'withscores')); - $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('withscores' => true))); - } - - /** - * @group connected - */ - public function testRangeWithLimitModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array('d', 'e'); - - $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('limit' => array(1, 2)))); - $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, array('limit' => array('offset' => 1, 'count' => 2)))); - } - - /** - * @group connected - */ - public function testRangeWithCombinedModifiers() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $options = array('limit' => array(1, 2), 'withscores' => true); - $expected = array(array('d', '20'), array('e', '20')); - - $this->assertSame($expected, $redis->zrangebyscore('letters', 10, 20, $options)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zrangebyscore('foo', 0, 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRangeTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRangeTest.php deleted file mode 100644 index 1ea7a97c2..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetRangeTest.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetRangeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetRange'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZRANGE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('zset', 0, 100, array('withscores' => true)); - $expected = array('zset', 0, 100, 'WITHSCORES'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithStringWithscores() - { - $arguments = array('zset', 0, 100, 'withscores'); - $expected = array('zset', 0, 100, 'WITHSCORES'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('element1', 'element2', 'element3'); - $expected = array('element1', 'element2', 'element3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testParseResponseWithScores() - { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array(array('element1', '1'), array('element2', '2'), array('element3', '3')); - - $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('zset', 0, 100, array('withscores' => true)); - $expected = array('prefix:zset', 0, 100, 'WITHSCORES'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue() - { - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsElementsInRange() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(array(), $redis->zrange('letters', 1, 0)); - $this->assertSame(array('a'), $redis->zrange('letters', 0, 0)); - $this->assertSame(array('a', 'b', 'c', 'd'), $redis->zrange('letters', 0, 3)); - - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrange('letters', 0, -1)); - $this->assertSame(array('a', 'b', 'c'), $redis->zrange('letters', 0, -4)); - $this->assertSame(array('c'), $redis->zrange('letters', 2, -4)); - $this->assertSame(array('a', 'b', 'c', 'd', 'e', 'f'), $redis->zrange('letters', -100, 100)); - - $this->assertSame(array(), $redis->zrange('unknown', 0, 30)); - } - - /** - * @group connected - */ - public function testRangeWithWithscoresModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array(array('c', '10'), array('d', '20'), array('e', '20')); - - $this->assertSame($expected, $redis->zrange('letters', 2, 4, 'withscores')); - $this->assertSame($expected, $redis->zrange('letters', 2, 4, array('withscores' => true))); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zrange('foo', 0, 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRankTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRankTest.php deleted file mode 100644 index 87c4932c1..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetRankTest.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetRankTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetRank'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZRANK'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'member'); - $expected = array('key', 'member'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'member'); - $expected = array('prefix:key', 'member'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsRank() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(0, $redis->zrank('letters', 'a')); - $this->assertSame(1, $redis->zrank('letters', 'b')); - $this->assertSame(4, $redis->zrank('letters', 'e')); - - $this->assertNull($redis->zrank('unknown', 'a')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zrank('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByRankTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByRankTest.php deleted file mode 100644 index 9bdcc59b7..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByRankTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetRemoveRangeByRankTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetRemoveRangeByRank'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZREMRANGEBYRANK'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 10); - $expected = array('key', 0, 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 0, 10); - $expected = array('prefix:key', 0, 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testRemovesRangeByRank() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(3, $redis->zremrangebyrank('letters', 2, 4)); - $this->assertSame(array('a', 'b', 'f'), $redis->zrange('letters', 0, -1)); - - $this->assertSame(0, $redis->zremrangebyrank('unknown', 0, 30)); - } - - /** - * @group connected - */ - public function testRemovesRangeByRankWithNegativeIndex() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(3, $redis->zremrangebyrank('letters', -5, 3)); - $this->assertSame(array('a', 'e', 'f'), $redis->zrange('letters', 0, -1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zremrangebyrank('foo', 0, 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByScoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByScoreTest.php deleted file mode 100644 index 193d72b49..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveRangeByScoreTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetRemoveRangeByScoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetRemoveRangeByScore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZREMRANGEBYSCORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 10); - $expected = array('key', 0, 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 0, 10); - $expected = array('prefix:key', 0, 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testRemovesRangeByScore() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(3, $redis->zremrangebyscore('letters', 5, 20)); - $this->assertSame(array('a', 'b', 'f'), $redis->zrange('letters', 0, -1)); - - $this->assertSame(0, $redis->zremrangebyscore('unknown', 0, 30)); - } - - /** - * @group connected - */ - public function testRemovesRangeByExclusiveScore() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(2, $redis->zremrangebyscore('letters', '(10', '(30')); - $this->assertSame(array('a', 'b', 'c', 'f'), $redis->zrange('letters', 0, -1)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zremrangebyscore('foo', 0, 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetRemoveTest.php deleted file mode 100644 index f419ddbc3..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetRemoveTest.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetRemoveTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetRemove'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZREM'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('zset', 'member1', 'member2', 'member3'); - $expected = array('zset', 'member1', 'member2', 'member3'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('zset', 'member1', 'member2', 'member3'); - $expected = array('prefix:zset', 'member1', 'member2', 'member3'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testRemovesSpecifiedMembers() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(3, $redis->zrem('letters', 'b', 'd', 'f', 'z')); - $this->assertSame(array('a', 'c', 'e'), $redis->zrange('letters', 0, -1)); - - $this->assertSame(0, $redis->zrem('unknown', 'a')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zrem('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeByScoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeByScoreTest.php deleted file mode 100644 index 1186ed3c3..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeByScoreTest.php +++ /dev/null @@ -1,257 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetReverseRangeByScoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetReverseRangeByScore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZREVRANGEBYSCORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $modifiers = array( - 'withscores' => true, - 'limit' => array(0, 100), - ); - - $arguments = array('zset', 0, 100, $modifiers); - $expected = array('zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithStringWithscores() - { - $arguments = array('zset', 0, 100, 'withscores'); - $expected = array('zset', 0, 100, 'WITHSCORES'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithNamedLimit() - { - $arguments = array('zset', 0, 100, array('limit' => array('offset' => 1, 'count' => 2))); - $expected = array('zset', 0, 100, 'LIMIT', 1, 2); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('element1', 'element2', 'element3'); - $expected = array('element1', 'element2', 'element3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testParseResponseWithScores() - { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array(array('element1', '1'), array('element2', '2'), array('element3', '3')); - - $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $modifiers = array( - 'withscores' => true, - 'limit' => array(0, 100), - ); - - $arguments = array('zset', 0, 100, $modifiers); - $expected = array('prefix:zset', 0, 100, 'LIMIT', 0, 100, 'WITHSCORES'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue() - { - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsElementsInScoreRange() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(array('a'), $redis->zrevrangebyscore('letters', -10, -10)); - $this->assertSame(array(), $redis->zrevrangebyscore('letters', 10, 30)); - $this->assertSame(array('e', 'd'), $redis->zrevrangebyscore('letters', 20, 20)); - $this->assertSame(array('f', 'e', 'd', 'c', 'b'), $redis->zrevrangebyscore('letters', 30, 0)); - - $this->assertSame(array(), $redis->zrevrangebyscore('unknown', 0, 30)); - } - - /** - * @group connected - */ - public function testInfinityScoreIntervals() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(array('f', 'e', 'd'), $redis->zrevrangebyscore('letters', '+inf', 15)); - $this->assertSame(array('c', 'b', 'a'), $redis->zrevrangebyscore('letters', 15, '-inf')); - $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrangebyscore('letters', '+inf', '-inf')); - } - - /** - * @group connected - */ - public function testExclusiveScoreIntervals() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(array('e', 'd', 'c'), $redis->zrevrangebyscore('letters', '(30', 10)); - $this->assertSame(array('f', 'e', 'd'), $redis->zrevrangebyscore('letters', 30, '(10')); - $this->assertSame(array('e', 'd'), $redis->zrevrangebyscore('letters', '(30', '(10')); - } - - /** - * @group connected - */ - public function testRangeWithWithscoresModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array(array('e', '20'), array('d', '20'), array('c', '10')); - - $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, 'withscores')); - $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('withscores' => true))); - } - - /** - * @group connected - */ - public function testRangeWithLimitModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array('d', 'c'); - - $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('limit' => array(1, 2)))); - $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, array('limit' => array('offset' => 1, 'count' => 2)))); - } - - /** - * @group connected - */ - public function testRangeWithCombinedModifiers() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $options = array('limit' => array(1, 2), 'withscores' => true); - $expected = array(array('d', '20'), array('c', '10')); - - $this->assertSame($expected, $redis->zrevrangebyscore('letters', 20, 10, $options)); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zrevrangebyscore('foo', 0, 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeTest.php deleted file mode 100644 index e83462bfe..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRangeTest.php +++ /dev/null @@ -1,180 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetReverseRangeTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetReverseRange'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZREVRANGE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('zset', 0, 100, array('withscores' => true)); - $expected = array('zset', 0, 100, 'WITHSCORES'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithStringWithscores() - { - $arguments = array('zset', 0, 100, 'withscores'); - $expected = array('zset', 0, 100, 'WITHSCORES'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('element1', 'element2', 'element3'); - $expected = array('element1', 'element2', 'element3'); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testParseResponseWithScores() - { - $raw = array('element1', '1', 'element2', '2', 'element3', '3'); - $expected = array(array('element1', '1'), array('element2', '2'), array('element3', '3')); - - $command = $this->getCommandWithArgumentsArray(array('zset', 0, 1, 'withscores')); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('zset', 0, 100, array('withscores' => true)); - $expected = array('prefix:zset', 0, 100, 'WITHSCORES'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testAddsWithscoresModifiersOnlyWhenOptionIsTrue() - { - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => true)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 1)); - $this->assertSame(array('zset', 0, 100, 'WITHSCORES'), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => false)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); - - $command = $this->getCommandWithArguments('zset', 0, 100, array('withscores' => 0)); - $this->assertSame(array('zset', 0, 100), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsElementsInRange() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(array(), $redis->zrevrange('letters', 1, 0)); - $this->assertSame(array('f'), $redis->zrevrange('letters', 0, 0)); - $this->assertSame(array('f', 'e', 'd', 'c'), $redis->zrevrange('letters', 0, 3)); - - $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrange('letters', 0, -1)); - $this->assertSame(array('f', 'e', 'd'), $redis->zrevrange('letters', 0, -4)); - $this->assertSame(array('d'), $redis->zrevrange('letters', 2, -4)); - $this->assertSame(array('f', 'e', 'd', 'c', 'b', 'a'), $redis->zrevrange('letters', -100, 100)); - - $this->assertSame(array(), $redis->zrevrange('unknown', 0, 30)); - } - - /** - * @group connected - */ - public function testRangeWithWithscoresModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - $expected = array(array('d', '20'), array('c', '10'), array('b', '0')); - - $this->assertSame($expected, $redis->zrevrange('letters', 2, 4, 'withscores')); - $this->assertSame($expected, $redis->zrevrange('letters', 2, 4, array('withscores' => true))); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zrevrange('foo', 0, 10); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRankTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetReverseRankTest.php deleted file mode 100644 index d61cee54e..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetReverseRankTest.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetReverseRankTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetReverseRank'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZREVRANK'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'member'); - $expected = array('key', 'member'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'member'); - $expected = array('prefix:key', 'member'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsRank() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame(5, $redis->zrevrank('letters', 'a')); - $this->assertSame(4, $redis->zrevrank('letters', 'b')); - $this->assertSame(1, $redis->zrevrank('letters', 'e')); - - $this->assertNull($redis->zrevrank('unknown', 'a')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zrevrank('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetScanTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetScanTest.php deleted file mode 100644 index 20e31ddc5..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetScanTest.php +++ /dev/null @@ -1,161 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetScanTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetScan'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZSCAN'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); - $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsBasicUsage() - { - $arguments = array('key', 0); - $expected = array('key', 0); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsWithOptionsArray() - { - $arguments = array('key', 0, array('match' => 'member:*', 'count' => 10)); - $expected = array('key', 0, 'MATCH', 'member:*', 'COUNT', 10); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $raw = array('3', array('member:1', '1', 'member:2', '2', 'member:3', '3')); - $expected = array(3, array(array('member:1' , 1.0), array('member:2', 2.0), array('member:3' , 3.0))); - - $command = $this->getCommand(); - - $this->assertSame($expected, $command->parseResponse($raw)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', '0', 'MATCH', 'member:*', 'COUNT', 10); - $expected = array('prefix:key', '0', 'MATCH', 'member:*', 'COUNT', 10); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testScanWithoutMatch() - { - $expectedMembers = array('member:one', 'member:two', 'member:three', 'member:four'); - $expectedScores = array(1.0, 2.0, 3.0, 4.0); - - $redis = $this->getClient(); - $redis->zadd('key', array_combine($expectedMembers, $expectedScores)); - - $response = $redis->zscan('key', 0); - - $this->assertSame(0, $response[0]); - $this->assertSame($expectedMembers, array_map(function ($e) { return $e[0]; }, $response[1])); - $this->assertSame($expectedScores, array_map(function ($e) { return $e[1]; }, $response[1])); - } - - /** - * @group connected - */ - public function testScanWithMatchingMembers() - { - $redis = $this->getClient(); - $redis->zadd('key', array('member:one' => 1.0, 'member:two' => 2.0, 'member:three' => 3.0, 'member:four' => 4.0)); - - $response = $redis->zscan('key', 0, 'MATCH', 'member:t*'); - - $this->assertSame(array('member:two', 'member:three'), array_map(function ($e) { return $e[0]; }, $response[1])); - $this->assertSame(array(2.0, 3.0), array_map(function ($e) { return $e[1]; }, $response[1])); - } - - /** - * @group connected - */ - public function testScanWithNoMatchingMembers() - { - $redis = $this->getClient(); - $redis->zadd('key', $members = array('member:one' => 1.0, 'member:two' => 2.0, 'member:three' => 3.0, 'member:four' => 4.0)); - - $response = $redis->zscan('key', 0, 'MATCH', 'nomember:*'); - - $this->assertSame(0, $response[0]); - $this->assertEmpty($response[1]); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetScoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetScoreTest.php deleted file mode 100644 index b65f9f378..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetScoreTest.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetScoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetScore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZSCORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $arguments = array('key', 'member'); - $expected = array('key', 'member'); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $arguments = array('key', 'member'); - $expected = array('prefix:key', 'member'); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testReturnsRank() - { - $redis = $this->getClient(); - - $redis->zadd('letters', -10, 'a', 0, 'b', 10, 'c', 20, 'd', 20, 'e', 30, 'f'); - - $this->assertSame('-10', $redis->zscore('letters', 'a')); - $this->assertSame('0', $redis->zscore('letters', 'b')); - $this->assertSame('20', $redis->zscore('letters', 'e')); - - $this->assertNull($redis->zscore('unknown', 'a')); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zscore('foo', 'bar'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Command/ZSetUnionStoreTest.php b/vendor/predis/predis/tests/Predis/Command/ZSetUnionStoreTest.php deleted file mode 100644 index eb427867e..000000000 --- a/vendor/predis/predis/tests/Predis/Command/ZSetUnionStoreTest.php +++ /dev/null @@ -1,219 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Command; - -/** - * @group commands - * @group realm-zset - */ -class ZSetUnionStoreTest extends PredisCommandTestCase -{ - /** - * {@inheritdoc} - */ - protected function getExpectedCommand() - { - return 'Predis\Command\ZSetUnionStore'; - } - - /** - * {@inheritdoc} - */ - protected function getExpectedId() - { - return 'ZUNIONSTORE'; - } - - /** - * @group disconnected - */ - public function testFilterArguments() - { - $modifiers = array( - 'aggregate' => 'sum', - 'weights' => array(10, 100), - ); - $arguments = array('zset:destination', 2, 'zset1', 'zset2', $modifiers); - - $expected = array( - 'zset:destination', 2, 'zset1', 'zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' - ); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testFilterArgumentsSourceKeysAsSingleArray() - { - $modifiers = array( - 'aggregate' => 'sum', - 'weights' => array(10, 100), - ); - $arguments = array('zset:destination', array('zset1', 'zset2'), $modifiers); - - $expected = array( - 'zset:destination', 2, 'zset1', 'zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' - ); - - $command = $this->getCommand(); - $command->setArguments($arguments); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testParseResponse() - { - $this->assertSame(1, $this->getCommand()->parseResponse(1)); - } - - /** - * @group disconnected - */ - public function testPrefixKeys() - { - $modifiers = array( - 'aggregate' => 'sum', - 'weights' => array(10, 100), - ); - $arguments = array('zset:destination', 2, 'zset1', 'zset2', $modifiers); - - $expected = array( - 'prefix:zset:destination', 2, 'prefix:zset1', 'prefix:zset2', 'WEIGHTS', 10, 100, 'AGGREGATE', 'sum' - ); - - $command = $this->getCommandWithArgumentsArray($arguments); - $command->prefixKeys('prefix:'); - - $this->assertSame($expected, $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testPrefixKeysIgnoredOnEmptyArguments() - { - $command = $this->getCommand(); - $command->prefixKeys('prefix:'); - - $this->assertSame(array(), $command->getArguments()); - } - - /** - * @group connected - */ - public function testStoresUnionInNewSortedSet() - { - $redis = $this->getClient(); - - $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); - $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); - - $this->assertSame(4, $redis->zunionstore('letters:out', 2, 'letters:1st', 'letters:2nd')); - $this->assertSame( - array(array('a', '1'), array('b', '3'), array('d', '3'), array('c', '5')), - $redis->zrange('letters:out', 0, -1, 'withscores') - ); - - $this->assertSame(3, $redis->zunionstore('letters:out', 2, 'letters:1st', 'letters:void')); - $this->assertSame(3, $redis->zunionstore('letters:out', 2, 'letters:void', 'letters:2nd')); - $this->assertSame(0, $redis->zunionstore('letters:out', 2, 'letters:void', 'letters:void')); - } - - /** - * @group connected - */ - public function testStoresUnionWithAggregateModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); - $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); - - $options = array('aggregate' => 'min'); - $this->assertSame(4, $redis->zunionstore('letters:min', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame( - array(array('a', '1'), array('b', '1'), array('c', '2'), array('d', '3')), - $redis->zrange('letters:min', 0, -1, 'withscores') - ); - - $options = array('aggregate' => 'max'); - $this->assertSame(4, $redis->zunionstore('letters:max', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame( - array(array('a', '1'), array('b', '2'), array('c', '3'), array('d', '3')), - $redis->zrange('letters:max', 0, -1, 'withscores') - ); - - $options = array('aggregate' => 'sum'); - $this->assertSame(4, $redis->zunionstore('letters:sum', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame( - array(array('a', '1'), array('b', '3'), array('d', '3'), array('c', '5')), - $redis->zrange('letters:sum', 0, -1, 'withscores') - ); - } - - /** - * @group connected - */ - public function testStoresUnionWithWeightsModifier() - { - $redis = $this->getClient(); - - $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); - $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); - - $options = array('weights' => array(2, 3)); - $this->assertSame(4, $redis->zunionstore('letters:out', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame( - array(array('a', '2'), array('b', '7'), array('d', '9'), array('c', '12')), - $redis->zrange('letters:out', 0, -1, 'withscores') - ); - } - - /** - * @group connected - */ - public function testStoresUnionWithCombinedModifiers() - { - $redis = $this->getClient(); - - $redis->zadd('letters:1st', 1, 'a', 2, 'b', 3, 'c'); - $redis->zadd('letters:2nd', 1, 'b', 2, 'c', 3, 'd'); - - $options = array('aggregate' => 'max', 'weights' => array(10, 15)); - $this->assertSame(4, $redis->zunionstore('letters:out', 2, 'letters:1st', 'letters:2nd', $options)); - $this->assertSame( - array(array('a', '10'), array('b', '20'), array('c', '30'), array('d', '45')), - $redis->zrange('letters:out', 0, -1, 'withscores') - ); - } - - /** - * @group connected - * @expectedException Predis\ServerException - * @expectedExceptionMessage Operation against a key holding the wrong kind of value - */ - public function testThrowsExceptionOnWrongType() - { - $redis = $this->getClient(); - - $redis->set('foo', 'bar'); - $redis->zunionstore('zset:destination', 1, 'foo'); - } -} diff --git a/vendor/predis/predis/tests/Predis/CommunicationExceptionTest.php b/vendor/predis/predis/tests/Predis/CommunicationExceptionTest.php deleted file mode 100644 index 4199334eb..000000000 --- a/vendor/predis/predis/tests/Predis/CommunicationExceptionTest.php +++ /dev/null @@ -1,113 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use PredisTestCase; -use Predis\Connection\SingleConnectionInterface; - -/** - * - */ -class CommunicationExceptionTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExceptionMessage() - { - $message = 'Connection error message.'; - $connection = $this->getMockedConnectionBase(); - $exception = $this->getException($connection, $message); - - $this->setExpectedException('Predis\CommunicationException', $message); - - throw $exception; - } - - /** - * @group disconnected - */ - public function testExceptionConnection() - { - $connection = $this->getMockedConnectionBase(); - $exception = $this->getException($connection, 'ERROR MESSAGE'); - - $this->assertSame($connection, $exception->getConnection()); - } - - /** - * @group disconnected - */ - public function testShouldResetConnection() - { - $connection = $this->getMockedConnectionBase(); - $exception = $this->getException($connection, 'ERROR MESSAGE'); - - $this->assertTrue($exception->shouldResetConnection()); - } - - /** - * @group disconnected - * @expectedException Predis\CommunicationException - * @expectedExceptionMessage Communication error - */ - public function testCommunicationExceptionHandling() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once())->method('isConnected')->will($this->returnValue(true)); - $connection->expects($this->once())->method('disconnect'); - - $exception = $this->getException($connection, 'Communication error'); - - CommunicationException::handle($exception); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a mocked connection instance. - * - * @param mixed $parameters Connection parameters. - * @return SingleConnectionInterface - */ - protected function getMockedConnectionBase($parameters = null) - { - $builder = $this->getMockBuilder('Predis\Connection\AbstractConnection'); - - if ($parameters === null) { - $builder->disableOriginalConstructor(); - } elseif (!$parameters instanceof ConnectionParametersInterface) { - $parameters = new ConnectionParameters($parameters); - } - - return $builder->getMockForAbstractClass(array($parameters)); - } - - /** - * Returns a connection exception instance. - * - * @param Connection\SingleConnectionInterface $connection Connection instance. - * @param string $message Exception message. - * @param int $code Exception code. - * @param \Exception $inner Inner exception. - * @return \Exception - */ - protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) - { - $arguments = array($connection, $message, $code, $inner); - $mock = $this->getMockForAbstractClass('Predis\CommunicationException', $arguments); - - return $mock; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/ComposableStreamConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/ComposableStreamConnectionTest.php deleted file mode 100644 index 594280146..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/ComposableStreamConnectionTest.php +++ /dev/null @@ -1,120 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -/** - * - */ -class ComposableStreamConnectionTest extends PredisConnectionTestCase -{ - /** - * @group disconnected - */ - public function testConstructorDoesNotOpenConnection() - { - $connection = new ComposableStreamConnection($this->getParameters()); - - $this->assertFalse($connection->isConnected()); - } - - /** - * @group disconnected - */ - public function testExposesParameters() - { - $parameters = $this->getParameters(); - $connection = new ComposableStreamConnection($parameters); - - $this->assertSame($parameters, $connection->getParameters()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid scheme: udp - */ - public function testThrowsExceptionOnInvalidScheme() - { - $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new ComposableStreamConnection($parameters); - } - - /** - * @group disconnected - */ - public function testCanBeSerialized() - { - $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); - $connection = new ComposableStreamConnection($parameters); - - $unserialized = unserialize(serialize($connection)); - - $this->assertEquals($connection, $unserialized); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testReadsMultibulkRepliesAsIterators() - { - $connection = $this->getConnection($profile, true); - $connection->getProtocol()->setOption('iterable_multibulk', true); - - $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); - $connection->writeCommand($profile->createCommand('lrange', array('metavars', 0, -1))); - - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponse', $iterator = $connection->read()); - $this->assertSame(array('foo', 'hoge', 'lol'), iterator_to_array($iterator)); - } - - /** - * @group connected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Unknown prefix: 'P' - */ - public function testThrowsExceptionOnProtocolDesynchronizationErrors() - { - $connection = $this->getConnection($profile); - $stream = $connection->getResource(); - - $connection->writeCommand($profile->createCommand('ping')); - fread($stream, 1); - - $connection->read(); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * {@inheritdoc} - */ - protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()) - { - $parameters = $this->getParameters($parameters); - $profile = $this->getProfile(); - - $connection = new ComposableStreamConnection($parameters); - - if ($initialize) { - $connection->pushInitCommand($profile->createCommand('select', array($parameters->database))); - $connection->pushInitCommand($profile->createCommand('flushdb')); - } - - return $connection; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/ConnectionExceptionTest.php b/vendor/predis/predis/tests/Predis/Connection/ConnectionExceptionTest.php deleted file mode 100644 index 71cb4b6f4..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/ConnectionExceptionTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -require_once __DIR__.'/../CommunicationExceptionTest.php'; - -use Predis\CommunicationExceptionTest; -use Predis\Connection\SingleConnectionInterface; - -/** - * - */ -class ConnectionExceptionTest extends CommunicationExceptionTest -{ - /** - * {@inheritdoc} - */ - protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) - { - return new ConnectionException($connection, $message, $code, $inner); - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/ConnectionFactoryTest.php b/vendor/predis/predis/tests/Predis/Connection/ConnectionFactoryTest.php deleted file mode 100644 index 809106fe8..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/ConnectionFactoryTest.php +++ /dev/null @@ -1,383 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use PredisTestCase; -/** - * - */ -class ConnectionFactoryTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testImplementsCorrectInterface() - { - $factory = new ConnectionFactory(); - - $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $factory); - } - - /** - * @group disconnected - */ - public function testCreateConnection() - { - $factory = new ConnectionFactory(); - - $tcp = new ConnectionParameters(array( - 'scheme' => 'tcp', - 'host' => 'locahost', - )); - - $connection = $factory->create($tcp); - $parameters = $connection->getParameters(); - $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); - $this->assertEquals($tcp->scheme, $parameters->scheme); - $this->assertEquals($tcp->host, $parameters->host); - $this->assertEquals($tcp->database, $parameters->database); - - $unix = new ConnectionParameters(array( - 'scheme' => 'unix', - 'path' => '/tmp/redis.sock', - )); - - $connection = $factory->create($tcp); - $parameters = $connection->getParameters(); - $this->assertInstanceOf('Predis\Connection\StreamConnection', $connection); - $this->assertEquals($tcp->scheme, $parameters->scheme); - $this->assertEquals($tcp->database, $parameters->database); - } - - /** - * @group disconnected - */ - public function testCreateConnectionWithNullParameters() - { - $factory = new ConnectionFactory(); - $connection = $factory->create(null); - $parameters = $connection->getParameters(); - - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - $this->assertEquals('tcp', $parameters->scheme); - - $this->assertFalse(isset($parameters->custom)); - $this->assertNull($parameters->custom); - } - - /** - * @group disconnected - */ - public function testCreateConnectionWithArrayParameters() - { - $factory = new ConnectionFactory(); - $connection = $factory->create(array('scheme' => 'tcp', 'custom' => 'foobar')); - $parameters = $connection->getParameters(); - - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - $this->assertEquals('tcp', $parameters->scheme); - - $this->assertTrue(isset($parameters->custom)); - $this->assertSame('foobar', $parameters->custom); - } - - /** - * @group disconnected - */ - public function testCreateConnectionWithStringURI() - { - $factory = new ConnectionFactory(); - $connection = $factory->create('tcp://127.0.0.1?custom=foobar'); - $parameters = $connection->getParameters(); - - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - $this->assertEquals('tcp', $parameters->scheme); - - $this->assertTrue(isset($parameters->custom)); - $this->assertSame('foobar', $parameters->custom); - } - - /** - * @group disconnected - */ - public function testCreateConnectionWithoutInitializationCommands() - { - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); - $profile->expects($this->never())->method('create'); - - $factory = new ConnectionFactory($profile); - $parameters = new ConnectionParameters(); - $connection = $factory->create($parameters); - - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - } - - /** - * @group disconnected - */ - public function testCreateConnectionWithInitializationCommands() - { - $test = $this; - $database = 15; - $password = 'foobar'; - $commands = array(); - - $createCommand = function ($id, $arguments) use ($test, &$commands) { - $commands[$id] = $arguments; - $command = $test->getMock('Predis\Command\CommandInterface'); - - return $command; - }; - - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); - $profile->expects($this->exactly(2)) - ->method('createCommand') - ->with($this->isType('string'), $this->isType('array')) - ->will($this->returnCallback($createCommand)); - - $factory = new ConnectionFactory($profile); - $parameters = new ConnectionParameters(array('database' => $database, 'password' => $password)); - $connection = $factory->create($parameters); - - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - $this->assertEquals(2, count($commands)); // TODO: assertCount()? - $this->assertEquals(array($database), $commands['select']); - $this->assertEquals(array($password), $commands['auth']); - } - - /** - * @group disconnected - * @todo This test smells but there's no other way around it right now. - */ - public function testCreateConnectionWithDatabaseAndPasswordButNoProfile() - { - $parameters = new ConnectionParameters(array('database' => 0, 'password' => 'foobar')); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->never()) - ->method('getParameters') - ->will($this->returnValue($parameters)); - $connection->expects($this->never()) - ->method('pushInitCommand'); - - $factory = new ConnectionFactory(); - - $reflection = new \ReflectionObject($factory); - $prepareConnection = $reflection->getMethod('prepareConnection'); - $prepareConnection->setAccessible(true); - $prepareConnection->invoke($factory, $connection); - } - - /** - * @group disconnected - */ - public function testCreateUndefinedConnection() - { - $scheme = 'unknown'; - $this->setExpectedException('InvalidArgumentException', "Unknown connection scheme: $scheme"); - - $factory = new ConnectionFactory(); - $factory->create(new ConnectionParameters(array('scheme' => $scheme))); - } - - /** - * @group disconnected - */ - public function testDefineConnectionWithFQN() - { - list(, $connectionClass) = $this->getMockConnectionClass(); - - $parameters = new ConnectionParameters(array('scheme' => 'foobar')); - $factory = new ConnectionFactory(); - - $factory->define($parameters->scheme, $connectionClass); - $connection = $factory->create($parameters); - - $this->assertInstanceOf($connectionClass, $connection); - } - - /** - * @group disconnected - */ - public function testDefineConnectionWithCallable() - { - list(, $connectionClass) = $this->getMockConnectionClass(); - - $parameters = new ConnectionParameters(array('scheme' => 'foobar')); - - $initializer = function ($parameters) use ($connectionClass) { - return new $connectionClass($parameters); - }; - - $initializerMock = $this->getMock('stdClass', array('__invoke')); - $initializerMock->expects($this->exactly(2)) - ->method('__invoke') - ->with($parameters) - ->will($this->returnCallback($initializer)); - - $factory = new ConnectionFactory(); - $factory->define($parameters->scheme, $initializerMock); - $connection1 = $factory->create($parameters); - $connection2 = $factory->create($parameters); - - $this->assertInstanceOf($connectionClass, $connection1); - $this->assertInstanceOf($connectionClass, $connection2); - $this->assertNotSame($connection1, $connection2); - } - - /** - * @group disconnected - */ - public function testDefineConnectionWithInvalidArgument() - { - $this->setExpectedException('InvalidArgumentException'); - - $factory = new ConnectionFactory(); - $factory->define('foobar', new \stdClass()); - } - - /** - * @group disconnected - */ - public function testUndefineDefinedConnection() - { - $this->setExpectedException('InvalidArgumentException', 'Unknown connection scheme: tcp'); - - $factory = new ConnectionFactory(); - $factory->undefine('tcp'); - $factory->create('tcp://127.0.0.1'); - } - - /** - * @group disconnected - */ - public function testUndefineUndefinedConnection() - { - $factory = new ConnectionFactory(); - $factory->undefine('unknown'); - $connection = $factory->create('tcp://127.0.0.1'); - - $this->assertInstanceOf('Predis\Connection\SingleConnectionInterface', $connection); - } - - /** - * @group disconnected - */ - public function testDefineAndUndefineConnection() - { - list(, $connectionClass) = $this->getMockConnectionClass(); - - $factory = new ConnectionFactory(); - - $factory->define('redis', $connectionClass); - $this->assertInstanceOf($connectionClass, $factory->create('redis://127.0.0.1')); - - $factory->undefine('redis'); - $this->setExpectedException('InvalidArgumentException', 'Unknown connection scheme: redis'); - $factory->create('redis://127.0.0.1'); - } - - /** - * @group disconnected - */ - public function testAggregatedConnectionSkipCreationOnConnectionInstance() - { - list(, $connectionClass) = $this->getMockConnectionClass(); - - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); - $cluster->expects($this->exactly(2)) - ->method('add') - ->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface')); - - $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create')); - $factory->expects($this->never()) - ->method('create'); - - $factory->createAggregated($cluster, array(new $connectionClass(), new $connectionClass())); - } - - /** - * @group disconnected - */ - public function testAggregatedConnectionWithMixedParameters() - { - list(, $connectionClass) = $this->getMockConnectionClass(); - - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); - $cluster->expects($this->exactly(4)) - ->method('add') - ->with($this->isInstanceOf('Predis\Connection\SingleConnectionInterface')); - - $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create')); - $factory->expects($this->exactly(3)) - ->method('create') - ->will($this->returnCallback(function ($_) use ($connectionClass) { - return new $connectionClass; - })); - - $factory->createAggregated($cluster, array(null, 'tcp://127.0.0.1', array('scheme' => 'tcp'), new $connectionClass())); - } - - /** - * @group disconnected - */ - public function testAggregatedConnectionWithEmptyListOfParameters() - { - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); - $cluster->expects($this->never())->method('add'); - - $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create')); - $factory->expects($this->never())->method('create'); - - $factory->createAggregated($cluster, array()); - } - - /** - * @group disconnected - * @todo We might want to add a test for SingleConnectionInterface::pushInitCommand(). - */ - public function testAggregatedConnectionWithServerProfileArgument() - { - list(, $connectionClass) = $this->getMockConnectionClass(); - - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); - - $factory = $this->getMock('Predis\Connection\ConnectionFactory', array('create'), array($profile)); - $factory->expects($this->exactly(2)) - ->method('create') - ->with($this->anything()) - ->will($this->returnCallback(function ($_) use ($connectionClass) { - return new $connectionClass(); - })); - - $nodes = array('tcp://127.0.0.1:7001?password=foo', 'tcp://127.0.0.1:7002?password=bar'); - $factory->createAggregated($cluster, $nodes); - } - - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a mocked Predis\Connection\SingleConnectionInterface. - * - * @return Array Mock instance and class name - */ - protected function getMockConnectionClass() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - return array($connection, get_class($connection)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/ConnectionParametersTest.php b/vendor/predis/predis/tests/Predis/Connection/ConnectionParametersTest.php deleted file mode 100644 index d31b32ade..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/ConnectionParametersTest.php +++ /dev/null @@ -1,265 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use PredisTestCase; -/** - * @todo ConnectionParameters::define(); - * @todo ConnectionParameters::undefine(); - */ -class ParametersTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testDefaultValues() - { - $defaults = $this->getDefaultParametersArray(); - $parameters = new ConnectionParameters(); - - $this->assertEquals($defaults['scheme'], $parameters->scheme); - $this->assertEquals($defaults['host'], $parameters->host); - $this->assertEquals($defaults['port'], $parameters->port); - $this->assertEquals($defaults['timeout'], $parameters->timeout); - } - - /** - * @group disconnected - */ - public function testIsSet() - { - $parameters = new ConnectionParameters(); - - $this->assertTrue(isset($parameters->scheme)); - $this->assertFalse(isset($parameters->unknown)); - } - - /** - * @group disconnected - */ - public function testUserDefinedParameters() - { - $parameters = new ConnectionParameters(array('port' => 7000, 'custom' => 'foobar')); - - $this->assertTrue(isset($parameters->scheme)); - $this->assertSame('tcp', $parameters->scheme); - - $this->assertTrue(isset($parameters->port)); - $this->assertSame(7000, $parameters->port); - - $this->assertTrue(isset($parameters->custom)); - $this->assertSame('foobar', $parameters->custom); - - $this->assertFalse(isset($parameters->unknown)); - $this->assertNull($parameters->unknown); - } - - /** - * @group disconnected - */ - public function testConstructWithUriString() - { - $defaults = $this->getDefaultParametersArray(); - - $overrides = array( - 'port' => 7000, - 'database' => 5, - 'iterable_multibulk' => false, - 'custom' => 'foobar', - ); - - $parameters = new ConnectionParameters($this->getParametersString($overrides)); - - $this->assertEquals($defaults['scheme'], $parameters->scheme); - $this->assertEquals($defaults['host'], $parameters->host); - $this->assertEquals($overrides['port'], $parameters->port); - - $this->assertEquals($overrides['database'], $parameters->database); - $this->assertEquals($overrides['iterable_multibulk'], $parameters->iterable_multibulk); - - $this->assertTrue(isset($parameters->custom)); - $this->assertEquals($overrides['custom'], $parameters->custom); - - $this->assertFalse(isset($parameters->unknown)); - $this->assertNull($parameters->unknown); - } - - /** - * @group disconnected - */ - public function testToArray() - { - $additional = array('port' => 7000, 'custom' => 'foobar'); - $parameters = new ConnectionParameters($additional); - - $this->assertEquals($this->getParametersArray($additional), $parameters->toArray()); - } - - /** - * @group disconnected - */ - public function testSerialization() - { - $parameters = new ConnectionParameters(array('port' => 7000, 'custom' => 'foobar')); - $unserialized = unserialize(serialize($parameters)); - - $this->assertEquals($parameters->scheme, $unserialized->scheme); - $this->assertEquals($parameters->port, $unserialized->port); - - $this->assertTrue(isset($unserialized->custom)); - $this->assertEquals($parameters->custom, $unserialized->custom); - - $this->assertFalse(isset($unserialized->unknown)); - $this->assertNull($unserialized->unknown); - } - - /** - * @group disconnected - */ - public function testParsingURI() - { - $uri = 'tcp://10.10.10.10:6400?timeout=0.5&persistent=1'; - - $expected = array( - 'scheme' => 'tcp', - 'host' => '10.10.10.10', - 'port' => 6400, - 'timeout' => '0.5', - 'persistent' => '1', - ); - - $this->assertSame($expected, ConnectionParameters::parseURI($uri)); - } - - /** - * @group disconnected - */ - public function testParsingUnixDomainURI() - { - $uri = 'unix:///tmp/redis.sock?timeout=0.5&persistent=1'; - - $expected = array( - 'scheme' => 'unix', - 'host' => 'localhost', - 'path' => '/tmp/redis.sock', - 'timeout' => '0.5', - 'persistent' => '1', - ); - - $this->assertSame($expected, ConnectionParameters::parseURI($uri)); - } - - /** - * @group disconnected - */ - public function testParsingURIWithIncompletePairInQueryString() - { - $uri = 'tcp://10.10.10.10?persistent=1&foo=&bar'; - - $expected = array( - 'scheme' => 'tcp', - 'host' => '10.10.10.10', - 'persistent' => '1', - 'foo' => '', - 'bar' => '', - ); - - $this->assertSame($expected, ConnectionParameters::parseURI($uri)); - } - - /** - * @group disconnected - */ - public function testParsingURIWithMoreThanOneEqualSignInQueryStringPairValue() - { - $uri = 'tcp://10.10.10.10?foobar=a=b=c&persistent=1'; - - $expected = array( - 'scheme' => 'tcp', - 'host' => '10.10.10.10', - 'foobar' => 'a=b=c', - 'persistent' => '1', - ); - - $this->assertSame($expected, ConnectionParameters::parseURI($uri)); - } - - /** - * @group disconnected - */ - public function testParsingURIWhenQueryStringHasBracketsInFieldnames() - { - $uri = 'tcp://10.10.10.10?persistent=1&metavars[]=foo&metavars[]=hoge'; - - $expected = array( - 'scheme' => 'tcp', - 'host' => '10.10.10.10', - 'persistent' => '1', - 'metavars' => array('foo', 'hoge'), - ); - - $this->assertSame($expected, ConnectionParameters::parseURI($uri)); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - * @expectedExceptionMessage Invalid URI: tcp://invalid:uri - */ - public function testParsingURIThrowOnInvalidURI() - { - ConnectionParameters::parseURI('tcp://invalid:uri'); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a named array with the default connection parameters and their values. - * - * @return Array Default connection parameters. - */ - protected function getDefaultParametersArray() - { - return array( - 'scheme' => 'tcp', - 'host' => '127.0.0.1', - 'port' => 6379, - 'timeout' => 5.0, - ); - } - - /** - * Returns an URI string representation of the specified connection parameters. - * - * @param Array $parameters Array of connection parameters. - * @return String URI string. - */ - protected function getParametersString(Array $parameters) - { - $defaults = $this->getDefaultParametersArray(); - - $scheme = isset($parameters['scheme']) ? $parameters['scheme'] : $defaults['scheme']; - $host = isset($parameters['host']) ? $parameters['host'] : $defaults['host']; - $port = isset($parameters['port']) ? $parameters['port'] : $defaults['port']; - - unset($parameters['scheme'], $parameters['host'], $parameters['port']); - $uriString = "$scheme://$host:$port/?"; - - foreach ($parameters as $k => $v) { - $uriString .= "$k=$v&"; - } - - return $uriString; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/MasterSlaveReplicationTest.php b/vendor/predis/predis/tests/Predis/Connection/MasterSlaveReplicationTest.php deleted file mode 100644 index 9d364c9cf..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/MasterSlaveReplicationTest.php +++ /dev/null @@ -1,593 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use PredisTestCase; -use Predis\Profile\ServerProfile; -use Predis\Replication\ReplicationStrategy; - -/** - * - */ -class MasterSlaveReplicationTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testAddingConnectionsToReplication() - { - $master = $this->getMockConnection('tcp://host1?alias=master'); - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave2 = $this->getMockConnection('tcp://host3?alias=slave2'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - $replication->add($slave2); - - $this->assertSame($master, $replication->getConnectionById('master')); - $this->assertSame($slave1, $replication->getConnectionById('slave1')); - $this->assertSame($slave2, $replication->getConnectionById('slave2')); - - $this->assertSame($master, $replication->getMaster()); - $this->assertSame(array($slave1, $slave2), $replication->getSlaves()); - } - - /** - * @group disconnected - */ - public function testRemovingConnectionsFromReplication() - { - $master = $this->getMockConnection('tcp://host1?alias=master'); - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave2 = $this->getMockConnection('tcp://host3?alias=slave2'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $this->assertTrue($replication->remove($slave1)); - $this->assertFalse($replication->remove($slave2)); - - $this->assertSame($master, $replication->getMaster()); - $this->assertSame(array(), $replication->getSlaves()); - } - - /** - * @group disconnected - * @expectedException RuntimeException - * @expectedExceptionMessage Replication needs a master and at least one slave - */ - public function testThrowsExceptionOnEmptyReplication() - { - $replication = new MasterSlaveReplication(); - $replication->connect(); - } - - /** - * @group disconnected - * @expectedException RuntimeException - * @expectedExceptionMessage Replication needs a master and at least one slave - */ - public function testThrowsExceptionOnMissingMaster() - { - $replication = new MasterSlaveReplication(); - $replication->add($this->getMockConnection('tcp://host2?alias=slave1')); - - $replication->connect(); - } - - /** - * @group disconnected - * @expectedException RuntimeException - * @expectedExceptionMessage Replication needs a master and at least one slave - */ - public function testThrowsExceptionOnMissingSlave() - { - $replication = new MasterSlaveReplication(); - $replication->add($this->getMockConnection('tcp://host1?alias=master')); - - $replication->connect(); - } - - /** - * @group disconnected - */ - public function testConnectForcesConnectionToOneOfSlaves() - { - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->never())->method('connect'); - - $slave = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave->expects($this->once())->method('connect'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave); - - $replication->connect(); - } - - /** - * @group disconnected - */ - public function testIsConnectedReturnsTrueIfAtLeastOneConnectionIsOpen() - { - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->never())->method('isConnected')->will($this->returnValue(false)); - - $slave = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave->expects($this->once())->method('isConnected')->will($this->returnValue(true)); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave); - $replication->connect(); - - $this->assertTrue($replication->isConnected()); - } - - /** - * @group disconnected - */ - public function testIsConnectedReturnsFalseIfAllConnectionsAreClosed() - { - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->any())->method('isConnected')->will($this->returnValue(false)); - - $slave = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave->expects($this->any())->method('isConnected')->will($this->returnValue(false)); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave); - - $this->assertFalse($replication->isConnected()); - - $replication->connect(); - $replication->disconnect(); - - $this->assertFalse($replication->isConnected()); - } - - /** - * @group disconnected - */ - public function testDisconnectForcesCurrentConnectionToDisconnect() - { - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('disconnect'); - - $slave = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave->expects($this->once())->method('disconnect'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave); - - $replication->disconnect(); - } - - /** - * @group disconnected - */ - public function testCanSwitchConnectionByAlias() - { - $master = $this->getMockConnection('tcp://host1?alias=master'); - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $this->assertNull($replication->getCurrent()); - - $replication->switchTo('master'); - $this->assertSame($master, $replication->getCurrent()); - $replication->switchTo('slave1'); - $this->assertSame($slave1, $replication->getCurrent()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage The specified connection is not valid - */ - public function testThrowsErrorWhenSwitchingToUnknownConnection() - { - $replication = new MasterSlaveReplication(); - $replication->add($this->getMockConnection('tcp://host1?alias=master')); - $replication->add($this->getMockConnection('tcp://host2?alias=slave1')); - - $replication->switchTo('unknown'); - } - - /** - * @group disconnected - */ - public function testUsesSlavesOnReadOnlyCommands() - { - $profile = ServerProfile::getDefault(); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $cmd = $profile->createCommand('exists', array('foo')); - $this->assertSame($slave1, $replication->getConnection($cmd)); - - $cmd = $profile->createCommand('get', array('foo')); - $this->assertSame($slave1, $replication->getConnection($cmd)); - } - - /** - * @group disconnected - */ - public function testUsesMasterOnWriteCommands() - { - $profile = ServerProfile::getDefault(); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $cmd = $profile->createCommand('set', array('foo', 'bar')); - $this->assertSame($master, $replication->getConnection($cmd)); - - $cmd = $profile->createCommand('get', array('foo')); - $this->assertSame($master, $replication->getConnection($cmd)); - } - - /** - * @group disconnected - */ - public function testSwitchesFromSlaveToMasterOnWriteCommands() - { - $profile = ServerProfile::getDefault(); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $cmd = $profile->createCommand('exists', array('foo')); - $this->assertSame($slave1, $replication->getConnection($cmd)); - - $cmd = $profile->createCommand('set', array('foo', 'bar')); - $this->assertSame($master, $replication->getConnection($cmd)); - - $cmd = $profile->createCommand('exists', array('foo')); - $this->assertSame($master, $replication->getConnection($cmd)); - } - - /** - * @group disconnected - */ - public function testWritesCommandToCorrectConnection() - { - $profile = ServerProfile::getDefault(); - $cmdExists = $profile->createCommand('exists', array('foo')); - $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('writeCommand')->with($cmdSet); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->once())->method('writeCommand')->with($cmdExists); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->writeCommand($cmdExists); - $replication->writeCommand($cmdSet); - } - - /** - * @group disconnected - */ - public function testReadsCommandFromCorrectConnection() - { - $profile = ServerProfile::getDefault(); - $cmdExists = $profile->createCommand('exists', array('foo')); - $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('readResponse')->with($cmdSet); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->once())->method('readResponse')->with($cmdExists); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->readResponse($cmdExists); - $replication->readResponse($cmdSet); - } - - /** - * @group disconnected - */ - public function testExecutesCommandOnCorrectConnection() - { - $profile = ServerProfile::getDefault(); - $cmdExists = $profile->createCommand('exists', array('foo')); - $cmdSet = $profile->getDefault()->createCommand('set', array('foo', 'bar')); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('executeCommand')->with($cmdSet); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->once())->method('executeCommand')->with($cmdExists); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->executeCommand($cmdExists); - $replication->executeCommand($cmdSet); - } - - /** - * @group disconnected - */ - public function testWatchTriggersSwitchToMasterConnection() - { - $profile = ServerProfile::getDefault(); - $cmdWatch = $profile->createCommand('watch', array('foo')); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('executeCommand')->with($cmdWatch); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->never())->method('executeCommand'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->executeCommand($cmdWatch); - } - - /** - * @group disconnected - */ - public function testMultiTriggersSwitchToMasterConnection() - { - $profile = ServerProfile::getDefault(); - $cmdMulti = $profile->createCommand('multi'); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('executeCommand')->with($cmdMulti); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->never())->method('executeCommand'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->executeCommand($cmdMulti); - } - - /** - * @group disconnected - */ - public function testEvalTriggersSwitchToMasterConnection() - { - $profile = ServerProfile::get('dev'); - $cmdEval = $profile->createCommand('eval', array("return redis.call('info')")); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('executeCommand')->with($cmdEval); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->never())->method('executeCommand'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->executeCommand($cmdEval); - } - - /** - * @group disconnected - */ - public function testSortTriggersSwitchToMasterConnectionOnStoreModifier() - { - $profile = ServerProfile::get('dev'); - $cmdSortNormal = $profile->createCommand('sort', array('key')); - $cmdSortStore = $profile->createCommand('sort', array('key', array('store' => 'key:store'))); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('executeCommand')->with($cmdSortStore); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->once())->method('executeCommand')->with($cmdSortNormal); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->executeCommand($cmdSortNormal); - $replication->executeCommand($cmdSortStore); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The command INFO is not allowed in replication mode - */ - public function testThrowsExceptionOnNonSupportedCommand() - { - $cmd = ServerProfile::getDefault()->createCommand('info'); - - $replication = new MasterSlaveReplication(); - $replication->add($this->getMockConnection('tcp://host1?alias=master')); - $replication->add($this->getMockConnection('tcp://host2?alias=slave1')); - - $replication->getConnection($cmd); - } - - /** - * @group disconnected - */ - public function testCanOverrideReadOnlyFlagForCommands() - { - $profile = ServerProfile::getDefault(); - $cmdSet = $profile->createCommand('set', array('foo', 'bar')); - $cmdGet = $profile->createCommand('get', array('foo')); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('executeCommand')->with($cmdGet); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->once())->method('executeCommand')->with($cmdSet); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->getReplicationStrategy()->setCommandReadOnly($cmdSet->getId(), true); - $replication->getReplicationStrategy()->setCommandReadOnly($cmdGet->getId(), false); - - $replication->executeCommand($cmdSet); - $replication->executeCommand($cmdGet); - } - - /** - * @group disconnected - */ - public function testAcceptsCallableToOverrideReadOnlyFlagForCommands() - { - $profile = ServerProfile::getDefault(); - $cmdExistsFoo = $profile->createCommand('exists', array('foo')); - $cmdExistsBar = $profile->createCommand('exists', array('bar')); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->once())->method('executeCommand')->with($cmdExistsBar); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->once())->method('executeCommand')->with($cmdExistsFoo); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->getReplicationStrategy()->setCommandReadOnly('exists', function ($cmd) { - list($arg1) = $cmd->getArguments(); - - return $arg1 === 'foo'; - }); - - $replication->executeCommand($cmdExistsFoo); - $replication->executeCommand($cmdExistsBar); - } - - /** - * @group disconnected - */ - public function testCanSetReadOnlyFlagForEvalScripts() - { - $profile = ServerProfile::get('dev'); - - $cmdEval = $profile->createCommand('eval', array($script = "return redis.call('info');")); - $cmdEvalSha = $profile->createCommand('evalsha', array($scriptSHA1 = sha1($script))); - - $master = $this->getMockConnection('tcp://host1?alias=master'); - $master->expects($this->never())->method('executeCommand'); - - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - $slave1->expects($this->exactly(2)) - ->method('executeCommand') - ->with($this->logicalOr($cmdEval, $cmdEvalSha)); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $replication->getReplicationStrategy()->setScriptReadOnly($script); - - $replication->executeCommand($cmdEval); - $replication->executeCommand($cmdEvalSha); - } - - /** - * @group disconnected - */ - public function testExposesReplicationStrategy() - { - $replication = new MasterSlaveReplication(); - $this->assertInstanceOf('Predis\Replication\ReplicationStrategy', $replication->getReplicationStrategy()); - - $strategy = new ReplicationStrategy(); - $replication = new MasterSlaveReplication($strategy); - $this->assertSame($strategy, $replication->getReplicationStrategy()); - } - - /** - * @group disconnected - */ - public function testCanBeSerialized() - { - $master = $this->getMockConnection('tcp://host1?alias=master'); - $slave1 = $this->getMockConnection('tcp://host2?alias=slave1'); - - $replication = new MasterSlaveReplication(); - $replication->add($master); - $replication->add($slave1); - - $unserialized = unserialize(serialize($replication)); - - $this->assertEquals($master, $unserialized->getConnectionById('master')); - $this->assertEquals($slave1, $unserialized->getConnectionById('slave1')); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. - * - * @param mixed $parameters Optional parameters. - * @return mixed - */ - protected function getMockConnection($parameters = null) - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - if ($parameters) { - $parameters = new ConnectionParameters($parameters); - $hash = "{$parameters->host}:{$parameters->port}"; - - $connection->expects($this->any()) - ->method('getParameters') - ->will($this->returnValue($parameters)); - $connection->expects($this->any()) - ->method('__toString') - ->will($this->returnValue($hash)); - } - - return $connection; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/PhpiredisConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/PhpiredisConnectionTest.php deleted file mode 100644 index 0044814e6..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/PhpiredisConnectionTest.php +++ /dev/null @@ -1,138 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -/** - * @group ext-phpiredis - */ -class PhpiredisConnectionTest extends PredisConnectionTestCase -{ - /** - * @group disconnected - */ - public function testConstructorDoesNotOpenConnection() - { - $connection = new PhpiredisConnection($this->getParameters()); - - $this->assertFalse($connection->isConnected()); - } - - /** - * @group disconnected - */ - public function testExposesParameters() - { - $parameters = $this->getParameters(); - $connection = new PhpiredisConnection($parameters); - - $this->assertSame($parameters, $connection->getParameters()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid scheme: udp - */ - public function testThrowsExceptionOnInvalidScheme() - { - $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new PhpiredisConnection($parameters); - } - - /** - * @group disconnected - */ - public function testCanBeSerialized() - { - $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); - $connection = new PhpiredisConnection($parameters); - - $unserialized = unserialize(serialize($connection)); - - $this->assertInstanceOf('Predis\Connection\PhpiredisConnection', $unserialized); - $this->assertEquals($parameters, $unserialized->getParameters()); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testExecutesCommandsOnServer() - { - $connection = $this->getConnection($profile, true); - - $cmdPing = $profile->createCommand('ping'); - $cmdEcho = $profile->createCommand('echo', array('echoed')); - $cmdGet = $profile->createCommand('get', array('foobar')); - $cmdRpush = $profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')); - $cmdLrange = $profile->createCommand('lrange', array('metavars', 0, -1)); - - $this->assertSame('PONG', $connection->executeCommand($cmdPing)); - $this->assertSame('echoed', $connection->executeCommand($cmdEcho)); - $this->assertNull($connection->executeCommand($cmdGet)); - $this->assertSame(3, $connection->executeCommand($cmdRpush)); - $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange)); - } - - /** - * @group connected - * @expectedException Predis\Connection\ConnectionException - * @expectedExceptionMessage Cannot resolve the address of 'bogus.tld'. - */ - public function testThrowsExceptionOnUnresolvableHostname() - { - $parameters = $this->getParameters(array('host' => 'bogus.tld')); - $connection = new PhpiredisConnection($parameters); - $connection->connect(); - } - - /** - * @group connected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Protocol error, got "P" as reply type byte - */ - public function testThrowsExceptionOnProtocolDesynchronizationErrors() - { - $connection = $this->getConnection($profile); - $socket = $connection->getResource(); - - $connection->writeCommand($profile->createCommand('ping')); - socket_read($socket, 1); - - $connection->read(); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * {@inheritdoc} - */ - protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()) - { - $parameters = $this->getParameters($parameters); - $profile = $this->getProfile(); - - $connection = new PhpiredisConnection($parameters); - - if ($initialize) { - $connection->pushInitCommand($profile->createCommand('select', array($parameters->database))); - $connection->pushInitCommand($profile->createCommand('flushdb')); - } - - return $connection; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/PhpiredisStreamConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/PhpiredisStreamConnectionTest.php deleted file mode 100644 index 7126f2a43..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/PhpiredisStreamConnectionTest.php +++ /dev/null @@ -1,145 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -/** - * @group ext-phpiredis - */ -class PhpiredisStreamConnectionTest extends PredisConnectionTestCase -{ - /** - * @group disconnected - */ - public function testConstructorDoesNotOpenConnection() - { - $connection = new PhpiredisStreamConnection($this->getParameters()); - - $this->assertFalse($connection->isConnected()); - } - - /** - * @group disconnected - */ - public function testExposesParameters() - { - $parameters = $this->getParameters(); - $connection = new PhpiredisStreamConnection($parameters); - - $this->assertSame($parameters, $connection->getParameters()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid scheme: udp - */ - public function testThrowsExceptionOnInvalidScheme() - { - $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new PhpiredisStreamConnection($parameters); - } - - /** - * @group disconnected - */ - public function testCanBeSerialized() - { - $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); - $connection = new PhpiredisStreamConnection($parameters); - - $unserialized = unserialize(serialize($connection)); - - $this->assertInstanceOf('Predis\Connection\PhpiredisStreamConnection', $unserialized); - $this->assertEquals($parameters, $unserialized->getParameters()); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testAcceptsTcpNodelayParameter() - { - if (!version_compare(PHP_VERSION, '5.4.0', '>=')) { - $this->markTestSkipped('Setting TCP_NODELAY on PHP socket streams works on PHP >= 5.4.0'); - } - - $connection = new PhpiredisStreamConnection($this->getParameters(array('tcp_nodelay' => false))); - $connection->connect(); - $this->assertTrue($connection->isConnected()); - - $connection = new PhpiredisStreamConnection($this->getParameters(array('tcp_nodelay' => true))); - $connection->connect(); - $this->assertTrue($connection->isConnected()); - } - - /** - * @group connected - */ - public function testExecutesCommandsOnServer() - { - $connection = $this->getConnection($profile, true); - - $cmdPing = $profile->createCommand('ping'); - $cmdEcho = $profile->createCommand('echo', array('echoed')); - $cmdGet = $profile->createCommand('get', array('foobar')); - $cmdRpush = $profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')); - $cmdLrange = $profile->createCommand('lrange', array('metavars', 0, -1)); - - $this->assertSame('PONG', $connection->executeCommand($cmdPing)); - $this->assertSame('echoed', $connection->executeCommand($cmdEcho)); - $this->assertNull($connection->executeCommand($cmdGet)); - $this->assertSame(3, $connection->executeCommand($cmdRpush)); - $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange)); - } - - /** - * @medium - * @group connected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Protocol error, got "P" as reply type byte - */ - public function testThrowsExceptionOnProtocolDesynchronizationErrors() - { - $connection = $this->getConnection($profile); - $socket = $connection->getResource(); - - $connection->writeCommand($profile->createCommand('ping')); - fread($socket, 1); - - $connection->read(); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * {@inheritdoc} - */ - protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()) - { - $parameters = $this->getParameters($parameters); - $profile = $this->getProfile(); - - $connection = new PhpiredisStreamConnection($parameters); - - if ($initialize) { - $connection->pushInitCommand($profile->createCommand('select', array($parameters->database))); - $connection->pushInitCommand($profile->createCommand('flushdb')); - } - - return $connection; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/PredisClusterTest.php b/vendor/predis/predis/tests/Predis/Connection/PredisClusterTest.php deleted file mode 100644 index 76a7e42d9..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/PredisClusterTest.php +++ /dev/null @@ -1,404 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use PredisTestCase; -use Predis\Profile\ServerProfile; - -/** - * - */ -class PredisClusterTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExposesCommandHashStrategy() - { - $cluster = new PredisCluster(); - $this->assertInstanceOf('Predis\Cluster\PredisClusterHashStrategy', $cluster->getCommandHashStrategy()); - } - - /** - * @group disconnected - */ - public function testAddingConnectionsToCluster() - { - $connection1 = $this->getMockConnection(); - $connection2 = $this->getMockConnection(); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame(2, count($cluster)); - $this->assertSame($connection1, $cluster->getConnectionById(0)); - $this->assertSame($connection2, $cluster->getConnectionById(1)); - } - - /** - * @group disconnected - */ - public function testAddingConnectionsToClusterUsesConnectionAlias() - { - $connection1 = $this->getMockConnection('tcp://host1:7001?alias=node1'); - $connection2 = $this->getMockConnection('tcp://host1:7002?alias=node2'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame(2, count($cluster)); - $this->assertSame($connection1, $cluster->getConnectionById('node1')); - $this->assertSame($connection2, $cluster->getConnectionById('node2')); - } - - /** - * @group disconnected - */ - public function testRemovingConnectionsFromCluster() - { - $connection1 = $this->getMockConnection(); - $connection2 = $this->getMockConnection(); - $connection3 = $this->getMockConnection(); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertTrue($cluster->remove($connection1)); - $this->assertFalse($cluster->remove($connection3)); - $this->assertSame(1, count($cluster)); - } - - /** - * @group disconnected - */ - public function testRemovingConnectionsFromClusterByAlias() - { - $connection1 = $this->getMockConnection(); - $connection2 = $this->getMockConnection('tcp://host1:7001?alias=node2'); - $connection3 = $this->getMockConnection('tcp://host1:7002?alias=node3'); - $connection4 = $this->getMockConnection('tcp://host1:7003?alias=node4'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - $cluster->add($connection3); - - $this->assertTrue($cluster->removeById(0)); - $this->assertTrue($cluster->removeById('node2')); - $this->assertFalse($cluster->removeById('node4')); - $this->assertSame(1, count($cluster)); - } - - /** - * @group disconnected - */ - public function testConnectForcesAllConnectionsToConnect() - { - $connection1 = $this->getMockConnection(); - $connection1->expects($this->once())->method('connect'); - - $connection2 = $this->getMockConnection(); - $connection2->expects($this->once())->method('connect'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->connect(); - } - - /** - * @group disconnected - */ - public function testDisconnectForcesAllConnectionsToDisconnect() - { - $connection1 = $this->getMockConnection(); - $connection1->expects($this->once())->method('disconnect'); - - $connection2 = $this->getMockConnection(); - $connection2->expects($this->once())->method('disconnect'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->disconnect(); - } - - /** - * @group disconnected - */ - public function testIsConnectedReturnsTrueIfAtLeastOneConnectionIsOpen() - { - $connection1 = $this->getMockConnection(); - $connection1->expects($this->once()) - ->method('isConnected') - ->will($this->returnValue(false)); - - $connection2 = $this->getMockConnection(); - $connection2->expects($this->once()) - ->method('isConnected') - ->will($this->returnValue(true)); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertTrue($cluster->isConnected()); - } - - /** - * @group disconnected - */ - public function testIsConnectedReturnsFalseIfAllConnectionsAreClosed() - { - $connection1 = $this->getMockConnection(); - $connection1->expects($this->once()) - ->method('isConnected') - ->will($this->returnValue(false)); - - $connection2 = $this->getMockConnection(); - $connection2->expects($this->once()) - ->method('isConnected') - ->will($this->returnValue(false)); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertFalse($cluster->isConnected()); - } - - /** - * @group disconnected - */ - public function testCanReturnAnIteratorForConnections() - { - $connection1 = $this->getMockConnection(); - $connection2 = $this->getMockConnection(); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertInstanceOf('Iterator', $iterator = $cluster->getIterator()); - $connections = iterator_to_array($iterator); - - $this->assertSame($connection1, $connections[0]); - $this->assertSame($connection2, $connections[1]); - } - - /** - * @group disconnected - */ - public function testReturnsCorrectConnectionUsingKey() - { - $connection1 = $this->getMockConnection('tcp://host1:7001'); - $connection2 = $this->getMockConnection('tcp://host1:7002'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame($connection1, $cluster->getConnectionByKey('node01:5431')); - $this->assertSame($connection2, $cluster->getConnectionByKey('node02:3212')); - $this->assertSame($connection1, $cluster->getConnectionByKey('prefix:{node01:5431}')); - $this->assertSame($connection2, $cluster->getConnectionByKey('prefix:{node02:3212}')); - } - - /** - * @group disconnected - */ - public function testReturnsCorrectConnectionUsingCommandInstance() - { - $profile = ServerProfile::getDefault(); - - $connection1 = $this->getMockConnection('tcp://host1:7001'); - $connection2 = $this->getMockConnection('tcp://host1:7002'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $set = $profile->createCommand('set', array('node01:5431', 'foobar')); - $get = $profile->createCommand('get', array('node01:5431')); - $this->assertSame($connection1, $cluster->getConnection($set)); - $this->assertSame($connection1, $cluster->getConnection($get)); - - $set = $profile->createCommand('set', array('prefix:{node01:5431}', 'foobar')); - $get = $profile->createCommand('get', array('prefix:{node01:5431}')); - $this->assertSame($connection1, $cluster->getConnection($set)); - $this->assertSame($connection1, $cluster->getConnection($get)); - - $set = $profile->createCommand('set', array('node02:3212', 'foobar')); - $get = $profile->createCommand('get', array('node02:3212')); - $this->assertSame($connection2, $cluster->getConnection($set)); - $this->assertSame($connection2, $cluster->getConnection($get)); - - $set = $profile->createCommand('set', array('prefix:{node02:3212}', 'foobar')); - $get = $profile->createCommand('get', array('prefix:{node02:3212}')); - $this->assertSame($connection2, $cluster->getConnection($set)); - $this->assertSame($connection2, $cluster->getConnection($get)); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage Cannot use PING with a cluster of connections - */ - public function testThrowsExceptionOnNonShardableCommand() - { - $ping = ServerProfile::getDefault()->createCommand('ping'); - - $cluster = new PredisCluster(); - $cluster->add($this->getMockConnection()); - - $cluster->getConnection($ping); - } - - /** - * @group disconnected - */ - public function testWritesCommandToCorrectConnection() - { - $command = ServerProfile::getDefault()->createCommand('get', array('node01:5431')); - - $connection1 = $this->getMockConnection('tcp://host1:7001'); - $connection1->expects($this->once())->method('writeCommand')->with($command); - - $connection2 = $this->getMockConnection('tcp://host1:7002'); - $connection2->expects($this->never())->method('writeCommand'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->writeCommand($command); - } - - /** - * @group disconnected - */ - public function testReadsCommandFromCorrectConnection() - { - $command = ServerProfile::getDefault()->createCommand('get', array('node02:3212')); - - $connection1 = $this->getMockConnection('tcp://host1:7001'); - $connection1->expects($this->never())->method('readResponse'); - - $connection2 = $this->getMockConnection('tcp://host1:7002'); - $connection2->expects($this->once())->method('readResponse')->with($command); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->readResponse($command); - } - - /** - * @group disconnected - */ - public function testExecutesCommandOnCorrectConnection() - { - $command = ServerProfile::getDefault()->createCommand('get', array('node01:5431')); - - $connection1 = $this->getMockConnection('tcp://host1:7001'); - $connection1->expects($this->once())->method('executeCommand')->with($command); - - $connection2 = $this->getMockConnection('tcp://host1:7002'); - $connection2->expects($this->never())->method('executeCommand'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->executeCommand($command); - } - - /** - * @group disconnected - */ - public function testExecuteCommandOnEachNode() - { - $ping = ServerProfile::getDefault()->createCommand('ping', array()); - - $connection1 = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection1->expects($this->once()) - ->method('executeCommand') - ->with($ping) - ->will($this->returnValue(true)); - - $connection2 = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection2->expects($this->once()) - ->method('executeCommand') - ->with($ping) - ->will($this->returnValue(false)); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame(array(true, false), $cluster->executeCommandOnNodes($ping)); - } - - /** - * @group disconnected - */ - public function testCanBeSerialized() - { - $connection1 = $this->getMockConnection('tcp://host1?alias=first'); - $connection2 = $this->getMockConnection('tcp://host2?alias=second'); - - $cluster = new PredisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - // We use the following line to initialize the underlying hashring. - $cluster->getConnectionByKey('foo'); - $unserialized = unserialize(serialize($cluster)); - - $this->assertEquals($cluster, $unserialized); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. - * - * @param mixed $parameters Optional parameters. - * @return mixed - */ - protected function getMockConnection($parameters = null) - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - if ($parameters) { - $parameters = new ConnectionParameters($parameters); - $hash = "{$parameters->host}:{$parameters->port}"; - - $connection->expects($this->any()) - ->method('getParameters') - ->will($this->returnValue($parameters)); - $connection->expects($this->any()) - ->method('__toString') - ->will($this->returnValue($hash)); - } - - return $connection; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/RedisClusterTest.php b/vendor/predis/predis/tests/Predis/Connection/RedisClusterTest.php deleted file mode 100644 index 77dee6715..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/RedisClusterTest.php +++ /dev/null @@ -1,667 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use PredisTestCase; -use Predis\ResponseError; -use Predis\Profile\ServerProfile; - -/** - * - */ -class RedisClusterTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExposesCommandHashStrategy() - { - $cluster = new RedisCluster(); - $this->assertInstanceOf('Predis\Cluster\RedisClusterHashStrategy', $cluster->getCommandHashStrategy()); - } - - /** - * @group disconnected - */ - public function testAddingConnectionsToCluster() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame(2, count($cluster)); - $this->assertSame($connection1, $cluster->getConnectionById('127.0.0.1:6379')); - $this->assertSame($connection2, $cluster->getConnectionById('127.0.0.1:6380')); - } - - /** - * @group disconnected - */ - public function testRemovingConnectionsFromCluster() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6371'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertTrue($cluster->remove($connection1)); - $this->assertFalse($cluster->remove($connection3)); - $this->assertSame(1, count($cluster)); - } - - /** - * @group disconnected - */ - public function testRemovingConnectionsFromClusterByAlias() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertTrue($cluster->removeById('127.0.0.1:6380')); - $this->assertFalse($cluster->removeById('127.0.0.1:6390')); - $this->assertSame(1, count($cluster)); - } - - /** - * @group disconnected - */ - public function testCountReturnsNumberOfConnectionsInPool() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - $cluster->add($connection3); - - $this->assertSame(3, count($cluster)); - - $cluster->remove($connection3); - - $this->assertSame(2, count($cluster)); - } - - /** - * @group disconnected - */ - public function testConnectPicksRandomConnection() - { - $connect1 = false; - $connect2 = false; - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->any()) - ->method('connect') - ->will($this->returnCallback(function () use (&$connect1) { - $connect1 = true; - })); - $connection1->expects($this->any()) - ->method('isConnected') - ->will($this->returnCallback(function () use (&$connect1) { - return $connect1; - })); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->any()) - ->method('connect') - ->will($this->returnCallback(function () use (&$connect2) { - $connect2 = true; - })); - $connection2->expects($this->any()) - ->method('isConnected') - ->will($this->returnCallback(function () use (&$connect2) { - return $connect2; - })); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->connect(); - - $this->assertTrue($cluster->isConnected()); - - if ($connect1) { - $this->assertTrue($connect1); - $this->assertFalse($connect2); - } else { - $this->assertFalse($connect1); - $this->assertTrue($connect2); - } - } - - /** - * @group disconnected - */ - public function testDisconnectForcesAllConnectionsToDisconnect() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->once())->method('disconnect'); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->once())->method('disconnect'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->disconnect(); - } - - /** - * @group disconnected - */ - public function testIsConnectedReturnsTrueIfAtLeastOneConnectionIsOpen() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->once()) - ->method('isConnected') - ->will($this->returnValue(false)); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->once()) - ->method('isConnected') - ->will($this->returnValue(true)); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertTrue($cluster->isConnected()); - } - - /** - * @group disconnected - */ - public function testIsConnectedReturnsFalseIfAllConnectionsAreClosed() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->once()) - ->method('isConnected') - ->will($this->returnValue(false)); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->once()) - ->method('isConnected') - ->will($this->returnValue(false)); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertFalse($cluster->isConnected()); - } - - /** - * @group disconnected - */ - public function testCanReturnAnIteratorForConnections() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertInstanceOf('Iterator', $iterator = $cluster->getIterator()); - $connections = iterator_to_array($iterator); - - $this->assertSame($connection1, $connections[0]); - $this->assertSame($connection2, $connections[1]); - } - - /** - * @group disconnected - */ - public function testCanAssignConnectionsToCustomSlots() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - $cluster->add($connection3); - - $cluster->setSlots(0, 1364, '127.0.0.1:6379'); - $cluster->setSlots(1365, 2729, '127.0.0.1:6380'); - $cluster->setSlots(2730, 4095, '127.0.0.1:6381'); - - $expectedMap = array_merge( - array_fill(0, 1365, '127.0.0.1:6379'), - array_fill(1364, 1365, '127.0.0.1:6380'), - array_fill(2729, 1366, '127.0.0.1:6381') - ); - - $this->assertSame($expectedMap, $cluster->getSlotsMap()); - } - - /** - * @group disconnected - */ - public function testAddingConnectionResetsSlotsMap() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - - $cluster->setSlots(0, 4095, '127.0.0.1:6379'); - $this->assertSame(array_fill(0, 4096, '127.0.0.1:6379'), $cluster->getSlotsMap()); - - $cluster->add($connection2); - - $this->assertEmpty($cluster->getSlotsMap()); - } - - /** - * @group disconnected - */ - public function testRemovingConnectionResetsSlotsMap() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->setSlots(0, 2047, '127.0.0.1:6379'); - $cluster->setSlots(2048, 4095, '127.0.0.1:6380'); - - $expectedMap = array_merge( - array_fill(0, 2048, '127.0.0.1:6379'), - array_fill(2048, 2048, '127.0.0.1:6380') - ); - - $this->assertSame($expectedMap, $cluster->getSlotsMap()); - - $cluster->remove($connection1); - $this->assertEmpty($cluster->getSlotsMap()); - } - - /** - * @group disconnected - */ - public function testCanAssignConnectionsToCustomSlotsFromParameters() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-5460'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=5461-10921'); - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=10922-16383'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - $cluster->add($connection3); - - $expectedMap = array_merge( - array_fill(0, 5461, '127.0.0.1:6379'), - array_fill(5460, 5461, '127.0.0.1:6380'), - array_fill(10921, 5462, '127.0.0.1:6381') - ); - - $cluster->buildSlotsMap(); - - $this->assertSame($expectedMap, $cluster->getSlotsMap()); - } - - /** - * @group disconnected - */ - public function testReturnsCorrectConnectionUsingSlotID() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - $cluster->add($connection3); - - $this->assertSame($connection1, $cluster->getConnectionBySlot(0)); - $this->assertSame($connection2, $cluster->getConnectionBySlot(5461)); - $this->assertSame($connection3, $cluster->getConnectionBySlot(10922)); - - $cluster->setSlots(5461, 7096, '127.0.0.1:6380'); - $this->assertSame($connection2, $cluster->getConnectionBySlot(5461)); - } - - /** - * @group disconnected - */ - public function testReturnsCorrectConnectionUsingCommandInstance() - { - $profile = ServerProfile::getDefault(); - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - $cluster->add($connection3); - - $set = $profile->createCommand('set', array('node:1001', 'foobar')); - $get = $profile->createCommand('get', array('node:1001')); - $this->assertSame($connection1, $cluster->getConnection($set)); - $this->assertSame($connection1, $cluster->getConnection($get)); - - $set = $profile->createCommand('set', array('node:1048', 'foobar')); - $get = $profile->createCommand('get', array('node:1048')); - $this->assertSame($connection2, $cluster->getConnection($set)); - $this->assertSame($connection2, $cluster->getConnection($get)); - - $set = $profile->createCommand('set', array('node:1082', 'foobar')); - $get = $profile->createCommand('get', array('node:1082')); - $this->assertSame($connection3, $cluster->getConnection($set)); - $this->assertSame($connection3, $cluster->getConnection($get)); - } - - /** - * @group disconnected - */ - public function testWritesCommandToCorrectConnection() - { - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->once())->method('writeCommand')->with($command); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->never())->method('writeCommand'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->writeCommand($command); - } - - /** - * @group disconnected - */ - public function testReadsCommandFromCorrectConnection() - { - $command = ServerProfile::getDefault()->createCommand('get', array('node:1050')); - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->never())->method('readResponse'); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->once())->method('readResponse')->with($command); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $cluster->readResponse($command); - } - - /** - * @group disconnected - */ - public function testDoesNotSupportKeyTags() - { - $profile = ServerProfile::getDefault(); - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - - $set = $profile->createCommand('set', array('{node:1001}:foo', 'foobar')); - $get = $profile->createCommand('get', array('{node:1001}:foo')); - $this->assertSame($connection1, $cluster->getConnection($set)); - $this->assertSame($connection1, $cluster->getConnection($get)); - - $set = $profile->createCommand('set', array('{node:1001}:bar', 'foobar')); - $get = $profile->createCommand('get', array('{node:1001}:bar')); - $this->assertSame($connection2, $cluster->getConnection($set)); - $this->assertSame($connection2, $cluster->getConnection($get)); - } - - /** - * @group disconnected - */ - public function testAskResponseWithConnectionInPool() - { - $askResponse = new ResponseError('ASK 1970 127.0.0.1:6380'); - - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->exactly(2)) - ->method('executeCommand') - ->with($command) - ->will($this->onConsecutiveCalls($askResponse, 'foobar')); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->at(2)) - ->method('executeCommand') - ->with($this->isRedisCommand('ASKING')); - $connection2->expects($this->at(3)) - ->method('executeCommand') - ->with($command) - ->will($this->returnValue('foobar')); - - $factory = $this->getMock('Predis\Connection\ConnectionFactory'); - $factory->expects($this->never())->method('create'); - - $cluster = new RedisCluster($factory); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame('foobar', $cluster->executeCommand($command)); - $this->assertSame('foobar', $cluster->executeCommand($command)); - $this->assertSame(2, count($cluster)); - } - - /** - * @group disconnected - */ - public function testAskResponseWithConnectionNotInPool() - { - $askResponse = new ResponseError('ASK 1970 127.0.0.1:6381'); - - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->exactly(2)) - ->method('executeCommand') - ->with($command) - ->will($this->onConsecutiveCalls($askResponse, 'foobar')); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->never()) - ->method('executeCommand'); - - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); - $connection3->expects($this->at(0)) - ->method('executeCommand') - ->with($this->isRedisCommand('ASKING')); - $connection3->expects($this->at(1)) - ->method('executeCommand') - ->with($command) - ->will($this->returnValue('foobar')); - - $factory = $this->getMock('Predis\Connection\ConnectionFactory'); - $factory->expects($this->once()) - ->method('create') - ->with(array('host' => '127.0.0.1', 'port' => '6381')) - ->will($this->returnValue($connection3)); - - $cluster = new RedisCluster($factory); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame('foobar', $cluster->executeCommand($command)); - $this->assertSame('foobar', $cluster->executeCommand($command)); - $this->assertSame(2, count($cluster)); - } - - /** - * @group disconnected - */ - public function testMovedResponseWithConnectionInPool() - { - $movedResponse = new ResponseError('MOVED 1970 127.0.0.1:6380'); - - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->exactly(1)) - ->method('executeCommand') - ->with($command) - ->will($this->returnValue($movedResponse)); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->exactly(2)) - ->method('executeCommand') - ->with($command) - ->will($this->onConsecutiveCalls('foobar', 'foobar')); - - $factory = $this->getMock('Predis\Connection\ConnectionFactory'); - $factory->expects($this->never())->method('create'); - - $cluster = new RedisCluster($factory); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame('foobar', $cluster->executeCommand($command)); - $this->assertSame('foobar', $cluster->executeCommand($command)); - $this->assertSame(2, count($cluster)); - } - - /** - * @group disconnected - */ - public function testMovedResponseWithConnectionNotInPool() - { - $movedResponse = new ResponseError('MOVED 1970 127.0.0.1:6381'); - - $command = ServerProfile::getDefault()->createCommand('get', array('node:1001')); - - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379'); - $connection1->expects($this->once()) - ->method('executeCommand') - ->with($command) - ->will($this->returnValue($movedResponse)); - - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380'); - $connection2->expects($this->never()) - ->method('executeCommand'); - - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381'); - $connection3->expects($this->exactly(2)) - ->method('executeCommand') - ->with($command) - ->will($this->onConsecutiveCalls('foobar', 'foobar')); - - $factory = $this->getMock('Predis\Connection\ConnectionFactory'); - $factory->expects($this->once()) - ->method('create') - ->with(array('host' => '127.0.0.1', 'port' => '6381')) - ->will($this->returnValue($connection3)); - - $cluster = new RedisCluster($factory); - $cluster->add($connection1); - $cluster->add($connection2); - - $this->assertSame('foobar', $cluster->executeCommand($command)); - $this->assertSame('foobar', $cluster->executeCommand($command)); - $this->assertSame(3, count($cluster)); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage Cannot use PING with redis-cluster - */ - public function testThrowsExceptionOnNonSupportedCommand() - { - $ping = ServerProfile::getDefault()->createCommand('ping'); - - $cluster = new RedisCluster(); - $cluster->add($this->getMockConnection('tcp://127.0.0.1:6379')); - - $cluster->getConnection($ping); - } - - /** - * @group disconnected - */ - public function testCanBeSerialized() - { - $connection1 = $this->getMockConnection('tcp://127.0.0.1:6379?slots=0-1364'); - $connection2 = $this->getMockConnection('tcp://127.0.0.1:6380?slots=1365-2729'); - $connection3 = $this->getMockConnection('tcp://127.0.0.1:6381?slots=2730-4095'); - - $cluster = new RedisCluster(); - $cluster->add($connection1); - $cluster->add($connection2); - $cluster->add($connection3); - - $cluster->buildSlotsMap(); - - $unserialized = unserialize(serialize($cluster)); - - $this->assertEquals($cluster, $unserialized); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a base mocked connection from Predis\Connection\SingleConnectionInterface. - * - * @param mixed $parameters Optional parameters. - * @return mixed - */ - protected function getMockConnection($parameters = null) - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - if ($parameters) { - $parameters = new ConnectionParameters($parameters); - $hash = "{$parameters->host}:{$parameters->port}"; - - $connection->expects($this->any()) - ->method('getParameters') - ->will($this->returnValue($parameters)); - $connection->expects($this->any()) - ->method('__toString') - ->will($this->returnValue($hash)); - } - - return $connection; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/StreamConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/StreamConnectionTest.php deleted file mode 100644 index f4ff2f6f7..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/StreamConnectionTest.php +++ /dev/null @@ -1,137 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -/** - * - */ -class StreamConnectionTest extends PredisConnectionTestCase -{ - /** - * @group disconnected - */ - public function testConstructorDoesNotOpenConnection() - { - $connection = new StreamConnection($this->getParameters()); - - $this->assertFalse($connection->isConnected()); - } - - /** - * @group disconnected - */ - public function testExposesParameters() - { - $parameters = $this->getParameters(); - $connection = new StreamConnection($parameters); - - $this->assertSame($parameters, $connection->getParameters()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid scheme: udp - */ - public function testThrowsExceptionOnInvalidScheme() - { - $parameters = $this->getParameters(array('scheme' => 'udp')); - $connection = new StreamConnection($parameters); - } - - /** - * @group disconnected - */ - public function testCanBeSerialized() - { - $parameters = $this->getParameters(array('alias' => 'redis', 'read_write_timeout' => 10)); - $connection = new StreamConnection($parameters); - - $unserialized = unserialize(serialize($connection)); - - $this->assertEquals($connection, $unserialized); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testAcceptsTcpNodelayParameter() - { - if (!version_compare(PHP_VERSION, '5.4.0', '>=')) { - $this->markTestSkipped('Setting TCP_NODELAY on PHP socket streams works on PHP >= 5.4.0'); - } - - $connection = new StreamConnection($this->getParameters(array('tcp_nodelay' => false))); - $connection->connect(); - $this->assertTrue($connection->isConnected()); - - $connection = new StreamConnection($this->getParameters(array('tcp_nodelay' => true))); - $connection->connect(); - $this->assertTrue($connection->isConnected()); - } - - /** - * @group connected - */ - public function testReadsMultibulkRepliesAsIterators() - { - $connection = $this->getConnection($profile, true, array('iterable_multibulk' => true)); - - $connection->executeCommand($profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol'))); - $connection->writeCommand($profile->createCommand('lrange', array('metavars', 0, -1))); - - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponse', $iterator = $connection->read()); - $this->assertSame(array('foo', 'hoge', 'lol'), iterator_to_array($iterator)); - } - - /** - * @group connected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Unknown prefix: 'P' - */ - public function testThrowsExceptionOnProtocolDesynchronizationErrors() - { - $connection = $this->getConnection($profile); - $stream = $connection->getResource(); - - $connection->writeCommand($profile->createCommand('ping')); - fread($stream, 1); - - $connection->read(); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * {@inheritdoc} - */ - protected function getConnection(&$profile = null, $initialize = false, Array $parameters = array()) - { - $parameters = $this->getParameters($parameters); - $profile = $this->getProfile(); - - $connection = new StreamConnection($parameters); - - if ($initialize) { - $connection->pushInitCommand($profile->createCommand('select', array($parameters->database))); - $connection->pushInitCommand($profile->createCommand('flushdb')); - } - - return $connection; - } -} diff --git a/vendor/predis/predis/tests/Predis/Connection/WebdisConnectionTest.php b/vendor/predis/predis/tests/Predis/Connection/WebdisConnectionTest.php deleted file mode 100644 index 6eaea14ed..000000000 --- a/vendor/predis/predis/tests/Predis/Connection/WebdisConnectionTest.php +++ /dev/null @@ -1,186 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Connection; - -use PredisTestCase; - -/** - * @group ext-curl - * @group ext-phpiredis - * @group realm-connection - * @group realm-webdis - */ -class WebdisConnectionTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testIsConnectedAlwaysReturnsTrue() - { - $connection = new WebdisConnection($this->getParameters()); - - $this->assertTrue($connection->isConnected()); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The method Predis\Connection\WebdisConnection::writeCommand() is not supported - */ - public function testWritingCommandsIsNotSupported() - { - $connection = new WebdisConnection($this->getParameters()); - $connection->writeCommand($this->getProfile()->createCommand('ping')); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The method Predis\Connection\WebdisConnection::readResponse() is not supported - */ - public function testReadingResponsesIsNotSupported() - { - $connection = new WebdisConnection($this->getParameters()); - $connection->readResponse($this->getProfile()->createCommand('ping')); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The method Predis\Connection\WebdisConnection::read() is not supported - */ - public function testReadingFromConnectionIsNotSupported() - { - $connection = new WebdisConnection($this->getParameters()); - $connection->read(); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The method Predis\Connection\WebdisConnection::pushInitCommand() is not supported - */ - public function testPushingInitCommandsIsNotSupported() - { - $connection = new WebdisConnection($this->getParameters()); - $connection->pushInitCommand($this->getProfile()->createCommand('ping')); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage Disabled command: SELECT - */ - public function testRejectCommandSelect() - { - $connection = new WebdisConnection($this->getParameters()); - $connection->executeCommand($this->getProfile()->createCommand('select', array(0))); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage Disabled command: AUTH - */ - public function testRejectCommandAuth() - { - $connection = new WebdisConnection($this->getParameters()); - $connection->executeCommand($this->getProfile()->createCommand('auth', array('foobar'))); - } - - /** - * @group disconnected - */ - public function testCanBeSerialized() - { - $parameters = $this->getParameters(array('alias' => 'webdis')); - $connection = new WebdisConnection($parameters); - - $unserialized = unserialize(serialize($connection)); - - $this->assertInstanceOf('Predis\Connection\WebdisConnection', $unserialized); - $this->assertEquals($parameters, $unserialized->getParameters()); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testExecutesCommandsOnServer() - { - $connection = $this->getConnection($profile); - - $cmdPing = $profile->createCommand('ping'); - $cmdEcho = $profile->createCommand('echo', array('echoed')); - $cmdGet = $profile->createCommand('get', array('foobar')); - $cmdRpush = $profile->createCommand('rpush', array('metavars', 'foo', 'hoge', 'lol')); - $cmdLrange = $profile->createCommand('lrange', array('metavars', 0, -1)); - - $this->assertSame('PONG', $connection->executeCommand($cmdPing)); - $this->assertSame('echoed', $connection->executeCommand($cmdEcho)); - $this->assertNull($connection->executeCommand($cmdGet)); - $this->assertSame(3, $connection->executeCommand($cmdRpush)); - $this->assertSame(array('foo', 'hoge', 'lol'), $connection->executeCommand($cmdLrange)); - } - - /** - * @medium - * @group disconnected - * @group slow - * @expectedException Predis\Connection\ConnectionException - */ - public function testThrowExceptionWhenUnableToConnect() - { - $parameters = $this->getParameters(array('host' => '169.254.10.10')); - $connection = new WebdisConnection($parameters); - $connection->executeCommand($this->getProfile()->createCommand('ping')); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a named array with the default connection parameters and their values. - * - * @return Array Default connection parameters. - */ - protected function getDefaultParametersArray() - { - return array( - 'scheme' => 'http', - 'host' => WEBDIS_SERVER_HOST, - 'port' => WEBDIS_SERVER_PORT, - ); - } - - /** - * Returns a new instance of a connection instance. - * - * @param mixed $profile Redis profile. - * @param array $parameters Additional connection parameters. - * @return WebdisConnection - */ - protected function getConnection(&$profile = null, Array $parameters = array()) - { - $parameters = $this->getParameters($parameters); - $profile = $this->getProfile(); - - $connection = new WebdisConnection($parameters); - $connection->executeCommand($profile->createCommand('flushdb')); - - return $connection; - } -} diff --git a/vendor/predis/predis/tests/Predis/HelpersTest.php b/vendor/predis/predis/tests/Predis/HelpersTest.php deleted file mode 100644 index ac69b7b05..000000000 --- a/vendor/predis/predis/tests/Predis/HelpersTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use PredisTestCase; - -/** - * - */ -class HelpersTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testOnCommunicationException() - { - $this->setExpectedException('Predis\CommunicationException'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once())->method('isConnected')->will($this->returnValue(true)); - $connection->expects($this->once())->method('disconnect'); - - $exception = $this->getMockForAbstractClass('Predis\CommunicationException', array($connection)); - - Helpers::onCommunicationException($exception); - } - - /** - * @group disconnected - */ - public function testFilterArrayArguments() - { - $arguments = array('arg1', 'arg2', 'arg3', 'arg4'); - - $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); - $this->assertSame($arguments, Helpers::filterArrayArguments(array($arguments))); - - $arguments = array(array(), array()); - $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); - - $arguments = array(new \stdClass()); - $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); - } - - /** - * @group disconnected - */ - public function testFilterVariadicValues() - { - $arguments = array('key', 'value1', 'value2', 'value3'); - - $this->assertSame($arguments, Helpers::filterVariadicValues($arguments)); - $this->assertSame($arguments, Helpers::filterVariadicValues(array('key', array('value1', 'value2', 'value3')))); - - $arguments = array(array(), array()); - $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); - - $arguments = array(new \stdClass()); - $this->assertSame($arguments, Helpers::filterArrayArguments($arguments)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseSimpleTest.php b/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseSimpleTest.php deleted file mode 100644 index 5ab5faf4b..000000000 --- a/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseSimpleTest.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Iterator; - -use PredisTestCase; -use Predis\Client; - -/** - * @group realm-iterators - */ -class MultiBulkResponseSimpleTest extends PredisTestCase -{ - /** - * @group connected - */ - public function testIterableMultibulk() - { - $client = $this->getClient(); - $client->rpush('metavars', 'foo', 'hoge', 'lol'); - - $this->assertInstanceOf('Iterator', $iterator = $client->lrange('metavars', 0, -1)); - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $iterator); - $this->assertTrue($iterator->valid()); - $this->assertSame(3, $iterator->count()); - - $this->assertSame('foo', $iterator->current()); - $this->assertSame(1, $iterator->next()); - $this->assertTrue($iterator->valid()); - - $this->assertSame('hoge', $iterator->current()); - $this->assertSame(2, $iterator->next()); - $this->assertTrue($iterator->valid()); - - $this->assertSame('lol', $iterator->current()); - $this->assertSame(3, $iterator->next()); - $this->assertFalse($iterator->valid()); - - $this->assertTrue($client->ping()); - } - - /** - * @group connected - */ - public function testIterableMultibulkCanBeWrappedAsTupleIterator() - { - $client = $this->getClient(); - $client->mset('foo', 'bar', 'hoge', 'piyo'); - - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $iterator = $client->mget('foo', 'bar')); - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseTuple', $iterator->asTuple()); - } - - /** - * @group connected - */ - public function testSyncWithFalseConsumesReplyFromUnderlyingConnection() - { - $client = $this->getClient(); - $client->rpush('metavars', 'foo', 'hoge', 'lol'); - - $iterator = $client->lrange('metavars', 0, -1); - $iterator->sync(false); - - $this->assertTrue($client->isConnected()); - $this->assertTrue($client->ping()); - } - - /** - * @group connected - */ - public function testSyncWithTrueDropsUnderlyingConnection() - { - $client = $this->getClient(); - $client->rpush('metavars', 'foo', 'hoge', 'lol'); - - $iterator = $client->lrange('metavars', 0, -1); - $iterator->sync(true); - - $this->assertFalse($client->isConnected()); - $this->assertTrue($client->ping()); - } - - /** - * @group connected - */ - public function testGarbageCollectorDropsUnderlyingConnection() - { - $client = $this->getClient(); - $client->rpush('metavars', 'foo', 'hoge', 'lol'); - - $iterator = $client->lrange('metavars', 0, -1); - - unset($iterator); - - $this->assertFalse($client->isConnected()); - $this->assertTrue($client->ping()); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a new client instance. - * - * @return Client - */ - protected function getClient() - { - $parameters = $this->getParametersArray(array( - 'iterable_multibulk' => true, - 'read_write_timeout' => 2, - )); - - $client = $this->createClient($parameters); - - return $client; - } -} diff --git a/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseTupleTest.php b/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseTupleTest.php deleted file mode 100644 index 5ac5845ce..000000000 --- a/vendor/predis/predis/tests/Predis/Iterator/MultiBulkResponseTupleTest.php +++ /dev/null @@ -1,114 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Iterator; - -use PredisTestCase; -use Predis\Client; - -/** - * @group realm-iterators - */ -class MultiBulkResponseTupleTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException RuntimeException - * @expectedExceptionMessage Cannot initialize a tuple iterator with an already initiated iterator - */ - public function testInitiatedMultiBulkIteratorsAreNotValid() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $iterator = new MultiBulkResponseSimple($connection, 2); - $iterator->next(); - - new MultiBulkResponseTuple($iterator); - } - - /** - * @group disconnected - * @expectedException UnexpectedValueException - * @expectedExceptionMessage Invalid reply size for a tuple iterator [3] - */ - public function testMultiBulkWithOddSizesAreInvalid() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $iterator = new MultiBulkResponseSimple($connection, 3); - - new MultiBulkResponseTuple($iterator); - } - - /** - * @group connected - */ - public function testIterableMultibulk() - { - $client = $this->getClient(); - $client->zadd('metavars', 1, 'foo', 2, 'hoge', 3, 'lol'); - - $this->assertInstanceOf('OuterIterator', $iterator = $client->zrange('metavars', 0, -1, 'withscores')->asTuple()); - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseTuple', $iterator); - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $iterator->getInnerIterator()); - $this->assertTrue($iterator->valid()); - $this->assertSame(3, $iterator->count()); - - $this->assertSame(array('foo', '1'), $iterator->current()); - $this->assertSame(1, $iterator->next()); - $this->assertTrue($iterator->valid()); - - $this->assertSame(array('hoge', '2'), $iterator->current()); - $this->assertSame(2, $iterator->next()); - $this->assertTrue($iterator->valid()); - - $this->assertSame(array('lol', '3'), $iterator->current()); - $this->assertSame(3, $iterator->next()); - $this->assertFalse($iterator->valid()); - - $this->assertTrue($client->ping()); - } - - /** - * @group connected - */ - public function testGarbageCollectorDropsUnderlyingConnection() - { - $client = $this->getClient(); - $client->zadd('metavars', 1, 'foo', 2, 'hoge', 3, 'lol'); - - $iterator = $client->zrange('metavars', 0, -1, 'withscores')->asTuple(); - - unset($iterator); - - $this->assertFalse($client->isConnected()); - $this->assertTrue($client->ping()); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a new client instance. - * - * @return Client - */ - protected function getClient() - { - $parameters = $this->getParametersArray(array( - 'iterable_multibulk' => true, - 'read_write_timeout' => 2, - )); - - $client = $this->createClient($parameters); - - return $client; - } -} diff --git a/vendor/predis/predis/tests/Predis/Monitor/MonitorContextTest.php b/vendor/predis/predis/tests/Predis/Monitor/MonitorContextTest.php deleted file mode 100644 index 7be5a6a06..000000000 --- a/vendor/predis/predis/tests/Predis/Monitor/MonitorContextTest.php +++ /dev/null @@ -1,196 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Monitor; - -use PredisTestCase; -use Predis\Client; -use Predis\Profile\ServerProfile; - -/** - * @group realm-monitor - */ -class MonitorContextTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The current profile does not support the MONITOR command - */ - public function testMonitorContextRequireMonitorCommand() - { - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); - $profile->expects($this->once()) - ->method('supportsCommand') - ->with('monitor') - ->will($this->returnValue(false)); - - $client = new Client(null, array('profile' => $profile)); - $monitor = new MonitorContext($client); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage Cannot initialize a monitor context when using aggregated connections - */ - public function testMonitorContextDoesNotWorkOnClusters() - { - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); - - $client = new Client($cluster); - $monitor = new MonitorContext($client); - } - - /** - * @group disconnected - */ - public function testConstructorOpensContext() - { - $cmdMonitor = ServerProfile::getDefault()->createCommand('monitor'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $client = $this->getMock('Predis\Client', array('createCommand', 'executeCommand'), array($connection)); - $client->expects($this->once()) - ->method('createCommand') - ->with('monitor', array()) - ->will($this->returnValue($cmdMonitor)); - $client->expects($this->once()) - ->method('executeCommand') - ->with($cmdMonitor); - - $monitor = new MonitorContext($client); - } - - /** - * @group disconnected - * @todo We should investigate why disconnect is invoked 2 times in this test, - * but the reason is probably that the GC invokes __destruct() on monitor - * thus calling $client->disconnect() a second time at the end of the test. - */ - public function testClosingContextClosesConnection() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); - $client->expects($this->exactly(2))->method('disconnect'); - - $monitor = new MonitorContext($client); - $monitor->closeContext(); - } - - /** - * @group disconnected - */ - public function testGarbageCollectorRunClosesContext() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); - $client->expects($this->once())->method('disconnect'); - - $monitor = new MonitorContext($client); - unset($monitor); - } - - /** - * @group disconnected - */ - public function testReadsMessageFromConnectionToRedis24() - { - $message = '1323367530.939137 (db 15) "MONITOR"'; - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once()) - ->method('read') - ->will($this->returnValue($message)); - - $client = new Client($connection); - $monitor = new MonitorContext($client); - - $payload = $monitor->current(); - $this->assertSame(1323367530, (int) $payload->timestamp); - $this->assertSame(15, $payload->database); - $this->assertNull($payload->client); - $this->assertSame('MONITOR', $payload->command); - $this->assertNull($payload->arguments); - } - - /** - * @group disconnected - */ - public function testReadsMessageFromConnectionToRedis26() - { - $message = '1323367530.939137 [15 127.0.0.1:37265] "MONITOR"'; - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once()) - ->method('read') - ->will($this->returnValue($message)); - - $client = new Client($connection); - $monitor = new MonitorContext($client); - - $payload = $monitor->current(); - $this->assertSame(1323367530, (int) $payload->timestamp); - $this->assertSame(15, $payload->database); - $this->assertSame('127.0.0.1:37265', $payload->client); - $this->assertSame('MONITOR', $payload->command); - $this->assertNull($payload->arguments); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testMonitorAgainstRedisServer() - { - $parameters = array( - 'host' => REDIS_SERVER_HOST, - 'port' => REDIS_SERVER_PORT, - 'database' => REDIS_SERVER_DBNUM, - // Prevents suite from handing on broken test - 'read_write_timeout' => 2, - ); - - $options = array('profile' => REDIS_SERVER_VERSION); - $echoed = array(); - - $producer = new Client($parameters, $options); - $producer->connect(); - - $consumer = new Client($parameters, $options); - $consumer->connect(); - - $monitor = new MonitorContext($consumer); - - $producer->echo('message1'); - $producer->echo('message2'); - $producer->echo('QUIT'); - - foreach ($monitor as $message) { - if ($message->command == 'ECHO') { - $echoed[] = $arguments = trim($message->arguments, '"'); - if ($arguments == 'QUIT') { - $monitor->closeContext(); - } - } - } - - $this->assertSame(array('message1', 'message2', 'QUIT'), $echoed); - $this->assertFalse($monitor->valid()); - $this->assertTrue($consumer->ping()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/AbstractOptionTest.php b/vendor/predis/predis/tests/Predis/Option/AbstractOptionTest.php deleted file mode 100644 index 17f6acf2e..000000000 --- a/vendor/predis/predis/tests/Predis/Option/AbstractOptionTest.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; - -/** - * - */ -class AbstractOptionTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testValidationReturnsTheSameObject() - { - $value = new \stdClass(); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = $this->getMockForAbstractClass('Predis\Option\AbstractOption'); - - $this->assertSame($value, $option->filter($options, $value)); - } - - /** - * @group disconnected - */ - public function testDefaultReturnsNull() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = $this->getMockForAbstractClass('Predis\Option\AbstractOption'); - - $this->assertNull($option->getDefault($options)); - } - - /** - * @group disconnected - */ - public function testInvokePerformsValidationWhenValueIsSet() - { - $value = new \stdClass(); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - - $option = $this->getMock('Predis\Option\AbstractOption', array('filter', 'getDefault')); - $option->expects($this->once()) - ->method('filter') - ->with($options, $value) - ->will($this->returnValue($value)); - $option->expects($this->never())->method('getDefault'); - - $this->assertSame($value, $option($options, $value)); - } - - /** - * @group disconnected - */ - public function testInvokeReturnsDefaultWhenValueIsNotSet() - { - $expected = new \stdClass(); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - - $option = $this->getMock('Predis\Option\AbstractOption', array('filter', 'getDefault')); - $option->expects($this->never())->method('filter'); - $option->expects($this->once()) - ->method('getDefault') - ->with($options) - ->will($this->returnValue($expected)); - - $this->assertSame($expected, $option($options, null)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientClusterTest.php b/vendor/predis/predis/tests/Predis/Option/ClientClusterTest.php deleted file mode 100644 index ec8e636df..000000000 --- a/vendor/predis/predis/tests/Predis/Option/ClientClusterTest.php +++ /dev/null @@ -1,127 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; - -/** - * - */ -class ClientClusterTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testValidationAcceptsFQNStringAsInitializer() - { - $clusterClass = get_class($this->getMock('Predis\Connection\ClusterConnectionInterface')); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientCluster(); - - $cluster = $option->filter($options, $clusterClass); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster); - } - - /** - * @group disconnected - */ - public function testValidationRecognizesCertainPredefinedShortNames() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientCluster(); - - $cluster = $option->filter($options, 'predis'); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster); - } - - /** - * @group disconnected - */ - public function testValidationAcceptsCallableObjectAsInitializers() - { - $value = $this->getMock('Predis\Connection\ClusterConnectionInterface'); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientCluster(); - - $initializer = $this->getMock('stdClass', array('__invoke')); - $initializer->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $option) - ->will($this->returnValue($value)); - - $cluster = $option->filter($options, $initializer, $option); - - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $cluster); - $this->assertSame($value, $cluster); - } - - /** - * @group disconnected - */ - public function testValidationThrowsExceptionOnInvalidClassTypes() - { - $this->setExpectedException('InvalidArgumentException'); - - $connectionClass = get_class($this->getMock('Predis\Connection\SingleConnectionInterface')); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientCluster(); - - $option->filter($options, $connectionClass); - } - - /** - * @group disconnected - */ - public function testValidationThrowsExceptionOnInvalidShortName() - { - $this->setExpectedException('InvalidArgumentException'); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientCluster(); - - $option->filter($options, 'unknown'); - } - - /** - * @group disconnected - */ - public function testValidationThrowsExceptionOnInvalidObjectReturnedByCallback() - { - $this->setExpectedException('InvalidArgumentException'); - - $value = function ($options) { - return new \stdClass(); - }; - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientCluster(); - - $option->filter($options, $value); - } - - /** - * @group disconnected - */ - public function testValidationThrowsExceptionOnInvalidArguments() - { - $this->setExpectedException('InvalidArgumentException'); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientCluster(); - - $option->filter($options, new \stdClass()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientConnectionFactoryTest.php b/vendor/predis/predis/tests/Predis/Option/ClientConnectionFactoryTest.php deleted file mode 100644 index c47b2c959..000000000 --- a/vendor/predis/predis/tests/Predis/Option/ClientConnectionFactoryTest.php +++ /dev/null @@ -1,137 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; -use Predis\Connection\ConnectionFactory; - -/** - * - */ -class ClientConnectionFactoryTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testValidationReturnsDefaultFactoryWithSchemeDefinitionsArray() - { - $connectionClass = get_class($this->getMock('Predis\Connection\SingleConnectionInterface')); - $value = array('tcp' => $connectionClass, 'redis' => $connectionClass); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - - $default = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); - $default->expects($this->exactly(2)) - ->method('define') - ->with($this->matchesRegularExpression('/^tcp|redis$/'), $connectionClass); - - $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('getDefault')); - $option->expects($this->once()) - ->method('getDefault') - ->with($options) - ->will($this->returnValue($default)); - - $factory = $option->filter($options, $value); - - $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $factory); - $this->assertSame($default, $factory); - } - - /** - * @group disconnected - */ - public function testValidationAcceptsFactoryInstancesAsValue() - { - $value = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - - $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('getDefault')); - $option->expects($this->never())->method('getDefault'); - - $this->assertSame($value, $option->filter($options, $value)); - } - - /** - * @group disconnected - */ - public function testValidationAcceptsCallableObjectAsInitializers() - { - $value = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientConnectionFactory(); - - $initializer = $this->getMock('stdClass', array('__invoke')); - $initializer->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $option) - ->will($this->returnValue($value)); - - $cluster = $option->filter($options, $initializer, $option); - - $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $cluster); - $this->assertSame($value, $cluster); - } - - /** - * @group disconnected - */ - public function testValidationAcceptsStringAsValue() - { - $factory = 'Predis\Connection\ConnectionFactory'; - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - - $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('getDefault')); - $option->expects($this->never())->method('getDefault'); - - $this->assertInstanceOf($factory, $option->filter($options, $factory)); - } - - /** - * @group disconnected - */ - public function testValidationThrowsExceptionOnWrongInvalidArguments() - { - $this->setExpectedException('InvalidArgumentException'); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientConnectionFactory(); - - $option->filter($options, new \stdClass()); - } - - /** - * @group disconnected - */ - public function testInvokeReturnsSpecifiedFactoryOrDefault() - { - $value = $this->getMock('Predis\Connection\ConnectionFactoryInterface'); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - - $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('filter', 'getDefault')); - $option->expects($this->once()) - ->method('filter') - ->with($options, $value) - ->will($this->returnValue($value)); - $option->expects($this->never())->method('getDefault'); - - $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $option($options, $value)); - - $option = $this->getMock('Predis\Option\ClientConnectionFactory', array('filter', 'getDefault')); - $option->expects($this->never())->method('filter'); - $option->expects($this->once()) - ->method('getDefault') - ->with($options) - ->will($this->returnValue($value)); - - $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $option($options, null)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientExceptionsTest.php b/vendor/predis/predis/tests/Predis/Option/ClientExceptionsTest.php deleted file mode 100644 index ec414bd16..000000000 --- a/vendor/predis/predis/tests/Predis/Option/ClientExceptionsTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; - -/** - * - */ -class ClientExceptionsTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testDefaultReturnsTrue() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientExceptions(); - - $this->assertTrue($option->getDefault($options)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientOptionsTest.php b/vendor/predis/predis/tests/Predis/Option/ClientOptionsTest.php deleted file mode 100644 index f74c10369..000000000 --- a/vendor/predis/predis/tests/Predis/Option/ClientOptionsTest.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; - -/** - * @todo We should test the inner work performed by this class - * using mock objects, but it is quite hard to to that. - */ -class ClientOptionsTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testConstructorWithoutArguments() - { - $options = new ClientOptions(); - - $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $options->connections); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->profile); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster); - $this->assertNull($options->prefix); - } - - /** - * @group disconnected - */ - public function testConstructorWithArrayArgument() - { - $options = new ClientOptions(array( - 'cluster' => 'Predis\Connection\PredisCluster', - 'connections' => 'Predis\Connection\ConnectionFactory', - 'prefix' => 'prefix:', - 'profile' => '2.0', - 'exceptions' => false, - )); - - $this->assertInstanceOf('Predis\Connection\ConnectionFactoryInterface', $options->connections); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $options->profile); - $this->assertInstanceOf('Predis\Connection\ClusterConnectionInterface', $options->cluster); - $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $options->prefix); - $this->assertInternalType('bool', $options->exceptions); - } - - /** - * @group disconnected - */ - public function testHandlesCustomOptionsWithoutHandlers() - { - $options = new ClientOptions(array( - 'custom' => 'foobar', - )); - - $this->assertSame('foobar', $options->custom); - } - - /** - * @group disconnected - */ - public function testIsSetReturnsIfOptionHasBeenSetByUser() - { - $options = new ClientOptions(array( - 'prefix' => 'prefix:', - 'custom' => 'foobar', - )); - - $this->assertTrue(isset($options->prefix)); - $this->assertTrue(isset($options->custom)); - $this->assertFalse(isset($options->profile)); - } - - /** - * @group disconnected - */ - public function testGetDefaultUsingOptionName() - { - $options = new ClientOptions(); - - $this->assertInstanceOf('Predis\Connection\PredisCluster', $options->getDefault('cluster')); - } - - /** - * @group disconnected - */ - public function testGetDefaultUsingUnhandledOptionName() - { - $options = new ClientOptions(); - $option = new ClientCluster(); - - $this->assertNull($options->getDefault('foo')); - } - - /** - * @group disconnected - */ - public function testGetDefaultUsingOptionInstance() - { - $options = new ClientOptions(); - $option = new ClientCluster(); - - $this->assertInstanceOf('Predis\Connection\PredisCluster', $options->getDefault($option)); - } - - /** - * @group disconnected - */ - public function testGetDefaultUsingUnhandledOptionInstance() - { - $options = new ClientOptions(); - $option = new CustomOption(array( - 'default' => function ($options) { - return 'foo'; - }, - )); - - $this->assertSame('foo', $options->getDefault($option)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientPrefixTest.php b/vendor/predis/predis/tests/Predis/Option/ClientPrefixTest.php deleted file mode 100644 index 08763f622..000000000 --- a/vendor/predis/predis/tests/Predis/Option/ClientPrefixTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; - -/** - * - */ -class ClientPrefixTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testValidationReturnsCommandProcessor() - { - $value = 'prefix:'; - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientPrefix(); - - $return = $option->filter($options, $value); - - $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $return); - $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $return); - $this->assertEquals($value, $return->getPrefix()); - } - - /** - * @group disconnected - */ - public function testDefaultReturnsNull() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientPrefix(); - - $this->assertNull($option->getDefault($options)); - } - - /** - * @group disconnected - */ - public function testInvokeReturnsCommandProcessorOrNull() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientPrefix(); - - $this->assertInstanceOf('Predis\Command\Processor\CommandProcessorInterface', $option($options, 'prefix:')); - $this->assertNull($option($options, null)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientProfileTest.php b/vendor/predis/predis/tests/Predis/Option/ClientProfileTest.php deleted file mode 100644 index 513623449..000000000 --- a/vendor/predis/predis/tests/Predis/Option/ClientProfileTest.php +++ /dev/null @@ -1,210 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; -use Predis\Command\Processor\KeyPrefixProcessor; -use Predis\Profile\ServerProfile; - -/** - * - */ -class ClientProfileTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testValidationReturnsServerProfileWithStringValue() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientProfile(); - - $profile = $option->filter($options, '2.0'); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertEquals('2.0', $profile->getVersion()); - $this->assertNull($profile->getProcessor()); - } - - /** - * @group disconnected - */ - public function testValidationAcceptsProfileInstancesAsValue() - { - $value = ServerProfile::get('2.0'); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientProfile(); - - $profile = $option->filter($options, $value); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertEquals('2.0', $profile->getVersion()); - $this->assertNull($profile->getProcessor()); - } - - /** - * @group disconnected - */ - public function testValidationAcceptsCallableObjectAsInitializers() - { - $value = $this->getMock('Predis\Profile\ServerProfileInterface'); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientProfile(); - - $initializer = $this->getMock('stdClass', array('__invoke')); - $initializer->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $option) - ->will($this->returnValue($value)); - - $profile = $option->filter($options, $initializer, $option); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertSame($value, $profile); - } - - /** - * @group disconnected - */ - public function testValidationThrowsExceptionOnWrongInvalidArguments() - { - $this->setExpectedException('InvalidArgumentException'); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientProfile(); - - $option->filter($options, new \stdClass()); - } - - /** - * @group disconnected - */ - public function testDefaultReturnsDefaultServerProfile() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientProfile(); - - $profile = $option->getDefault($options); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); - $this->assertNull($profile->getProcessor()); - } - - /** - * @group disconnected - */ - public function testInvokeReturnsSpecifiedServerProfileOrDefault() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientProfile(); - - $profile = $option($options, '2.0'); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertEquals('2.0', $profile->getVersion()); - $this->assertNull($profile->getProcessor()); - - $profile = $option($options, null); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); - $this->assertNull($profile->getProcessor()); - } - - /** - * @group disconnected - * @todo Can't we when trap __isset when mocking an interface? Doesn't seem to work here. - */ - public function testFilterSetsPrefixProcessorFromClientOptions() - { - $options = $this->getMock('Predis\Option\ClientOptions', array('__isset', '__get')); - $options->expects($this->once()) - ->method('__isset') - ->with('prefix') - ->will($this->returnValue(true)); - $options->expects($this->once()) - ->method('__get') - ->with('prefix') - ->will($this->returnValue(new KeyPrefixProcessor('prefix:'))); - - $option = new ClientProfile(); - - $profile = $option->filter($options, '2.0'); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertEquals('2.0', $profile->getVersion()); - $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); - $this->assertEquals('prefix:', $profile->getProcessor()->getPrefix()); - } - - /** - * @group disconnected - * @todo Can't we when trap __isset when mocking an interface? Doesn't seem to work here. - */ - public function testDefaultSetsPrefixProcessorFromClientOptions() - { - $options = $this->getMock('Predis\Option\ClientOptions', array('__isset', '__get')); - $options->expects($this->once()) - ->method('__isset') - ->with('prefix') - ->will($this->returnValue(true)); - $options->expects($this->once()) - ->method('__get') - ->with('prefix') - ->will($this->returnValue(new KeyPrefixProcessor('prefix:'))); - - $option = new ClientProfile(); - - $profile = $option->getDefault($options); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertInstanceOf(get_class(ServerProfile::getDefault()), $profile); - $this->assertInstanceOf('Predis\Command\Processor\KeyPrefixProcessor', $profile->getProcessor()); - $this->assertEquals('prefix:', $profile->getProcessor()->getPrefix()); - } - - /** - * @group disconnected - */ - public function testValidationDoesNotSetPrefixProcessorWhenValueIsProfileInstance() - { - $options = $this->getMock('Predis\Option\ClientOptions', array('__isset', '__get')); - $options->expects($this->never())->method('__isset'); - $options->expects($this->never())->method('__get'); - - $option = new ClientProfile(); - - $profile = $option->filter($options, ServerProfile::getDefault()); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertNull($profile->getProcessor()); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Invalid value for the profile option - */ - public function testValidationThrowsExceptionOnInvalidObjectReturnedByCallback() - { - $value = function ($options) { - return new \stdClass(); - }; - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientProfile(); - - $option->filter($options, $value); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/ClientReplicationTest.php b/vendor/predis/predis/tests/Predis/Option/ClientReplicationTest.php deleted file mode 100644 index ba93abd3a..000000000 --- a/vendor/predis/predis/tests/Predis/Option/ClientReplicationTest.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; - -/** - * - */ -class ClientReplicationTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testValidationAcceptsFQNStringAsInitializer() - { - $replicationClass = get_class($this->getMock('Predis\Connection\ReplicationConnectionInterface')); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientReplication(); - - $replication = $option->filter($options, $replicationClass); - - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $replication); - } - - /** - * @group disconnected - */ - public function testValidationAcceptsBooleanValue() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientReplication(); - - $replication = $option->filter($options, true); - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $replication); - - $replication = $option->filter($options, false); - $this->assertNull($replication); - } - - /** - * @group disconnected - */ - public function testValidationAcceptsCallableObjectAsInitializers() - { - $value = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientReplication(); - - $initializer = $this->getMock('stdClass', array('__invoke')); - $initializer->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $option) - ->will($this->returnValue($value)); - - $replication = $option->filter($options, $initializer, $option); - - $this->assertInstanceOf('Predis\Connection\ReplicationConnectionInterface', $replication); - $this->assertSame($value, $replication); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - */ - public function testValidationThrowsExceptionOnInvalidObjectReturnedByCallback() - { - $value = function ($options) { - return new \stdClass(); - }; - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientReplication(); - - $option->filter($options, $value); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - */ - public function testValidationThrowsExceptionOnInvalidClassTypes() - { - $connectionClass = get_class($this->getMock('Predis\Connection\SingleConnectionInterface')); - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new ClientReplication(); - - $option->filter($options, $connectionClass); - } -} diff --git a/vendor/predis/predis/tests/Predis/Option/CustomOptionTest.php b/vendor/predis/predis/tests/Predis/Option/CustomOptionTest.php deleted file mode 100644 index 13f70e399..000000000 --- a/vendor/predis/predis/tests/Predis/Option/CustomOptionTest.php +++ /dev/null @@ -1,114 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Option; - -use PredisTestCase; - -/** - * - */ -class CustomOptionTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException InvalidArgumentException - */ - public function testConstructorAcceptsOnlyCallablesForFilter() - { - $option = new CustomOption(array('filter' => new \stdClass())); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - */ - public function testConstructorAcceptsOnlyCallablesForDefault() - { - $option = new CustomOption(array('default' => new \stdClass())); - } - - /** - * @group disconnected - */ - public function testConstructorIgnoresUnrecognizedParameters() - { - $option = new CustomOption(array('unknown' => new \stdClass())); - - $this->assertNotNull($option); - } - - /** - * @group disconnected - */ - public function testFilterWithoutCallbackReturnsValue() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new CustomOption(); - - $this->assertEquals('test', $option->filter($options, 'test')); - } - - /** - * @group disconnected - */ - public function testDefaultWithoutCallbackReturnsNull() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - $option = new CustomOption(); - - $this->assertNull($option->getDefault($options)); - } - - /** - * @group disconnected - */ - public function testInvokeCallsFilterCallback() - { - $value = 'test'; - - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - - $filter = $this->getMock('stdClass', array('__invoke')); - $filter->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface'), $value) - ->will($this->returnValue(true)); - - $default = $this->getMock('stdClass', array('__invoke')); - $default->expects($this->never())->method('__invoke'); - - $option = new CustomOption(array('filter' => $filter, 'default' => $default)); - - $this->assertTrue($option($options, $value)); - } - - /** - * @group disconnected - */ - public function testInvokeCallsDefaultCallback() - { - $options = $this->getMock('Predis\Option\ClientOptionsInterface'); - - $filter = $this->getMock('stdClass', array('__invoke')); - $filter->expects($this->never())->method('__invoke'); - - $default = $this->getMock('stdClass', array('__invoke')); - $default->expects($this->once()) - ->method('__invoke') - ->with($this->isInstanceOf('Predis\Option\ClientOptionsInterface')) - ->will($this->returnValue(true)); - - $option = new CustomOption(array('filter' => $filter, 'default' => $default)); - - $this->assertTrue($option($options, null)); - } -} diff --git a/vendor/predis/predis/tests/Predis/Pipeline/FireAndForgetExecutorTest.php b/vendor/predis/predis/tests/Predis/Pipeline/FireAndForgetExecutorTest.php deleted file mode 100644 index 709499a5b..000000000 --- a/vendor/predis/predis/tests/Predis/Pipeline/FireAndForgetExecutorTest.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use SplQueue; -use PredisTestCase; -use Predis\Profile\ServerProfile; - -/** - * - */ -class FireAndForgetExecutorTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExecutorWithSingleConnection() - { - $executor = new FireAndForgetExecutor(); - $pipeline = $this->getCommandsQueue(); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(3)) - ->method('writeCommand'); - $connection->expects($this->never()) - ->method('readResponse'); - - $replies = $executor->execute($connection, $pipeline); - - $this->assertTrue($pipeline->isEmpty()); - $this->assertEmpty($replies); - } - - /** - * @group disconnected - */ - public function testExecutorWithReplicationConnection() - { - $executor = new FireAndForgetExecutor(); - $pipeline = $this->getCommandsQueue(); - - $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); - $connection->expects($this->once()) - ->method('switchTo') - ->with('master'); - $connection->expects($this->exactly(3)) - ->method('writeCommand'); - $connection->expects($this->never()) - ->method('readResponse'); - - $replies = $executor->execute($connection, $pipeline); - - $this->assertTrue($pipeline->isEmpty()); - $this->assertEmpty($replies); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a list of queued command instances. - * - * @return SplQueue - */ - protected function getCommandsQueue() - { - $profile = ServerProfile::getDevelopment(); - - $pipeline = new SplQueue(); - $pipeline->enqueue($profile->createCommand('ping')); - $pipeline->enqueue($profile->createCommand('ping')); - $pipeline->enqueue($profile->createCommand('ping')); - - return $pipeline; - } -} diff --git a/vendor/predis/predis/tests/Predis/Pipeline/MultiExecExecutorTest.php b/vendor/predis/predis/tests/Predis/Pipeline/MultiExecExecutorTest.php deleted file mode 100644 index 02baddb35..000000000 --- a/vendor/predis/predis/tests/Predis/Pipeline/MultiExecExecutorTest.php +++ /dev/null @@ -1,187 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use ArrayIterator; -use SplQueue; -use PredisTestCase; -use Predis\ResponseError; -use Predis\ResponseObjectInterface; -use Predis\ResponseQueued; -use Predis\Profile\ServerProfile; - -/** - * - */ -class ResponseIteratorStub extends ArrayIterator implements ResponseObjectInterface -{ -} - -/** - * - */ -class MultiExecExecutorTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExecutorWithSingleConnection() - { - $executor = new MultiExecExecutor(); - $pipeline = $this->getCommandsQueue(); - $queued = new ResponseQueued(); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(2)) - ->method('executeCommand') - ->will($this->onConsecutiveCalls(true, array('PONG', 'PONG', 'PONG'))); - $connection->expects($this->exactly(3)) - ->method('writeCommand'); - $connection->expects($this->at(3)) - ->method('readResponse') - ->will($this->onConsecutiveCalls($queued, $queued, $queued)); - - $replies = $executor->execute($connection, $pipeline); - - $this->assertTrue($pipeline->isEmpty()); - $this->assertSame(array(true, true, true), $replies); - } - - /** - * @group disconnected - */ - public function testExecutorWithSingleConnectionReturningIterator() - { - $executor = new MultiExecExecutor(); - $pipeline = $this->getCommandsQueue(); - $queued = new ResponseQueued(); - $execResponse = new ResponseIteratorStub(array('PONG', 'PONG', 'PONG')); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(2)) - ->method('executeCommand') - ->will($this->onConsecutiveCalls(true, $execResponse)); - $connection->expects($this->exactly(3)) - ->method('writeCommand'); - $connection->expects($this->at(3)) - ->method('readResponse') - ->will($this->onConsecutiveCalls($queued, $queued, $queued)); - - $replies = $executor->execute($connection, $pipeline); - - $this->assertTrue($pipeline->isEmpty()); - $this->assertSame(array(true, true, true), $replies); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - * @expectedExceptionMessage The underlying transaction has been aborted by the server - */ - public function testExecutorWithAbortedTransaction() - { - $executor = new MultiExecExecutor(); - $pipeline = $this->getCommandsQueue(); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(2)) - ->method('executeCommand') - ->will($this->onConsecutiveCalls(true, null)); - - $executor->execute($connection, $pipeline); - } - - /** - * @group disconnected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR Test error - */ - public function testExecutorWithErrorInTransaction() - { - $executor = new MultiExecExecutor(); - $pipeline = $this->getCommandsQueue(); - $queued = new ResponseQueued(); - $error = new ResponseError('ERR Test error'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->at(0)) - ->method('executeCommand') - ->will($this->returnValue(true)); - $connection->expects($this->exactly(3)) - ->method('readResponse') - ->will($this->onConsecutiveCalls($queued, $queued, $error)); - $connection->expects($this->at(7)) - ->method('executeCommand') - ->with($this->isInstanceOf('Predis\Command\TransactionDiscard')); - - $executor->execute($connection, $pipeline); - } - - /** - * @group disconnected - */ - public function testExecutorWithErrorInCommandResponse() - { - $executor = new MultiExecExecutor(); - $pipeline = $this->getCommandsQueue(); - $queued = new ResponseQueued(); - $error = new ResponseError('ERR Test error'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(3)) - ->method('readResponse') - ->will($this->onConsecutiveCalls($queued, $queued, $queued)); - $connection->expects($this->at(7)) - ->method('executeCommand') - ->will($this->returnValue(array('PONG', 'PONG', $error))); - - $replies = $executor->execute($connection, $pipeline); - - $this->assertSame(array(true, true, $error), $replies); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - * @expectedExceptionMessage Predis\Pipeline\MultiExecExecutor can be used only with single connections - */ - public function testExecutorWithAggregatedConnection() - { - $executor = new MultiExecExecutor(); - $pipeline = $this->getCommandsQueue(); - - $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); - - $replies = $executor->execute($connection, $pipeline); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a list of queued command instances. - * - * @return SplQueue - */ - protected function getCommandsQueue() - { - $profile = ServerProfile::getDevelopment(); - - $pipeline = new SplQueue(); - $pipeline->enqueue($profile->createCommand('ping')); - $pipeline->enqueue($profile->createCommand('ping')); - $pipeline->enqueue($profile->createCommand('ping')); - - return $pipeline; - } -} diff --git a/vendor/predis/predis/tests/Predis/Pipeline/PipelineContextTest.php b/vendor/predis/predis/tests/Predis/Pipeline/PipelineContextTest.php deleted file mode 100644 index 4354e1244..000000000 --- a/vendor/predis/predis/tests/Predis/Pipeline/PipelineContextTest.php +++ /dev/null @@ -1,438 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use PredisTestCase; -use Predis\Client; -use Predis\ClientException; -use Predis\Profile\ServerProfile; - -/** - * - */ -class PipelineContextTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testConstructorWithoutOptions() - { - $client = new Client(); - $pipeline = new PipelineContext($client); - - $this->assertSame($client, $pipeline->getClient()); - $this->assertInstanceOf('Predis\Pipeline\StandardExecutor', $pipeline->getExecutor()); - } - - /** - * @group disconnected - */ - public function testConstructorWithExecutorArgument() - { - $client = new Client(); - $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); - - $pipeline = new PipelineContext($client, $executor); - $this->assertSame($executor, $pipeline->getExecutor()); - } - - /** - * @group disconnected - */ - public function testCallDoesNotSendCommandsWithoutExecute() - { - $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); - $executor->expects($this->never())->method('executor'); - - $pipeline = new PipelineContext(new Client(), $executor); - - $pipeline->echo('one'); - $pipeline->echo('two'); - $pipeline->echo('three'); - } - - /** - * @group disconnected - */ - public function testCallReturnsPipelineForFluentInterface() - { - $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); - $executor->expects($this->never())->method('executor'); - - $pipeline = new PipelineContext(new Client(), $executor); - - $this->assertSame($pipeline, $pipeline->echo('one')); - $this->assertSame($pipeline, $pipeline->echo('one')->echo('two')->echo('three')); - } - - /** - * @group disconnected - */ - public function testExecuteReturnsPipelineForFluentInterface() - { - $profile = ServerProfile::getDefault(); - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $pipeline = new PipelineContext(new Client($connection)); - $command = $profile->createCommand('echo', array('one')); - - $this->assertSame($pipeline, $pipeline->executeCommand($command)); - } - - /** - * @group disconnected - */ - public function testExecuteCommandDoesNotSendCommandsWithoutExecute() - { - $profile = ServerProfile::getDefault(); - - $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); - $executor->expects($this->never())->method('executor'); - - $pipeline = new PipelineContext(new Client(), $executor); - - $pipeline->executeCommand($profile->createCommand('echo', array('one'))); - $pipeline->executeCommand($profile->createCommand('echo', array('two'))); - $pipeline->executeCommand($profile->createCommand('echo', array('three'))); - } - - /** - * @group disconnected - */ - public function testExecuteWithEmptyBuffer() - { - $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); - $executor->expects($this->never())->method('executor'); - - $pipeline = new PipelineContext(new Client(), $executor); - - $this->assertSame(array(), $pipeline->execute()); - } - - /** - * @group disconnected - */ - public function testExecuteWithFilledBuffer() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(3)) - ->method('writeCommand'); - $connection->expects($this->exactly(3)) - ->method('readResponse') - ->will($this->returnCallback($this->getReadCallback())); - - $pipeline = new PipelineContext(new Client($connection)); - - $pipeline->echo('one'); - $pipeline->echo('two'); - $pipeline->echo('three'); - - $pipeline->flushPipeline(); - - $this->assertSame(array('one', 'two', 'three'), $pipeline->execute()); - } - - /** - * @group disconnected - */ - public function testFlushWithFalseArgumentDiscardsBuffer() - { - $executor = $this->getMock('Predis\Pipeline\PipelineExecutorInterface'); - $executor->expects($this->never())->method('executor'); - - $pipeline = new PipelineContext(new Client(), $executor); - - $pipeline->echo('one'); - $pipeline->echo('two'); - $pipeline->echo('three'); - - $pipeline->flushPipeline(false); - - $this->assertSame(array(), $pipeline->execute()); - } - - /** - * @group disconnected - */ - public function testFlushHandlesPartialBuffers() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(4)) - ->method('writeCommand'); - $connection->expects($this->exactly(4)) - ->method('readResponse') - ->will($this->returnCallback($this->getReadCallback())); - - $pipeline = new PipelineContext(new Client($connection)); - - $pipeline->echo('one'); - $pipeline->echo('two'); - $pipeline->flushPipeline(); - $pipeline->echo('three'); - $pipeline->echo('four'); - - $this->assertSame(array('one', 'two', 'three', 'four'), $pipeline->execute()); - } - - /** - * @group disconnected - */ - public function testExecuteAcceptsCallableArgument() - { - $test = $this; - $pipeline = new PipelineContext(new Client()); - - $callable = function ($pipe) use ($test, $pipeline) { - $test->assertSame($pipeline, $pipe); - $pipe->flushPipeline(false); - }; - - $pipeline->execute($callable); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - */ - public function testExecuteDoesNotAcceptNonCallableArgument() - { - $noncallable = new \stdClass(); - - $pipeline = new PipelineContext(new Client()); - $pipeline->execute($noncallable); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - */ - public function testExecuteInsideCallableArgumentThrowsException() - { - $pipeline = new PipelineContext(new Client()); - - $pipeline->execute(function ($pipe) { - $pipe->execute(); - }); - } - - /** - * @group disconnected - */ - public function testExecuteWithCallableArgumentRunsPipelineInCallable() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(4)) - ->method('writeCommand'); - $connection->expects($this->exactly(4)) - ->method('readResponse') - ->will($this->returnCallback($this->getReadCallback())); - - $pipeline = new PipelineContext(new Client($connection)); - - $replies = $pipeline->execute(function ($pipe) { - $pipe->echo('one'); - $pipe->echo('two'); - $pipe->echo('three'); - $pipe->echo('four'); - }); - - $this->assertSame(array('one', 'two', 'three', 'four'), $replies); - } - - /** - * @group disconnected - */ - public function testExecuteWithCallableArgumentHandlesExceptions() - { - $exception = null; - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->never())->method('writeCommand'); - $connection->expects($this->never())->method('readResponse'); - - $pipeline = new PipelineContext(new Client($connection)); - - $exception = null; - $replies = null; - - try { - $replies = $pipeline->execute(function ($pipe) { - $pipe->echo('one'); - throw new ClientException('TEST'); - $pipe->echo('two'); - }); - } catch (\Exception $exception) { - // NOOP - } - - $this->assertInstanceOf('Predis\ClientException', $exception); - $this->assertSame('TEST', $exception->getMessage()); - $this->assertNull($replies); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testIntegrationWithFluentInterface() - { - $pipeline = $this->getClient()->pipeline(); - - $results = $pipeline->echo('one') - ->echo('two') - ->echo('three') - ->execute(); - - $this->assertSame(array('one', 'two', 'three'), $results); - } - - /** - * @group connected - */ - public function testIntegrationWithCallableBlock() - { - $client = $this->getClient(); - - $results = $client->pipeline(function ($pipe) { - $pipe->set('foo', 'bar'); - $pipe->get('foo'); - }); - - $this->assertSame(array(true, 'bar'), $results); - $this->assertTrue($client->exists('foo')); - } - - /** - * @group connected - */ - public function testOutOfBandMessagesInsidePipeline() - { - $oob = null; - $client = $this->getClient(); - - $results = $client->pipeline(function ($pipe) use (&$oob) { - $pipe->set('foo', 'bar'); - $oob = $pipe->getClient()->echo('oob message'); - $pipe->get('foo'); - }); - - $this->assertSame(array(true, 'bar'), $results); - $this->assertSame('oob message', $oob); - $this->assertTrue($client->exists('foo')); - } - - /** - * @group connected - */ - public function testIntegrationWithClientExceptionInCallableBlock() - { - $exception = null; - - $client = $this->getClient(); - - try { - $client->pipeline(function ($pipe) { - $pipe->set('foo', 'bar'); - throw new ClientException('TEST'); - }); - } catch (\Exception $exception) { - // NOOP - } - - $this->assertInstanceOf('Predis\ClientException', $exception); - $this->assertSame('TEST', $exception->getMessage()); - $this->assertFalse($client->exists('foo')); - } - - /** - * @group connected - */ - public function testIntegrationWithServerExceptionInCallableBlock() - { - $exception = null; - - $client = $this->getClient(); - - try { - $client->pipeline(function ($pipe) { - $pipe->set('foo', 'bar'); - // LPUSH on a string key fails, but won't stop - // the pipeline to send the commands. - $pipe->lpush('foo', 'bar'); - $pipe->set('hoge', 'piyo'); - }); - } catch (\Exception $exception) { - // NOOP - } - - $this->assertInstanceOf('Predis\ServerException', $exception); - $this->assertTrue($client->exists('foo')); - $this->assertTrue($client->exists('hoge')); - } - - /** - * @group connected - */ - public function testIntegrationWithServerErrorInCallableBlock() - { - $client = $this->getClient(array(), array('exceptions' => false)); - - $results = $client->pipeline(function ($pipe) { - $pipe->set('foo', 'bar'); - $pipe->lpush('foo', 'bar'); // LPUSH on a string key fails. - $pipe->get('foo'); - }); - - $this->assertTrue($results[0]); - $this->assertInstanceOf('Predis\ResponseError', $results[1]); - $this->assertSame('bar', $results[2]); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a client instance connected to the specified Redis - * server instance to perform integration tests. - * - * @param array $parameters Additional connection parameters. - * @param array $options Additional client options. - * @return Client - */ - protected function getClient(array $parameters = array(), array $options = array()) - { - return $this->createClient($parameters, $options); - } - - /** - * Helper method that returns a callback used to emulate a reply - * to an ECHO command. - * - * @return \Closure - */ - protected function getReadCallback() - { - return function ($command) { - if (($id = $command->getId()) !== 'ECHO') { - throw new \InvalidArgumentException("Expected ECHO, got {$id}"); - } - - list($echoed) = $command->getArguments(); - - return $echoed; - }; - } -} diff --git a/vendor/predis/predis/tests/Predis/Pipeline/StandardExecutorTest.php b/vendor/predis/predis/tests/Predis/Pipeline/StandardExecutorTest.php deleted file mode 100644 index e7a2ea5e9..000000000 --- a/vendor/predis/predis/tests/Predis/Pipeline/StandardExecutorTest.php +++ /dev/null @@ -1,159 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Pipeline; - -use SplQueue; -use PredisTestCase; -use Predis\ResponseError; -use Predis\ResponseObjectInterface; -use Predis\Profile\ServerProfile; - -/** - * - */ -class StandardExecutorTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExecutorWithSingleConnection() - { - $executor = new StandardExecutor(); - $pipeline = $this->getCommandsQueue(); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(3)) - ->method('writeCommand'); - $connection->expects($this->exactly(3)) - ->method('readResponse') - ->will($this->returnValue('PONG')); - - $replies = $executor->execute($connection, $pipeline); - - $this->assertTrue($pipeline->isEmpty()); - $this->assertSame(array(true, true, true), $replies); - } - - /** - * @group disconnected - */ - public function testExecutorWithReplicationConnection() - { - $executor = new StandardExecutor(); - $pipeline = $this->getCommandsQueue(); - - $connection = $this->getMock('Predis\Connection\ReplicationConnectionInterface'); - $connection->expects($this->once()) - ->method('switchTo') - ->with('master'); - $connection->expects($this->exactly(3)) - ->method('writeCommand'); - $connection->expects($this->exactly(3)) - ->method('readResponse') - ->will($this->returnValue('PONG')); - - $replies = $executor->execute($connection, $pipeline); - - $this->assertTrue($pipeline->isEmpty()); - $this->assertSame(array(true, true, true), $replies); - } - - /** - * @group disconnected - */ - public function testExecutorDoesNotParseResponseObjects() - { - $executor = new StandardExecutor(); - $response = $this->getMock('Predis\ResponseObjectInterface'); - - $this->simpleResponseObjectTest($executor, $response); - } - - /** - * @group disconnected - */ - public function testExecutorCanReturnRedisErrors() - { - $executor = new StandardExecutor(false); - $response = $this->getMock('Predis\ResponseErrorInterface'); - - $this->simpleResponseObjectTest($executor, $response); - } - - /** - * @group disconnected - * @expectedException Predis\ServerException - * @expectedExceptionMessage ERR Test error - */ - public function testExecutorCanThrowExceptions() - { - $executor = new StandardExecutor(true); - $pipeline = $this->getCommandsQueue(); - $error = new ResponseError('ERR Test error'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once()) - ->method('readResponse') - ->will($this->returnValue($error)); - - $executor->execute($connection, $pipeline); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Executes a test for the Predis\ResponseObjectInterface type. - * - * @param PipelineExecutorInterface $executor - * @param ResponseObjectInterface $response - */ - protected function simpleResponseObjectTest(PipelineExecutorInterface $executor, ResponseObjectInterface $response) - { - $pipeline = new SplQueue(); - - $command = $this->getMock('Predis\Command\CommandInterface'); - $command->expects($this->never()) - ->method('parseResponse'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once()) - ->method('writeCommand'); - $connection->expects($this->once()) - ->method('readResponse') - ->will($this->returnValue($response)); - - $pipeline->enqueue($command); - $replies = $executor->execute($connection, $pipeline); - - $this->assertTrue($pipeline->isEmpty()); - $this->assertSame(array($response), $replies); - } - - /** - * Returns a list of queued command instances. - * - * @return SplQueue - */ - protected function getCommandsQueue() - { - $profile = ServerProfile::getDevelopment(); - - $pipeline = new SplQueue(); - $pipeline->enqueue($profile->createCommand('ping')); - $pipeline->enqueue($profile->createCommand('ping')); - $pipeline->enqueue($profile->createCommand('ping')); - - return $pipeline; - } -} diff --git a/vendor/predis/predis/tests/Predis/PredisExceptionTest.php b/vendor/predis/predis/tests/Predis/PredisExceptionTest.php deleted file mode 100644 index 07b638160..000000000 --- a/vendor/predis/predis/tests/Predis/PredisExceptionTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use PredisTestCase; - -/** - * - */ -class PredisExceptionTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExceptionMessage() - { - $message = 'Predis exception message'; - $exception = $this->getMockForAbstractClass('Predis\PredisException', array($message)); - - $this->setExpectedException('Predis\PredisException', $message); - - throw $exception; - } -} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerProfileTest.php b/vendor/predis/predis/tests/Predis/Profile/ServerProfileTest.php deleted file mode 100644 index 6173973c5..000000000 --- a/vendor/predis/predis/tests/Predis/Profile/ServerProfileTest.php +++ /dev/null @@ -1,293 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -use PredisTestCase; -use Predis\Command\Processor\ProcessorChain; - -/** - * - */ -class ServerProfileTest extends PredisTestCase -{ - const DEFAULT_PROFILE_VERSION = '2.6'; - const DEVELOPMENT_PROFILE_VERSION = '3.0'; - - /** - * @group disconnected - */ - public function testGetVersion() - { - $profile = ServerProfile::get('2.0'); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile); - $this->assertEquals('2.0', $profile->getVersion()); - } - - /** - * @group disconnected - */ - public function testGetDefault() - { - $profile1 = ServerProfile::get(self::DEFAULT_PROFILE_VERSION); - $profile2 = ServerProfile::get('default'); - $profile3 = ServerProfile::getDefault(); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile1); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile2); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile3); - $this->assertEquals($profile1->getVersion(), $profile2->getVersion()); - $this->assertEquals($profile2->getVersion(), $profile3->getVersion()); - } - - /** - * @group disconnected - */ - public function testGetDevelopment() - { - $profile1 = ServerProfile::get('dev'); - $profile2 = ServerProfile::getDevelopment(); - - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile1); - $this->assertInstanceOf('Predis\Profile\ServerProfileInterface', $profile2); - $this->assertEquals(self::DEVELOPMENT_PROFILE_VERSION, $profile2->getVersion()); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - * @expectedExceptionMessage Unknown server profile: 1.0 - */ - public function testGetUndefinedProfile() - { - ServerProfile::get('1.0'); - } - - /** - * @group disconnected - */ - public function testDefineProfile() - { - $profileClass = get_class($this->getMock('Predis\Profile\ServerProfileInterface')); - - ServerProfile::define('mock', $profileClass); - - $this->assertInstanceOf($profileClass, ServerProfile::get('mock')); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Cannot register 'stdClass' as it is not a valid profile class - */ - public function testDefineInvalidProfile() - { - ServerProfile::define('bogus', 'stdClass'); - } - - /** - * @group disconnected - */ - public function testToString() - { - $this->assertEquals('2.0', (string) ServerProfile::get('2.0')); - } - - /** - * @group disconnected - */ - public function testSupportCommand() - { - $profile = ServerProfile::getDefault(); - - $this->assertTrue($profile->supportsCommand('info')); - $this->assertTrue($profile->supportsCommand('INFO')); - - $this->assertFalse($profile->supportsCommand('unknown')); - $this->assertFalse($profile->supportsCommand('UNKNOWN')); - } - - /** - * @group disconnected - */ - public function testSupportCommands() - { - $profile = ServerProfile::getDefault(); - - $this->assertTrue($profile->supportsCommands(array('get', 'set'))); - $this->assertTrue($profile->supportsCommands(array('GET', 'SET'))); - - $this->assertFalse($profile->supportsCommands(array('get', 'unknown'))); - - $this->assertFalse($profile->supportsCommands(array('unknown1', 'unknown2'))); - } - - /** - * @group disconnected - */ - public function testGetCommandClass() - { - $profile = ServerProfile::getDefault(); - - $this->assertSame('Predis\Command\ConnectionPing', $profile->getCommandClass('ping')); - $this->assertSame('Predis\Command\ConnectionPing', $profile->getCommandClass('PING')); - - $this->assertNull($profile->getCommandClass('unknown')); - $this->assertNull($profile->getCommandClass('UNKNOWN')); - } - - /** - * @group disconnected - */ - public function testDefineCommand() - { - $profile = ServerProfile::getDefault(); - $command = $this->getMock('Predis\Command\CommandInterface'); - - $profile->defineCommand('mock', get_class($command)); - - $this->assertTrue($profile->supportsCommand('mock')); - $this->assertTrue($profile->supportsCommand('MOCK')); - - $this->assertSame(get_class($command), $profile->getCommandClass('mock')); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Cannot register 'stdClass' as it is not a valid Redis command - */ - public function testDefineInvalidCommand() - { - $profile = ServerProfile::getDefault(); - - $profile->defineCommand('mock', 'stdClass'); - } - - /** - * @group disconnected - */ - public function testCreateCommandWithoutArguments() - { - $profile = ServerProfile::getDefault(); - - $command = $profile->createCommand('info'); - $this->assertInstanceOf('Predis\Command\CommandInterface', $command); - $this->assertEquals('INFO', $command->getId()); - $this->assertEquals(array(), $command->getArguments()); - } - - /** - * @group disconnected - */ - public function testCreateCommandWithArguments() - { - $profile = ServerProfile::getDefault(); - $arguments = array('foo', 'bar'); - - $command = $profile->createCommand('set', $arguments); - $this->assertInstanceOf('Predis\Command\CommandInterface', $command); - $this->assertEquals('SET', $command->getId()); - $this->assertEquals($arguments, $command->getArguments()); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - * @expectedExceptionMessage 'unknown' is not a registered Redis command - */ - public function testCreateUndefinedCommand() - { - $profile = ServerProfile::getDefault(); - $profile->createCommand('unknown'); - } - - /** - * @group disconnected - */ - public function testGetDefaultProcessor() - { - $profile = ServerProfile::getDefault(); - - $this->assertNull($profile->getProcessor()); - } - - /** - * @group disconnected - */ - public function testSetProcessor() - { - $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - - $profile = ServerProfile::getDefault(); - $profile->setProcessor($processor); - - $this->assertSame($processor, $profile->getProcessor()); - } - - /** - * @group disconnected - */ - public function testSetAndUnsetProcessor() - { - $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - $profile = ServerProfile::getDefault(); - - $profile->setProcessor($processor); - $this->assertSame($processor, $profile->getProcessor()); - - $profile->setProcessor(null); - $this->assertNull($profile->getProcessor()); - } - - /** - * @group disconnected - * @todo Could it be that objects passed to the return callback of a mocked - * method are cloned instead of being passed by reference? - */ - public function testSingleProcessor() - { - $argsRef = null; - - $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - $processor->expects($this->once()) - ->method('process') - ->with($this->isInstanceOf('Predis\Command\CommandInterface')) - ->will($this->returnCallback(function ($cmd) use (&$argsRef) { - $cmd->setRawArguments($argsRef = array_map('strtoupper', $cmd->getArguments())); - })); - - $profile = ServerProfile::getDefault(); - $profile->setProcessor($processor); - $command = $profile->createCommand('set', array('foo', 'bar')); - - $this->assertSame(array('FOO', 'BAR'), $argsRef); - } - - /** - * @group disconnected - */ - public function testChainOfProcessors() - { - $processor = $this->getMock('Predis\Command\Processor\CommandProcessorInterface'); - $processor->expects($this->exactly(2)) - ->method('process'); - - $chain = new ProcessorChain(); - $chain->add($processor); - $chain->add($processor); - - $profile = ServerProfile::getDefault(); - $profile->setProcessor($chain); - $profile->createCommand('info'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion12Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion12Test.php deleted file mode 100644 index 1723dce3c..000000000 --- a/vendor/predis/predis/tests/Predis/Profile/ServerVersion12Test.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * - */ -class ServerVersion12Test extends PredisProfileTestCase -{ - /** - * {@inheritdoc} - */ - public function getProfile($version = null) - { - return new ServerVersion12(); - } - - /** - * {@inheritdoc} - */ - public function getExpectedVersion() - { - return '1.2'; - } - - /** - * {@inheritdoc} - */ - public function getExpectedCommands() - { - return array( - 0 => 'exists', - 1 => 'del', - 2 => 'type', - 3 => 'keys', - 4 => 'randomkey', - 5 => 'rename', - 6 => 'renamenx', - 7 => 'expire', - 8 => 'expireat', - 9 => 'ttl', - 10 => 'move', - 11 => 'sort', - 12 => 'set', - 13 => 'setnx', - 14 => 'mset', - 15 => 'msetnx', - 16 => 'get', - 17 => 'mget', - 18 => 'getset', - 19 => 'incr', - 20 => 'incrby', - 21 => 'decr', - 22 => 'decrby', - 23 => 'rpush', - 24 => 'lpush', - 25 => 'llen', - 26 => 'lrange', - 27 => 'ltrim', - 28 => 'lindex', - 29 => 'lset', - 30 => 'lrem', - 31 => 'lpop', - 32 => 'rpop', - 33 => 'rpoplpush', - 34 => 'sadd', - 35 => 'srem', - 36 => 'spop', - 37 => 'smove', - 38 => 'scard', - 39 => 'sismember', - 40 => 'sinter', - 41 => 'sinterstore', - 42 => 'sunion', - 43 => 'sunionstore', - 44 => 'sdiff', - 45 => 'sdiffstore', - 46 => 'smembers', - 47 => 'srandmember', - 48 => 'zadd', - 49 => 'zincrby', - 50 => 'zrem', - 51 => 'zrange', - 52 => 'zrevrange', - 53 => 'zrangebyscore', - 54 => 'zcard', - 55 => 'zscore', - 56 => 'zremrangebyscore', - 57 => 'ping', - 58 => 'auth', - 59 => 'select', - 60 => 'echo', - 61 => 'quit', - 62 => 'info', - 63 => 'slaveof', - 64 => 'monitor', - 65 => 'dbsize', - 66 => 'flushdb', - 67 => 'flushall', - 68 => 'save', - 69 => 'bgsave', - 70 => 'lastsave', - 71 => 'shutdown', - 72 => 'bgrewriteaof', - ); - } -} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion20Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion20Test.php deleted file mode 100644 index f1f1abaa1..000000000 --- a/vendor/predis/predis/tests/Predis/Profile/ServerVersion20Test.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * - */ -class ServerVersion20Test extends PredisProfileTestCase -{ - /** - * {@inheritdoc} - */ - public function getProfile($version = null) - { - return new ServerVersion20(); - } - - /** - * {@inheritdoc} - */ - public function getExpectedVersion() - { - return '2.0'; - } - - /** - * {@inheritdoc} - */ - public function getExpectedCommands() - { - return array( - 0 => 'exists', - 1 => 'del', - 2 => 'type', - 3 => 'keys', - 4 => 'randomkey', - 5 => 'rename', - 6 => 'renamenx', - 7 => 'expire', - 8 => 'expireat', - 9 => 'ttl', - 10 => 'move', - 11 => 'sort', - 12 => 'set', - 13 => 'setnx', - 14 => 'mset', - 15 => 'msetnx', - 16 => 'get', - 17 => 'mget', - 18 => 'getset', - 19 => 'incr', - 20 => 'incrby', - 21 => 'decr', - 22 => 'decrby', - 23 => 'rpush', - 24 => 'lpush', - 25 => 'llen', - 26 => 'lrange', - 27 => 'ltrim', - 28 => 'lindex', - 29 => 'lset', - 30 => 'lrem', - 31 => 'lpop', - 32 => 'rpop', - 33 => 'rpoplpush', - 34 => 'sadd', - 35 => 'srem', - 36 => 'spop', - 37 => 'smove', - 38 => 'scard', - 39 => 'sismember', - 40 => 'sinter', - 41 => 'sinterstore', - 42 => 'sunion', - 43 => 'sunionstore', - 44 => 'sdiff', - 45 => 'sdiffstore', - 46 => 'smembers', - 47 => 'srandmember', - 48 => 'zadd', - 49 => 'zincrby', - 50 => 'zrem', - 51 => 'zrange', - 52 => 'zrevrange', - 53 => 'zrangebyscore', - 54 => 'zcard', - 55 => 'zscore', - 56 => 'zremrangebyscore', - 57 => 'ping', - 58 => 'auth', - 59 => 'select', - 60 => 'echo', - 61 => 'quit', - 62 => 'info', - 63 => 'slaveof', - 64 => 'monitor', - 65 => 'dbsize', - 66 => 'flushdb', - 67 => 'flushall', - 68 => 'save', - 69 => 'bgsave', - 70 => 'lastsave', - 71 => 'shutdown', - 72 => 'bgrewriteaof', - 73 => 'setex', - 74 => 'append', - 75 => 'substr', - 76 => 'blpop', - 77 => 'brpop', - 78 => 'zunionstore', - 79 => 'zinterstore', - 80 => 'zcount', - 81 => 'zrank', - 82 => 'zrevrank', - 83 => 'zremrangebyrank', - 84 => 'hset', - 85 => 'hsetnx', - 86 => 'hmset', - 87 => 'hincrby', - 88 => 'hget', - 89 => 'hmget', - 90 => 'hdel', - 91 => 'hexists', - 92 => 'hlen', - 93 => 'hkeys', - 94 => 'hvals', - 95 => 'hgetall', - 96 => 'multi', - 97 => 'exec', - 98 => 'discard', - 99 => 'subscribe', - 100 => 'unsubscribe', - 101 => 'psubscribe', - 102 => 'punsubscribe', - 103 => 'publish', - 104 => 'config', - ); - } -} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion22Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion22Test.php deleted file mode 100644 index a62efa091..000000000 --- a/vendor/predis/predis/tests/Predis/Profile/ServerVersion22Test.php +++ /dev/null @@ -1,163 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * - */ -class ServerVersion22Test extends PredisProfileTestCase -{ - /** - * {@inheritdoc} - */ - public function getProfile($version = null) - { - return new ServerVersion22(); - } - - /** - * {@inheritdoc} - */ - public function getExpectedVersion() - { - return '2.2'; - } - - /** - * {@inheritdoc} - */ - public function getExpectedCommands() - { - return array( - 0 => 'exists', - 1 => 'del', - 2 => 'type', - 3 => 'keys', - 4 => 'randomkey', - 5 => 'rename', - 6 => 'renamenx', - 7 => 'expire', - 8 => 'expireat', - 9 => 'ttl', - 10 => 'move', - 11 => 'sort', - 12 => 'set', - 13 => 'setnx', - 14 => 'mset', - 15 => 'msetnx', - 16 => 'get', - 17 => 'mget', - 18 => 'getset', - 19 => 'incr', - 20 => 'incrby', - 21 => 'decr', - 22 => 'decrby', - 23 => 'rpush', - 24 => 'lpush', - 25 => 'llen', - 26 => 'lrange', - 27 => 'ltrim', - 28 => 'lindex', - 29 => 'lset', - 30 => 'lrem', - 31 => 'lpop', - 32 => 'rpop', - 33 => 'rpoplpush', - 34 => 'sadd', - 35 => 'srem', - 36 => 'spop', - 37 => 'smove', - 38 => 'scard', - 39 => 'sismember', - 40 => 'sinter', - 41 => 'sinterstore', - 42 => 'sunion', - 43 => 'sunionstore', - 44 => 'sdiff', - 45 => 'sdiffstore', - 46 => 'smembers', - 47 => 'srandmember', - 48 => 'zadd', - 49 => 'zincrby', - 50 => 'zrem', - 51 => 'zrange', - 52 => 'zrevrange', - 53 => 'zrangebyscore', - 54 => 'zcard', - 55 => 'zscore', - 56 => 'zremrangebyscore', - 57 => 'ping', - 58 => 'auth', - 59 => 'select', - 60 => 'echo', - 61 => 'quit', - 62 => 'info', - 63 => 'slaveof', - 64 => 'monitor', - 65 => 'dbsize', - 66 => 'flushdb', - 67 => 'flushall', - 68 => 'save', - 69 => 'bgsave', - 70 => 'lastsave', - 71 => 'shutdown', - 72 => 'bgrewriteaof', - 73 => 'setex', - 74 => 'append', - 75 => 'substr', - 76 => 'blpop', - 77 => 'brpop', - 78 => 'zunionstore', - 79 => 'zinterstore', - 80 => 'zcount', - 81 => 'zrank', - 82 => 'zrevrank', - 83 => 'zremrangebyrank', - 84 => 'hset', - 85 => 'hsetnx', - 86 => 'hmset', - 87 => 'hincrby', - 88 => 'hget', - 89 => 'hmget', - 90 => 'hdel', - 91 => 'hexists', - 92 => 'hlen', - 93 => 'hkeys', - 94 => 'hvals', - 95 => 'hgetall', - 96 => 'multi', - 97 => 'exec', - 98 => 'discard', - 99 => 'subscribe', - 100 => 'unsubscribe', - 101 => 'psubscribe', - 102 => 'punsubscribe', - 103 => 'publish', - 104 => 'config', - 105 => 'persist', - 106 => 'strlen', - 107 => 'setrange', - 108 => 'getrange', - 109 => 'setbit', - 110 => 'getbit', - 111 => 'rpushx', - 112 => 'lpushx', - 113 => 'linsert', - 114 => 'brpoplpush', - 115 => 'zrevrangebyscore', - 116 => 'watch', - 117 => 'unwatch', - 118 => 'object', - 119 => 'slowlog', - ); - } -} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion24Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion24Test.php deleted file mode 100644 index 899d31901..000000000 --- a/vendor/predis/predis/tests/Predis/Profile/ServerVersion24Test.php +++ /dev/null @@ -1,164 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * - */ -class ServerVersion24Test extends PredisProfileTestCase -{ - /** - * {@inheritdoc} - */ - public function getProfile($version = null) - { - return new ServerVersion24(); - } - - /** - * {@inheritdoc} - */ - public function getExpectedVersion() - { - return '2.4'; - } - - /** - * {@inheritdoc} - */ - public function getExpectedCommands() - { - return array( - 0 => 'exists', - 1 => 'del', - 2 => 'type', - 3 => 'keys', - 4 => 'randomkey', - 5 => 'rename', - 6 => 'renamenx', - 7 => 'expire', - 8 => 'expireat', - 9 => 'ttl', - 10 => 'move', - 11 => 'sort', - 12 => 'set', - 13 => 'setnx', - 14 => 'mset', - 15 => 'msetnx', - 16 => 'get', - 17 => 'mget', - 18 => 'getset', - 19 => 'incr', - 20 => 'incrby', - 21 => 'decr', - 22 => 'decrby', - 23 => 'rpush', - 24 => 'lpush', - 25 => 'llen', - 26 => 'lrange', - 27 => 'ltrim', - 28 => 'lindex', - 29 => 'lset', - 30 => 'lrem', - 31 => 'lpop', - 32 => 'rpop', - 33 => 'rpoplpush', - 34 => 'sadd', - 35 => 'srem', - 36 => 'spop', - 37 => 'smove', - 38 => 'scard', - 39 => 'sismember', - 40 => 'sinter', - 41 => 'sinterstore', - 42 => 'sunion', - 43 => 'sunionstore', - 44 => 'sdiff', - 45 => 'sdiffstore', - 46 => 'smembers', - 47 => 'srandmember', - 48 => 'zadd', - 49 => 'zincrby', - 50 => 'zrem', - 51 => 'zrange', - 52 => 'zrevrange', - 53 => 'zrangebyscore', - 54 => 'zcard', - 55 => 'zscore', - 56 => 'zremrangebyscore', - 57 => 'ping', - 58 => 'auth', - 59 => 'select', - 60 => 'echo', - 61 => 'quit', - 62 => 'info', - 63 => 'slaveof', - 64 => 'monitor', - 65 => 'dbsize', - 66 => 'flushdb', - 67 => 'flushall', - 68 => 'save', - 69 => 'bgsave', - 70 => 'lastsave', - 71 => 'shutdown', - 72 => 'bgrewriteaof', - 73 => 'setex', - 74 => 'append', - 75 => 'substr', - 76 => 'blpop', - 77 => 'brpop', - 78 => 'zunionstore', - 79 => 'zinterstore', - 80 => 'zcount', - 81 => 'zrank', - 82 => 'zrevrank', - 83 => 'zremrangebyrank', - 84 => 'hset', - 85 => 'hsetnx', - 86 => 'hmset', - 87 => 'hincrby', - 88 => 'hget', - 89 => 'hmget', - 90 => 'hdel', - 91 => 'hexists', - 92 => 'hlen', - 93 => 'hkeys', - 94 => 'hvals', - 95 => 'hgetall', - 96 => 'multi', - 97 => 'exec', - 98 => 'discard', - 99 => 'subscribe', - 100 => 'unsubscribe', - 101 => 'psubscribe', - 102 => 'punsubscribe', - 103 => 'publish', - 104 => 'config', - 105 => 'persist', - 106 => 'strlen', - 107 => 'setrange', - 108 => 'getrange', - 109 => 'setbit', - 110 => 'getbit', - 111 => 'rpushx', - 112 => 'lpushx', - 113 => 'linsert', - 114 => 'brpoplpush', - 115 => 'zrevrangebyscore', - 116 => 'watch', - 117 => 'unwatch', - 118 => 'object', - 119 => 'slowlog', - 120 => 'client', - ); - } -} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion26Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion26Test.php deleted file mode 100644 index bc01e5ce3..000000000 --- a/vendor/predis/predis/tests/Predis/Profile/ServerVersion26Test.php +++ /dev/null @@ -1,178 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * - */ -class ServerVersion26Test extends PredisProfileTestCase -{ - /** - * {@inheritdoc} - */ - public function getProfile($version = null) - { - return new ServerVersion26(); - } - - /** - * {@inheritdoc} - */ - public function getExpectedVersion() - { - return '2.6'; - } - - /** - * {@inheritdoc} - */ - public function getExpectedCommands() - { - return array( - 0 => 'exists', - 1 => 'del', - 2 => 'type', - 3 => 'keys', - 4 => 'randomkey', - 5 => 'rename', - 6 => 'renamenx', - 7 => 'expire', - 8 => 'expireat', - 9 => 'ttl', - 10 => 'move', - 11 => 'sort', - 12 => 'dump', - 13 => 'restore', - 14 => 'set', - 15 => 'setnx', - 16 => 'mset', - 17 => 'msetnx', - 18 => 'get', - 19 => 'mget', - 20 => 'getset', - 21 => 'incr', - 22 => 'incrby', - 23 => 'decr', - 24 => 'decrby', - 25 => 'rpush', - 26 => 'lpush', - 27 => 'llen', - 28 => 'lrange', - 29 => 'ltrim', - 30 => 'lindex', - 31 => 'lset', - 32 => 'lrem', - 33 => 'lpop', - 34 => 'rpop', - 35 => 'rpoplpush', - 36 => 'sadd', - 37 => 'srem', - 38 => 'spop', - 39 => 'smove', - 40 => 'scard', - 41 => 'sismember', - 42 => 'sinter', - 43 => 'sinterstore', - 44 => 'sunion', - 45 => 'sunionstore', - 46 => 'sdiff', - 47 => 'sdiffstore', - 48 => 'smembers', - 49 => 'srandmember', - 50 => 'zadd', - 51 => 'zincrby', - 52 => 'zrem', - 53 => 'zrange', - 54 => 'zrevrange', - 55 => 'zrangebyscore', - 56 => 'zcard', - 57 => 'zscore', - 58 => 'zremrangebyscore', - 59 => 'ping', - 60 => 'auth', - 61 => 'select', - 62 => 'echo', - 63 => 'quit', - 64 => 'info', - 65 => 'slaveof', - 66 => 'monitor', - 67 => 'dbsize', - 68 => 'flushdb', - 69 => 'flushall', - 70 => 'save', - 71 => 'bgsave', - 72 => 'lastsave', - 73 => 'shutdown', - 74 => 'bgrewriteaof', - 75 => 'setex', - 76 => 'append', - 77 => 'substr', - 78 => 'blpop', - 79 => 'brpop', - 80 => 'zunionstore', - 81 => 'zinterstore', - 82 => 'zcount', - 83 => 'zrank', - 84 => 'zrevrank', - 85 => 'zremrangebyrank', - 86 => 'hset', - 87 => 'hsetnx', - 88 => 'hmset', - 89 => 'hincrby', - 90 => 'hget', - 91 => 'hmget', - 92 => 'hdel', - 93 => 'hexists', - 94 => 'hlen', - 95 => 'hkeys', - 96 => 'hvals', - 97 => 'hgetall', - 98 => 'multi', - 99 => 'exec', - 100 => 'discard', - 101 => 'subscribe', - 102 => 'unsubscribe', - 103 => 'psubscribe', - 104 => 'punsubscribe', - 105 => 'publish', - 106 => 'config', - 107 => 'persist', - 108 => 'strlen', - 109 => 'setrange', - 110 => 'getrange', - 111 => 'setbit', - 112 => 'getbit', - 113 => 'rpushx', - 114 => 'lpushx', - 115 => 'linsert', - 116 => 'brpoplpush', - 117 => 'zrevrangebyscore', - 118 => 'watch', - 119 => 'unwatch', - 120 => 'object', - 121 => 'slowlog', - 122 => 'client', - 123 => 'pttl', - 124 => 'pexpire', - 125 => 'pexpireat', - 126 => 'psetex', - 127 => 'incrbyfloat', - 128 => 'bitop', - 129 => 'bitcount', - 130 => 'hincrbyfloat', - 131 => 'eval', - 132 => 'evalsha', - 133 => 'script', - 134 => 'time', - ); - } -} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersion28Test.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersion28Test.php deleted file mode 100644 index b9cf28112..000000000 --- a/vendor/predis/predis/tests/Predis/Profile/ServerVersion28Test.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * - */ -class ServerVersion28Test extends PredisProfileTestCase -{ - /** - * {@inheritdoc} - */ - public function getProfile($version = null) - { - return new ServerVersion28(); - } - - /** - * {@inheritdoc} - */ - public function getExpectedVersion() - { - return '2.8'; - } - - /** - * {@inheritdoc} - */ - public function getExpectedCommands() - { - return array( - 0 => 'exists', - 1 => 'del', - 2 => 'type', - 3 => 'keys', - 4 => 'randomkey', - 5 => 'rename', - 6 => 'renamenx', - 7 => 'expire', - 8 => 'expireat', - 9 => 'ttl', - 10 => 'move', - 11 => 'sort', - 12 => 'dump', - 13 => 'restore', - 14 => 'set', - 15 => 'setnx', - 16 => 'mset', - 17 => 'msetnx', - 18 => 'get', - 19 => 'mget', - 20 => 'getset', - 21 => 'incr', - 22 => 'incrby', - 23 => 'decr', - 24 => 'decrby', - 25 => 'rpush', - 26 => 'lpush', - 27 => 'llen', - 28 => 'lrange', - 29 => 'ltrim', - 30 => 'lindex', - 31 => 'lset', - 32 => 'lrem', - 33 => 'lpop', - 34 => 'rpop', - 35 => 'rpoplpush', - 36 => 'sadd', - 37 => 'srem', - 38 => 'spop', - 39 => 'smove', - 40 => 'scard', - 41 => 'sismember', - 42 => 'sinter', - 43 => 'sinterstore', - 44 => 'sunion', - 45 => 'sunionstore', - 46 => 'sdiff', - 47 => 'sdiffstore', - 48 => 'smembers', - 49 => 'srandmember', - 50 => 'zadd', - 51 => 'zincrby', - 52 => 'zrem', - 53 => 'zrange', - 54 => 'zrevrange', - 55 => 'zrangebyscore', - 56 => 'zcard', - 57 => 'zscore', - 58 => 'zremrangebyscore', - 59 => 'ping', - 60 => 'auth', - 61 => 'select', - 62 => 'echo', - 63 => 'quit', - 64 => 'info', - 65 => 'slaveof', - 66 => 'monitor', - 67 => 'dbsize', - 68 => 'flushdb', - 69 => 'flushall', - 70 => 'save', - 71 => 'bgsave', - 72 => 'lastsave', - 73 => 'shutdown', - 74 => 'bgrewriteaof', - 75 => 'setex', - 76 => 'append', - 77 => 'substr', - 78 => 'blpop', - 79 => 'brpop', - 80 => 'zunionstore', - 81 => 'zinterstore', - 82 => 'zcount', - 83 => 'zrank', - 84 => 'zrevrank', - 85 => 'zremrangebyrank', - 86 => 'hset', - 87 => 'hsetnx', - 88 => 'hmset', - 89 => 'hincrby', - 90 => 'hget', - 91 => 'hmget', - 92 => 'hdel', - 93 => 'hexists', - 94 => 'hlen', - 95 => 'hkeys', - 96 => 'hvals', - 97 => 'hgetall', - 98 => 'multi', - 99 => 'exec', - 100 => 'discard', - 101 => 'subscribe', - 102 => 'unsubscribe', - 103 => 'psubscribe', - 104 => 'punsubscribe', - 105 => 'publish', - 106 => 'config', - 107 => 'persist', - 108 => 'strlen', - 109 => 'setrange', - 110 => 'getrange', - 111 => 'setbit', - 112 => 'getbit', - 113 => 'rpushx', - 114 => 'lpushx', - 115 => 'linsert', - 116 => 'brpoplpush', - 117 => 'zrevrangebyscore', - 118 => 'watch', - 119 => 'unwatch', - 120 => 'object', - 121 => 'slowlog', - 122 => 'client', - 123 => 'pttl', - 124 => 'pexpire', - 125 => 'pexpireat', - 126 => 'psetex', - 127 => 'incrbyfloat', - 128 => 'bitop', - 129 => 'bitcount', - 130 => 'hincrbyfloat', - 131 => 'eval', - 132 => 'evalsha', - 133 => 'script', - 134 => 'time', - 135 => 'scan', - 136 => 'sscan', - 137 => 'zscan', - 138 => 'hscan', - ); - } -} diff --git a/vendor/predis/predis/tests/Predis/Profile/ServerVersionNextTest.php b/vendor/predis/predis/tests/Predis/Profile/ServerVersionNextTest.php deleted file mode 100644 index 9a5a1f026..000000000 --- a/vendor/predis/predis/tests/Predis/Profile/ServerVersionNextTest.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Profile; - -/** - * - */ -class ServerVersionNextTest extends PredisProfileTestCase -{ - /** - * {@inheritdoc} - */ - public function getProfile($version = null) - { - return new ServerVersionNext(); - } - - /** - * {@inheritdoc} - */ - public function getExpectedVersion() - { - return '3.0'; - } - - /** - * {@inheritdoc} - */ - public function getExpectedCommands() - { - return array( - 0 => 'exists', - 1 => 'del', - 2 => 'type', - 3 => 'keys', - 4 => 'randomkey', - 5 => 'rename', - 6 => 'renamenx', - 7 => 'expire', - 8 => 'expireat', - 9 => 'ttl', - 10 => 'move', - 11 => 'sort', - 12 => 'dump', - 13 => 'restore', - 14 => 'set', - 15 => 'setnx', - 16 => 'mset', - 17 => 'msetnx', - 18 => 'get', - 19 => 'mget', - 20 => 'getset', - 21 => 'incr', - 22 => 'incrby', - 23 => 'decr', - 24 => 'decrby', - 25 => 'rpush', - 26 => 'lpush', - 27 => 'llen', - 28 => 'lrange', - 29 => 'ltrim', - 30 => 'lindex', - 31 => 'lset', - 32 => 'lrem', - 33 => 'lpop', - 34 => 'rpop', - 35 => 'rpoplpush', - 36 => 'sadd', - 37 => 'srem', - 38 => 'spop', - 39 => 'smove', - 40 => 'scard', - 41 => 'sismember', - 42 => 'sinter', - 43 => 'sinterstore', - 44 => 'sunion', - 45 => 'sunionstore', - 46 => 'sdiff', - 47 => 'sdiffstore', - 48 => 'smembers', - 49 => 'srandmember', - 50 => 'zadd', - 51 => 'zincrby', - 52 => 'zrem', - 53 => 'zrange', - 54 => 'zrevrange', - 55 => 'zrangebyscore', - 56 => 'zcard', - 57 => 'zscore', - 58 => 'zremrangebyscore', - 59 => 'ping', - 60 => 'auth', - 61 => 'select', - 62 => 'echo', - 63 => 'quit', - 64 => 'info', - 65 => 'slaveof', - 66 => 'monitor', - 67 => 'dbsize', - 68 => 'flushdb', - 69 => 'flushall', - 70 => 'save', - 71 => 'bgsave', - 72 => 'lastsave', - 73 => 'shutdown', - 74 => 'bgrewriteaof', - 75 => 'setex', - 76 => 'append', - 77 => 'substr', - 78 => 'blpop', - 79 => 'brpop', - 80 => 'zunionstore', - 81 => 'zinterstore', - 82 => 'zcount', - 83 => 'zrank', - 84 => 'zrevrank', - 85 => 'zremrangebyrank', - 86 => 'hset', - 87 => 'hsetnx', - 88 => 'hmset', - 89 => 'hincrby', - 90 => 'hget', - 91 => 'hmget', - 92 => 'hdel', - 93 => 'hexists', - 94 => 'hlen', - 95 => 'hkeys', - 96 => 'hvals', - 97 => 'hgetall', - 98 => 'multi', - 99 => 'exec', - 100 => 'discard', - 101 => 'subscribe', - 102 => 'unsubscribe', - 103 => 'psubscribe', - 104 => 'punsubscribe', - 105 => 'publish', - 106 => 'config', - 107 => 'persist', - 108 => 'strlen', - 109 => 'setrange', - 110 => 'getrange', - 111 => 'setbit', - 112 => 'getbit', - 113 => 'rpushx', - 114 => 'lpushx', - 115 => 'linsert', - 116 => 'brpoplpush', - 117 => 'zrevrangebyscore', - 118 => 'watch', - 119 => 'unwatch', - 120 => 'object', - 121 => 'slowlog', - 122 => 'client', - 123 => 'pttl', - 124 => 'pexpire', - 125 => 'pexpireat', - 126 => 'psetex', - 127 => 'incrbyfloat', - 128 => 'bitop', - 129 => 'bitcount', - 130 => 'hincrbyfloat', - 131 => 'eval', - 132 => 'evalsha', - 133 => 'script', - 134 => 'time', - 135 => 'scan', - 136 => 'sscan', - 137 => 'zscan', - 138 => 'hscan', - ); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/ProtocolExceptionTest.php b/vendor/predis/predis/tests/Predis/Protocol/ProtocolExceptionTest.php deleted file mode 100644 index a8b2ac7a4..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/ProtocolExceptionTest.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol; - -require_once __DIR__.'/../CommunicationExceptionTest.php'; - -use Predis\CommunicationExceptionTest; -use Predis\Connection\SingleConnectionInterface; - -/** - * - */ -class ProtocolExceptionTest extends CommunicationExceptionTest -{ - /** - * {@inheritdoc} - */ - protected function getException(SingleConnectionInterface $connection, $message, $code = 0, \Exception $inner = null) - { - return new ProtocolException($connection, $message, $code, $inner); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ComposableTextProtocolTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ComposableTextProtocolTest.php deleted file mode 100644 index b9bbc669d..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/ComposableTextProtocolTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class ComposableTextProtocolTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testCustomSerializer() - { - $serializer = $this->getMock('Predis\Protocol\CommandSerializerInterface'); - - $protocol = new ComposableTextProtocol(); - $protocol->setSerializer($serializer); - - $this->assertSame($serializer, $protocol->getSerializer()); - } - - /** - * @group disconnected - */ - public function testCustomReader() - { - $reader = $this->getMock('Predis\Protocol\ResponseReaderInterface'); - - $protocol = new ComposableTextProtocol(); - $protocol->setReader($reader); - - $this->assertSame($reader, $protocol->getReader()); - } - - /** - * @group disconnected - */ - public function testConnectionWrite() - { - $serialized = "*1\r\n$4\r\nPING\r\n"; - - $command = $this->getMock('Predis\Command\CommandInterface'); - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - $serializer = $this->getMock('Predis\Protocol\CommandSerializerInterface'); - - $protocol = new ComposableTextProtocol(); - $protocol->setSerializer($serializer); - - $connection->expects($this->once()) - ->method('writeBytes') - ->with($this->equalTo($serialized)); - - $serializer->expects($this->once()) - ->method('serialize') - ->with($command) - ->will($this->returnValue($serialized)); - - $protocol->write($connection, $command); - } - - /** - * @group disconnected - */ - public function testConnectionRead() - { - $serialized = "*1\r\n$4\r\nPING\r\n"; - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - $reader = $this->getMock('Predis\Protocol\ResponseReaderInterface'); - - $protocol = new ComposableTextProtocol(); - $protocol->setReader($reader); - - $reader->expects($this->once()) - ->method('read') - ->with($connection) - ->will($this->returnValue('bulk')); - - $this->assertSame('bulk', $protocol->read($connection)); - } - - /** - * @group disconnected - */ - public function testSetMultibulkOption() - { - $protocol = new ComposableTextProtocol(); - $reader = $protocol->getReader(); - - $protocol->setOption('iterable_multibulk', true); - $this->assertInstanceOf('Predis\Protocol\Text\ResponseMultiBulkStreamHandler', $reader->getHandler('*')); - - $protocol->setOption('iterable_multibulk', false); - $this->assertInstanceOf('Predis\Protocol\Text\ResponseMultiBulkHandler', $reader->getHandler('*')); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage The option unknown_option is not supported by the current protocol - */ - public function testSetInvalidOption() - { - $protocol = new ComposableTextProtocol(); - $protocol->setOption('unknown_option', true); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseBulkHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseBulkHandlerTest.php deleted file mode 100644 index 930076d74..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseBulkHandlerTest.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class ResponseBulkHandlerTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testZeroLengthBulk() - { - $handler = new ResponseBulkHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->once()) - ->method('readBytes') - ->with($this->equalTo(2)) - ->will($this->returnValue("\r\n")); - - $this->assertSame('', $handler->handle($connection, '0')); - } - - /** - * @group disconnected - */ - public function testBulk() - { - $bulk = "This is a bulk string."; - $bulkLengh = strlen($bulk); - - $handler = new ResponseBulkHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->once()) - ->method('readBytes') - ->with($this->equalTo($bulkLengh + 2)) - ->will($this->returnValue("$bulk\r\n")); - - $this->assertSame($bulk, $handler->handle($connection, (string) $bulkLengh)); - } - - /** - * @group disconnected - */ - public function testNull() - { - $handler = new ResponseBulkHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $this->assertNull($handler->handle($connection, '-1')); - } - - /** - * @group disconnected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Cannot parse 'invalid' as bulk length - */ - public function testInvalidLength() - { - $handler = new ResponseBulkHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $handler->handle($connection, 'invalid'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseErrorHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseErrorHandlerTest.php deleted file mode 100644 index e6b0ef0e0..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseErrorHandlerTest.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class ResponseErrorHandlerTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testOk() - { - $handler = new ResponseErrorHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $message = "ERR Operation against a key holding the wrong kind of value"; - $response = $handler->handle($connection, $message); - - $this->assertInstanceOf('Predis\ResponseError', $response); - $this->assertSame($message, $response->getMessage()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseIntegerHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseIntegerHandlerTest.php deleted file mode 100644 index e30f011d0..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseIntegerHandlerTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class ResponseIntegerHandlerTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testInteger() - { - $handler = new ResponseIntegerHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $this->assertSame(0, $handler->handle($connection, '0')); - $this->assertSame(1, $handler->handle($connection, '1')); - $this->assertSame(10, $handler->handle($connection, '10')); - $this->assertSame(-10, $handler->handle($connection, '-10')); - } - - /** - * @group disconnected - */ - public function testNull() - { - $handler = new ResponseIntegerHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $this->assertNull($handler->handle($connection, 'nil')); - } - - /** - * @group disconnected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Cannot parse 'invalid' as numeric response - */ - public function testInvalid() - { - $handler = new ResponseIntegerHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $handler->handle($connection, 'invalid'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkHandlerTest.php deleted file mode 100644 index d1964a8b6..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkHandlerTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class ResponseMultiBulkHandlerTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testMultiBulk() - { - $handler = new ResponseMultiBulkHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->once()) - ->method('getProtocol') - ->will($this->returnValue(new ComposableTextProtocol())); - - $connection->expects($this->at(1)) - ->method('readLine') - ->will($this->returnValue("$3")); - - $connection->expects($this->at(2)) - ->method('readBytes') - ->will($this->returnValue("foo\r\n")); - - $connection->expects($this->at(3)) - ->method('readLine') - ->will($this->returnValue("$3")); - - $connection->expects($this->at(4)) - ->method('readBytes') - ->will($this->returnValue("bar\r\n")); - - $this->assertSame(array('foo', 'bar'), $handler->handle($connection, '2')); - } - - /** - * @group disconnected - */ - public function testNull() - { - $handler = new ResponseMultiBulkHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $this->assertNull($handler->handle($connection, '-1')); - } - - /** - * @group disconnected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Cannot parse 'invalid' as multi-bulk length - */ - public function testInvalid() - { - $handler = new ResponseMultiBulkHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $handler->handle($connection, 'invalid'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkStreamHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkStreamHandlerTest.php deleted file mode 100644 index cd64704e8..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseMultiBulkStreamHandlerTest.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class ResponseMultiBulkStreamHandlerTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testOk() - { - $handler = new ResponseMultiBulkStreamHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $handler->handle($connection, '1')); - } - - /** - * @group disconnected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Cannot parse 'invalid' as multi-bulk length - */ - public function testInvalid() - { - $handler = new ResponseMultiBulkStreamHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $handler->handle($connection, 'invalid'); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseStatusHandlerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseStatusHandlerTest.php deleted file mode 100644 index fabe14a50..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/ResponseStatusHandlerTest.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; -use Predis\ResponseQueued; - -/** - * - */ -class ResponseStatusHandlerTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testOk() - { - $handler = new ResponseStatusHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $this->assertTrue($handler->handle($connection, 'OK')); - } - - /** - * @group disconnected - */ - public function testQueued() - { - $handler = new ResponseStatusHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $this->assertInstanceOf('Predis\ResponseQueued', $handler->handle($connection, 'QUEUED')); - } - - /** - * @group disconnected - */ - public function testPlainString() - { - $handler = new ResponseStatusHandler(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->never())->method('readLine'); - $connection->expects($this->never())->method('readBytes'); - - $this->assertSame('Background saving started', $handler->handle($connection, 'Background saving started')); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/TextCommandSerializerTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/TextCommandSerializerTest.php deleted file mode 100644 index 5cba9ce6c..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/TextCommandSerializerTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class TextCommandSerializerTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testSerializerIdWithNoArguments() - { - $serializer = new TextCommandSerializer(); - - $command = $this->getMock('Predis\Command\CommandInterface'); - - $command->expects($this->once()) - ->method('getId') - ->will($this->returnValue('PING')); - - $command->expects($this->once()) - ->method('getArguments') - ->will($this->returnValue(array())); - - $result = $serializer->serialize($command); - - $this->assertSame("*1\r\n$4\r\nPING\r\n", $result); - } - - /** - * @group disconnected - */ - public function testSerializerIdWithArguments() - { - $serializer = new TextCommandSerializer(); - - $command = $this->getMock('Predis\Command\CommandInterface'); - - $command->expects($this->once()) - ->method('getId') - ->will($this->returnValue('SET')); - - $command->expects($this->once()) - ->method('getArguments') - ->will($this->returnValue(array('key', 'value'))); - - $result = $serializer->serialize($command); - - $this->assertSame("*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n", $result); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/TextProtocolTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/TextProtocolTest.php deleted file mode 100644 index b1d643c04..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/TextProtocolTest.php +++ /dev/null @@ -1,119 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class TextProtocolTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testConnectionWrite() - { - $serialized = "*1\r\n$4\r\nPING\r\n"; - $protocol = new TextProtocol(); - - $command = $this->getMock('Predis\Command\CommandInterface'); - - $command->expects($this->once()) - ->method('getId') - ->will($this->returnValue('PING')); - - $command->expects($this->once()) - ->method('getArguments') - ->will($this->returnValue(array())); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->once()) - ->method('writeBytes') - ->with($this->equalTo($serialized)); - - $protocol->write($connection, $command); - } - - /** - * @todo Improve test coverage - * @group disconnected - */ - public function testConnectionRead() - { - $protocol = new TextProtocol(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->at(0)) - ->method('readLine') - ->will($this->returnValue("+OK")); - - $connection->expects($this->at(1)) - ->method('readLine') - ->will($this->returnValue("-ERR error message")); - - $connection->expects($this->at(2)) - ->method('readLine') - ->will($this->returnValue(":2")); - - $connection->expects($this->at(3)) - ->method('readLine') - ->will($this->returnValue("$-1")); - - $connection->expects($this->at(4)) - ->method('readLine') - ->will($this->returnValue("*-1")); - - $this->assertTrue($protocol->read($connection)); - $this->assertEquals("ERR error message", $protocol->read($connection)); - $this->assertSame(2, $protocol->read($connection)); - $this->assertNull($protocol->read($connection)); - $this->assertNull($protocol->read($connection)); - } - - /** - * @group disconnected - */ - public function testIterableMultibulkSupport() - { - $protocol = new TextProtocol(); - $protocol->setOption('iterable_multibulk', true); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->once(4)) - ->method('readLine') - ->will($this->returnValue("*1")); - - $this->assertInstanceOf('Predis\Iterator\MultiBulkResponseSimple', $protocol->read($connection)); - } - - /** - * @group disconnected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Unknown prefix: '!' - */ - public function testUnknownResponsePrefix() - { - $protocol = new TextProtocol(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->once()) - ->method('readLine') - ->will($this->returnValue('!')); - - $protocol->read($connection); - } -} diff --git a/vendor/predis/predis/tests/Predis/Protocol/Text/TextResponseReaderTest.php b/vendor/predis/predis/tests/Predis/Protocol/Text/TextResponseReaderTest.php deleted file mode 100644 index a47fd3536..000000000 --- a/vendor/predis/predis/tests/Predis/Protocol/Text/TextResponseReaderTest.php +++ /dev/null @@ -1,123 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Protocol\Text; - -use PredisTestCase; - -/** - * - */ -class TextResponseReaderTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testDefaultHandlers() - { - $reader = new TextResponseReader(); - - $this->assertInstanceOf('Predis\Protocol\Text\ResponseStatusHandler', $reader->getHandler('+')); - $this->assertInstanceOf('Predis\Protocol\Text\ResponseErrorHandler', $reader->getHandler('-')); - $this->assertInstanceOf('Predis\Protocol\Text\ResponseIntegerHandler', $reader->getHandler(':')); - $this->assertInstanceOf('Predis\Protocol\Text\ResponseBulkHandler', $reader->getHandler('$')); - $this->assertInstanceOf('Predis\Protocol\Text\ResponseMultiBulkHandler', $reader->getHandler('*')); - - $this->assertNull($reader->getHandler('!')); - } - - /** - * @group disconnected - */ - public function testReplaceHandler() - { - $handler = $this->getMock('Predis\Protocol\ResponseHandlerInterface'); - - $reader = new TextResponseReader(); - $reader->setHandler('+', $handler); - - $this->assertSame($handler, $reader->getHandler('+')); - } - - /** - * @group disconnected - */ - public function testReadResponse() - { - $reader = new TextResponseReader(); - - $protocol = new ComposableTextProtocol(); - $protocol->setReader($reader); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->at(0)) - ->method('readLine') - ->will($this->returnValue("+OK")); - - $connection->expects($this->at(1)) - ->method('readLine') - ->will($this->returnValue("-ERR error message")); - - $connection->expects($this->at(2)) - ->method('readLine') - ->will($this->returnValue(":2")); - - $connection->expects($this->at(3)) - ->method('readLine') - ->will($this->returnValue("$-1")); - - $connection->expects($this->at(4)) - ->method('readLine') - ->will($this->returnValue("*-1")); - - $this->assertTrue($reader->read($connection)); - $this->assertEquals("ERR error message", $reader->read($connection)); - $this->assertSame(2, $reader->read($connection)); - $this->assertNull($reader->read($connection)); - $this->assertNull($reader->read($connection)); - } - - /** - * @group disconnected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Unexpected empty header - */ - public function testEmptyResponseHeader() - { - $reader = new TextResponseReader(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->once()) - ->method('readLine') - ->will($this->returnValue('')); - - $reader->read($connection); - } - /** - * @group disconnected - * @expectedException Predis\Protocol\ProtocolException - * @expectedExceptionMessage Unknown prefix: '!' - */ - public function testUnknownResponsePrefix() - { - $reader = new TextResponseReader(); - - $connection = $this->getMock('Predis\Connection\ComposableConnectionInterface'); - - $connection->expects($this->once()) - ->method('readLine') - ->will($this->returnValue('!')); - - $reader->read($connection); - } -} diff --git a/vendor/predis/predis/tests/Predis/PubSub/DispatcherLoopTest.php b/vendor/predis/predis/tests/Predis/PubSub/DispatcherLoopTest.php deleted file mode 100644 index e92c8940d..000000000 --- a/vendor/predis/predis/tests/Predis/PubSub/DispatcherLoopTest.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\PubSub; - -use PredisTestCase; -use Predis\Client; - -/** - * @group realm-pubsub - */ -class DispatcherLoopTest extends PredisTestCase -{ - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testDispatcherLoopAgainstRedisServer() - { - $parameters = array( - 'host' => REDIS_SERVER_HOST, - 'port' => REDIS_SERVER_PORT, - 'database' => REDIS_SERVER_DBNUM, - // Prevents suite from handing on broken test - 'read_write_timeout' => 2, - ); - - $options = array('profile' => REDIS_SERVER_VERSION); - - $producer = new Client($parameters, $options); - $producer->connect(); - - $consumer = new Client($parameters, $options); - $consumer->connect(); - - $dispatcher = new DispatcherLoop($consumer); - - $function01 = $this->getMock('stdClass', array('__invoke')); - $function01->expects($this->exactly(2)) - ->method('__invoke') - ->with($this->logicalOr( - $this->equalTo('01:argument'), - $this->equalTo('01:quit') - )) - ->will($this->returnCallback(function ($arg) use ($dispatcher) { - if ($arg === '01:quit') { - $dispatcher->stop(); - } - })); - - $function02 = $this->getMock('stdClass', array('__invoke')); - $function02->expects($this->once()) - ->method('__invoke') - ->with('02:argument'); - - $function03 = $this->getMock('stdClass', array('__invoke')); - $function03->expects($this->never()) - ->method('__invoke'); - - $dispatcher->attachCallback('function:01', $function01); - $dispatcher->attachCallback('function:02', $function02); - $dispatcher->attachCallback('function:03', $function03); - - $producer->publish('function:01', '01:argument'); - $producer->publish('function:02', '02:argument'); - $producer->publish('function:01', '01:quit'); - - $dispatcher->run(); - - $this->assertTrue($consumer->ping()); - } - - /** - * @group connected - */ - public function testDispatcherLoopAgainstRedisServerWithPrefix() - { - $parameters = array( - 'host' => REDIS_SERVER_HOST, - 'port' => REDIS_SERVER_PORT, - 'database' => REDIS_SERVER_DBNUM, - // Prevents suite from handing on broken test - 'read_write_timeout' => 2, - ); - - $options = array('profile' => REDIS_SERVER_VERSION); - - $producerNonPfx = new Client($parameters, $options); - $producerNonPfx->connect(); - - $producerPfx = new Client($parameters, $options + array('prefix' => 'foobar')); - $producerPfx->connect(); - - $consumer = new Client($parameters, $options + array('prefix' => 'foobar')); - $dispatcher = new DispatcherLoop($consumer); - - $callback = $this->getMock('stdClass', array('__invoke')); - $callback->expects($this->exactly(1)) - ->method('__invoke') - ->with($this->equalTo('arg:prefixed')) - ->will($this->returnCallback(function ($arg) use ($dispatcher) { - $dispatcher->stop(); - })); - - $dispatcher->attachCallback('callback', $callback); - - $producerNonPfx->publish('callback', 'arg:non-prefixed'); - $producerPfx->publish('callback', 'arg:prefixed'); - - $dispatcher->run(); - - $this->assertTrue($consumer->ping()); - } -} diff --git a/vendor/predis/predis/tests/Predis/PubSub/PubSubContextTest.php b/vendor/predis/predis/tests/Predis/PubSub/PubSubContextTest.php deleted file mode 100644 index 1cbe8af24..000000000 --- a/vendor/predis/predis/tests/Predis/PubSub/PubSubContextTest.php +++ /dev/null @@ -1,307 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\PubSub; - -use PredisTestCase; -use Predis\Client; -use Predis\Profile\ServerProfile; - -/** - * @group realm-pubsub - */ -class PubSubContextTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The current profile does not support PUB/SUB related commands - */ - public function testPubSubContextRequirePubSubRelatedCommand() - { - $profile = $this->getMock('Predis\Profile\ServerProfileInterface'); - $profile->expects($this->any()) - ->method('supportsCommands') - ->will($this->returnValue(false)); - - $client = new Client(null, array('profile' => $profile)); - $pubsub = new PubSubContext($client); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage Cannot initialize a PUB/SUB context when using aggregated connections - */ - public function testPubSubContextDoesNotWorkOnClusters() - { - $cluster = $this->getMock('Predis\Connection\ClusterConnectionInterface'); - - $client = new Client($cluster); - $pubsub = new PubSubContext($client); - } - - /** - * @group disconnected - */ - public function testConstructorWithoutSubscriptionsDoesNotOpenContext() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $client = $this->getMock('Predis\Client', array('executeCommand'), array($connection)); - $client->expects($this->never())->method('executeCommand'); - - $pubsub = new PubSubContext($client); - } - - /** - * @group disconnected - */ - public function testConstructorWithSubscriptionsOpensContext() - { - $profile = ServerProfile::get(REDIS_SERVER_VERSION); - - $cmdSubscribe = $profile->createCommand('subscribe', array('channel:foo')); - $cmdPsubscribe = $profile->createCommand('psubscribe', array('channels:*')); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->exactly(2))->method('writeCommand'); - - $client = $this->getMock('Predis\Client', array('createCommand', 'writeCommand'), array($connection)); - $client->expects($this->exactly(2)) - ->method('createCommand') - ->with($this->logicalOr($this->equalTo('subscribe'), $this->equalTo('psubscribe'))) - ->will($this->returnCallback(function ($id, $args) use ($profile) { - return $profile->createCommand($id, $args); - })); - - $options = array('subscribe' => 'channel:foo', 'psubscribe' => 'channels:*'); - $pubsub = new PubSubContext($client, $options); - } - - /** - * @group disconnected - */ - public function testClosingContextWithTrueClosesConnection() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); - $client->expects($this->exactly(1))->method('disconnect'); - - $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); - - $connection->expects($this->never())->method('writeCommand'); - - $pubsub->closeContext(true); - } - - /** - * @group disconnected - */ - public function testClosingContextWithFalseSendsUnsubscriptions() - { - $profile = ServerProfile::get(REDIS_SERVER_VERSION); - $classUnsubscribe = $profile->getCommandClass('unsubscribe'); - $classPunsubscribe = $profile->getCommandClass('punsubscribe'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); - - $options = array('subscribe' => 'channel:foo', 'psubscribe' => 'channels:*'); - $pubsub = new PubSubContext($client, $options); - - $connection->expects($this->exactly(2)) - ->method('writeCommand') - ->with($this->logicalOr( - $this->isInstanceOf($classUnsubscribe), - $this->isInstanceOf($classPunsubscribe) - )); - - $pubsub->closeContext(false); - } - - /** - * @group disconnected - */ - public function testIsNotValidWhenNotSubscribed() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $client = $this->getMock('Predis\Client', array('disconnect'), array($connection)); - - $pubsub = new PubSubContext($client); - - $this->assertFalse($pubsub->valid()); - $this->assertNull($pubsub->next()); - } - - /** - * @group disconnected - */ - public function testReadsMessageFromConnection() - { - $rawmessage = array('message', 'channel:foo', 'message from channel'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); - - $client = new Client($connection); - $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); - - $message = $pubsub->current(); - $this->assertSame('message', $message->kind); - $this->assertSame('channel:foo', $message->channel); - $this->assertSame('message from channel', $message->payload); - } - - /** - * @group disconnected - */ - public function testReadsPmessageFromConnection() - { - $rawmessage = array('pmessage', 'channel:*', 'channel:foo', 'message from channel'); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); - - $client = new Client($connection); - $pubsub = new PubSubContext($client, array('psubscribe' => 'channel:*')); - - $message = $pubsub->current(); - $this->assertSame('pmessage', $message->kind); - $this->assertSame('channel:*', $message->pattern); - $this->assertSame('channel:foo', $message->channel); - $this->assertSame('message from channel', $message->payload); - } - - /** - * @group disconnected - */ - public function testReadsSubscriptionMessageFromConnection() - { - $rawmessage = array('subscribe', 'channel:foo', 1); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); - - $client = new Client($connection); - $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); - - $message = $pubsub->current(); - $this->assertSame('subscribe', $message->kind); - $this->assertSame('channel:foo', $message->channel); - $this->assertSame(1, $message->payload); - } - - /** - * @group disconnected - */ - public function testReadsUnsubscriptionMessageFromConnection() - { - $rawmessage = array('unsubscribe', 'channel:foo', 1); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); - - $client = new Client($connection); - $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); - - $message = $pubsub->current(); - $this->assertSame('unsubscribe', $message->kind); - $this->assertSame('channel:foo', $message->channel); - $this->assertSame(1, $message->payload); - } - - /** - * @group disconnected - */ - public function testUnsubscriptionMessageWithZeroChannelCountInvalidatesContext() - { - $rawmessage = array('unsubscribe', 'channel:foo', 0); - - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->once())->method('read')->will($this->returnValue($rawmessage)); - - $client = new Client($connection); - $pubsub = new PubSubContext($client, array('subscribe' => 'channel:foo')); - - $this->assertTrue($pubsub->valid()); - - $message = $pubsub->current(); - $this->assertSame('unsubscribe', $message->kind); - $this->assertSame('channel:foo', $message->channel); - $this->assertSame(0, $message->payload); - - $this->assertFalse($pubsub->valid()); - } - - /** - * @group disconnected - */ - public function testGetUnderlyingClientInstance() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - - $client = new Client($connection); - $pubsub = new PubSubContext($client); - - $this->assertSame($client, $pubsub->getClient()); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testPubSubAgainstRedisServer() - { - $parameters = array( - 'host' => REDIS_SERVER_HOST, - 'port' => REDIS_SERVER_PORT, - 'database' => REDIS_SERVER_DBNUM, - // Prevents suite from handing on broken test - 'read_write_timeout' => 2, - ); - - $options = array('profile' => REDIS_SERVER_VERSION); - $messages = array(); - - $producer = new Client($parameters, $options); - $producer->connect(); - - $consumer = new Client($parameters, $options); - $consumer->connect(); - - $pubsub = new PubSubContext($consumer); - $pubsub->subscribe('channel:foo'); - - $producer->publish('channel:foo', 'message1'); - $producer->publish('channel:foo', 'message2'); - $producer->publish('channel:foo', 'QUIT'); - - foreach ($pubsub as $message) { - if ($message->kind !== 'message') { - continue; - } - $messages[] = ($payload = $message->payload); - if ($payload === 'QUIT') { - $pubsub->closeContext(); - } - } - - $this->assertSame(array('message1', 'message2', 'QUIT'), $messages); - $this->assertFalse($pubsub->valid()); - $this->assertTrue($consumer->ping()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Replication/ReplicationStrategyTest.php b/vendor/predis/predis/tests/Predis/Replication/ReplicationStrategyTest.php deleted file mode 100644 index 474e95e3c..000000000 --- a/vendor/predis/predis/tests/Predis/Replication/ReplicationStrategyTest.php +++ /dev/null @@ -1,373 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Replication; - -use PredisTestCase; -use Predis\Profile\ServerProfile; - -/** - * - */ -class ReplicationStrategyTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testReadCommands() - { - $profile = ServerProfile::getDevelopment(); - $strategy = new ReplicationStrategy(); - - foreach ($this->getExpectedCommands('read') as $commandId) { - $command = $profile->createCommand($commandId); - $this->assertTrue($strategy->isReadOperation($command)); - } - } - - /** - * @group disconnected - */ - public function testWriteCommands() - { - $profile = ServerProfile::getDevelopment(); - $strategy = new ReplicationStrategy(); - - foreach ($this->getExpectedCommands('write') as $commandId) { - $command = $profile->createCommand($commandId); - $this->assertFalse($strategy->isReadOperation($command), $commandId); - } - } - - /** - * @group disconnected - */ - public function testDisallowedCommands() - { - $profile = ServerProfile::getDevelopment(); - $strategy = new ReplicationStrategy(); - - foreach ($this->getExpectedCommands('disallowed') as $commandId) { - $command = $profile->createCommand($commandId); - $this->assertTrue($strategy->isDisallowedOperation($command), $commandId); - } - } - - /** - * @group disconnected - */ - public function testSortCommand() - { - $profile = ServerProfile::getDevelopment(); - $strategy = new ReplicationStrategy(); - - $cmdReadSort = $profile->createCommand('SORT', array('key:list')); - $this->assertTrue($strategy->isReadOperation($cmdReadSort), 'SORT [read-only]'); - - $cmdWriteSort = $profile->createCommand('SORT', array('key:list', array('store' => 'key:stored'))); - $this->assertFalse($strategy->isReadOperation($cmdWriteSort), 'SORT [write with STORE]'); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The command INFO is not allowed in replication mode - */ - public function testUsingDisallowedCommandThrowsException() - { - $profile = ServerProfile::getDevelopment(); - $strategy = new ReplicationStrategy(); - - $command = $profile->createCommand('INFO'); - $strategy->isReadOperation($command); - } - - /** - * @group disconnected - */ - public function testDefaultIsWriteOperation() - { - $strategy = new ReplicationStrategy(); - - $command = $this->getMock('Predis\Command\CommandInterface'); - $command->expects($this->any()) - ->method('getId') - ->will($this->returnValue('CMDTEST')); - - $this->assertFalse($strategy->isReadOperation($command)); - } - - /** - * @group disconnected - */ - public function testCanSetCommandAsReadOperation() - { - $strategy = new ReplicationStrategy(); - - $command = $this->getMock('Predis\Command\CommandInterface'); - $command->expects($this->any()) - ->method('getId') - ->will($this->returnValue('CMDTEST')); - - $strategy->setCommandReadOnly('CMDTEST', true); - $this->assertTrue($strategy->isReadOperation($command)); - } - - /** - * @group disconnected - */ - public function testCanSetCommandAsWriteOperation() - { - $strategy = new ReplicationStrategy(); - - $command = $this->getMock('Predis\Command\CommandInterface'); - $command->expects($this->any()) - ->method('getId') - ->will($this->returnValue('CMDTEST')); - - $strategy->setCommandReadOnly('CMDTEST', false); - $this->assertFalse($strategy->isReadOperation($command)); - - $strategy->setCommandReadOnly('GET', false); - $this->assertFalse($strategy->isReadOperation($command)); - } - - /** - * @group disconnected - */ - public function testCanUseCallableToCheckCommand() - { - $strategy = new ReplicationStrategy(); - $profile = ServerProfile::getDevelopment(); - - $strategy->setCommandReadOnly('SET', function ($command) { - return $command->getArgument(1) === true; - }); - - $command = $profile->createCommand('SET', array('trigger', false)); - $this->assertFalse($strategy->isReadOperation($command)); - - $command = $profile->createCommand('SET', array('trigger', true)); - $this->assertTrue($strategy->isReadOperation($command)); - } - - /** - * @group disconnected - */ - public function testSetLuaScriptAsReadOperation() - { - $strategy = new ReplicationStrategy(); - $profile = ServerProfile::getDevelopment(); - - $writeScript = 'redis.call("set", "foo", "bar")'; - $readScript = 'return true'; - - $strategy->setScriptReadOnly($readScript, true); - - $cmdEval = $profile->createCommand('EVAL', array($writeScript)); - $cmdEvalSHA = $profile->createCommand('EVALSHA', array(sha1($writeScript))); - $this->assertFalse($strategy->isReadOperation($cmdEval)); - $this->assertFalse($strategy->isReadOperation($cmdEvalSHA)); - - $cmdEval = $profile->createCommand('EVAL', array($readScript)); - $cmdEvalSHA = $profile->createCommand('EVALSHA', array(sha1($readScript))); - $this->assertTrue($strategy->isReadOperation($cmdEval)); - $this->assertTrue($strategy->isReadOperation($cmdEvalSHA)); - } - - /** - * @group disconnected - */ - public function testSetLuaScriptAsReadOperationWorksWithScriptedCommand() - { - $strategy = new ReplicationStrategy(); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript')); - $command->expects($this->any()) - ->method('getScript') - ->will($this->returnValue($script = 'return true')); - - $strategy->setScriptReadOnly($script, function ($command) { - return $command->getArgument(2) === true; - }); - - $command->setArguments(array(false)); - $this->assertFalse($strategy->isReadOperation($command)); - - $command->setArguments(array(true)); - $this->assertTrue($strategy->isReadOperation($command)); - } - - /** - * @group disconnected - */ - public function testSetLuaScriptAsReadOperationWorksWithScriptedCommandAndCallableCheck() - { - $strategy = new ReplicationStrategy(); - - $command = $this->getMock('Predis\Command\ScriptedCommand', array('getScript')); - $command->expects($this->any()) - ->method('getScript') - ->will($this->returnValue($script = 'return true')); - - $command->setArguments(array('trigger', false)); - - $strategy->setScriptReadOnly($script, true); - - $this->assertTrue($strategy->isReadOperation($command)); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns the list of expected supported commands. - * - * @param string $type Optional type of command (based on its keys) - * @return array - */ - protected function getExpectedCommands($type = null) - { - $commands = array( - /* commands operating on the connection */ - 'AUTH' => 'read', - 'SELECT' => 'read', - 'ECHO' => 'read', - 'QUIT' => 'read', - 'OBJECT' => 'read', - 'BITCOUNT' => 'read', - 'TIME' => 'read', - 'SHUTDOWN' => 'disallowed', - 'INFO' => 'disallowed', - 'DBSIZE' => 'disallowed', - 'LASTSAVE' => 'disallowed', - 'CONFIG' => 'disallowed', - 'MONITOR' => 'disallowed', - 'SLAVEOF' => 'disallowed', - 'SAVE' => 'disallowed', - 'BGSAVE' => 'disallowed', - 'BGREWRITEAOF' => 'disallowed', - 'SLOWLOG' => 'disallowed', - - /* commands operating on the key space */ - 'EXISTS' => 'read', - 'DEL' => 'write', - 'TYPE' => 'read', - 'EXPIRE' => 'write', - 'EXPIREAT' => 'write', - 'PERSIST' => 'write', - 'PEXPIRE' => 'write', - 'PEXPIREAT' => 'write', - 'TTL' => 'read', - 'PTTL' => 'write', - 'SORT' => 'variable', - 'KEYS' => 'read', - 'SCAN' => 'read', - 'RANDOMKEY' => 'read', - - /* commands operating on string values */ - 'APPEND' => 'write', - 'DECR' => 'write', - 'DECRBY' => 'write', - 'GET' => 'read', - 'GETBIT' => 'read', - 'MGET' => 'read', - 'SET' => 'write', - 'GETRANGE' => 'read', - 'GETSET' => 'write', - 'INCR' => 'write', - 'INCRBY' => 'write', - 'SETBIT' => 'write', - 'SETEX' => 'write', - 'MSET' => 'write', - 'MSETNX' => 'write', - 'SETNX' => 'write', - 'SETRANGE' => 'write', - 'STRLEN' => 'read', - 'SUBSTR' => 'read', - - /* commands operating on lists */ - 'LINSERT' => 'write', - 'LINDEX' => 'read', - 'LLEN' => 'read', - 'LPOP' => 'write', - 'RPOP' => 'write', - 'BLPOP' => 'write', - 'BRPOP' => 'write', - 'LPUSH' => 'write', - 'LPUSHX' => 'write', - 'RPUSH' => 'write', - 'RPUSHX' => 'write', - 'LRANGE' => 'read', - 'LREM' => 'write', - 'LSET' => 'write', - 'LTRIM' => 'write', - - /* commands operating on sets */ - 'SADD' => 'write', - 'SCARD' => 'read', - 'SISMEMBER' => 'read', - 'SMEMBERS' => 'read', - 'SSCAN' => 'read', - 'SRANDMEMBER' => 'read', - 'SPOP' => 'write', - 'SREM' => 'write', - 'SINTER' => 'read', - 'SUNION' => 'read', - 'SDIFF' => 'read', - - /* commands operating on sorted sets */ - 'ZADD' => 'write', - 'ZCARD' => 'read', - 'ZCOUNT' => 'read', - 'ZINCRBY' => 'write', - 'ZRANGE' => 'read', - 'ZRANGEBYSCORE' => 'read', - 'ZRANK' => 'read', - 'ZREM' => 'write', - 'ZREMRANGEBYRANK' => 'write', - 'ZREMRANGEBYSCORE' => 'write', - 'ZREVRANGE' => 'read', - 'ZREVRANGEBYSCORE' => 'read', - 'ZREVRANK' => 'read', - 'ZSCORE' => 'read', - 'ZSCAN' => 'read', - - /* commands operating on hashes */ - 'HDEL' => 'write', - 'HEXISTS' => 'read', - 'HGET' => 'read', - 'HGETALL' => 'read', - 'HMGET' => 'read', - 'HINCRBY' => 'write', - 'HINCRBYFLOAT' => 'write', - 'HKEYS' => 'read', - 'HLEN' => 'read', - 'HSET' => 'write', - 'HSETNX' => 'write', - 'HVALS' => 'read', - 'HSCAN' => 'read', - - /* scripting */ - 'EVAL' => 'write', - 'EVALSHA' => 'write', - ); - - if (isset($type)) { - $commands = array_filter($commands, function ($expectedType) use ($type) { - return $expectedType === $type; - }); - } - - return array_keys($commands); - } -} diff --git a/vendor/predis/predis/tests/Predis/ResponseErrorTest.php b/vendor/predis/predis/tests/Predis/ResponseErrorTest.php deleted file mode 100644 index b3a1f6710..000000000 --- a/vendor/predis/predis/tests/Predis/ResponseErrorTest.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use PredisTestCase; - -/** - * - */ -class ResponseErrorTest extends PredisTestCase -{ - const ERR_WRONG_KEY_TYPE = 'ERR Operation against a key holding the wrong kind of value'; - - /** - * @group disconnected - */ - public function testResponseErrorClass() - { - $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); - - $this->assertInstanceOf('Predis\ResponseErrorInterface', $error); - $this->assertInstanceOf('Predis\ResponseObjectInterface', $error); - } - - /** - * @group disconnected - */ - public function testErrorMessage() - { - $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); - - $this->assertEquals(self::ERR_WRONG_KEY_TYPE, $error->getMessage()); - } - - /** - * @group disconnected - */ - public function testErrorType() - { - $exception = new ResponseError(self::ERR_WRONG_KEY_TYPE); - - $this->assertEquals('ERR', $exception->getErrorType()); - } - - /** - * @group disconnected - */ - public function testToString() - { - $error = new ResponseError(self::ERR_WRONG_KEY_TYPE); - - $this->assertEquals(self::ERR_WRONG_KEY_TYPE, (string) $error); - } -} diff --git a/vendor/predis/predis/tests/Predis/ResponseQueuedTest.php b/vendor/predis/predis/tests/Predis/ResponseQueuedTest.php deleted file mode 100644 index 4b2b4c71c..000000000 --- a/vendor/predis/predis/tests/Predis/ResponseQueuedTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use PredisTestCase; - -/** - * - */ -class ResponseQueuedTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testResponseQueuedClass() - { - $queued = new ResponseQueued(); - - $this->assertInstanceOf('Predis\ResponseObjectInterface', $queued); - } - - /** - * @group disconnected - */ - public function testToString() - { - $queued = new ResponseQueued(); - - $this->assertEquals('QUEUED', (string) $queued); - } - - /** - * @group disconnected - */ - public function testQueuedProperty() - { - $queued = new ResponseQueued(); - - $this->assertTrue(isset($queued->queued)); - $this->assertTrue($queued->queued); - } -} diff --git a/vendor/predis/predis/tests/Predis/ServerExceptionTest.php b/vendor/predis/predis/tests/Predis/ServerExceptionTest.php deleted file mode 100644 index d9aa7a155..000000000 --- a/vendor/predis/predis/tests/Predis/ServerExceptionTest.php +++ /dev/null @@ -1,69 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis; - -use PredisTestCase; - -/** - * - */ -class ServerExceptionTest extends PredisTestCase -{ - const ERR_WRONG_KEY_TYPE = 'ERR Operation against a key holding the wrong kind of value'; - - /** - * @group disconnected - */ - public function testExceptionMessage() - { - $this->setExpectedException('Predis\ServerException', self::ERR_WRONG_KEY_TYPE); - - throw new ServerException(self::ERR_WRONG_KEY_TYPE); - } - - /** - * @group disconnected - */ - public function testExceptionClass() - { - $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); - - $this->assertInstanceOf('Predis\ServerException', $exception); - $this->assertInstanceOf('Predis\ResponseErrorInterface', $exception); - $this->assertInstanceOf('Predis\ResponseObjectInterface', $exception); - $this->assertInstanceOf('Predis\PredisException', $exception); - } - - /** - * @group disconnected - */ - public function testErrorType() - { - $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); - - $this->assertEquals('ERR', $exception->getErrorType()); - } - - /** - * @group disconnected - */ - public function testToResponseError() - { - $exception = new ServerException(self::ERR_WRONG_KEY_TYPE); - $error = $exception->toResponseError(); - - $this->assertInstanceOf('Predis\ResponseError', $error); - - $this->assertEquals($exception->getMessage(), $error->getMessage()); - $this->assertEquals($exception->getErrorType(), $error->getErrorType()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Transaction/AbortedMultiExecExceptionTest.php b/vendor/predis/predis/tests/Predis/Transaction/AbortedMultiExecExceptionTest.php deleted file mode 100644 index fc10e92c8..000000000 --- a/vendor/predis/predis/tests/Predis/Transaction/AbortedMultiExecExceptionTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Transaction; - -use PredisTestCase; -use Predis\Client; - -/** - * - */ -class AbortedMultiExecExceptionTest extends PredisTestCase -{ - /** - * @group disconnected - */ - public function testExceptionClass() - { - $client = new Client(); - $transaction = new MultiExecContext($client); - $exception = new AbortedMultiExecException($transaction, 'ABORTED'); - - $this->assertInstanceOf('Predis\PredisException', $exception); - $this->assertSame('ABORTED', $exception->getMessage()); - $this->assertSame($transaction, $exception->getTransaction()); - } -} diff --git a/vendor/predis/predis/tests/Predis/Transaction/MultiExecContextTest.php b/vendor/predis/predis/tests/Predis/Transaction/MultiExecContextTest.php deleted file mode 100644 index 6ae5553ac..000000000 --- a/vendor/predis/predis/tests/Predis/Transaction/MultiExecContextTest.php +++ /dev/null @@ -1,778 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Predis\Transaction; - -use PredisTestCase; -use Predis\Client; -use Predis\ResponseQueued; -use Predis\ServerException; -use Predis\Command\CommandInterface; - -/** - * @group realm-transaction - */ -class MultiExecContextTest extends PredisTestCase -{ - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The current profile does not support MULTI, EXEC and DISCARD - */ - public function testThrowsExceptionOnUnsupportedMultiExecInProfile() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $client = new Client($connection, array('profile' => '1.2')); - $tx = new MultiExecContext($client); - } - - /** - * @group disconnected - * @expectedException Predis\NotSupportedException - * @expectedExceptionMessage The current profile does not support WATCH and UNWATCH - */ - public function testThrowsExceptionOnUnsupportedWatchUnwatchInProfile() - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $client = new Client($connection, array('profile' => '2.0')); - $tx = new MultiExecContext($client, array('options' => 'cas')); - - $tx->watch('foo'); - } - - /** - * @group disconnected - */ - public function testExecutionWithFluentInterface() - { - $commands = array(); - $expected = array('one', 'two', 'three'); - - $callback = $this->getExecuteCallback($expected, $commands); - $tx = $this->getMockedTransaction($callback); - - $this->assertSame($expected, $tx->echo('one')->echo('two')->echo('three')->execute()); - $this->assertSame(array('MULTI', 'ECHO', 'ECHO', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - */ - public function testExecutionWithCallable() - { - $commands = array(); - $expected = array('one', 'two', 'three'); - - $callback = $this->getExecuteCallback($expected, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = $tx->execute(function ($tx) { - $tx->echo('one'); - $tx->echo('two'); - $tx->echo('three'); - }); - - $this->assertSame($expected, $replies); - $this->assertSame(array('MULTI', 'ECHO', 'ECHO', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - */ - public function testCannotMixExecutionWithFluentInterfaceAndCallable() - { - $exception = null; - - $commands = array(); - - $callback = $this->getExecuteCallback(null, $commands); - $tx = $this->getMockedTransaction($callback); - - $exception = null; - - try { - $tx->echo('foo')->execute(function ($tx) { - $tx->echo('bar'); - }); - } catch (\Exception $exception) { - // NOOP - } - - $this->assertInstanceOf('Predis\ClientException', $exception); - $this->assertSame(array('MULTI', 'ECHO', 'DISCARD'), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - */ - public function testEmptyTransactionDoesNotSendMultiExecCommands() - { - $commands = array(); - - $callback = $this->getExecuteCallback(null, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = $tx->execute(function ($tx) { - // NOOP - }); - - $this->assertNull($replies); - $this->assertSame(array(), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - * @expectedException Predis\ClientException - * @expectedExceptionMessage Cannot invoke 'execute' or 'exec' inside an active client transaction block - */ - public function testThrowsExceptionOnExecInsideTransactionBlock() - { - $commands = array(); - - $callback = $this->getExecuteCallback(null, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = $tx->execute(function ($tx) { - $tx->exec(); - }); - - $this->assertNull($replies); - $this->assertSame(array(), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - */ - public function testEmptyTransactionIgnoresDiscard() - { - $commands = array(); - - $callback = $this->getExecuteCallback(null, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = $tx->execute(function ($tx) { - $tx->discard(); - }); - - $this->assertNull($replies); - $this->assertSame(array(), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - */ - public function testTransactionWithCommandsSendsDiscard() - { - $commands = array(); - - $callback = $this->getExecuteCallback(null, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = $tx->execute(function ($tx) { - $tx->set('foo', 'bar'); - $tx->get('foo'); - $tx->discard(); - }); - - $this->assertNull($replies); - $this->assertSame(array('MULTI', 'SET', 'GET', 'DISCARD'), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - */ - public function testSendMultiOnCommandsFollowingDiscard() - { - $commands = array(); - $expected = array('after DISCARD'); - - $callback = $this->getExecuteCallback($expected, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = $tx->execute(function ($tx) { - $tx->echo('before DISCARD'); - $tx->discard(); - $tx->echo('after DISCARD'); - }); - - $this->assertSame($replies, $expected); - $this->assertSame(array('MULTI', 'ECHO', 'DISCARD', 'MULTI', 'ECHO', 'EXEC'), self::commandsToIDs($commands)); - } - /** - * @group disconnected - * @expectedException Predis\ClientException - */ - public function testThrowsExceptionOnWatchInsideMulti() - { - $callback = $this->getExecuteCallback(); - $tx = $this->getMockedTransaction($callback); - - $tx->echo('foobar')->watch('foo')->execute(); - } - - /** - * @group disconnected - */ - public function testUnwatchInsideMulti() - { - $commands = array(); - $expected = array('foobar', true); - - $callback = $this->getExecuteCallback($expected, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = $tx->echo('foobar')->unwatch('foo')->execute(); - - $this->assertSame($replies, $expected); - $this->assertSame(array('MULTI', 'ECHO', 'UNWATCH', 'EXEC'), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - */ - public function testAutomaticWatchInOptions() - { - $txCommands = $casCommands = array(); - $expected = array('bar', 'piyo'); - $options = array('watch' => array('foo', 'hoge')); - - $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); - $tx = $this->getMockedTransaction($callback, $options); - - $replies = $tx->execute(function ($tx) { - $tx->get('foo'); - $tx->get('hoge'); - }); - - $this->assertSame($replies, $expected); - $this->assertSame(array('WATCH'), self::commandsToIDs($casCommands)); - $this->assertSame(array('foo', 'hoge'), $casCommands[0]->getArguments()); - $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); - } - /** - * @group disconnected - */ - public function testCheckAndSetWithFluentInterface() - { - $txCommands = $casCommands = array(); - $expected = array('bar', 'piyo'); - $options = array('cas' => true, 'watch' => array('foo', 'hoge')); - - $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); - $tx = $this->getMockedTransaction($callback, $options); - - $tx->watch('foobar'); - $this->assertSame('DUMMY_REPLY', $tx->get('foo')); - $this->assertSame('DUMMY_REPLY', $tx->get('hoge')); - - $replies = $tx->multi() - ->get('foo') - ->get('hoge') - ->execute(); - - $this->assertSame($replies, $expected); - $this->assertSame(array('WATCH', 'WATCH', 'GET', 'GET'), self::commandsToIDs($casCommands)); - $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); - } - - /** - * @group disconnected - */ - public function testCheckAndSetWithBlock() - { - $txCommands = $casCommands = array(); - $expected = array('bar', 'piyo'); - $options = array('cas' => true, 'watch' => array('foo', 'hoge')); - - $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); - $tx = $this->getMockedTransaction($callback, $options); - - $test = $this; - $replies = $tx->execute(function ($tx) use ($test) { - $tx->watch('foobar'); - - $reply1 = $tx->get('foo'); - $reply2 = $tx->get('hoge'); - - $test->assertSame('DUMMY_REPLY', $reply1); - $test->assertSame('DUMMY_REPLY', $reply2); - - $tx->multi(); - - $tx->get('foo'); - $tx->get('hoge'); - }); - - $this->assertSame($replies, $expected); - $this->assertSame(array('WATCH', 'WATCH', 'GET', 'GET'), self::commandsToIDs($casCommands)); - $this->assertSame(array('MULTI', 'GET', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); - } - - /** - * @group disconnected - */ - public function testCheckAndSetWithEmptyBlock() - { - $txCommands = $casCommands = array(); - $options = array('cas' => true); - - $callback = $this->getExecuteCallback(array(), $txCommands, $casCommands); - $tx = $this->getMockedTransaction($callback, $options); - - $tx->execute(function ($tx) { - $tx->multi(); - }); - - $this->assertSame(array(), self::commandsToIDs($casCommands)); - $this->assertSame(array(), self::commandsToIDs($txCommands)); - } - - /** - * @group disconnected - */ - public function testCheckAndSetWithoutExec() - { - $txCommands = $casCommands = array(); - $options = array('cas' => true); - - $callback = $this->getExecuteCallback(array(), $txCommands, $casCommands); - $tx = $this->getMockedTransaction($callback, $options); - - $tx->execute(function ($tx) { - $bar = $tx->get('foo'); - $tx->set('hoge', 'piyo'); - }); - - $this->assertSame(array('GET', 'SET'), self::commandsToIDs($casCommands)); - $this->assertSame(array(), self::commandsToIDs($txCommands)); - } - - /** - * @group disconnected - * @expectedException InvalidArgumentException - * @expectedExceptionMessage Automatic retries can be used only when a transaction block is provided - */ - public function testThrowsExceptionOnAutomaticRetriesWithFluentInterface() - { - $options = array('retry' => 1); - - $callback = $this->getExecuteCallback(); - $tx = $this->getMockedTransaction($callback, $options); - - $tx->echo('message')->execute(); - } - - /** - * @group disconnected - */ - public function testAutomaticRetryOnServerSideTransactionAbort() - { - $casCommands = $txCommands = array(); - $expected = array('bar'); - $options = array('watch' => array('foo', 'bar'), 'retry' => ($attempts = 2) + 1); - - $sentinel = $this->getMock('stdClass', array('signal')); - $sentinel->expects($this->exactly($attempts))->method('signal'); - - $callback = $this->getExecuteCallback($expected, $txCommands, $casCommands); - $tx = $this->getMockedTransaction($callback, $options); - - $replies = $tx->execute(function ($tx) use ($sentinel, &$attempts) { - $tx->get('foo'); - - if ($attempts > 0) { - $attempts -= 1; - $sentinel->signal(); - - $tx->echo('!!ABORT!!'); - } - }); - - $this->assertSame($replies, $expected); - $this->assertSame(array('WATCH'), self::commandsToIDs($casCommands)); - $this->assertSame(array('foo', 'bar'), $casCommands[0]->getArguments()); - $this->assertSame(array('MULTI', 'GET', 'EXEC'), self::commandsToIDs($txCommands)); - } - - /** - * @group disconnected - * @expectedException Predis\Transaction\AbortedMultiExecException - */ - public function testThrowsExceptionOnServerSideTransactionAbort() - { - $callback = $this->getExecuteCallback(); - $tx = $this->getMockedTransaction($callback); - - $replies = $tx->execute(function ($tx) { - $tx->echo('!!ABORT!!'); - }); - } - - /** - * @group disconnected - */ - public function testHandlesStandardExceptionsInBlock() - { - $exception = null; - - $commands = array(); - $expected = array('foobar', true); - - $callback = $this->getExecuteCallback($expected, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = null; - - try { - $replies = $tx->execute(function ($tx) { - $tx->set('foo', 'bar'); - $tx->get('foo'); - - throw new \RuntimeException('TEST'); - }); - } catch (\Exception $exception) { - // NOOP - } - - $this->assertNull($replies, $expected); - $this->assertSame(array('MULTI', 'SET', 'GET', 'DISCARD'), self::commandsToIDs($commands)); - } - - /** - * @group disconnected - */ - public function testHandlesServerExceptionsInBlock() - { - $commands = array(); - $expected = array('foobar', true); - - $callback = $this->getExecuteCallback($expected, $commands); - $tx = $this->getMockedTransaction($callback); - - $replies = null; - - try { - $replies = $tx->execute(function ($tx) { - $tx->set('foo', 'bar'); - $tx->echo('ERR Invalid operation'); - $tx->get('foo'); - }); - } catch (ServerException $exception) { - $tx->discard(); - } - - $this->assertNull($replies); - $this->assertSame(array('MULTI', 'SET', 'ECHO', 'DISCARD'), self::commandsToIDs($commands)); - } - - // ******************************************************************** // - // ---- INTEGRATION TESTS --------------------------------------------- // - // ******************************************************************** // - - /** - * @group connected - */ - public function testIntegrationHandlesStandardExceptionsInBlock() - { - $exception = null; - - $client = $this->getClient(); - - try { - $client->multiExec(function ($tx) { - $tx->set('foo', 'bar'); - throw new \RuntimeException("TEST"); - }); - } catch (\Exception $exception) { - // NOOP - } - - $this->assertInstanceOf('RuntimeException', $exception); - $this->assertFalse($client->exists('foo')); - } - - /** - * @group connected - */ - public function testIntegrationThrowsExceptionOnRedisErrorInBlock() - { - $exception = null; - - $client = $this->getClient(); - $value = (string) rand(); - - try { - $client->multiExec(function ($tx) use ($value) { - $tx->set('foo', 'bar'); - $tx->lpush('foo', 'bar'); - $tx->set('foo', $value); - }); - } catch (ServerException $exception) { - // NOOP - } - - $this->assertInstanceOf('Predis\ResponseErrorInterface', $exception); - $this->assertSame($value, $client->get('foo')); - } - - /** - * @group connected - */ - public function testIntegrationReturnsErrorObjectOnRedisErrorInBlock() - { - $client = $this->getClient(array(), array('exceptions' => false)); - - $replies = $client->multiExec(function ($tx) { - $tx->set('foo', 'bar'); - $tx->lpush('foo', 'bar'); - $tx->echo('foobar'); - }); - - $this->assertTrue($replies[0]); - $this->assertInstanceOf('Predis\ResponseErrorInterface', $replies[1]); - $this->assertSame('foobar', $replies[2]); - } - - /** - * @group connected - */ - public function testIntegrationSendMultiOnCommandsAfterDiscard() - { - $client = $this->getClient(); - - $replies = $client->multiExec(function ($tx) { - $tx->set('foo', 'bar'); - $tx->discard(); - $tx->set('hoge', 'piyo'); - }); - - $this->assertSame(1, count($replies)); - $this->assertFalse($client->exists('foo')); - $this->assertTrue($client->exists('hoge')); - } - - /** - * @group connected - */ - public function testIntegrationWritesOnWatchedKeysAbortTransaction() - { - $exception = null; - - $client1 = $this->getClient(); - $client2 = $this->getClient(); - - try { - $client1->multiExec(array('watch' => 'sentinel'), function ($tx) use ($client2) { - $tx->set('sentinel', 'client1'); - $tx->get('sentinel'); - $client2->set('sentinel', 'client2'); - }); - } catch (AbortedMultiExecException $exception) { - // NOOP - } - - $this->assertInstanceOf('Predis\Transaction\AbortedMultiExecException', $exception); - $this->assertSame('client2', $client1->get('sentinel')); - } - - /** - * @group connected - */ - public function testIntegrationCheckAndSetWithDiscardAndRetry() - { - $client = $this->getClient(); - - $client->set('foo', 'bar'); - $options = array('watch' => 'foo', 'cas' => true); - - $replies = $client->multiExec($options, function ($tx) { - $tx->watch('foobar'); - $foo = $tx->get('foo'); - - $tx->multi(); - $tx->set('foobar', $foo); - $tx->discard(); - $tx->mget('foo', 'foobar'); - }); - - $this->assertInternalType('array', $replies); - $this->assertSame(array(array('bar', null)), $replies); - - $hijack = true; - $client2 = $this->getClient(); - $client->set('foo', 'bar'); - - $options = array('watch' => 'foo', 'cas' => true, 'retry' => 1); - $replies = $client->multiExec($options, function ($tx) use ($client2, &$hijack) { - $foo = $tx->get('foo'); - $tx->multi(); - - $tx->set('foobar', $foo); - $tx->discard(); - - if ($hijack) { - $hijack = false; - $client2->set('foo', 'hijacked!'); - } - - $tx->mget('foo', 'foobar'); - }); - - $this->assertInternalType('array', $replies); - $this->assertSame(array(array('hijacked!', null)), $replies); - } - - // ******************************************************************** // - // ---- HELPER METHODS ------------------------------------------------ // - // ******************************************************************** // - - /** - * Returns a mocked instance of Predis\Connection\SingleConnectionInterface - * usingthe specified callback to return values from executeCommand(). - * - * @param \Closure $executeCallback - * @return \Predis\Connection\SingleConnectionInterface - */ - protected function getMockedConnection($executeCallback) - { - $connection = $this->getMock('Predis\Connection\SingleConnectionInterface'); - $connection->expects($this->any()) - ->method('executeCommand') - ->will($this->returnCallback($executeCallback)); - - return $connection; - } - - /** - * Returns a mocked instance of Predis\Transaction\MultiExecContext using - * the specified callback to return values from the executeCommand method - * of the underlying connection. - * - * @param \Closure $executeCallback - * @param array $options - * @return MultiExecContext - */ - protected function getMockedTransaction($executeCallback, $options = array()) - { - $connection = $this->getMockedConnection($executeCallback); - $client = new Client($connection); - $transaction = new MultiExecContext($client, $options); - - return $transaction; - } - - /** - * Returns a callback that emulates a server-side MULTI/EXEC transaction context. - * - * @param array $expected Expected responses. - * @param array $commands Reference to an array storing the whole flow of commands. - * @param array $cas Check and set operations performed by the transaction. - * @return \Closure - */ - protected function getExecuteCallback($expected = array(), &$commands = array(), &$cas = array()) - { - $multi = $watch = $abort = false; - - return function (CommandInterface $command) use (&$expected, &$commands, &$cas, &$multi, &$watch, &$abort) { - $cmd = $command->getId(); - - if ($multi || $cmd === 'MULTI') { - $commands[] = $command; - } else { - $cas[] = $command; - } - - switch ($cmd) { - case 'WATCH': - if ($multi) { - throw new ServerException("ERR $cmd inside MULTI is not allowed"); - } - - return $watch = true; - - case 'MULTI': - if ($multi) { - throw new ServerException("ERR MULTI calls can not be nested"); - } - - return $multi = true; - - case 'EXEC': - if (!$multi) { - throw new ServerException("ERR $cmd without MULTI"); - } - - $watch = $multi = false; - - if ($abort) { - $commands = $cas = array(); - $abort = false; - - return null; - } - - return $expected; - - case 'DISCARD': - if (!$multi) { - throw new ServerException("ERR $cmd without MULTI"); - } - - $watch = $multi = false; - - return true; - - case 'ECHO': - @list($trigger) = $command->getArguments(); - if (strpos($trigger, 'ERR ') === 0) { - throw new ServerException($trigger); - } - - if ($trigger === '!!ABORT!!' && $multi) { - $abort = true; - } - - return new ResponseQueued(); - - case 'UNWATCH': - $watch = false; - - default: - return $multi ? new ResponseQueued() : 'DUMMY_REPLY'; - } - }; - } - - /** - * Converts an array of instances of Predis\Command\CommandInterface and - * returns an array containing their IDs. - * - * @param array $commands List of commands instances. - * @return array - */ - protected static function commandsToIDs($commands) - { - return array_map(function ($cmd) { return $cmd->getId(); }, $commands); - } - - /** - * Returns a client instance connected to the specified Redis - * server instance to perform integration tests. - * - * @param array Additional connection parameters. - * @param array Additional client options. - * @return Client client instance. - */ - protected function getClient(array $parameters = array(), array $options = array()) - { - return $this->createClient($parameters, $options); - } -} diff --git a/vendor/predis/predis/tests/README.md b/vendor/predis/predis/tests/README.md deleted file mode 100644 index 020290795..000000000 --- a/vendor/predis/predis/tests/README.md +++ /dev/null @@ -1,83 +0,0 @@ -# About testing Predis # - -__ATTENTION__: Do not ever ever run this test suite against instances of Redis running in production -environments or containing data you are interested in! If you still want to test this library on a -production server without hitting the database, please read ahead about how to disable integration -tests. - -Predis ships a comprehensive test suite that uses __PHPUnit__ to cover every aspect of the library. -The suite is organized into several unit groups with the PHPUnit `@group` annotation which makes it -possible to run only selected groups of tests. The main groups are: - - - __disconnected__: generic tests verifying the correct behaviour of the library without requiring - an active connection to Redis. - - __connected__: integration tests that require an active connection to Redis - - __commands__: tests for the implementation of Redis commands. - - __slow__: tests that might slow down the execution of the test suite (either __connected__ or - __disconnected__). - -A list of all the available groups in the suite can be obtained by running: - -```bash -$ phpunit --list-groups -``` - -Groups of tests can be disabled or enabled via the XML configuration file or the standard command -line test runner. Please note that due to a bug in PHPUnit, older versions ignore the `--group` -option when the group is excluded in the XML configuration file. More details about this issue are -available on [PHPUnit's bug tracker](http://github.com/sebastianbergmann/phpunit/issues/320). - -Certain groups of tests requiring native extensions, such as `ext-curl` or `ext-phpiredis`, are -disabled by default in the configuration file. To enable these groups of tests you should remove -them from the exclusion list in `phpunit.xml`. - -### Combining groups for inclusion or exclusion with the command-line runner ### - -```bash -$ phpunit --group disconnected --exclude-group commands,slow -``` - -### Integration tests ### - -The suite performs integration tests against a running instance of Redis (>= 2.4.0) to verify the -correct behavior of the implementation of each command and certain abstractions implemented in the -library that depend on them. These tests are identified by the __connected__ group. - -Integration tests for commands that are not defined in the specified server profile (see the value -of the `REDIS_SERVER_VERSION` constant in `phpunit.xml`) are marked as __skipped__ automatically. - -By default, the test suite is configured to execute integration tests using the server profile for -Redis v2.6. You can run the suite against a Redis instance built from the `unstable` branch with the -development profile by changing the `REDIS_SERVER_VERSION` to `dev` in the `phpunit.xml` file, or to -`2.8` for the current stable version. - -If you do not have a Redis instance up and running or available for testing, you can completely -disable integration tests by excluding the __connected__ group: - -```bash -$ phpunit --exclude-group connected -``` - -### Slow tests ### - -Certain tests can slow down the execution of the suite. These tests can be disabled by excluding the -__slow__ group: - -```bash -$ phpunit --exclude-group slow -``` - -### Testing Redis commands ### - -We also provide an helper script in the `bin` directory that can be used to automatically generate a -file with the scheleton of a test case to test a Redis command by specifying the name of the class -in the `Predis\Command` namespace (only classes in this namespace are considered valid). For example - to generate a test case for `SET` (represented by the `Predis\Command\StringSet` class): - -```bash -$ ./bin/create-command-test --class=StringSet -``` - -Each command has its own realm (e.g. commands operating on strings, lists, sets and such) which is -automatically inferred from the name of the specified class. The realm can be also provided manually -leveraging the `--realm` option. diff --git a/vendor/predis/predis/tests/bootstrap.php b/vendor/predis/predis/tests/bootstrap.php deleted file mode 100644 index e55c90650..000000000 --- a/vendor/predis/predis/tests/bootstrap.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -if (file_exists(__DIR__.'/../autoload.php')) { - require __DIR__.'/../autoload.php'; -} else if (@include('Predis/Autoloader.php')) { - Predis\Autoloader::register(); -} else { - die('ERROR: Unable to find a suitable mean to register Predis\Autoloader.'); -} - -require __DIR__.'/PHPUnit/ArrayHasSameValuesConstraint.php'; -require __DIR__.'/PHPUnit/RedisCommandConstraint.php'; -require __DIR__.'/PHPUnit/PredisTestCase.php'; -require __DIR__.'/PHPUnit/PredisCommandTestCase.php'; -require __DIR__.'/PHPUnit/PredisConnectionTestCase.php'; -require __DIR__.'/PHPUnit/PredisProfileTestCase.php'; -require __DIR__.'/PHPUnit/PredisDistributorTestCase.php'; diff --git a/vendor/psr/http-message/LICENSE b/vendor/psr/http-message/LICENSE deleted file mode 100644 index c2d8e452d..000000000 --- a/vendor/psr/http-message/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2014 PHP Framework Interoperability Group - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/psr/http-message/README.md b/vendor/psr/http-message/README.md deleted file mode 100644 index 28185338f..000000000 --- a/vendor/psr/http-message/README.md +++ /dev/null @@ -1,13 +0,0 @@ -PSR Http Message -================ - -This repository holds all interfaces/classes/traits related to -[PSR-7](http://www.php-fig.org/psr/psr-7/). - -Note that this is not a HTTP message implementation of its own. It is merely an -interface that describes a HTTP message. See the specification for more details. - -Usage ------ - -We'll certainly need some stuff in here. \ No newline at end of file diff --git a/vendor/psr/http-message/composer.json b/vendor/psr/http-message/composer.json deleted file mode 100644 index 4774b6126..000000000 --- a/vendor/psr/http-message/composer.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "name": "psr/http-message", - "description": "Common interface for HTTP messages", - "keywords": ["psr", "psr-7", "http", "http-message", "request", "response"], - "license": "MIT", - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "require": { - "php": ">=5.3.0" - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - } -} diff --git a/vendor/psr/http-message/src/MessageInterface.php b/vendor/psr/http-message/src/MessageInterface.php deleted file mode 100644 index 8f67a050e..000000000 --- a/vendor/psr/http-message/src/MessageInterface.php +++ /dev/null @@ -1,187 +0,0 @@ -getHeaders() as $name => $values) { - * echo $name . ": " . implode(", ", $values); - * } - * - * // Emit headers iteratively: - * foreach ($message->getHeaders() as $name => $values) { - * foreach ($values as $value) { - * header(sprintf('%s: %s', $name, $value), false); - * } - * } - * - * While header names are not case-sensitive, getHeaders() will preserve the - * exact case in which headers were originally specified. - * - * @return array Returns an associative array of the message's headers. Each - * key MUST be a header name, and each value MUST be an array of strings - * for that header. - */ - public function getHeaders(); - - /** - * Checks if a header exists by the given case-insensitive name. - * - * @param string $name Case-insensitive header field name. - * @return bool Returns true if any header names match the given header - * name using a case-insensitive string comparison. Returns false if - * no matching header name is found in the message. - */ - public function hasHeader($name); - - /** - * Retrieves a message header value by the given case-insensitive name. - * - * This method returns an array of all the header values of the given - * case-insensitive header name. - * - * If the header does not appear in the message, this method MUST return an - * empty array. - * - * @param string $name Case-insensitive header field name. - * @return string[] An array of string values as provided for the given - * header. If the header does not appear in the message, this method MUST - * return an empty array. - */ - public function getHeader($name); - - /** - * Retrieves a comma-separated string of the values for a single header. - * - * This method returns all of the header values of the given - * case-insensitive header name as a string concatenated together using - * a comma. - * - * NOTE: Not all header values may be appropriately represented using - * comma concatenation. For such headers, use getHeader() instead - * and supply your own delimiter when concatenating. - * - * If the header does not appear in the message, this method MUST return - * an empty string. - * - * @param string $name Case-insensitive header field name. - * @return string A string of values as provided for the given header - * concatenated together using a comma. If the header does not appear in - * the message, this method MUST return an empty string. - */ - public function getHeaderLine($name); - - /** - * Return an instance with the provided value replacing the specified header. - * - * While header names are case-insensitive, the casing of the header will - * be preserved by this function, and returned from getHeaders(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new and/or updated header and value. - * - * @param string $name Case-insensitive header field name. - * @param string|string[] $value Header value(s). - * @return self - * @throws \InvalidArgumentException for invalid header names or values. - */ - public function withHeader($name, $value); - - /** - * Return an instance with the specified header appended with the given value. - * - * Existing values for the specified header will be maintained. The new - * value(s) will be appended to the existing list. If the header did not - * exist previously, it will be added. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * new header and/or value. - * - * @param string $name Case-insensitive header field name to add. - * @param string|string[] $value Header value(s). - * @return self - * @throws \InvalidArgumentException for invalid header names or values. - */ - public function withAddedHeader($name, $value); - - /** - * Return an instance without the specified header. - * - * Header resolution MUST be done without case-sensitivity. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that removes - * the named header. - * - * @param string $name Case-insensitive header field name to remove. - * @return self - */ - public function withoutHeader($name); - - /** - * Gets the body of the message. - * - * @return StreamInterface Returns the body as a stream. - */ - public function getBody(); - - /** - * Return an instance with the specified message body. - * - * The body MUST be a StreamInterface object. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return a new instance that has the - * new body stream. - * - * @param StreamInterface $body Body. - * @return self - * @throws \InvalidArgumentException When the body is not valid. - */ - public function withBody(StreamInterface $body); -} diff --git a/vendor/psr/http-message/src/RequestInterface.php b/vendor/psr/http-message/src/RequestInterface.php deleted file mode 100644 index 75c802e29..000000000 --- a/vendor/psr/http-message/src/RequestInterface.php +++ /dev/null @@ -1,129 +0,0 @@ -getQuery()` - * or from the `QUERY_STRING` server param. - * - * @return array - */ - public function getQueryParams(); - - /** - * Return an instance with the specified query string arguments. - * - * These values SHOULD remain immutable over the course of the incoming - * request. They MAY be injected during instantiation, such as from PHP's - * $_GET superglobal, or MAY be derived from some other value such as the - * URI. In cases where the arguments are parsed from the URI, the data - * MUST be compatible with what PHP's parse_str() would return for - * purposes of how duplicate query parameters are handled, and how nested - * sets are handled. - * - * Setting query string arguments MUST NOT change the URI stored by the - * request, nor the values in the server params. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated query string arguments. - * - * @param array $query Array of query string arguments, typically from - * $_GET. - * @return self - */ - public function withQueryParams(array $query); - - /** - * Retrieve normalized file upload data. - * - * This method returns upload metadata in a normalized tree, with each leaf - * an instance of Psr\Http\Message\UploadedFileInterface. - * - * These values MAY be prepared from $_FILES or the message body during - * instantiation, or MAY be injected via withUploadedFiles(). - * - * @return array An array tree of UploadedFileInterface instances; an empty - * array MUST be returned if no data is present. - */ - public function getUploadedFiles(); - - /** - * Create a new instance with the specified uploaded files. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated body parameters. - * - * @param array An array tree of UploadedFileInterface instances. - * @return self - * @throws \InvalidArgumentException if an invalid structure is provided. - */ - public function withUploadedFiles(array $uploadedFiles); - - /** - * Retrieve any parameters provided in the request body. - * - * If the request Content-Type is either application/x-www-form-urlencoded - * or multipart/form-data, and the request method is POST, this method MUST - * return the contents of $_POST. - * - * Otherwise, this method may return any results of deserializing - * the request body content; as parsing returns structured content, the - * potential types MUST be arrays or objects only. A null value indicates - * the absence of body content. - * - * @return null|array|object The deserialized body parameters, if any. - * These will typically be an array or object. - */ - public function getParsedBody(); - - /** - * Return an instance with the specified body parameters. - * - * These MAY be injected during instantiation. - * - * If the request Content-Type is either application/x-www-form-urlencoded - * or multipart/form-data, and the request method is POST, use this method - * ONLY to inject the contents of $_POST. - * - * The data IS NOT REQUIRED to come from $_POST, but MUST be the results of - * deserializing the request body content. Deserialization/parsing returns - * structured data, and, as such, this method ONLY accepts arrays or objects, - * or a null value if nothing was available to parse. - * - * As an example, if content negotiation determines that the request data - * is a JSON payload, this method could be used to create a request - * instance with the deserialized parameters. - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated body parameters. - * - * @param null|array|object $data The deserialized body data. This will - * typically be in an array or object. - * @return self - * @throws \InvalidArgumentException if an unsupported argument type is - * provided. - */ - public function withParsedBody($data); - - /** - * Retrieve attributes derived from the request. - * - * The request "attributes" may be used to allow injection of any - * parameters derived from the request: e.g., the results of path - * match operations; the results of decrypting cookies; the results of - * deserializing non-form-encoded message bodies; etc. Attributes - * will be application and request specific, and CAN be mutable. - * - * @return array Attributes derived from the request. - */ - public function getAttributes(); - - /** - * Retrieve a single derived request attribute. - * - * Retrieves a single derived request attribute as described in - * getAttributes(). If the attribute has not been previously set, returns - * the default value as provided. - * - * This method obviates the need for a hasAttribute() method, as it allows - * specifying a default value to return if the attribute is not found. - * - * @see getAttributes() - * @param string $name The attribute name. - * @param mixed $default Default value to return if the attribute does not exist. - * @return mixed - */ - public function getAttribute($name, $default = null); - - /** - * Return an instance with the specified derived request attribute. - * - * This method allows setting a single derived request attribute as - * described in getAttributes(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that has the - * updated attribute. - * - * @see getAttributes() - * @param string $name The attribute name. - * @param mixed $value The value of the attribute. - * @return self - */ - public function withAttribute($name, $value); - - /** - * Return an instance that removes the specified derived request attribute. - * - * This method allows removing a single derived request attribute as - * described in getAttributes(). - * - * This method MUST be implemented in such a way as to retain the - * immutability of the message, and MUST return an instance that removes - * the attribute. - * - * @see getAttributes() - * @param string $name The attribute name. - * @return self - */ - public function withoutAttribute($name); -} diff --git a/vendor/psr/http-message/src/StreamInterface.php b/vendor/psr/http-message/src/StreamInterface.php deleted file mode 100644 index f68f39126..000000000 --- a/vendor/psr/http-message/src/StreamInterface.php +++ /dev/null @@ -1,158 +0,0 @@ - - * [user-info@]host[:port] - * - * - * If the port component is not set or is the standard port for the current - * scheme, it SHOULD NOT be included. - * - * @see https://tools.ietf.org/html/rfc3986#section-3.2 - * @return string The URI authority, in "[user-info@]host[:port]" format. - */ - public function getAuthority(); - - /** - * Retrieve the user information component of the URI. - * - * If no user information is present, this method MUST return an empty - * string. - * - * If a user is present in the URI, this will return that value; - * additionally, if the password is also present, it will be appended to the - * user value, with a colon (":") separating the values. - * - * The trailing "@" character is not part of the user information and MUST - * NOT be added. - * - * @return string The URI user information, in "username[:password]" format. - */ - public function getUserInfo(); - - /** - * Retrieve the host component of the URI. - * - * If no host is present, this method MUST return an empty string. - * - * The value returned MUST be normalized to lowercase, per RFC 3986 - * Section 3.2.2. - * - * @see http://tools.ietf.org/html/rfc3986#section-3.2.2 - * @return string The URI host. - */ - public function getHost(); - - /** - * Retrieve the port component of the URI. - * - * If a port is present, and it is non-standard for the current scheme, - * this method MUST return it as an integer. If the port is the standard port - * used with the current scheme, this method SHOULD return null. - * - * If no port is present, and no scheme is present, this method MUST return - * a null value. - * - * If no port is present, but a scheme is present, this method MAY return - * the standard port for that scheme, but SHOULD return null. - * - * @return null|int The URI port. - */ - public function getPort(); - - /** - * Retrieve the path component of the URI. - * - * The path can either be empty or absolute (starting with a slash) or - * rootless (not starting with a slash). Implementations MUST support all - * three syntaxes. - * - * Normally, the empty path "" and absolute path "/" are considered equal as - * defined in RFC 7230 Section 2.7.3. But this method MUST NOT automatically - * do this normalization because in contexts with a trimmed base path, e.g. - * the front controller, this difference becomes significant. It's the task - * of the user to handle both "" and "/". - * - * The value returned MUST be percent-encoded, but MUST NOT double-encode - * any characters. To determine what characters to encode, please refer to - * RFC 3986, Sections 2 and 3.3. - * - * As an example, if the value should include a slash ("/") not intended as - * delimiter between path segments, that value MUST be passed in encoded - * form (e.g., "%2F") to the instance. - * - * @see https://tools.ietf.org/html/rfc3986#section-2 - * @see https://tools.ietf.org/html/rfc3986#section-3.3 - * @return string The URI path. - */ - public function getPath(); - - /** - * Retrieve the query string of the URI. - * - * If no query string is present, this method MUST return an empty string. - * - * The leading "?" character is not part of the query and MUST NOT be - * added. - * - * The value returned MUST be percent-encoded, but MUST NOT double-encode - * any characters. To determine what characters to encode, please refer to - * RFC 3986, Sections 2 and 3.4. - * - * As an example, if a value in a key/value pair of the query string should - * include an ampersand ("&") not intended as a delimiter between values, - * that value MUST be passed in encoded form (e.g., "%26") to the instance. - * - * @see https://tools.ietf.org/html/rfc3986#section-2 - * @see https://tools.ietf.org/html/rfc3986#section-3.4 - * @return string The URI query string. - */ - public function getQuery(); - - /** - * Retrieve the fragment component of the URI. - * - * If no fragment is present, this method MUST return an empty string. - * - * The leading "#" character is not part of the fragment and MUST NOT be - * added. - * - * The value returned MUST be percent-encoded, but MUST NOT double-encode - * any characters. To determine what characters to encode, please refer to - * RFC 3986, Sections 2 and 3.5. - * - * @see https://tools.ietf.org/html/rfc3986#section-2 - * @see https://tools.ietf.org/html/rfc3986#section-3.5 - * @return string The URI fragment. - */ - public function getFragment(); - - /** - * Return an instance with the specified scheme. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified scheme. - * - * Implementations MUST support the schemes "http" and "https" case - * insensitively, and MAY accommodate other schemes if required. - * - * An empty scheme is equivalent to removing the scheme. - * - * @param string $scheme The scheme to use with the new instance. - * @return self A new instance with the specified scheme. - * @throws \InvalidArgumentException for invalid or unsupported schemes. - */ - public function withScheme($scheme); - - /** - * Return an instance with the specified user information. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified user information. - * - * Password is optional, but the user information MUST include the - * user; an empty string for the user is equivalent to removing user - * information. - * - * @param string $user The user name to use for authority. - * @param null|string $password The password associated with $user. - * @return self A new instance with the specified user information. - */ - public function withUserInfo($user, $password = null); - - /** - * Return an instance with the specified host. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified host. - * - * An empty host value is equivalent to removing the host. - * - * @param string $host The hostname to use with the new instance. - * @return self A new instance with the specified host. - * @throws \InvalidArgumentException for invalid hostnames. - */ - public function withHost($host); - - /** - * Return an instance with the specified port. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified port. - * - * Implementations MUST raise an exception for ports outside the - * established TCP and UDP port ranges. - * - * A null value provided for the port is equivalent to removing the port - * information. - * - * @param null|int $port The port to use with the new instance; a null value - * removes the port information. - * @return self A new instance with the specified port. - * @throws \InvalidArgumentException for invalid ports. - */ - public function withPort($port); - - /** - * Return an instance with the specified path. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified path. - * - * The path can either be empty or absolute (starting with a slash) or - * rootless (not starting with a slash). Implementations MUST support all - * three syntaxes. - * - * If the path is intended to be domain-relative rather than path relative then - * it must begin with a slash ("/"). Paths not starting with a slash ("/") - * are assumed to be relative to some base path known to the application or - * consumer. - * - * Users can provide both encoded and decoded path characters. - * Implementations ensure the correct encoding as outlined in getPath(). - * - * @param string $path The path to use with the new instance. - * @return self A new instance with the specified path. - * @throws \InvalidArgumentException for invalid paths. - */ - public function withPath($path); - - /** - * Return an instance with the specified query string. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified query string. - * - * Users can provide both encoded and decoded query characters. - * Implementations ensure the correct encoding as outlined in getQuery(). - * - * An empty query string value is equivalent to removing the query string. - * - * @param string $query The query string to use with the new instance. - * @return self A new instance with the specified query string. - * @throws \InvalidArgumentException for invalid query strings. - */ - public function withQuery($query); - - /** - * Return an instance with the specified URI fragment. - * - * This method MUST retain the state of the current instance, and return - * an instance that contains the specified URI fragment. - * - * Users can provide both encoded and decoded fragment characters. - * Implementations ensure the correct encoding as outlined in getFragment(). - * - * An empty fragment value is equivalent to removing the fragment. - * - * @param string $fragment The fragment to use with the new instance. - * @return self A new instance with the specified fragment. - */ - public function withFragment($fragment); - - /** - * Return the string representation as a URI reference. - * - * Depending on which components of the URI are present, the resulting - * string is either a full URI or relative reference according to RFC 3986, - * Section 4.1. The method concatenates the various components of the URI, - * using the appropriate delimiters: - * - * - If a scheme is present, it MUST be suffixed by ":". - * - If an authority is present, it MUST be prefixed by "//". - * - The path can be concatenated without delimiters. But there are two - * cases where the path has to be adjusted to make the URI reference - * valid as PHP does not allow to throw an exception in __toString(): - * - If the path is rootless and an authority is present, the path MUST - * be prefixed by "/". - * - If the path is starting with more than one "/" and no authority is - * present, the starting slashes MUST be reduced to one. - * - If a query is present, it MUST be prefixed by "?". - * - If a fragment is present, it MUST be prefixed by "#". - * - * @see http://tools.ietf.org/html/rfc3986#section-4.1 - * @return string - */ - public function __toString(); -} diff --git a/vendor/psr/log/.gitignore b/vendor/psr/log/.gitignore deleted file mode 100644 index 22d0d82f8..000000000 --- a/vendor/psr/log/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vendor diff --git a/vendor/psr/log/LICENSE b/vendor/psr/log/LICENSE deleted file mode 100644 index 474c952b4..000000000 --- a/vendor/psr/log/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2012 PHP Framework Interoperability Group - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/psr/log/Psr/Log/AbstractLogger.php b/vendor/psr/log/Psr/Log/AbstractLogger.php deleted file mode 100644 index 5a68a2340..000000000 --- a/vendor/psr/log/Psr/Log/AbstractLogger.php +++ /dev/null @@ -1,128 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } -} diff --git a/vendor/psr/log/Psr/Log/InvalidArgumentException.php b/vendor/psr/log/Psr/Log/InvalidArgumentException.php deleted file mode 100644 index 67f852d1d..000000000 --- a/vendor/psr/log/Psr/Log/InvalidArgumentException.php +++ /dev/null @@ -1,7 +0,0 @@ -logger = $logger; - } -} diff --git a/vendor/psr/log/Psr/Log/LoggerInterface.php b/vendor/psr/log/Psr/Log/LoggerInterface.php deleted file mode 100644 index 16c04adeb..000000000 --- a/vendor/psr/log/Psr/Log/LoggerInterface.php +++ /dev/null @@ -1,123 +0,0 @@ -log(LogLevel::EMERGENCY, $message, $context); - } - - /** - * Action must be taken immediately. - * - * Example: Entire website down, database unavailable, etc. This should - * trigger the SMS alerts and wake you up. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function alert($message, array $context = array()) - { - $this->log(LogLevel::ALERT, $message, $context); - } - - /** - * Critical conditions. - * - * Example: Application component unavailable, unexpected exception. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function critical($message, array $context = array()) - { - $this->log(LogLevel::CRITICAL, $message, $context); - } - - /** - * Runtime errors that do not require immediate action but should typically - * be logged and monitored. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function error($message, array $context = array()) - { - $this->log(LogLevel::ERROR, $message, $context); - } - - /** - * Exceptional occurrences that are not errors. - * - * Example: Use of deprecated APIs, poor use of an API, undesirable things - * that are not necessarily wrong. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function warning($message, array $context = array()) - { - $this->log(LogLevel::WARNING, $message, $context); - } - - /** - * Normal but significant events. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function notice($message, array $context = array()) - { - $this->log(LogLevel::NOTICE, $message, $context); - } - - /** - * Interesting events. - * - * Example: User logs in, SQL logs. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function info($message, array $context = array()) - { - $this->log(LogLevel::INFO, $message, $context); - } - - /** - * Detailed debug information. - * - * @param string $message - * @param array $context - * - * @return null - */ - public function debug($message, array $context = array()) - { - $this->log(LogLevel::DEBUG, $message, $context); - } - - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - * - * @return null - */ - abstract public function log($level, $message, array $context = array()); -} diff --git a/vendor/psr/log/Psr/Log/NullLogger.php b/vendor/psr/log/Psr/Log/NullLogger.php deleted file mode 100644 index 3fc5100f1..000000000 --- a/vendor/psr/log/Psr/Log/NullLogger.php +++ /dev/null @@ -1,28 +0,0 @@ -logger) { }` - * blocks. - */ -class NullLogger extends AbstractLogger -{ - /** - * Logs with an arbitrary level. - * - * @param mixed $level - * @param string $message - * @param array $context - * - * @return null - */ - public function log($level, $message, array $context = array()) - { - // noop - } -} diff --git a/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php b/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php deleted file mode 100644 index f66a2b02b..000000000 --- a/vendor/psr/log/Psr/Log/Test/LoggerInterfaceTest.php +++ /dev/null @@ -1,140 +0,0 @@ - ". - * - * Example ->error('Foo') would yield "error Foo". - * - * @return string[] - */ - abstract public function getLogs(); - - public function testImplements() - { - $this->assertInstanceOf('Psr\Log\LoggerInterface', $this->getLogger()); - } - - /** - * @dataProvider provideLevelsAndMessages - */ - public function testLogsAtAllLevels($level, $message) - { - $logger = $this->getLogger(); - $logger->{$level}($message, array('user' => 'Bob')); - $logger->log($level, $message, array('user' => 'Bob')); - - $expected = array( - $level.' message of level '.$level.' with context: Bob', - $level.' message of level '.$level.' with context: Bob', - ); - $this->assertEquals($expected, $this->getLogs()); - } - - public function provideLevelsAndMessages() - { - return array( - LogLevel::EMERGENCY => array(LogLevel::EMERGENCY, 'message of level emergency with context: {user}'), - LogLevel::ALERT => array(LogLevel::ALERT, 'message of level alert with context: {user}'), - LogLevel::CRITICAL => array(LogLevel::CRITICAL, 'message of level critical with context: {user}'), - LogLevel::ERROR => array(LogLevel::ERROR, 'message of level error with context: {user}'), - LogLevel::WARNING => array(LogLevel::WARNING, 'message of level warning with context: {user}'), - LogLevel::NOTICE => array(LogLevel::NOTICE, 'message of level notice with context: {user}'), - LogLevel::INFO => array(LogLevel::INFO, 'message of level info with context: {user}'), - LogLevel::DEBUG => array(LogLevel::DEBUG, 'message of level debug with context: {user}'), - ); - } - - /** - * @expectedException \Psr\Log\InvalidArgumentException - */ - public function testThrowsOnInvalidLevel() - { - $logger = $this->getLogger(); - $logger->log('invalid level', 'Foo'); - } - - public function testContextReplacement() - { - $logger = $this->getLogger(); - $logger->info('{Message {nothing} {user} {foo.bar} a}', array('user' => 'Bob', 'foo.bar' => 'Bar')); - - $expected = array('info {Message {nothing} Bob Bar a}'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testObjectCastToString() - { - if (method_exists($this, 'createMock')) { - $dummy = $this->createMock('Psr\Log\Test\DummyTest', array('__toString')); - } else { - $dummy = $this->getMock('Psr\Log\Test\DummyTest', array('__toString')); - } - $dummy->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('DUMMY')); - - $this->getLogger()->warning($dummy); - - $expected = array('warning DUMMY'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testContextCanContainAnything() - { - $context = array( - 'bool' => true, - 'null' => null, - 'string' => 'Foo', - 'int' => 0, - 'float' => 0.5, - 'nested' => array('with object' => new DummyTest), - 'object' => new \DateTime, - 'resource' => fopen('php://memory', 'r'), - ); - - $this->getLogger()->warning('Crazy context data', $context); - - $expected = array('warning Crazy context data'); - $this->assertEquals($expected, $this->getLogs()); - } - - public function testContextExceptionKeyCanBeExceptionOrOtherValues() - { - $logger = $this->getLogger(); - $logger->warning('Random message', array('exception' => 'oops')); - $logger->critical('Uncaught Exception!', array('exception' => new \LogicException('Fail'))); - - $expected = array( - 'warning Random message', - 'critical Uncaught Exception!' - ); - $this->assertEquals($expected, $this->getLogs()); - } -} - -class DummyTest -{ - public function __toString() - { - } -} diff --git a/vendor/psr/log/README.md b/vendor/psr/log/README.md deleted file mode 100644 index 574bc1cb2..000000000 --- a/vendor/psr/log/README.md +++ /dev/null @@ -1,45 +0,0 @@ -PSR Log -======= - -This repository holds all interfaces/classes/traits related to -[PSR-3](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md). - -Note that this is not a logger of its own. It is merely an interface that -describes a logger. See the specification for more details. - -Usage ------ - -If you need a logger, you can use the interface like this: - -```php -logger = $logger; - } - - public function doSomething() - { - if ($this->logger) { - $this->logger->info('Doing work'); - } - - // do something useful - } -} -``` - -You can then pick one of the implementations of the interface to get a logger. - -If you want to implement the interface, you can require this package and -implement `Psr\Log\LoggerInterface` in your code. Please read the -[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) -for details. diff --git a/vendor/psr/log/composer.json b/vendor/psr/log/composer.json deleted file mode 100644 index 87934d707..000000000 --- a/vendor/psr/log/composer.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "psr/log", - "description": "Common interface for logging libraries", - "keywords": ["psr", "psr-3", "log"], - "homepage": "https://github.com/php-fig/log", - "license": "MIT", - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "require": { - "php": ">=5.3.0" - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - } -} diff --git a/vendor/slim/slim/.gitignore b/vendor/slim/slim/.gitignore deleted file mode 100644 index 485dee64b..000000000 --- a/vendor/slim/slim/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.idea diff --git a/vendor/slim/slim/.htaccess b/vendor/slim/slim/.htaccess deleted file mode 100644 index b5f9c3c4a..000000000 --- a/vendor/slim/slim/.htaccess +++ /dev/null @@ -1,10 +0,0 @@ -RewriteEngine On - -# Some hosts may require you to use the `RewriteBase` directive. -# If you need to use the `RewriteBase` directive, it should be the -# absolute physical path to the directory that contains this htaccess file. -# -# RewriteBase / - -RewriteCond %{REQUEST_FILENAME} !-f -RewriteRule ^ index.php [QSA,L] \ No newline at end of file diff --git a/vendor/slim/slim/.travis.yml b/vendor/slim/slim/.travis.yml deleted file mode 100644 index 9cb62f1a3..000000000 --- a/vendor/slim/slim/.travis.yml +++ /dev/null @@ -1,9 +0,0 @@ -language: php - -php: - - 5.3 - - 5.4 - - 5.5 - - hhvm - -script: phpunit --coverage-text diff --git a/vendor/slim/slim/CONTRIBUTING.md b/vendor/slim/slim/CONTRIBUTING.md deleted file mode 100644 index 9bbb6b17c..000000000 --- a/vendor/slim/slim/CONTRIBUTING.md +++ /dev/null @@ -1,20 +0,0 @@ -# How to Contribute - -## Pull Requests - -1. Fork the Slim Framework repository -2. Create a new branch for each feature or improvement -3. Send a pull request from each feature branch to the **develop** branch - -It is very important to separate new features or improvements into separate feature branches, and to send a -pull request for each branch. This allows me to review and pull in new features or improvements individually. - -## Style Guide - -All pull requests must adhere to the [PSR-2 standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md). - -## Unit Testing - -All pull requests must be accompanied by passing unit tests and complete code coverage. The Slim Framework uses phpunit for testing. - -[Learn about PHPUnit](https://github.com/sebastianbergmann/phpunit/) diff --git a/vendor/slim/slim/LICENSE b/vendor/slim/slim/LICENSE deleted file mode 100644 index ec361cbc9..000000000 --- a/vendor/slim/slim/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2012 Josh Lockhart - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/slim/slim/README.markdown b/vendor/slim/slim/README.markdown deleted file mode 100644 index 8e4fbe84a..000000000 --- a/vendor/slim/slim/README.markdown +++ /dev/null @@ -1,183 +0,0 @@ -# Slim Framework - -[![Build Status](https://secure.travis-ci.org/codeguy/Slim.png?branch=master)](http://travis-ci.org/codeguy/Slim) - -Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs. -Slim is easy to use for both beginners and professionals. Slim favors cleanliness over terseness and common cases -over edge cases. Its interface is simple, intuitive, and extensively documented — both online and in the code itself. -Thank you for choosing the Slim Framework for your next project. I think you're going to love it. - -## Features - -* Powerful router - * Standard and custom HTTP methods - * Route parameters with wildcards and conditions - * Route redirect, halt, and pass - * Route middleware -* Resource Locator and DI container -* Template rendering with custom views -* Flash messages -* Secure cookies with AES-256 encryption -* HTTP caching -* Logging with custom log writers -* Error handling and debugging -* Middleware and hook architecture -* Simple configuration - -## Getting Started - -### Install - -You may install the Slim Framework with Composer (recommended) or manually. - -[Read how to install Slim](http://docs.slimframework.com/#Installation) - -### System Requirements - -You need **PHP >= 5.3.0**. If you use encrypted cookies, you'll also need the `mcrypt` extension. - -### Hello World Tutorial - -Instantiate a Slim application: - - $app = new \Slim\Slim(); - -Define a HTTP GET route: - - $app->get('/hello/:name', function ($name) { - echo "Hello, $name"; - }); - -Run the Slim application: - - $app->run(); - -### Setup your web server - -#### Apache - -Ensure the `.htaccess` and `index.php` files are in the same public-accessible directory. The `.htaccess` file -should contain this code: - - RewriteEngine On - RewriteCond %{REQUEST_FILENAME} !-f - RewriteRule ^ index.php [QSA,L] - -Additionally, make sure your virtual host is configured with the AllowOverride option so that the .htaccess rewrite rules can be used: - - AllowOverride All - -#### Nginx - -The nginx configuration file should contain this code (along with other settings you may need) in your `location` block: - - try_files $uri $uri/ /index.php?$args; - -This assumes that Slim's `index.php` is in the root folder of your project (www root). - -#### HipHop Virtual Machine for PHP - -Your HipHop Virtual Machine configuration file should contain this code (along with other settings you may need). -Be sure you change the `ServerRoot` setting to point to your Slim app's document root directory. - - Server { - SourceRoot = /path/to/public/directory - } - - ServerVariables { - SCRIPT_NAME = /index.php - } - - VirtualHost { - * { - Pattern = .* - RewriteRules { - * { - pattern = ^(.*)$ - to = index.php/$1 - qsa = true - } - } - } - } - -#### lighttpd #### - -Your lighttpd configuration file should contain this code (along with other settings you may need). This code requires -lighttpd >= 1.4.24. - - url.rewrite-if-not-file = ("(.*)" => "/index.php/$0") - -This assumes that Slim's `index.php` is in the root folder of your project (www root). - -#### IIS - -Ensure the `Web.config` and `index.php` files are in the same public-accessible directory. The `Web.config` file should contain this code: - - - - - - - - - - - - - - - - - - - -## Documentation - - - -## How to Contribute - -### Pull Requests - -1. Fork the Slim Framework repository -2. Create a new branch for each feature or improvement -3. Send a pull request from each feature branch to the **develop** branch - -It is very important to separate new features or improvements into separate feature branches, and to send a pull -request for each branch. This allows me to review and pull in new features or improvements individually. - -### Style Guide - -All pull requests must adhere to the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) standard. - -### Unit Testing - -All pull requests must be accompanied by passing unit tests and complete code coverage. The Slim Framework uses -`phpunit` for testing. - -[Learn about PHPUnit](https://github.com/sebastianbergmann/phpunit/) - -## Community - -### Forum and Knowledgebase - -Visit Slim's official forum and knowledge base at where you can find announcements, -chat with fellow Slim users, ask questions, help others, or show off your cool Slim Framework apps. - -### Twitter - -Follow [@slimphp](http://www.twitter.com/slimphp) on Twitter to receive news and updates about the framework. - -## Author - -The Slim Framework is created and maintained by [Josh Lockhart](http://www.joshlockhart.com). Josh is a senior -web developer at [New Media Campaigns](http://www.newmediacampaigns.com/). Josh also created and maintains -[PHP: The Right Way](http://www.phptherightway.com/), a popular movement in the PHP community to introduce new -PHP programmers to best practices and good information. - -## License - -The Slim Framework is released under the MIT public license. - - diff --git a/vendor/slim/slim/Slim/Environment.php b/vendor/slim/slim/Slim/Environment.php deleted file mode 100644 index a15e1e4ba..000000000 --- a/vendor/slim/slim/Slim/Environment.php +++ /dev/null @@ -1,224 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim; - -/** - * Environment - * - * This class creates and returns a key/value array of common - * environment variables for the current HTTP request. - * - * This is a singleton class; derived environment variables will - * be common across multiple Slim applications. - * - * This class matches the Rack (Ruby) specification as closely - * as possible. More information available below. - * - * @package Slim - * @author Josh Lockhart - * @since 1.6.0 - */ -class Environment implements \ArrayAccess, \IteratorAggregate -{ - /** - * @var array - */ - protected $properties; - - /** - * @var \Slim\Environment - */ - protected static $environment; - - /** - * Get environment instance (singleton) - * - * This creates and/or returns an environment instance (singleton) - * derived from $_SERVER variables. You may override the global server - * variables by using `\Slim\Environment::mock()` instead. - * - * @param bool $refresh Refresh properties using global server variables? - * @return \Slim\Environment - */ - public static function getInstance($refresh = false) - { - if (is_null(self::$environment) || $refresh) { - self::$environment = new self(); - } - - return self::$environment; - } - - /** - * Get mock environment instance - * - * @param array $userSettings - * @return \Slim\Environment - */ - public static function mock($userSettings = array()) - { - $defaults = array( - 'REQUEST_METHOD' => 'GET', - 'SCRIPT_NAME' => '', - 'PATH_INFO' => '', - 'QUERY_STRING' => '', - 'SERVER_NAME' => 'localhost', - 'SERVER_PORT' => 80, - 'ACCEPT' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', - 'ACCEPT_LANGUAGE' => 'en-US,en;q=0.8', - 'ACCEPT_CHARSET' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', - 'USER_AGENT' => 'Slim Framework', - 'REMOTE_ADDR' => '127.0.0.1', - 'slim.url_scheme' => 'http', - 'slim.input' => '', - 'slim.errors' => @fopen('php://stderr', 'w') - ); - self::$environment = new self(array_merge($defaults, $userSettings)); - - return self::$environment; - } - - /** - * Constructor (private access) - * - * @param array|null $settings If present, these are used instead of global server variables - */ - private function __construct($settings = null) - { - if ($settings) { - $this->properties = $settings; - } else { - $env = array(); - - //The HTTP request method - $env['REQUEST_METHOD'] = $_SERVER['REQUEST_METHOD']; - - //The IP - $env['REMOTE_ADDR'] = $_SERVER['REMOTE_ADDR']; - - // Server params - $scriptName = $_SERVER['SCRIPT_NAME']; // <-- "/foo/index.php" - $requestUri = $_SERVER['REQUEST_URI']; // <-- "/foo/bar?test=abc" or "/foo/index.php/bar?test=abc" - $queryString = isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : ''; // <-- "test=abc" or "" - - // Physical path - if (strpos($requestUri, $scriptName) !== false) { - $physicalPath = $scriptName; // <-- Without rewriting - } else { - $physicalPath = str_replace('\\', '', dirname($scriptName)); // <-- With rewriting - } - $env['SCRIPT_NAME'] = rtrim($physicalPath, '/'); // <-- Remove trailing slashes - - // Virtual path - $env['PATH_INFO'] = substr_replace($requestUri, '', 0, strlen($physicalPath)); // <-- Remove physical path - $env['PATH_INFO'] = str_replace('?' . $queryString, '', $env['PATH_INFO']); // <-- Remove query string - $env['PATH_INFO'] = '/' . ltrim($env['PATH_INFO'], '/'); // <-- Ensure leading slash - - // Query string (without leading "?") - $env['QUERY_STRING'] = $queryString; - - //Name of server host that is running the script - $env['SERVER_NAME'] = $_SERVER['SERVER_NAME']; - - //Number of server port that is running the script - $env['SERVER_PORT'] = $_SERVER['SERVER_PORT']; - - //HTTP request headers (retains HTTP_ prefix to match $_SERVER) - $headers = \Slim\Http\Headers::extract($_SERVER); - foreach ($headers as $key => $value) { - $env[$key] = $value; - } - - //Is the application running under HTTPS or HTTP protocol? - $env['slim.url_scheme'] = empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] === 'off' ? 'http' : 'https'; - - //Input stream (readable one time only; not available for multipart/form-data requests) - $rawInput = @file_get_contents('php://input'); - if (!$rawInput) { - $rawInput = ''; - } - $env['slim.input'] = $rawInput; - - //Error stream - $env['slim.errors'] = @fopen('php://stderr', 'w'); - - $this->properties = $env; - } - } - - /** - * Array Access: Offset Exists - */ - public function offsetExists($offset) - { - return isset($this->properties[$offset]); - } - - /** - * Array Access: Offset Get - */ - public function offsetGet($offset) - { - if (isset($this->properties[$offset])) { - return $this->properties[$offset]; - } else { - return null; - } - } - - /** - * Array Access: Offset Set - */ - public function offsetSet($offset, $value) - { - $this->properties[$offset] = $value; - } - - /** - * Array Access: Offset Unset - */ - public function offsetUnset($offset) - { - unset($this->properties[$offset]); - } - - /** - * IteratorAggregate - * - * @return \ArrayIterator - */ - public function getIterator() - { - return new \ArrayIterator($this->properties); - } -} diff --git a/vendor/slim/slim/Slim/Exception/Pass.php b/vendor/slim/slim/Slim/Exception/Pass.php deleted file mode 100644 index 99d95c252..000000000 --- a/vendor/slim/slim/Slim/Exception/Pass.php +++ /dev/null @@ -1,49 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Exception; - -/** - * Pass Exception - * - * This Exception will cause the Router::dispatch method - * to skip the current matching route and continue to the next - * matching route. If no subsequent routes are found, a - * HTTP 404 Not Found response will be sent to the client. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class Pass extends \Exception -{ -} diff --git a/vendor/slim/slim/Slim/Exception/Stop.php b/vendor/slim/slim/Slim/Exception/Stop.php deleted file mode 100644 index a2518515d..000000000 --- a/vendor/slim/slim/Slim/Exception/Stop.php +++ /dev/null @@ -1,47 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Exception; - -/** - * Stop Exception - * - * This Exception is thrown when the Slim application needs to abort - * processing and return control flow to the outer PHP script. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class Stop extends \Exception -{ -} diff --git a/vendor/slim/slim/Slim/Helper/Set.php b/vendor/slim/slim/Slim/Helper/Set.php deleted file mode 100644 index 9538b6942..000000000 --- a/vendor/slim/slim/Slim/Helper/Set.php +++ /dev/null @@ -1,246 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Helper; - -class Set implements \ArrayAccess, \Countable, \IteratorAggregate -{ - /** - * Key-value array of arbitrary data - * @var array - */ - protected $data = array(); - - /** - * Constructor - * @param array $items Pre-populate set with this key-value array - */ - public function __construct($items = array()) - { - $this->replace($items); - } - - /** - * Normalize data key - * - * Used to transform data key into the necessary - * key format for this set. Used in subclasses - * like \Slim\Http\Headers. - * - * @param string $key The data key - * @return mixed The transformed/normalized data key - */ - protected function normalizeKey($key) - { - return $key; - } - - /** - * Set data key to value - * @param string $key The data key - * @param mixed $value The data value - */ - public function set($key, $value) - { - $this->data[$this->normalizeKey($key)] = $value; - } - - /** - * Get data value with key - * @param string $key The data key - * @param mixed $default The value to return if data key does not exist - * @return mixed The data value, or the default value - */ - public function get($key, $default = null) - { - if ($this->has($key)) { - $isInvokable = is_object($this->data[$this->normalizeKey($key)]) && method_exists($this->data[$this->normalizeKey($key)], '__invoke'); - - return $isInvokable ? $this->data[$this->normalizeKey($key)]($this) : $this->data[$this->normalizeKey($key)]; - } - - return $default; - } - - /** - * Add data to set - * @param array $items Key-value array of data to append to this set - */ - public function replace($items) - { - foreach ($items as $key => $value) { - $this->set($key, $value); // Ensure keys are normalized - } - } - - /** - * Fetch set data - * @return array This set's key-value data array - */ - public function all() - { - return $this->data; - } - - /** - * Fetch set data keys - * @return array This set's key-value data array keys - */ - public function keys() - { - return array_keys($this->data); - } - - /** - * Does this set contain a key? - * @param string $key The data key - * @return boolean - */ - public function has($key) - { - return array_key_exists($this->normalizeKey($key), $this->data); - } - - /** - * Remove value with key from this set - * @param string $key The data key - */ - public function remove($key) - { - unset($this->data[$this->normalizeKey($key)]); - } - - /** - * Property Overloading - */ - - public function __get($key) - { - return $this->get($key); - } - - public function __set($key, $value) - { - $this->set($key, $value); - } - - public function __isset($key) - { - return $this->has($key); - } - - public function __unset($key) - { - return $this->remove($key); - } - - /** - * Clear all values - */ - public function clear() - { - $this->data = array(); - } - - /** - * Array Access - */ - - public function offsetExists($offset) - { - return $this->has($offset); - } - - public function offsetGet($offset) - { - return $this->get($offset); - } - - public function offsetSet($offset, $value) - { - $this->set($offset, $value); - } - - public function offsetUnset($offset) - { - $this->remove($offset); - } - - /** - * Countable - */ - - public function count() - { - return count($this->data); - } - - /** - * IteratorAggregate - */ - - public function getIterator() - { - return new \ArrayIterator($this->data); - } - - /** - * Ensure a value or object will remain globally unique - * @param string $key The value or object name - * @param Closure The closure that defines the object - * @return mixed - */ - public function singleton($key, $value) - { - $this->set($key, function ($c) use ($value) { - static $object; - - if (null === $object) { - $object = $value($c); - } - - return $object; - }); - } - - /** - * Protect closure from being directly invoked - * @param Closure $callable A closure to keep from being invoked and evaluated - * @return Closure - */ - public function protect(\Closure $callable) - { - return function () use ($callable) { - return $callable; - }; - } -} diff --git a/vendor/slim/slim/Slim/Http/Cookies.php b/vendor/slim/slim/Slim/Http/Cookies.php deleted file mode 100644 index cf13801d7..000000000 --- a/vendor/slim/slim/Slim/Http/Cookies.php +++ /dev/null @@ -1,91 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Http; - -class Cookies extends \Slim\Helper\Set -{ - /** - * Default cookie settings - * @var array - */ - protected $defaults = array( - 'value' => '', - 'domain' => null, - 'path' => null, - 'expires' => null, - 'secure' => false, - 'httponly' => false - ); - - /** - * Set cookie - * - * The second argument may be a single scalar value, in which case - * it will be merged with the default settings and considered the `value` - * of the merged result. - * - * The second argument may also be an array containing any or all of - * the keys shown in the default settings above. This array will be - * merged with the defaults shown above. - * - * @param string $key Cookie name - * @param mixed $value Cookie settings - */ - public function set($key, $value) - { - if (is_array($value)) { - $cookieSettings = array_replace($this->defaults, $value); - } else { - $cookieSettings = array_replace($this->defaults, array('value' => $value)); - } - parent::set($key, $cookieSettings); - } - - /** - * Remove cookie - * - * Unlike \Slim\Helper\Set, this will actually *set* a cookie with - * an expiration date in the past. This expiration date will force - * the client-side cache to remove its cookie with the given name - * and settings. - * - * @param string $key Cookie name - * @param array $settings Optional cookie settings - */ - public function remove($key, $settings = array()) - { - $settings['value'] = ''; - $settings['expires'] = time() - 86400; - $this->set($key, array_replace($this->defaults, $settings)); - } -} diff --git a/vendor/slim/slim/Slim/Http/Headers.php b/vendor/slim/slim/Slim/Http/Headers.php deleted file mode 100644 index 1704b8016..000000000 --- a/vendor/slim/slim/Slim/Http/Headers.php +++ /dev/null @@ -1,104 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Http; - - /** - * HTTP Headers - * - * @package Slim - * @author Josh Lockhart - * @since 1.6.0 - */ -class Headers extends \Slim\Helper\Set -{ - /******************************************************************************** - * Static interface - *******************************************************************************/ - - /** - * Special-case HTTP headers that are otherwise unidentifiable as HTTP headers. - * Typically, HTTP headers in the $_SERVER array will be prefixed with - * `HTTP_` or `X_`. These are not so we list them here for later reference. - * - * @var array - */ - protected static $special = array( - 'CONTENT_TYPE', - 'CONTENT_LENGTH', - 'PHP_AUTH_USER', - 'PHP_AUTH_PW', - 'PHP_AUTH_DIGEST', - 'AUTH_TYPE' - ); - - /** - * Extract HTTP headers from an array of data (e.g. $_SERVER) - * @param array $data - * @return array - */ - public static function extract($data) - { - $results = array(); - foreach ($data as $key => $value) { - $key = strtoupper($key); - if (strpos($key, 'X_') === 0 || strpos($key, 'HTTP_') === 0 || in_array($key, static::$special)) { - if ($key === 'HTTP_CONTENT_LENGTH') { - continue; - } - $results[$key] = $value; - } - } - - return $results; - } - - /******************************************************************************** - * Instance interface - *******************************************************************************/ - - /** - * Transform header name into canonical form - * @param string $key - * @return string - */ - protected function normalizeKey($key) - { - $key = strtolower($key); - $key = str_replace(array('-', '_'), ' ', $key); - $key = preg_replace('#^http #', '', $key); - $key = ucwords($key); - $key = str_replace(' ', '-', $key); - - return $key; - } -} diff --git a/vendor/slim/slim/Slim/Http/Request.php b/vendor/slim/slim/Slim/Http/Request.php deleted file mode 100644 index 735484b01..000000000 --- a/vendor/slim/slim/Slim/Http/Request.php +++ /dev/null @@ -1,617 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Http; - -/** - * Slim HTTP Request - * - * This class provides a human-friendly interface to the Slim environment variables; - * environment variables are passed by reference and will be modified directly. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class Request -{ - const METHOD_HEAD = 'HEAD'; - const METHOD_GET = 'GET'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_PATCH = 'PATCH'; - const METHOD_DELETE = 'DELETE'; - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_OVERRIDE = '_METHOD'; - - /** - * @var array - */ - protected static $formDataMediaTypes = array('application/x-www-form-urlencoded'); - - /** - * Application Environment - * @var \Slim\Environment - */ - protected $env; - - /** - * HTTP Headers - * @var \Slim\Http\Headers - */ - public $headers; - - /** - * HTTP Cookies - * @var \Slim\Helper\Set - */ - public $cookies; - - /** - * Constructor - * @param \Slim\Environment $env - */ - public function __construct(\Slim\Environment $env) - { - $this->env = $env; - $this->headers = new \Slim\Http\Headers(\Slim\Http\Headers::extract($env)); - $this->cookies = new \Slim\Helper\Set(\Slim\Http\Util::parseCookieHeader($env['HTTP_COOKIE'])); - } - - /** - * Get HTTP method - * @return string - */ - public function getMethod() - { - return $this->env['REQUEST_METHOD']; - } - - /** - * Is this a GET request? - * @return bool - */ - public function isGet() - { - return $this->getMethod() === self::METHOD_GET; - } - - /** - * Is this a POST request? - * @return bool - */ - public function isPost() - { - return $this->getMethod() === self::METHOD_POST; - } - - /** - * Is this a PUT request? - * @return bool - */ - public function isPut() - { - return $this->getMethod() === self::METHOD_PUT; - } - - /** - * Is this a PATCH request? - * @return bool - */ - public function isPatch() - { - return $this->getMethod() === self::METHOD_PATCH; - } - - /** - * Is this a DELETE request? - * @return bool - */ - public function isDelete() - { - return $this->getMethod() === self::METHOD_DELETE; - } - - /** - * Is this a HEAD request? - * @return bool - */ - public function isHead() - { - return $this->getMethod() === self::METHOD_HEAD; - } - - /** - * Is this a OPTIONS request? - * @return bool - */ - public function isOptions() - { - return $this->getMethod() === self::METHOD_OPTIONS; - } - - /** - * Is this an AJAX request? - * @return bool - */ - public function isAjax() - { - if ($this->params('isajax')) { - return true; - } elseif (isset($this->headers['X_REQUESTED_WITH']) && $this->headers['X_REQUESTED_WITH'] === 'XMLHttpRequest') { - return true; - } else { - return false; - } - } - - /** - * Is this an XHR request? (alias of Slim_Http_Request::isAjax) - * @return bool - */ - public function isXhr() - { - return $this->isAjax(); - } - - /** - * Fetch GET and POST data - * - * This method returns a union of GET and POST data as a key-value array, or the value - * of the array key if requested; if the array key does not exist, NULL is returned, - * unless there is a default value specified. - * - * @param string $key - * @param mixed $default - * @return array|mixed|null - */ - public function params($key = null, $default = null) - { - $union = array_merge($this->get(), $this->post()); - if ($key) { - return isset($union[$key]) ? $union[$key] : $default; - } - - return $union; - } - - /** - * Fetch GET data - * - * This method returns a key-value array of data sent in the HTTP request query string, or - * the value of the array key if requested; if the array key does not exist, NULL is returned. - * - * @param string $key - * @param mixed $default Default return value when key does not exist - * @return array|mixed|null - */ - public function get($key = null, $default = null) - { - if (!isset($this->env['slim.request.query_hash'])) { - $output = array(); - if (function_exists('mb_parse_str') && !isset($this->env['slim.tests.ignore_multibyte'])) { - mb_parse_str($this->env['QUERY_STRING'], $output); - } else { - parse_str($this->env['QUERY_STRING'], $output); - } - $this->env['slim.request.query_hash'] = Util::stripSlashesIfMagicQuotes($output); - } - if ($key) { - if (isset($this->env['slim.request.query_hash'][$key])) { - return $this->env['slim.request.query_hash'][$key]; - } else { - return $default; - } - } else { - return $this->env['slim.request.query_hash']; - } - } - - /** - * Fetch POST data - * - * This method returns a key-value array of data sent in the HTTP request body, or - * the value of a hash key if requested; if the array key does not exist, NULL is returned. - * - * @param string $key - * @param mixed $default Default return value when key does not exist - * @return array|mixed|null - * @throws \RuntimeException If environment input is not available - */ - public function post($key = null, $default = null) - { - if (!isset($this->env['slim.input'])) { - throw new \RuntimeException('Missing slim.input in environment variables'); - } - if (!isset($this->env['slim.request.form_hash'])) { - $this->env['slim.request.form_hash'] = array(); - if ($this->isFormData() && is_string($this->env['slim.input'])) { - $output = array(); - if (function_exists('mb_parse_str') && !isset($this->env['slim.tests.ignore_multibyte'])) { - mb_parse_str($this->env['slim.input'], $output); - } else { - parse_str($this->env['slim.input'], $output); - } - $this->env['slim.request.form_hash'] = Util::stripSlashesIfMagicQuotes($output); - } else { - $this->env['slim.request.form_hash'] = Util::stripSlashesIfMagicQuotes($_POST); - } - } - if ($key) { - if (isset($this->env['slim.request.form_hash'][$key])) { - return $this->env['slim.request.form_hash'][$key]; - } else { - return $default; - } - } else { - return $this->env['slim.request.form_hash']; - } - } - - /** - * Fetch PUT data (alias for \Slim\Http\Request::post) - * @param string $key - * @param mixed $default Default return value when key does not exist - * @return array|mixed|null - */ - public function put($key = null, $default = null) - { - return $this->post($key, $default); - } - - /** - * Fetch PATCH data (alias for \Slim\Http\Request::post) - * @param string $key - * @param mixed $default Default return value when key does not exist - * @return array|mixed|null - */ - public function patch($key = null, $default = null) - { - return $this->post($key, $default); - } - - /** - * Fetch DELETE data (alias for \Slim\Http\Request::post) - * @param string $key - * @param mixed $default Default return value when key does not exist - * @return array|mixed|null - */ - public function delete($key = null, $default = null) - { - return $this->post($key, $default); - } - - /** - * Fetch COOKIE data - * - * This method returns a key-value array of Cookie data sent in the HTTP request, or - * the value of a array key if requested; if the array key does not exist, NULL is returned. - * - * @param string $key - * @return array|string|null - */ - public function cookies($key = null) - { - if ($key) { - return $this->cookies->get($key); - } - - return $this->cookies; - // if (!isset($this->env['slim.request.cookie_hash'])) { - // $cookieHeader = isset($this->env['COOKIE']) ? $this->env['COOKIE'] : ''; - // $this->env['slim.request.cookie_hash'] = Util::parseCookieHeader($cookieHeader); - // } - // if ($key) { - // if (isset($this->env['slim.request.cookie_hash'][$key])) { - // return $this->env['slim.request.cookie_hash'][$key]; - // } else { - // return null; - // } - // } else { - // return $this->env['slim.request.cookie_hash']; - // } - } - - /** - * Does the Request body contain parsed form data? - * @return bool - */ - public function isFormData() - { - $method = isset($this->env['slim.method_override.original_method']) ? $this->env['slim.method_override.original_method'] : $this->getMethod(); - - return ($method === self::METHOD_POST && is_null($this->getContentType())) || in_array($this->getMediaType(), self::$formDataMediaTypes); - } - - /** - * Get Headers - * - * This method returns a key-value array of headers sent in the HTTP request, or - * the value of a hash key if requested; if the array key does not exist, NULL is returned. - * - * @param string $key - * @param mixed $default The default value returned if the requested header is not available - * @return mixed - */ - public function headers($key = null, $default = null) - { - if ($key) { - return $this->headers->get($key, $default); - } - - return $this->headers; - // if ($key) { - // $key = strtoupper($key); - // $key = str_replace('-', '_', $key); - // $key = preg_replace('@^HTTP_@', '', $key); - // if (isset($this->env[$key])) { - // return $this->env[$key]; - // } else { - // return $default; - // } - // } else { - // $headers = array(); - // foreach ($this->env as $key => $value) { - // if (strpos($key, 'slim.') !== 0) { - // $headers[$key] = $value; - // } - // } - // - // return $headers; - // } - } - - /** - * Get Body - * @return string - */ - public function getBody() - { - return $this->env['slim.input']; - } - - /** - * Get Content Type - * @return string|null - */ - public function getContentType() - { - return $this->headers->get('CONTENT_TYPE'); - } - - /** - * Get Media Type (type/subtype within Content Type header) - * @return string|null - */ - public function getMediaType() - { - $contentType = $this->getContentType(); - if ($contentType) { - $contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType); - - return strtolower($contentTypeParts[0]); - } - - return null; - } - - /** - * Get Media Type Params - * @return array - */ - public function getMediaTypeParams() - { - $contentType = $this->getContentType(); - $contentTypeParams = array(); - if ($contentType) { - $contentTypeParts = preg_split('/\s*[;,]\s*/', $contentType); - $contentTypePartsLength = count($contentTypeParts); - for ($i = 1; $i < $contentTypePartsLength; $i++) { - $paramParts = explode('=', $contentTypeParts[$i]); - $contentTypeParams[strtolower($paramParts[0])] = $paramParts[1]; - } - } - - return $contentTypeParams; - } - - /** - * Get Content Charset - * @return string|null - */ - public function getContentCharset() - { - $mediaTypeParams = $this->getMediaTypeParams(); - if (isset($mediaTypeParams['charset'])) { - return $mediaTypeParams['charset']; - } - - return null; - } - - /** - * Get Content-Length - * @return int - */ - public function getContentLength() - { - return $this->headers->get('CONTENT_LENGTH', 0); - } - - /** - * Get Host - * @return string - */ - public function getHost() - { - if (isset($this->env['HTTP_HOST'])) { - if (strpos($this->env['HTTP_HOST'], ':') !== false) { - $hostParts = explode(':', $this->env['HTTP_HOST']); - - return $hostParts[0]; - } - - return $this->env['HTTP_HOST']; - } - - return $this->env['SERVER_NAME']; - } - - /** - * Get Host with Port - * @return string - */ - public function getHostWithPort() - { - return sprintf('%s:%s', $this->getHost(), $this->getPort()); - } - - /** - * Get Port - * @return int - */ - public function getPort() - { - return (int)$this->env['SERVER_PORT']; - } - - /** - * Get Scheme (https or http) - * @return string - */ - public function getScheme() - { - return $this->env['slim.url_scheme']; - } - - /** - * Get Script Name (physical path) - * @return string - */ - public function getScriptName() - { - return $this->env['SCRIPT_NAME']; - } - - /** - * LEGACY: Get Root URI (alias for Slim_Http_Request::getScriptName) - * @return string - */ - public function getRootUri() - { - return $this->getScriptName(); - } - - /** - * Get Path (physical path + virtual path) - * @return string - */ - public function getPath() - { - return $this->getScriptName() . $this->getPathInfo(); - } - - /** - * Get Path Info (virtual path) - * @return string - */ - public function getPathInfo() - { - return $this->env['PATH_INFO']; - } - - /** - * LEGACY: Get Resource URI (alias for Slim_Http_Request::getPathInfo) - * @return string - */ - public function getResourceUri() - { - return $this->getPathInfo(); - } - - /** - * Get URL (scheme + host [ + port if non-standard ]) - * @return string - */ - public function getUrl() - { - $url = $this->getScheme() . '://' . $this->getHost(); - if (($this->getScheme() === 'https' && $this->getPort() !== 443) || ($this->getScheme() === 'http' && $this->getPort() !== 80)) { - $url .= sprintf(':%s', $this->getPort()); - } - - return $url; - } - - /** - * Get IP - * @return string - */ - public function getIp() - { - $keys = array('X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR', 'CLIENT_IP', 'REMOTE_ADDR'); - foreach ($keys as $key) { - if (isset($this->env[$key])) { - return $this->env[$key]; - } - } - - return $this->env['REMOTE_ADDR']; - } - - /** - * Get Referrer - * @return string|null - */ - public function getReferrer() - { - return $this->headers->get('HTTP_REFERER'); - } - - /** - * Get Referer (for those who can't spell) - * @return string|null - */ - public function getReferer() - { - return $this->getReferrer(); - } - - /** - * Get User Agent - * @return string|null - */ - public function getUserAgent() - { - return $this->headers->get('HTTP_USER_AGENT'); - } -} diff --git a/vendor/slim/slim/Slim/Http/Response.php b/vendor/slim/slim/Slim/Http/Response.php deleted file mode 100644 index c55d647cb..000000000 --- a/vendor/slim/slim/Slim/Http/Response.php +++ /dev/null @@ -1,512 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Http; - -/** - * Response - * - * This is a simple abstraction over top an HTTP response. This - * provides methods to set the HTTP status, the HTTP headers, - * and the HTTP body. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class Response implements \ArrayAccess, \Countable, \IteratorAggregate -{ - /** - * @var int HTTP status code - */ - protected $status; - - /** - * @var \Slim\Http\Headers - */ - public $headers; - - /** - * @var \Slim\Http\Cookies - */ - public $cookies; - - /** - * @var string HTTP response body - */ - protected $body; - - /** - * @var int Length of HTTP response body - */ - protected $length; - - /** - * @var array HTTP response codes and messages - */ - protected static $messages = array( - //Informational 1xx - 100 => '100 Continue', - 101 => '101 Switching Protocols', - //Successful 2xx - 200 => '200 OK', - 201 => '201 Created', - 202 => '202 Accepted', - 203 => '203 Non-Authoritative Information', - 204 => '204 No Content', - 205 => '205 Reset Content', - 206 => '206 Partial Content', - //Redirection 3xx - 300 => '300 Multiple Choices', - 301 => '301 Moved Permanently', - 302 => '302 Found', - 303 => '303 See Other', - 304 => '304 Not Modified', - 305 => '305 Use Proxy', - 306 => '306 (Unused)', - 307 => '307 Temporary Redirect', - //Client Error 4xx - 400 => '400 Bad Request', - 401 => '401 Unauthorized', - 402 => '402 Payment Required', - 403 => '403 Forbidden', - 404 => '404 Not Found', - 405 => '405 Method Not Allowed', - 406 => '406 Not Acceptable', - 407 => '407 Proxy Authentication Required', - 408 => '408 Request Timeout', - 409 => '409 Conflict', - 410 => '410 Gone', - 411 => '411 Length Required', - 412 => '412 Precondition Failed', - 413 => '413 Request Entity Too Large', - 414 => '414 Request-URI Too Long', - 415 => '415 Unsupported Media Type', - 416 => '416 Requested Range Not Satisfiable', - 417 => '417 Expectation Failed', - 418 => '418 I\'m a teapot', - 422 => '422 Unprocessable Entity', - 423 => '423 Locked', - //Server Error 5xx - 500 => '500 Internal Server Error', - 501 => '501 Not Implemented', - 502 => '502 Bad Gateway', - 503 => '503 Service Unavailable', - 504 => '504 Gateway Timeout', - 505 => '505 HTTP Version Not Supported' - ); - - /** - * Constructor - * @param string $body The HTTP response body - * @param int $status The HTTP response status - * @param \Slim\Http\Headers|array $headers The HTTP response headers - */ - public function __construct($body = '', $status = 200, $headers = array()) - { - $this->setStatus($status); - $this->headers = new \Slim\Http\Headers(array('Content-Type' => 'text/html')); - $this->headers->replace($headers); - $this->cookies = new \Slim\Http\Cookies(); - $this->write($body); - } - - public function getStatus() - { - return $this->status; - } - - public function setStatus($status) - { - $this->status = (int)$status; - } - - /** - * DEPRECATION WARNING! Use `getStatus` or `setStatus` instead. - * - * Get and set status - * @param int|null $status - * @return int - */ - public function status($status = null) - { - if (!is_null($status)) { - $this->status = (int) $status; - } - - return $this->status; - } - - /** - * DEPRECATION WARNING! Access `headers` property directly. - * - * Get and set header - * @param string $name Header name - * @param string|null $value Header value - * @return string Header value - */ - public function header($name, $value = null) - { - if (!is_null($value)) { - $this->headers->set($name, $value); - } - - return $this->headers->get($name); - } - - /** - * DEPRECATION WARNING! Access `headers` property directly. - * - * Get headers - * @return \Slim\Http\Headers - */ - public function headers() - { - return $this->headers; - } - - public function getBody() - { - return $this->body; - } - - public function setBody($content) - { - $this->write($content, true); - } - - /** - * DEPRECATION WARNING! use `getBody` or `setBody` instead. - * - * Get and set body - * @param string|null $body Content of HTTP response body - * @return string - */ - public function body($body = null) - { - if (!is_null($body)) { - $this->write($body, true); - } - - return $this->body; - } - - /** - * Append HTTP response body - * @param string $body Content to append to the current HTTP response body - * @param bool $replace Overwrite existing response body? - * @return string The updated HTTP response body - */ - public function write($body, $replace = false) - { - if ($replace) { - $this->body = $body; - } else { - $this->body .= (string)$body; - } - $this->length = strlen($this->body); - - return $this->body; - } - - public function getLength() - { - return $this->length; - } - - /** - * DEPRECATION WARNING! Use `getLength` or `write` or `body` instead. - * - * Get and set length - * @param int|null $length - * @return int - */ - public function length($length = null) - { - if (!is_null($length)) { - $this->length = (int) $length; - } - - return $this->length; - } - - /** - * Finalize - * - * This prepares this response and returns an array - * of [status, headers, body]. This array is passed to outer middleware - * if available or directly to the Slim run method. - * - * @return array[int status, array headers, string body] - */ - public function finalize() - { - // Prepare response - if (in_array($this->status, array(204, 304))) { - $this->headers->remove('Content-Type'); - $this->headers->remove('Content-Length'); - $this->setBody(''); - } - - return array($this->status, $this->headers, $this->body); - } - - /** - * DEPRECATION WARNING! Access `cookies` property directly. - * - * Set cookie - * - * Instead of using PHP's `setcookie()` function, Slim manually constructs the HTTP `Set-Cookie` - * header on its own and delegates this responsibility to the `Slim_Http_Util` class. This - * response's header is passed by reference to the utility class and is directly modified. By not - * relying on PHP's native implementation, Slim allows middleware the opportunity to massage or - * analyze the raw header before the response is ultimately delivered to the HTTP client. - * - * @param string $name The name of the cookie - * @param string|array $value If string, the value of cookie; if array, properties for - * cookie including: value, expire, path, domain, secure, httponly - */ - public function setCookie($name, $value) - { - // Util::setCookieHeader($this->header, $name, $value); - $this->cookies->set($name, $value); - } - - /** - * DEPRECATION WARNING! Access `cookies` property directly. - * - * Delete cookie - * - * Instead of using PHP's `setcookie()` function, Slim manually constructs the HTTP `Set-Cookie` - * header on its own and delegates this responsibility to the `Slim_Http_Util` class. This - * response's header is passed by reference to the utility class and is directly modified. By not - * relying on PHP's native implementation, Slim allows middleware the opportunity to massage or - * analyze the raw header before the response is ultimately delivered to the HTTP client. - * - * This method will set a cookie with the given name that has an expiration time in the past; this will - * prompt the HTTP client to invalidate and remove the client-side cookie. Optionally, you may - * also pass a key/value array as the second argument. If the "domain" key is present in this - * array, only the Cookie with the given name AND domain will be removed. The invalidating cookie - * sent with this response will adopt all properties of the second argument. - * - * @param string $name The name of the cookie - * @param array $settings Properties for cookie including: value, expire, path, domain, secure, httponly - */ - public function deleteCookie($name, $settings = array()) - { - $this->cookies->remove($name, $settings); - // Util::deleteCookieHeader($this->header, $name, $value); - } - - /** - * Redirect - * - * This method prepares this response to return an HTTP Redirect response - * to the HTTP client. - * - * @param string $url The redirect destination - * @param int $status The redirect HTTP status code - */ - public function redirect ($url, $status = 302) - { - $this->setStatus($status); - $this->headers->set('Location', $url); - } - - /** - * Helpers: Empty? - * @return bool - */ - public function isEmpty() - { - return in_array($this->status, array(201, 204, 304)); - } - - /** - * Helpers: Informational? - * @return bool - */ - public function isInformational() - { - return $this->status >= 100 && $this->status < 200; - } - - /** - * Helpers: OK? - * @return bool - */ - public function isOk() - { - return $this->status === 200; - } - - /** - * Helpers: Successful? - * @return bool - */ - public function isSuccessful() - { - return $this->status >= 200 && $this->status < 300; - } - - /** - * Helpers: Redirect? - * @return bool - */ - public function isRedirect() - { - return in_array($this->status, array(301, 302, 303, 307)); - } - - /** - * Helpers: Redirection? - * @return bool - */ - public function isRedirection() - { - return $this->status >= 300 && $this->status < 400; - } - - /** - * Helpers: Forbidden? - * @return bool - */ - public function isForbidden() - { - return $this->status === 403; - } - - /** - * Helpers: Not Found? - * @return bool - */ - public function isNotFound() - { - return $this->status === 404; - } - - /** - * Helpers: Client error? - * @return bool - */ - public function isClientError() - { - return $this->status >= 400 && $this->status < 500; - } - - /** - * Helpers: Server Error? - * @return bool - */ - public function isServerError() - { - return $this->status >= 500 && $this->status < 600; - } - - /** - * DEPRECATION WARNING! ArrayAccess interface will be removed from \Slim\Http\Response. - * Iterate `headers` or `cookies` properties directly. - */ - - /** - * Array Access: Offset Exists - */ - public function offsetExists($offset) - { - return isset($this->headers[$offset]); - } - - /** - * Array Access: Offset Get - */ - public function offsetGet($offset) - { - return $this->headers[$offset]; - } - - /** - * Array Access: Offset Set - */ - public function offsetSet($offset, $value) - { - $this->headers[$offset] = $value; - } - - /** - * Array Access: Offset Unset - */ - public function offsetUnset($offset) - { - unset($this->headers[$offset]); - } - - /** - * DEPRECATION WARNING! Countable interface will be removed from \Slim\Http\Response. - * Call `count` on `headers` or `cookies` properties directly. - * - * Countable: Count - */ - public function count() - { - return count($this->headers); - } - - /** - * DEPRECATION WARNING! IteratorAggregate interface will be removed from \Slim\Http\Response. - * Iterate `headers` or `cookies` properties directly. - * - * Get Iterator - * - * This returns the contained `\Slim\Http\Headers` instance which - * is itself iterable. - * - * @return \Slim\Http\Headers - */ - public function getIterator() - { - return $this->headers->getIterator(); - } - - /** - * Get message for HTTP status code - * @param int $status - * @return string|null - */ - public static function getMessageForCode($status) - { - if (isset(self::$messages[$status])) { - return self::$messages[$status]; - } else { - return null; - } - } -} diff --git a/vendor/slim/slim/Slim/Http/Util.php b/vendor/slim/slim/Slim/Http/Util.php deleted file mode 100644 index dafedb38d..000000000 --- a/vendor/slim/slim/Slim/Http/Util.php +++ /dev/null @@ -1,434 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Http; - -/** - * Slim HTTP Utilities - * - * This class provides useful methods for handling HTTP requests. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class Util -{ - /** - * Strip slashes from string or array - * - * This method strips slashes from its input. By default, this method will only - * strip slashes from its input if magic quotes are enabled. Otherwise, you may - * override the magic quotes setting with either TRUE or FALSE as the send argument - * to force this method to strip or not strip slashes from its input. - * - * @param array|string $rawData - * @param bool $overrideStripSlashes - * @return array|string - */ - public static function stripSlashesIfMagicQuotes($rawData, $overrideStripSlashes = null) - { - $strip = is_null($overrideStripSlashes) ? get_magic_quotes_gpc() : $overrideStripSlashes; - if ($strip) { - return self::stripSlashes($rawData); - } else { - return $rawData; - } - } - - /** - * Strip slashes from string or array - * @param array|string $rawData - * @return array|string - */ - protected static function stripSlashes($rawData) - { - return is_array($rawData) ? array_map(array('self', 'stripSlashes'), $rawData) : stripslashes($rawData); - } - - /** - * Encrypt data - * - * This method will encrypt data using a given key, vector, and cipher. - * By default, this will encrypt data using the RIJNDAEL/AES 256 bit cipher. You - * may override the default cipher and cipher mode by passing your own desired - * cipher and cipher mode as the final key-value array argument. - * - * @param string $data The unencrypted data - * @param string $key The encryption key - * @param string $iv The encryption initialization vector - * @param array $settings Optional key-value array with custom algorithm and mode - * @return string - */ - public static function encrypt($data, $key, $iv, $settings = array()) - { - if ($data === '' || !extension_loaded('mcrypt')) { - return $data; - } - - //Merge settings with defaults - $defaults = array( - 'algorithm' => MCRYPT_RIJNDAEL_256, - 'mode' => MCRYPT_MODE_CBC - ); - $settings = array_merge($defaults, $settings); - - //Get module - $module = mcrypt_module_open($settings['algorithm'], '', $settings['mode'], ''); - - //Validate IV - $ivSize = mcrypt_enc_get_iv_size($module); - if (strlen($iv) > $ivSize) { - $iv = substr($iv, 0, $ivSize); - } - - //Validate key - $keySize = mcrypt_enc_get_key_size($module); - if (strlen($key) > $keySize) { - $key = substr($key, 0, $keySize); - } - - //Encrypt value - mcrypt_generic_init($module, $key, $iv); - $res = @mcrypt_generic($module, $data); - mcrypt_generic_deinit($module); - - return $res; - } - - /** - * Decrypt data - * - * This method will decrypt data using a given key, vector, and cipher. - * By default, this will decrypt data using the RIJNDAEL/AES 256 bit cipher. You - * may override the default cipher and cipher mode by passing your own desired - * cipher and cipher mode as the final key-value array argument. - * - * @param string $data The encrypted data - * @param string $key The encryption key - * @param string $iv The encryption initialization vector - * @param array $settings Optional key-value array with custom algorithm and mode - * @return string - */ - public static function decrypt($data, $key, $iv, $settings = array()) - { - if ($data === '' || !extension_loaded('mcrypt')) { - return $data; - } - - //Merge settings with defaults - $defaults = array( - 'algorithm' => MCRYPT_RIJNDAEL_256, - 'mode' => MCRYPT_MODE_CBC - ); - $settings = array_merge($defaults, $settings); - - //Get module - $module = mcrypt_module_open($settings['algorithm'], '', $settings['mode'], ''); - - //Validate IV - $ivSize = mcrypt_enc_get_iv_size($module); - if (strlen($iv) > $ivSize) { - $iv = substr($iv, 0, $ivSize); - } - - //Validate key - $keySize = mcrypt_enc_get_key_size($module); - if (strlen($key) > $keySize) { - $key = substr($key, 0, $keySize); - } - - //Decrypt value - mcrypt_generic_init($module, $key, $iv); - $decryptedData = @mdecrypt_generic($module, $data); - $res = rtrim($decryptedData, "\0"); - mcrypt_generic_deinit($module); - - return $res; - } - - /** - * Serialize Response cookies into raw HTTP header - * @param \Slim\Http\Headers $headers The Response headers - * @param \Slim\Http\Cookies $cookies The Response cookies - * @param array $config The Slim app settings - */ - public static function serializeCookies(\Slim\Http\Headers &$headers, \Slim\Http\Cookies $cookies, array $config) - { - if ($config['cookies.encrypt']) { - foreach ($cookies as $name => $settings) { - if (is_string($settings['expires'])) { - $expires = strtotime($settings['expires']); - } else { - $expires = (int) $settings['expires']; - } - - $settings['value'] = static::encodeSecureCookie( - $settings['value'], - $expires, - $config['cookies.secret_key'], - $config['cookies.cipher'], - $config['cookies.cipher_mode'] - ); - static::setCookieHeader($headers, $name, $settings); - } - } else { - foreach ($cookies as $name => $settings) { - static::setCookieHeader($headers, $name, $settings); - } - } - } - - /** - * Encode secure cookie value - * - * This method will create the secure value of an HTTP cookie. The - * cookie value is encrypted and hashed so that its value is - * secure and checked for integrity when read in subsequent requests. - * - * @param string $value The insecure HTTP cookie value - * @param int $expires The UNIX timestamp at which this cookie will expire - * @param string $secret The secret key used to hash the cookie value - * @param int $algorithm The algorithm to use for encryption - * @param int $mode The algorithm mode to use for encryption - * @return string - */ - public static function encodeSecureCookie($value, $expires, $secret, $algorithm, $mode) - { - $key = hash_hmac('sha1', (string) $expires, $secret); - $iv = self::getIv($expires, $secret); - $secureString = base64_encode( - self::encrypt( - $value, - $key, - $iv, - array( - 'algorithm' => $algorithm, - 'mode' => $mode - ) - ) - ); - $verificationString = hash_hmac('sha1', $expires . $value, $key); - - return implode('|', array($expires, $secureString, $verificationString)); - } - - /** - * Decode secure cookie value - * - * This method will decode the secure value of an HTTP cookie. The - * cookie value is encrypted and hashed so that its value is - * secure and checked for integrity when read in subsequent requests. - * - * @param string $value The secure HTTP cookie value - * @param string $secret The secret key used to hash the cookie value - * @param int $algorithm The algorithm to use for encryption - * @param int $mode The algorithm mode to use for encryption - * @return bool|string - */ - public static function decodeSecureCookie($value, $secret, $algorithm, $mode) - { - if ($value) { - $value = explode('|', $value); - if (count($value) === 3 && ((int) $value[0] === 0 || (int) $value[0] > time())) { - $key = hash_hmac('sha1', $value[0], $secret); - $iv = self::getIv($value[0], $secret); - $data = self::decrypt( - base64_decode($value[1]), - $key, - $iv, - array( - 'algorithm' => $algorithm, - 'mode' => $mode - ) - ); - $verificationString = hash_hmac('sha1', $value[0] . $data, $key); - if ($verificationString === $value[2]) { - return $data; - } - } - } - - return false; - } - - /** - * Set HTTP cookie header - * - * This method will construct and set the HTTP `Set-Cookie` header. Slim - * uses this method instead of PHP's native `setcookie` method. This allows - * more control of the HTTP header irrespective of the native implementation's - * dependency on PHP versions. - * - * This method accepts the Slim_Http_Headers object by reference as its - * first argument; this method directly modifies this object instead of - * returning a value. - * - * @param array $header - * @param string $name - * @param string $value - */ - public static function setCookieHeader(&$header, $name, $value) - { - //Build cookie header - if (is_array($value)) { - $domain = ''; - $path = ''; - $expires = ''; - $secure = ''; - $httponly = ''; - if (isset($value['domain']) && $value['domain']) { - $domain = '; domain=' . $value['domain']; - } - if (isset($value['path']) && $value['path']) { - $path = '; path=' . $value['path']; - } - if (isset($value['expires'])) { - if (is_string($value['expires'])) { - $timestamp = strtotime($value['expires']); - } else { - $timestamp = (int) $value['expires']; - } - if ($timestamp !== 0) { - $expires = '; expires=' . gmdate('D, d-M-Y H:i:s e', $timestamp); - } - } - if (isset($value['secure']) && $value['secure']) { - $secure = '; secure'; - } - if (isset($value['httponly']) && $value['httponly']) { - $httponly = '; HttpOnly'; - } - $cookie = sprintf('%s=%s%s', urlencode($name), urlencode((string) $value['value']), $domain . $path . $expires . $secure . $httponly); - } else { - $cookie = sprintf('%s=%s', urlencode($name), urlencode((string) $value)); - } - - //Set cookie header - if (!isset($header['Set-Cookie']) || $header['Set-Cookie'] === '') { - $header['Set-Cookie'] = $cookie; - } else { - $header['Set-Cookie'] = implode("\n", array($header['Set-Cookie'], $cookie)); - } - } - - /** - * Delete HTTP cookie header - * - * This method will construct and set the HTTP `Set-Cookie` header to invalidate - * a client-side HTTP cookie. If a cookie with the same name (and, optionally, domain) - * is already set in the HTTP response, it will also be removed. Slim uses this method - * instead of PHP's native `setcookie` method. This allows more control of the HTTP header - * irrespective of PHP's native implementation's dependency on PHP versions. - * - * This method accepts the Slim_Http_Headers object by reference as its - * first argument; this method directly modifies this object instead of - * returning a value. - * - * @param array $header - * @param string $name - * @param array $value - */ - public static function deleteCookieHeader(&$header, $name, $value = array()) - { - //Remove affected cookies from current response header - $cookiesOld = array(); - $cookiesNew = array(); - if (isset($header['Set-Cookie'])) { - $cookiesOld = explode("\n", $header['Set-Cookie']); - } - foreach ($cookiesOld as $c) { - if (isset($value['domain']) && $value['domain']) { - $regex = sprintf('@%s=.*domain=%s@', urlencode($name), preg_quote($value['domain'])); - } else { - $regex = sprintf('@%s=@', urlencode($name)); - } - if (preg_match($regex, $c) === 0) { - $cookiesNew[] = $c; - } - } - if ($cookiesNew) { - $header['Set-Cookie'] = implode("\n", $cookiesNew); - } else { - unset($header['Set-Cookie']); - } - - //Set invalidating cookie to clear client-side cookie - self::setCookieHeader($header, $name, array_merge(array('value' => '', 'path' => null, 'domain' => null, 'expires' => time() - 100), $value)); - } - - /** - * Parse cookie header - * - * This method will parse the HTTP request's `Cookie` header - * and extract cookies into an associative array. - * - * @param string - * @return array - */ - public static function parseCookieHeader($header) - { - $cookies = array(); - $header = rtrim($header, "\r\n"); - $headerPieces = preg_split('@\s*[;,]\s*@', $header); - foreach ($headerPieces as $c) { - $cParts = explode('=', $c, 2); - if (count($cParts) === 2) { - $key = urldecode($cParts[0]); - $value = urldecode($cParts[1]); - if (!isset($cookies[$key])) { - $cookies[$key] = $value; - } - } - } - - return $cookies; - } - - /** - * Generate a random IV - * - * This method will generate a non-predictable IV for use with - * the cookie encryption - * - * @param int $expires The UNIX timestamp at which this cookie will expire - * @param string $secret The secret key used to hash the cookie value - * @return string Hash - */ - private static function getIv($expires, $secret) - { - $data1 = hash_hmac('sha1', 'a'.$expires.'b', $secret); - $data2 = hash_hmac('sha1', 'z'.$expires.'y', $secret); - - return pack("h*", $data1.$data2); - } -} diff --git a/vendor/slim/slim/Slim/Log.php b/vendor/slim/slim/Slim/Log.php deleted file mode 100644 index d872e8715..000000000 --- a/vendor/slim/slim/Slim/Log.php +++ /dev/null @@ -1,349 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim; - -/** - * Log - * - * This is the primary logger for a Slim application. You may provide - * a Log Writer in conjunction with this Log to write to various output - * destinations (e.g. a file). This class provides this interface: - * - * debug( mixed $object, array $context ) - * info( mixed $object, array $context ) - * notice( mixed $object, array $context ) - * warning( mixed $object, array $context ) - * error( mixed $object, array $context ) - * critical( mixed $object, array $context ) - * alert( mixed $object, array $context ) - * emergency( mixed $object, array $context ) - * log( mixed $level, mixed $object, array $context ) - * - * This class assumes only that your Log Writer has a public `write()` method - * that accepts any object as its one and only argument. The Log Writer - * class may write or send its argument anywhere: a file, STDERR, - * a remote web API, etc. The possibilities are endless. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class Log -{ - const EMERGENCY = 1; - const ALERT = 2; - const CRITICAL = 3; - const FATAL = 3; //DEPRECATED replace with CRITICAL - const ERROR = 4; - const WARN = 5; - const NOTICE = 6; - const INFO = 7; - const DEBUG = 8; - - /** - * @var array - */ - protected static $levels = array( - self::EMERGENCY => 'EMERGENCY', - self::ALERT => 'ALERT', - self::CRITICAL => 'CRITICAL', - self::ERROR => 'ERROR', - self::WARN => 'WARNING', - self::NOTICE => 'NOTICE', - self::INFO => 'INFO', - self::DEBUG => 'DEBUG' - ); - - /** - * @var mixed - */ - protected $writer; - - /** - * @var bool - */ - protected $enabled; - - /** - * @var int - */ - protected $level; - - /** - * Constructor - * @param mixed $writer - */ - public function __construct($writer) - { - $this->writer = $writer; - $this->enabled = true; - $this->level = self::DEBUG; - } - - /** - * Is logging enabled? - * @return bool - */ - public function getEnabled() - { - return $this->enabled; - } - - /** - * Enable or disable logging - * @param bool $enabled - */ - public function setEnabled($enabled) - { - if ($enabled) { - $this->enabled = true; - } else { - $this->enabled = false; - } - } - - /** - * Set level - * @param int $level - * @throws \InvalidArgumentException If invalid log level specified - */ - public function setLevel($level) - { - if (!isset(self::$levels[$level])) { - throw new \InvalidArgumentException('Invalid log level'); - } - $this->level = $level; - } - - /** - * Get level - * @return int - */ - public function getLevel() - { - return $this->level; - } - - /** - * Set writer - * @param mixed $writer - */ - public function setWriter($writer) - { - $this->writer = $writer; - } - - /** - * Get writer - * @return mixed - */ - public function getWriter() - { - return $this->writer; - } - - /** - * Is logging enabled? - * @return bool - */ - public function isEnabled() - { - return $this->enabled; - } - - /** - * Log debug message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function debug($object, $context = array()) - { - return $this->log(self::DEBUG, $object, $context); - } - - /** - * Log info message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function info($object, $context = array()) - { - return $this->log(self::INFO, $object, $context); - } - - /** - * Log notice message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function notice($object, $context = array()) - { - return $this->log(self::NOTICE, $object, $context); - } - - /** - * Log warning message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function warning($object, $context = array()) - { - return $this->log(self::WARN, $object, $context); - } - - /** - * DEPRECATED for function warning - * Log warning message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function warn($object, $context = array()) - { - return $this->log(self::WARN, $object, $context); - } - - /** - * Log error message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function error($object, $context = array()) - { - return $this->log(self::ERROR, $object, $context); - } - - /** - * Log critical message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function critical($object, $context = array()) - { - return $this->log(self::CRITICAL, $object, $context); - } - - /** - * DEPRECATED for function critical - * Log fatal message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function fatal($object, $context = array()) - { - return $this->log(self::CRITICAL, $object, $context); - } - - /** - * Log alert message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function alert($object, $context = array()) - { - return $this->log(self::ALERT, $object, $context); - } - - /** - * Log emergency message - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - */ - public function emergency($object, $context = array()) - { - return $this->log(self::EMERGENCY, $object, $context); - } - - /** - * Log message - * @param mixed $level - * @param mixed $object - * @param array $context - * @return mixed|bool What the Logger returns, or false if Logger not set or not enabled - * @throws \InvalidArgumentException If invalid log level - */ - public function log($level, $object, $context = array()) - { - if (!isset(self::$levels[$level])) { - throw new \InvalidArgumentException('Invalid log level supplied to function'); - } else if ($this->enabled && $this->writer && $level <= $this->level) { - $message = (string)$object; - if (count($context) > 0) { - if (isset($context['exception']) && $context['exception'] instanceof \Exception) { - $message .= ' - ' . $context['exception']; - unset($context['exception']); - } - $message = $this->interpolate($message, $context); - } - return $this->writer->write($message, $level); - } else { - return false; - } - } - - /** - * DEPRECATED for function log - * Log message - * @param mixed $object The object to log - * @param int $level The message level - * @return int|bool - */ - protected function write($object, $level) - { - return $this->log($level, $object); - } - - /** - * Interpolate log message - * @param mixed $message The log message - * @param array $context An array of placeholder values - * @return string The processed string - */ - protected function interpolate($message, $context = array()) - { - $replace = array(); - foreach ($context as $key => $value) { - $replace['{' . $key . '}'] = $value; - } - return strtr($message, $replace); - } -} diff --git a/vendor/slim/slim/Slim/LogWriter.php b/vendor/slim/slim/Slim/LogWriter.php deleted file mode 100644 index 5e44e2f57..000000000 --- a/vendor/slim/slim/Slim/LogWriter.php +++ /dev/null @@ -1,75 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim; - -/** - * Log Writer - * - * This class is used by Slim_Log to write log messages to a valid, writable - * resource handle (e.g. a file or STDERR). - * - * @package Slim - * @author Josh Lockhart - * @since 1.6.0 - */ -class LogWriter -{ - /** - * @var resource - */ - protected $resource; - - /** - * Constructor - * @param resource $resource - * @throws \InvalidArgumentException If invalid resource - */ - public function __construct($resource) - { - if (!is_resource($resource)) { - throw new \InvalidArgumentException('Cannot create LogWriter. Invalid resource handle.'); - } - $this->resource = $resource; - } - - /** - * Write message - * @param mixed $message - * @param int $level - * @return int|bool - */ - public function write($message, $level = null) - { - return fwrite($this->resource, (string) $message . PHP_EOL); - } -} diff --git a/vendor/slim/slim/Slim/Middleware.php b/vendor/slim/slim/Slim/Middleware.php deleted file mode 100644 index be2310064..000000000 --- a/vendor/slim/slim/Slim/Middleware.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim; - -/** - * Middleware - * - * @package Slim - * @author Josh Lockhart - * @since 1.6.0 - */ -abstract class Middleware -{ - /** - * @var \Slim\Slim Reference to the primary application instance - */ - protected $app; - - /** - * @var mixed Reference to the next downstream middleware - */ - protected $next; - - /** - * Set application - * - * This method injects the primary Slim application instance into - * this middleware. - * - * @param \Slim\Slim $application - */ - final public function setApplication($application) - { - $this->app = $application; - } - - /** - * Get application - * - * This method retrieves the application previously injected - * into this middleware. - * - * @return \Slim\Slim - */ - final public function getApplication() - { - return $this->app; - } - - /** - * Set next middleware - * - * This method injects the next downstream middleware into - * this middleware so that it may optionally be called - * when appropriate. - * - * @param \Slim|\Slim\Middleware - */ - final public function setNextMiddleware($nextMiddleware) - { - $this->next = $nextMiddleware; - } - - /** - * Get next middleware - * - * This method retrieves the next downstream middleware - * previously injected into this middleware. - * - * @return \Slim\Slim|\Slim\Middleware - */ - final public function getNextMiddleware() - { - return $this->next; - } - - /** - * Call - * - * Perform actions specific to this middleware and optionally - * call the next downstream middleware. - */ - abstract public function call(); -} diff --git a/vendor/slim/slim/Slim/Middleware/ContentTypes.php b/vendor/slim/slim/Slim/Middleware/ContentTypes.php deleted file mode 100644 index 08049db5d..000000000 --- a/vendor/slim/slim/Slim/Middleware/ContentTypes.php +++ /dev/null @@ -1,174 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Middleware; - - /** - * Content Types - * - * This is middleware for a Slim application that intercepts - * the HTTP request body and parses it into the appropriate - * PHP data structure if possible; else it returns the HTTP - * request body unchanged. This is particularly useful - * for preparing the HTTP request body for an XML or JSON API. - * - * @package Slim - * @author Josh Lockhart - * @since 1.6.0 - */ -class ContentTypes extends \Slim\Middleware -{ - /** - * @var array - */ - protected $contentTypes; - - /** - * Constructor - * @param array $settings - */ - public function __construct($settings = array()) - { - $defaults = array( - 'application/json' => array($this, 'parseJson'), - 'application/xml' => array($this, 'parseXml'), - 'text/xml' => array($this, 'parseXml'), - 'text/csv' => array($this, 'parseCsv') - ); - $this->contentTypes = array_merge($defaults, $settings); - } - - /** - * Call - */ - public function call() - { - $mediaType = $this->app->request()->getMediaType(); - if ($mediaType) { - $env = $this->app->environment(); - $env['slim.input_original'] = $env['slim.input']; - $env['slim.input'] = $this->parse($env['slim.input'], $mediaType); - } - $this->next->call(); - } - - /** - * Parse input - * - * This method will attempt to parse the request body - * based on its content type if available. - * - * @param string $input - * @param string $contentType - * @return mixed - */ - protected function parse ($input, $contentType) - { - if (isset($this->contentTypes[$contentType]) && is_callable($this->contentTypes[$contentType])) { - $result = call_user_func($this->contentTypes[$contentType], $input); - if ($result) { - return $result; - } - } - - return $input; - } - - /** - * Parse JSON - * - * This method converts the raw JSON input - * into an associative array. - * - * @param string $input - * @return array|string - */ - protected function parseJson($input) - { - if (function_exists('json_decode')) { - $result = json_decode($input, true); - if ($result) { - return $result; - } - } - } - - /** - * Parse XML - * - * This method creates a SimpleXMLElement - * based upon the XML input. If the SimpleXML - * extension is not available, the raw input - * will be returned unchanged. - * - * @param string $input - * @return \SimpleXMLElement|string - */ - protected function parseXml($input) - { - if (class_exists('SimpleXMLElement')) { - try { - $backup = libxml_disable_entity_loader(true); - $result = new \SimpleXMLElement($input); - libxml_disable_entity_loader($backup); - return $result; - } catch (\Exception $e) { - // Do nothing - } - } - - return $input; - } - - /** - * Parse CSV - * - * This method parses CSV content into a numeric array - * containing an array of data for each CSV line. - * - * @param string $input - * @return array - */ - protected function parseCsv($input) - { - $temp = fopen('php://memory', 'rw'); - fwrite($temp, $input); - fseek($temp, 0); - $res = array(); - while (($data = fgetcsv($temp)) !== false) { - $res[] = $data; - } - fclose($temp); - - return $res; - } -} diff --git a/vendor/slim/slim/Slim/Middleware/Flash.php b/vendor/slim/slim/Slim/Middleware/Flash.php deleted file mode 100644 index 96f685e9e..000000000 --- a/vendor/slim/slim/Slim/Middleware/Flash.php +++ /dev/null @@ -1,212 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Middleware; - - /** - * Flash - * - * This is middleware for a Slim application that enables - * Flash messaging between HTTP requests. This allows you - * set Flash messages for the current request, for the next request, - * or to retain messages from the previous request through to - * the next request. - * - * @package Slim - * @author Josh Lockhart - * @since 1.6.0 - */ -class Flash extends \Slim\Middleware implements \ArrayAccess, \IteratorAggregate, \Countable -{ - /** - * @var array - */ - protected $settings; - - /** - * @var array - */ - protected $messages; - - /** - * Constructor - * @param array $settings - */ - public function __construct($settings = array()) - { - $this->settings = array_merge(array('key' => 'slim.flash'), $settings); - $this->messages = array( - 'prev' => array(), //flash messages from prev request (loaded when middleware called) - 'next' => array(), //flash messages for next request - 'now' => array() //flash messages for current request - ); - } - - /** - * Call - */ - public function call() - { - //Read flash messaging from previous request if available - $this->loadMessages(); - - //Prepare flash messaging for current request - $env = $this->app->environment(); - $env['slim.flash'] = $this; - $this->next->call(); - $this->save(); - } - - /** - * Now - * - * Specify a flash message for a given key to be shown for the current request - * - * @param string $key - * @param string $value - */ - public function now($key, $value) - { - $this->messages['now'][(string) $key] = $value; - } - - /** - * Set - * - * Specify a flash message for a given key to be shown for the next request - * - * @param string $key - * @param string $value - */ - public function set($key, $value) - { - $this->messages['next'][(string) $key] = $value; - } - - /** - * Keep - * - * Retain flash messages from the previous request for the next request - */ - public function keep() - { - foreach ($this->messages['prev'] as $key => $val) { - $this->messages['next'][$key] = $val; - } - } - - /** - * Save - */ - public function save() - { - $_SESSION[$this->settings['key']] = $this->messages['next']; - } - - /** - * Load messages from previous request if available - */ - public function loadMessages() - { - if (isset($_SESSION[$this->settings['key']])) { - $this->messages['prev'] = $_SESSION[$this->settings['key']]; - } - } - - /** - * Return array of flash messages to be shown for the current request - * - * @return array - */ - public function getMessages() - { - return array_merge($this->messages['prev'], $this->messages['now']); - } - - /** - * Array Access: Offset Exists - */ - public function offsetExists($offset) - { - $messages = $this->getMessages(); - - return isset($messages[$offset]); - } - - /** - * Array Access: Offset Get - */ - public function offsetGet($offset) - { - $messages = $this->getMessages(); - - return isset($messages[$offset]) ? $messages[$offset] : null; - } - - /** - * Array Access: Offset Set - */ - public function offsetSet($offset, $value) - { - $this->now($offset, $value); - } - - /** - * Array Access: Offset Unset - */ - public function offsetUnset($offset) - { - unset($this->messages['prev'][$offset], $this->messages['now'][$offset]); - } - - /** - * Iterator Aggregate: Get Iterator - * @return \ArrayIterator - */ - public function getIterator() - { - $messages = $this->getMessages(); - - return new \ArrayIterator($messages); - } - - /** - * Countable: Count - */ - public function count() - { - return count($this->getMessages()); - } - - - -} diff --git a/vendor/slim/slim/Slim/Middleware/MethodOverride.php b/vendor/slim/slim/Slim/Middleware/MethodOverride.php deleted file mode 100644 index 7fa3bb0a3..000000000 --- a/vendor/slim/slim/Slim/Middleware/MethodOverride.php +++ /dev/null @@ -1,94 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Middleware; - - /** - * HTTP Method Override - * - * This is middleware for a Slim application that allows traditional - * desktop browsers to submit pseudo PUT and DELETE requests by relying - * on a pre-determined request parameter. Without this middleware, - * desktop browsers are only able to submit GET and POST requests. - * - * This middleware is included automatically! - * - * @package Slim - * @author Josh Lockhart - * @since 1.6.0 - */ -class MethodOverride extends \Slim\Middleware -{ - /** - * @var array - */ - protected $settings; - - /** - * Constructor - * @param array $settings - */ - public function __construct($settings = array()) - { - $this->settings = array_merge(array('key' => '_METHOD'), $settings); - } - - /** - * Call - * - * Implements Slim middleware interface. This method is invoked and passed - * an array of environment variables. This middleware inspects the environment - * variables for the HTTP method override parameter; if found, this middleware - * modifies the environment settings so downstream middleware and/or the Slim - * application will treat the request with the desired HTTP method. - * - * @return array[status, header, body] - */ - public function call() - { - $env = $this->app->environment(); - if (isset($env['HTTP_X_HTTP_METHOD_OVERRIDE'])) { - // Header commonly used by Backbone.js and others - $env['slim.method_override.original_method'] = $env['REQUEST_METHOD']; - $env['REQUEST_METHOD'] = strtoupper($env['HTTP_X_HTTP_METHOD_OVERRIDE']); - } elseif (isset($env['REQUEST_METHOD']) && $env['REQUEST_METHOD'] === 'POST') { - // HTML Form Override - $req = new \Slim\Http\Request($env); - $method = $req->post($this->settings['key']); - if ($method) { - $env['slim.method_override.original_method'] = $env['REQUEST_METHOD']; - $env['REQUEST_METHOD'] = strtoupper($method); - } - } - $this->next->call(); - } -} diff --git a/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php b/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php deleted file mode 100644 index 8a56442b0..000000000 --- a/vendor/slim/slim/Slim/Middleware/PrettyExceptions.php +++ /dev/null @@ -1,116 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Middleware; - -/** - * Pretty Exceptions - * - * This middleware catches any Exception thrown by the surrounded - * application and displays a developer-friendly diagnostic screen. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class PrettyExceptions extends \Slim\Middleware -{ - /** - * @var array - */ - protected $settings; - - /** - * Constructor - * @param array $settings - */ - public function __construct($settings = array()) - { - $this->settings = $settings; - } - - /** - * Call - */ - public function call() - { - try { - $this->next->call(); - } catch (\Exception $e) { - $log = $this->app->getLog(); // Force Slim to append log to env if not already - $env = $this->app->environment(); - $env['slim.log'] = $log; - $env['slim.log']->error($e); - $this->app->contentType('text/html'); - $this->app->response()->status(500); - $this->app->response()->body($this->renderBody($env, $e)); - } - } - - /** - * Render response body - * @param array $env - * @param \Exception $exception - * @return string - */ - protected function renderBody(&$env, $exception) - { - $title = 'Slim Application Error'; - $code = $exception->getCode(); - $message = $exception->getMessage(); - $file = $exception->getFile(); - $line = $exception->getLine(); - $trace = str_replace(array('#', '\n'), array('
#', '
'), $exception->getTraceAsString()); - $html = sprintf('

%s

', $title); - $html .= '

The application could not run because of the following error:

'; - $html .= '

Details

'; - $html .= sprintf('
Type: %s
', get_class($exception)); - if ($code) { - $html .= sprintf('
Code: %s
', $code); - } - if ($message) { - $html .= sprintf('
Message: %s
', $message); - } - if ($file) { - $html .= sprintf('
File: %s
', $file); - } - if ($line) { - $html .= sprintf('
Line: %s
', $line); - } - if ($trace) { - $html .= '

Trace

'; - $html .= sprintf('
%s
', $trace); - } - - return sprintf("%s%s", $title, $html); - } -} diff --git a/vendor/slim/slim/Slim/Middleware/SessionCookie.php b/vendor/slim/slim/Slim/Middleware/SessionCookie.php deleted file mode 100644 index a467475d0..000000000 --- a/vendor/slim/slim/Slim/Middleware/SessionCookie.php +++ /dev/null @@ -1,210 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim\Middleware; - -/** - * Session Cookie - * - * This class provides an HTTP cookie storage mechanism - * for session data. This class avoids using a PHP session - * and instead serializes/unserializes the $_SESSION global - * variable to/from an HTTP cookie. - * - * You should NEVER store sensitive data in a client-side cookie - * in any format, encrypted (with cookies.encrypt) or not. If you - * need to store sensitive user information in a session, you should - * rely on PHP's native session implementation, or use other middleware - * to store session data in a database or alternative server-side cache. - * - * Because this class stores serialized session data in an HTTP cookie, - * you are inherently limited to 4 Kb. If you attempt to store - * more than this amount, serialization will fail. - * - * @package Slim - * @author Josh Lockhart - * @since 1.6.0 - */ -class SessionCookie extends \Slim\Middleware -{ - /** - * @var array - */ - protected $settings; - - /** - * Constructor - * - * @param array $settings - */ - public function __construct($settings = array()) - { - $defaults = array( - 'expires' => '20 minutes', - 'path' => '/', - 'domain' => null, - 'secure' => false, - 'httponly' => false, - 'name' => 'slim_session', - ); - $this->settings = array_merge($defaults, $settings); - if (is_string($this->settings['expires'])) { - $this->settings['expires'] = strtotime($this->settings['expires']); - } - - /** - * Session - * - * We must start a native PHP session to initialize the $_SESSION superglobal. - * However, we won't be using the native session store for persistence, so we - * disable the session cookie and cache limiter. We also set the session - * handler to this class instance to avoid PHP's native session file locking. - */ - ini_set('session.use_cookies', 0); - session_cache_limiter(false); - session_set_save_handler( - array($this, 'open'), - array($this, 'close'), - array($this, 'read'), - array($this, 'write'), - array($this, 'destroy'), - array($this, 'gc') - ); - } - - /** - * Call - */ - public function call() - { - $this->loadSession(); - $this->next->call(); - $this->saveSession(); - } - - /** - * Load session - */ - protected function loadSession() - { - if (session_id() === '') { - session_start(); - } - - $value = $this->app->getCookie($this->settings['name']); - - if ($value) { - try { - $_SESSION = unserialize($value); - } catch (\Exception $e) { - $this->app->getLog()->error('Error unserializing session cookie value! ' . $e->getMessage()); - } - } else { - $_SESSION = array(); - } - } - - /** - * Save session - */ - protected function saveSession() - { - $value = serialize($_SESSION); - - if (strlen($value) > 4096) { - $this->app->getLog()->error('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.'); - } else { - $this->app->setCookie( - $this->settings['name'], - $value, - $this->settings['expires'], - $this->settings['path'], - $this->settings['domain'], - $this->settings['secure'], - $this->settings['httponly'] - ); - } - // session_destroy(); - } - - /******************************************************************************** - * Session Handler - *******************************************************************************/ - - /** - * @codeCoverageIgnore - */ - public function open($savePath, $sessionName) - { - return true; - } - - /** - * @codeCoverageIgnore - */ - public function close() - { - return true; - } - - /** - * @codeCoverageIgnore - */ - public function read($id) - { - return ''; - } - - /** - * @codeCoverageIgnore - */ - public function write($id, $data) - { - return true; - } - - /** - * @codeCoverageIgnore - */ - public function destroy($id) - { - return true; - } - - /** - * @codeCoverageIgnore - */ - public function gc($maxlifetime) - { - return true; - } -} diff --git a/vendor/slim/slim/Slim/Route.php b/vendor/slim/slim/Slim/Route.php deleted file mode 100644 index 99b47a135..000000000 --- a/vendor/slim/slim/Slim/Route.php +++ /dev/null @@ -1,465 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim; - -/** - * Route - * @package Slim - * @author Josh Lockhart, Thomas Bley - * @since 1.0.0 - */ -class Route -{ - /** - * @var string The route pattern (e.g. "/books/:id") - */ - protected $pattern; - - /** - * @var mixed The route callable - */ - protected $callable; - - /** - * @var array Conditions for this route's URL parameters - */ - protected $conditions = array(); - - /** - * @var array Default conditions applied to all route instances - */ - protected static $defaultConditions = array(); - - /** - * @var string The name of this route (optional) - */ - protected $name; - - /** - * @var array Key-value array of URL parameters - */ - protected $params = array(); - - /** - * @var array value array of URL parameter names - */ - protected $paramNames = array(); - - /** - * @var array key array of URL parameter names with + at the end - */ - protected $paramNamesPath = array(); - - /** - * @var array HTTP methods supported by this Route - */ - protected $methods = array(); - - /** - * @var array[Callable] Middleware to be run before only this route instance - */ - protected $middleware = array(); - - /** - * @var bool Whether or not this route should be matched in a case-sensitive manner - */ - protected $caseSensitive; - - /** - * Constructor - * @param string $pattern The URL pattern (e.g. "/books/:id") - * @param mixed $callable Anything that returns TRUE for is_callable() - * @param bool $caseSensitive Whether or not this route should be matched in a case-sensitive manner - */ - public function __construct($pattern, $callable, $caseSensitive = true) - { - $this->setPattern($pattern); - $this->setCallable($callable); - $this->setConditions(self::getDefaultConditions()); - $this->caseSensitive = $caseSensitive; - } - - /** - * Set default route conditions for all instances - * @param array $defaultConditions - */ - public static function setDefaultConditions(array $defaultConditions) - { - self::$defaultConditions = $defaultConditions; - } - - /** - * Get default route conditions for all instances - * @return array - */ - public static function getDefaultConditions() - { - return self::$defaultConditions; - } - - /** - * Get route pattern - * @return string - */ - public function getPattern() - { - return $this->pattern; - } - - /** - * Set route pattern - * @param string $pattern - */ - public function setPattern($pattern) - { - $this->pattern = $pattern; - } - - /** - * Get route callable - * @return mixed - */ - public function getCallable() - { - return $this->callable; - } - - /** - * Set route callable - * @param mixed $callable - * @throws \InvalidArgumentException If argument is not callable - */ - public function setCallable($callable) - { - $matches = array(); - if (is_string($callable) && preg_match('!^([^\:]+)\:([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)$!', $callable, $matches)) { - $class = $matches[1]; - $method = $matches[2]; - $callable = function() use ($class, $method) { - static $obj = null; - if ($obj === null) { - $obj = new $class; - } - return call_user_func_array(array($obj, $method), func_get_args()); - }; - } - - if (!is_callable($callable)) { - throw new \InvalidArgumentException('Route callable must be callable'); - } - - $this->callable = $callable; - } - - /** - * Get route conditions - * @return array - */ - public function getConditions() - { - return $this->conditions; - } - - /** - * Set route conditions - * @param array $conditions - */ - public function setConditions(array $conditions) - { - $this->conditions = $conditions; - } - - /** - * Get route name - * @return string|null - */ - public function getName() - { - return $this->name; - } - - /** - * Set route name - * @param string $name - */ - public function setName($name) - { - $this->name = (string)$name; - } - - /** - * Get route parameters - * @return array - */ - public function getParams() - { - return $this->params; - } - - /** - * Set route parameters - * @param array $params - */ - public function setParams($params) - { - $this->params = $params; - } - - /** - * Get route parameter value - * @param string $index Name of URL parameter - * @return string - * @throws \InvalidArgumentException If route parameter does not exist at index - */ - public function getParam($index) - { - if (!isset($this->params[$index])) { - throw new \InvalidArgumentException('Route parameter does not exist at specified index'); - } - - return $this->params[$index]; - } - - /** - * Set route parameter value - * @param string $index Name of URL parameter - * @param mixed $value The new parameter value - * @throws \InvalidArgumentException If route parameter does not exist at index - */ - public function setParam($index, $value) - { - if (!isset($this->params[$index])) { - throw new \InvalidArgumentException('Route parameter does not exist at specified index'); - } - $this->params[$index] = $value; - } - - /** - * Add supported HTTP method(s) - */ - public function setHttpMethods() - { - $args = func_get_args(); - $this->methods = $args; - } - - /** - * Get supported HTTP methods - * @return array - */ - public function getHttpMethods() - { - return $this->methods; - } - - /** - * Append supported HTTP methods - */ - public function appendHttpMethods() - { - $args = func_get_args(); - $this->methods = array_merge($this->methods, $args); - } - - /** - * Append supported HTTP methods (alias for Route::appendHttpMethods) - * @return \Slim\Route - */ - public function via() - { - $args = func_get_args(); - $this->methods = array_merge($this->methods, $args); - - return $this; - } - - /** - * Detect support for an HTTP method - * @param string $method - * @return bool - */ - public function supportsHttpMethod($method) - { - return in_array($method, $this->methods); - } - - /** - * Get middleware - * @return array[Callable] - */ - public function getMiddleware() - { - return $this->middleware; - } - - /** - * Set middleware - * - * This method allows middleware to be assigned to a specific Route. - * If the method argument `is_callable` (including callable arrays!), - * we directly append the argument to `$this->middleware`. Else, we - * assume the argument is an array of callables and merge the array - * with `$this->middleware`. Each middleware is checked for is_callable() - * and an InvalidArgumentException is thrown immediately if it isn't. - * - * @param Callable|array[Callable] - * @return \Slim\Route - * @throws \InvalidArgumentException If argument is not callable or not an array of callables. - */ - public function setMiddleware($middleware) - { - if (is_callable($middleware)) { - $this->middleware[] = $middleware; - } elseif (is_array($middleware)) { - foreach ($middleware as $callable) { - if (!is_callable($callable)) { - throw new \InvalidArgumentException('All Route middleware must be callable'); - } - } - $this->middleware = array_merge($this->middleware, $middleware); - } else { - throw new \InvalidArgumentException('Route middleware must be callable or an array of callables'); - } - - return $this; - } - - /** - * Matches URI? - * - * Parse this route's pattern, and then compare it to an HTTP resource URI - * This method was modeled after the techniques demonstrated by Dan Sosedoff at: - * - * http://blog.sosedoff.com/2009/09/20/rails-like-php-url-router/ - * - * @param string $resourceUri A Request URI - * @return bool - */ - public function matches($resourceUri) - { - //Convert URL params into regex patterns, construct a regex for this route, init params - $patternAsRegex = preg_replace_callback( - '#:([\w]+)\+?#', - array($this, 'matchesCallback'), - str_replace(')', ')?', (string)$this->pattern) - ); - if (substr($this->pattern, -1) === '/') { - $patternAsRegex .= '?'; - } - - $regex = '#^' . $patternAsRegex . '$#'; - - if ($this->caseSensitive === false) { - $regex .= 'i'; - } - - //Cache URL params' names and values if this route matches the current HTTP request - if (!preg_match($regex, $resourceUri, $paramValues)) { - return false; - } - foreach ($this->paramNames as $name) { - if (isset($paramValues[$name])) { - if (isset($this->paramNamesPath[$name])) { - $this->params[$name] = explode('/', urldecode($paramValues[$name])); - } else { - $this->params[$name] = urldecode($paramValues[$name]); - } - } - } - - return true; - } - - /** - * Convert a URL parameter (e.g. ":id", ":id+") into a regular expression - * @param array $m URL parameters - * @return string Regular expression for URL parameter - */ - protected function matchesCallback($m) - { - $this->paramNames[] = $m[1]; - if (isset($this->conditions[$m[1]])) { - return '(?P<' . $m[1] . '>' . $this->conditions[$m[1]] . ')'; - } - if (substr($m[0], -1) === '+') { - $this->paramNamesPath[$m[1]] = 1; - - return '(?P<' . $m[1] . '>.+)'; - } - - return '(?P<' . $m[1] . '>[^/]+)'; - } - - /** - * Set route name - * @param string $name The name of the route - * @return \Slim\Route - */ - public function name($name) - { - $this->setName($name); - - return $this; - } - - /** - * Merge route conditions - * @param array $conditions Key-value array of URL parameter conditions - * @return \Slim\Route - */ - public function conditions(array $conditions) - { - $this->conditions = array_merge($this->conditions, $conditions); - - return $this; - } - - /** - * Dispatch route - * - * This method invokes the route object's callable. If middleware is - * registered for the route, each callable middleware is invoked in - * the order specified. - * - * @return bool - */ - public function dispatch() - { - foreach ($this->middleware as $mw) { - call_user_func_array($mw, array($this)); - } - - $return = call_user_func_array($this->getCallable(), array_values($this->getParams())); - return ($return === false) ? false : true; - } -} diff --git a/vendor/slim/slim/Slim/Router.php b/vendor/slim/slim/Slim/Router.php deleted file mode 100644 index b0e7a60f2..000000000 --- a/vendor/slim/slim/Slim/Router.php +++ /dev/null @@ -1,257 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim; - -/** - * Router - * - * This class organizes, iterates, and dispatches \Slim\Route objects. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class Router -{ - /** - * @var Route The current route (most recently dispatched) - */ - protected $currentRoute; - - /** - * @var array Lookup hash of all route objects - */ - protected $routes; - - /** - * @var array Lookup hash of named route objects, keyed by route name (lazy-loaded) - */ - protected $namedRoutes; - - /** - * @var array Array of route objects that match the request URI (lazy-loaded) - */ - protected $matchedRoutes; - - /** - * @var array Array containing all route groups - */ - protected $routeGroups; - - /** - * Constructor - */ - public function __construct() - { - $this->routes = array(); - $this->routeGroups = array(); - } - - /** - * Get Current Route object or the first matched one if matching has been performed - * @return \Slim\Route|null - */ - public function getCurrentRoute() - { - if ($this->currentRoute !== null) { - return $this->currentRoute; - } - - if (is_array($this->matchedRoutes) && count($this->matchedRoutes) > 0) { - return $this->matchedRoutes[0]; - } - - return null; - } - - /** - * Return route objects that match the given HTTP method and URI - * @param string $httpMethod The HTTP method to match against - * @param string $resourceUri The resource URI to match against - * @param bool $reload Should matching routes be re-parsed? - * @return array[\Slim\Route] - */ - public function getMatchedRoutes($httpMethod, $resourceUri, $reload = false) - { - if ($reload || is_null($this->matchedRoutes)) { - $this->matchedRoutes = array(); - foreach ($this->routes as $route) { - if (!$route->supportsHttpMethod($httpMethod) && !$route->supportsHttpMethod("ANY")) { - continue; - } - - if ($route->matches($resourceUri)) { - $this->matchedRoutes[] = $route; - } - } - } - - return $this->matchedRoutes; - } - - /** - * Add a route object to the router - * @param \Slim\Route $route The Slim Route - */ - public function map(\Slim\Route $route) - { - list($groupPattern, $groupMiddleware) = $this->processGroups(); - - $route->setPattern($groupPattern . $route->getPattern()); - $this->routes[] = $route; - - - foreach ($groupMiddleware as $middleware) { - $route->setMiddleware($middleware); - } - } - - /** - * A helper function for processing the group's pattern and middleware - * @return array Returns an array with the elements: pattern, middlewareArr - */ - protected function processGroups() - { - $pattern = ""; - $middleware = array(); - foreach ($this->routeGroups as $group) { - $k = key($group); - $pattern .= $k; - if (is_array($group[$k])) { - $middleware = array_merge($middleware, $group[$k]); - } - } - return array($pattern, $middleware); - } - - /** - * Add a route group to the array - * @param string $group The group pattern (ie. "/books/:id") - * @param array|null $middleware Optional parameter array of middleware - * @return int The index of the new group - */ - public function pushGroup($group, $middleware = array()) - { - return array_push($this->routeGroups, array($group => $middleware)); - } - - /** - * Removes the last route group from the array - * @return bool True if successful, else False - */ - public function popGroup() - { - return (array_pop($this->routeGroups) !== null); - } - - /** - * Get URL for named route - * @param string $name The name of the route - * @param array $params Associative array of URL parameter names and replacement values - * @throws \RuntimeException If named route not found - * @return string The URL for the given route populated with provided replacement values - */ - public function urlFor($name, $params = array()) - { - if (!$this->hasNamedRoute($name)) { - throw new \RuntimeException('Named route not found for name: ' . $name); - } - $search = array(); - foreach ($params as $key => $value) { - $search[] = '#:' . preg_quote($key, '#') . '\+?(?!\w)#'; - } - $pattern = preg_replace($search, $params, $this->getNamedRoute($name)->getPattern()); - - //Remove remnants of unpopulated, trailing optional pattern segments, escaped special characters - return preg_replace('#\(/?:.+\)|\(|\)|\\\\#', '', $pattern); - } - - /** - * Add named route - * @param string $name The route name - * @param \Slim\Route $route The route object - * @throws \RuntimeException If a named route already exists with the same name - */ - public function addNamedRoute($name, \Slim\Route $route) - { - if ($this->hasNamedRoute($name)) { - throw new \RuntimeException('Named route already exists with name: ' . $name); - } - $this->namedRoutes[(string) $name] = $route; - } - - /** - * Has named route - * @param string $name The route name - * @return bool - */ - public function hasNamedRoute($name) - { - $this->getNamedRoutes(); - - return isset($this->namedRoutes[(string) $name]); - } - - /** - * Get named route - * @param string $name - * @return \Slim\Route|null - */ - public function getNamedRoute($name) - { - $this->getNamedRoutes(); - if ($this->hasNamedRoute($name)) { - return $this->namedRoutes[(string) $name]; - } else { - return null; - } - } - - /** - * Get named routes - * @return \ArrayIterator - */ - public function getNamedRoutes() - { - if (is_null($this->namedRoutes)) { - $this->namedRoutes = array(); - foreach ($this->routes as $route) { - if ($route->getName() !== null) { - $this->addNamedRoute($route->getName(), $route); - } - } - } - - return new \ArrayIterator($this->namedRoutes); - } -} diff --git a/vendor/slim/slim/Slim/Slim.php b/vendor/slim/slim/Slim/Slim.php deleted file mode 100644 index cb8ef664b..000000000 --- a/vendor/slim/slim/Slim/Slim.php +++ /dev/null @@ -1,1412 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim; - -// Ensure mcrypt constants are defined even if mcrypt extension is not loaded -if (!extension_loaded('mcrypt')) { - define('MCRYPT_MODE_CBC', 0); - define('MCRYPT_RIJNDAEL_256', 0); -} - -/** - * Slim - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - * - * @property \Slim\Environment $environment - * @property \Slim\Http\Response $response - * @property \Slim\Http\Request $request - * @property \Slim\Router $router - */ -class Slim -{ - /** - * @const string - */ - const VERSION = '2.4.2'; - - /** - * @var \Slim\Helper\Set - */ - public $container; - - /** - * @var array[\Slim] - */ - protected static $apps = array(); - - /** - * @var string - */ - protected $name; - - /** - * @var array - */ - protected $middleware; - - /** - * @var mixed Callable to be invoked if application error - */ - protected $error; - - /** - * @var mixed Callable to be invoked if no matching routes are found - */ - protected $notFound; - - /** - * @var array - */ - protected $hooks = array( - 'slim.before' => array(array()), - 'slim.before.router' => array(array()), - 'slim.before.dispatch' => array(array()), - 'slim.after.dispatch' => array(array()), - 'slim.after.router' => array(array()), - 'slim.after' => array(array()) - ); - - /******************************************************************************** - * PSR-0 Autoloader - * - * Do not use if you are using Composer to autoload dependencies. - *******************************************************************************/ - - /** - * Slim PSR-0 autoloader - */ - public static function autoload($className) - { - $thisClass = str_replace(__NAMESPACE__.'\\', '', __CLASS__); - - $baseDir = __DIR__; - - if (substr($baseDir, -strlen($thisClass)) === $thisClass) { - $baseDir = substr($baseDir, 0, -strlen($thisClass)); - } - - $className = ltrim($className, '\\'); - $fileName = $baseDir; - $namespace = ''; - if ($lastNsPos = strripos($className, '\\')) { - $namespace = substr($className, 0, $lastNsPos); - $className = substr($className, $lastNsPos + 1); - $fileName .= str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; - } - $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; - - if (file_exists($fileName)) { - require $fileName; - } - } - - /** - * Register Slim's PSR-0 autoloader - */ - public static function registerAutoloader() - { - spl_autoload_register(__NAMESPACE__ . "\\Slim::autoload"); - } - - /******************************************************************************** - * Instantiation and Configuration - *******************************************************************************/ - - /** - * Constructor - * @param array $userSettings Associative array of application settings - */ - public function __construct(array $userSettings = array()) - { - // Setup IoC container - $this->container = new \Slim\Helper\Set(); - $this->container['settings'] = array_merge(static::getDefaultSettings(), $userSettings); - - // Default environment - $this->container->singleton('environment', function ($c) { - return \Slim\Environment::getInstance(); - }); - - // Default request - $this->container->singleton('request', function ($c) { - return new \Slim\Http\Request($c['environment']); - }); - - // Default response - $this->container->singleton('response', function ($c) { - return new \Slim\Http\Response(); - }); - - // Default router - $this->container->singleton('router', function ($c) { - return new \Slim\Router(); - }); - - // Default view - $this->container->singleton('view', function ($c) { - $viewClass = $c['settings']['view']; - $templatesPath = $c['settings']['templates.path']; - - $view = ($viewClass instanceOf \Slim\View) ? $viewClass : new $viewClass; - $view->setTemplatesDirectory($templatesPath); - return $view; - }); - - // Default log writer - $this->container->singleton('logWriter', function ($c) { - $logWriter = $c['settings']['log.writer']; - - return is_object($logWriter) ? $logWriter : new \Slim\LogWriter($c['environment']['slim.errors']); - }); - - // Default log - $this->container->singleton('log', function ($c) { - $log = new \Slim\Log($c['logWriter']); - $log->setEnabled($c['settings']['log.enabled']); - $log->setLevel($c['settings']['log.level']); - $env = $c['environment']; - $env['slim.log'] = $log; - - return $log; - }); - - // Default mode - $this->container['mode'] = function ($c) { - $mode = $c['settings']['mode']; - - if (isset($_ENV['SLIM_MODE'])) { - $mode = $_ENV['SLIM_MODE']; - } else { - $envMode = getenv('SLIM_MODE'); - if ($envMode !== false) { - $mode = $envMode; - } - } - - return $mode; - }; - - // Define default middleware stack - $this->middleware = array($this); - $this->add(new \Slim\Middleware\Flash()); - $this->add(new \Slim\Middleware\MethodOverride()); - - // Make default if first instance - if (is_null(static::getInstance())) { - $this->setName('default'); - } - } - - public function __get($name) - { - return $this->container[$name]; - } - - public function __set($name, $value) - { - $this->container[$name] = $value; - } - - public function __isset($name) - { - return isset($this->container[$name]); - } - - public function __unset($name) - { - unset($this->container[$name]); - } - - /** - * Get application instance by name - * @param string $name The name of the Slim application - * @return \Slim\Slim|null - */ - public static function getInstance($name = 'default') - { - return isset(static::$apps[$name]) ? static::$apps[$name] : null; - } - - /** - * Set Slim application name - * @param string $name The name of this Slim application - */ - public function setName($name) - { - $this->name = $name; - static::$apps[$name] = $this; - } - - /** - * Get Slim application name - * @return string|null - */ - public function getName() - { - return $this->name; - } - - /** - * Get default application settings - * @return array - */ - public static function getDefaultSettings() - { - return array( - // Application - 'mode' => 'development', - // Debugging - 'debug' => true, - // Logging - 'log.writer' => null, - 'log.level' => \Slim\Log::DEBUG, - 'log.enabled' => true, - // View - 'templates.path' => './templates', - 'view' => '\Slim\View', - // Cookies - 'cookies.encrypt' => false, - 'cookies.lifetime' => '20 minutes', - 'cookies.path' => '/', - 'cookies.domain' => null, - 'cookies.secure' => false, - 'cookies.httponly' => false, - // Encryption - 'cookies.secret_key' => 'CHANGE_ME', - 'cookies.cipher' => MCRYPT_RIJNDAEL_256, - 'cookies.cipher_mode' => MCRYPT_MODE_CBC, - // HTTP - 'http.version' => '1.1', - // Routing - 'routes.case_sensitive' => true - ); - } - - /** - * Configure Slim Settings - * - * This method defines application settings and acts as a setter and a getter. - * - * If only one argument is specified and that argument is a string, the value - * of the setting identified by the first argument will be returned, or NULL if - * that setting does not exist. - * - * If only one argument is specified and that argument is an associative array, - * the array will be merged into the existing application settings. - * - * If two arguments are provided, the first argument is the name of the setting - * to be created or updated, and the second argument is the setting value. - * - * @param string|array $name If a string, the name of the setting to set or retrieve. Else an associated array of setting names and values - * @param mixed $value If name is a string, the value of the setting identified by $name - * @return mixed The value of a setting if only one argument is a string - */ - public function config($name, $value = null) - { - $c = $this->container; - - if (is_array($name)) { - if (true === $value) { - $c['settings'] = array_merge_recursive($c['settings'], $name); - } else { - $c['settings'] = array_merge($c['settings'], $name); - } - } elseif (func_num_args() === 1) { - return isset($c['settings'][$name]) ? $c['settings'][$name] : null; - } else { - $settings = $c['settings']; - $settings[$name] = $value; - $c['settings'] = $settings; - } - } - - /******************************************************************************** - * Application Modes - *******************************************************************************/ - - /** - * Get application mode - * - * This method determines the application mode. It first inspects the $_ENV - * superglobal for key `SLIM_MODE`. If that is not found, it queries - * the `getenv` function. Else, it uses the application `mode` setting. - * - * @return string - */ - public function getMode() - { - return $this->mode; - } - - /** - * Configure Slim for a given mode - * - * This method will immediately invoke the callable if - * the specified mode matches the current application mode. - * Otherwise, the callable is ignored. This should be called - * only _after_ you initialize your Slim app. - * - * @param string $mode - * @param mixed $callable - * @return void - */ - public function configureMode($mode, $callable) - { - if ($mode === $this->getMode() && is_callable($callable)) { - call_user_func($callable); - } - } - - /******************************************************************************** - * Logging - *******************************************************************************/ - - /** - * Get application log - * @return \Slim\Log - */ - public function getLog() - { - return $this->log; - } - - /******************************************************************************** - * Routing - *******************************************************************************/ - - /** - * Add GET|POST|PUT|PATCH|DELETE route - * - * Adds a new route to the router with associated callable. This - * route will only be invoked when the HTTP request's method matches - * this route's method. - * - * ARGUMENTS: - * - * First: string The URL pattern (REQUIRED) - * In-Between: mixed Anything that returns TRUE for `is_callable` (OPTIONAL) - * Last: mixed Anything that returns TRUE for `is_callable` (REQUIRED) - * - * The first argument is required and must always be the - * route pattern (ie. '/books/:id'). - * - * The last argument is required and must always be the callable object - * to be invoked when the route matches an HTTP request. - * - * You may also provide an unlimited number of in-between arguments; - * each interior argument must be callable and will be invoked in the - * order specified before the route's callable is invoked. - * - * USAGE: - * - * Slim::get('/foo'[, middleware, middleware, ...], callable); - * - * @param array (See notes above) - * @return \Slim\Route - */ - protected function mapRoute($args) - { - $pattern = array_shift($args); - $callable = array_pop($args); - $route = new \Slim\Route($pattern, $callable, $this->settings['routes.case_sensitive']); - $this->router->map($route); - if (count($args) > 0) { - $route->setMiddleware($args); - } - - return $route; - } - - /** - * Add generic route without associated HTTP method - * @see mapRoute() - * @return \Slim\Route - */ - public function map() - { - $args = func_get_args(); - - return $this->mapRoute($args); - } - - /** - * Add GET route - * @see mapRoute() - * @return \Slim\Route - */ - public function get() - { - $args = func_get_args(); - - return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_GET, \Slim\Http\Request::METHOD_HEAD); - } - - /** - * Add POST route - * @see mapRoute() - * @return \Slim\Route - */ - public function post() - { - $args = func_get_args(); - - return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_POST); - } - - /** - * Add PUT route - * @see mapRoute() - * @return \Slim\Route - */ - public function put() - { - $args = func_get_args(); - - return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_PUT); - } - - /** - * Add PATCH route - * @see mapRoute() - * @return \Slim\Route - */ - public function patch() - { - $args = func_get_args(); - - return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_PATCH); - } - - /** - * Add DELETE route - * @see mapRoute() - * @return \Slim\Route - */ - public function delete() - { - $args = func_get_args(); - - return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_DELETE); - } - - /** - * Add OPTIONS route - * @see mapRoute() - * @return \Slim\Route - */ - public function options() - { - $args = func_get_args(); - - return $this->mapRoute($args)->via(\Slim\Http\Request::METHOD_OPTIONS); - } - - /** - * Route Groups - * - * This method accepts a route pattern and a callback all Route - * declarations in the callback will be prepended by the group(s) - * that it is in - * - * Accepts the same parameters as a standard route so: - * (pattern, middleware1, middleware2, ..., $callback) - */ - public function group() - { - $args = func_get_args(); - $pattern = array_shift($args); - $callable = array_pop($args); - $this->router->pushGroup($pattern, $args); - if (is_callable($callable)) { - call_user_func($callable); - } - $this->router->popGroup(); - } - - /* - * Add route for any HTTP method - * @see mapRoute() - * @return \Slim\Route - */ - public function any() - { - $args = func_get_args(); - - return $this->mapRoute($args)->via("ANY"); - } - - /** - * Not Found Handler - * - * This method defines or invokes the application-wide Not Found handler. - * There are two contexts in which this method may be invoked: - * - * 1. When declaring the handler: - * - * If the $callable parameter is not null and is callable, this - * method will register the callable to be invoked when no - * routes match the current HTTP request. It WILL NOT invoke the callable. - * - * 2. When invoking the handler: - * - * If the $callable parameter is null, Slim assumes you want - * to invoke an already-registered handler. If the handler has been - * registered and is callable, it is invoked and sends a 404 HTTP Response - * whose body is the output of the Not Found handler. - * - * @param mixed $callable Anything that returns true for is_callable() - */ - public function notFound ($callable = null) - { - if (is_callable($callable)) { - $this->notFound = $callable; - } else { - ob_start(); - if (is_callable($this->notFound)) { - call_user_func($this->notFound); - } else { - call_user_func(array($this, 'defaultNotFound')); - } - $this->halt(404, ob_get_clean()); - } - } - - /** - * Error Handler - * - * This method defines or invokes the application-wide Error handler. - * There are two contexts in which this method may be invoked: - * - * 1. When declaring the handler: - * - * If the $argument parameter is callable, this - * method will register the callable to be invoked when an uncaught - * Exception is detected, or when otherwise explicitly invoked. - * The handler WILL NOT be invoked in this context. - * - * 2. When invoking the handler: - * - * If the $argument parameter is not callable, Slim assumes you want - * to invoke an already-registered handler. If the handler has been - * registered and is callable, it is invoked and passed the caught Exception - * as its one and only argument. The error handler's output is captured - * into an output buffer and sent as the body of a 500 HTTP Response. - * - * @param mixed $argument Callable|\Exception - */ - public function error($argument = null) - { - if (is_callable($argument)) { - //Register error handler - $this->error = $argument; - } else { - //Invoke error handler - $this->response->status(500); - $this->response->body(''); - $this->response->write($this->callErrorHandler($argument)); - $this->stop(); - } - } - - /** - * Call error handler - * - * This will invoke the custom or default error handler - * and RETURN its output. - * - * @param \Exception|null $argument - * @return string - */ - protected function callErrorHandler($argument = null) - { - ob_start(); - if (is_callable($this->error)) { - call_user_func_array($this->error, array($argument)); - } else { - call_user_func_array(array($this, 'defaultError'), array($argument)); - } - - return ob_get_clean(); - } - - /******************************************************************************** - * Application Accessors - *******************************************************************************/ - - /** - * Get a reference to the Environment object - * @return \Slim\Environment - */ - public function environment() - { - return $this->environment; - } - - /** - * Get the Request object - * @return \Slim\Http\Request - */ - public function request() - { - return $this->request; - } - - /** - * Get the Response object - * @return \Slim\Http\Response - */ - public function response() - { - return $this->response; - } - - /** - * Get the Router object - * @return \Slim\Router - */ - public function router() - { - return $this->router; - } - - /** - * Get and/or set the View - * - * This method declares the View to be used by the Slim application. - * If the argument is a string, Slim will instantiate a new object - * of the same class. If the argument is an instance of View or a subclass - * of View, Slim will use the argument as the View. - * - * If a View already exists and this method is called to create a - * new View, data already set in the existing View will be - * transferred to the new View. - * - * @param string|\Slim\View $viewClass The name or instance of a \Slim\View subclass - * @return \Slim\View - */ - public function view($viewClass = null) - { - if (!is_null($viewClass)) { - $existingData = is_null($this->view) ? array() : $this->view->getData(); - if ($viewClass instanceOf \Slim\View) { - $this->view = $viewClass; - } else { - $this->view = new $viewClass(); - } - $this->view->appendData($existingData); - $this->view->setTemplatesDirectory($this->config('templates.path')); - } - - return $this->view; - } - - /******************************************************************************** - * Rendering - *******************************************************************************/ - - /** - * Render a template - * - * Call this method within a GET, POST, PUT, PATCH, DELETE, NOT FOUND, or ERROR - * callable to render a template whose output is appended to the - * current HTTP response body. How the template is rendered is - * delegated to the current View. - * - * @param string $template The name of the template passed into the view's render() method - * @param array $data Associative array of data made available to the view - * @param int $status The HTTP response status code to use (optional) - */ - public function render($template, $data = array(), $status = null) - { - if (!is_null($status)) { - $this->response->status($status); - } - $this->view->appendData($data); - $this->view->display($template); - } - - /******************************************************************************** - * HTTP Caching - *******************************************************************************/ - - /** - * Set Last-Modified HTTP Response Header - * - * Set the HTTP 'Last-Modified' header and stop if a conditional - * GET request's `If-Modified-Since` header matches the last modified time - * of the resource. The `time` argument is a UNIX timestamp integer value. - * When the current request includes an 'If-Modified-Since' header that - * matches the specified last modified time, the application will stop - * and send a '304 Not Modified' response to the client. - * - * @param int $time The last modified UNIX timestamp - * @throws \InvalidArgumentException If provided timestamp is not an integer - */ - public function lastModified($time) - { - if (is_integer($time)) { - $this->response->headers->set('Last-Modified', gmdate('D, d M Y H:i:s T', $time)); - if ($time === strtotime($this->request->headers->get('IF_MODIFIED_SINCE'))) { - $this->halt(304); - } - } else { - throw new \InvalidArgumentException('Slim::lastModified only accepts an integer UNIX timestamp value.'); - } - } - - /** - * Set ETag HTTP Response Header - * - * Set the etag header and stop if the conditional GET request matches. - * The `value` argument is a unique identifier for the current resource. - * The `type` argument indicates whether the etag should be used as a strong or - * weak cache validator. - * - * When the current request includes an 'If-None-Match' header with - * a matching etag, execution is immediately stopped. If the request - * method is GET or HEAD, a '304 Not Modified' response is sent. - * - * @param string $value The etag value - * @param string $type The type of etag to create; either "strong" or "weak" - * @throws \InvalidArgumentException If provided type is invalid - */ - public function etag($value, $type = 'strong') - { - //Ensure type is correct - if (!in_array($type, array('strong', 'weak'))) { - throw new \InvalidArgumentException('Invalid Slim::etag type. Expected "strong" or "weak".'); - } - - //Set etag value - $value = '"' . $value . '"'; - if ($type === 'weak') { - $value = 'W/'.$value; - } - $this->response['ETag'] = $value; - - //Check conditional GET - if ($etagsHeader = $this->request->headers->get('IF_NONE_MATCH')) { - $etags = preg_split('@\s*,\s*@', $etagsHeader); - if (in_array($value, $etags) || in_array('*', $etags)) { - $this->halt(304); - } - } - } - - /** - * Set Expires HTTP response header - * - * The `Expires` header tells the HTTP client the time at which - * the current resource should be considered stale. At that time the HTTP - * client will send a conditional GET request to the server; the server - * may return a 200 OK if the resource has changed, else a 304 Not Modified - * if the resource has not changed. The `Expires` header should be used in - * conjunction with the `etag()` or `lastModified()` methods above. - * - * @param string|int $time If string, a time to be parsed by `strtotime()`; - * If int, a UNIX timestamp; - */ - public function expires($time) - { - if (is_string($time)) { - $time = strtotime($time); - } - $this->response->headers->set('Expires', gmdate('D, d M Y H:i:s T', $time)); - } - - /******************************************************************************** - * HTTP Cookies - *******************************************************************************/ - - /** - * Set HTTP cookie to be sent with the HTTP response - * - * @param string $name The cookie name - * @param string $value The cookie value - * @param int|string $time The duration of the cookie; - * If integer, should be UNIX timestamp; - * If string, converted to UNIX timestamp with `strtotime`; - * @param string $path The path on the server in which the cookie will be available on - * @param string $domain The domain that the cookie is available to - * @param bool $secure Indicates that the cookie should only be transmitted over a secure - * HTTPS connection to/from the client - * @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol - */ - public function setCookie($name, $value, $time = null, $path = null, $domain = null, $secure = null, $httponly = null) - { - $settings = array( - 'value' => $value, - 'expires' => is_null($time) ? $this->config('cookies.lifetime') : $time, - 'path' => is_null($path) ? $this->config('cookies.path') : $path, - 'domain' => is_null($domain) ? $this->config('cookies.domain') : $domain, - 'secure' => is_null($secure) ? $this->config('cookies.secure') : $secure, - 'httponly' => is_null($httponly) ? $this->config('cookies.httponly') : $httponly - ); - $this->response->cookies->set($name, $settings); - } - - /** - * Get value of HTTP cookie from the current HTTP request - * - * Return the value of a cookie from the current HTTP request, - * or return NULL if cookie does not exist. Cookies created during - * the current request will not be available until the next request. - * - * @param string $name - * @param bool $deleteIfInvalid - * @return string|null - */ - public function getCookie($name, $deleteIfInvalid = true) - { - // Get cookie value - $value = $this->request->cookies->get($name); - - // Decode if encrypted - if ($this->config('cookies.encrypt')) { - $value = \Slim\Http\Util::decodeSecureCookie( - $value, - $this->config('cookies.secret_key'), - $this->config('cookies.cipher'), - $this->config('cookies.cipher_mode') - ); - if ($value === false && $deleteIfInvalid) { - $this->deleteCookie($name); - } - } - - return $value; - } - - /** - * DEPRECATION WARNING! Use `setCookie` with the `cookies.encrypt` app setting set to `true`. - * - * Set encrypted HTTP cookie - * - * @param string $name The cookie name - * @param mixed $value The cookie value - * @param mixed $expires The duration of the cookie; - * If integer, should be UNIX timestamp; - * If string, converted to UNIX timestamp with `strtotime`; - * @param string $path The path on the server in which the cookie will be available on - * @param string $domain The domain that the cookie is available to - * @param bool $secure Indicates that the cookie should only be transmitted over a secure - * HTTPS connection from the client - * @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol - */ - public function setEncryptedCookie($name, $value, $expires = null, $path = null, $domain = null, $secure = false, $httponly = false) - { - $this->setCookie($name, $value, $expires, $path, $domain, $secure, $httponly); - } - - /** - * DEPRECATION WARNING! Use `getCookie` with the `cookies.encrypt` app setting set to `true`. - * - * Get value of encrypted HTTP cookie - * - * Return the value of an encrypted cookie from the current HTTP request, - * or return NULL if cookie does not exist. Encrypted cookies created during - * the current request will not be available until the next request. - * - * @param string $name - * @param bool $deleteIfInvalid - * @return string|bool - */ - public function getEncryptedCookie($name, $deleteIfInvalid = true) - { - return $this->getCookie($name, $deleteIfInvalid); - } - - /** - * Delete HTTP cookie (encrypted or unencrypted) - * - * Remove a Cookie from the client. This method will overwrite an existing Cookie - * with a new, empty, auto-expiring Cookie. This method's arguments must match - * the original Cookie's respective arguments for the original Cookie to be - * removed. If any of this method's arguments are omitted or set to NULL, the - * default Cookie setting values (set during Slim::init) will be used instead. - * - * @param string $name The cookie name - * @param string $path The path on the server in which the cookie will be available on - * @param string $domain The domain that the cookie is available to - * @param bool $secure Indicates that the cookie should only be transmitted over a secure - * HTTPS connection from the client - * @param bool $httponly When TRUE the cookie will be made accessible only through the HTTP protocol - */ - public function deleteCookie($name, $path = null, $domain = null, $secure = null, $httponly = null) - { - $settings = array( - 'domain' => is_null($domain) ? $this->config('cookies.domain') : $domain, - 'path' => is_null($path) ? $this->config('cookies.path') : $path, - 'secure' => is_null($secure) ? $this->config('cookies.secure') : $secure, - 'httponly' => is_null($httponly) ? $this->config('cookies.httponly') : $httponly - ); - $this->response->cookies->remove($name, $settings); - } - - /******************************************************************************** - * Helper Methods - *******************************************************************************/ - - /** - * Get the absolute path to this Slim application's root directory - * - * This method returns the absolute path to the Slim application's - * directory. If the Slim application is installed in a public-accessible - * sub-directory, the sub-directory path will be included. This method - * will always return an absolute path WITH a trailing slash. - * - * @return string - */ - public function root() - { - return rtrim($_SERVER['DOCUMENT_ROOT'], '/') . rtrim($this->request->getRootUri(), '/') . '/'; - } - - /** - * Clean current output buffer - */ - protected function cleanBuffer() - { - if (ob_get_level() !== 0) { - ob_clean(); - } - } - - /** - * Stop - * - * The thrown exception will be caught in application's `call()` method - * and the response will be sent as is to the HTTP client. - * - * @throws \Slim\Exception\Stop - */ - public function stop() - { - throw new \Slim\Exception\Stop(); - } - - /** - * Halt - * - * Stop the application and immediately send the response with a - * specific status and body to the HTTP client. This may send any - * type of response: info, success, redirect, client error, or server error. - * If you need to render a template AND customize the response status, - * use the application's `render()` method instead. - * - * @param int $status The HTTP response status - * @param string $message The HTTP response body - */ - public function halt($status, $message = '') - { - $this->cleanBuffer(); - $this->response->status($status); - $this->response->body($message); - $this->stop(); - } - - /** - * Pass - * - * The thrown exception is caught in the application's `call()` method causing - * the router's current iteration to stop and continue to the subsequent route if available. - * If no subsequent matching routes are found, a 404 response will be sent to the client. - * - * @throws \Slim\Exception\Pass - */ - public function pass() - { - $this->cleanBuffer(); - throw new \Slim\Exception\Pass(); - } - - /** - * Set the HTTP response Content-Type - * @param string $type The Content-Type for the Response (ie. text/html) - */ - public function contentType($type) - { - $this->response->headers->set('Content-Type', $type); - } - - /** - * Set the HTTP response status code - * @param int $code The HTTP response status code - */ - public function status($code) - { - $this->response->setStatus($code); - } - - /** - * Get the URL for a named route - * @param string $name The route name - * @param array $params Associative array of URL parameters and replacement values - * @throws \RuntimeException If named route does not exist - * @return string - */ - public function urlFor($name, $params = array()) - { - return $this->request->getRootUri() . $this->router->urlFor($name, $params); - } - - /** - * Redirect - * - * This method immediately redirects to a new URL. By default, - * this issues a 302 Found response; this is considered the default - * generic redirect response. You may also specify another valid - * 3xx status code if you want. This method will automatically set the - * HTTP Location header for you using the URL parameter. - * - * @param string $url The destination URL - * @param int $status The HTTP redirect status code (optional) - */ - public function redirect($url, $status = 302) - { - $this->response->redirect($url, $status); - $this->halt($status); - } - - /******************************************************************************** - * Flash Messages - *******************************************************************************/ - - /** - * Set flash message for subsequent request - * @param string $key - * @param mixed $value - */ - public function flash($key, $value) - { - if (isset($this->environment['slim.flash'])) { - $this->environment['slim.flash']->set($key, $value); - } - } - - /** - * Set flash message for current request - * @param string $key - * @param mixed $value - */ - public function flashNow($key, $value) - { - if (isset($this->environment['slim.flash'])) { - $this->environment['slim.flash']->now($key, $value); - } - } - - /** - * Keep flash messages from previous request for subsequent request - */ - public function flashKeep() - { - if (isset($this->environment['slim.flash'])) { - $this->environment['slim.flash']->keep(); - } - } - - /******************************************************************************** - * Hooks - *******************************************************************************/ - - /** - * Assign hook - * @param string $name The hook name - * @param mixed $callable A callable object - * @param int $priority The hook priority; 0 = high, 10 = low - */ - public function hook($name, $callable, $priority = 10) - { - if (!isset($this->hooks[$name])) { - $this->hooks[$name] = array(array()); - } - if (is_callable($callable)) { - $this->hooks[$name][(int) $priority][] = $callable; - } - } - - /** - * Invoke hook - * @param string $name The hook name - * @param mixed $hookArg (Optional) Argument for hooked functions - */ - public function applyHook($name, $hookArg = null) - { - if (!isset($this->hooks[$name])) { - $this->hooks[$name] = array(array()); - } - if (!empty($this->hooks[$name])) { - // Sort by priority, low to high, if there's more than one priority - if (count($this->hooks[$name]) > 1) { - ksort($this->hooks[$name]); - } - foreach ($this->hooks[$name] as $priority) { - if (!empty($priority)) { - foreach ($priority as $callable) { - call_user_func($callable, $hookArg); - } - } - } - } - } - - /** - * Get hook listeners - * - * Return an array of registered hooks. If `$name` is a valid - * hook name, only the listeners attached to that hook are returned. - * Else, all listeners are returned as an associative array whose - * keys are hook names and whose values are arrays of listeners. - * - * @param string $name A hook name (Optional) - * @return array|null - */ - public function getHooks($name = null) - { - if (!is_null($name)) { - return isset($this->hooks[(string) $name]) ? $this->hooks[(string) $name] : null; - } else { - return $this->hooks; - } - } - - /** - * Clear hook listeners - * - * Clear all listeners for all hooks. If `$name` is - * a valid hook name, only the listeners attached - * to that hook will be cleared. - * - * @param string $name A hook name (Optional) - */ - public function clearHooks($name = null) - { - if (!is_null($name) && isset($this->hooks[(string) $name])) { - $this->hooks[(string) $name] = array(array()); - } else { - foreach ($this->hooks as $key => $value) { - $this->hooks[$key] = array(array()); - } - } - } - - /******************************************************************************** - * Middleware - *******************************************************************************/ - - /** - * Add middleware - * - * This method prepends new middleware to the application middleware stack. - * The argument must be an instance that subclasses Slim_Middleware. - * - * @param \Slim\Middleware - */ - public function add(\Slim\Middleware $newMiddleware) - { - if(in_array($newMiddleware, $this->middleware)) { - $middleware_class = get_class($newMiddleware); - throw new \RuntimeException("Circular Middleware setup detected. Tried to queue the same Middleware instance ({$middleware_class}) twice."); - } - $newMiddleware->setApplication($this); - $newMiddleware->setNextMiddleware($this->middleware[0]); - array_unshift($this->middleware, $newMiddleware); - } - - /******************************************************************************** - * Runner - *******************************************************************************/ - - /** - * Run - * - * This method invokes the middleware stack, including the core Slim application; - * the result is an array of HTTP status, header, and body. These three items - * are returned to the HTTP client. - */ - public function run() - { - set_error_handler(array('\Slim\Slim', 'handleErrors')); - - //Apply final outer middleware layers - if ($this->config('debug')) { - //Apply pretty exceptions only in debug to avoid accidental information leakage in production - $this->add(new \Slim\Middleware\PrettyExceptions()); - } - - //Invoke middleware and application stack - $this->middleware[0]->call(); - - //Fetch status, header, and body - list($status, $headers, $body) = $this->response->finalize(); - - // Serialize cookies (with optional encryption) - \Slim\Http\Util::serializeCookies($headers, $this->response->cookies, $this->settings); - - //Send headers - if (headers_sent() === false) { - //Send status - if (strpos(PHP_SAPI, 'cgi') === 0) { - header(sprintf('Status: %s', \Slim\Http\Response::getMessageForCode($status))); - } else { - header(sprintf('HTTP/%s %s', $this->config('http.version'), \Slim\Http\Response::getMessageForCode($status))); - } - - //Send headers - foreach ($headers as $name => $value) { - $hValues = explode("\n", $value); - foreach ($hValues as $hVal) { - header("$name: $hVal", false); - } - } - } - - //Send body, but only if it isn't a HEAD request - if (!$this->request->isHead()) { - echo $body; - } - - $this->applyHook('slim.after'); - - restore_error_handler(); - } - - /** - * Call - * - * This method finds and iterates all route objects that match the current request URI. - */ - public function call() - { - try { - if (isset($this->environment['slim.flash'])) { - $this->view()->setData('flash', $this->environment['slim.flash']); - } - $this->applyHook('slim.before'); - ob_start(); - $this->applyHook('slim.before.router'); - $dispatched = false; - $matchedRoutes = $this->router->getMatchedRoutes($this->request->getMethod(), $this->request->getResourceUri()); - foreach ($matchedRoutes as $route) { - try { - $this->applyHook('slim.before.dispatch'); - $dispatched = $route->dispatch(); - $this->applyHook('slim.after.dispatch'); - if ($dispatched) { - break; - } - } catch (\Slim\Exception\Pass $e) { - continue; - } - } - if (!$dispatched) { - $this->notFound(); - } - $this->applyHook('slim.after.router'); - $this->stop(); - } catch (\Slim\Exception\Stop $e) { - $this->response()->write(ob_get_clean()); - } catch (\Exception $e) { - if ($this->config('debug')) { - throw $e; - } else { - try { - $this->error($e); - } catch (\Slim\Exception\Stop $e) { - // Do nothing - } - } - } - } - - /******************************************************************************** - * Error Handling and Debugging - *******************************************************************************/ - - /** - * Convert errors into ErrorException objects - * - * This method catches PHP errors and converts them into \ErrorException objects; - * these \ErrorException objects are then thrown and caught by Slim's - * built-in or custom error handlers. - * - * @param int $errno The numeric type of the Error - * @param string $errstr The error message - * @param string $errfile The absolute path to the affected file - * @param int $errline The line number of the error in the affected file - * @return bool - * @throws \ErrorException - */ - public static function handleErrors($errno, $errstr = '', $errfile = '', $errline = '') - { - if (!($errno & error_reporting())) { - return; - } - - throw new \ErrorException($errstr, $errno, 0, $errfile, $errline); - } - - /** - * Generate diagnostic template markup - * - * This method accepts a title and body content to generate an HTML document layout. - * - * @param string $title The title of the HTML template - * @param string $body The body content of the HTML template - * @return string - */ - protected static function generateTemplateMarkup($title, $body) - { - return sprintf("%s

%s

%s", $title, $title, $body); - } - - /** - * Default Not Found handler - */ - protected function defaultNotFound() - { - echo static::generateTemplateMarkup('404 Page Not Found', '

The page you are looking for could not be found. Check the address bar to ensure your URL is spelled correctly. If all else fails, you can visit our home page at the link below.

Visit the Home Page'); - } - - /** - * Default Error handler - */ - protected function defaultError($e) - { - $this->getLog()->error($e); - echo self::generateTemplateMarkup('Error', '

A website error has occurred. The website administrator has been notified of the issue. Sorry for the temporary inconvenience.

'); - } -} diff --git a/vendor/slim/slim/Slim/View.php b/vendor/slim/slim/Slim/View.php deleted file mode 100644 index 1a3973b9c..000000000 --- a/vendor/slim/slim/Slim/View.php +++ /dev/null @@ -1,282 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * @package Slim - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -namespace Slim; - -/** - * View - * - * The view is responsible for rendering a template. The view - * should subclass \Slim\View and implement this interface: - * - * public render(string $template); - * - * This method should render the specified template and return - * the resultant string. - * - * @package Slim - * @author Josh Lockhart - * @since 1.0.0 - */ -class View -{ - /** - * Data available to the view templates - * @var \Slim\Helper\Set - */ - protected $data; - - /** - * Path to templates base directory (without trailing slash) - * @var string - */ - protected $templatesDirectory; - - /** - * Constructor - */ - public function __construct() - { - $this->data = new \Slim\Helper\Set(); - } - - /******************************************************************************** - * Data methods - *******************************************************************************/ - - /** - * Does view data have value with key? - * @param string $key - * @return boolean - */ - public function has($key) - { - return $this->data->has($key); - } - - /** - * Return view data value with key - * @param string $key - * @return mixed - */ - public function get($key) - { - return $this->data->get($key); - } - - /** - * Set view data value with key - * @param string $key - * @param mixed $value - */ - public function set($key, $value) - { - $this->data->set($key, $value); - } - - /** - * Set view data value as Closure with key - * @param string $key - * @param mixed $value - */ - public function keep($key, Closure $value) - { - $this->data->keep($key, $value); - } - - /** - * Return view data - * @return array - */ - public function all() - { - return $this->data->all(); - } - - /** - * Replace view data - * @param array $data - */ - public function replace(array $data) - { - $this->data->replace($data); - } - - /** - * Clear view data - */ - public function clear() - { - $this->data->clear(); - } - - /******************************************************************************** - * Legacy data methods - *******************************************************************************/ - - /** - * DEPRECATION WARNING! This method will be removed in the next major point release - * - * Get data from view - */ - public function getData($key = null) - { - if (!is_null($key)) { - return isset($this->data[$key]) ? $this->data[$key] : null; - } else { - return $this->data->all(); - } - } - - /** - * DEPRECATION WARNING! This method will be removed in the next major point release - * - * Set data for view - */ - public function setData() - { - $args = func_get_args(); - if (count($args) === 1 && is_array($args[0])) { - $this->data->replace($args[0]); - } elseif (count($args) === 2) { - // Ensure original behavior is maintained. DO NOT invoke stored Closures. - if (is_object($args[1]) && method_exists($args[1], '__invoke')) { - $this->data->set($args[0], $this->data->protect($args[1])); - } else { - $this->data->set($args[0], $args[1]); - } - } else { - throw new \InvalidArgumentException('Cannot set View data with provided arguments. Usage: `View::setData( $key, $value );` or `View::setData([ key => value, ... ]);`'); - } - } - - /** - * DEPRECATION WARNING! This method will be removed in the next major point release - * - * Append data to view - * @param array $data - */ - public function appendData($data) - { - if (!is_array($data)) { - throw new \InvalidArgumentException('Cannot append view data. Expected array argument.'); - } - $this->data->replace($data); - } - - /******************************************************************************** - * Resolve template paths - *******************************************************************************/ - - /** - * Set the base directory that contains view templates - * @param string $directory - * @throws \InvalidArgumentException If directory is not a directory - */ - public function setTemplatesDirectory($directory) - { - $this->templatesDirectory = rtrim($directory, DIRECTORY_SEPARATOR); - } - - /** - * Get templates base directory - * @return string - */ - public function getTemplatesDirectory() - { - return $this->templatesDirectory; - } - - /** - * Get fully qualified path to template file using templates base directory - * @param string $file The template file pathname relative to templates base directory - * @return string - */ - public function getTemplatePathname($file) - { - return $this->templatesDirectory . DIRECTORY_SEPARATOR . ltrim($file, DIRECTORY_SEPARATOR); - } - - /******************************************************************************** - * Rendering - *******************************************************************************/ - - /** - * Display template - * - * This method echoes the rendered template to the current output buffer - * - * @param string $template Pathname of template file relative to templates directory - * @param array $data Any additonal data to be passed to the template. - */ - public function display($template, $data = null) - { - echo $this->fetch($template, $data); - } - - /** - * Return the contents of a rendered template file - * - * @param string $template The template pathname, relative to the template base directory - * @param array $data Any additonal data to be passed to the template. - * @return string The rendered template - */ - public function fetch($template, $data = null) - { - return $this->render($template, $data); - } - - /** - * Render a template file - * - * NOTE: This method should be overridden by custom view subclasses - * - * @param string $template The template pathname, relative to the template base directory - * @param array $data Any additonal data to be passed to the template. - * @return string The rendered template - * @throws \RuntimeException If resolved template pathname is not a valid file - */ - protected function render($template, $data = null) - { - $templatePathname = $this->getTemplatePathname($template); - if (!is_file($templatePathname)) { - throw new \RuntimeException("View cannot render `$template` because the template does not exist"); - } - - $data = array_merge($this->data->all(), (array) $data); - extract($data); - ob_start(); - require $templatePathname; - - return ob_get_clean(); - } -} diff --git a/vendor/slim/slim/composer.json b/vendor/slim/slim/composer.json deleted file mode 100644 index 0becfe687..000000000 --- a/vendor/slim/slim/composer.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "slim/slim", - "type": "library", - "description": "Slim Framework, a PHP micro framework", - "keywords": ["microframework","rest","router"], - "homepage": "http://github.com/codeguy/Slim", - "license": "MIT", - "authors": [ - { - "name": "Josh Lockhart", - "email": "info@joshlockhart.com", - "homepage": "http://www.joshlockhart.com/" - } - ], - "require": { - "php": ">=5.3.0" - }, - "suggest": { - "ext-mcrypt": "Required for HTTP cookie encryption" - }, - "autoload": { - "psr-0": { "Slim": "." } - } -} diff --git a/vendor/slim/slim/index.php b/vendor/slim/slim/index.php deleted file mode 100644 index 9bfd62d98..000000000 --- a/vendor/slim/slim/index.php +++ /dev/null @@ -1,169 +0,0 @@ -get( - '/', - function () { - $template = << - - - - Slim Framework for PHP 5 - - - -
- Slim -
-

Welcome to Slim!

-

- Congratulations! Your Slim application is running. If this is - your first time using Slim, start with this "Hello World" Tutorial. -

-
-

Get Started

-
    -
  1. The application code is in index.php
  2. -
  3. Read the online documentation
  4. -
  5. Follow @slimphp on Twitter
  6. -
-
-
-

Slim Framework Community

- -

Support Forum and Knowledge Base

-

- Visit the Slim support forum and knowledge base - to read announcements, chat with fellow Slim users, ask questions, help others, or show off your cool - Slim Framework apps. -

- -

Twitter

-

- Follow @slimphp on Twitter to receive the very latest news - and updates about the framework. -

-
-
-

Slim Framework Extras

-

- Custom View classes for Smarty, Twig, Mustache, and other template - frameworks are available online in a separate repository. -

-

Browse the Extras Repository

-
- - -EOT; - echo $template; - } -); - -// POST route -$app->post( - '/post', - function () { - echo 'This is a POST route'; - } -); - -// PUT route -$app->put( - '/put', - function () { - echo 'This is a PUT route'; - } -); - -// PATCH route -$app->patch('/patch', function () { - echo 'This is a PATCH route'; -}); - -// DELETE route -$app->delete( - '/delete', - function () { - echo 'This is a DELETE route'; - } -); - -/** - * Step 4: Run the Slim application - * - * This method should be called last. This executes the Slim application - * and returns the HTTP response to the HTTP client. - */ -$app->run(); diff --git a/vendor/slim/slim/phpunit.xml.dist b/vendor/slim/slim/phpunit.xml.dist deleted file mode 100644 index c4da17207..000000000 --- a/vendor/slim/slim/phpunit.xml.dist +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - ./tests/ - - - - - - ./Slim/ - - - diff --git a/vendor/slim/slim/tests/EnvironmentTest.php b/vendor/slim/slim/tests/EnvironmentTest.php deleted file mode 100644 index b35405c6c..000000000 --- a/vendor/slim/slim/tests/EnvironmentTest.php +++ /dev/null @@ -1,376 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class EnvironmentTest extends PHPUnit_Framework_TestCase -{ - /** - * Default server settings assume the Slim app is installed - * in a subdirectory `foo/` directly beneath the public document - * root directory; URL rewrite is disabled; requested app - * resource is GET `/bar/xyz` with three query params. - * - * These only provide a common baseline for the following - * tests; tests are free to override these values. - */ - public function setUp() - { - $_SERVER['DOCUMENT_ROOT'] = '/var/www'; - $_SERVER['SCRIPT_FILENAME'] = '/var/www/foo/index.php'; - $_SERVER['SERVER_NAME'] = 'slim'; - $_SERVER['SERVER_PORT'] = '80'; - $_SERVER['SCRIPT_NAME'] = '/foo/index.php'; - $_SERVER['REQUEST_URI'] = '/foo/index.php/bar/xyz'; - $_SERVER['PATH_INFO'] = '/bar/xyz'; - $_SERVER['REQUEST_METHOD'] = 'GET'; - $_SERVER['QUERY_STRING'] = 'one=1&two=2&three=3'; - $_SERVER['HTTPS'] = ''; - $_SERVER['REMOTE_ADDR'] = '127.0.0.1'; - unset($_SERVER['CONTENT_TYPE'], $_SERVER['CONTENT_LENGTH']); - } - - /** - * Test mock environment - * - * This should return the custom values where specified - * and the default values otherwise. - */ - public function testMockEnvironment() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PUT' - )); - $env2 = \Slim\Environment::getInstance(); - $this->assertSame($env, $env2); - $this->assertInstanceOf('\Slim\Environment', $env); - $this->assertEquals('PUT', $env['REQUEST_METHOD']); - $this->assertEquals(80, $env['SERVER_PORT']); - $this->assertNull($env['foo']); - } - - /** - * Test sets HTTP method - */ - public function testSetsHttpMethod() - { - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('GET', $env['REQUEST_METHOD']); - } - - /** - * Test parses script name and path info - * - * Pre-conditions: - * URL Rewrite is disabled; - * App installed in subdirectory; - */ - public function testParsesPathsWithoutUrlRewriteInSubdirectory() - { - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('/bar/xyz', $env['PATH_INFO']); - $this->assertEquals('/foo/index.php', $env['SCRIPT_NAME']); - } - - /** - * Test parses script name and path info - * - * Pre-conditions: - * URL Rewrite is disabled; - * App installed in root directory; - */ - public function testParsesPathsWithoutUrlRewriteInRootDirectory() - { - $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php'; - $_SERVER['REQUEST_URI'] = '/index.php/bar/xyz'; - $_SERVER['SCRIPT_NAME'] = '/index.php'; - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('/bar/xyz', $env['PATH_INFO']); - $this->assertEquals('/index.php', $env['SCRIPT_NAME']); - } - - /** - * Test parses script name and path info - * - * Pre-conditions: - * URL Rewrite disabled; - * App installed in root directory; - * Requested resource is "/"; - */ - public function testParsesPathsWithoutUrlRewriteInRootDirectoryForAppRootUri() - { - $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php'; - $_SERVER['REQUEST_URI'] = '/index.php'; - $_SERVER['SCRIPT_NAME'] = '/index.php'; - unset($_SERVER['PATH_INFO']); - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('/', $env['PATH_INFO']); - $this->assertEquals('/index.php', $env['SCRIPT_NAME']); - } - - /** - * Test parses script name and path info - * - * Pre-conditions: - * URL Rewrite enabled; - * App installed in subdirectory; - */ - public function testParsesPathsWithUrlRewriteInSubdirectory() - { - $_SERVER['SCRIPT_NAME'] = '/foo/index.php'; - $_SERVER['REQUEST_URI'] = '/foo/bar/xyz'; - unset($_SERVER['PATH_INFO']); - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('/bar/xyz', $env['PATH_INFO']); - $this->assertEquals('/foo', $env['SCRIPT_NAME']); - } - - /** - * Test parses script name and path info - * - * Pre-conditions: - * URL Rewrite enabled; - * App installed in root directory; - */ - public function testParsesPathsWithUrlRewriteInRootDirectory() - { - $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php'; - $_SERVER['SCRIPT_NAME'] = '/index.php'; - $_SERVER['REQUEST_URI'] = '/bar/xyz'; - unset($_SERVER['PATH_INFO']); - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('/bar/xyz', $env['PATH_INFO']); - $this->assertEquals('', $env['SCRIPT_NAME']); - } - - /** - * Test parses script name and path info - * - * Pre-conditions: - * URL Rewrite enabled; - * App installed in root directory; - * Requested resource is "/" - */ - public function testParsesPathsWithUrlRewriteInRootDirectoryForAppRootUri() - { - $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php'; - $_SERVER['REQUEST_URI'] = '/'; - $_SERVER['SCRIPT_NAME'] = '/index.php'; - unset($_SERVER['PATH_INFO']); - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('/', $env['PATH_INFO']); - $this->assertEquals('', $env['SCRIPT_NAME']); - } - - /** - * Test parses query string - * - * Pre-conditions: - * $_SERVER['QUERY_STRING'] exists and is not empty; - */ - public function testParsesQueryString() - { - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('one=1&two=2&three=3', $env['QUERY_STRING']); - } - - /** - * Test removes query string from PATH_INFO when using URL Rewrite - * - * Pre-conditions: - * $_SERVER['QUERY_STRING'] exists and is not empty; - * URL Rewrite enabled; - */ - public function testRemovesQueryStringFromPathInfo() - { - $_SERVER['SCRIPT_NAME'] = '/foo/index.php'; - $_SERVER['REQUEST_URI'] = '/foo/bar/xyz?one=1&two=2&three=3'; - unset($_SERVER['PATH_INFO']); - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('/bar/xyz', $env['PATH_INFO']); - } - - /** - * Test environment's PATH_INFO retains URL encoded characters (e.g. #) - * - * In earlier version, \Slim\Environment would use PATH_INFO instead - * of REQUEST_URI to determine the root URI and resource URI. - * Unfortunately, the server would URL decode the PATH_INFO string - * before it was handed to PHP. This prevented certain URL-encoded - * characters like the octothorpe from being delivered correctly to - * the Slim application environment. This test ensures the - * REQUEST_URI is used instead and parsed as expected. - */ - public function testPathInfoRetainsUrlEncodedCharacters() - { - $_SERVER['SCRIPT_FILENAME'] = '/var/www/index.php'; - $_SERVER['SCRIPT_NAME'] = '/index.php'; - $_SERVER['REQUEST_URI'] = '/foo/%23bar'; //<-- URL-encoded "#bar" - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('/foo/%23bar', $env['PATH_INFO']); - } - - /** - * Test parses query string - * - * Pre-conditions: - * $_SERVER['QUERY_STRING'] does not exist; - */ - public function testParsesQueryStringThatDoesNotExist() - { - unset($_SERVER['QUERY_STRING']); - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('', $env['QUERY_STRING']); - } - - /** - * Test SERVER_NAME is not empty - */ - public function testServerNameIsNotEmpty() - { - $env = \Slim\Environment::getInstance(true); - $this->assertFalse(empty($env['SERVER_NAME'])); - } - - /** - * Test SERVER_PORT is not empty - */ - public function testServerPortIsNotEmpty() - { - $env = \Slim\Environment::getInstance(true); - $this->assertFalse(empty($env['SERVER_PORT'])); - } - - /** - * Test unsets HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH - * - * Pre-conditions: - * HTTP_CONTENT_TYPE is sent with HTTP request; - * HTTP_CONTENT_LENGTH is sent with HTTP request; - */ - public function testUnsetsContentTypeAndContentLength() - { - $_SERVER['HTTP_CONTENT_LENGTH'] = 150; - $env = \Slim\Environment::getInstance(true); - $this->assertFalse(isset($env['HTTP_CONTENT_LENGTH'])); - } - - /** - * Test sets special request headers if not empty - * - * Pre-conditions: - * CONTENT_TYPE, CONTENT_LENGTH, X_REQUESTED_WITH are sent in client HTTP request; - * CONTENT_TYPE, CONTENT_LENGTH, X_REQUESTED_WITH are not empty; - */ - public function testSetsSpecialHeaders() - { - $_SERVER['CONTENT_TYPE'] = 'text/csv'; - $_SERVER['CONTENT_LENGTH'] = '100'; - $_SERVER['HTTP_X_REQUESTED_WITH'] = 'XmlHttpRequest'; - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('text/csv', $env['CONTENT_TYPE']); - $this->assertEquals('100', $env['CONTENT_LENGTH']); - $this->assertEquals('XmlHttpRequest', $env['HTTP_X_REQUESTED_WITH']); - } - - /** - * Tests X-HTTP-Method-Override is allowed through unmolested. - * - * Pre-conditions: - * X_HTTP_METHOD_OVERRIDE is sent in client HTTP request; - * X_HTTP_METHOD_OVERRIDE is not empty; - */ - public function testSetsHttpMethodOverrideHeader() { - $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'DELETE'; - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('DELETE', $env['HTTP_X_HTTP_METHOD_OVERRIDE']); - } - - /** - * Test detects HTTPS - * - * Pre-conditions: - * $_SERVER['HTTPS'] is set to a non-empty value; - */ - public function testHttps() - { - $_SERVER['HTTPS'] = 1; - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('https', $env['slim.url_scheme']); - } - - /** - * Test detects not HTTPS - * - * Pre-conditions: - * $_SERVER['HTTPS'] is set to an empty value; - */ - public function testNotHttps() - { - $_SERVER['HTTPS'] = ''; - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('http', $env['slim.url_scheme']); - } - - /** - * Test detects not HTTPS on IIS - * - * Pre-conditions: - * $_SERVER['HTTPS'] is set to "off"; - */ - public function testNotHttpsIIS() - { - $_SERVER['HTTPS'] = 'off'; - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('http', $env['slim.url_scheme']); - } - - /** - * Test input is an empty string (and not false) - * - * Pre-conditions: - * Input at php://input may only be read once; subsequent attempts - * will return `false`; in which case, use an empty string. - */ - public function testInputIsEmptyString() - { - $env = \Slim\Environment::getInstance(true); - $this->assertEquals('', $env['slim.input']); - } - - /** - * Test valid resource handle to php://stdErr - */ - public function testErrorResource() - { - $env = \Slim\Environment::getInstance(true); - $this->assertTrue(is_resource($env['slim.errors'])); - } -} diff --git a/vendor/slim/slim/tests/Foo.php b/vendor/slim/slim/tests/Foo.php deleted file mode 100644 index d772d02ec..000000000 --- a/vendor/slim/slim/tests/Foo.php +++ /dev/null @@ -1,7 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class SetTest extends PHPUnit_Framework_TestCase -{ - protected $bag; - protected $property; - - public function setUp() - { - $this->bag = new \Slim\Helper\Set(); - $this->property = new \ReflectionProperty($this->bag, 'data'); - $this->property->setAccessible(true); - } - - public function testSet() - { - $this->bag->set('foo', 'bar'); - $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); - $bag = $this->property->getValue($this->bag); - $this->assertEquals('bar', $bag['foo']); - } - - public function testGet() - { - $this->property->setValue($this->bag, array('foo' => 'bar')); - $this->assertEquals('bar', $this->bag->get('foo')); - } - - public function testGetNotExists() - { - $this->property->setValue($this->bag, array('foo' => 'bar')); - $this->assertEquals('default', $this->bag->get('abc', 'default')); - } - - public function testAdd() - { - $this->bag->replace(array( - 'abc' => '123', - 'foo' => 'bar' - )); - $this->assertArrayHasKey('abc', $this->property->getValue($this->bag)); - $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); - $bag = $this->property->getValue($this->bag); - $this->assertEquals('123', $bag['abc']); - $this->assertEquals('bar', $bag['foo']); - } - - public function testAll() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->assertEquals($data, $this->bag->all()); - } - - public function testKeys() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->assertEquals(array('abc', 'foo'), $this->bag->keys()); - } - - public function testRemove() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->bag->remove('foo'); - $this->assertEquals(array('abc' => '123'), $this->property->getValue($this->bag)); - } - - public function testClear() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->bag->clear(); - $this->assertEquals(array(), $this->property->getValue($this->bag)); - } - - public function testArrayAccessGet() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->assertEquals('bar', $this->bag['foo']); - } - - public function testArrayAccessSet() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->bag['foo'] = 'changed'; - $bag = $this->property->getValue($this->bag); - $this->assertEquals('changed', $bag['foo']); - } - - public function testArrayAccessExists() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->assertTrue(isset($this->bag['foo'])); - $this->assertFalse(isset($this->bag['bar'])); - } - - public function testArrayAccessUnset() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - unset($this->bag['foo']); - $this->assertEquals(array('abc' => '123'), $this->property->getValue($this->bag)); - } - - public function testCount() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->assertEquals(2, count($this->bag)); - } - - public function testGetIterator() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - $this->assertInstanceOf('\ArrayIterator', $this->bag->getIterator()); - } - - public function testPropertyOverloadGet() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - - $this->assertEquals('123', $this->bag->abc); - $this->assertEquals('bar', $this->bag->foo); - } - - public function testPropertyOverloadSet() - { - $this->bag->foo = 'bar'; - $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); - $this->assertEquals('bar', $this->bag->foo); - } - - public function testPropertyOverloadingIsset() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - - $this->assertTrue(isset($this->bag->abc)); - $this->assertTrue(isset($this->bag->foo)); - $this->assertFalse(isset($this->bag->foobar)); - } - - public function testPropertyOverloadingUnset() - { - $data = array( - 'abc' => '123', - 'foo' => 'bar' - ); - $this->property->setValue($this->bag, $data); - - $this->assertTrue(isset($this->bag->abc)); - unset($this->bag->abc); - $this->assertFalse(isset($this->bag->abc)); - $this->assertArrayNotHasKey('abc', $this->property->getValue($this->bag)); - $this->assertArrayHasKey('foo', $this->property->getValue($this->bag)); - } - - public function testProtect() - { - $callable = function () { - return 'foo'; - }; - $result = $this->bag->protect($callable); - - $this->assertInstanceOf('\Closure', $result); - $this->assertSame($callable, $result()); - } -} diff --git a/vendor/slim/slim/tests/Http/CookiesTest.php b/vendor/slim/slim/tests/Http/CookiesTest.php deleted file mode 100644 index 232553a03..000000000 --- a/vendor/slim/slim/tests/Http/CookiesTest.php +++ /dev/null @@ -1,92 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ -class CookiesTest extends PHPUnit_Framework_TestCase -{ - public function testSetWithStringValue() - { - $c = new \Slim\Http\Cookies(); - $c->set('foo', 'bar'); - $this->assertAttributeEquals( - array( - 'foo' => array( - 'value' => 'bar', - 'expires' => null, - 'domain' => null, - 'path' => null, - 'secure' => false, - 'httponly' => false - ) - ), - 'data', - $c - ); - } - - public function testSetWithArrayValue() - { - $now = time(); - $c = new \Slim\Http\Cookies(); - $c->set('foo', array( - 'value' => 'bar', - 'expires' => $now + 86400, - 'domain' => '.example.com', - 'path' => '/', - 'secure' => true, - 'httponly' => true - )); - $this->assertAttributeEquals( - array( - 'foo' => array( - 'value' => 'bar', - 'expires' => $now + 86400, - 'domain' => '.example.com', - 'path' => '/', - 'secure' => true, - 'httponly' => true - ) - ), - 'data', - $c - ); - } - - public function testRemove() - { - $c = new \Slim\Http\Cookies(); - $c->remove('foo'); - $prop = new \ReflectionProperty($c, 'data'); - $prop->setAccessible(true); - $cValue = $prop->getValue($c); - $this->assertEquals('', $cValue['foo']['value']); - $this->assertLessThan(time(), $cValue['foo']['expires']); - } -} diff --git a/vendor/slim/slim/tests/Http/HeadersTest.php b/vendor/slim/slim/tests/Http/HeadersTest.php deleted file mode 100644 index 22090f1db..000000000 --- a/vendor/slim/slim/tests/Http/HeadersTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class HeadersTest extends PHPUnit_Framework_TestCase -{ - public function testNormalizesKey() - { - $h = new \Slim\Http\Headers(); - $h->set('Http_Content_Type', 'text/html'); - $prop = new \ReflectionProperty($h, 'data'); - $prop->setAccessible(true); - $this->assertArrayHasKey('Content-Type', $prop->getValue($h)); - } - - public function testExtractHeaders() - { - $test = array( - 'HTTP_HOST' => 'foo.com', - 'SERVER_NAME' => 'foo', - 'CONTENT_TYPE' => 'text/html', - 'X_FORWARDED_FOR' => '127.0.0.1' - ); - $results = \Slim\Http\Headers::extract($test); - $this->assertEquals(array( - 'HTTP_HOST' => 'foo.com', - 'CONTENT_TYPE' => 'text/html', - 'X_FORWARDED_FOR' => '127.0.0.1' - ), $results); - } -} diff --git a/vendor/slim/slim/tests/Http/RequestTest.php b/vendor/slim/slim/tests/Http/RequestTest.php deleted file mode 100644 index 6d87659c7..000000000 --- a/vendor/slim/slim/tests/Http/RequestTest.php +++ /dev/null @@ -1,949 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class RequestTest extends PHPUnit_Framework_TestCase -{ - /** - * Test sets HTTP method - */ - public function testGetMethod() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'GET' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('GET', $req->getMethod()); - } - - /** - * Test HTTP GET method detection - */ - public function testIsGet() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'GET' - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isGet()); - } - - /** - * Test HTTP POST method detection - */ - public function testIsPost() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isPost()); - } - - /** - * Test HTTP PUT method detection - */ - public function testIsPut() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PUT', - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isPut()); - } - - /** - * Test HTTP DELETE method detection - */ - public function testIsDelete() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'DELETE', - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isDelete()); - } - - /** - * Test HTTP OPTIONS method detection - */ - public function testIsOptions() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'OPTIONS', - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isOptions()); - } - - /** - * Test HTTP HEAD method detection - */ - public function testIsHead() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'HEAD', - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isHead()); - } - - /** - * Test HTTP PATCH method detection - */ - public function testIsPatch() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PATCH', - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isPatch()); - } - - /** - * Test AJAX method detection w/ header - */ - public function testIsAjaxWithHeader() - { - $env = \Slim\Environment::mock(array( - 'X_REQUESTED_WITH' => 'XMLHttpRequest' - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isAjax()); - $this->assertTrue($req->isXhr()); - } - - /** - * Test AJAX method detection w/ query parameter - */ - public function testIsAjaxWithQueryParameter() - { - $env = \Slim\Environment::mock(array( - 'QUERY_STRING' => 'isajax=1', - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isAjax()); - $this->assertTrue($req->isXhr()); - } - - /** - * Test AJAX method detection without header or query parameter - */ - public function testIsAjaxWithoutHeaderOrQueryParameter() - { - $env = \Slim\Environment::mock(); - $req = new \Slim\Http\Request($env); - $this->assertFalse($req->isAjax()); - $this->assertFalse($req->isXhr()); - } - - /** - * Test AJAX method detection with misspelled header - */ - public function testIsAjaxWithMisspelledHeader() - { - $env = \Slim\Environment::mock(array( - 'X_REQUESTED_WITH' => 'foo' - )); - $req = new \Slim\Http\Request($env); - $this->assertFalse($req->isAjax()); - $this->assertFalse($req->isXhr()); - } - - /** - * Test params from query string - */ - public function testParamsFromQueryString() - { - $env = \Slim\Environment::mock(array( - 'QUERY_STRING' => 'one=1&two=2&three=3' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(3, count($req->params())); - $this->assertEquals('1', $req->params('one')); - $this->assertNull($req->params('foo')); - $this->assertEquals(1, $req->params('foo', 1)); - } - - /** - * Test params from request body - */ - public function testParamsFromRequestBody() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'QUERY_STRING' => 'one=1&two=2&three=3', - 'slim.input' => 'foo=bar&abc=123', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 15 - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(5, count($req->params())); //Union of GET and POST - $this->assertEquals('bar', $req->params('foo')); - } - - /** - * Test fetch GET params - */ - public function testGet() - { - $env = \Slim\Environment::mock(array( - 'QUERY_STRING' => 'one=1&two=2&three=3' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(3, count($req->get())); - $this->assertEquals('1', $req->get('one')); - $this->assertNull($req->get('foo')); - $this->assertFalse($req->get('foo', false)); - } - - /** - * Test fetch GET params without multibyte - */ - public function testGetWithoutMultibyte() - { - $env = \Slim\Environment::mock(array( - 'QUERY_STRING' => 'one=1&two=2&three=3', - 'slim.tests.ignore_multibyte' => true - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(3, count($req->get())); - $this->assertEquals('1', $req->get('one')); - $this->assertNull($req->get('foo')); - $this->assertFalse($req->get('foo', false)); - } - - /** - * Test fetch POST params - */ - public function testPost() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'slim.input' => 'foo=bar&abc=123', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 15 - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(2, count($req->post())); - $this->assertEquals('bar', $req->post('foo')); - $this->assertNull($req->post('xyz')); - $this->assertFalse($req->post('xyz', false)); - } - - /** - * Test fetch POST params without multibyte - */ - public function testPostWithoutMultibyte() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'slim.input' => 'foo=bar&abc=123', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 15, - 'slim.tests.ignore_multibyte' => true - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(2, count($req->post())); - $this->assertEquals('bar', $req->post('foo')); - $this->assertNull($req->post('xyz')); - $this->assertFalse($req->post('xyz', false)); - } - - /** - * Test fetch POST without slim.input - */ - public function testPostWithoutInput() - { - $this->setExpectedException('RuntimeException'); - $env = \Slim\Environment::mock(); - unset($env['slim.input']); - $req = new \Slim\Http\Request($env); - $req->post('foo'); - } - - /** - * Test fetch POST params even if multipart/form-data request - */ - public function testPostWithMultipartRequest() - { - $_POST = array('foo' => 'bar'); //<-- Set by PHP - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'slim.input' => '', //<-- "php://input" is empty for multipart/form-data requests - 'CONTENT_TYPE' => 'multipart/form-data', - 'CONTENT_LENGTH' => 0 - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(1, count($req->post())); - $this->assertEquals('bar', $req->post('foo')); - $this->assertNull($req->post('xyz')); - } - - /** - * Test fetch PUT params - */ - public function testPut() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PUT', - 'slim.input' => 'foo=bar&abc=123', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 15 - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(2, count($req->put())); - $this->assertEquals('bar', $req->put('foo')); - $this->assertEquals('bar', $req->params('foo')); - $this->assertNull($req->put('xyz')); - $this->assertFalse($req->put('xyz', false)); - } - - /** - * Test fetch PATCH params - */ - public function testPatch() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PATCH', - 'slim.input' => 'foo=bar&abc=123', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 15 - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(2, count($req->patch())); - $this->assertEquals('bar', $req->patch('foo')); - $this->assertEquals('bar', $req->params('foo')); - $this->assertNull($req->patch('xyz')); - $this->assertFalse($req->patch('xyz', false)); - } - - /** - * Test fetch DELETE params - */ - public function testDelete() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'DELETE', - 'slim.input' => 'foo=bar&abc=123', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 15 - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(2, count($req->delete())); - $this->assertEquals('bar', $req->delete('foo')); - $this->assertEquals('bar', $req->params('foo')); - $this->assertNull($req->delete('xyz')); - $this->assertFalse($req->delete('xyz', false)); - } - - /** - * Test fetch COOKIE params - */ - public function testCookies() - { - $env = \Slim\Environment::mock(array( - 'HTTP_COOKIE' => 'foo=bar; abc=123' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(2, count($req->cookies())); - $this->assertEquals('bar', $req->cookies('foo')); - $this->assertNull($req->cookies('xyz')); - } - - /** - * Test is form data - */ - public function testIsFormDataContentFormUrlencoded() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PUT', - 'slim.input' => '', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded' - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isFormData()); - } - - /** - * Test is form data - */ - public function testIsFormDataPostContentUnknown() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'slim.input' => '', - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isFormData()); - } - - /** - * Test is form data - */ - public function testIsFormDataPostContentUnknownWithMethodOverride() - { - $env = \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PUT', - )); - $env['slim.method_override.original_method'] = 'POST'; - $req = new \Slim\Http\Request($env); - $this->assertTrue($req->isPut()); - $this->assertTrue($req->isFormData()); - } - - /** - * Test is not form data - */ - public function testIsNotFormData() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => '', - 'CONTENT_TYPE' => 'application/json' - )); - $req = new \Slim\Http\Request($env); - $this->assertFalse($req->isFormData()); - } - - /** - * Test headers - */ - public function testHeaders() - { - $env = \Slim\Environment::mock(array( - 'HTTP_ACCEPT_ENCODING' => 'gzip' - )); - $req = new \Slim\Http\Request($env); - $headers = $req->headers(); - $this->assertInstanceOf('\Slim\Http\Headers', $headers); - $this->assertEquals('gzip', $req->headers('HTTP_ACCEPT_ENCODING')); - $this->assertEquals('gzip', $req->headers('HTTP-ACCEPT-ENCODING')); - $this->assertEquals('gzip', $req->headers('http_accept_encoding')); - $this->assertEquals('gzip', $req->headers('http-accept-encoding')); - $this->assertEquals('gzip', $req->headers('ACCEPT_ENCODING')); - $this->assertEquals('gzip', $req->headers('ACCEPT-ENCODING')); - $this->assertEquals('gzip', $req->headers('accept_encoding')); - $this->assertEquals('gzip', $req->headers('accept-encoding')); - $this->assertNull($req->headers('foo')); - } - - /** - * Test accurately removes HTTP_ prefix from input header name - */ - public function testHeaderRemovesHttpPrefix() - { - $env = \Slim\Environment::mock(array( - 'X_HTTP_METHOD_OVERRIDE' => 'PUT', - 'CONTENT_TYPE' => 'application/json' - )); - //fwrite(fopen('php://stdout', 'w'), print_r($env, true)); - $req = new \Slim\Http\Request($env); - $this->assertEquals('PUT', $req->headers('X_HTTP_METHOD_OVERRIDE')); - $this->assertNull($req->headers('X_METHOD_OVERRIDE')); //<-- Ensures `HTTP_` is not removed if not prefix - $this->assertEquals('application/json', $req->headers('HTTP_CONTENT_TYPE')); //<-- Ensures `HTTP_` is removed if prefix - } - - /** - * Test get body - */ - public function testGetBodyWhenExists() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => 'foo=bar&abc=123', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 15 - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('foo=bar&abc=123', $req->getBody()); - } - - /** - * Test get body - */ - public function testGetBodyWhenNotExists() - { - $env = \Slim\Environment::mock(); - $req = new \Slim\Http\Request($env); - $this->assertEquals('', $req->getBody()); - } - - /** - * Test get content type - */ - public function testGetContentTypeWhenExists() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => '', - 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('application/json; charset=ISO-8859-4', $req->getContentType()); - } - - /** - * Test get content type for built-in PHP server - */ - public function testGetContentTypeForBuiltInServer() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => '', - 'HTTP_CONTENT_TYPE' => 'application/json; charset=ISO-8859-4' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('application/json; charset=ISO-8859-4', $req->getContentType()); - } - - /** - * Test get content type - */ - public function testGetContentTypeWhenNotExists() - { - $env = \Slim\Environment::mock(); - $req = new \Slim\Http\Request($env); - $this->assertNull($req->getContentType()); - } - - /** - * Test get content type with built-in server - */ - public function testGetContentTypeWithBuiltInServer() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => '', - 'HTTP_CONTENT_TYPE' => 'application/json; charset=ISO-8859-4' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('application/json; charset=ISO-8859-4', $req->getContentType()); - } - - /** - * Test get media type - */ - public function testGetMediaTypeWhenExists() - { - $env = \Slim\Environment::mock(array( - 'CONTENT_TYPE' => 'application/json;charset=utf-8' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('application/json', $req->getMediaType()); - } - - /** - * Test get media type - */ - public function testGetMediaTypeWhenNotExists() - { - $env = \Slim\Environment::mock(); - $req = new \Slim\Http\Request($env); - $this->assertNull($req->getMediaType()); - } - - /** - * Test get media type - */ - public function testGetMediaTypeWhenNoParamsExist() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => '', - 'CONTENT_TYPE' => 'application/json' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('application/json', $req->getMediaType()); - } - - /** - * Test get media type params - */ - public function testGetMediaTypeParams() - { - $env = \Slim\Environment::mock(array( - 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4' - )); - $req = new \Slim\Http\Request($env); - $params = $req->getMediaTypeParams(); - $this->assertEquals(1, count($params)); - $this->assertArrayHasKey('charset', $params); - $this->assertEquals('ISO-8859-4', $params['charset']); - } - - /** - * Test get media type params - */ - public function testGetMediaTypeParamsWhenNotExists() - { - $env = \Slim\Environment::mock(); - $req = new \Slim\Http\Request($env); - $params = $req->getMediaTypeParams(); - $this->assertTrue(is_array($params)); - $this->assertEquals(0, count($params)); - } - - /** - * Test get content charset - */ - public function testGetContentCharset() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => '', - 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('ISO-8859-4', $req->getContentCharset()); - } - - /** - * Test get content charset - */ - public function testGetContentCharsetWhenNotExists() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => '', - 'CONTENT_TYPE' => 'application/json' - )); - $req = new \Slim\Http\Request($env); - $this->assertNull($req->getContentCharset()); - } - - /** - * Test get content length - */ - public function testGetContentLength() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => 'foo=bar&abc=123', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 15 - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(15, $req->getContentLength()); - } - - /** - * Test get content length - */ - public function testGetContentLengthWhenNotExists() - { - $env = \Slim\Environment::mock(array( - 'slim.input' => '', - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals(0, $req->getContentLength()); - } - - /** - * Test get host - */ - public function testGetHost() - { - $env = \Slim\Environment::mock(array( - 'SERVER_NAME' => 'slim', - 'HTTP_HOST' => 'slimframework.com' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('slimframework.com', $req->getHost()); //Uses HTTP_HOST if available - } - - /** - * Test get host when it has a port number - */ - public function testGetHostAndStripPort() - { - $env = \Slim\Environment::mock(array( - 'SERVER_NAME' => 'slim', - 'HTTP_HOST' => 'slimframework.com:80' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('slimframework.com', $req->getHost()); //Uses HTTP_HOST if available - } - - /** - * Test get host - */ - public function testGetHostWhenNotExists() - { - $env = \Slim\Environment::mock(array( - 'SERVER_NAME' => 'slim', - 'HTTP_HOST' => 'slimframework.com' - )); - unset($env['HTTP_HOST']); - $req = new \Slim\Http\Request($env); - $this->assertEquals('slim', $req->getHost()); //Uses SERVER_NAME as backup - } - - /** - * Test get host with port - */ - public function testGetHostWithPort() - { - $env = \Slim\Environment::mock(array( - 'HTTP_HOST' => 'slimframework.com', - 'SERVER_NAME' => 'slim', - 'SERVER_PORT' => 80, - 'slim.url_scheme' => 'http' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('slimframework.com:80', $req->getHostWithPort()); - } - - /** - * Test get host with port doesn't duplicate port numbers - */ - public function testGetHostDoesntDuplicatePort() - { - $env = \Slim\Environment::mock(array( - 'HTTP_HOST' => 'slimframework.com:80', - 'SERVER_NAME' => 'slim', - 'SERVER_PORT' => 80, - 'slim.url_scheme' => 'http' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('slimframework.com:80', $req->getHostWithPort()); - } - - /** - * Test get port - */ - public function testGetPort() - { - $env = \Slim\Environment::mock(array( - 'SERVER_PORT' => 80 - )); - $req = new \Slim\Http\Request($env); - $this->assertTrue(is_integer($req->getPort())); - $this->assertEquals(80, $req->getPort()); - } - - /** - * Test get scheme - */ - public function testGetSchemeIfHttp() - { - $env = \Slim\Environment::mock(array( - 'slim.url_scheme' => 'http' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('http', $req->getScheme()); - } - - /** - * Test get scheme - */ - public function testGetSchemeIfHttps() - { - $env = \Slim\Environment::mock(array( - 'slim.url_scheme' => 'https', - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('https', $req->getScheme()); - } - - /** - * Test get [script name, root uri, path, path info, resource uri] in subdirectory without htaccess - */ - public function testAppPathsInSubdirectoryWithoutHtaccess() - { - $env = \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo/index.php', //<-- Physical - 'PATH_INFO' => '/bar/xyz', //<-- Virtual - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('/foo/index.php', $req->getScriptName()); - $this->assertEquals('/foo/index.php', $req->getRootUri()); - $this->assertEquals('/foo/index.php/bar/xyz', $req->getPath()); - $this->assertEquals('/bar/xyz', $req->getPathInfo()); - $this->assertEquals('/bar/xyz', $req->getResourceUri()); - } - - /** - * Test get [script name, root uri, path, path info, resource uri] in subdirectory with htaccess - */ - public function testAppPathsInSubdirectoryWithHtaccess() - { - $env = \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar/xyz', //<-- Virtual - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('/foo', $req->getScriptName()); - $this->assertEquals('/foo', $req->getRootUri()); - $this->assertEquals('/foo/bar/xyz', $req->getPath()); - $this->assertEquals('/bar/xyz', $req->getPathInfo()); - $this->assertEquals('/bar/xyz', $req->getResourceUri()); - } - - /** - * Test get [script name, root uri, path, path info, resource uri] in root directory without htaccess - */ - public function testAppPathsInRootDirectoryWithoutHtaccess() - { - $env = \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', //<-- Physical - 'PATH_INFO' => '/bar/xyz', //<-- Virtual - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('/index.php', $req->getScriptName()); - $this->assertEquals('/index.php', $req->getRootUri()); - $this->assertEquals('/index.php/bar/xyz', $req->getPath()); - $this->assertEquals('/bar/xyz', $req->getPathInfo()); - $this->assertEquals('/bar/xyz', $req->getResourceUri()); - } - - /** - * Test get [script name, root uri, path, path info, resource uri] in root directory with htaccess - */ - public function testAppPathsInRootDirectoryWithHtaccess() - { - $env = \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '', //<-- Physical - 'PATH_INFO' => '/bar/xyz', //<-- Virtual - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('', $req->getScriptName()); - $this->assertEquals('', $req->getRootUri()); - $this->assertEquals('/bar/xyz', $req->getPath()); - $this->assertEquals('/bar/xyz', $req->getPathInfo()); - $this->assertEquals('/bar/xyz', $req->getResourceUri()); - } - - /** - * Test get URL - */ - public function testGetUrl() - { - $env = \Slim\Environment::mock(array( - 'HTTP_HOST' => 'slimframework.com', - 'SERVER_NAME' => 'slim', - 'SERVER_PORT' => 80, - 'slim.url_scheme' => 'http' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('http://slimframework.com', $req->getUrl()); - } - - /** - * Test get URL - */ - public function testGetUrlWithCustomPort() - { - $env = \Slim\Environment::mock(array( - 'HTTP_HOST' => 'slimframework.com', - 'SERVER_NAME' => 'slim', - 'SERVER_PORT' => 8080, - 'slim.url_scheme' => 'http' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('http://slimframework.com:8080', $req->getUrl()); - } - - /** - * Test get URL - */ - public function testGetUrlWithHttps() - { - $env = \Slim\Environment::mock(array( - 'HTTP_HOST' => 'slimframework.com', - 'SERVER_NAME' => 'slim', - 'SERVER_PORT' => 443, - 'slim.url_scheme' => 'https' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('https://slimframework.com', $req->getUrl()); - } - - /** - * Test get IP - * @dataProvider dataTestIp - */ - public function testGetIp(array $server, $expected) - { - $env = \Slim\Environment::mock($server); - $req = new \Slim\Http\Request($env); - $this->assertEquals($expected, $req->getIp()); - } - - public function dataTestIp() - { - return array( - array(array('REMOTE_ADDR' => '127.0.0.1'), '127.0.0.1'), - array(array('REMOTE_ADDR' => '127.0.0.1', 'CLIENT_IP' => '127.0.0.2'), '127.0.0.2'), - array(array('REMOTE_ADDR' => '127.0.0.1', 'CLIENT_IP' => '127.0.0.2', 'X_FORWARDED_FOR' => '127.0.0.3'), '127.0.0.3'), - array(array('REMOTE_ADDR' => '127.0.0.1', 'CLIENT_IP' => '127.0.0.2', 'HTTP_X_FORWARDED_FOR' => '127.0.0.4'), '127.0.0.4'), - array(array('REMOTE_ADDR' => '127.0.0.1', 'CLIENT_IP' => '127.0.0.2', 'X_FORWARDED_FOR' => '127.0.0.3', 'HTTP_X_FORWARDED_FOR' => '127.0.0.4'), '127.0.0.3'), - ); - } - - /** - * Test get referer - */ - public function testGetReferrer() - { - $env = \Slim\Environment::mock(array( - 'HTTP_REFERER' => 'http://foo.com' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('http://foo.com', $req->getReferrer()); - $this->assertEquals('http://foo.com', $req->getReferer()); - } - - /** - * Test get referer - */ - public function testGetReferrerWhenNotExists() - { - $env = \Slim\Environment::mock(); - $req = new \Slim\Http\Request($env); - $this->assertNull($req->getReferrer()); - $this->assertNull($req->getReferer()); - } - - /** - * Test get user agent string - */ - public function testGetUserAgent() - { - $env = \Slim\Environment::mock(array( - 'HTTP_USER_AGENT' => 'user-agent-string' - )); - $req = new \Slim\Http\Request($env); - $this->assertEquals('user-agent-string', $req->getUserAgent()); - } - - /** - * Test get user agent string when not set - */ - public function testGetUserAgentWhenNotExists() - { - $env = \Slim\Environment::mock(); - unset($env['HTTP_USER_AGENT']); - $req = new \Slim\Http\Request($env); - $this->assertNull($req->getUserAgent()); - } -} diff --git a/vendor/slim/slim/tests/Http/ResponseTest.php b/vendor/slim/slim/tests/Http/ResponseTest.php deleted file mode 100644 index d7c07f544..000000000 --- a/vendor/slim/slim/tests/Http/ResponseTest.php +++ /dev/null @@ -1,271 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class ResponseTest extends PHPUnit_Framework_TestCase -{ - public function testConstructWithoutArgs() - { - $res = new \Slim\Http\Response(); - - $this->assertAttributeEquals(200, 'status', $res); - $this->assertAttributeEquals('', 'body', $res); - } - - public function testConstructWithArgs() - { - $res = new \Slim\Http\Response('Foo', 201); - - $this->assertAttributeEquals(201, 'status', $res); - $this->assertAttributeEquals('Foo', 'body', $res); - } - - public function testGetStatus() - { - $res = new \Slim\Http\Response(); - - $this->assertEquals(200, $res->getStatus()); - } - - public function testSetStatus() - { - $res = new \Slim\Http\Response(); - $res->setStatus(301); - - $this->assertAttributeEquals(301, 'status', $res); - } - - /** - * DEPRECATION WARNING! - */ - public function testStatusGetOld() - { - $res = new \Slim\Http\Response('', 201); - $this->assertEquals(201, $res->status()); - } - - /** - * DEPRECATION WARNING! - */ - public function testStatusSetOld() - { - $res = new \Slim\Http\Response(); - $prop = new \ReflectionProperty($res, 'status'); - $prop->setAccessible(true); - $res->status(301); - - $this->assertEquals(301, $prop->getValue($res)); - } - - public function testGetBody() - { - $res = new \Slim\Http\Response(); - $property = new \ReflectionProperty($res, 'body'); - $property->setAccessible(true); - $property->setValue($res, 'foo'); - - $this->assertEquals('foo', $res->getBody()); - } - - public function testSetBody() - { - $res = new \Slim\Http\Response('bar'); - $res->setBody('foo'); // <-- Should replace body - - $this->assertAttributeEquals('foo', 'body', $res); - } - - public function testWrite() - { - $res = new \Slim\Http\Response(); - $property = new \ReflectionProperty($res, 'body'); - $property->setAccessible(true); - $property->setValue($res, 'foo'); - $res->write('bar'); // <-- Should append to body - - $this->assertAttributeEquals('foobar', 'body', $res); - } - - public function testLength() - { - $res = new \Slim\Http\Response('foo'); // <-- Sets body and length - - $this->assertEquals(3, $res->getLength()); - } - - public function testFinalize() - { - $res = new \Slim\Http\Response(); - $resFinal = $res->finalize(); - - $this->assertTrue(is_array($resFinal)); - $this->assertEquals(3, count($resFinal)); - $this->assertEquals(200, $resFinal[0]); - $this->assertInstanceOf('\Slim\Http\Headers', $resFinal[1]); - $this->assertEquals('', $resFinal[2]); - } - - public function testFinalizeWithEmptyBody() - { - $res = new \Slim\Http\Response('Foo', 304); - $resFinal = $res->finalize(); - - $this->assertEquals('', $resFinal[2]); - } - - public function testRedirect() - { - $res = new \Slim\Http\Response(); - $res->redirect('/foo'); - - $pStatus = new \ReflectionProperty($res, 'status'); - $pStatus->setAccessible(true); - - $this->assertEquals(302, $pStatus->getValue($res)); - $this->assertEquals('/foo', $res->headers['Location']); - } - - public function testIsEmpty() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r1->setStatus(404); - $r2->setStatus(201); - $this->assertFalse($r1->isEmpty()); - $this->assertTrue($r2->isEmpty()); - } - - public function testIsClientError() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r1->setStatus(404); - $r2->setStatus(500); - $this->assertTrue($r1->isClientError()); - $this->assertFalse($r2->isClientError()); - } - - public function testIsForbidden() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r1->setStatus(403); - $r2->setStatus(500); - $this->assertTrue($r1->isForbidden()); - $this->assertFalse($r2->isForbidden()); - } - - public function testIsInformational() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r1->setStatus(100); - $r2->setStatus(200); - $this->assertTrue($r1->isInformational()); - $this->assertFalse($r2->isInformational()); - } - - public function testIsNotFound() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r1->setStatus(404); - $r2->setStatus(200); - $this->assertTrue($r1->isNotFound()); - $this->assertFalse($r2->isNotFound()); - } - - public function testIsOk() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r1->setStatus(200); - $r2->setStatus(201); - $this->assertTrue($r1->isOk()); - $this->assertFalse($r2->isOk()); - } - - public function testIsSuccessful() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r3 = new \Slim\Http\Response(); - $r1->setStatus(200); - $r2->setStatus(201); - $r3->setStatus(302); - $this->assertTrue($r1->isSuccessful()); - $this->assertTrue($r2->isSuccessful()); - $this->assertFalse($r3->isSuccessful()); - } - - public function testIsRedirect() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r1->setStatus(307); - $r2->setStatus(304); - $this->assertTrue($r1->isRedirect()); - $this->assertFalse($r2->isRedirect()); - } - - public function testIsRedirection() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r3 = new \Slim\Http\Response(); - $r1->setStatus(307); - $r2->setStatus(304); - $r3->setStatus(200); - $this->assertTrue($r1->isRedirection()); - $this->assertTrue($r2->isRedirection()); - $this->assertFalse($r3->isRedirection()); - } - - public function testIsServerError() - { - $r1 = new \Slim\Http\Response(); - $r2 = new \Slim\Http\Response(); - $r1->setStatus(500); - $r2->setStatus(400); - $this->assertTrue($r1->isServerError()); - $this->assertFalse($r2->isServerError()); - } - - public function testMessageForCode() - { - $this->assertEquals('200 OK', \Slim\Http\Response::getMessageForCode(200)); - } - - public function testMessageForCodeWithInvalidCode() - { - $this->assertNull(\Slim\Http\Response::getMessageForCode(600)); - } -} diff --git a/vendor/slim/slim/tests/Http/UtilTest.php b/vendor/slim/slim/tests/Http/UtilTest.php deleted file mode 100644 index dfe0ea1b8..000000000 --- a/vendor/slim/slim/tests/Http/UtilTest.php +++ /dev/null @@ -1,445 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class SlimHttpUtilTest extends PHPUnit_Framework_TestCase -{ - /** - * Test strip slashes when magic quotes disabled - */ - public function testStripSlashesWithoutMagicQuotes() - { - $data = "This should have \"quotes\" in it"; - $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, false); - $this->assertEquals($data, $stripped); - } - - /** - * Test strip slashes from array when magic quotes disabled - */ - public function testStripSlashesFromArrayWithoutMagicQuotes() - { - $data = array("This should have \"quotes\" in it", "And this \"too\" has quotes"); - $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, false); - $this->assertEquals($data, $stripped); - } - - /** - * Test strip slashes when magic quotes enabled - */ - public function testStripSlashesWithMagicQuotes() - { - $data = "This should have \"quotes\" in it"; - $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, true); - $this->assertEquals('This should have "quotes" in it', $stripped); - } - - /** - * Test strip slashes from array when magic quotes enabled - */ - public function testStripSlashesFromArrayWithMagicQuotes() - { - $data = array("This should have \"quotes\" in it", "And this \"too\" has quotes"); - $stripped = \Slim\Http\Util::stripSlashesIfMagicQuotes($data, true); - $this->assertEquals($data = array('This should have "quotes" in it', 'And this "too" has quotes'), $stripped); - } - - /** - * Test encrypt and decrypt with valid data - */ - public function testEncryptAndDecryptWithValidData() - { - $data = 'foo'; - $key = 'secret'; - $iv = md5('initializationVector'); - $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv); - $decrypted = \Slim\Http\Util::decrypt($encrypted, $key, $iv); - $this->assertEquals($data, $decrypted); - $this->assertTrue($data !== $encrypted); - } - - /** - * Test encrypt when data is empty string - */ - public function testEncryptWhenDataIsEmptyString() - { - $data = ''; - $key = 'secret'; - $iv = md5('initializationVector'); - $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv); - $this->assertEquals('', $encrypted); - } - - /** - * Test decrypt when data is empty string - */ - public function testDecryptWhenDataIsEmptyString() - { - $data = ''; - $key = 'secret'; - $iv = md5('initializationVector'); - $decrypted = \Slim\Http\Util::decrypt($data, $key, $iv); - $this->assertEquals('', $decrypted); - } - - /** - * Test encrypt when IV and key sizes are too long - */ - public function testEncryptAndDecryptWhenKeyAndIvAreTooLong() - { - $data = 'foo'; - $key = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; - $iv = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'; - $encrypted = \Slim\Http\Util::encrypt($data, $key, $iv); - $decrypted = \Slim\Http\Util::decrypt($encrypted, $key, $iv); - $this->assertEquals($data, $decrypted); - $this->assertTrue($data !== $encrypted); - } - - public function testEncodeAndDecodeSecureCookieWithValidData() - { - //Prepare cookie value - $value = 'foo'; - $expires = time() + 86400; - $secret = 'password'; - $algorithm = MCRYPT_RIJNDAEL_256; - $mode = MCRYPT_MODE_CBC; - $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode); - $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode); - - //Test secure cookie value - $parts = explode('|', $encodedValue); - $this->assertEquals(3, count($parts)); - $this->assertEquals($expires, $parts[0]); - $this->assertEquals($value, $decodedValue); - } - - /** - * Test encode/decode secure cookie with old expiration - * - * In this test, the expiration date is purposefully set to a time before now. - * When decoding the encoded cookie value, FALSE is returned since the cookie - * will have expired before it is decoded. - */ - public function testEncodeAndDecodeSecureCookieWithOldExpiration() - { - $value = 'foo'; - $expires = time() - 100; - $secret = 'password'; - $algorithm = MCRYPT_RIJNDAEL_256; - $mode = MCRYPT_MODE_CBC; - $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode); - $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode); - $this->assertFalse($decodedValue); - } - - /** - * Test encode/decode secure cookie with tampered data - * - * In this test, the encoded data is purposefully changed to simulate someone - * tampering with the client-side cookie data. When decoding the encoded cookie value, - * FALSE is returned since the verification key will not match. - */ - public function testEncodeAndDecodeSecureCookieWithTamperedData() - { - $value = 'foo'; - $expires = time() + 86400; - $secret = 'password'; - $algorithm = MCRYPT_RIJNDAEL_256; - $mode = MCRYPT_MODE_CBC; - $encodedValue = \Slim\Http\Util::encodeSecureCookie($value, $expires, $secret, $algorithm, $mode); - $encodedValueParts = explode('|', $encodedValue); - $encodedValueParts[1] = $encodedValueParts[1] . 'changed'; - $encodedValue = implode('|', $encodedValueParts); - $decodedValue = \Slim\Http\Util::decodeSecureCookie($encodedValue, $secret, $algorithm, $mode); - $this->assertFalse($decodedValue); - } - - public function testSetCookieHeaderWithNameAndValue() - { - $name = 'foo'; - $value = 'bar'; - $header = array(); - \Slim\Http\Util::setCookieHeader($header, $name, $value); - $this->assertEquals('foo=bar', $header['Set-Cookie']); - } - - public function testSetCookieHeaderWithNameAndValueWhenCookieAlreadySet() - { - $name = 'foo'; - $value = 'bar'; - $header = array('Set-Cookie' => 'one=two'); - \Slim\Http\Util::setCookieHeader($header, $name, $value); - $this->assertEquals("one=two\nfoo=bar", $header['Set-Cookie']); - } - - public function testSetCookieHeaderWithNameAndValueAndDomain() - { - $name = 'foo'; - $value = 'bar'; - $domain = 'foo.com'; - $header = array(); - \Slim\Http\Util::setCookieHeader($header, $name, array( - 'value' => $value, - 'domain' => $domain - )); - $this->assertEquals('foo=bar; domain=foo.com', $header['Set-Cookie']); - } - - public function testSetCookieHeaderWithNameAndValueAndDomainAndPath() - { - $name = 'foo'; - $value = 'bar'; - $domain = 'foo.com'; - $path = '/foo'; - $header = array(); - \Slim\Http\Util::setCookieHeader($header, $name, array( - 'value' => $value, - 'domain' => $domain, - 'path' => $path - )); - $this->assertEquals('foo=bar; domain=foo.com; path=/foo', $header['Set-Cookie']); - } - - public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsString() - { - $name = 'foo'; - $value = 'bar'; - $domain = 'foo.com'; - $path = '/foo'; - $expires = '2 days'; - $expiresFormat = gmdate('D, d-M-Y H:i:s e', strtotime($expires)); - $header = array(); - \Slim\Http\Util::setCookieHeader($header, $name, array( - 'value' => $value, - 'domain' => $domain, - 'path' => '/foo', - 'expires' => $expires - )); - $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat, $header['Set-Cookie']); - } - - public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsInteger() - { - $name = 'foo'; - $value = 'bar'; - $domain = 'foo.com'; - $path = '/foo'; - $expires = strtotime('2 days'); - $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires); - $header = array(); - \Slim\Http\Util::setCookieHeader($header, $name, array( - 'value' => $value, - 'domain' => $domain, - 'path' => '/foo', - 'expires' => $expires - )); - $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat, $header['Set-Cookie']); - } - - public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAsZero() - { - $name = 'foo'; - $value = 'bar'; - $domain = 'foo.com'; - $path = '/foo'; - $expires = 0; - $header = array(); - \Slim\Http\Util::setCookieHeader($header, $name, array( - 'value' => $value, - 'domain' => $domain, - 'path' => '/foo', - 'expires' => $expires - )); - $this->assertEquals('foo=bar; domain=foo.com; path=/foo', $header['Set-Cookie']); - } - - public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAndSecure() - { - $name = 'foo'; - $value = 'bar'; - $domain = 'foo.com'; - $path = '/foo'; - $expires = strtotime('2 days'); - $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires); - $secure = true; - $header = array(); - \Slim\Http\Util::setCookieHeader($header, $name, array( - 'value' => $value, - 'domain' => $domain, - 'path' => '/foo', - 'expires' => $expires, - 'secure' => $secure - )); - $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat . '; secure', $header['Set-Cookie']); - } - - public function testSetCookieHeaderWithNameAndValueAndDomainAndPathAndExpiresAndSecureAndHttpOnly() - { - $name = 'foo'; - $value = 'bar'; - $domain = 'foo.com'; - $path = '/foo'; - $expires = strtotime('2 days'); - $expiresFormat = gmdate('D, d-M-Y H:i:s e', $expires); - $secure = true; - $httpOnly = true; - $header = array(); - \Slim\Http\Util::setCookieHeader($header, $name, array( - 'value' => $value, - 'domain' => $domain, - 'path' => '/foo', - 'expires' => $expires, - 'secure' => $secure, - 'httponly' => $httpOnly - )); - $this->assertEquals('foo=bar; domain=foo.com; path=/foo; expires=' . $expiresFormat . '; secure; HttpOnly', $header['Set-Cookie']); - } - - /** - * Test serializeCookies and decrypt with string expires - * - * In this test a cookie with a string typed value for 'expires' is set, - * which should be parsed by `strtotime` to a timestamp when it's added to - * the headers; this timestamp should then be correctly parsed, and the - * value correctly decrypted, by `decodeSecureCookie`. - */ - public function testSerializeCookiesAndDecryptWithStringExpires() - { - $value = 'bar'; - - $headers = new \Slim\Http\Headers(); - - $settings = array( - 'cookies.encrypt' => true, - 'cookies.secret_key' => 'secret', - 'cookies.cipher' => MCRYPT_RIJNDAEL_256, - 'cookies.cipher_mode' => MCRYPT_MODE_CBC - ); - - $cookies = new \Slim\Http\Cookies(); - $cookies->set('foo', array( - 'value' => $value, - 'expires' => '1 hour' - )); - - \Slim\Http\Util::serializeCookies($headers, $cookies, $settings); - - $encrypted = $headers->get('Set-Cookie'); - $encrypted = strstr($encrypted, ';', true); - $encrypted = urldecode(substr(strstr($encrypted, '='), 1)); - - $decrypted = \Slim\Http\Util::decodeSecureCookie( - $encrypted, - $settings['cookies.secret_key'], - $settings['cookies.cipher'], - $settings['cookies.cipher_mode'] - ); - - $this->assertEquals($value, $decrypted); - $this->assertTrue($value !== $encrypted); - } - - public function testDeleteCookieHeaderWithSurvivingCookie() - { - $header = array('Set-Cookie' => "foo=bar\none=two"); - \Slim\Http\Util::deleteCookieHeader($header, 'foo'); - $this->assertEquals(1, preg_match("@^one=two\nfoo=; expires=@", $header['Set-Cookie'])); - } - - public function testDeleteCookieHeaderWithoutSurvivingCookie() - { - $header = array('Set-Cookie' => "foo=bar"); - \Slim\Http\Util::deleteCookieHeader($header, 'foo'); - $this->assertEquals(1, preg_match("@foo=; expires=@", $header['Set-Cookie'])); - } - - public function testDeleteCookieHeaderWithMatchingDomain() - { - $header = array('Set-Cookie' => "foo=bar; domain=foo.com"); - \Slim\Http\Util::deleteCookieHeader($header, 'foo', array( - 'domain' => 'foo.com' - )); - $this->assertEquals(1, preg_match("@foo=; domain=foo.com; expires=@", $header['Set-Cookie'])); - } - - public function testDeleteCookieHeaderWithoutMatchingDomain() - { - $header = array('Set-Cookie' => "foo=bar; domain=foo.com"); - \Slim\Http\Util::deleteCookieHeader($header, 'foo', array( - 'domain' => 'bar.com' - )); - $this->assertEquals(1, preg_match("@foo=bar; domain=foo\.com\nfoo=; domain=bar\.com@", $header['Set-Cookie'])); - } - - /** - * Test parses Cookie: HTTP header - */ - public function testParsesCookieHeader() - { - $header = 'foo=bar; one=two; colors=blue'; - $result = \Slim\Http\Util::parseCookieHeader($header); - $this->assertEquals(3, count($result)); - $this->assertEquals('bar', $result['foo']); - $this->assertEquals('two', $result['one']); - $this->assertEquals('blue', $result['colors']); - } - - /** - * Test parses Cookie: HTTP header with `=` in the cookie value - */ - public function testParsesCookieHeaderWithEqualSignInValue() - { - $header = 'foo=bar; one=two=; colors=blue'; - $result = \Slim\Http\Util::parseCookieHeader($header); - $this->assertEquals(3, count($result)); - $this->assertEquals('bar', $result['foo']); - $this->assertEquals('two=', $result['one']); - $this->assertEquals('blue', $result['colors']); - } - - public function testParsesCookieHeaderWithCommaSeparator() - { - $header = 'foo=bar, one=two, colors=blue'; - $result = \Slim\Http\Util::parseCookieHeader($header); - $this->assertEquals(3, count($result)); - $this->assertEquals('bar', $result['foo']); - $this->assertEquals('two', $result['one']); - $this->assertEquals('blue', $result['colors']); - } - - public function testPrefersLeftmostCookieWhenManyCookiesWithSameName() - { - $header = 'foo=bar; foo=beer'; - $result = \Slim\Http\Util::parseCookieHeader($header); - $this->assertEquals('bar', $result['foo']); - } -} diff --git a/vendor/slim/slim/tests/LogTest.php b/vendor/slim/slim/tests/LogTest.php deleted file mode 100644 index b3ced65ab..000000000 --- a/vendor/slim/slim/tests/LogTest.php +++ /dev/null @@ -1,208 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class MyWriter -{ - public function write( $object, $level ) - { - echo (string) $object; - - return true; - } -} - -class LogTest extends PHPUnit_Framework_TestCase -{ - public function testEnabled() - { - $log = new \Slim\Log(new MyWriter()); - $this->assertTrue($log->isEnabled()); //<-- Default case - $log->setEnabled(true); - $this->assertTrue($log->isEnabled()); - $log->setEnabled(false); - $this->assertFalse($log->isEnabled()); - } - - public function testGetLevel() - { - $log = new \Slim\Log(new MyWriter()); - $this->assertEquals(\Slim\Log::DEBUG, $log->getLevel()); - } - - public function testSetLevel() - { - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::WARN); - $this->assertEquals(\Slim\Log::WARN, $log->getLevel()); - } - - public function testSetInvalidLevel() - { - $this->setExpectedException('InvalidArgumentException'); - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::DEBUG + 1); - } - - public function testLogDebug() - { - $this->expectOutputString('Debug'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->debug('Debug'); - $this->assertTrue($result); - } - - public function testLogDebugExcludedByLevel() - { - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::INFO); - $this->assertFalse($log->debug('Debug')); - } - - public function testLogInfo() - { - $this->expectOutputString('Info'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->info('Info'); - $this->assertTrue($result); - } - - public function testLogInfoExcludedByLevel() - { - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::NOTICE); - $this->assertFalse($log->info('Info')); - } - - public function testLogNotice() - { - $this->expectOutputString('Notice'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->notice('Notice'); - $this->assertTrue($result); - } - - public function testLogNoticeExcludedByLevel() - { - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::WARN); - $this->assertFalse($log->info('Info')); - } - - public function testLogWarn() - { - $this->expectOutputString('Warn'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->warning('Warn'); - $this->assertTrue($result); - } - - public function testLogWarnExcludedByLevel() - { - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::ERROR); - $this->assertFalse($log->warning('Warn')); - } - - public function testLogError() - { - $this->expectOutputString('Error'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->error('Error'); - $this->assertTrue($result); - } - - public function testLogErrorExcludedByLevel() - { - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::CRITICAL); - $this->assertFalse($log->error('Error')); - } - - public function testLogCritical() - { - $this->expectOutputString('Critical'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->critical('Critical'); - $this->assertTrue($result); - } - - public function testLogCriticalExcludedByLevel() - { - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::ALERT); - $this->assertFalse($log->critical('Critical')); - } - - public function testLogAlert() - { - $this->expectOutputString('Alert'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->alert('Alert'); - $this->assertTrue($result); - } - - public function testLogAlertExcludedByLevel() - { - $log = new \Slim\Log(new MyWriter()); - $log->setLevel(\Slim\Log::EMERGENCY); - $this->assertFalse($log->alert('Alert')); - } - - public function testLogEmergency() - { - $this->expectOutputString('Emergency'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->emergency('Emergency'); - $this->assertTrue($result); - } - - public function testInterpolateMessage() - { - $this->expectOutputString('Hello Slim !'); - $log = new \Slim\Log(new MyWriter()); - $result = $log->debug( - 'Hello {framework} !', - array('framework' => "Slim") - ); - $this->assertTrue($result); - } - - public function testGetAndSetWriter() - { - $writer1 = new MyWriter(); - $writer2 = new MyWriter(); - $log = new \Slim\Log($writer1); - $this->assertSame($writer1, $log->getWriter()); - $log->setWriter($writer2); - $this->assertSame($writer2, $log->getWriter()); - } -} diff --git a/vendor/slim/slim/tests/LogWriterTest.php b/vendor/slim/slim/tests/LogWriterTest.php deleted file mode 100644 index 25c6f290b..000000000 --- a/vendor/slim/slim/tests/LogWriterTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class LogWriterTest extends PHPUnit_Framework_TestCase -{ - public function testInstantiation() - { - $this->expectOutputString('Hello!' . PHP_EOL); - $handle = fopen('php://output', 'w'); - $fw = new \Slim\LogWriter($handle); - $this->assertTrue($fw->write('Hello!') > 0); //<-- Returns number of bytes written if successful - } - - public function testInstantiationWithNonResource() - { - $this->setExpectedException('InvalidArgumentException'); - $fw = new \Slim\LogWriter(@fopen('/foo/bar.txt', 'w')); - } -} diff --git a/vendor/slim/slim/tests/Middleware/ContentTypesTest.php b/vendor/slim/slim/tests/Middleware/ContentTypesTest.php deleted file mode 100644 index 9510da42f..000000000 --- a/vendor/slim/slim/tests/Middleware/ContentTypesTest.php +++ /dev/null @@ -1,162 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class ContentTypesTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - ob_start(); - } - - public function tearDown() - { - ob_end_clean(); - } - - /** - * Test parses JSON - */ - public function testParsesJson() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/json', - 'CONENT_LENGTH' => 13, - 'slim.input' => '{"foo":"bar"}' - )); - $s = new \Slim\Slim(); - $s->add(new \Slim\Middleware\ContentTypes()); - $s->run(); - $body = $s->request()->getBody(); - $this->assertTrue(is_array($body)); - $this->assertEquals('bar', $body['foo']); - } - - /** - * Test ignores JSON with errors - */ - public function testParsesJsonWithError() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/json', - 'CONENT_LENGTH' => 12, - 'slim.input' => '{"foo":"bar"' //<-- This should be incorrect! - )); - $s = new \Slim\Slim(); - $s->add(new \Slim\Middleware\ContentTypes()); - $s->run(); - $body = $s->request()->getBody(); - $this->assertTrue(is_string($body)); - $this->assertEquals('{"foo":"bar"', $body); - } - - /** - * Test parses XML - */ - public function testParsesXml() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/xml', - 'CONENT_LENGTH' => 68, - 'slim.input' => '1Clive Cussler' - )); - $s = new \Slim\Slim(); - $s->add(new \Slim\Middleware\ContentTypes()); - $s->run(); - $body = $s->request()->getBody(); - $this->assertInstanceOf('SimpleXMLElement', $body); - $this->assertEquals('Clive Cussler', (string) $body->book->author); - } - - /** - * Test ignores XML with errors - */ - public function testParsesXmlWithError() - { - libxml_use_internal_errors(true); - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/xml', - 'CONTENT_LENGTH' => 68, - 'slim.input' => '1Clive Cussler' //<-- This should be incorrect! - )); - $s = new \Slim\Slim(); - $s->add(new \Slim\Middleware\ContentTypes()); - $s->run(); - $body = $s->request()->getBody(); - $this->assertTrue(is_string($body)); - $this->assertEquals('1Clive Cussler', $body); - } - - /** - * Test parses CSV - */ - public function testParsesCsv() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'text/csv', - 'CONTENT_LENGTH' => 44, - 'slim.input' => "John,Doe,000-111-2222\nJane,Doe,111-222-3333" - )); - $s = new \Slim\Slim(); - $s->add(new \Slim\Middleware\ContentTypes()); - $s->run(); - $body = $s->request()->getBody(); - $this->assertTrue(is_array($body)); - $this->assertEquals(2, count($body)); - $this->assertEquals('000-111-2222', $body[0][2]); - $this->assertEquals('Doe', $body[1][1]); - } - - /** - * Test parses request body based on media-type only, disregarding - * any extra content-type header parameters - */ - public function testParsesRequestBodyWithMediaType() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/json; charset=ISO-8859-4', - 'CONTENT_LENGTH' => 13, - 'slim.input' => '{"foo":"bar"}' - )); - $s = new \Slim\Slim(); - $s->add(new \Slim\Middleware\ContentTypes()); - $s->run(); - $body = $s->request()->getBody(); - $this->assertTrue(is_array($body)); - $this->assertEquals('bar', $body['foo']); - } -} diff --git a/vendor/slim/slim/tests/Middleware/FlashTest.php b/vendor/slim/slim/tests/Middleware/FlashTest.php deleted file mode 100644 index d7cde6c7e..000000000 --- a/vendor/slim/slim/tests/Middleware/FlashTest.php +++ /dev/null @@ -1,141 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class SlimFlashTest extends PHPUnit_Framework_TestCase -{ - /** - * Setup - */ - public function setUp() - { - $_SESSION = array(); - } - - /** - * Test set flash message for next request - */ - public function testSetFlashForNextRequest() - { - $f = new \Slim\Middleware\Flash(); - $f->set('foo', 'bar'); - $f->save(); - $this->assertEquals('bar', $_SESSION['slim.flash']['foo']); - } - - /** - * Test set flash message for current request - */ - public function testSetFlashForCurrentRequest() - { - $f = new \Slim\Middleware\Flash(); - $f->now('foo', 'bar'); - $this->assertEquals('bar', $f['foo']); - } - - /** - * Test loads flash from previous request - */ - public function testLoadsFlashFromPreviousRequest() - { - $_SESSION['slim.flash'] = array('info' => 'foo'); - $f = new \Slim\Middleware\Flash(); - $f->loadMessages(); - $this->assertEquals('foo', $f['info']); - } - - /** - * Test keep flash message for next request - */ - public function testKeepFlashFromPreviousRequest() - { - $_SESSION['slim.flash'] = array('info' => 'foo'); - $f = new \Slim\Middleware\Flash(); - $f->loadMessages(); - $f->keep(); - $f->save(); - $this->assertEquals('foo', $_SESSION['slim.flash']['info']); - } - - /** - * Test flash messages from previous request do not persist to next request - */ - public function testFlashMessagesFromPreviousRequestDoNotPersist() - { - $_SESSION['slim.flash'] = array('info' => 'foo'); - $f = new \Slim\Middleware\Flash(); - $f->save(); - $this->assertEmpty($_SESSION['slim.flash']); - } - - /** - * Test set Flash using array access - */ - public function testFlashArrayAccess() - { - $_SESSION['slim.flash'] = array('info' => 'foo'); - $f = new \Slim\Middleware\Flash(); - $f['info'] = 'bar'; - $f->save(); - $this->assertTrue(isset($f['info'])); - $this->assertEquals('bar', $f['info']); - unset($f['info']); - $this->assertFalse(isset($f['info'])); - } - - /** - * Test iteration - */ - public function testIteration() - { - $_SESSION['slim.flash'] = array('info' => 'foo', 'error' => 'bar'); - $f = new \Slim\Middleware\Flash(); - $f->loadMessages(); - $output = ''; - foreach ($f as $key => $value) { - $output .= $key . $value; - } - $this->assertEquals('infofooerrorbar', $output); - } - - /** - * Test countable - */ - public function testCountable() - { - $_SESSION['slim.flash'] = array('info' => 'foo', 'error' => 'bar'); - $f = new \Slim\MiddleWare\Flash(); - $f->loadMessages(); - $this->assertEquals(2, count($f)); - } - - -} diff --git a/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php b/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php deleted file mode 100644 index 48d00c98d..000000000 --- a/vendor/slim/slim/tests/Middleware/MethodOverrideTest.php +++ /dev/null @@ -1,149 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * We use a mock application, instead of a Slim application. - * so that we may easily test the Method Override middleware - * in isolation. - */ -class CustomAppMethod -{ - protected $environment; - - public function __construct() - { - $this->environment = \Slim\Environment::getInstance(); - } - - public function &environment() { - return $this->environment; - } - - public function call() - { - //Do nothing - } -} - -class MethodOverrideTest extends PHPUnit_Framework_TestCase -{ - /** - * Test overrides method as POST - */ - public function testOverrideMethodAsPost() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', - 'CONTENT_LENGTH' => 11, - 'slim.input' => '_METHOD=PUT' - )); - $app = new CustomAppMethod(); - $mw = new \Slim\Middleware\MethodOverride(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $env =& $app->environment(); - $this->assertEquals('PUT', $env['REQUEST_METHOD']); - $this->assertTrue(isset($env['slim.method_override.original_method'])); - $this->assertEquals('POST', $env['slim.method_override.original_method']); - } - - /** - * Test does not override method if not POST - */ - public function testDoesNotOverrideMethodIfNotPost() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'GET', - 'slim.input' => '' - )); - $app = new CustomAppMethod(); - $mw = new \Slim\Middleware\MethodOverride(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $env =& $app->environment(); - $this->assertEquals('GET', $env['REQUEST_METHOD']); - $this->assertFalse(isset($env['slim.method_override.original_method'])); - } - - /** - * Test does not override method if no method override parameter - */ - public function testDoesNotOverrideMethodAsPostWithoutParameter() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'REMOTE_ADDR' => '127.0.0.1', - 'SCRIPT_NAME' => '/foo/index.php', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'QUERY_STRING' => 'foo=bar', - 'SERVER_NAME' => 'slim', - 'SERVER_PORT' => 80, - 'slim.url_scheme' => 'http', - 'slim.input' => '', - 'slim.errors' => fopen('php://stderr', 'w') - )); - $app = new CustomAppMethod(); - $mw = new \Slim\Middleware\MethodOverride(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $env =& $app->environment(); - $this->assertEquals('POST', $env['REQUEST_METHOD']); - $this->assertFalse(isset($env['slim.method_override.original_method'])); - } - - /** - * Test overrides method with X-Http-Method-Override header - */ - public function testOverrideMethodAsHeader() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'CONTENT_TYPE' => 'application/json', - 'CONTENT_LENGTH' => 0, - 'slim.input' => '', - 'HTTP_X_HTTP_METHOD_OVERRIDE' => 'DELETE' - )); - $app = new CustomAppMethod(); - $mw = new \Slim\Middleware\MethodOverride(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $env =& $app->environment(); - $this->assertEquals('DELETE', $env['REQUEST_METHOD']); - $this->assertTrue(isset($env['slim.method_override.original_method'])); - $this->assertEquals('POST', $env['slim.method_override.original_method']); - } -} diff --git a/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php b/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php deleted file mode 100644 index 3e29655bb..000000000 --- a/vendor/slim/slim/tests/Middleware/PrettyExceptionsTest.php +++ /dev/null @@ -1,153 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class PrettyExceptionsTest extends PHPUnit_Framework_TestCase -{ - /** - * Test middleware returns successful response unchanged - */ - public function testReturnsUnchangedSuccessResponse() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo' - )); - $app = new \Slim\Slim(); - $app->get('/foo', function () { - echo "Success"; - }); - $mw = new \Slim\Middleware\PrettyExceptions(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $this->assertEquals(200, $app->response()->status()); - $this->assertEquals('Success', $app->response()->body()); - } - - /** - * Test middleware returns diagnostic screen for error response - */ - public function testReturnsDiagnosticsForErrorResponse() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo' - )); - $app = new \Slim\Slim(array( - 'log.enabled' => false - )); - $app->get('/foo', function () { - throw new \Exception('Test Message', 100); - }); - $mw = new \Slim\Middleware\PrettyExceptions(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $this->assertEquals(1, preg_match('@Slim Application Error@', $app->response()->body())); - $this->assertEquals(500, $app->response()->status()); - } - - /** - * Test middleware overrides response content type to html - */ - public function testResponseContentTypeIsOverriddenToHtml() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo' - )); - $app = new \Slim\Slim(array( - 'log.enabled' => false - )); - $app->get('/foo', function () use ($app) { - $app->contentType('application/json;charset=utf-8'); //<-- set content type to something else - throw new \Exception('Test Message', 100); - }); - $mw = new \Slim\Middleware\PrettyExceptions(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $response = $app->response(); - $this->assertEquals('text/html', $response['Content-Type']); - } - - /** - * Test exception type is in response body - */ - public function testExceptionTypeIsInResponseBody() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo' - )); - $app = new \Slim\Slim(array( - 'log.enabled' => false - )); - $app->get('/foo', function () use ($app) { - throw new \LogicException('Test Message', 100); - }); - $mw = new \Slim\Middleware\PrettyExceptions(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - - $this->assertContains('LogicException', $app->response()->body()); - } - - /** - * Test with custom log - */ - public function testWithCustomLogWriter() - { - $this->setExpectedException('\LogicException'); - - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo' - )); - $app = new \Slim\Slim(array( - 'log.enabled' => false - )); - $app->container->singleton('log', function () use ($app) { - return new \Slim\Log(new \Slim\LogWriter('php://temp')); - }); - $app->get('/foo', function () use ($app) { - throw new \LogicException('Test Message', 100); - }); - $mw = new \Slim\Middleware\PrettyExceptions(); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - - $this->assertContains('LogicException', $app->response()->body()); - } -} diff --git a/vendor/slim/slim/tests/Middleware/SessionCookieTest.php b/vendor/slim/slim/tests/Middleware/SessionCookieTest.php deleted file mode 100644 index 9543ac41f..000000000 --- a/vendor/slim/slim/tests/Middleware/SessionCookieTest.php +++ /dev/null @@ -1,469 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class SessionCookieTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - $_SESSION = array(); - } - - /** - * Test session cookie is set and constructed correctly - * - * We test for two things: - * - * 1) That the HTTP cookie exists with the correct name; - * 2) That the HTTP cookie's value is the expected value; - */ - public function testSessionCookieIsCreated() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo' - )); - $app = new \Slim\Slim(); - $app->get('/foo', function () { - $_SESSION['foo'] = 'bar'; - echo "Success"; - }); - $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - list($status, $header, $body) = $app->response()->finalize(); - $this->assertTrue($app->response->cookies->has('slim_session')); - $cookie = $app->response->cookies->get('slim_session'); - $this->assertEquals(serialize(array('foo' => 'bar')), $cookie['value']); - } - - /** - * Test $_SESSION is populated from an encrypted HTTP cookie - * - * The encrypted cookie contains the serialized array ['foo' => 'bar']. The - * global secret, cipher, and cipher mode are assumed to be the default - * values. - */ - public function testSessionIsPopulatedFromEncryptedCookie() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo', - 'HTTP_COOKIE' => 'slim_session=1644004961%7CLKkYPwqKIMvBK7MWl6D%2BxeuhLuMaW4quN%2F512ZAaVIY%3D%7Ce0f007fa852c7101e8224bb529e26be4d0dfbd63', - )); - $app = new \Slim\Slim(); - // The cookie value in the test is encrypted, so cookies.encrypt must - // be set to true - $app->config('cookies.encrypt', true); - $app->get('/foo', function () { - echo "Success"; - }); - $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $this->assertEquals(array('foo' => 'bar'), $_SESSION); - } - - /** - * Test $_SESSION is populated from an unencrypted HTTP cookie - * - * The unencrypted cookie contains the serialized array ['foo' => 'bar']. - * The global cookies.encrypt setting is set to false - */ - public function testSessionIsPopulatedFromUnencryptedCookie() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo', - 'HTTP_COOKIE' => 'slim_session=a%3A1%3A%7Bs%3A3%3A%22foo%22%3Bs%3A3%3A%22bar%22%3B%7D', - )); - $app = new \Slim\Slim(); - // The cookie value in the test is unencrypted, so cookies.encrypt must - // be set to false - $app->config('cookies.encrypt', false); - $app->get('/foo', function () { - echo "Success"; - }); - $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $this->assertEquals(array('foo' => 'bar'), $_SESSION); - } - - public function testUnserializeErrorsAreCaughtAndLogged() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo', - 'HTTP_COOKIE' => 'slim_session=1644004961%7CLKkYPwqKIMvBK7MWl6D%2BxeuhLuMaW4quN%2F512ZAaVIY%3D%7Ce0f007fa852c7101e8224bb529e26be4d0dfbd63', - )); - - $logWriter = $this->getMockBuilder('Slim\LogWriter') - ->disableOriginalConstructor() - ->getMock(); - - $logWriter->expects($this->once()) - ->method('write'); - $oldLevel = error_reporting(E_ALL); - - $app = new \Slim\Slim(array( - 'log.writer' => $logWriter - )); - // Unserializing an encrypted value fails if cookie not decrpyted - $app->config('cookies.encrypt', false); - $app->get('/foo', function () { - echo "Success"; - }); - $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $this->assertEquals(array(), $_SESSION); - - error_reporting($oldLevel); - } - - /** - * Test $_SESSION is populated as empty array if no HTTP cookie - */ - public function testSessionIsPopulatedAsEmptyIfNoCookie() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo' - )); - $app = new \Slim\Slim(); - $app->get('/foo', function () { - echo "Success"; - }); - $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - $this->assertEquals(array(), $_SESSION); - } - - public function testSerializingTooLongValueWritesLogAndDoesntCreateCookie() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/index.php', - 'PATH_INFO' => '/foo' - )); - - $logWriter = $this->getMockBuilder('Slim\LogWriter') - ->disableOriginalConstructor() - ->getMock(); - - $logWriter->expects($this->once()) - ->method('write') - ->with('WARNING! Slim\Middleware\SessionCookie data size is larger than 4KB. Content save failed.', \Slim\Log::ERROR); - - $app = new \Slim\Slim(array( - 'log.writer' => $logWriter - )); - - $tooLongValue = $this->getTooLongValue(); - - $app->get('/foo', function () use ($tooLongValue) { - $_SESSION['test'] = $tooLongValue; - echo "Success"; - }); - - $mw = new \Slim\Middleware\SessionCookie(array('expires' => '10 years')); - $mw->setApplication($app); - $mw->setNextMiddleware($app); - $mw->call(); - list($status, $header, $body) = $app->response()->finalize(); - $this->assertFalse($app->response->cookies->has('slim_session')); - } - - /** - * Generated by http://www.random.org/strings/ - */ - protected function getTooLongValue() - { - return << - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class MyMiddleware extends \Slim\Middleware -{ - public function call() {} -} - -class MiddlewareTest extends PHPUnit_Framework_TestCase -{ - public function testSetApplication() - { - $app = new stdClass(); - $mw = new MyMiddleware(); - $mw->setApplication($app); - - $this->assertAttributeSame($app, 'app', $mw); - } - - public function testGetApplication() - { - $app = new stdClass(); - $mw = new MyMiddleware(); - $property = new \ReflectionProperty($mw, 'app'); - $property->setAccessible(true); - $property->setValue($mw, $app); - - $this->assertSame($app, $mw->getApplication()); - } - - public function testSetNextMiddleware() - { - $mw1 = new MyMiddleware(); - $mw2 = new MyMiddleware(); - $mw1->setNextMiddleware($mw2); - - $this->assertAttributeSame($mw2, 'next', $mw1); - } - - public function testGetNextMiddleware() - { - $mw1 = new MyMiddleware(); - $mw2 = new MyMiddleware(); - $property = new \ReflectionProperty($mw1, 'next'); - $property->setAccessible(true); - $property->setValue($mw1, $mw2); - - $this->assertSame($mw2, $mw1->getNextMiddleware()); - } -} diff --git a/vendor/slim/slim/tests/README b/vendor/slim/slim/tests/README deleted file mode 100644 index 7bc611c31..000000000 --- a/vendor/slim/slim/tests/README +++ /dev/null @@ -1,18 +0,0 @@ -Slim Framework Unit Tests - -Follow the directions below to run the Slim Framework unit tests. You'll need the latest version of PHPUnit. To save development time, these unit tests require PHP >= 5.3. However, the Slim Framework itself requires only PHP >= 5.2. - -1. Install the latest version of PHPUnit -Visit http://www.phpunit.de/ for installation instructions. - -2. Run PHPUnit -From the filesystem directory that contains the `tests` directory, you may run all unit tests or specific unit tests. Here are several examples. The '$>' in the examples below is your command prompt. - -To run all tests: -$> phpunit tests - -To run all HTTP-related tests: -$> phpunit tests/Http - -To run only the HTTP Request tests: -$> phpunit tests/Http/RequestTest \ No newline at end of file diff --git a/vendor/slim/slim/tests/RouteTest.php b/vendor/slim/slim/tests/RouteTest.php deleted file mode 100644 index b44fa8c89..000000000 --- a/vendor/slim/slim/tests/RouteTest.php +++ /dev/null @@ -1,599 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class LazyInitializeTestClass { - public static $initialized = false; - - public function __construct() { - self::$initialized = true; - } - - public function foo() { - } -} - -class FooTestClass { - public static $foo_invoked = false; - public static $foo_invoked_args = array(); - - public function foo() { - self::$foo_invoked = true; - self::$foo_invoked_args = func_get_args(); - } -} - -class RouteTest extends PHPUnit_Framework_TestCase -{ - public function testGetPattern() - { - $route = new \Slim\Route('/foo', function () {}); - - $this->assertEquals('/foo', $route->getPattern()); - } - - public function testGetName() - { - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($route, 'name'); - $property->setAccessible(true); - $property->setValue($route, 'foo'); - - $this->assertEquals('foo', $route->getName()); - } - - public function testSetName() - { - $route = new \Slim\Route('/foo', function () {}); - $route->name('foo'); // <-- Alias for `setName()` - - $this->assertAttributeEquals('foo', 'name', $route); - } - - public function testGetCallable() - { - $callable = function () { - echo 'Foo'; - }; - $route = new \Slim\Route('/foo', $callable); - - $this->assertSame($callable, $route->getCallable()); - } - - public function testGetCallableAsClass() - { - FooTestClass::$foo_invoked = false; - FooTestClass::$foo_invoked_args = array(); - $route = new \Slim\Route('/foo', '\FooTestClass:foo'); - $route->setParams(array('bar' => '1234')); - - $this->assertFalse(FooTestClass::$foo_invoked); - $this->assertTrue($route->dispatch()); - $this->assertTrue(FooTestClass::$foo_invoked); - $this->assertEquals(array('1234'), FooTestClass::$foo_invoked_args); - } - - public function testGetCallableAsClassLazyInitialize() - { - LazyInitializeTestClass::$initialized = false; - - $route = new \Slim\Route('/foo', '\LazyInitializeTestClass:foo'); - $this->assertFalse(LazyInitializeTestClass::$initialized); - - $route->dispatch(); - $this->assertTrue(LazyInitializeTestClass::$initialized); - } - - public function testGetCallableAsStaticMethod() - { - $route = new \Slim\Route('/bar', '\Slim\Slim::getInstance'); - - $callable = $route->getCallable(); - $this->assertEquals('\Slim\Slim::getInstance', $callable); - } - - public function example_càllâble_wïth_wéird_chars() - { - return 'test'; - } - - public function testGetCallableWithOddCharsAsClass() - { - $route = new \Slim\Route('/foo', '\RouteTest:example_càllâble_wïth_wéird_chars'); - $callable = $route->getCallable(); - - $this->assertEquals('test', $callable()); - } - - public function testSetCallable() - { - $callable = function () { - echo 'Foo'; - }; - $route = new \Slim\Route('/foo', $callable); // <-- Called inside __construct() - - $this->assertAttributeSame($callable, 'callable', $route); - } - - public function testSetCallableWithInvalidArgument() - { - $this->setExpectedException('\InvalidArgumentException'); - $route = new \Slim\Route('/foo', 'doesNotExist'); // <-- Called inside __construct() - } - - public function testGetParams() - { - $route = new \Slim\Route('/hello/:first/:last', function () {}); - $route->matches('/hello/mr/anderson'); // <-- Parses params from argument - - $this->assertEquals(array( - 'first' => 'mr', - 'last' => 'anderson' - ), $route->getParams()); - } - - public function testSetParams() - { - $route = new \Slim\Route('/hello/:first/:last', function () {}); - $route->matches('/hello/mr/anderson'); // <-- Parses params from argument - $route->setParams(array( - 'first' => 'agent', - 'last' => 'smith' - )); - - $this->assertAttributeEquals(array( - 'first' => 'agent', - 'last' => 'smith' - ), 'params', $route); - } - - public function testGetParam() - { - $route = new \Slim\Route('/hello/:first/:last', function () {}); - - $property = new \ReflectionProperty($route, 'params'); - $property->setAccessible(true); - $property->setValue($route, array( - 'first' => 'foo', - 'last' => 'bar' - )); - - $this->assertEquals('foo', $route->getParam('first')); - } - - public function testGetParamThatDoesNotExist() - { - $this->setExpectedException('InvalidArgumentException'); - - $route = new \Slim\Route('/hello/:first/:last', function () {}); - - $property = new \ReflectionProperty($route, 'params'); - $property->setAccessible(true); - $property->setValue($route, array( - 'first' => 'foo', - 'last' => 'bar' - )); - - $route->getParam('middle'); - } - - public function testSetParam() - { - $route = new \Slim\Route('/hello/:first/:last', function () {}); - $route->matches('/hello/mr/anderson'); // <-- Parses params from argument - $route->setParam('last', 'smith'); - - $this->assertAttributeEquals(array( - 'first' => 'mr', - 'last' => 'smith' - ), 'params', $route); - } - - public function testSetParamThatDoesNotExist() - { - $this->setExpectedException('InvalidArgumentException'); - - $route = new \Slim\Route('/hello/:first/:last', function () {}); - $route->matches('/hello/mr/anderson'); // <-- Parses params from argument - $route->setParam('middle', 'smith'); // <-- Should trigger InvalidArgumentException - } - - public function testMatches() - { - $route = new \Slim\Route('/hello/:name', function () {}); - - $this->assertTrue($route->matches('/hello/josh')); - } - - public function testMatchesIsFalse() - { - $route = new \Slim\Route('/foo', function () {}); - - $this->assertFalse($route->matches('/bar')); - } - - public function testMatchesPatternWithTrailingSlash() - { - $route = new \Slim\Route('/foo/', function () {}); - - $this->assertTrue($route->matches('/foo/')); - $this->assertTrue($route->matches('/foo')); - } - - public function testMatchesPatternWithoutTrailingSlash() - { - $route = new \Slim\Route('/foo', function () {}); - - $this->assertFalse($route->matches('/foo/')); - $this->assertTrue($route->matches('/foo')); - } - - public function testMatchesWithConditions() - { - $route = new \Slim\Route('/hello/:first/and/:second', function () {}); - $route->conditions(array( - 'first' => '[a-zA-Z]{3,}' - )); - - $this->assertTrue($route->matches('/hello/Josh/and/John')); - } - - public function testMatchesWithConditionsIsFalse() - { - $route = new \Slim\Route('/hello/:first/and/:second', function () {}); - $route->conditions(array( - 'first' => '[a-z]{3,}' - )); - - $this->assertFalse($route->matches('/hello/Josh/and/John')); - } - - /* - * Route should match URI with valid path component according to rfc2396 - * - * "Uniform Resource Identifiers (URI): Generic Syntax" http://www.ietf.org/rfc/rfc2396.txt - * - * Excludes "+" which is valid but decodes into a space character - */ - public function testMatchesWithValidRfc2396PathComponent() - { - $symbols = ':@&=$,'; - $route = new \Slim\Route('/rfc2386/:symbols', function () {}); - - $this->assertTrue($route->matches('/rfc2386/' . $symbols)); - } - - /* - * Route should match URI including unreserved punctuation marks from rfc2396 - * - * "Uniform Resource Identifiers (URI): Generic Syntax" http://www.ietf.org/rfc/rfc2396.txt - */ - public function testMatchesWithUnreservedMarks() - { - $marks = "-_.!~*'()"; - $route = new \Slim\Route('/marks/:marks', function () {}); - - $this->assertTrue($route->matches('/marks/' . $marks)); - } - - public function testMatchesOptionalParameters() - { - $pattern = '/archive/:year(/:month(/:day))'; - - $route1 = new \Slim\Route($pattern, function () {}); - $this->assertTrue($route1->matches('/archive/2010')); - $this->assertEquals(array('year' => '2010'), $route1->getParams()); - - $route2 = new \Slim\Route($pattern, function () {}); - $this->assertTrue($route2->matches('/archive/2010/05')); - $this->assertEquals(array('year' => '2010', 'month' => '05'), $route2->getParams()); - - $route3 = new \Slim\Route($pattern, function () {}); - $this->assertTrue($route3->matches('/archive/2010/05/13')); - $this->assertEquals(array('year' => '2010', 'month' => '05', 'day' => '13'), $route3->getParams()); - } - - public function testMatchesIsCaseSensitiveByDefault() - { - $route = new \Slim\Route('/case/sensitive', function () {}); - $this->assertTrue($route->matches('/case/sensitive')); - $this->assertFalse($route->matches('/CaSe/SensItiVe')); - } - - public function testMatchesCanBeCaseInsensitive() - { - $route = new \Slim\Route('/Case/Insensitive', function () {}, false); - $this->assertTrue($route->matches('/Case/Insensitive')); - $this->assertTrue($route->matches('/CaSe/iNSensItiVe')); - } - - public function testGetConditions() - { - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($route, 'conditions'); - $property->setAccessible(true); - $property->setValue($route, array('foo' => '\d{3}')); - - $this->assertEquals(array('foo' => '\d{3}'), $route->getConditions()); - } - - public function testSetDefaultConditions() - { - \Slim\Route::setDefaultConditions(array( - 'id' => '\d+' - )); - - $property = new \ReflectionProperty('\Slim\Route', 'defaultConditions'); - $property->setAccessible(true); - - $this->assertEquals(array( - 'id' => '\d+' - ), $property->getValue()); - } - - public function testGetDefaultConditions() - { - $property = new \ReflectionProperty('\Slim\Route', 'defaultConditions'); - $property->setAccessible(true); - $property->setValue(array( - 'id' => '\d+' - )); - - $this->assertEquals(array( - 'id' => '\d+' - ), \Slim\Route::getDefaultConditions()); - } - - public function testDefaultConditionsAssignedToInstance() - { - $staticProperty = new \ReflectionProperty('\Slim\Route', 'defaultConditions'); - $staticProperty->setAccessible(true); - $staticProperty->setValue(array( - 'id' => '\d+' - )); - $route = new \Slim\Route('/foo', function () {}); - - $this->assertAttributeEquals(array( - 'id' => '\d+' - ), 'conditions', $route); - } - - public function testMatchesWildcard() - { - $route = new \Slim\Route('/hello/:path+/world', function () {}); - - $this->assertTrue($route->matches('/hello/foo/bar/world')); - $this->assertAttributeEquals(array( - 'path' => array('foo', 'bar') - ), 'params', $route); - } - - public function testMatchesMultipleWildcards() - { - $route = new \Slim\Route('/hello/:path+/world/:date+', function () {}); - - $this->assertTrue($route->matches('/hello/foo/bar/world/2012/03/10')); - $this->assertAttributeEquals(array( - 'path' => array('foo', 'bar'), - 'date' => array('2012', '03', '10') - ), 'params', $route); - } - - public function testMatchesParamsAndWildcards() - { - $route = new \Slim\Route('/hello/:path+/world/:year/:month/:day/:path2+', function () {}); - - $this->assertTrue($route->matches('/hello/foo/bar/world/2012/03/10/first/second')); - $this->assertAttributeEquals(array( - 'path' => array('foo', 'bar'), - 'year' => '2012', - 'month' => '03', - 'day' => '10', - 'path2' => array('first', 'second') - ), 'params', $route); - } - - public function testMatchesParamsWithOptionalWildcard() - { - $route = new \Slim\Route('/hello(/:foo(/:bar+))', function () {}); - - $this->assertTrue($route->matches('/hello')); - $this->assertTrue($route->matches('/hello/world')); - $this->assertTrue($route->matches('/hello/world/foo')); - $this->assertTrue($route->matches('/hello/world/foo/bar')); - } - - public function testSetMiddleware() - { - $route = new \Slim\Route('/foo', function () {}); - $mw = function () { - echo 'Foo'; - }; - $route->setMiddleware($mw); - - $this->assertAttributeContains($mw, 'middleware', $route); - } - - public function testSetMiddlewareMultipleTimes() - { - $route = new \Slim\Route('/foo', function () {}); - $mw1 = function () { - echo 'Foo'; - }; - $mw2 = function () { - echo 'Bar'; - }; - $route->setMiddleware($mw1); - $route->setMiddleware($mw2); - - $this->assertAttributeContains($mw1, 'middleware', $route); - $this->assertAttributeContains($mw2, 'middleware', $route); - } - - public function testSetMiddlewareWithArray() - { - $route = new \Slim\Route('/foo', function () {}); - $mw1 = function () { - echo 'Foo'; - }; - $mw2 = function () { - echo 'Bar'; - }; - $route->setMiddleware(array($mw1, $mw2)); - - $this->assertAttributeContains($mw1, 'middleware', $route); - $this->assertAttributeContains($mw2, 'middleware', $route); - } - - public function testSetMiddlewareWithInvalidArgument() - { - $this->setExpectedException('InvalidArgumentException'); - - $route = new \Slim\Route('/foo', function () {}); - $route->setMiddleware('doesNotExist'); // <-- Should throw InvalidArgumentException - } - - public function testSetMiddlewareWithArrayWithInvalidArgument() - { - $this->setExpectedException('InvalidArgumentException'); - - $route = new \Slim\Route('/foo', function () {}); - $route->setMiddleware(array('doesNotExist')); - } - - public function testGetMiddleware() - { - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($route, 'middleware'); - $property->setAccessible(true); - $property->setValue($route, array('foo' => 'bar')); - - $this->assertEquals(array('foo' => 'bar'), $route->getMiddleware()); - } - - public function testSetHttpMethods() - { - $route = new \Slim\Route('/foo', function () {}); - $route->setHttpMethods('GET', 'POST'); - - $this->assertAttributeEquals(array('GET', 'POST'), 'methods', $route); - } - - public function testGetHttpMethods() - { - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($route, 'methods'); - $property->setAccessible(true); - $property->setValue($route, array('GET', 'POST')); - - $this->assertEquals(array('GET', 'POST'), $route->getHttpMethods()); - } - - public function testAppendHttpMethods() - { - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($route, 'methods'); - $property->setAccessible(true); - $property->setValue($route, array('GET', 'POST')); - - $route->appendHttpMethods('PUT'); - - $this->assertAttributeEquals(array('GET', 'POST', 'PUT'), 'methods', $route); - } - - public function testAppendHttpMethodsWithVia() - { - $route = new \Slim\Route('/foo', function () {}); - $route->via('PUT'); - - $this->assertAttributeContains('PUT', 'methods', $route); - } - - public function testSupportsHttpMethod() - { - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($route, 'methods'); - $property->setAccessible(true); - $property->setValue($route, array('POST')); - - $this->assertTrue($route->supportsHttpMethod('POST')); - $this->assertFalse($route->supportsHttpMethod('PUT')); - } - - /** - * Test dispatch with params - */ - public function testDispatch() - { - $this->expectOutputString('Hello josh'); - $route = new \Slim\Route('/hello/:name', function ($name) { echo "Hello $name"; }); - $route->matches('/hello/josh'); //<-- Extracts params from resource URI - $route->dispatch(); - } - - /** - * Test dispatch with middleware - */ - public function testDispatchWithMiddleware() - { - $this->expectOutputString('First! Second! Hello josh'); - $route = new \Slim\Route('/hello/:name', function ($name) { echo "Hello $name"; }); - $route->setMiddleware(function () { - echo "First! "; - }); - $route->setMiddleware(function () { - echo "Second! "; - }); - $route->matches('/hello/josh'); //<-- Extracts params from resource URI - $route->dispatch(); - } - - /** - * Test middleware with arguments - */ - public function testRouteMiddlwareArguments() - { - $this->expectOutputString('foobar'); - $route = new \Slim\Route('/foo', function () { echo "bar"; }); - $route->setName('foo'); - $route->setMiddleware(function ($route) { - echo $route->getName(); - }); - $route->matches('/foo'); //<-- Extracts params from resource URI - $route->dispatch(); - } -} diff --git a/vendor/slim/slim/tests/RouterTest.php b/vendor/slim/slim/tests/RouterTest.php deleted file mode 100644 index 1ae583f2e..000000000 --- a/vendor/slim/slim/tests/RouterTest.php +++ /dev/null @@ -1,250 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class RouterTest extends PHPUnit_Framework_TestCase -{ - /** - * Constructor should initialize routes as empty array - */ - public function testConstruct() - { - $router = new \Slim\Router(); - - $this->assertAttributeEquals(array(), 'routes', $router); - } - - /** - * Map should set and return instance of \Slim\Route - */ - public function testMap() - { - $router = new \Slim\Router(); - $route = new \Slim\Route('/foo', function() {}); - $router->map($route); - - $this->assertAttributeContains($route, 'routes', $router); - } - - /** - * Named route should be added and indexed by name - */ - public function testAddNamedRoute() - { - $router = new \Slim\Router(); - $route = new \Slim\Route('/foo', function () {}); - $router->addNamedRoute('foo', $route); - - $property = new \ReflectionProperty($router, 'namedRoutes'); - $property->setAccessible(true); - - $rV = $property->getValue($router); - $this->assertSame($route, $rV['foo']); - } - - /** - * Named route should have unique name - */ - public function testAddNamedRouteWithDuplicateKey() - { - $this->setExpectedException('RuntimeException'); - - $router = new \Slim\Router(); - $route = new \Slim\Route('/foo', function () {}); - $router->addNamedRoute('foo', $route); - $router->addNamedRoute('foo', $route); - } - - /** - * Router should return named route by name, or null if not found - */ - public function testGetNamedRoute() - { - $router = new \Slim\Router(); - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($router, 'namedRoutes'); - $property->setAccessible(true); - $property->setValue($router, array('foo' => $route)); - - $this->assertSame($route, $router->getNamedRoute('foo')); - $this->assertNull($router->getNamedRoute('bar')); - } - - /** - * Router should determine named routes and cache results - */ - public function testGetNamedRoutes() - { - $router = new \Slim\Router(); - $route1 = new \Slim\Route('/foo', function () {}); - $route2 = new \Slim\Route('/bar', function () {}); - - // Init router routes to array - $propertyRouterRoutes = new \ReflectionProperty($router, 'routes'); - $propertyRouterRoutes->setAccessible(true); - $propertyRouterRoutes->setValue($router, array($route1, $route2)); - - // Init router named routes to null - $propertyRouterNamedRoutes = new \ReflectionProperty($router, 'namedRoutes'); - $propertyRouterNamedRoutes->setAccessible(true); - $propertyRouterNamedRoutes->setValue($router, null); - - // Init route name - $propertyRouteName = new \ReflectionProperty($route2, 'name'); - $propertyRouteName->setAccessible(true); - $propertyRouteName->setValue($route2, 'bar'); - - $namedRoutes = $router->getNamedRoutes(); - $this->assertCount(1, $namedRoutes); - $this->assertSame($route2, $namedRoutes['bar']); - } - - /** - * Router should detect presence of a named route by name - */ - public function testHasNamedRoute() - { - $router = new \Slim\Router(); - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($router, 'namedRoutes'); - $property->setAccessible(true); - $property->setValue($router, array('foo' => $route)); - - $this->assertTrue($router->hasNamedRoute('foo')); - $this->assertFalse($router->hasNamedRoute('bar')); - } - - /** - * Router should return current route if set during iteration - */ - public function testGetCurrentRoute() - { - $router = new \Slim\Router(); - $route = new \Slim\Route('/foo', function () {}); - - $property = new \ReflectionProperty($router, 'currentRoute'); - $property->setAccessible(true); - $property->setValue($router, $route); - - $this->assertSame($route, $router->getCurrentRoute()); - } - - /** - * Router should return first matching route if current route not set yet by iteration - */ - public function testGetCurrentRouteIfMatchedRoutes() - { - $router = new \Slim\Router(); - $route = new \Slim\Route('/foo', function () {}); - - $propertyMatchedRoutes = new \ReflectionProperty($router, 'matchedRoutes'); - $propertyMatchedRoutes->setAccessible(true); - $propertyMatchedRoutes->setValue($router, array($route)); - - $propertyCurrentRoute = new \ReflectionProperty($router, 'currentRoute'); - $propertyCurrentRoute->setAccessible(true); - $propertyCurrentRoute->setValue($router, null); - - $this->assertSame($route, $router->getCurrentRoute()); - } - - /** - * Router should return `null` if current route not set yet and there are no matching routes - */ - public function testGetCurrentRouteIfNoMatchedRoutes() - { - $router = new \Slim\Router(); - - $propertyMatchedRoutes = new \ReflectionProperty($router, 'matchedRoutes'); - $propertyMatchedRoutes->setAccessible(true); - $propertyMatchedRoutes->setValue($router, array()); - - $propertyCurrentRoute = new \ReflectionProperty($router, 'currentRoute'); - $propertyCurrentRoute->setAccessible(true); - $propertyCurrentRoute->setValue($router, null); - - $this->assertNull($router->getCurrentRoute()); - } - - public function testGetMatchedRoutes() - { - $router = new \Slim\Router(); - - $route1 = new \Slim\Route('/foo', function () {}); - $route1 = $route1->via('GET'); - - $route2 = new \Slim\Route('/foo', function () {}); - $route2 = $route2->via('POST'); - - $route3 = new \Slim\Route('/bar', function () {}); - $route3 = $route3->via('PUT'); - - $routes = new \ReflectionProperty($router, 'routes'); - $routes->setAccessible(true); - $routes->setValue($router, array($route1, $route2, $route3)); - - $matchedRoutes = $router->getMatchedRoutes('GET', '/foo'); - $this->assertSame($route1, $matchedRoutes[0]); - } - - // Test url for named route - - public function testUrlFor() - { - $router = new \Slim\Router(); - - $route1 = new \Slim\Route('/hello/:first/:last', function () {}); - $route1 = $route1->via('GET')->name('hello'); - - $route2 = new \Slim\Route('/path/(:foo\.:bar)', function () {}); - $route2 = $route2->via('GET')->name('regexRoute'); - - $routes = new \ReflectionProperty($router, 'namedRoutes'); - $routes->setAccessible(true); - $routes->setValue($router, array( - 'hello' => $route1, - 'regexRoute' => $route2 - )); - - $this->assertEquals('/hello/Josh/Lockhart', $router->urlFor('hello', array('first' => 'Josh', 'last' => 'Lockhart'))); - $this->assertEquals('/path/Hello.Josh', $router->urlFor('regexRoute', array('foo' => 'Hello', 'bar' => 'Josh'))); - } - - public function testUrlForIfNoSuchRoute() - { - $this->setExpectedException('RuntimeException'); - - $router = new \Slim\Router(); - $router->urlFor('foo', array('abc' => '123')); - } -} diff --git a/vendor/slim/slim/tests/SlimTest.php b/vendor/slim/slim/tests/SlimTest.php deleted file mode 100644 index a33fa4940..000000000 --- a/vendor/slim/slim/tests/SlimTest.php +++ /dev/null @@ -1,1621 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -//Mock custom view -class CustomView extends \Slim\View -{ - public function render($template, $data = null) { echo "Custom view"; } -} - -//Echo Logger -class EchoErrorLogger -{ - public function error($object) { echo get_class($object) .':'.$object->getMessage(); } -} - -//Mock extending class -class Derived extends \Slim\Slim -{ - public static function getDefaultSettings() - { - return array_merge( - array("late-static-binding" => true) - , parent::getDefaultSettings()); - } -} - -//Mock middleware -class CustomMiddleware extends \Slim\Middleware -{ - public function call() - { - $env = $this->app->environment(); - $res = $this->app->response(); - $env['slim.test'] = 'Hello'; - $this->next->call(); - $res->header('X-Slim-Test', 'Hello'); - $res->write('Hello'); - } -} - -class SlimTest extends PHPUnit_Framework_TestCase -{ - public function setUp() - { - //Remove environment mode if set - unset($_ENV['SLIM_MODE']); - - //Reset session - $_SESSION = array(); - - //Prepare default environment variables - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'QUERY_STRING' => 'one=foo&two=bar', - 'SERVER_NAME' => 'slimframework.com', - )); - } - - /************************************************ - * INSTANTIATION - ************************************************/ - - /** - * Test version constant is string - */ - public function testHasVersionConstant() - { - $this->assertTrue(is_string(\Slim\Slim::VERSION)); - } - - /** - * Test default instance properties - */ - public function testDefaultInstanceProperties() - { - $s = new \Slim\Slim(); - $this->assertInstanceOf('\Slim\Http\Request', $s->request()); - $this->assertInstanceOf('\Slim\Http\Response', $s->response()); - $this->assertInstanceOf('\Slim\Router', $s->router()); - $this->assertInstanceOf('\Slim\View', $s->view()); - $this->assertInstanceOf('\Slim\Log', $s->getLog()); - $this->assertEquals(\Slim\Log::DEBUG, $s->getLog()->getLevel()); - $this->assertTrue($s->getLog()->getEnabled()); - $this->assertInstanceOf('\Slim\Environment', $s->environment()); - } - - /** - * Test get default instance - */ - public function testGetDefaultInstance() - { - $s = new \Slim\Slim(); - $s->setName('default'); //We must do this manually since a default app is already set in prev tests - $this->assertEquals('default', $s->getName()); - $this->assertInstanceOf('\Slim\Slim', \Slim\Slim::getInstance()); - $this->assertSame($s, \Slim\Slim::getInstance()); - } - - /** - * Test get named instance - */ - public function testGetNamedInstance() - { - $s = new \Slim\Slim(); - $s->setName('foo'); - $this->assertSame($s, \Slim\Slim::getInstance('foo')); - } - - /** - * Test Slim autoloader ignores non-Slim classes - * - * Pre-conditions: - * Instantiate a non-Slim class; - * - * Post-conditions: - * Slim autoloader returns without requiring a class file; - */ - public function testSlimAutoloaderIgnoresNonSlimClass() - { - $foo = new Foo(); - } - - /************************************************ - * SETTINGS - ************************************************/ - - /** - * Test get setting that exists - */ - public function testGetSettingThatExists() - { - $s = new \Slim\Slim(); - $this->assertEquals('./templates', $s->config('templates.path')); - } - - /** - * Test get setting that does not exist - */ - public function testGetSettingThatDoesNotExist() - { - $s = new \Slim\Slim(); - $this->assertNull($s->config('foo')); - } - - /** - * Test set setting - */ - public function testSetSetting() - { - $s = new \Slim\Slim(); - $this->assertEquals('./templates', $s->config('templates.path')); - $s->config('templates.path', './tmpl'); - $this->assertEquals('./tmpl', $s->config('templates.path')); - } - - /** - * Test batch set settings - */ - public function testBatchSetSettings() - { - $s = new \Slim\Slim(); - $this->assertEquals('./templates', $s->config('templates.path')); - $this->assertTrue($s->config('debug')); - $s->config(array( - 'templates.path' => './tmpl', - 'debug' => false - )); - $this->assertEquals('./tmpl', $s->config('templates.path')); - $this->assertFalse($s->config('debug')); - } - - /** - * Test set settings recursively - */ - public function testSetSettingsRecursively() - { - $config = array( - 'my_module' => array( - 'paths' => array( - './my_module/path/1', - ), - ) - ); - - $s = new \Slim\Slim($config); - - $override = array( - 'my_module' => array( - 'paths' => array( - './my_module/path/2', - './my_module/path/3', - ), - ) - ); - - // Test recursive batch behaviour - $s->config($override, true); - - $expected = array( - 'paths' => array( - './my_module/path/1', - './my_module/path/2', - './my_module/path/3', - ), - ); - - $this->assertEquals($expected, $s->config('my_module')); - - // Test default batch behaviour - $s = new \Slim\Slim($config); - $s->config($override); - - $this->assertNotEquals($expected, $s->config('my_module')); - } - - /************************************************ - * MODES - ************************************************/ - - /** - * Test default mode - */ - public function testGetDefaultMode() - { - $s = new \Slim\Slim(); - $this->assertEquals('development', $s->getMode()); - } - - /** - * Test custom mode from environment - */ - public function testGetModeFromEnvironment() - { - $_ENV['SLIM_MODE'] = 'production'; - $s = new \Slim\Slim(); - $this->assertEquals('production', $s->getMode()); - } - - /** - * Test custom mode from app settings - */ - public function testGetModeFromSettings() - { - $s = new \Slim\Slim(array( - 'mode' => 'test' - )); - $this->assertEquals('test', $s->getMode()); - } - - /** - * Test mode configuration - */ - public function testModeConfiguration() - { - $flag = 0; - $configureTest = function () use (&$flag) { - $flag = 'test'; - }; - $configureProduction = function () use (&$flag) { - $flag = 'production'; - }; - $s = new \Slim\Slim(array('mode' => 'test')); - $s->configureMode('test', $configureTest); - $s->configureMode('production', $configureProduction); - $this->assertEquals('test', $flag); - } - - /** - * Test mode configuration when mode does not match - */ - public function testModeConfigurationWhenModeDoesNotMatch() - { - $flag = 0; - $configureTest = function () use (&$flag) { - $flag = 'test'; - }; - $s = new \Slim\Slim(array('mode' => 'production')); - $s->configureMode('test', $configureTest); - $this->assertEquals(0, $flag); - } - - /** - * Test mode configuration when not callable - */ - public function testModeConfigurationWhenNotCallable() - { - $flag = 0; - $s = new \Slim\Slim(array('mode' => 'production')); - $s->configureMode('production', 'foo'); - $this->assertEquals(0, $flag); - } - - /** - * Test custom mode from getenv() - */ - public function testGetModeFromGetEnv() - { - putenv('SLIM_MODE=production'); - $s = new \Slim\Slim(); - $this->assertEquals('production', $s->getMode()); - } - - /************************************************ - * ROUTING - ************************************************/ - - /** - * Test GENERIC route - */ - public function testGenericRoute() - { - $s = new \Slim\Slim(); - $callable = function () { echo "foo"; }; - $route = $s->map('/bar', $callable); - $this->assertInstanceOf('\Slim\Route', $route); - $this->assertEmpty($route->getHttpMethods()); - } - - /** - * Test GET routes also get mapped as a HEAD route - */ - public function testGetRouteIsAlsoMappedAsHead() - { - $s = new \Slim\Slim(); - $route = $s->get('/foo', function () {}); - $this->assertTrue($route->supportsHttpMethod(\Slim\Http\Request::METHOD_GET)); - $this->assertTrue($route->supportsHttpMethod(\Slim\Http\Request::METHOD_HEAD)); - } - - /** - * Test GET route - */ - public function testGetRoute() - { - $s = new \Slim\Slim(); - $mw1 = function () { echo "foo"; }; - $mw2 = function () { echo "bar"; }; - $callable = function () { echo "xyz"; }; - $route = $s->get('/bar', $mw1, $mw2, $callable); - $s->call(); - $this->assertEquals('foobarxyz', $s->response()->body()); - $this->assertEquals('/bar', $route->getPattern()); - $this->assertSame($callable, $route->getCallable()); - } - - /** - * Test POST route - */ - public function testPostRoute() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'POST', - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $mw1 = function () { echo "foo"; }; - $mw2 = function () { echo "bar"; }; - $callable = function () { echo "xyz"; }; - $route = $s->post('/bar', $mw1, $mw2, $callable); - $s->call(); - $this->assertEquals('foobarxyz', $s->response()->body()); - $this->assertEquals('/bar', $route->getPattern()); - $this->assertSame($callable, $route->getCallable()); - } - - /** - * Test PUT route - */ - public function testPutRoute() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PUT', - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $mw1 = function () { echo "foo"; }; - $mw2 = function () { echo "bar"; }; - $callable = function () { echo "xyz"; }; - $route = $s->put('/bar', $mw1, $mw2, $callable); - $s->call(); - $this->assertEquals('foobarxyz', $s->response()->body()); - $this->assertEquals('/bar', $route->getPattern()); - $this->assertSame($callable, $route->getCallable()); - } - - /** - * Test PATCH route - */ - public function testPatchRoute() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'PATCH', - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $mw1 = function () { echo "foo"; }; - $mw2 = function () { echo "bar"; }; - $callable = function () { echo "xyz"; }; - $route = $s->patch('/bar', $mw1, $mw2, $callable); - $s->call(); - $this->assertEquals('foobarxyz', $s->response()->body()); - $this->assertEquals('/bar', $route->getPattern()); - $this->assertSame($callable, $route->getCallable()); - } - - /** - * Test DELETE route - */ - public function testDeleteRoute() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'DELETE', - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $mw1 = function () { echo "foo"; }; - $mw2 = function () { echo "bar"; }; - $callable = function () { echo "xyz"; }; - $route = $s->delete('/bar', $mw1, $mw2, $callable); - $s->call(); - $this->assertEquals('foobarxyz', $s->response()->body()); - $this->assertEquals('/bar', $route->getPattern()); - $this->assertSame($callable, $route->getCallable()); - } - - /** - * Test OPTIONS route - */ - public function testOptionsRoute() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'OPTIONS', - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $mw1 = function () { echo "foo"; }; - $mw2 = function () { echo "bar"; }; - $callable = function () { echo "xyz"; }; - $route = $s->options('/bar', $mw1, $mw2, $callable); - $s->call(); - $this->assertEquals('foobarxyz', $s->response()->body()); - $this->assertEquals('/bar', $route->getPattern()); - $this->assertSame($callable, $route->getCallable()); - } - - /** - * Test route groups - */ - public function testRouteGroups() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'GET', - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar/baz', //<-- Virtual' - )); - $s = new \Slim\Slim(); - $mw1 = function () { echo "foo"; }; - $mw2 = function () { echo "bar"; }; - $callable = function () { echo "xyz"; }; - $s->group('/bar', $mw1, function () use ($s, $mw2, $callable) { - $s->get('/baz', $mw2, $callable); - }); - $s->call(); - $this->assertEquals('foobarxyz', $s->response()->body()); - } - - /* - * Test ANY route - */ - public function testAnyRoute() - { - $mw1 = function () { echo "foo"; }; - $mw2 = function () { echo "bar"; }; - $callable = function () { echo "xyz"; }; - $methods = array('GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'); - foreach ($methods as $i => $method) { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => $method, - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $route = $s->any('/bar', $mw1, $mw2, $callable); - $s->call(); - $this->assertEquals('foobarxyz', $s->response()->body()); - $this->assertEquals('/bar', $route->getPattern()); - $this->assertSame($callable, $route->getCallable()); - } - } - - /** - * Test if route does NOT expect trailing slash and URL has one - */ - public function testRouteWithoutSlashAndUrlWithOne() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar/', //<-- Virtual - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () { echo "xyz"; }); - $s->call(); - $this->assertEquals(404, $s->response()->status()); - } - - /** - * Tests if route will match in case-insensitive manner if configured to do so - */ - public function testRouteMatchesInCaseInsensitiveMannerIfConfigured() - { - \Slim\Environment::mock(array( - 'PATH_INFO' => '/BaR', // Does not match route case - )); - $s = new \Slim\Slim(array('routes.case_sensitive' => false)); - $route = $s->get('/bar', function () { echo "xyz"; }); - $s->call(); - $this->assertEquals(200, $s->response()->status()); - $this->assertEquals('xyz', $s->response()->body()); - $this->assertEquals('/bar', $route->getPattern()); - } - - /** - * Test if route contains URL encoded characters - */ - public function testRouteWithUrlEncodedCharacters() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar/jo%20hn/smi%20th', //<-- Virtual - )); - $s = new \Slim\Slim(); - $s->get('/bar/:one/:two', function ($one, $two) { echo $one . $two; }); - $s->call(); - $this->assertEquals('jo hnsmi th', $s->response()->body()); - } - - /************************************************ - * VIEW - ************************************************/ - - /** - * Test set view with string class name - */ - public function testSetSlimViewFromString() - { - $s = new \Slim\Slim(); - $this->assertInstanceOf('\Slim\View', $s->view()); - $s->view('CustomView'); - $this->assertInstanceOf('CustomView', $s->view()); - } - - /** - * Test set view with object instance - */ - public function testSetSlimViewFromInstance() - { - $s = new \Slim\Slim(); - $this->assertInstanceOf('\Slim\View', $s->view()); - $s->view(new CustomView()); - $this->assertInstanceOf('CustomView', $s->view()); - } - - /** - * Test view data is transferred to newer view - */ - public function testViewDataTransfer() - { - $data = array('foo' => 'bar'); - $s = new \Slim\Slim(); - $s->view()->setData($data); - $s->view('CustomView'); - $this->assertSame($data, $s->view()->getData()); - } - - /************************************************ - * RENDERING - ************************************************/ - - /** - * Test template path is passed to view - */ - public function testViewGetsTemplatesPath() - { - $path = dirname(__FILE__) . '/templates'; - $s = new \Slim\Slim(array('templates.path' => $path)); - $this->assertEquals($s->view->getTemplatesDirectory(), $path); - } - - /** - * Test render with template and data - */ - public function testRenderTemplateWithData() - { - $s = new \Slim\Slim(array('templates.path' => dirname(__FILE__) . '/templates')); - $s->get('/bar', function () use ($s) { - $s->render('test.php', array('foo' => 'bar')); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertEquals(200, $status); - $this->assertEquals('test output bar', $body); - } - - /** - * Test render with template and data and status - */ - public function testRenderTemplateWithDataAndStatus() - { - $s = new \Slim\Slim(array('templates.path' => dirname(__FILE__) . '/templates')); - $s->get('/bar', function () use ($s) { - $s->render('test.php', array('foo' => 'bar'), 500); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertEquals(500, $status); - $this->assertEquals('test output bar', $body); - } - - /************************************************ - * LOG - ************************************************/ - - /** - * Test get log - * - * This asserts that a Slim app has a default Log - * upon instantiation. The Log itself is tested - * separately in another file. - */ - public function testGetLog() - { - $s = new \Slim\Slim(); - $this->assertInstanceOf('\Slim\Log', $s->getLog()); - } - - /************************************************ - * HTTP CACHING - ************************************************/ - - /** - * Test Last-Modified match - */ - public function testLastModifiedMatch() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'GET', - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'HTTP_IF_MODIFIED_SINCE' => 'Sun, 03 Oct 2010 21:00:52 GMT', - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->lastModified(1286139652); - }); - $s->call(); - $this->assertEquals(304, $s->response()->status()); - } - - /** - * Test Last-Modified match - */ - public function testLastModifiedDoesNotMatch() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'IF_MODIFIED_SINCE' => 'Sun, 03 Oct 2010 21:00:52 GMT', - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->lastModified(1286139250); - }); - $s->call(); - $this->assertEquals(200, $s->response()->status()); - } - - public function testLastModifiedOnlyAcceptsIntegers() - { - $this->setExpectedException('\InvalidArgumentException'); - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->lastModified('Test'); - }); - $s->call(); - } - - /** - * Test Last Modified header format - */ - public function testLastModifiedHeaderFormat() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->lastModified(1286139652); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertTrue(isset($header['Last-Modified'])); - $this->assertEquals('Sun, 03 Oct 2010 21:00:52 GMT', $header['Last-Modified']); - } - - /** - * Test ETag matches - */ - public function testEtagMatches() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'HTTP_IF_NONE_MATCH' => '"abc123"', - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->etag('abc123'); - }); - $s->call(); - $this->assertEquals(304, $s->response()->status()); - } - - /** - * Test ETag does not match - */ - public function testEtagDoesNotMatch() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'IF_NONE_MATCH' => '"abc1234"', - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->etag('abc123'); - }); - $s->call(); - $this->assertEquals(200, $s->response()->status()); - } - - /** - * Test ETag with invalid type - */ - public function testETagWithInvalidType() - { - $this->setExpectedException('\InvalidArgumentException'); - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'IF_NONE_MATCH' => '"abc1234"', - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->etag('123','foo'); - }); - $s->call(); - } - - /** - * Test Expires - */ - public function testExpiresAsString() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->expires('5 days'); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertTrue(isset($header['Expires'])); - - $this->assertEquals( - strtotime('5 days'), - strtotime($header['Expires']), - 1 // delta - ); - } - - /** - * Test Expires - */ - public function testExpiresAsInteger() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $fiveDaysFromNow = time() + (60 * 60 * 24 * 5); - $expectedDate = gmdate('D, d M Y H:i:s T', $fiveDaysFromNow); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s, $fiveDaysFromNow) { - $s->expires($fiveDaysFromNow); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertTrue(isset($header['Expires'])); - $this->assertEquals($header['Expires'], $expectedDate); - } - - /************************************************ - * COOKIES - ************************************************/ - - /** - * Set cookie - * - * This tests that the Slim application instance sets - * a cookie in the HTTP response header. This does NOT - * test the implementation of setting the cookie; that is - * tested in a separate file. - */ - public function testSetCookie() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->setCookie('foo', 'bar', '2 days'); - $s->setCookie('foo1', 'bar1', '2 days'); - }); - $s->call(); - $cookie1 = $s->response->cookies->get('foo'); - $cookie2 = $s->response->cookies->get('foo1'); - $this->assertEquals(2, count($s->response->cookies)); - $this->assertEquals('bar', $cookie1['value']); - $this->assertEquals('bar1', $cookie2['value']); - } - - /** - * Test get cookie - * - * This method ensures that the `Cookie:` HTTP request - * header is parsed if present, and made accessible via the - * Request object. - */ - public function testGetCookie() - { - \Slim\Environment::mock(array( - 'REQUEST_METHOD' => 'GET', - 'REMOTE_ADDR' => '127.0.0.1', - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'QUERY_STRING' => 'one=foo&two=bar', - 'SERVER_NAME' => 'slimframework.com', - 'SERVER_PORT' => 80, - 'HTTP_COOKIE' => 'foo=bar; foo2=bar2', - 'slim.url_scheme' => 'http', - 'slim.input' => '', - 'slim.errors' => @fopen('php://stderr', 'w') - )); - $s = new \Slim\Slim(); - $this->assertEquals('bar', $s->getCookie('foo')); - $this->assertEquals('bar2', $s->getCookie('foo2')); - } - - /** - * Test get cookie when cookie does not exist - */ - public function testGetCookieThatDoesNotExist() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - )); - $s = new \Slim\Slim(); - $this->assertNull($s->getCookie('foo')); - } - - /** - * Test delete cookie - * - * This method ensures that the `Set-Cookie:` HTTP response - * header is set. The implementation of setting the response - * cookie is tested separately in another file. - */ - public function testDeleteCookie() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/bar', //<-- Virtual - 'COOKIE' => 'foo=bar; foo2=bar2', - )); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->setCookie('foo', 'bar'); - $s->deleteCookie('foo'); - }); - $s->call(); - $cookie = $s->response->cookies->get('foo'); - $this->assertEquals(1, count($s->response->cookies)); - $this->assertEquals('', $cookie['value']); - $this->assertLessThan(time(), $cookie['expires']); - } - - /************************************************ - * HELPERS - ************************************************/ - - /** - * Test get filesystem path to Slim app root directory - */ - public function testGetRoot() - { - $_SERVER['DOCUMENT_ROOT'] = dirname(__FILE__); //<-- No trailing slash - $s = new \Slim\Slim(); - $this->assertEquals($_SERVER['DOCUMENT_ROOT'] . '/foo/', $s->root()); //<-- Appends physical app path with trailing slash - } - - /** - * Test stop - */ - public function testStop() - { - $this->setExpectedException('\Slim\Exception\Stop'); - $s = new \Slim\Slim(); - $s->stop(); - } - - /** - * Test stop with subsequent output - */ - public function testStopWithSubsequentOutput() - { - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - echo "Foo"; //<-- Should be in response body! - $s->stop(); - echo "Bar"; //<-- Should not be in response body! - }); - $s->call(); - $this->assertEquals('Foo', $s->response()->body()); - } - - /** - * Test stop with output buffer on and pre content - */ - public function testStopOutputWithOutputBufferingOnAndPreContent() - { - $this->expectOutputString('1.2.Foo.3'); //<-- PHP unit uses OB here - echo "1."; - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - echo "Foo"; - $s->stop(); - }); - echo "2."; - $s->run(); //<-- Needs to be run to actually echo body - echo ".3"; - } - - /** - * Test stop does not leave output buffers open - */ - public function testStopDoesNotLeaveOutputBuffersOpen() - { - $level_start = ob_get_level(); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->stop(); - }); - $s->run(); - $this->assertEquals($level_start, ob_get_level()); - } - - /** - * Test halt - */ - public function testHalt() - { - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - echo "Foo!"; //<-- Should not be in response body! - $s->halt(500, 'Something broke'); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertEquals(500, $status); - $this->assertEquals('Something broke', $body); - } - - /** - * Test halt with output buffering and pre content - */ - public function testHaltOutputWithOutputBufferingOnAndPreContent() - { - $this->expectOutputString('1.2.Something broke.3'); //<-- PHP unit uses OB here - echo "1."; - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - echo "Foo!"; //<-- Should not be in response body! - $s->halt(500, 'Something broke'); - }); - echo "2."; - $s->run(); - echo ".3"; - } - - /** - * Test halt does not leave output buffers open - */ - public function testHaltDoesNotLeaveOutputBuffersOpen() - { - $level_start = ob_get_level(); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->halt(500, ''); - }); - $s->run(); - $this->assertEquals($level_start, ob_get_level()); - } - - /** - * Test pass cleans buffer and throws exception - */ - public function testPass() - { - ob_start(); - $s = new \Slim\Slim(); - echo "Foo"; - try { - $s->pass(); - $this->fail('Did not catch Slim_Exception_Pass'); - } catch ( \Slim\Exception\Pass $e ) {} - $output = ob_get_clean(); - $this->assertEquals('', $output); - } - - /** - * Test pass when there is a subsequent fallback route - */ - public function testPassWithSubsequentRoute() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/name/Frank', //<-- Virtual - )); - $s = new \Slim\Slim(); - $s->get('/name/Frank', function () use ($s) { - echo "Fail"; //<-- Should not be in response body! - $s->pass(); - }); - $s->get('/name/:name', function ($name) { - echo $name; //<-- Should be in response body! - }); - $s->call(); - $this->assertEquals('Frank', $s->response()->body()); - } - - /** - * Test pass when there is not a subsequent fallback route - */ - public function testPassWithoutSubsequentRoute() - { - \Slim\Environment::mock(array( - 'SCRIPT_NAME' => '/foo', //<-- Physical - 'PATH_INFO' => '/name/Frank', //<-- Virtual - )); - $s = new \Slim\Slim(); - $s->get('/name/Frank', function () use ($s) { - echo "Fail"; //<-- Should not be in response body! - $s->pass(); - }); - $s->call(); - $this->assertEquals(404, $s->response()->status()); - } - - /** - * Test content type - */ - public function testContentType() - { - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->contentType('application/json'); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertEquals('application/json', $header['Content-Type']); - } - - /** - * Test status - */ - public function testStatus() - { - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->status(403); - }); - $s->call(); - $this->assertEquals(403, $s->response()->status()); - } - - /** - * Test URL for - */ - public function testSlimUrlFor() - { - $s = new \Slim\Slim(); - $s->get('/hello/:name', function () {})->name('hello'); - $this->assertEquals('/foo/hello/Josh', $s->urlFor('hello', array('name' => 'Josh'))); //<-- Prepends physical path! - } - - /** - * Test redirect sets status and header - */ - public function testRedirect() - { - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - echo "Foo"; //<-- Should not be in response body! - $s->redirect('/somewhere/else', 303); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertEquals(303, $status); - $this->assertEquals('/somewhere/else', $header['Location']); - $this->assertEquals('', $body); - } - - /************************************************ - * RUNNER - ************************************************/ - - /** - * Test that runner sends headers and body - */ - public function testRun() - { - $this->expectOutputString('Foo'); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - echo "Foo"; - }); - $s->run(); - } - - /** - * Test runner output with output buffering on and pre content - */ - public function testRunOutputWithOutputBufferingOnAndPreContent() - { - $this->expectOutputString('1.2.Foo.3'); //<-- PHP unit uses OB here - $s = new \Slim\Slim(); - echo "1."; - $s->get('/bar', function () use ($s) { - echo "Foo"; - }); - echo "2."; - $s->run(); - echo ".3"; - } - - /** - * Test that runner does not leave output buffers open - */ - public function testRunDoesNotLeaveAnyOutputBuffersOpen() - { - $level_start = ob_get_level(); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) {}); - $s->run(); - $this->assertEquals($level_start, ob_get_level()); - } - - /************************************************ - * MIDDLEWARE - ************************************************/ - - /** - * Test add middleware - * - * This asserts that middleware are queued and called - * in sequence. This also asserts that the environment - * variables are passed by reference. - */ - public function testAddMiddleware() - { - $this->expectOutputString('FooHello'); - $s = new \Slim\Slim(); - $s->add(new CustomMiddleware()); //<-- See top of this file for class definition - $s->get('/bar', function () { - echo 'Foo'; - }); - $s->run(); - $this->assertEquals('Hello', $s->response()->header('X-Slim-Test')); - } - - /** - * Test exception when adding circular middleware queues - * - * This asserts that the same middleware can NOT be queued twice (usually by accident). - * Circular middleware stack causes a troublesome to debug PHP Fatal error: - * - * > Fatal error: Maximum function nesting level of '100' reached. aborting! - */ - public function testFailureWhenAddingCircularMiddleware() - { - $this->setExpectedException('\RuntimeException'); - $middleware = new CustomMiddleware; - $s = new \Slim\Slim; - $s->add($middleware); - $s->add(new CustomMiddleware); - $s->add($middleware); - $s->run(); - } - - /************************************************ - * FLASH MESSAGING - ************************************************/ - - public function testSetFlashForNextRequest() - { - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->flash('info', 'bar'); - }); - $this->assertFalse(isset($_SESSION['slim.flash'])); - $s->run(); - $this->assertEquals('bar', $_SESSION['slim.flash']['info']); - } - - public function testSetFlashForCurrentRequest() - { - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->flashNow('info', 'bar'); - }); - $s->run(); - $env = $s->environment(); - $this->assertEquals('bar', $env['slim.flash']['info']); - } - - public function testKeepFlashForNextRequest() - { - $_SESSION['slim.flash'] = array('info' => 'Foo'); - $s = new \Slim\Slim(); - $s->get('/bar', function () use ($s) { - $s->flashKeep(); - }); - $s->run(); - $this->assertEquals('Foo', $_SESSION['slim.flash']['info']); - } - - /************************************************ - * NOT FOUND HANDLING - ************************************************/ - - /** - * Test custom Not Found handler - */ - public function testNotFound() - { - $s = new \Slim\Slim(); - $s->notFound(function () { - echo "Not Found"; - }); - $s->get('/foo', function () {}); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertEquals(404, $status); - $this->assertEquals('Not Found', $body); - } - - /************************************************ - * ERROR HANDLING - ************************************************/ - - /** - * Test default and custom error handlers - * - * Pre-conditions: - * Invoked app route calls default error handler; - * - * Post-conditions: - * Response status code is 500; - */ - public function testSlimError() - { - $s = new \Slim\Slim(array( - "log.enabled" => false - )); - $s->get('/bar', function () use ($s) { - $s->error(); - }); - $s->call(); - $this->assertEquals(500, $s->response()->status()); - } - - /** - * Test default error handler logs the error when debug is false. - * - * Pre-conditions: - * Invoked app route calls default error handler; - * - * Post-conditions: - * Error log is called - */ - public function testDefaultHandlerLogsTheErrorWhenDebugIsFalse() - { - $s = new \Slim\Slim(array('debug' => false)); - $s->container->singleton('log', function ($c) { - return new EchoErrorLogger(); - }); - $s->get('/bar', function () use ($s) { - throw new \InvalidArgumentException('my specific error message'); - }); - - ob_start(); - $s->run(); - $output = ob_get_clean(); - $this->assertTrue(strpos($output, 'InvalidArgumentException:my specific error message') !== false); - } - - /** - * Test triggered errors are converted to ErrorExceptions - * - * Pre-conditions: - * Custom error handler defined; - * Invoked app route triggers error; - * - * Post-conditions: - * Response status is 500; - * Response body is equal to triggered error message; - * Error handler's argument is ErrorException instance; - */ - public function DISABLEDtestTriggeredErrorsAreConvertedToErrorExceptions() - { - $s = new \Slim\Slim(array( - 'debug' => false - )); - $s->error(function ( $e ) { - if ($e instanceof \ErrorException) { - echo $e->getMessage(); - } - }); - $s->get('/bar', function () { - trigger_error('Foo I say!'); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertEquals(500, $status); - $this->assertEquals('Foo I say!', $body); - } - - /** - * Test error triggered with multiple applications - * - * Pre-conditions: - * Multiple Slim apps are instantiated; - * Both apps are run; - * One app returns 200 OK; - * One app triggers an error; - * - * Post-conditions: - * One app returns 200 OK with no Exceptions; - * One app returns 500 Error; - * Error triggered does not affect other app; - */ - public function testErrorWithMultipleApps() - { - $s1 = new \Slim\Slim(array( - 'debug' => false, - 'log.enabled' => false - )); - $s2 = new \Slim\Slim(); - $s1->get('/bar', function () use ($s1) { - $s1->error(); - }); - $s2->get('/bar', function () { - echo 'success'; - }); - $s1->call(); - $s2->call(); - $this->assertEquals(500, $s1->response()->status()); - $this->assertEquals(200, $s2->response()->status()); - } - - /** - * Test custom error handler uses existing Response object - */ - public function testErrorHandlerUsesCurrentResponseObject() - { - $s = new \Slim\Slim(array( - 'debug' => false - )); - $s->error(function ( \Exception $e ) use ($s) { - $r = $s->response(); - $r->status(503); - $r->write('Foo'); - $r['X-Powered-By'] = 'Slim'; - echo 'Bar'; - }); - $s->get('/bar', function () { - throw new \Exception('Foo'); - }); - $s->call(); - list($status, $header, $body) = $s->response()->finalize(); - $this->assertEquals(503, $status); - $this->assertEquals('FooBar', $body); - $this->assertEquals('Slim', $header['X-Powered-By']); - } - - /** - * Test custom global error handler - */ - public function testHandleErrors() - { - $defaultErrorReporting = error_reporting(); - - // Test 1 - error_reporting(E_ALL ^ E_NOTICE); // <-- Report all errors EXCEPT notices - try { - \Slim\Slim::handleErrors(E_NOTICE, 'test error', 'Slim.php', 119); - } catch (\ErrorException $e) { - $this->fail('Slim::handleErrors reported a disabled error level.'); - } - - // Test 2 - error_reporting(E_ALL | E_STRICT); // <-- Report all errors, including E_STRICT - try { - \Slim\Slim::handleErrors(E_STRICT, 'test error', 'Slim.php', 119); - $this->fail('Slim::handleErrors didn\'t report a enabled error level'); - } catch (\ErrorException $e) {} - - error_reporting($defaultErrorReporting); - } - - /** - * Slim should keep reference to a callable error callback - */ - public function testErrorHandler() { - $s = new \Slim\Slim(); - $errCallback = function () { echo "404"; }; - $s->error($errCallback); - $this->assertSame($errCallback, PHPUnit_Framework_Assert::readAttribute($s, 'error')); - } - - /** - * Slim should throw a Slim_Exception_Stop if error callback is not callable - */ - public function testErrorHandlerIfNotCallable() { - $this->setExpectedException('\Slim\Exception\Stop'); - $s = new \Slim\Slim(array("log.enabled" => false)); - $errCallback = 'foo'; - $s->error($errCallback); - } - - /** - * Slim should keep reference to a callable NotFound callback - */ - public function testNotFoundHandler() { - $s = new \Slim\Slim(); - $notFoundCallback = function () { echo "404"; }; - $s->notFound($notFoundCallback); - $this->assertSame($notFoundCallback, PHPUnit_Framework_Assert::readAttribute($s, 'notFound')); - } - - /** - * Slim should throw a Slim_Exception_Stop if NotFound callback is not callable - */ - public function testNotFoundHandlerIfNotCallable() { - $this->setExpectedException('\Slim\Exception\Stop'); - $s = new \Slim\Slim(); - $notFoundCallback = 'foo'; - $s->notFound($notFoundCallback); - } - - /************************************************ - * HOOKS - ************************************************/ - - /** - * Test hook listener - * - * Pre-conditions: - * Slim app instantiated; - * Hook name does not exist; - * Listeners are callable objects; - * - * Post-conditions: - * Callables are invoked in expected order; - */ - public function testRegistersAndCallsHooksByPriority() - { - $this->expectOutputString('barfoo'); - $app = new \Slim\Slim(); - $callable1 = function () { echo "foo"; }; - $callable2 = function () { echo "bar"; }; - $app->hook('test.hook.one', $callable1); //default is 10 - $app->hook('test.hook.one', $callable2, 8); - $hooks = $app->getHooks(); - $this->assertEquals(7, count($hooks)); //6 default, 1 custom - $app->applyHook('test.hook.one'); - } - - /** - * Test hook listener if listener is not callable - * - * Pre-conditions: - * Slim app instantiated; - * Hook name does not exist; - * Listener is NOT a callable object; - * - * Post-conditions: - * Hook is created; - * Callable is NOT assigned to hook; - */ - public function testHookInvalidCallable() - { - $app = new \Slim\Slim(); - $callable = 'test'; //NOT callable - $app->hook('test.hook.one', $callable); - $this->assertEquals(array(array()), $app->getHooks('test.hook.one')); - } - - /** - * Test hook invocation if hook does not exist - * - * Pre-conditions: - * Slim app instantiated; - * Hook name does not exist; - * - * Post-conditions: - * Hook is created; - * Hook initialized with empty array; - */ - public function testHookInvocationIfNotExists() - { - $app = new \Slim\Slim(); - $app->applyHook('test.hook.one'); - $this->assertEquals(array(array()), $app->getHooks('test.hook.one')); - } - - /** - * Test clear hooks - * - * Pre-conditions: - * Slim app instantiated; - * Two hooks exist, each with one listener; - * - * Post-conditions: - * Case A: Listeners for 'test.hook.one' are cleared; - * Case B: Listeners for all hooks are cleared; - */ - public function testHookClear() - { - $app = new \Slim\Slim(); - $app->hook('test.hook.one', function () {}); - $app->hook('test.hook.two', function () {}); - $app->clearHooks('test.hook.two'); - $this->assertEquals(array(array()), $app->getHooks('test.hook.two')); - $hookOne = $app->getHooks('test.hook.one'); - $this->assertTrue(count($hookOne[10]) === 1); - $app->clearHooks(); - $this->assertEquals(array(array()), $app->getHooks('test.hook.one')); - } - - /** - * Test late static binding - * - * Pre-conditions: - * Slim app is extended by Derived class and instantiated; - * Derived class overrides the 'getDefaultSettings' function and adds an extra default config value - * Test that the new config value exists - * - * Post-conditions: - * Config value exists and is equal to expected value - */ - public function testDerivedClassCanOverrideStaticFunction() - { - $app = new Derived(); - $this->assertEquals($app->config("late-static-binding"), true); - } -} diff --git a/vendor/slim/slim/tests/ViewTest.php b/vendor/slim/slim/tests/ViewTest.php deleted file mode 100644 index 6101807cf..000000000 --- a/vendor/slim/slim/tests/ViewTest.php +++ /dev/null @@ -1,198 +0,0 @@ - - * @copyright 2011 Josh Lockhart - * @link http://www.slimframework.com - * @license http://www.slimframework.com/license - * @version 2.4.2 - * - * MIT LICENSE - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -class ViewTest extends PHPUnit_Framework_TestCase -{ - public function testGetDataAll() - { - $view = new \Slim\View(); - $prop = new \ReflectionProperty($view, 'data'); - $prop->setAccessible(true); - $prop->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar'))); - - $this->assertSame(array('foo' => 'bar'), $view->getData()); - } - - public function testGetDataKeyExists() - { - $view = new \Slim\View(); - $prop = new \ReflectionProperty($view, 'data'); - $prop->setAccessible(true); - $prop->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar'))); - - $this->assertEquals('bar', $view->getData('foo')); - } - - public function testGetDataKeyNotExists() - { - $view = new \Slim\View(); - $prop = new \ReflectionProperty($view, 'data'); - $prop->setAccessible(true); - $prop->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar'))); - - $this->assertNull($view->getData('abc')); - } - - public function testSetDataKeyValue() - { - $view = new \Slim\View(); - $prop = new \ReflectionProperty($view, 'data'); - $prop->setAccessible(true); - $view->setData('foo', 'bar'); - - $this->assertEquals(array('foo' => 'bar'), $prop->getValue($view)->all()); - } - - public function testSetDataKeyValueAsClosure() - { - $view = new \Slim\View(); - $prop = new \ReflectionProperty($view, 'data'); - $prop->setAccessible(true); - - $view->setData('fooClosure', function () { - return 'foo'; - }); - - $value = $prop->getValue($view)->get('fooClosure'); - $this->assertInstanceOf('Closure', $value); - $this->assertEquals('foo', $value()); - } - - public function testSetDataArray() - { - $view = new \Slim\View(); - $prop = new \ReflectionProperty($view, 'data'); - $prop->setAccessible(true); - $view->setData(array('foo' => 'bar')); - - $this->assertEquals(array('foo' => 'bar'), $prop->getValue($view)->all()); - } - - public function testSetDataInvalidArgument() - { - $this->setExpectedException('InvalidArgumentException'); - - $view = new \Slim\View(); - $view->setData('foo'); - } - - public function testAppendData() - { - $view = new \Slim\View(); - $prop = new \ReflectionProperty($view, 'data'); - $prop->setAccessible(true); - $view->appendData(array('foo' => 'bar')); - - $this->assertEquals(array('foo' => 'bar'), $prop->getValue($view)->all()); - } - - public function testLocalData() - { - $view = new \Slim\View(); - $prop1 = new \ReflectionProperty($view, 'data'); - $prop1->setAccessible(true); - $prop1->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar'))); - - $prop2 = new \ReflectionProperty($view, 'templatesDirectory'); - $prop2->setAccessible(true); - $prop2->setValue($view, dirname(__FILE__) . '/templates'); - - $output = $view->fetch('test.php', array('foo' => 'baz')); - $this->assertEquals('test output baz', $output); - } - - public function testAppendDataOverwrite() - { - $view = new \Slim\View(); - $prop = new \ReflectionProperty($view, 'data'); - $prop->setAccessible(true); - $prop->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar'))); - $view->appendData(array('foo' => '123')); - - $this->assertEquals(array('foo' => '123'), $prop->getValue($view)->all()); - } - - public function testAppendDataInvalidArgument() - { - $this->setExpectedException('InvalidArgumentException'); - - $view = new \Slim\View(); - $view->appendData('foo'); - } - - public function testGetTemplatesDirectory() - { - $view = new \Slim\View(); - $property = new \ReflectionProperty($view, 'templatesDirectory'); - $property->setAccessible(true); - $property->setValue($view, 'templates'); - - $this->assertEquals('templates', $view->getTemplatesDirectory()); - } - - public function testSetTemplatesDirectory() - { - $view = new \Slim\View(); - $view->setTemplatesDirectory('templates/'); // <-- Should strip trailing slash - - $this->assertAttributeEquals('templates', 'templatesDirectory', $view); - } - - public function testDisplay() - { - $this->expectOutputString('test output bar'); - - $view = new \Slim\View(); - $prop1 = new \ReflectionProperty($view, 'data'); - $prop1->setAccessible(true); - $prop1->setValue($view, new \Slim\Helper\Set(array('foo' => 'bar'))); - - $prop2 = new \ReflectionProperty($view, 'templatesDirectory'); - $prop2->setAccessible(true); - $prop2->setValue($view, dirname(__FILE__) . '/templates'); - - $view->display('test.php'); - } - - public function testDisplayTemplateThatDoesNotExist() - { - $this->setExpectedException('\RuntimeException'); - - $view = new \Slim\View(); - - $prop2 = new \ReflectionProperty($view, 'templatesDirectory'); - $prop2->setAccessible(true); - $prop2->setValue($view, dirname(__FILE__) . '/templates'); - - $view->display('foo.php'); - } -} diff --git a/vendor/slim/slim/tests/bootstrap.php b/vendor/slim/slim/tests/bootstrap.php deleted file mode 100644 index c25335009..000000000 --- a/vendor/slim/slim/tests/bootstrap.php +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/vendor/slim/views/Slim/Views/README.md b/vendor/slim/views/Slim/Views/README.md deleted file mode 100644 index b0b54cab3..000000000 --- a/vendor/slim/views/Slim/Views/README.md +++ /dev/null @@ -1,175 +0,0 @@ -# Slim Views - -This repository contains custom View classes for the template frameworks listed below. -You can use any of these custom View classes by either requiring the appropriate class in your -Slim Framework bootstrap file and initialize your Slim application using an instance of -the selected View class or using Composer (the recommended way). - -Slim Views only officially support the following views listed below. - -- Smarty -- Twig - -## How to Install - -#### using [Composer](http://getcomposer.org/) - -Create a composer.json file in your project root: - -```json -{ - "require": { - "slim/views": "0.1.*" - } -} -``` - -Then run the following composer command: - -```bash -$ php composer.phar install -``` - -## Smarty - -### How to use - -```php - new \Slim\Views\Smarty() -)); -``` - -To use Smarty options do the following: - -```php -$view = $app->view(); -$view->parserDirectory = dirname(__FILE__) . 'smarty'; -$view->parserCompileDirectory = dirname(__FILE__) . '/compiled'; -$view->parserCacheDirectory = dirname(__FILE__) . '/cache'; -``` - -## Twig - -### How to use - -```php - new \Slim\Views\Twig() -)); -``` - -To use Twig options do the following: - -```php -$view = $app->view(); -$view->parserOptions = array( - 'debug' => true, - 'cache' => dirname(__FILE__) . '/cache' -); -``` - -In addition to all of this we also have a few helper functions which are included for both view parsers. -In order to start using these you can add them to their respective view parser as stated below: - -#### Twig - -```php -$view->parserExtensions = array( - new \Slim\Views\TwigExtension(), -); -``` - -#### Smarty - -```php -$view->parserExtensions = array( - dirname(__FILE__) . '/vendor/slim/views/Slim/Views/SmartyPlugins', -); -``` - -These helpers are listed below. - -- urlFor -- siteUrl -- baseUrl - -#### urlFor - -__Twig__ - -Inside your Twig template you would write: - - {{ urlFor('hello', {"name": "Josh", "age": "19"}) }} - -You can easily pass variables that are objects or arrays by doing: - - Hello {{ name }} - -If you need to specify the appname for the getInstance method in the urlFor functions, set it as the third parameter of the function -in your template: - - Hello {{ name }} - -__Smarty__ - -Inside your Smarty template you would write: - - {urlFor name="hello" options="name.Josh|age.26"} - -or with the new array syntax: - - {urlFor name="hello" options=["name" => "Josh", "age" => "26"]} - -You can easily pass variables that are arrays as normal or using the (.): - - Hello {$name} - -If you need to specify the appname for the getInstance method in the urlFor functions, set the appname parameter in your function: - - Hello {$name} - -#### siteUrl - -__Twig__ - -Inside your Twig template you would write: - - {{ siteUrl('/about/me') }} - -__Smarty__ - -Inside your Smarty template you would write: - - {siteUrl url='/about/me'} - - -#### baseUrl - -__Twig__ - -Inside your Twig template you would write: - - {{ baseUrl() }} - -__Smarty__ - -Inside your Smarty template you would write: - - {baseUrl} - -## Authors - -[Josh Lockhart](https://github.com/codeguy) - -[Andrew Smith](https://github.com/silentworks) - -## License - -MIT Public License \ No newline at end of file diff --git a/vendor/slim/views/Slim/Views/Smarty.php b/vendor/slim/views/Slim/Views/Smarty.php deleted file mode 100644 index 6bbc37202..000000000 --- a/vendor/slim/views/Slim/Views/Smarty.php +++ /dev/null @@ -1,124 +0,0 @@ - - */ -class Smarty extends \Slim\View -{ - /** - * @var string The path to the Smarty code directory WITHOUT the trailing slash - */ - public $parserDirectory = null; - - /** - * @var string The path to the Smarty compiled templates folder WITHOUT the trailing slash - */ - public $parserCompileDirectory = null; - - /** - * @var string The path to the Smarty cache folder WITHOUT the trailing slash - */ - public $parserCacheDirectory = null; - - /** - * @var SmartyExtensions The Smarty extensions directory you want to load plugins from - */ - public $parserExtensions = array(); - - /** - * @var parserInstance persistent instance of the Parser object. - */ - private $parserInstance = null; - - /** - * Render Template - * - * This method will output the rendered template content - * - * @param string $template The path to the template, relative to the templates directory. - * @param null $data - * @return string - */ - public function render($template, $data = null) - { - $parser = $this->getInstance(); - $parser->assign($this->all()); - - return $parser->fetch($template, $data); - } - - /** - * Creates new Smarty object instance if it doesn't already exist, and returns it. - * - * @throws \RuntimeException If Smarty lib directory does not exist - * @return \Smarty Instance - */ - public function getInstance() - { - if (! ($this->parserInstance instanceof \Smarty)) { - if (!class_exists('\Smarty')) { - if (!is_dir($this->parserDirectory)) { - throw new \RuntimeException('Cannot set the Smarty lib directory : ' . $this->parserDirectory . '. Directory does not exist.'); - } - require_once $this->parserDirectory . '/Smarty.class.php'; - } - - $this->parserInstance = new \Smarty(); - $this->parserInstance->template_dir = $this->getTemplatesDirectory(); - if ($this->parserExtensions) { - $this->parserInstance->addPluginsDir($this->parserExtensions); - } - if ($this->parserCompileDirectory) { - $this->parserInstance->compile_dir = $this->parserCompileDirectory; - } - if ($this->parserCacheDirectory) { - $this->parserInstance->cache_dir = $this->parserCacheDirectory; - } - } - - return $this->parserInstance; - } -} diff --git a/vendor/slim/views/Slim/Views/SmartyPlugins/function.baseUrl.php b/vendor/slim/views/Slim/Views/SmartyPlugins/function.baseUrl.php deleted file mode 100644 index 3d66249f9..000000000 --- a/vendor/slim/views/Slim/Views/SmartyPlugins/function.baseUrl.php +++ /dev/null @@ -1,26 +0,0 @@ -request(); - $uri = $req->getUrl(); - - if ($withUri) { - $uri .= $req->getRootUri(); - } - - return $uri; -} diff --git a/vendor/slim/views/Slim/Views/SmartyPlugins/function.siteUrl.php b/vendor/slim/views/Slim/Views/SmartyPlugins/function.siteUrl.php deleted file mode 100644 index 540d7b705..000000000 --- a/vendor/slim/views/Slim/Views/SmartyPlugins/function.siteUrl.php +++ /dev/null @@ -1,27 +0,0 @@ -request(); - $uri = $req->getUrl(); - - if ($withUri) { - $uri .= $req->getRootUri(); - } - - return $uri . '/' . ltrim($url, '/'); -} diff --git a/vendor/slim/views/Slim/Views/SmartyPlugins/function.urlFor.php b/vendor/slim/views/Slim/Views/SmartyPlugins/function.urlFor.php deleted file mode 100644 index 2ab419030..000000000 --- a/vendor/slim/views/Slim/Views/SmartyPlugins/function.urlFor.php +++ /dev/null @@ -1,43 +0,0 @@ -urlFor($name); - - if (isset($params['options'])) - { - switch (gettype($params['options'])) { - case 'array': - $opts = $params['options']; - break; - - case 'string': - $options = explode('|', $params['options']); - foreach ($options as $option) { - list($key, $value) = explode('.', $option); - $opts[$key] = $value; - } - break; - - default: - throw new \Exception('Options parameter is of unknown type, provide either string or array'); - } - - $url = \Slim\Slim::getInstance($appName)->urlFor($name, $opts); - } - - return $url; -} diff --git a/vendor/slim/views/Slim/Views/Twig.php b/vendor/slim/views/Slim/Views/Twig.php deleted file mode 100644 index 2a42ca0f0..000000000 --- a/vendor/slim/views/Slim/Views/Twig.php +++ /dev/null @@ -1,153 +0,0 @@ -getInstance(); - $parser = $env->loadTemplate($template); - - $data = array_merge($this->all(), (array) $data); - - return $parser->render($data); - } - - /** - * DEPRECATION WARNING! This method will be removed in the next major point release - * - * Use getInstance method instead - */ - public function getEnvironment() - { - return $this->getInstance(); - } - - /** - * Creates new TwigEnvironment if it doesn't already exist, and returns it. - * - * @return \Twig_Environment - */ - public function getInstance() - { - if (!$this->parserInstance) { - /** - * Check if Twig_Autoloader class exists - * otherwise include it. - */ - if (!class_exists('\Twig_Autoloader')) { - require_once $this->parserDirectory . '/Autoloader.php'; - } - - \Twig_Autoloader::register(); - $loader = new \Twig_Loader_Filesystem($this->getTemplateDirs()); - $this->parserInstance = new \Twig_Environment( - $loader, - $this->parserOptions - ); - - foreach ($this->parserExtensions as $ext) { - $extension = is_object($ext) ? $ext : new $ext; - $this->parserInstance->addExtension($extension); - } - } - - return $this->parserInstance; - } - - /** - * DEPRECATION WARNING! This method will be removed in the next major point release - * - * Get a list of template directories - * - * Returns an array of templates defined by self::$twigTemplateDirs, falls - * back to Slim\View's built-in getTemplatesDirectory method. - * - * @return array - **/ - private function getTemplateDirs() - { - if (empty($this->twigTemplateDirs)) { - return array($this->getTemplatesDirectory()); - } - return $this->twigTemplateDirs; - } -} diff --git a/vendor/slim/views/Slim/Views/TwigExtension.php b/vendor/slim/views/Slim/Views/TwigExtension.php deleted file mode 100644 index e5b13ed23..000000000 --- a/vendor/slim/views/Slim/Views/TwigExtension.php +++ /dev/null @@ -1,73 +0,0 @@ -urlFor($name, $params); - } - - public function site($url, $withUri = true, $appName = 'default') - { - return $this->base($withUri, $appName) . '/' . ltrim($url, '/'); - } - - public function base($withUri = true, $appName = 'default') - { - $req = Slim::getInstance($appName)->request(); - $uri = $req->getUrl(); - - if ($withUri) { - $uri .= $req->getRootUri(); - } - return $uri; - } -} diff --git a/vendor/slim/views/Slim/Views/composer.json b/vendor/slim/views/Slim/Views/composer.json deleted file mode 100644 index be06b7416..000000000 --- a/vendor/slim/views/Slim/Views/composer.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "slim/views", - "type": "library", - "description": "Smarty and Twig View Parser package for the Slim Framework", - "keywords": ["templating", "extensions", "slimphp"], - "homepage": "http://github.com/codeguy/Slim-Views", - "license": "MIT", - "authors": [ - { - "name": "Josh Lockhart", - "email": "info@joshlockhart.com", - "homepage": "http://www.joshlockhart.com/" - }, - { - "name": "Andrew Smith", - "email": "a.smith@silentworks.co.uk", - "homepage": "http://thoughts.silentworks.co.uk/" - } - ], - "require": { - "slim/slim": ">=2.4.0", - "php": ">=5.3.0" - }, - "suggest": { - "smarty/smarty": "Smarty templating system", - "twig/twig": "Twig templating system" - }, - "autoload": { - "psr-0": { - "Slim\\Views": "" - } - }, - "target-dir": "Slim/Views" -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md deleted file mode 100644 index bb42ee19c..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/CHANGELOG.md +++ /dev/null @@ -1,23 +0,0 @@ -CHANGELOG -========= - -2.5.0 ------ - - * added Debug\TraceableEventDispatcher (originally in HttpKernel) - * changed Debug\TraceableEventDispatcherInterface to extend EventDispatcherInterface - * added RegisterListenersPass (originally in HttpKernel) - -2.1.0 ------ - - * added TraceableEventDispatcherInterface - * added ContainerAwareEventDispatcher - * added a reference to the EventDispatcher on the Event - * added a reference to the Event name on the event - * added fluid interface to the dispatch() method which now returns the Event - object - * added GenericEvent event class - * added the possibility for subscribers to subscribe several times for the - same event - * added ImmutableEventDispatcher diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php deleted file mode 100644 index af0b6cef5..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ContainerAwareEventDispatcher.php +++ /dev/null @@ -1,202 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * Lazily loads listeners and subscribers from the dependency injection - * container. - * - * @author Fabien Potencier - * @author Bernhard Schussek - * @author Jordan Alliot - */ -class ContainerAwareEventDispatcher extends EventDispatcher -{ - /** - * The container from where services are loaded. - * - * @var ContainerInterface - */ - private $container; - - /** - * The service IDs of the event listeners and subscribers. - * - * @var array - */ - private $listenerIds = array(); - - /** - * The services registered as listeners. - * - * @var array - */ - private $listeners = array(); - - /** - * Constructor. - * - * @param ContainerInterface $container A ContainerInterface instance - */ - public function __construct(ContainerInterface $container) - { - $this->container = $container; - } - - /** - * Adds a service as event listener. - * - * @param string $eventName Event for which the listener is added - * @param array $callback The service ID of the listener service & the method - * name that has to be called - * @param int $priority The higher this value, the earlier an event listener - * will be triggered in the chain. - * Defaults to 0. - * - * @throws \InvalidArgumentException - */ - public function addListenerService($eventName, $callback, $priority = 0) - { - if (!is_array($callback) || 2 !== count($callback)) { - throw new \InvalidArgumentException('Expected an array("service", "method") argument'); - } - - $this->listenerIds[$eventName][] = array($callback[0], $callback[1], $priority); - } - - public function removeListener($eventName, $listener) - { - $this->lazyLoad($eventName); - - if (isset($this->listenerIds[$eventName])) { - foreach ($this->listenerIds[$eventName] as $i => $args) { - list($serviceId, $method, $priority) = $args; - $key = $serviceId.'.'.$method; - if (isset($this->listeners[$eventName][$key]) && $listener === array($this->listeners[$eventName][$key], $method)) { - unset($this->listeners[$eventName][$key]); - if (empty($this->listeners[$eventName])) { - unset($this->listeners[$eventName]); - } - unset($this->listenerIds[$eventName][$i]); - if (empty($this->listenerIds[$eventName])) { - unset($this->listenerIds[$eventName]); - } - } - } - } - - parent::removeListener($eventName, $listener); - } - - /** - * @see EventDispatcherInterface::hasListeners() - */ - public function hasListeners($eventName = null) - { - if (null === $eventName) { - return (bool) count($this->listenerIds) || (bool) count($this->listeners); - } - - if (isset($this->listenerIds[$eventName])) { - return true; - } - - return parent::hasListeners($eventName); - } - - /** - * @see EventDispatcherInterface::getListeners() - */ - public function getListeners($eventName = null) - { - if (null === $eventName) { - foreach (array_keys($this->listenerIds) as $serviceEventName) { - $this->lazyLoad($serviceEventName); - } - } else { - $this->lazyLoad($eventName); - } - - return parent::getListeners($eventName); - } - - /** - * Adds a service as event subscriber. - * - * @param string $serviceId The service ID of the subscriber service - * @param string $class The service's class name (which must implement EventSubscriberInterface) - */ - public function addSubscriberService($serviceId, $class) - { - foreach ($class::getSubscribedEvents() as $eventName => $params) { - if (is_string($params)) { - $this->listenerIds[$eventName][] = array($serviceId, $params, 0); - } elseif (is_string($params[0])) { - $this->listenerIds[$eventName][] = array($serviceId, $params[0], isset($params[1]) ? $params[1] : 0); - } else { - foreach ($params as $listener) { - $this->listenerIds[$eventName][] = array($serviceId, $listener[0], isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - /** - * {@inheritdoc} - * - * Lazily loads listeners for this event from the dependency injection - * container. - * - * @throws \InvalidArgumentException if the service is not defined - */ - public function dispatch($eventName, Event $event = null) - { - $this->lazyLoad($eventName); - - return parent::dispatch($eventName, $event); - } - - public function getContainer() - { - return $this->container; - } - - /** - * Lazily loads listeners for this event from the dependency injection - * container. - * - * @param string $eventName The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - */ - protected function lazyLoad($eventName) - { - if (isset($this->listenerIds[$eventName])) { - foreach ($this->listenerIds[$eventName] as $args) { - list($serviceId, $method, $priority) = $args; - $listener = $this->container->get($serviceId); - - $key = $serviceId.'.'.$method; - if (!isset($this->listeners[$eventName][$key])) { - $this->addListener($eventName, array($listener, $method), $priority); - } elseif ($listener !== $this->listeners[$eventName][$key]) { - parent::removeListener($eventName, array($this->listeners[$eventName][$key], $method)); - $this->addListener($eventName, array($listener, $method), $priority); - } - - $this->listeners[$eventName][$key] = $listener; - } - } - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php deleted file mode 100644 index 2119b81b3..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcher.php +++ /dev/null @@ -1,320 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\Stopwatch\Stopwatch; -use Psr\Log\LoggerInterface; - -/** - * Collects some data about event listeners. - * - * This event dispatcher delegates the dispatching to another one. - * - * @author Fabien Potencier - */ -class TraceableEventDispatcher implements TraceableEventDispatcherInterface -{ - protected $logger; - protected $stopwatch; - - private $called; - private $dispatcher; - - /** - * Constructor. - * - * @param EventDispatcherInterface $dispatcher An EventDispatcherInterface instance - * @param Stopwatch $stopwatch A Stopwatch instance - * @param LoggerInterface $logger A LoggerInterface instance - */ - public function __construct(EventDispatcherInterface $dispatcher, Stopwatch $stopwatch, LoggerInterface $logger = null) - { - $this->dispatcher = $dispatcher; - $this->stopwatch = $stopwatch; - $this->logger = $logger; - $this->called = array(); - } - - /** - * {@inheritdoc} - */ - public function addListener($eventName, $listener, $priority = 0) - { - $this->dispatcher->addListener($eventName, $listener, $priority); - } - - /** - * {@inheritdoc} - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - $this->dispatcher->addSubscriber($subscriber); - } - - /** - * {@inheritdoc} - */ - public function removeListener($eventName, $listener) - { - return $this->dispatcher->removeListener($eventName, $listener); - } - - /** - * {@inheritdoc} - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - return $this->dispatcher->removeSubscriber($subscriber); - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - return $this->dispatcher->getListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function hasListeners($eventName = null) - { - return $this->dispatcher->hasListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function dispatch($eventName, Event $event = null) - { - if (null === $event) { - $event = new Event(); - } - - $this->preProcess($eventName); - $this->preDispatch($eventName, $event); - - $e = $this->stopwatch->start($eventName, 'section'); - - $this->dispatcher->dispatch($eventName, $event); - - if ($e->isStarted()) { - $e->stop(); - } - - $this->postDispatch($eventName, $event); - $this->postProcess($eventName); - - return $event; - } - - /** - * {@inheritdoc} - */ - public function getCalledListeners() - { - $called = array(); - foreach ($this->called as $eventName => $listeners) { - foreach ($listeners as $listener) { - $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName); - $called[$eventName.'.'.$info['pretty']] = $info; - } - } - - return $called; - } - - /** - * {@inheritdoc} - */ - public function getNotCalledListeners() - { - try { - $allListeners = $this->getListeners(); - } catch (\Exception $e) { - if (null !== $this->logger) { - $this->logger->info(sprintf('An exception was thrown while getting the uncalled listeners (%s)', $e->getMessage()), array('exception' => $e)); - } - - // unable to retrieve the uncalled listeners - return array(); - } - - $notCalled = array(); - foreach ($allListeners as $eventName => $listeners) { - foreach ($listeners as $listener) { - $called = false; - if (isset($this->called[$eventName])) { - foreach ($this->called[$eventName] as $l) { - if ($l->getWrappedListener() === $listener) { - $called = true; - - break; - } - } - } - - if (!$called) { - $info = $this->getListenerInfo($listener, $eventName); - $notCalled[$eventName.'.'.$info['pretty']] = $info; - } - } - } - - return $notCalled; - } - - /** - * Proxies all method calls to the original event dispatcher. - * - * @param string $method The method name - * @param array $arguments The method arguments - * - * @return mixed - */ - public function __call($method, $arguments) - { - return call_user_func_array(array($this->dispatcher, $method), $arguments); - } - - /** - * Called before dispatching the event. - * - * @param string $eventName The event name - * @param Event $event The event - */ - protected function preDispatch($eventName, Event $event) - { - } - - /** - * Called after dispatching the event. - * - * @param string $eventName The event name - * @param Event $event The event - */ - protected function postDispatch($eventName, Event $event) - { - } - - private function preProcess($eventName) - { - foreach ($this->dispatcher->getListeners($eventName) as $listener) { - $this->dispatcher->removeListener($eventName, $listener); - $info = $this->getListenerInfo($listener, $eventName); - $name = isset($info['class']) ? $info['class'] : $info['type']; - $this->dispatcher->addListener($eventName, new WrappedListener($listener, $name, $this->stopwatch, $this)); - } - } - - private function postProcess($eventName) - { - $skipped = false; - foreach ($this->dispatcher->getListeners($eventName) as $listener) { - if (!$listener instanceof WrappedListener) { // #12845: a new listener was added during dispatch. - continue; - } - // Unwrap listener - $this->dispatcher->removeListener($eventName, $listener); - $this->dispatcher->addListener($eventName, $listener->getWrappedListener()); - - $info = $this->getListenerInfo($listener->getWrappedListener(), $eventName); - if ($listener->wasCalled()) { - if (null !== $this->logger) { - $this->logger->debug(sprintf('Notified event "%s" to listener "%s".', $eventName, $info['pretty'])); - } - - if (!isset($this->called[$eventName])) { - $this->called[$eventName] = new \SplObjectStorage(); - } - - $this->called[$eventName]->attach($listener); - } - - if (null !== $this->logger && $skipped) { - $this->logger->debug(sprintf('Listener "%s" was not called for event "%s".', $info['pretty'], $eventName)); - } - - if ($listener->stoppedPropagation()) { - if (null !== $this->logger) { - $this->logger->debug(sprintf('Listener "%s" stopped propagation of the event "%s".', $info['pretty'], $eventName)); - } - - $skipped = true; - } - } - } - - /** - * Returns information about the listener - * - * @param object $listener The listener - * @param string $eventName The event name - * - * @return array Information about the listener - */ - private function getListenerInfo($listener, $eventName) - { - $info = array( - 'event' => $eventName, - ); - if ($listener instanceof \Closure) { - $info += array( - 'type' => 'Closure', - 'pretty' => 'closure', - ); - } elseif (is_string($listener)) { - try { - $r = new \ReflectionFunction($listener); - $file = $r->getFileName(); - $line = $r->getStartLine(); - } catch (\ReflectionException $e) { - $file = null; - $line = null; - } - $info += array( - 'type' => 'Function', - 'function' => $listener, - 'file' => $file, - 'line' => $line, - 'pretty' => $listener, - ); - } elseif (is_array($listener) || (is_object($listener) && is_callable($listener))) { - if (!is_array($listener)) { - $listener = array($listener, '__invoke'); - } - $class = is_object($listener[0]) ? get_class($listener[0]) : $listener[0]; - try { - $r = new \ReflectionMethod($class, $listener[1]); - $file = $r->getFileName(); - $line = $r->getStartLine(); - } catch (\ReflectionException $e) { - $file = null; - $line = null; - } - $info += array( - 'type' => 'Method', - 'class' => $class, - 'method' => $listener[1], - 'file' => $file, - 'line' => $line, - 'pretty' => $class.'::'.$listener[1], - ); - } - - return $info; - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php deleted file mode 100644 index 5483e8150..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/TraceableEventDispatcherInterface.php +++ /dev/null @@ -1,34 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * @author Fabien Potencier - */ -interface TraceableEventDispatcherInterface extends EventDispatcherInterface -{ - /** - * Gets the called listeners. - * - * @return array An array of called listeners - */ - public function getCalledListeners(); - - /** - * Gets the not called listeners. - * - * @return array An array of not called listeners - */ - public function getNotCalledListeners(); -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php deleted file mode 100644 index e16627d6a..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Debug/WrappedListener.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Debug; - -use Symfony\Component\Stopwatch\Stopwatch; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * @author Fabien Potencier - */ -class WrappedListener -{ - private $listener; - private $name; - private $called; - private $stoppedPropagation; - private $stopwatch; - private $dispatcher; - - public function __construct($listener, $name, Stopwatch $stopwatch, EventDispatcherInterface $dispatcher = null) - { - $this->listener = $listener; - $this->name = $name; - $this->stopwatch = $stopwatch; - $this->dispatcher = $dispatcher; - $this->called = false; - $this->stoppedPropagation = false; - } - - public function getWrappedListener() - { - return $this->listener; - } - - public function wasCalled() - { - return $this->called; - } - - public function stoppedPropagation() - { - return $this->stoppedPropagation; - } - - public function __invoke(Event $event, $eventName, EventDispatcherInterface $dispatcher) - { - $this->called = true; - - $e = $this->stopwatch->start($this->name, 'event_listener'); - - call_user_func($this->listener, $event, $eventName, $this->dispatcher ?: $dispatcher); - - if ($e->isStarted()) { - $e->stop(); - } - - if ($event->isPropagationStopped()) { - $this->stoppedPropagation = true; - } - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php deleted file mode 100644 index 7e74a37aa..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php +++ /dev/null @@ -1,110 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; - -/** - * Compiler pass to register tagged services for an event dispatcher. - */ -class RegisterListenersPass implements CompilerPassInterface -{ - /** - * @var string - */ - protected $dispatcherService; - - /** - * @var string - */ - protected $listenerTag; - - /** - * @var string - */ - protected $subscriberTag; - - /** - * Constructor. - * - * @param string $dispatcherService Service name of the event dispatcher in processed container - * @param string $listenerTag Tag name used for listener - * @param string $subscriberTag Tag name used for subscribers - */ - public function __construct($dispatcherService = 'event_dispatcher', $listenerTag = 'kernel.event_listener', $subscriberTag = 'kernel.event_subscriber') - { - $this->dispatcherService = $dispatcherService; - $this->listenerTag = $listenerTag; - $this->subscriberTag = $subscriberTag; - } - - public function process(ContainerBuilder $container) - { - if (!$container->hasDefinition($this->dispatcherService) && !$container->hasAlias($this->dispatcherService)) { - return; - } - - $definition = $container->findDefinition($this->dispatcherService); - - foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) { - $def = $container->getDefinition($id); - if (!$def->isPublic()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event listeners are lazy-loaded.', $id)); - } - - if ($def->isAbstract()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event listeners are lazy-loaded.', $id)); - } - - foreach ($events as $event) { - $priority = isset($event['priority']) ? $event['priority'] : 0; - - if (!isset($event['event'])) { - throw new \InvalidArgumentException(sprintf('Service "%s" must define the "event" attribute on "%s" tags.', $id, $this->listenerTag)); - } - - if (!isset($event['method'])) { - $event['method'] = 'on'.preg_replace_callback(array( - '/(?<=\b)[a-z]/i', - '/[^a-z0-9]/i', - ), function ($matches) { return strtoupper($matches[0]); }, $event['event']); - $event['method'] = preg_replace('/[^a-z0-9]/i', '', $event['method']); - } - - $definition->addMethodCall('addListenerService', array($event['event'], array($id, $event['method']), $priority)); - } - } - - foreach ($container->findTaggedServiceIds($this->subscriberTag) as $id => $attributes) { - $def = $container->getDefinition($id); - if (!$def->isPublic()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must be public as event subscribers are lazy-loaded.', $id)); - } - - if ($def->isAbstract()) { - throw new \InvalidArgumentException(sprintf('The service "%s" must not be abstract as event subscribers are lazy-loaded.', $id)); - } - - // We must assume that the class value has been correctly filled, even if the service is created by a factory - $class = $container->getParameterBag()->resolveValue($def->getClass()); - - $refClass = new \ReflectionClass($class); - $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; - if (!$refClass->implementsInterface($interface)) { - throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); - } - - $definition->addMethodCall('addSubscriberService', array($id, $class)); - } - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php deleted file mode 100644 index dc39b05d5..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Event.php +++ /dev/null @@ -1,130 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * Event is the base class for classes containing event data. - * - * This class contains no event data. It is used by events that do not pass - * state information to an event handler when an event is raised. - * - * You can call the method stopPropagation() to abort the execution of - * further listeners in your event listener. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * - * @api - */ -class Event -{ - /** - * @var bool Whether no further event listeners should be triggered - */ - private $propagationStopped = false; - - /** - * @var EventDispatcher Dispatcher that dispatched this event - */ - private $dispatcher; - - /** - * @var string This event's name - */ - private $name; - - /** - * Returns whether further event listeners should be triggered. - * - * @see Event::stopPropagation() - * - * @return bool Whether propagation was already stopped for this event. - * - * @api - */ - public function isPropagationStopped() - { - return $this->propagationStopped; - } - - /** - * Stops the propagation of the event to further event listeners. - * - * If multiple event listeners are connected to the same event, no - * further event listener will be triggered once any trigger calls - * stopPropagation(). - * - * @api - */ - public function stopPropagation() - { - $this->propagationStopped = true; - } - - /** - * Stores the EventDispatcher that dispatches this Event. - * - * @param EventDispatcherInterface $dispatcher - * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. - * - * @api - */ - public function setDispatcher(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - /** - * Returns the EventDispatcher that dispatches this Event. - * - * @return EventDispatcherInterface - * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event dispatcher is passed to the listener call. - * - * @api - */ - public function getDispatcher() - { - return $this->dispatcher; - } - - /** - * Gets the event's name. - * - * @return string - * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. - * - * @api - */ - public function getName() - { - return $this->name; - } - - /** - * Sets the event's name property. - * - * @param string $name The event name. - * - * @deprecated Deprecated in 2.4, to be removed in 3.0. The event name is passed to the listener call. - * - * @api - */ - public function setName($name) - { - $this->name = $name; - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php deleted file mode 100644 index 3b032fb08..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcher.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * @author Fabien Potencier - * @author Jordi Boggiano - * @author Jordan Alliot - * - * @api - */ -class EventDispatcher implements EventDispatcherInterface -{ - private $listeners = array(); - private $sorted = array(); - - /** - * @see EventDispatcherInterface::dispatch() - * - * @api - */ - public function dispatch($eventName, Event $event = null) - { - if (null === $event) { - $event = new Event(); - } - - $event->setDispatcher($this); - $event->setName($eventName); - - if (!isset($this->listeners[$eventName])) { - return $event; - } - - $this->doDispatch($this->getListeners($eventName), $eventName, $event); - - return $event; - } - - /** - * @see EventDispatcherInterface::getListeners() - */ - public function getListeners($eventName = null) - { - if (null !== $eventName) { - if (!isset($this->sorted[$eventName])) { - $this->sortListeners($eventName); - } - - return $this->sorted[$eventName]; - } - - foreach (array_keys($this->listeners) as $eventName) { - if (!isset($this->sorted[$eventName])) { - $this->sortListeners($eventName); - } - } - - return array_filter($this->sorted); - } - - /** - * @see EventDispatcherInterface::hasListeners() - */ - public function hasListeners($eventName = null) - { - return (bool) count($this->getListeners($eventName)); - } - - /** - * @see EventDispatcherInterface::addListener() - * - * @api - */ - public function addListener($eventName, $listener, $priority = 0) - { - $this->listeners[$eventName][$priority][] = $listener; - unset($this->sorted[$eventName]); - } - - /** - * @see EventDispatcherInterface::removeListener() - */ - public function removeListener($eventName, $listener) - { - if (!isset($this->listeners[$eventName])) { - return; - } - - foreach ($this->listeners[$eventName] as $priority => $listeners) { - if (false !== ($key = array_search($listener, $listeners, true))) { - unset($this->listeners[$eventName][$priority][$key], $this->sorted[$eventName]); - } - } - } - - /** - * @see EventDispatcherInterface::addSubscriber() - * - * @api - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { - if (is_string($params)) { - $this->addListener($eventName, array($subscriber, $params)); - } elseif (is_string($params[0])) { - $this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0); - } else { - foreach ($params as $listener) { - $this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0); - } - } - } - } - - /** - * @see EventDispatcherInterface::removeSubscriber() - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - foreach ($subscriber->getSubscribedEvents() as $eventName => $params) { - if (is_array($params) && is_array($params[0])) { - foreach ($params as $listener) { - $this->removeListener($eventName, array($subscriber, $listener[0])); - } - } else { - $this->removeListener($eventName, array($subscriber, is_string($params) ? $params : $params[0])); - } - } - } - - /** - * Triggers the listeners of an event. - * - * This method can be overridden to add functionality that is executed - * for each listener. - * - * @param callable[] $listeners The event listeners. - * @param string $eventName The name of the event to dispatch. - * @param Event $event The event object to pass to the event handlers/listeners. - */ - protected function doDispatch($listeners, $eventName, Event $event) - { - foreach ($listeners as $listener) { - call_user_func($listener, $event, $eventName, $this); - if ($event->isPropagationStopped()) { - break; - } - } - } - - /** - * Sorts the internal list of listeners for the given event by priority. - * - * @param string $eventName The name of the event. - */ - private function sortListeners($eventName) - { - $this->sorted[$eventName] = array(); - - if (isset($this->listeners[$eventName])) { - krsort($this->listeners[$eventName]); - $this->sorted[$eventName] = call_user_func_array('array_merge', $this->listeners[$eventName]); - } - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php deleted file mode 100644 index efb7c5bec..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventDispatcherInterface.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * The EventDispatcherInterface is the central point of Symfony's event listener system. - * Listeners are registered on the manager and events are dispatched through the - * manager. - * - * @author Bernhard Schussek - * - * @api - */ -interface EventDispatcherInterface -{ - /** - * Dispatches an event to all registered listeners. - * - * @param string $eventName The name of the event to dispatch. The name of - * the event is the name of the method that is - * invoked on listeners. - * @param Event $event The event to pass to the event handlers/listeners. - * If not supplied, an empty Event instance is created. - * - * @return Event - * - * @api - */ - public function dispatch($eventName, Event $event = null); - - /** - * Adds an event listener that listens on the specified events. - * - * @param string $eventName The event to listen on - * @param callable $listener The listener - * @param int $priority The higher this value, the earlier an event - * listener will be triggered in the chain (defaults to 0) - * - * @api - */ - public function addListener($eventName, $listener, $priority = 0); - - /** - * Adds an event subscriber. - * - * The subscriber is asked for all the events he is - * interested in and added as a listener for these events. - * - * @param EventSubscriberInterface $subscriber The subscriber. - * - * @api - */ - public function addSubscriber(EventSubscriberInterface $subscriber); - - /** - * Removes an event listener from the specified events. - * - * @param string $eventName The event to remove a listener from - * @param callable $listener The listener to remove - */ - public function removeListener($eventName, $listener); - - /** - * Removes an event subscriber. - * - * @param EventSubscriberInterface $subscriber The subscriber - */ - public function removeSubscriber(EventSubscriberInterface $subscriber); - - /** - * Gets the listeners of a specific event or all listeners. - * - * @param string $eventName The name of the event - * - * @return array The event listeners for the specified event, or all event listeners by event name - */ - public function getListeners($eventName = null); - - /** - * Checks whether an event has any registered listeners. - * - * @param string $eventName The name of the event - * - * @return bool true if the specified event has any listeners, false otherwise - */ - public function hasListeners($eventName = null); -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php deleted file mode 100644 index ff7e305cd..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/EventSubscriberInterface.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * An EventSubscriber knows himself what events he is interested in. - * If an EventSubscriber is added to an EventDispatcherInterface, the manager invokes - * {@link getSubscribedEvents} and registers the subscriber as a listener for all - * returned events. - * - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author Bernhard Schussek - * - * @api - */ -interface EventSubscriberInterface -{ - /** - * Returns an array of event names this subscriber wants to listen to. - * - * The array keys are event names and the value can be: - * - * * The method name to call (priority defaults to 0) - * * An array composed of the method name to call and the priority - * * An array of arrays composed of the method names to call and respective - * priorities, or 0 if unset - * - * For instance: - * - * * array('eventName' => 'methodName') - * * array('eventName' => array('methodName', $priority)) - * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) - * - * @return array The event names to listen to - * - * @api - */ - public static function getSubscribedEvents(); -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php deleted file mode 100644 index a8955ca42..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/GenericEvent.php +++ /dev/null @@ -1,186 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * Event encapsulation class. - * - * Encapsulates events thus decoupling the observer from the subject they encapsulate. - * - * @author Drak - */ -class GenericEvent extends Event implements \ArrayAccess, \IteratorAggregate -{ - /** - * Event subject. - * - * @var mixed usually object or callable - */ - protected $subject; - - /** - * Array of arguments. - * - * @var array - */ - protected $arguments; - - /** - * Encapsulate an event with $subject and $args. - * - * @param mixed $subject The subject of the event, usually an object. - * @param array $arguments Arguments to store in the event. - */ - public function __construct($subject = null, array $arguments = array()) - { - $this->subject = $subject; - $this->arguments = $arguments; - } - - /** - * Getter for subject property. - * - * @return mixed $subject The observer subject. - */ - public function getSubject() - { - return $this->subject; - } - - /** - * Get argument by key. - * - * @param string $key Key. - * - * @throws \InvalidArgumentException If key is not found. - * - * @return mixed Contents of array key. - */ - public function getArgument($key) - { - if ($this->hasArgument($key)) { - return $this->arguments[$key]; - } - - throw new \InvalidArgumentException(sprintf('%s not found in %s', $key, $this->getName())); - } - - /** - * Add argument to event. - * - * @param string $key Argument name. - * @param mixed $value Value. - * - * @return GenericEvent - */ - public function setArgument($key, $value) - { - $this->arguments[$key] = $value; - - return $this; - } - - /** - * Getter for all arguments. - * - * @return array - */ - public function getArguments() - { - return $this->arguments; - } - - /** - * Set args property. - * - * @param array $args Arguments. - * - * @return GenericEvent - */ - public function setArguments(array $args = array()) - { - $this->arguments = $args; - - return $this; - } - - /** - * Has argument. - * - * @param string $key Key of arguments array. - * - * @return bool - */ - public function hasArgument($key) - { - return array_key_exists($key, $this->arguments); - } - - /** - * ArrayAccess for argument getter. - * - * @param string $key Array key. - * - * @throws \InvalidArgumentException If key does not exist in $this->args. - * - * @return mixed - */ - public function offsetGet($key) - { - return $this->getArgument($key); - } - - /** - * ArrayAccess for argument setter. - * - * @param string $key Array key to set. - * @param mixed $value Value. - */ - public function offsetSet($key, $value) - { - $this->setArgument($key, $value); - } - - /** - * ArrayAccess for unset argument. - * - * @param string $key Array key. - */ - public function offsetUnset($key) - { - if ($this->hasArgument($key)) { - unset($this->arguments[$key]); - } - } - - /** - * ArrayAccess has argument. - * - * @param string $key Array key. - * - * @return bool - */ - public function offsetExists($key) - { - return $this->hasArgument($key); - } - - /** - * IteratorAggregate for iterating over the object like an array. - * - * @return \ArrayIterator - */ - public function getIterator() - { - return new \ArrayIterator($this->arguments); - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php deleted file mode 100644 index 7ef9ece75..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/ImmutableEventDispatcher.php +++ /dev/null @@ -1,93 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher; - -/** - * A read-only proxy for an event dispatcher. - * - * @author Bernhard Schussek - */ -class ImmutableEventDispatcher implements EventDispatcherInterface -{ - /** - * The proxied dispatcher. - * - * @var EventDispatcherInterface - */ - private $dispatcher; - - /** - * Creates an unmodifiable proxy for an event dispatcher. - * - * @param EventDispatcherInterface $dispatcher The proxied event dispatcher. - */ - public function __construct(EventDispatcherInterface $dispatcher) - { - $this->dispatcher = $dispatcher; - } - - /** - * {@inheritdoc} - */ - public function dispatch($eventName, Event $event = null) - { - return $this->dispatcher->dispatch($eventName, $event); - } - - /** - * {@inheritdoc} - */ - public function addListener($eventName, $listener, $priority = 0) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function addSubscriber(EventSubscriberInterface $subscriber) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function removeListener($eventName, $listener) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function removeSubscriber(EventSubscriberInterface $subscriber) - { - throw new \BadMethodCallException('Unmodifiable event dispatchers must not be modified.'); - } - - /** - * {@inheritdoc} - */ - public function getListeners($eventName = null) - { - return $this->dispatcher->getListeners($eventName); - } - - /** - * {@inheritdoc} - */ - public function hasListeners($eventName = null) - { - return $this->dispatcher->hasListeners($eventName); - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE deleted file mode 100644 index 43028bc60..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md deleted file mode 100644 index 8031f4dd3..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/README.md +++ /dev/null @@ -1,27 +0,0 @@ -EventDispatcher Component -========================= - -The Symfony EventDispatcher component implements the Mediator pattern in a -simple and effective way to make your projects truly extensible. - -```php -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; - -$dispatcher = new EventDispatcher(); - -$dispatcher->addListener('event_name', function (Event $event) { - // ... -}); - -$dispatcher->dispatch('event_name'); -``` - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/EventDispatcher/ - $ composer install - $ phpunit diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php deleted file mode 100644 index b9e419496..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/AbstractEventDispatcherTest.php +++ /dev/null @@ -1,369 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -abstract class AbstractEventDispatcherTest extends \PHPUnit_Framework_TestCase -{ - /* Some pseudo events */ - const preFoo = 'pre.foo'; - const postFoo = 'post.foo'; - const preBar = 'pre.bar'; - const postBar = 'post.bar'; - - /** - * @var EventDispatcher - */ - private $dispatcher; - - private $listener; - - protected function setUp() - { - $this->dispatcher = $this->createEventDispatcher(); - $this->listener = new TestEventListener(); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->listener = null; - } - - abstract protected function createEventDispatcher(); - - public function testInitialState() - { - $this->assertEquals(array(), $this->dispatcher->getListeners()); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - $this->assertFalse($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testAddListener() - { - $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo')); - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo')); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - $this->assertCount(1, $this->dispatcher->getListeners(self::preFoo)); - $this->assertCount(1, $this->dispatcher->getListeners(self::postFoo)); - $this->assertCount(2, $this->dispatcher->getListeners()); - } - - public function testGetListenersSortsByPriority() - { - $listener1 = new TestEventListener(); - $listener2 = new TestEventListener(); - $listener3 = new TestEventListener(); - $listener1->name = '1'; - $listener2->name = '2'; - $listener3->name = '3'; - - $this->dispatcher->addListener('pre.foo', array($listener1, 'preFoo'), -10); - $this->dispatcher->addListener('pre.foo', array($listener2, 'preFoo'), 10); - $this->dispatcher->addListener('pre.foo', array($listener3, 'preFoo')); - - $expected = array( - array($listener2, 'preFoo'), - array($listener3, 'preFoo'), - array($listener1, 'preFoo'), - ); - - $this->assertSame($expected, $this->dispatcher->getListeners('pre.foo')); - } - - public function testGetAllListenersSortsByPriority() - { - $listener1 = new TestEventListener(); - $listener2 = new TestEventListener(); - $listener3 = new TestEventListener(); - $listener4 = new TestEventListener(); - $listener5 = new TestEventListener(); - $listener6 = new TestEventListener(); - - $this->dispatcher->addListener('pre.foo', $listener1, -10); - $this->dispatcher->addListener('pre.foo', $listener2); - $this->dispatcher->addListener('pre.foo', $listener3, 10); - $this->dispatcher->addListener('post.foo', $listener4, -10); - $this->dispatcher->addListener('post.foo', $listener5); - $this->dispatcher->addListener('post.foo', $listener6, 10); - - $expected = array( - 'pre.foo' => array($listener3, $listener2, $listener1), - 'post.foo' => array($listener6, $listener5, $listener4), - ); - - $this->assertSame($expected, $this->dispatcher->getListeners()); - } - - public function testDispatch() - { - $this->dispatcher->addListener('pre.foo', array($this->listener, 'preFoo')); - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo')); - $this->dispatcher->dispatch(self::preFoo); - $this->assertTrue($this->listener->preFooInvoked); - $this->assertFalse($this->listener->postFooInvoked); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch('noevent')); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Event', $this->dispatcher->dispatch(self::preFoo)); - $event = new Event(); - $return = $this->dispatcher->dispatch(self::preFoo, $event); - $this->assertEquals('pre.foo', $event->getName()); - $this->assertSame($event, $return); - } - - public function testDispatchForClosure() - { - $invoked = 0; - $listener = function () use (&$invoked) { - $invoked++; - }; - $this->dispatcher->addListener('pre.foo', $listener); - $this->dispatcher->addListener('post.foo', $listener); - $this->dispatcher->dispatch(self::preFoo); - $this->assertEquals(1, $invoked); - } - - public function testStopEventPropagation() - { - $otherListener = new TestEventListener(); - - // postFoo() stops the propagation, so only one listener should - // be executed - // Manually set priority to enforce $this->listener to be called first - $this->dispatcher->addListener('post.foo', array($this->listener, 'postFoo'), 10); - $this->dispatcher->addListener('post.foo', array($otherListener, 'preFoo')); - $this->dispatcher->dispatch(self::postFoo); - $this->assertTrue($this->listener->postFooInvoked); - $this->assertFalse($otherListener->postFooInvoked); - } - - public function testDispatchByPriority() - { - $invoked = array(); - $listener1 = function () use (&$invoked) { - $invoked[] = '1'; - }; - $listener2 = function () use (&$invoked) { - $invoked[] = '2'; - }; - $listener3 = function () use (&$invoked) { - $invoked[] = '3'; - }; - $this->dispatcher->addListener('pre.foo', $listener1, -10); - $this->dispatcher->addListener('pre.foo', $listener2); - $this->dispatcher->addListener('pre.foo', $listener3, 10); - $this->dispatcher->dispatch(self::preFoo); - $this->assertEquals(array('3', '2', '1'), $invoked); - } - - public function testRemoveListener() - { - $this->dispatcher->addListener('pre.bar', $this->listener); - $this->assertTrue($this->dispatcher->hasListeners(self::preBar)); - $this->dispatcher->removeListener('pre.bar', $this->listener); - $this->assertFalse($this->dispatcher->hasListeners(self::preBar)); - $this->dispatcher->removeListener('notExists', $this->listener); - } - - public function testAddSubscriber() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testAddSubscriberWithPriorities() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $eventSubscriber = new TestEventSubscriberWithPriorities(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $listeners = $this->dispatcher->getListeners('pre.foo'); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $listeners); - $this->assertInstanceOf('Symfony\Component\EventDispatcher\Tests\TestEventSubscriberWithPriorities', $listeners[0][0]); - } - - public function testAddSubscriberWithMultipleListeners() - { - $eventSubscriber = new TestEventSubscriberWithMultipleListeners(); - $this->dispatcher->addSubscriber($eventSubscriber); - - $listeners = $this->dispatcher->getListeners('pre.foo'); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $listeners); - $this->assertEquals('preFoo2', $listeners[0][1]); - } - - public function testRemoveSubscriber() - { - $eventSubscriber = new TestEventSubscriber(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertTrue($this->dispatcher->hasListeners(self::postFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - $this->assertFalse($this->dispatcher->hasListeners(self::postFoo)); - } - - public function testRemoveSubscriberWithPriorities() - { - $eventSubscriber = new TestEventSubscriberWithPriorities(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - } - - public function testRemoveSubscriberWithMultipleListeners() - { - $eventSubscriber = new TestEventSubscriberWithMultipleListeners(); - $this->dispatcher->addSubscriber($eventSubscriber); - $this->assertTrue($this->dispatcher->hasListeners(self::preFoo)); - $this->assertCount(2, $this->dispatcher->getListeners(self::preFoo)); - $this->dispatcher->removeSubscriber($eventSubscriber); - $this->assertFalse($this->dispatcher->hasListeners(self::preFoo)); - } - - public function testEventReceivesTheDispatcherInstance() - { - $dispatcher = null; - $this->dispatcher->addListener('test', function ($event) use (&$dispatcher) { - $dispatcher = $event->getDispatcher(); - }); - $this->dispatcher->dispatch('test'); - $this->assertSame($this->dispatcher, $dispatcher); - } - - public function testEventReceivesTheDispatcherInstanceAsArgument() - { - $listener = new TestWithDispatcher(); - $this->dispatcher->addListener('test', array($listener, 'foo')); - $this->assertNull($listener->name); - $this->assertNull($listener->dispatcher); - $this->dispatcher->dispatch('test'); - $this->assertEquals('test', $listener->name); - $this->assertSame($this->dispatcher, $listener->dispatcher); - } - - /** - * @see https://bugs.php.net/bug.php?id=62976 - * - * This bug affects: - * - The PHP 5.3 branch for versions < 5.3.18 - * - The PHP 5.4 branch for versions < 5.4.8 - * - The PHP 5.5 branch is not affected - */ - public function testWorkaroundForPhpBug62976() - { - $dispatcher = $this->createEventDispatcher(); - $dispatcher->addListener('bug.62976', new CallableClass()); - $dispatcher->removeListener('bug.62976', function () {}); - $this->assertTrue($dispatcher->hasListeners('bug.62976')); - } - - public function testHasListenersWhenAddedCallbackListenerIsRemoved() - { - $listener = function () {}; - $this->dispatcher->addListener('foo', $listener); - $this->dispatcher->removeListener('foo', $listener); - $this->assertFalse($this->dispatcher->hasListeners()); - } - - public function testGetListenersWhenAddedCallbackListenerIsRemoved() - { - $listener = function () {}; - $this->dispatcher->addListener('foo', $listener); - $this->dispatcher->removeListener('foo', $listener); - $this->assertSame(array(), $this->dispatcher->getListeners()); - } - - public function testHasListenersWithoutEventsReturnsFalseAfterHasListenersWithEventHasBeenCalled() - { - $this->assertFalse($this->dispatcher->hasListeners('foo')); - $this->assertFalse($this->dispatcher->hasListeners()); - } -} - -class CallableClass -{ - public function __invoke() - { - } -} - -class TestEventListener -{ - public $preFooInvoked = false; - public $postFooInvoked = false; - - /* Listener methods */ - - public function preFoo(Event $e) - { - $this->preFooInvoked = true; - } - - public function postFoo(Event $e) - { - $this->postFooInvoked = true; - - $e->stopPropagation(); - } -} - -class TestWithDispatcher -{ - public $name; - public $dispatcher; - - public function foo(Event $e, $name, $dispatcher) - { - $this->name = $name; - $this->dispatcher = $dispatcher; - } -} - -class TestEventSubscriber implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('pre.foo' => 'preFoo', 'post.foo' => 'postFoo'); - } -} - -class TestEventSubscriberWithPriorities implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array( - 'pre.foo' => array('preFoo', 10), - 'post.foo' => array('postFoo'), - ); - } -} - -class TestEventSubscriberWithMultipleListeners implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('pre.foo' => array( - array('preFoo1'), - array('preFoo2', 10), - )); - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php deleted file mode 100644 index 6f2fbcb9d..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ContainerAwareEventDispatcherTest.php +++ /dev/null @@ -1,249 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\DependencyInjection\Container; -use Symfony\Component\DependencyInjection\Scope; -use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -class ContainerAwareEventDispatcherTest extends AbstractEventDispatcherTest -{ - protected function createEventDispatcher() - { - $container = new Container(); - - return new ContainerAwareEventDispatcher($container); - } - - public function testAddAListenerService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->dispatch('onEvent', $event); - } - - public function testAddASubscriberService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\SubscriberService'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.subscriber', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addSubscriberService('service.subscriber', 'Symfony\Component\EventDispatcher\Tests\SubscriberService'); - - $dispatcher->dispatch('onEvent', $event); - } - - public function testPreventDuplicateListenerService() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 5); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent'), 10); - - $dispatcher->dispatch('onEvent', $event); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testTriggerAListenerServiceOutOfScope() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $scope = new Scope('scope'); - $container = new Container(); - $container->addScope($scope); - $container->enterScope('scope'); - - $container->set('service.listener', $service, 'scope'); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $container->leaveScope('scope'); - $dispatcher->dispatch('onEvent'); - } - - public function testReEnteringAScope() - { - $event = new Event(); - - $service1 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service1 - ->expects($this->exactly(2)) - ->method('onEvent') - ->with($event) - ; - - $scope = new Scope('scope'); - $container = new Container(); - $container->addScope($scope); - $container->enterScope('scope'); - - $container->set('service.listener', $service1, 'scope'); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - $dispatcher->dispatch('onEvent', $event); - - $service2 = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $service2 - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $container->enterScope('scope'); - $container->set('service.listener', $service2, 'scope'); - - $dispatcher->dispatch('onEvent', $event); - - $container->leaveScope('scope'); - - $dispatcher->dispatch('onEvent'); - } - - public function testHasListenersOnLazyLoad() - { - $event = new Event(); - - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $event->setDispatcher($dispatcher); - $event->setName('onEvent'); - - $service - ->expects($this->once()) - ->method('onEvent') - ->with($event) - ; - - $this->assertTrue($dispatcher->hasListeners()); - - if ($dispatcher->hasListeners('onEvent')) { - $dispatcher->dispatch('onEvent'); - } - } - - public function testGetListenersOnLazyLoad() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $listeners = $dispatcher->getListeners(); - - $this->assertTrue(isset($listeners['onEvent'])); - - $this->assertCount(1, $dispatcher->getListeners('onEvent')); - } - - public function testRemoveAfterDispatch() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->dispatch('onEvent', new Event()); - $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent')); - $this->assertFalse($dispatcher->hasListeners('onEvent')); - } - - public function testRemoveBeforeDispatch() - { - $service = $this->getMock('Symfony\Component\EventDispatcher\Tests\Service'); - - $container = new Container(); - $container->set('service.listener', $service); - - $dispatcher = new ContainerAwareEventDispatcher($container); - $dispatcher->addListenerService('onEvent', array('service.listener', 'onEvent')); - - $dispatcher->removeListener('onEvent', array($container->get('service.listener'), 'onEvent')); - $this->assertFalse($dispatcher->hasListeners('onEvent')); - } -} - -class Service -{ - public function onEvent(Event $e) - { - } -} - -class SubscriberService implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array( - 'onEvent' => array('onEvent'), - ); - } - - public function onEvent(Event $e) - { - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php deleted file mode 100644 index 68b952365..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/Debug/TraceableEventDispatcherTest.php +++ /dev/null @@ -1,185 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests\Debug; - -use Symfony\Component\EventDispatcher\Debug\TraceableEventDispatcher; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\Stopwatch\Stopwatch; - -class TraceableEventDispatcherTest extends \PHPUnit_Framework_TestCase -{ - public function testAddRemoveListener() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $tdispatcher->addListener('foo', $listener = function () {; }); - $listeners = $dispatcher->getListeners('foo'); - $this->assertCount(1, $listeners); - $this->assertSame($listener, $listeners[0]); - - $tdispatcher->removeListener('foo', $listener); - $this->assertCount(0, $dispatcher->getListeners('foo')); - } - - public function testGetListeners() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $tdispatcher->addListener('foo', $listener = function () {; }); - $this->assertSame($dispatcher->getListeners('foo'), $tdispatcher->getListeners('foo')); - } - - public function testHasListeners() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $this->assertFalse($dispatcher->hasListeners('foo')); - $this->assertFalse($tdispatcher->hasListeners('foo')); - - $tdispatcher->addListener('foo', $listener = function () {; }); - $this->assertTrue($dispatcher->hasListeners('foo')); - $this->assertTrue($tdispatcher->hasListeners('foo')); - } - - public function testAddRemoveSubscriber() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - - $subscriber = new EventSubscriber(); - - $tdispatcher->addSubscriber($subscriber); - $listeners = $dispatcher->getListeners('foo'); - $this->assertCount(1, $listeners); - $this->assertSame(array($subscriber, 'call'), $listeners[0]); - - $tdispatcher->removeSubscriber($subscriber); - $this->assertCount(0, $dispatcher->getListeners('foo')); - } - - public function testGetCalledListeners() - { - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', $listener = function () {; }); - - $this->assertEquals(array(), $tdispatcher->getCalledListeners()); - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getNotCalledListeners()); - - $tdispatcher->dispatch('foo'); - - $this->assertEquals(array('foo.closure' => array('event' => 'foo', 'type' => 'Closure', 'pretty' => 'closure')), $tdispatcher->getCalledListeners()); - $this->assertEquals(array(), $tdispatcher->getNotCalledListeners()); - } - - public function testGetCalledListenersNested() - { - $tdispatcher = null; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('foo', function (Event $event, $eventName, $dispatcher) use (&$tdispatcher) { - $tdispatcher = $dispatcher; - $dispatcher->dispatch('bar'); - }); - $dispatcher->addListener('bar', function (Event $event) {}); - $dispatcher->dispatch('foo'); - $this->assertSame($dispatcher, $tdispatcher); - $this->assertCount(2, $dispatcher->getCalledListeners()); - } - - public function testLogger() - { - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); - $tdispatcher->addListener('foo', $listener1 = function () {; }); - $tdispatcher->addListener('foo', $listener2 = function () {; }); - - $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); - $logger->expects($this->at(1))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); - - $tdispatcher->dispatch('foo'); - } - - public function testLoggerWithStoppedEvent() - { - $logger = $this->getMock('Psr\Log\LoggerInterface'); - - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch(), $logger); - $tdispatcher->addListener('foo', $listener1 = function (Event $event) { $event->stopPropagation(); }); - $tdispatcher->addListener('foo', $listener2 = function () {; }); - - $logger->expects($this->at(0))->method('debug')->with("Notified event \"foo\" to listener \"closure\"."); - $logger->expects($this->at(1))->method('debug')->with("Listener \"closure\" stopped propagation of the event \"foo\"."); - $logger->expects($this->at(2))->method('debug')->with("Listener \"closure\" was not called for event \"foo\"."); - - $tdispatcher->dispatch('foo'); - } - - public function testDispatchCallListeners() - { - $called = array(); - - $dispatcher = new EventDispatcher(); - $tdispatcher = new TraceableEventDispatcher($dispatcher, new Stopwatch()); - $tdispatcher->addListener('foo', $listener1 = function () use (&$called) { $called[] = 'foo1'; }); - $tdispatcher->addListener('foo', $listener2 = function () use (&$called) { $called[] = 'foo2'; }); - - $tdispatcher->dispatch('foo'); - - $this->assertEquals(array('foo1', 'foo2'), $called); - } - - public function testDispatchNested() - { - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $loop = 1; - $dispatcher->addListener('foo', $listener1 = function () use ($dispatcher, &$loop) { - ++$loop; - if (2 == $loop) { - $dispatcher->dispatch('foo'); - } - }); - - $dispatcher->dispatch('foo'); - } - - public function testDispatchReusedEventNested() - { - $nestedCall = false; - $dispatcher = new TraceableEventDispatcher(new EventDispatcher(), new Stopwatch()); - $dispatcher->addListener('foo', function (Event $e) use ($dispatcher) { - $dispatcher->dispatch('bar', $e); - }); - $dispatcher->addListener('bar', function (Event $e) use (&$nestedCall) { - $nestedCall = true; - }); - - $this->assertFalse($nestedCall); - $dispatcher->dispatch('foo'); - $this->assertTrue($nestedCall); - } -} - -class EventSubscriber implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - return array('foo' => 'call'); - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php deleted file mode 100644 index 0fdd6372b..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php +++ /dev/null @@ -1,200 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests\DependencyInjection; - -use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\EventDispatcher\DependencyInjection\RegisterListenersPass; - -class RegisterListenersPassTest extends \PHPUnit_Framework_TestCase -{ - /** - * Tests that event subscribers not implementing EventSubscriberInterface - * trigger an exception. - * - * @expectedException \InvalidArgumentException - */ - public function testEventSubscriberWithoutInterface() - { - // one service, not implementing any interface - $services = array( - 'my_event_subscriber' => array(0 => array()), - ); - - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $definition->expects($this->atLeastOnce()) - ->method('isPublic') - ->will($this->returnValue(true)); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('stdClass')); - - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition') - ); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.event_listener here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->onConsecutiveCalls(array(), $services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->returnValue($definition)); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($builder); - } - - public function testValidEventSubscriber() - { - $services = array( - 'my_event_subscriber' => array(0 => array()), - ); - - $definition = $this->getMock('Symfony\Component\DependencyInjection\Definition'); - $definition->expects($this->atLeastOnce()) - ->method('isPublic') - ->will($this->returnValue(true)); - $definition->expects($this->atLeastOnce()) - ->method('getClass') - ->will($this->returnValue('Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService')); - - $builder = $this->getMock( - 'Symfony\Component\DependencyInjection\ContainerBuilder', - array('hasDefinition', 'findTaggedServiceIds', 'getDefinition', 'findDefinition') - ); - $builder->expects($this->any()) - ->method('hasDefinition') - ->will($this->returnValue(true)); - - // We don't test kernel.event_listener here - $builder->expects($this->atLeastOnce()) - ->method('findTaggedServiceIds') - ->will($this->onConsecutiveCalls(array(), $services)); - - $builder->expects($this->atLeastOnce()) - ->method('getDefinition') - ->will($this->returnValue($definition)); - - $builder->expects($this->atLeastOnce()) - ->method('findDefinition') - ->will($this->returnValue($definition)); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($builder); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" must be public as event listeners are lazy-loaded. - */ - public function testPrivateEventListener() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setPublic(false)->addTag('kernel.event_listener', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" must be public as event subscribers are lazy-loaded. - */ - public function testPrivateEventSubscriber() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setPublic(false)->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" must not be abstract as event listeners are lazy-loaded. - */ - public function testAbstractEventListener() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_listener', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage The service "foo" must not be abstract as event subscribers are lazy-loaded. - */ - public function testAbstractEventSubscriber() - { - $container = new ContainerBuilder(); - $container->register('foo', 'stdClass')->setAbstract(true)->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } - - public function testEventSubscriberResolvableClassName() - { - $container = new ContainerBuilder(); - - $container->setParameter('subscriber.class', 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService'); - $container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - - $definition = $container->getDefinition('event_dispatcher'); - $expected_calls = array( - array( - 'addSubscriberService', - array( - 'foo', - 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\SubscriberService', - ), - ), - ); - $this->assertSame($expected_calls, $definition->getMethodCalls()); - } - - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage You have requested a non-existent parameter "subscriber.class" - */ - public function testEventSubscriberUnresolvableClassName() - { - $container = new ContainerBuilder(); - $container->register('foo', '%subscriber.class%')->addTag('kernel.event_subscriber', array()); - $container->register('event_dispatcher', 'stdClass'); - - $registerListenersPass = new RegisterListenersPass(); - $registerListenersPass->process($container); - } -} - -class SubscriberService implements \Symfony\Component\EventDispatcher\EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php deleted file mode 100644 index 5faa5c8be..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventDispatcherTest.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\EventDispatcher; - -class EventDispatcherTest extends AbstractEventDispatcherTest -{ - protected function createEventDispatcher() - { - return new EventDispatcher(); - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php deleted file mode 100644 index 4bd269722..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/EventTest.php +++ /dev/null @@ -1,100 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\EventDispatcher; - -/** - * Test class for Event. - */ -class EventTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Symfony\Component\EventDispatcher\Event - */ - protected $event; - - /** - * @var \Symfony\Component\EventDispatcher\EventDispatcher - */ - protected $dispatcher; - - /** - * Sets up the fixture, for example, opens a network connection. - * This method is called before a test is executed. - */ - protected function setUp() - { - $this->event = new Event(); - $this->dispatcher = new EventDispatcher(); - } - - /** - * Tears down the fixture, for example, closes a network connection. - * This method is called after a test is executed. - */ - protected function tearDown() - { - $this->event = null; - $this->dispatcher = null; - } - - public function testIsPropagationStopped() - { - $this->assertFalse($this->event->isPropagationStopped()); - } - - public function testStopPropagationAndIsPropagationStopped() - { - $this->event->stopPropagation(); - $this->assertTrue($this->event->isPropagationStopped()); - } - - /** - * @group legacy - */ - public function testLegacySetDispatcher() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->event->setDispatcher($this->dispatcher); - $this->assertSame($this->dispatcher, $this->event->getDispatcher()); - } - - /** - * @group legacy - */ - public function testLegacyGetDispatcher() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->assertNull($this->event->getDispatcher()); - } - - /** - * @group legacy - */ - public function testLegacyGetName() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->assertNull($this->event->getName()); - } - - /** - * @group legacy - */ - public function testLegacySetName() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - $this->event->setName('foo'); - $this->assertEquals('foo', $this->event->getName()); - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php deleted file mode 100644 index aebd82dab..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\GenericEvent; - -/** - * Test class for Event. - */ -class GenericEventTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var GenericEvent - */ - private $event; - - private $subject; - - /** - * Prepares the environment before running a test. - */ - protected function setUp() - { - parent::setUp(); - - $this->subject = new \stdClass(); - $this->event = new GenericEvent($this->subject, array('name' => 'Event')); - } - - /** - * Cleans up the environment after running a test. - */ - protected function tearDown() - { - $this->subject = null; - $this->event = null; - - parent::tearDown(); - } - - public function testConstruct() - { - $this->assertEquals($this->event, new GenericEvent($this->subject, array('name' => 'Event'))); - } - - /** - * Tests Event->getArgs(). - */ - public function testGetArguments() - { - // test getting all - $this->assertSame(array('name' => 'Event'), $this->event->getArguments()); - } - - public function testSetArguments() - { - $result = $this->event->setArguments(array('foo' => 'bar')); - $this->assertAttributeSame(array('foo' => 'bar'), 'arguments', $this->event); - $this->assertSame($this->event, $result); - } - - public function testSetArgument() - { - $result = $this->event->setArgument('foo2', 'bar2'); - $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); - $this->assertEquals($this->event, $result); - } - - public function testGetArgument() - { - // test getting key - $this->assertEquals('Event', $this->event->getArgument('name')); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGetArgException() - { - $this->event->getArgument('nameNotExist'); - } - - public function testOffsetGet() - { - // test getting key - $this->assertEquals('Event', $this->event['name']); - - // test getting invalid arg - $this->setExpectedException('InvalidArgumentException'); - $this->assertFalse($this->event['nameNotExist']); - } - - public function testOffsetSet() - { - $this->event['foo2'] = 'bar2'; - $this->assertAttributeSame(array('name' => 'Event', 'foo2' => 'bar2'), 'arguments', $this->event); - } - - public function testOffsetUnset() - { - unset($this->event['name']); - $this->assertAttributeSame(array(), 'arguments', $this->event); - } - - public function testOffsetIsset() - { - $this->assertTrue(isset($this->event['name'])); - $this->assertFalse(isset($this->event['nameNotExist'])); - } - - public function testHasArgument() - { - $this->assertTrue($this->event->hasArgument('name')); - $this->assertFalse($this->event->hasArgument('nameNotExist')); - } - - public function testGetSubject() - { - $this->assertSame($this->subject, $this->event->getSubject()); - } - - public function testHasIterator() - { - $data = array(); - foreach ($this->event as $key => $value) { - $data[$key] = $value; - } - $this->assertEquals(array('name' => 'Event'), $data); - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php deleted file mode 100644 index 80a7e43be..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\EventDispatcher\Tests; - -use Symfony\Component\EventDispatcher\Event; -use Symfony\Component\EventDispatcher\ImmutableEventDispatcher; - -/** - * @author Bernhard Schussek - */ -class ImmutableEventDispatcherTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $innerDispatcher; - - /** - * @var ImmutableEventDispatcher - */ - private $dispatcher; - - protected function setUp() - { - $this->innerDispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->dispatcher = new ImmutableEventDispatcher($this->innerDispatcher); - } - - public function testDispatchDelegates() - { - $event = new Event(); - - $this->innerDispatcher->expects($this->once()) - ->method('dispatch') - ->with('event', $event) - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->dispatch('event', $event)); - } - - public function testGetListenersDelegates() - { - $this->innerDispatcher->expects($this->once()) - ->method('getListeners') - ->with('event') - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->getListeners('event')); - } - - public function testHasListenersDelegates() - { - $this->innerDispatcher->expects($this->once()) - ->method('hasListeners') - ->with('event') - ->will($this->returnValue('result')); - - $this->assertSame('result', $this->dispatcher->hasListeners('event')); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testAddListenerDisallowed() - { - $this->dispatcher->addListener('event', function () { return 'foo'; }); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testAddSubscriberDisallowed() - { - $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface'); - - $this->dispatcher->addSubscriber($subscriber); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testRemoveListenerDisallowed() - { - $this->dispatcher->removeListener('event', function () { return 'foo'; }); - } - - /** - * @expectedException \BadMethodCallException - */ - public function testRemoveSubscriberDisallowed() - { - $subscriber = $this->getMock('Symfony\Component\EventDispatcher\EventSubscriberInterface'); - - $this->dispatcher->removeSubscriber($subscriber); - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json deleted file mode 100644 index a516d4670..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/composer.json +++ /dev/null @@ -1,43 +0,0 @@ -{ - "name": "symfony/event-dispatcher", - "type": "library", - "description": "Symfony EventDispatcher Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7", - "symfony/dependency-injection": "~2.6", - "symfony/expression-language": "~2.6", - "symfony/config": "~2.0,>=2.0.5", - "symfony/stopwatch": "~2.3", - "psr/log": "~1.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "autoload": { - "psr-0": { "Symfony\\Component\\EventDispatcher\\": "" } - }, - "target-dir": "Symfony/Component/EventDispatcher", - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - } -} diff --git a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist b/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist deleted file mode 100644 index b14fde575..000000000 --- a/vendor/symfony/event-dispatcher/Symfony/Component/EventDispatcher/phpunit.xml.dist +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Resources - ./Tests - ./vendor - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/.gitignore b/vendor/symfony/form/Symfony/Component/Form/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/vendor/symfony/form/Symfony/Component/Form/AbstractExtension.php b/vendor/symfony/form/Symfony/Component/Form/AbstractExtension.php deleted file mode 100644 index a2eef508f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/AbstractExtension.php +++ /dev/null @@ -1,198 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -/** - * @author Bernhard Schussek - */ -abstract class AbstractExtension implements FormExtensionInterface -{ - /** - * The types provided by this extension. - * - * @var FormTypeInterface[] An array of FormTypeInterface - */ - private $types; - - /** - * The type extensions provided by this extension. - * - * @var FormTypeExtensionInterface[] An array of FormTypeExtensionInterface - */ - private $typeExtensions; - - /** - * The type guesser provided by this extension. - * - * @var FormTypeGuesserInterface - */ - private $typeGuesser; - - /** - * Whether the type guesser has been loaded. - * - * @var bool - */ - private $typeGuesserLoaded = false; - - /** - * {@inheritdoc} - */ - public function getType($name) - { - if (null === $this->types) { - $this->initTypes(); - } - - if (!isset($this->types[$name])) { - throw new InvalidArgumentException(sprintf('The type "%s" can not be loaded by this extension', $name)); - } - - return $this->types[$name]; - } - - /** - * {@inheritdoc} - */ - public function hasType($name) - { - if (null === $this->types) { - $this->initTypes(); - } - - return isset($this->types[$name]); - } - - /** - * {@inheritdoc} - */ - public function getTypeExtensions($name) - { - if (null === $this->typeExtensions) { - $this->initTypeExtensions(); - } - - return isset($this->typeExtensions[$name]) - ? $this->typeExtensions[$name] - : array(); - } - - /** - * {@inheritdoc} - */ - public function hasTypeExtensions($name) - { - if (null === $this->typeExtensions) { - $this->initTypeExtensions(); - } - - return isset($this->typeExtensions[$name]) && count($this->typeExtensions[$name]) > 0; - } - - /** - * {@inheritdoc} - */ - public function getTypeGuesser() - { - if (!$this->typeGuesserLoaded) { - $this->initTypeGuesser(); - } - - return $this->typeGuesser; - } - - /** - * Registers the types. - * - * @return FormTypeInterface[] An array of FormTypeInterface instances - */ - protected function loadTypes() - { - return array(); - } - - /** - * Registers the type extensions. - * - * @return FormTypeExtensionInterface[] An array of FormTypeExtensionInterface instances - */ - protected function loadTypeExtensions() - { - return array(); - } - - /** - * Registers the type guesser. - * - * @return FormTypeGuesserInterface|null A type guesser - */ - protected function loadTypeGuesser() - { - } - - /** - * Initializes the types. - * - * @throws UnexpectedTypeException if any registered type is not an instance of FormTypeInterface - */ - private function initTypes() - { - $this->types = array(); - - foreach ($this->loadTypes() as $type) { - if (!$type instanceof FormTypeInterface) { - throw new UnexpectedTypeException($type, 'Symfony\Component\Form\FormTypeInterface'); - } - - $this->types[$type->getName()] = $type; - } - } - - /** - * Initializes the type extensions. - * - * @throws UnexpectedTypeException if any registered type extension is not - * an instance of FormTypeExtensionInterface - */ - private function initTypeExtensions() - { - $this->typeExtensions = array(); - - foreach ($this->loadTypeExtensions() as $extension) { - if (!$extension instanceof FormTypeExtensionInterface) { - throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormTypeExtensionInterface'); - } - - $type = $extension->getExtendedType(); - - $this->typeExtensions[$type][] = $extension; - } - } - - /** - * Initializes the type guesser. - * - * @throws UnexpectedTypeException if the type guesser is not an instance of FormTypeGuesserInterface - */ - private function initTypeGuesser() - { - $this->typeGuesserLoaded = true; - - $this->typeGuesser = $this->loadTypeGuesser(); - if (null !== $this->typeGuesser && !$this->typeGuesser instanceof FormTypeGuesserInterface) { - throw new UnexpectedTypeException($this->typeGuesser, 'Symfony\Component\Form\FormTypeGuesserInterface'); - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/AbstractRendererEngine.php b/vendor/symfony/form/Symfony/Component/Form/AbstractRendererEngine.php deleted file mode 100644 index 8202cbf97..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/AbstractRendererEngine.php +++ /dev/null @@ -1,205 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * Default implementation of {@link FormRendererEngineInterface}. - * - * @author Bernhard Schussek - */ -abstract class AbstractRendererEngine implements FormRendererEngineInterface -{ - /** - * The variable in {@link FormView} used as cache key. - */ - const CACHE_KEY_VAR = 'cache_key'; - - /** - * @var array - */ - protected $defaultThemes; - - /** - * @var array - */ - protected $themes = array(); - - /** - * @var array - */ - protected $resources = array(); - - /** - * @var array - */ - private $resourceHierarchyLevels = array(); - - /** - * Creates a new renderer engine. - * - * @param array $defaultThemes The default themes. The type of these - * themes is open to the implementation. - */ - public function __construct(array $defaultThemes = array()) - { - $this->defaultThemes = $defaultThemes; - } - - /** - * {@inheritdoc} - */ - public function setTheme(FormView $view, $themes) - { - $cacheKey = $view->vars[self::CACHE_KEY_VAR]; - - // Do not cast, as casting turns objects into arrays of properties - $this->themes[$cacheKey] = is_array($themes) ? $themes : array($themes); - - // Unset instead of resetting to an empty array, in order to allow - // implementations (like TwigRendererEngine) to check whether $cacheKey - // is set at all. - unset($this->resources[$cacheKey], $this->resourceHierarchyLevels[$cacheKey]); - } - - /** - * {@inheritdoc} - */ - public function getResourceForBlockName(FormView $view, $blockName) - { - $cacheKey = $view->vars[self::CACHE_KEY_VAR]; - - if (!isset($this->resources[$cacheKey][$blockName])) { - $this->loadResourceForBlockName($cacheKey, $view, $blockName); - } - - return $this->resources[$cacheKey][$blockName]; - } - - /** - * {@inheritdoc} - */ - public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, $hierarchyLevel) - { - $cacheKey = $view->vars[self::CACHE_KEY_VAR]; - $blockName = $blockNameHierarchy[$hierarchyLevel]; - - if (!isset($this->resources[$cacheKey][$blockName])) { - $this->loadResourceForBlockNameHierarchy($cacheKey, $view, $blockNameHierarchy, $hierarchyLevel); - } - - return $this->resources[$cacheKey][$blockName]; - } - - /** - * {@inheritdoc} - */ - public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, $hierarchyLevel) - { - $cacheKey = $view->vars[self::CACHE_KEY_VAR]; - $blockName = $blockNameHierarchy[$hierarchyLevel]; - - if (!isset($this->resources[$cacheKey][$blockName])) { - $this->loadResourceForBlockNameHierarchy($cacheKey, $view, $blockNameHierarchy, $hierarchyLevel); - } - - // If $block was previously rendered loaded with loadTemplateForBlock(), the template - // is cached but the hierarchy level is not. In this case, we know that the block - // exists at this very hierarchy level, so we can just set it. - if (!isset($this->resourceHierarchyLevels[$cacheKey][$blockName])) { - $this->resourceHierarchyLevels[$cacheKey][$blockName] = $hierarchyLevel; - } - - return $this->resourceHierarchyLevels[$cacheKey][$blockName]; - } - - /** - * Loads the cache with the resource for a given block name. - * - * @see getResourceForBlock() - * - * @param string $cacheKey The cache key of the form view. - * @param FormView $view The form view for finding the applying themes. - * @param string $blockName The name of the block to load. - * - * @return bool True if the resource could be loaded, false otherwise. - */ - abstract protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName); - - /** - * Loads the cache with the resource for a specific level of a block hierarchy. - * - * @see getResourceForBlockHierarchy() - * - * @param string $cacheKey The cache key used for storing the - * resource. - * @param FormView $view The form view for finding the applying - * themes. - * @param array $blockNameHierarchy The block hierarchy, with the most - * specific block name at the end. - * @param int $hierarchyLevel The level in the block hierarchy that - * should be loaded. - * - * @return bool True if the resource could be loaded, false otherwise. - */ - private function loadResourceForBlockNameHierarchy($cacheKey, FormView $view, array $blockNameHierarchy, $hierarchyLevel) - { - $blockName = $blockNameHierarchy[$hierarchyLevel]; - - // Try to find a template for that block - if ($this->loadResourceForBlockName($cacheKey, $view, $blockName)) { - // If loadTemplateForBlock() returns true, it was able to populate the - // cache. The only missing thing is to set the hierarchy level at which - // the template was found. - $this->resourceHierarchyLevels[$cacheKey][$blockName] = $hierarchyLevel; - - return true; - } - - if ($hierarchyLevel > 0) { - $parentLevel = $hierarchyLevel - 1; - $parentBlockName = $blockNameHierarchy[$parentLevel]; - - // The next two if statements contain slightly duplicated code. This is by intention - // and tries to avoid execution of unnecessary checks in order to increase performance. - - if (isset($this->resources[$cacheKey][$parentBlockName])) { - // It may happen that the parent block is already loaded, but its level is not. - // In this case, the parent block must have been loaded by loadResourceForBlock(), - // which does not check the hierarchy of the block. Subsequently the block must have - // been found directly on the parent level. - if (!isset($this->resourceHierarchyLevels[$cacheKey][$parentBlockName])) { - $this->resourceHierarchyLevels[$cacheKey][$parentBlockName] = $parentLevel; - } - - // Cache the shortcuts for further accesses - $this->resources[$cacheKey][$blockName] = $this->resources[$cacheKey][$parentBlockName]; - $this->resourceHierarchyLevels[$cacheKey][$blockName] = $this->resourceHierarchyLevels[$cacheKey][$parentBlockName]; - - return true; - } - - if ($this->loadResourceForBlockNameHierarchy($cacheKey, $view, $blockNameHierarchy, $parentLevel)) { - // Cache the shortcuts for further accesses - $this->resources[$cacheKey][$blockName] = $this->resources[$cacheKey][$parentBlockName]; - $this->resourceHierarchyLevels[$cacheKey][$blockName] = $this->resourceHierarchyLevels[$cacheKey][$parentBlockName]; - - return true; - } - } - - // Cache the result for further accesses - $this->resources[$cacheKey][$blockName] = false; - $this->resourceHierarchyLevels[$cacheKey][$blockName] = false; - - return false; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/AbstractType.php b/vendor/symfony/form/Symfony/Component/Form/AbstractType.php deleted file mode 100644 index 6f7f5da65..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/AbstractType.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * @author Bernhard Schussek - */ -abstract class AbstractType implements FormTypeInterface -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'form'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/AbstractTypeExtension.php b/vendor/symfony/form/Symfony/Component/Form/AbstractTypeExtension.php deleted file mode 100644 index 351c80097..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/AbstractTypeExtension.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * @author Bernhard Schussek - */ -abstract class AbstractTypeExtension implements FormTypeExtensionInterface -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Button.php b/vendor/symfony/form/Symfony/Component/Form/Button.php deleted file mode 100644 index 00f5611d9..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Button.php +++ /dev/null @@ -1,444 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\AlreadySubmittedException; -use Symfony\Component\Form\Exception\BadMethodCallException; - -/** - * A form button. - * - * @author Bernhard Schussek - */ -class Button implements \IteratorAggregate, FormInterface -{ - /** - * @var FormInterface|null - */ - private $parent; - - /** - * @var FormConfigInterface - */ - private $config; - - /** - * @var bool - */ - private $submitted = false; - - /** - * Creates a new button from a form configuration. - * - * @param FormConfigInterface $config The button's configuration. - */ - public function __construct(FormConfigInterface $config) - { - $this->config = $config; - } - - /** - * Unsupported method. - * - * @param mixed $offset - * - * @return bool Always returns false. - */ - public function offsetExists($offset) - { - return false; - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param mixed $offset - * - * @throws BadMethodCallException - */ - public function offsetGet($offset) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param mixed $offset - * @param mixed $value - * - * @throws BadMethodCallException - */ - public function offsetSet($offset, $value) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param mixed $offset - * - * @throws BadMethodCallException - */ - public function offsetUnset($offset) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * {@inheritdoc} - */ - public function setParent(FormInterface $parent = null) - { - $this->parent = $parent; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return $this->parent; - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param int|string|FormInterface $child - * @param null $type - * @param array $options - * - * @throws BadMethodCallException - */ - public function add($child, $type = null, array $options = array()) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param string $name - * - * @throws BadMethodCallException - */ - public function get($name) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * Unsupported method. - * - * @param string $name - * - * @return bool Always returns false. - */ - public function has($name) - { - return false; - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param string $name - * - * @throws BadMethodCallException - */ - public function remove($name) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * {@inheritdoc} - */ - public function all() - { - return array(); - } - - /** - * {@inheritdoc} - */ - public function getErrors($deep = false, $flatten = true) - { - return new FormErrorIterator($this, array()); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param mixed $modelData - */ - public function setData($modelData) - { - // called during initialization of the form tree - // noop - } - - /** - * Unsupported method. - */ - public function getData() - { - } - - /** - * Unsupported method. - */ - public function getNormData() - { - } - - /** - * Unsupported method. - */ - public function getViewData() - { - } - - /** - * Unsupported method. - * - * @return array Always returns an empty array. - */ - public function getExtraData() - { - return array(); - } - - /** - * Returns the button's configuration. - * - * @return FormConfigInterface The configuration. - */ - public function getConfig() - { - return $this->config; - } - - /** - * Returns whether the button is submitted. - * - * @return bool true if the button was submitted. - */ - public function isSubmitted() - { - return $this->submitted; - } - - /** - * Returns the name by which the button is identified in forms. - * - * @return string The name of the button. - */ - public function getName() - { - return $this->config->getName(); - } - - /** - * Unsupported method. - */ - public function getPropertyPath() - { - } - - /** - * Unsupported method. - * - * @param FormError $error - * - * @throws BadMethodCallException - */ - public function addError(FormError $error) - { - throw new BadMethodCallException('Buttons cannot have errors.'); - } - - /** - * Unsupported method. - * - * @return bool Always returns true. - */ - public function isValid() - { - return true; - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function isRequired() - { - return false; - } - - /** - * {@inheritdoc} - */ - public function isDisabled() - { - if (null === $this->parent || !$this->parent->isDisabled()) { - return $this->config->getDisabled(); - } - - return true; - } - - /** - * Unsupported method. - * - * @return bool Always returns true. - */ - public function isEmpty() - { - return true; - } - - /** - * Unsupported method. - * - * @return bool Always returns true. - */ - public function isSynchronized() - { - return true; - } - - /** - * Unsupported method. - * - * @return null Always returns null - */ - public function getTransformationFailure() - { - } - - /** - * Unsupported method. - * - * @throws BadMethodCallException - */ - public function initialize() - { - throw new BadMethodCallException('Buttons cannot be initialized. Call initialize() on the root form instead.'); - } - - /** - * Unsupported method. - * - * @param mixed $request - * - * @throws BadMethodCallException - */ - public function handleRequest($request = null) - { - throw new BadMethodCallException('Buttons cannot handle requests. Call handleRequest() on the root form instead.'); - } - - /** - * Submits data to the button. - * - * @param null|string $submittedData The data. - * @param bool $clearMissing Not used. - * - * @return Button The button instance - * - * @throws Exception\AlreadySubmittedException If the button has already been submitted. - */ - public function submit($submittedData, $clearMissing = true) - { - if ($this->submitted) { - throw new AlreadySubmittedException('A form can only be submitted once'); - } - - $this->submitted = true; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getRoot() - { - return $this->parent ? $this->parent->getRoot() : $this; - } - - /** - * {@inheritdoc} - */ - public function isRoot() - { - return null === $this->parent; - } - - /** - * {@inheritdoc} - */ - public function createView(FormView $parent = null) - { - if (null === $parent && $this->parent) { - $parent = $this->parent->createView(); - } - - $type = $this->config->getType(); - $options = $this->config->getOptions(); - - $view = $type->createView($this, $parent); - - $type->buildView($view, $this, $options); - $type->finishView($view, $this, $options); - - return $view; - } - - /** - * Unsupported method. - * - * @return int Always returns 0. - */ - public function count() - { - return 0; - } - - /** - * Unsupported method. - * - * @return \EmptyIterator Always returns an empty iterator. - */ - public function getIterator() - { - return new \EmptyIterator(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/ButtonBuilder.php b/vendor/symfony/form/Symfony/Component/Form/ButtonBuilder.php deleted file mode 100644 index 24bc2f891..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/ButtonBuilder.php +++ /dev/null @@ -1,848 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Exception\BadMethodCallException; - -/** - * A builder for {@link Button} instances. - * - * @author Bernhard Schussek - */ -class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface -{ - /** - * @var bool - */ - protected $locked = false; - - /** - * @var bool - */ - private $disabled; - - /** - * @var ResolvedFormTypeInterface - */ - private $type; - - /** - * @var string - */ - private $name; - - /** - * @var array - */ - private $attributes = array(); - - /** - * @var array - */ - private $options; - - /** - * Creates a new button builder. - * - * @param string $name The name of the button. - * @param array $options The button's options. - * - * @throws InvalidArgumentException If the name is empty. - */ - public function __construct($name, array $options = array()) - { - if (empty($name) && 0 != $name) { - throw new InvalidArgumentException('Buttons cannot have empty names.'); - } - - $this->name = (string) $name; - $this->options = $options; - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param string|int|FormBuilderInterface $child - * @param string|FormTypeInterface $type - * @param array $options - * - * @throws BadMethodCallException - */ - public function add($child, $type = null, array $options = array()) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param string $name - * @param string|FormTypeInterface $type - * @param array $options - * - * @throws BadMethodCallException - */ - public function create($name, $type = null, array $options = array()) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param string $name - * - * @throws BadMethodCallException - */ - public function get($name) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param string $name - * - * @throws BadMethodCallException - */ - public function remove($name) - { - throw new BadMethodCallException('Buttons cannot have children.'); - } - - /** - * Unsupported method. - * - * @param string $name - * - * @return bool Always returns false. - */ - public function has($name) - { - return false; - } - - /** - * Returns the children. - * - * @return array Always returns an empty array. - */ - public function all() - { - return array(); - } - - /** - * Creates the button. - * - * @return Button The button - */ - public function getForm() - { - return new Button($this->getFormConfig()); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param string $eventName - * @param callable $listener - * @param int $priority - * - * @throws BadMethodCallException - */ - public function addEventListener($eventName, $listener, $priority = 0) - { - throw new BadMethodCallException('Buttons do not support event listeners.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param EventSubscriberInterface $subscriber - * - * @throws BadMethodCallException - */ - public function addEventSubscriber(EventSubscriberInterface $subscriber) - { - throw new BadMethodCallException('Buttons do not support event subscribers.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param DataTransformerInterface $viewTransformer - * @param bool $forcePrepend - * - * @throws BadMethodCallException - */ - public function addViewTransformer(DataTransformerInterface $viewTransformer, $forcePrepend = false) - { - throw new BadMethodCallException('Buttons do not support data transformers.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @throws BadMethodCallException - */ - public function resetViewTransformers() - { - throw new BadMethodCallException('Buttons do not support data transformers.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param DataTransformerInterface $modelTransformer - * @param bool $forceAppend - * - * @throws BadMethodCallException - */ - public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false) - { - throw new BadMethodCallException('Buttons do not support data transformers.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @throws BadMethodCallException - */ - public function resetModelTransformers() - { - throw new BadMethodCallException('Buttons do not support data transformers.'); - } - - /** - * {@inheritdoc} - */ - public function setAttribute($name, $value) - { - $this->attributes[$name] = $value; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setAttributes(array $attributes) - { - $this->attributes = $attributes; - - return $this; - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param DataMapperInterface $dataMapper - * - * @throws BadMethodCallException - */ - public function setDataMapper(DataMapperInterface $dataMapper = null) - { - throw new BadMethodCallException('Buttons do not support data mappers.'); - } - - /** - * Set whether the button is disabled. - * - * @param bool $disabled Whether the button is disabled - * - * @return ButtonBuilder The button builder. - */ - public function setDisabled($disabled) - { - $this->disabled = $disabled; - - return $this; - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param mixed $emptyData - * - * @throws BadMethodCallException - */ - public function setEmptyData($emptyData) - { - throw new BadMethodCallException('Buttons do not support empty data.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param bool $errorBubbling - * - * @throws BadMethodCallException - */ - public function setErrorBubbling($errorBubbling) - { - throw new BadMethodCallException('Buttons do not support error bubbling.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param bool $required - * - * @throws BadMethodCallException - */ - public function setRequired($required) - { - throw new BadMethodCallException('Buttons cannot be required.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param null $propertyPath - * - * @throws BadMethodCallException - */ - public function setPropertyPath($propertyPath) - { - throw new BadMethodCallException('Buttons do not support property paths.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param bool $mapped - * - * @throws BadMethodCallException - */ - public function setMapped($mapped) - { - throw new BadMethodCallException('Buttons do not support data mapping.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param bool $byReference - * - * @throws BadMethodCallException - */ - public function setByReference($byReference) - { - throw new BadMethodCallException('Buttons do not support data mapping.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param bool $virtual - * - * @throws BadMethodCallException - * - * @deprecated since version 2.3, to be removed in 3.0. Use - * {@link setInheritData()} instead. - */ - public function setVirtual($virtual) - { - throw new BadMethodCallException('Buttons cannot be virtual.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param bool $compound - * - * @throws BadMethodCallException - */ - public function setCompound($compound) - { - throw new BadMethodCallException('Buttons cannot be compound.'); - } - - /** - * Sets the type of the button. - * - * @param ResolvedFormTypeInterface $type The type of the button. - * - * @return ButtonBuilder The button builder. - */ - public function setType(ResolvedFormTypeInterface $type) - { - $this->type = $type; - - return $this; - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param mixed $data - * - * @throws BadMethodCallException - */ - public function setData($data) - { - throw new BadMethodCallException('Buttons do not support data.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param bool $locked - * - * @throws BadMethodCallException - */ - public function setDataLocked($locked) - { - throw new BadMethodCallException('Buttons do not support data locking.'); - } - - /** - * Unsupported method. - * - * This method should not be invoked. - * - * @param FormFactoryInterface $formFactory - * - * @throws BadMethodCallException - */ - public function setFormFactory(FormFactoryInterface $formFactory) - { - throw new BadMethodCallException('Buttons do not support form factories.'); - } - - /** - * Unsupported method. - * - * @param string $action - * - * @throws BadMethodCallException - */ - public function setAction($action) - { - throw new BadMethodCallException('Buttons do not support actions.'); - } - - /** - * Unsupported method. - * - * @param string $method - * - * @throws BadMethodCallException - */ - public function setMethod($method) - { - throw new BadMethodCallException('Buttons do not support methods.'); - } - - /** - * Unsupported method. - * - * @param RequestHandlerInterface $requestHandler - * - * @throws BadMethodCallException - */ - public function setRequestHandler(RequestHandlerInterface $requestHandler) - { - throw new BadMethodCallException('Buttons do not support form processors.'); - } - - /** - * Unsupported method. - * - * @param bool $initialize - * - * @return ButtonBuilder - * - * @throws BadMethodCallException - */ - public function setAutoInitialize($initialize) - { - if (true === $initialize) { - throw new BadMethodCallException('Buttons do not support automatic initialization.'); - } - - return $this; - } - - /** - * Unsupported method. - * - * @param bool $inheritData - * - * @throws BadMethodCallException - */ - public function setInheritData($inheritData) - { - throw new BadMethodCallException('Buttons do not support data inheritance.'); - } - - /** - * Builds and returns the button configuration. - * - * @return FormConfigInterface - */ - public function getFormConfig() - { - // This method should be idempotent, so clone the builder - $config = clone $this; - $config->locked = true; - - return $config; - } - - /** - * Unsupported method. - */ - public function getEventDispatcher() - { - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * Unsupported method. - */ - public function getPropertyPath() - { - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function getMapped() - { - return false; - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function getByReference() - { - return false; - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - * - * @deprecated since version 2.3, to be removed in 3.0. Use - * {@link getInheritData()} instead. - */ - public function getVirtual() - { - return false; - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function getCompound() - { - return false; - } - - /** - * Returns the form type used to construct the button. - * - * @return ResolvedFormTypeInterface The button's type. - */ - public function getType() - { - return $this->type; - } - - /** - * Unsupported method. - * - * @return array Always returns an empty array. - */ - public function getViewTransformers() - { - return array(); - } - - /** - * Unsupported method. - * - * @return array Always returns an empty array. - */ - public function getModelTransformers() - { - return array(); - } - - /** - * Unsupported method. - */ - public function getDataMapper() - { - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function getRequired() - { - return false; - } - - /** - * Returns whether the button is disabled. - * - * @return bool Whether the button is disabled. - */ - public function getDisabled() - { - return $this->disabled; - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function getErrorBubbling() - { - return false; - } - - /** - * Unsupported method. - */ - public function getEmptyData() - { - } - - /** - * Returns additional attributes of the button. - * - * @return array An array of key-value combinations. - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * Returns whether the attribute with the given name exists. - * - * @param string $name The attribute name. - * - * @return bool Whether the attribute exists. - */ - public function hasAttribute($name) - { - return array_key_exists($name, $this->attributes); - } - - /** - * Returns the value of the given attribute. - * - * @param string $name The attribute name. - * @param mixed $default The value returned if the attribute does not exist. - * - * @return mixed The attribute value. - */ - public function getAttribute($name, $default = null) - { - return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default; - } - - /** - * Unsupported method. - */ - public function getData() - { - } - - /** - * Unsupported method. - */ - public function getDataClass() - { - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function getDataLocked() - { - return false; - } - - /** - * Unsupported method. - */ - public function getFormFactory() - { - } - - /** - * Unsupported method. - */ - public function getAction() - { - } - - /** - * Unsupported method. - */ - public function getMethod() - { - } - - /** - * Unsupported method. - */ - public function getRequestHandler() - { - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function getAutoInitialize() - { - return false; - } - - /** - * Unsupported method. - * - * @return bool Always returns false. - */ - public function getInheritData() - { - return false; - } - - /** - * Returns all options passed during the construction of the button. - * - * @return array The passed options. - */ - public function getOptions() - { - return $this->options; - } - - /** - * Returns whether a specific option exists. - * - * @param string $name The option name, - * - * @return bool Whether the option exists. - */ - public function hasOption($name) - { - return array_key_exists($name, $this->options); - } - - /** - * Returns the value of a specific option. - * - * @param string $name The option name. - * @param mixed $default The value returned if the option does not exist. - * - * @return mixed The option value. - */ - public function getOption($name, $default = null) - { - return array_key_exists($name, $this->options) ? $this->options[$name] : $default; - } - - /** - * Unsupported method. - * - * @return int Always returns 0. - */ - public function count() - { - return 0; - } - - /** - * Unsupported method. - * - * @return \EmptyIterator Always returns an empty iterator. - */ - public function getIterator() - { - return new \EmptyIterator(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/ButtonTypeInterface.php b/vendor/symfony/form/Symfony/Component/Form/ButtonTypeInterface.php deleted file mode 100644 index dd5117c4d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/ButtonTypeInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * A type that should be converted into a {@link Button} instance. - * - * @author Bernhard Schussek - */ -interface ButtonTypeInterface extends FormTypeInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/CHANGELOG.md b/vendor/symfony/form/Symfony/Component/Form/CHANGELOG.md deleted file mode 100644 index 1060f57cd..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/CHANGELOG.md +++ /dev/null @@ -1,275 +0,0 @@ -CHANGELOG -========= - -2.6.2 ------ - - * Added back the `model_timezone` and `view_timezone` options for `TimeType`, `DateType` - and `BirthdayType` - -2.6.0 ------ - - * added "html5" option to Date, Time and DateTimeFormType to be able to - enable/disable HTML5 input date when widget option is "single_text" - * added "label_format" option with possible placeholders "%name%" and "%id%" - * [BC BREAK] drop support for model_timezone and view_timezone options in TimeType, DateType and BirthdayType, - update to 2.6.2 to get back support for these options - -2.5.0 ------- - - * deprecated options "max_length" and "pattern" in favor of putting these values in "attr" option - * added an option for multiple files upload - * form errors now reference their cause (constraint violation, exception, ...) - * form errors now remember which form they were originally added to - * [BC BREAK] added two optional parameters to FormInterface::getErrors() and - changed the method to return a Symfony\Component\Form\FormErrorIterator - instance instead of an array - * errors mapped to unsubmitted forms are discarded now - * ObjectChoiceList now compares choices by their value, if a value path is - given - * you can now pass interface names in the "data_class" option - * [BC BREAK] added `FormInterface::getTransformationFailure()` - -2.4.0 ------ - - * moved CSRF implementation to the new Security CSRF sub-component - * deprecated CsrfProviderInterface and its implementations - * deprecated options "csrf_provider" and "intention" in favor of the new options "csrf_token_generator" and "csrf_token_id" - -2.3.0 ------ - - * deprecated FormPerformanceTestCase and FormIntegrationTestCase in the Symfony\Component\Form\Tests namespace and moved them to the Symfony\Component\Form\Test namespace - * deprecated TypeTestCase in the Symfony\Component\Form\Tests\Extension\Core\Type namespace and moved it to the Symfony\Component\Form\Test namespace - * changed FormRenderer::humanize() to humanize also camel cased field name - * added RequestHandlerInterface and FormInterface::handleRequest() - * deprecated passing a Request instance to FormInterface::bind() - * added options "method" and "action" to FormType - * deprecated option "virtual" in favor "inherit_data" - * deprecated VirtualFormAwareIterator in favor of InheritDataAwareIterator - * [BC BREAK] removed the "array" type hint from DataMapperInterface - * improved forms inheriting their parent data to actually return that data from getData(), getNormData() and getViewData() - * added component-level exceptions for various SPL exceptions - changed all uses of the deprecated Exception class to use more specialized exceptions instead - removed NotInitializedException, NotValidException, TypeDefinitionException, TypeLoaderException, CreationException - * added events PRE_SUBMIT, SUBMIT and POST_SUBMIT - * deprecated events PRE_BIND, BIND and POST_BIND - * [BC BREAK] renamed bind() and isBound() in FormInterface to submit() and isSubmitted() - * added methods submit() and isSubmitted() to Form - * deprecated bind() and isBound() in Form - * deprecated AlreadyBoundException in favor of AlreadySubmittedException - * added support for PATCH requests - * [BC BREAK] added initialize() to FormInterface - * [BC BREAK] added getAutoInitialize() to FormConfigInterface - * [BC BREAK] added setAutoInitialize() to FormConfigBuilderInterface - * [BC BREAK] initialization for Form instances added to a form tree must be manually disabled - * PRE_SET_DATA is now guaranteed to be called after children were added by the form builder, - unless FormInterface::setData() is called manually - * fixed CSRF error message to be translated - * custom CSRF error messages can now be set through the "csrf_message" option - * fixed: expanded single-choice fields now show a radio button for the empty value - -2.2.0 ------ - - * TrimListener now removes unicode whitespaces - * deprecated getParent(), setParent() and hasParent() in FormBuilderInterface - * FormInterface::add() now accepts a FormInterface instance OR a field's name, type and options - * removed special characters between the choice or text fields of DateType unless - the option "format" is set to a custom value - * deprecated FormException and introduced ExceptionInterface instead - * [BC BREAK] FormException is now an interface - * protected FormBuilder methods from being called when it is turned into a FormConfigInterface with getFormConfig() - * [BC BREAK] inserted argument `$message` in the constructor of `FormError` - * the PropertyPath class and related classes were moved to a dedicated - PropertyAccess component. During the move, InvalidPropertyException was - renamed to NoSuchPropertyException. FormUtil was split: FormUtil::singularify() - can now be found in Symfony\Component\PropertyAccess\StringUtil. The methods - getValue() and setValue() from PropertyPath were extracted into a new class - PropertyAccessor. - * added an optional PropertyAccessorInterface parameter to FormType, - ObjectChoiceList and PropertyPathMapper - * [BC BREAK] PropertyPathMapper and FormType now have a constructor - * [BC BREAK] setting the option "validation_groups" to ``false`` now disables validation - instead of assuming group "Default" - -2.1.0 ------ - - * [BC BREAK] ``read_only`` field attribute now renders as ``readonly="readonly"``, use ``disabled`` instead - * [BC BREAK] child forms now aren't validated anymore by default - * made validation of form children configurable (new option: cascade_validation) - * added support for validation groups as callbacks - * made the translation catalogue configurable via the "translation_domain" option - * added Form::getErrorsAsString() to help debugging forms - * allowed setting different options for RepeatedType fields (like the label) - * added support for empty form name at root level, this enables rendering forms - without form name prefix in field names - * [BC BREAK] form and field names must start with a letter, digit or underscore - and only contain letters, digits, underscores, hyphens and colons - * [BC BREAK] changed default name of the prototype in the "collection" type - from "$$name$$" to "\__name\__". No dollars are appended/prepended to custom - names anymore. - * [BC BREAK] improved ChoiceListInterface - * [BC BREAK] added SimpleChoiceList and LazyChoiceList as replacement of - ArrayChoiceList - * added ChoiceList and ObjectChoiceList to use objects as choices - * [BC BREAK] removed EntitiesToArrayTransformer and EntityToIdTransformer. - The former has been replaced by CollectionToArrayTransformer in combination - with EntityChoiceList, the latter is not required in the core anymore. - * [BC BREAK] renamed - * ArrayToBooleanChoicesTransformer to ChoicesToBooleanArrayTransformer - * ScalarToBooleanChoicesTransformer to ChoiceToBooleanArrayTransformer - * ArrayToChoicesTransformer to ChoicesToValuesTransformer - * ScalarToChoiceTransformer to ChoiceToValueTransformer - to be consistent with the naming in ChoiceListInterface. - They were merged into ChoiceList and have no public equivalent anymore. - * choice fields now throw a FormException if neither the "choices" nor the - "choice_list" option is set - * the radio type is now a child of the checkbox type - * the collection, choice (with multiple selection) and entity (with multiple - selection) types now make use of addXxx() and removeXxx() methods in your - model if you set "by_reference" to false. For a custom, non-recognized - singular form, set the "property_path" option like this: "plural|singular" - * forms now don't create an empty object anymore if they are completely - empty and not required. The empty value for such forms is null. - * added constant Guess::VERY_HIGH_CONFIDENCE - * [BC BREAK] The methods `add`, `remove`, `setParent`, `bind` and `setData` - in class Form now throw an exception if the form is already bound - * fields of constrained classes without a NotBlank or NotNull constraint are - set to not required now, as stated in the docs - * fixed TimeType and DateTimeType to not display seconds when "widget" is - "single_text" unless "with_seconds" is set to true - * checkboxes of in an expanded multiple-choice field don't include the choice - in their name anymore. Their names terminate with "[]" now. - * deprecated FormValidatorInterface and substituted its implementations - by event subscribers - * simplified CSRF protection and removed the csrf type - * deprecated FieldType and merged it into FormType - * added new option "compound" that lets you switch between field and form behavior - * [BC BREAK] renamed theme blocks - * "field_*" to "form_*" - * "field_widget" to "form_widget_simple" - * "widget_choice_options" to "choice_widget_options" - * "generic_label" to "form_label" - * added theme blocks "form_widget_compound", "choice_widget_expanded" and - "choice_widget_collapsed" to make theming more modular - * ValidatorTypeGuesser now guesses "collection" for array type constraint - * added method `guessPattern` to FormTypeGuesserInterface to guess which pattern to use in the HTML5 attribute "pattern" - * deprecated method `guessMinLength` in favor of `guessPattern` - * labels don't display field attributes anymore. Label attributes can be - passed in the "label_attr" option/variable - * added option "mapped" which should be used instead of setting "property_path" to false - * [BC BREAK] "data_class" now *must* be set if a form maps to an object and should be left empty otherwise - * improved error mapping on forms - * dot (".") rules are now allowed to map errors assigned to a form to - one of its children - * errors are not mapped to unsynchronized forms anymore - * [BC BREAK] changed Form constructor to accept a single `FormConfigInterface` object - * [BC BREAK] changed argument order in the FormBuilder constructor - * added Form method `getViewData` - * deprecated Form methods - * `getTypes` - * `getErrorBubbling` - * `getNormTransformers` - * `getClientTransformers` - * `getAttribute` - * `hasAttribute` - * `getClientData` - * added FormBuilder methods - * `getTypes` - * `addViewTransformer` - * `getViewTransformers` - * `resetViewTransformers` - * `addModelTransformer` - * `getModelTransformers` - * `resetModelTransformers` - * deprecated FormBuilder methods - * `prependClientTransformer` - * `appendClientTransformer` - * `getClientTransformers` - * `resetClientTransformers` - * `prependNormTransformer` - * `appendNormTransformer` - * `getNormTransformers` - * `resetNormTransformers` - * deprecated the option "validation_constraint" in favor of the new - option "constraints" - * removed superfluous methods from DataMapperInterface - * `mapFormToData` - * `mapDataToForm` - * added `setDefaultOptions` to FormTypeInterface and FormTypeExtensionInterface - which accepts an OptionsResolverInterface instance - * deprecated the methods `getDefaultOptions` and `getAllowedOptionValues` - in FormTypeInterface and FormTypeExtensionInterface - * options passed during construction can now be accessed from FormConfigInterface - * added FormBuilderInterface and FormConfigEditorInterface - * [BC BREAK] the method `buildForm` in FormTypeInterface and FormTypeExtensionInterface - now receives a FormBuilderInterface instead of a FormBuilder instance - * [BC BREAK] the method `buildViewBottomUp` was renamed to `finishView` in - FormTypeInterface and FormTypeExtensionInterface - * [BC BREAK] the options array is now passed as last argument of the - methods - * `buildView` - * `finishView` - in FormTypeInterface and FormTypeExtensionInterface - * [BC BREAK] no options are passed to `getParent` of FormTypeInterface anymore - * deprecated DataEvent and FilterDataEvent in favor of the new FormEvent which is - now passed to all events thrown by the component - * FormEvents::BIND now replaces FormEvents::BIND_NORM_DATA - * FormEvents::PRE_SET_DATA now replaces FormEvents::SET_DATA - * FormEvents::PRE_BIND now replaces FormEvents::BIND_CLIENT_DATA - * deprecated FormEvents::SET_DATA, FormEvents::BIND_CLIENT_DATA and - FormEvents::BIND_NORM_DATA - * [BC BREAK] reversed the order of the first two arguments to `createNamed` - and `createNamedBuilder` in `FormFactoryInterface` - * deprecated `getChildren` in Form and FormBuilder in favor of `all` - * deprecated `hasChildren` in Form and FormBuilder in favor of `count` - * FormBuilder now implements \IteratorAggregate - * [BC BREAK] compound forms now always need a data mapper - * FormBuilder now maintains the order when explicitly adding form builders as children - * ChoiceType now doesn't add the empty value anymore if the choices already contain an empty element - * DateType, TimeType and DateTimeType now show empty values again if not required - * [BC BREAK] fixed rendering of errors for DateType, BirthdayType and similar ones - * [BC BREAK] fixed: form constraints are only validated if they belong to the validated group - * deprecated `bindRequest` in `Form` and replaced it by a listener to FormEvents::PRE_BIND - * fixed: the "data" option supersedes default values from the model - * changed DateType to refer to the "format" option for calculating the year and day choices instead - of padding them automatically - * [BC BREAK] DateType defaults to the format "yyyy-MM-dd" now if the widget is - "single_text", in order to support the HTML 5 date field out of the box - * added the option "format" to DateTimeType - * [BC BREAK] DateTimeType now outputs RFC 3339 dates by default, as generated and - consumed by HTML5 browsers, if the widget is "single_text" - * deprecated the options "data_timezone" and "user_timezone" in DateType, DateTimeType and TimeType - and renamed them to "model_timezone" and "view_timezone" - * fixed: TransformationFailedExceptions thrown in the model transformer are now caught by the form - * added FormRegistryInterface, ResolvedFormTypeInterface and ResolvedFormTypeFactoryInterface - * deprecated FormFactory methods - * `addType` - * `hasType` - * `getType` - * [BC BREAK] FormFactory now expects a FormRegistryInterface and a ResolvedFormTypeFactoryInterface as constructor argument - * [BC BREAK] The method `createBuilder` in FormTypeInterface is not supported anymore for performance reasons - * [BC BREAK] Removed `setTypes` from FormBuilder - * deprecated AbstractType methods - * `getExtensions` - * `setExtensions` - * ChoiceType now caches its created choice lists to improve performance - * [BC BREAK] Rows of a collection field cannot be themed individually anymore. All rows in the collection - field now have the same block names, which contains "entry" where it previously contained the row index. - * [BC BREAK] When registering a type through the DI extension, the tag alias has to match the actual type name. - * added FormRendererInterface, FormRendererEngineInterface and implementations of these interfaces - * [BC BREAK] removed the following methods from FormUtil: - * `toArrayKey` - * `toArrayKeys` - * `isChoiceGroup` - * `isChoiceSelected` - * [BC BREAK] renamed method `renderBlock` in FormHelper to `block` and changed its signature - * made FormView properties public and deprecated their accessor methods - * made the normalized data of a form accessible in the template through the variable "form.vars.data" - * made the original data of a choice accessible in the template through the property "choice.data" - * added convenience class Forms and FormFactoryBuilderInterface diff --git a/vendor/symfony/form/Symfony/Component/Form/CallbackTransformer.php b/vendor/symfony/form/Symfony/Component/Form/CallbackTransformer.php deleted file mode 100644 index 7857ad5f5..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/CallbackTransformer.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Exception\TransformationFailedException; - -class CallbackTransformer implements DataTransformerInterface -{ - /** - * The callback used for forward transform. - * - * @var callable - */ - private $transform; - - /** - * The callback used for reverse transform. - * - * @var callable - */ - private $reverseTransform; - - /** - * Constructor. - * - * @param callable $transform The forward transform callback - * @param callable $reverseTransform The reverse transform callback - * - * @throws \InvalidArgumentException when the given callbacks is invalid - */ - public function __construct($transform, $reverseTransform) - { - if (!is_callable($transform)) { - throw new \InvalidArgumentException('Argument 1 should be a callable'); - } - if (!is_callable($reverseTransform)) { - throw new \InvalidArgumentException('Argument 2 should be a callable'); - } - - $this->transform = $transform; - $this->reverseTransform = $reverseTransform; - } - - /** - * Transforms a value from the original representation to a transformed representation. - * - * @param mixed $data The value in the original representation - * - * @return mixed The value in the transformed representation - * - * @throws UnexpectedTypeException when the argument is not of the expected type - * @throws TransformationFailedException when the transformation fails - */ - public function transform($data) - { - return call_user_func($this->transform, $data); - } - - /** - * Transforms a value from the transformed representation to its original - * representation. - * - * @param mixed $data The value in the transformed representation - * - * @return mixed The value in the original representation - * - * @throws UnexpectedTypeException when the argument is not of the expected type - * @throws TransformationFailedException when the transformation fails - */ - public function reverseTransform($data) - { - return call_user_func($this->reverseTransform, $data); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/ClickableInterface.php b/vendor/symfony/form/Symfony/Component/Form/ClickableInterface.php deleted file mode 100644 index 6e45eff1a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/ClickableInterface.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * A clickable form element. - * - * @author Bernhard Schussek - */ -interface ClickableInterface -{ - /** - * Returns whether this element was clicked. - * - * @return bool Whether this element was clicked. - */ - public function isClicked(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/DataMapperInterface.php b/vendor/symfony/form/Symfony/Component/Form/DataMapperInterface.php deleted file mode 100644 index 6e0316829..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/DataMapperInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * @author Bernhard Schussek - */ -interface DataMapperInterface -{ - /** - * Maps properties of some data to a list of forms. - * - * @param mixed $data Structured data. - * @param FormInterface[] $forms A list of {@link FormInterface} instances. - * - * @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported. - */ - public function mapDataToForms($data, $forms); - - /** - * Maps the data of a list of forms into the properties of some data. - * - * @param FormInterface[] $forms A list of {@link FormInterface} instances. - * @param mixed $data Structured data. - * - * @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported. - */ - public function mapFormsToData($forms, &$data); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/DataTransformerInterface.php b/vendor/symfony/form/Symfony/Component/Form/DataTransformerInterface.php deleted file mode 100644 index 6567da259..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/DataTransformerInterface.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * Transforms a value between different representations. - * - * @author Bernhard Schussek - */ -interface DataTransformerInterface -{ - /** - * Transforms a value from the original representation to a transformed representation. - * - * This method is called on two occasions inside a form field: - * - * 1. When the form field is initialized with the data attached from the datasource (object or array). - * 2. When data from a request is submitted using {@link Form::submit()} to transform the new input data - * back into the renderable format. For example if you have a date field and submit '2009-10-10' - * you might accept this value because its easily parsed, but the transformer still writes back - * "2009/10/10" onto the form field (for further displaying or other purposes). - * - * This method must be able to deal with empty values. Usually this will - * be NULL, but depending on your implementation other empty values are - * possible as well (such as empty strings). The reasoning behind this is - * that value transformers must be chainable. If the transform() method - * of the first value transformer outputs NULL, the second value transformer - * must be able to process that value. - * - * By convention, transform() should return an empty string if NULL is - * passed. - * - * @param mixed $value The value in the original representation - * - * @return mixed The value in the transformed representation - * - * @throws TransformationFailedException When the transformation fails. - */ - public function transform($value); - - /** - * Transforms a value from the transformed representation to its original - * representation. - * - * This method is called when {@link Form::submit()} is called to transform the requests tainted data - * into an acceptable format for your data processing/model layer. - * - * This method must be able to deal with empty values. Usually this will - * be an empty string, but depending on your implementation other empty - * values are possible as well (such as empty strings). The reasoning behind - * this is that value transformers must be chainable. If the - * reverseTransform() method of the first value transformer outputs an - * empty string, the second value transformer must be able to process that - * value. - * - * By convention, reverseTransform() should return NULL if an empty string - * is passed. - * - * @param mixed $value The value in the transformed representation - * - * @return mixed The value in the original representation - * - * @throws TransformationFailedException When the transformation fails. - */ - public function reverseTransform($value); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/AlreadyBoundException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/AlreadyBoundException.php deleted file mode 100644 index 7ef0ca02e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/AlreadyBoundException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Alias of {@link AlreadySubmittedException}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link AlreadySubmittedException} instead. - */ -class AlreadyBoundException extends LogicException -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/AlreadySubmittedException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/AlreadySubmittedException.php deleted file mode 100644 index 7be212494..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/AlreadySubmittedException.php +++ /dev/null @@ -1,22 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Thrown when an operation is called that is not acceptable after submitting - * a form. - * - * @author Bernhard Schussek - */ -class AlreadySubmittedException extends AlreadyBoundException -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/BadMethodCallException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/BadMethodCallException.php deleted file mode 100644 index 27649dd02..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/BadMethodCallException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Base BadMethodCallException for the Form component. - * - * @author Bernhard Schussek - */ -class BadMethodCallException extends \BadMethodCallException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/ErrorMappingException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/ErrorMappingException.php deleted file mode 100644 index a69684926..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/ErrorMappingException.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -class ErrorMappingException extends RuntimeException -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/ExceptionInterface.php b/vendor/symfony/form/Symfony/Component/Form/Exception/ExceptionInterface.php deleted file mode 100644 index d455932ed..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/ExceptionInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Base ExceptionInterface for the Form component. - * - * @author Bernhard Schussek - */ -interface ExceptionInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/InvalidArgumentException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/InvalidArgumentException.php deleted file mode 100644 index a270e0ce9..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/InvalidArgumentException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Base InvalidArgumentException for the Form component. - * - * @author Bernhard Schussek - */ -class InvalidArgumentException extends \InvalidArgumentException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/InvalidConfigurationException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/InvalidConfigurationException.php deleted file mode 100644 index daa0c42f5..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/InvalidConfigurationException.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -class InvalidConfigurationException extends InvalidArgumentException -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/LogicException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/LogicException.php deleted file mode 100644 index 848780215..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/LogicException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Base LogicException for Form component. - * - * @author Alexander Kotynia - */ -class LogicException extends \LogicException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/OutOfBoundsException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/OutOfBoundsException.php deleted file mode 100644 index 44d311663..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/OutOfBoundsException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Base OutOfBoundsException for Form component. - * - * @author Alexander Kotynia - */ -class OutOfBoundsException extends \OutOfBoundsException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/RuntimeException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/RuntimeException.php deleted file mode 100644 index 0af48a4a2..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/RuntimeException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Base RuntimeException for the Form component. - * - * @author Bernhard Schussek - */ -class RuntimeException extends \RuntimeException implements ExceptionInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/StringCastException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/StringCastException.php deleted file mode 100644 index f9b51d604..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/StringCastException.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -class StringCastException extends RuntimeException -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/TransformationFailedException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/TransformationFailedException.php deleted file mode 100644 index d32896e69..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/TransformationFailedException.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -/** - * Indicates a value transformation error. - * - * @author Bernhard Schussek - */ -class TransformationFailedException extends RuntimeException -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Exception/UnexpectedTypeException.php b/vendor/symfony/form/Symfony/Component/Form/Exception/UnexpectedTypeException.php deleted file mode 100644 index 474e244bd..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Exception/UnexpectedTypeException.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Exception; - -class UnexpectedTypeException extends InvalidArgumentException -{ - public function __construct($value, $expectedType) - { - parent::__construct(sprintf('Expected argument of type "%s", "%s" given', $expectedType, is_object($value) ? get_class($value) : gettype($value))); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php deleted file mode 100644 index 57fd0fd9c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceList.php +++ /dev/null @@ -1,514 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -use Symfony\Component\Form\FormConfigBuilder; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Exception\InvalidConfigurationException; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; - -/** - * A choice list for choices of arbitrary data types. - * - * Choices and labels are passed in two arrays. The indices of the choices - * and the labels should match. Choices may also be given as hierarchy of - * unlimited depth by creating nested arrays. The title of the sub-hierarchy - * can be stored in the array key pointing to the nested array. The topmost - * level of the hierarchy may also be a \Traversable. - * - * - * $choices = array(true, false); - * $labels = array('Agree', 'Disagree'); - * $choiceList = new ChoiceList($choices, $labels); - * - * - * @author Bernhard Schussek - */ -class ChoiceList implements ChoiceListInterface -{ - /** - * The choices with their indices as keys. - * - * @var array - */ - protected $choices = array(); - - /** - * The choice values with the indices of the matching choices as keys. - * - * @var array - */ - protected $values = array(); - - /** - * The preferred view objects as hierarchy containing also the choice groups - * with the indices of the matching choices as bottom-level keys. - * - * @var array - */ - private $preferredViews = array(); - - /** - * The non-preferred view objects as hierarchy containing also the choice - * groups with the indices of the matching choices as bottom-level keys. - * - * @var array - */ - private $remainingViews = array(); - - /** - * Creates a new choice list. - * - * @param array|\Traversable $choices The array of choices. Choices may also be given - * as hierarchy of unlimited depth. Hierarchies are - * created by creating nested arrays. The title of - * the sub-hierarchy can be stored in the array - * key pointing to the nested array. The topmost - * level of the hierarchy may also be a \Traversable. - * @param array $labels The array of labels. The structure of this array - * should match the structure of $choices. - * @param array $preferredChoices A flat array of choices that should be - * presented to the user with priority. - * - * @throws UnexpectedTypeException If the choices are not an array or \Traversable. - */ - public function __construct($choices, array $labels, array $preferredChoices = array()) - { - if (!is_array($choices) && !$choices instanceof \Traversable) { - throw new UnexpectedTypeException($choices, 'array or \Traversable'); - } - - $this->initialize($choices, $labels, $preferredChoices); - } - - /** - * Initializes the list with choices. - * - * Safe to be called multiple times. The list is cleared on every call. - * - * @param array|\Traversable $choices The choices to write into the list. - * @param array $labels The labels belonging to the choices. - * @param array $preferredChoices The choices to display with priority. - */ - protected function initialize($choices, array $labels, array $preferredChoices) - { - $this->choices = array(); - $this->values = array(); - $this->preferredViews = array(); - $this->remainingViews = array(); - - $this->addChoices( - $this->preferredViews, - $this->remainingViews, - $choices, - $labels, - $preferredChoices - ); - } - - /** - * {@inheritdoc} - */ - public function getChoices() - { - return $this->choices; - } - - /** - * {@inheritdoc} - */ - public function getValues() - { - return $this->values; - } - - /** - * {@inheritdoc} - */ - public function getPreferredViews() - { - return $this->preferredViews; - } - - /** - * {@inheritdoc} - */ - public function getRemainingViews() - { - return $this->remainingViews; - } - - /** - * {@inheritdoc} - */ - public function getChoicesForValues(array $values) - { - $values = $this->fixValues($values); - $choices = array(); - - foreach ($values as $i => $givenValue) { - foreach ($this->values as $j => $value) { - if ($value === $givenValue) { - $choices[$i] = $this->choices[$j]; - unset($values[$i]); - - if (0 === count($values)) { - break 2; - } - } - } - } - - return $choices; - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - $choices = $this->fixChoices($choices); - $values = array(); - - foreach ($choices as $i => $givenChoice) { - foreach ($this->choices as $j => $choice) { - if ($choice === $givenChoice) { - $values[$i] = $this->values[$j]; - unset($choices[$i]); - - if (0 === count($choices)) { - break 2; - } - } - } - } - - return $values; - } - - /** - * {@inheritdoc} - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForChoices(array $choices) - { - $choices = $this->fixChoices($choices); - $indices = array(); - - foreach ($choices as $i => $givenChoice) { - foreach ($this->choices as $j => $choice) { - if ($choice === $givenChoice) { - $indices[$i] = $j; - unset($choices[$i]); - - if (0 === count($choices)) { - break 2; - } - } - } - } - - return $indices; - } - - /** - * {@inheritdoc} - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForValues(array $values) - { - $values = $this->fixValues($values); - $indices = array(); - - foreach ($values as $i => $givenValue) { - foreach ($this->values as $j => $value) { - if ($value === $givenValue) { - $indices[$i] = $j; - unset($values[$i]); - - if (0 === count($values)) { - break 2; - } - } - } - } - - return $indices; - } - - /** - * Recursively adds the given choices to the list. - * - * @param array $bucketForPreferred The bucket where to store the preferred - * view objects. - * @param array $bucketForRemaining The bucket where to store the - * non-preferred view objects. - * @param array|\Traversable $choices The list of choices. - * @param array $labels The labels corresponding to the choices. - * @param array $preferredChoices The preferred choices. - * - * @throws InvalidArgumentException If the structures of the choices and labels array do not match. - * @throws InvalidConfigurationException If no valid value or index could be created for a choice. - */ - protected function addChoices(array &$bucketForPreferred, array &$bucketForRemaining, $choices, array $labels, array $preferredChoices) - { - // Add choices to the nested buckets - foreach ($choices as $group => $choice) { - if (!array_key_exists($group, $labels)) { - throw new InvalidArgumentException('The structures of the choices and labels array do not match.'); - } - - if (is_array($choice)) { - // Don't do the work if the array is empty - if (count($choice) > 0) { - $this->addChoiceGroup( - $group, - $bucketForPreferred, - $bucketForRemaining, - $choice, - $labels[$group], - $preferredChoices - ); - } - } else { - $this->addChoice( - $bucketForPreferred, - $bucketForRemaining, - $choice, - $labels[$group], - $preferredChoices - ); - } - } - } - - /** - * Recursively adds a choice group. - * - * @param string $group The name of the group. - * @param array $bucketForPreferred The bucket where to store the preferred - * view objects. - * @param array $bucketForRemaining The bucket where to store the - * non-preferred view objects. - * @param array $choices The list of choices in the group. - * @param array $labels The labels corresponding to the choices in the group. - * @param array $preferredChoices The preferred choices. - * - * @throws InvalidConfigurationException If no valid value or index could be created for a choice. - */ - protected function addChoiceGroup($group, array &$bucketForPreferred, array &$bucketForRemaining, array $choices, array $labels, array $preferredChoices) - { - // If this is a choice group, create a new level in the choice - // key hierarchy - $bucketForPreferred[$group] = array(); - $bucketForRemaining[$group] = array(); - - $this->addChoices( - $bucketForPreferred[$group], - $bucketForRemaining[$group], - $choices, - $labels, - $preferredChoices - ); - - // Remove child levels if empty - if (empty($bucketForPreferred[$group])) { - unset($bucketForPreferred[$group]); - } - if (empty($bucketForRemaining[$group])) { - unset($bucketForRemaining[$group]); - } - } - - /** - * Adds a new choice. - * - * @param array $bucketForPreferred The bucket where to store the preferred - * view objects. - * @param array $bucketForRemaining The bucket where to store the - * non-preferred view objects. - * @param mixed $choice The choice to add. - * @param string $label The label for the choice. - * @param array $preferredChoices The preferred choices. - * - * @throws InvalidConfigurationException If no valid value or index could be created. - */ - protected function addChoice(array &$bucketForPreferred, array &$bucketForRemaining, $choice, $label, array $preferredChoices) - { - $index = $this->createIndex($choice); - - if ('' === $index || null === $index || !FormConfigBuilder::isValidName((string) $index)) { - throw new InvalidConfigurationException(sprintf('The index "%s" created by the choice list is invalid. It should be a valid, non-empty Form name.', $index)); - } - - $value = $this->createValue($choice); - - if (!is_string($value)) { - throw new InvalidConfigurationException(sprintf('The value created by the choice list is of type "%s", but should be a string.', gettype($value))); - } - - $view = new ChoiceView($choice, $value, $label); - - $this->choices[$index] = $this->fixChoice($choice); - $this->values[$index] = $value; - - if ($this->isPreferred($choice, $preferredChoices)) { - $bucketForPreferred[$index] = $view; - } else { - $bucketForRemaining[$index] = $view; - } - } - - /** - * Returns whether the given choice should be preferred judging by the - * given array of preferred choices. - * - * Extension point to optimize performance by changing the structure of the - * $preferredChoices array. - * - * @param mixed $choice The choice to test. - * @param array $preferredChoices An array of preferred choices. - * - * @return bool Whether the choice is preferred. - */ - protected function isPreferred($choice, array $preferredChoices) - { - return in_array($choice, $preferredChoices, true); - } - - /** - * Creates a new unique index for this choice. - * - * Extension point to change the indexing strategy. - * - * @param mixed $choice The choice to create an index for - * - * @return int|string A unique index containing only ASCII letters, - * digits and underscores. - */ - protected function createIndex($choice) - { - return count($this->choices); - } - - /** - * Creates a new unique value for this choice. - * - * By default, an integer is generated since it cannot be guaranteed that - * all values in the list are convertible to (unique) strings. Subclasses - * can override this behaviour if they can guarantee this property. - * - * @param mixed $choice The choice to create a value for - * - * @return string A unique string. - */ - protected function createValue($choice) - { - return (string) count($this->values); - } - - /** - * Fixes the data type of the given choice value to avoid comparison - * problems. - * - * @param mixed $value The choice value. - * - * @return string The value as string. - */ - protected function fixValue($value) - { - return (string) $value; - } - - /** - * Fixes the data types of the given choice values to avoid comparison - * problems. - * - * @param array $values The choice values. - * - * @return array The values as strings. - */ - protected function fixValues(array $values) - { - foreach ($values as $i => $value) { - $values[$i] = $this->fixValue($value); - } - - return $values; - } - - /** - * Fixes the data type of the given choice index to avoid comparison - * problems. - * - * @param mixed $index The choice index. - * - * @return int|string The index as PHP array key. - */ - protected function fixIndex($index) - { - if (is_bool($index) || (string) (int) $index === (string) $index) { - return (int) $index; - } - - return (string) $index; - } - - /** - * Fixes the data types of the given choice indices to avoid comparison - * problems. - * - * @param array $indices The choice indices. - * - * @return array The indices as strings. - */ - protected function fixIndices(array $indices) - { - foreach ($indices as $i => $index) { - $indices[$i] = $this->fixIndex($index); - } - - return $indices; - } - - /** - * Fixes the data type of the given choice to avoid comparison problems. - * - * Extension point. In this implementation, choices are guaranteed to - * always maintain their type and thus can be typesafely compared. - * - * @param mixed $choice The choice - * - * @return mixed The fixed choice - */ - protected function fixChoice($choice) - { - return $choice; - } - - /** - * Fixes the data type of the given choices to avoid comparison problems. - * - * @param array $choices The choices. - * - * @return array The fixed choices. - * - * @see fixChoice() - */ - protected function fixChoices(array $choices) - { - return $choices; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php deleted file mode 100644 index f0d8ec44d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ChoiceListInterface.php +++ /dev/null @@ -1,165 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -/** - * Contains choices that can be selected in a form field. - * - * Each choice has three different properties: - * - * - Choice: The choice that should be returned to the application by the - * choice field. Can be any scalar value or an object, but no - * array. - * - Label: A text representing the choice that is displayed to the user. - * - Value: A uniquely identifying value that can contain arbitrary - * characters, but no arrays or objects. This value is displayed - * in the HTML "value" attribute. - * - * @author Bernhard Schussek - */ -interface ChoiceListInterface -{ - /** - * Returns the list of choices. - * - * @return array The choices with their indices as keys - */ - public function getChoices(); - - /** - * Returns the values for the choices. - * - * @return array The values with the corresponding choice indices as keys - */ - public function getValues(); - - /** - * Returns the choice views of the preferred choices as nested array with - * the choice groups as top-level keys. - * - * Example: - * - * - * array( - * 'Group 1' => array( - * 10 => ChoiceView object, - * 20 => ChoiceView object, - * ), - * 'Group 2' => array( - * 30 => ChoiceView object, - * ), - * ) - * - * - * @return array A nested array containing the views with the corresponding - * choice indices as keys on the lowest levels and the choice - * group names in the keys of the higher levels - */ - public function getPreferredViews(); - - /** - * Returns the choice views of the choices that are not preferred as nested - * array with the choice groups as top-level keys. - * - * Example: - * - * - * array( - * 'Group 1' => array( - * 10 => ChoiceView object, - * 20 => ChoiceView object, - * ), - * 'Group 2' => array( - * 30 => ChoiceView object, - * ), - * ) - * - * - * @return array A nested array containing the views with the corresponding - * choice indices as keys on the lowest levels and the choice - * group names in the keys of the higher levels - * - * @see getPreferredValues() - */ - public function getRemainingViews(); - - /** - * Returns the choices corresponding to the given values. - * - * The choices can have any data type. - * - * The choices must be returned with the same keys and in the same order - * as the corresponding values in the given array. - * - * @param array $values An array of choice values. Not existing values in - * this array are ignored - * - * @return array An array of choices with ascending, 0-based numeric keys - */ - public function getChoicesForValues(array $values); - - /** - * Returns the values corresponding to the given choices. - * - * The values must be strings. - * - * The values must be returned with the same keys and in the same order - * as the corresponding choices in the given array. - * - * @param array $choices An array of choices. Not existing choices in this - * array are ignored - * - * @return array An array of choice values with ascending, 0-based numeric - * keys - */ - public function getValuesForChoices(array $choices); - - /** - * Returns the indices corresponding to the given choices. - * - * The indices must be positive integers or strings accepted by - * {@link FormConfigBuilder::validateName()}. - * - * The index "placeholder" is internally reserved. - * - * The indices must be returned with the same keys and in the same order - * as the corresponding choices in the given array. - * - * @param array $choices An array of choices. Not existing choices in this - * array are ignored - * - * @return array An array of indices with ascending, 0-based numeric keys - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForChoices(array $choices); - - /** - * Returns the indices corresponding to the given values. - * - * The indices must be positive integers or strings accepted by - * {@link FormConfigBuilder::validateName()}. - * - * The index "placeholder" is internally reserved. - * - * The indices must be returned with the same keys and in the same order - * as the corresponding values in the given array. - * - * @param array $values An array of choice values. Not existing values in - * this array are ignored - * - * @return array An array of indices with ascending, 0-based numeric keys - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForValues(array $values); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php deleted file mode 100644 index cc364d998..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/LazyChoiceList.php +++ /dev/null @@ -1,153 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -use Symfony\Component\Form\Exception\InvalidArgumentException; - -/** - * A choice list that is loaded lazily. - * - * This list loads itself as soon as any of the getters is accessed for the - * first time. You should implement loadChoiceList() in your child classes, - * which should return a ChoiceListInterface instance. - * - * @author Bernhard Schussek - */ -abstract class LazyChoiceList implements ChoiceListInterface -{ - /** - * The loaded choice list. - * - * @var ChoiceListInterface - */ - private $choiceList; - - /** - * {@inheritdoc} - */ - public function getChoices() - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getChoices(); - } - - /** - * {@inheritdoc} - */ - public function getValues() - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getValues(); - } - - /** - * {@inheritdoc} - */ - public function getPreferredViews() - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getPreferredViews(); - } - - /** - * {@inheritdoc} - */ - public function getRemainingViews() - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getRemainingViews(); - } - - /** - * {@inheritdoc} - */ - public function getChoicesForValues(array $values) - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getChoicesForValues($values); - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getValuesForChoices($choices); - } - - /** - * {@inheritdoc} - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForChoices(array $choices) - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getIndicesForChoices($choices); - } - - /** - * {@inheritdoc} - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForValues(array $values) - { - if (!$this->choiceList) { - $this->load(); - } - - return $this->choiceList->getIndicesForValues($values); - } - - /** - * Loads the choice list. - * - * Should be implemented by child classes. - * - * @return ChoiceListInterface The loaded choice list - */ - abstract protected function loadChoiceList(); - - private function load() - { - $choiceList = $this->loadChoiceList(); - - if (!$choiceList instanceof ChoiceListInterface) { - throw new InvalidArgumentException(sprintf('loadChoiceList() should return a ChoiceListInterface instance. Got %s', gettype($choiceList))); - } - - $this->choiceList = $choiceList; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php deleted file mode 100644 index 931d0655a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/ObjectChoiceList.php +++ /dev/null @@ -1,260 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -use Symfony\Component\Form\Exception\StringCastException; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\PropertyAccess\PropertyPath; -use Symfony\Component\PropertyAccess\Exception\NoSuchPropertyException; -use Symfony\Component\PropertyAccess\PropertyAccess; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; - -/** - * A choice list for object choices. - * - * Supports generation of choice labels, choice groups and choice values - * by calling getters of the object (or associated objects). - * - * - * $choices = array($user1, $user2); - * - * // call getName() to determine the choice labels - * $choiceList = new ObjectChoiceList($choices, 'name'); - * - * - * @author Bernhard Schussek - */ -class ObjectChoiceList extends ChoiceList -{ - /** - * @var PropertyAccessorInterface - */ - private $propertyAccessor; - - /** - * The property path used to obtain the choice label. - * - * @var PropertyPath - */ - private $labelPath; - - /** - * The property path used for object grouping. - * - * @var PropertyPath - */ - private $groupPath; - - /** - * The property path used to obtain the choice value. - * - * @var PropertyPath - */ - private $valuePath; - - /** - * Creates a new object choice list. - * - * @param array|\Traversable $choices The array of choices. Choices may also be given - * as hierarchy of unlimited depth by creating nested - * arrays. The title of the sub-hierarchy can be - * stored in the array key pointing to the nested - * array. The topmost level of the hierarchy may also - * be a \Traversable. - * @param string $labelPath A property path pointing to the property used - * for the choice labels. The value is obtained - * by calling the getter on the object. If the - * path is NULL, the object's __toString() method - * is used instead. - * @param array $preferredChoices A flat array of choices that should be - * presented to the user with priority. - * @param string $groupPath A property path pointing to the property used - * to group the choices. Only allowed if - * the choices are given as flat array. - * @param string $valuePath A property path pointing to the property used - * for the choice values. If not given, integers - * are generated instead. - * @param PropertyAccessorInterface $propertyAccessor The reflection graph for reading property paths. - */ - public function __construct($choices, $labelPath = null, array $preferredChoices = array(), $groupPath = null, $valuePath = null, PropertyAccessorInterface $propertyAccessor = null) - { - $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); - $this->labelPath = null !== $labelPath ? new PropertyPath($labelPath) : null; - $this->groupPath = null !== $groupPath ? new PropertyPath($groupPath) : null; - $this->valuePath = null !== $valuePath ? new PropertyPath($valuePath) : null; - - parent::__construct($choices, array(), $preferredChoices); - } - - /** - * Initializes the list with choices. - * - * Safe to be called multiple times. The list is cleared on every call. - * - * @param array|\Traversable $choices The choices to write into the list. - * @param array $labels Ignored. - * @param array $preferredChoices The choices to display with priority. - * - * @throws InvalidArgumentException When passing a hierarchy of choices and using - * the "groupPath" option at the same time. - */ - protected function initialize($choices, array $labels, array $preferredChoices) - { - if (null !== $this->groupPath) { - $groupedChoices = array(); - - foreach ($choices as $i => $choice) { - if (is_array($choice)) { - throw new InvalidArgumentException('You should pass a plain object array (without groups) when using the "groupPath" option.'); - } - - try { - $group = $this->propertyAccessor->getValue($choice, $this->groupPath); - } catch (NoSuchPropertyException $e) { - // Don't group items whose group property does not exist - // see https://github.com/symfony/symfony/commit/d9b7abb7c7a0f28e0ce970afc5e305dce5dccddf - $group = null; - } - - if (null === $group) { - $groupedChoices[$i] = $choice; - } else { - $groupName = (string) $group; - - if (!isset($groupedChoices[$groupName])) { - $groupedChoices[$groupName] = array(); - } - - $groupedChoices[$groupName][$i] = $choice; - } - } - - $choices = $groupedChoices; - } - - $labels = array(); - - $this->extractLabels($choices, $labels); - - parent::initialize($choices, $labels, $preferredChoices); - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - if (!$this->valuePath) { - return parent::getValuesForChoices($choices); - } - - // Use the value path to compare the choices - $choices = $this->fixChoices($choices); - $values = array(); - - foreach ($choices as $i => $givenChoice) { - // Ignore non-readable choices - if (!is_object($givenChoice) && !is_array($givenChoice)) { - continue; - } - - $givenValue = (string) $this->propertyAccessor->getValue($givenChoice, $this->valuePath); - - foreach ($this->values as $value) { - if ($value === $givenValue) { - $values[$i] = $value; - unset($choices[$i]); - - if (0 === count($choices)) { - break 2; - } - } - } - } - - return $values; - } - - /** - * {@inheritdoc} - * - * @deprecated Deprecated since version 2.4, to be removed in 3.0. - */ - public function getIndicesForChoices(array $choices) - { - if (!$this->valuePath) { - return parent::getIndicesForChoices($choices); - } - - // Use the value path to compare the choices - $choices = $this->fixChoices($choices); - $indices = array(); - - foreach ($choices as $i => $givenChoice) { - // Ignore non-readable choices - if (!is_object($givenChoice) && !is_array($givenChoice)) { - continue; - } - - $givenValue = (string) $this->propertyAccessor->getValue($givenChoice, $this->valuePath); - - foreach ($this->values as $j => $value) { - if ($value === $givenValue) { - $indices[$i] = $j; - unset($choices[$i]); - - if (0 === count($choices)) { - break 2; - } - } - } - } - - return $indices; - } - - /** - * Creates a new unique value for this choice. - * - * If a property path for the value was given at object creation, - * the getter behind that path is now called to obtain a new value. - * Otherwise a new integer is generated. - * - * @param mixed $choice The choice to create a value for - * - * @return int|string A unique value without character limitations. - */ - protected function createValue($choice) - { - if ($this->valuePath) { - return (string) $this->propertyAccessor->getValue($choice, $this->valuePath); - } - - return parent::createValue($choice); - } - - private function extractLabels($choices, array &$labels) - { - foreach ($choices as $i => $choice) { - if (is_array($choice)) { - $labels[$i] = array(); - $this->extractLabels($choice, $labels[$i]); - } elseif ($this->labelPath) { - $labels[$i] = $this->propertyAccessor->getValue($choice, $this->labelPath); - } elseif (method_exists($choice, '__toString')) { - $labels[$i] = (string) $choice; - } else { - throw new StringCastException(sprintf('A "__toString()" method was not found on the objects of type "%s" passed to the choice field. To read a custom getter instead, set the argument $labelPath to the desired property path.', get_class($choice))); - } - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php deleted file mode 100644 index 8d4ddd124..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/ChoiceList/SimpleChoiceList.php +++ /dev/null @@ -1,164 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\ChoiceList; - -/** - * A choice list for choices of type string or integer. - * - * Choices and their associated labels can be passed in a single array. Since - * choices are passed as array keys, only strings or integer choices are - * allowed. Choices may also be given as hierarchy of unlimited depth by - * creating nested arrays. The title of the sub-hierarchy can be stored in the - * array key pointing to the nested array. - * - * - * $choiceList = new SimpleChoiceList(array( - * 'creditcard' => 'Credit card payment', - * 'cash' => 'Cash payment', - * )); - * - * - * @author Bernhard Schussek - */ -class SimpleChoiceList extends ChoiceList -{ - /** - * Creates a new simple choice list. - * - * @param array $choices The array of choices with the choices as keys and - * the labels as values. Choices may also be given - * as hierarchy of unlimited depth by creating nested - * arrays. The title of the sub-hierarchy is stored - * in the array key pointing to the nested array. - * @param array $preferredChoices A flat array of choices that should be - * presented to the user with priority. - */ - public function __construct(array $choices, array $preferredChoices = array()) - { - // Flip preferred choices to speed up lookup - parent::__construct($choices, $choices, array_flip($preferredChoices)); - } - - /** - * {@inheritdoc} - */ - public function getChoicesForValues(array $values) - { - $values = $this->fixValues($values); - - // The values are identical to the choices, so we can just return them - // to improve performance a little bit - return $this->fixChoices(array_intersect($values, $this->getValues())); - } - - /** - * {@inheritdoc} - */ - public function getValuesForChoices(array $choices) - { - $choices = $this->fixChoices($choices); - - // The choices are identical to the values, so we can just return them - // to improve performance a little bit - return $this->fixValues(array_intersect($choices, $this->getValues())); - } - - /** - * Recursively adds the given choices to the list. - * - * Takes care of splitting the single $choices array passed in the - * constructor into choices and labels. - * - * @param array $bucketForPreferred The bucket where to store the preferred - * view objects. - * @param array $bucketForRemaining The bucket where to store the - * non-preferred view objects. - * @param array|\Traversable $choices The list of choices. - * @param array $labels Ignored. - * @param array $preferredChoices The preferred choices. - */ - protected function addChoices(array &$bucketForPreferred, array &$bucketForRemaining, $choices, array $labels, array $preferredChoices) - { - // Add choices to the nested buckets - foreach ($choices as $choice => $label) { - if (is_array($label)) { - // Don't do the work if the array is empty - if (count($label) > 0) { - $this->addChoiceGroup( - $choice, - $bucketForPreferred, - $bucketForRemaining, - $label, - $label, - $preferredChoices - ); - } - } else { - $this->addChoice( - $bucketForPreferred, - $bucketForRemaining, - $choice, - $label, - $preferredChoices - ); - } - } - } - - /** - * Returns whether the given choice should be preferred judging by the - * given array of preferred choices. - * - * Optimized for performance by treating the preferred choices as array - * where choices are stored in the keys. - * - * @param mixed $choice The choice to test. - * @param array $preferredChoices An array of preferred choices. - * - * @return bool Whether the choice is preferred. - */ - protected function isPreferred($choice, array $preferredChoices) - { - // Optimize performance over the default implementation - return isset($preferredChoices[$choice]); - } - - /** - * Converts the choice to a valid PHP array key. - * - * @param mixed $choice The choice - * - * @return string|int A valid PHP array key - */ - protected function fixChoice($choice) - { - return $this->fixIndex($choice); - } - - /** - * {@inheritdoc} - */ - protected function fixChoices(array $choices) - { - return $this->fixIndices($choices); - } - - /** - * {@inheritdoc} - */ - protected function createValue($choice) - { - // Choices are guaranteed to be unique and scalar, so we can simply - // convert them to strings - return (string) $choice; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/CoreExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/CoreExtension.php deleted file mode 100644 index a0153a57e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/CoreExtension.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core; - -use Symfony\Component\Form\AbstractExtension; -use Symfony\Component\PropertyAccess\PropertyAccess; - -/** - * Represents the main form extension, which loads the core functionality. - * - * @author Bernhard Schussek - */ -class CoreExtension extends AbstractExtension -{ - protected function loadTypes() - { - return array( - new Type\FormType(PropertyAccess::createPropertyAccessor()), - new Type\BirthdayType(), - new Type\CheckboxType(), - new Type\ChoiceType(), - new Type\CollectionType(), - new Type\CountryType(), - new Type\DateType(), - new Type\DateTimeType(), - new Type\EmailType(), - new Type\HiddenType(), - new Type\IntegerType(), - new Type\LanguageType(), - new Type\LocaleType(), - new Type\MoneyType(), - new Type\NumberType(), - new Type\PasswordType(), - new Type\PercentType(), - new Type\RadioType(), - new Type\RepeatedType(), - new Type\SearchType(), - new Type\TextareaType(), - new Type\TextType(), - new Type\TimeType(), - new Type\TimezoneType(), - new Type\UrlType(), - new Type\FileType(), - new Type\ButtonType(), - new Type\SubmitType(), - new Type\ResetType(), - new Type\CurrencyType(), - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php deleted file mode 100644 index 2208f26d1..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataMapper/PropertyPathMapper.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataMapper; - -use Symfony\Component\Form\DataMapperInterface; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\PropertyAccess\PropertyAccess; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; - -/** - * A data mapper using property paths to read/write data. - * - * @author Bernhard Schussek - */ -class PropertyPathMapper implements DataMapperInterface -{ - /** - * @var PropertyAccessorInterface - */ - private $propertyAccessor; - - /** - * Creates a new property path mapper. - * - * @param PropertyAccessorInterface $propertyAccessor - */ - public function __construct(PropertyAccessorInterface $propertyAccessor = null) - { - $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); - } - - /** - * {@inheritdoc} - */ - public function mapDataToForms($data, $forms) - { - $empty = null === $data || array() === $data; - - if (!$empty && !is_array($data) && !is_object($data)) { - throw new UnexpectedTypeException($data, 'object, array or empty'); - } - - foreach ($forms as $form) { - $propertyPath = $form->getPropertyPath(); - $config = $form->getConfig(); - - if (!$empty && null !== $propertyPath && $config->getMapped()) { - $form->setData($this->propertyAccessor->getValue($data, $propertyPath)); - } else { - $form->setData($form->getConfig()->getData()); - } - } - } - - /** - * {@inheritdoc} - */ - public function mapFormsToData($forms, &$data) - { - if (null === $data) { - return; - } - - if (!is_array($data) && !is_object($data)) { - throw new UnexpectedTypeException($data, 'object, array or empty'); - } - - foreach ($forms as $form) { - $propertyPath = $form->getPropertyPath(); - $config = $form->getConfig(); - - // Write-back is disabled if the form is not synchronized (transformation failed), - // if the form was not submitted and if the form is disabled (modification not allowed) - if (null !== $propertyPath && $config->getMapped() && $form->isSubmitted() && $form->isSynchronized() && !$form->isDisabled()) { - // If the field is of type DateTime and the data is the same skip the update to - // keep the original object hash - if ($form->getData() instanceof \DateTime && $form->getData() == $this->propertyAccessor->getValue($data, $propertyPath)) { - continue; - } - - // If the data is identical to the value in $data, we are - // dealing with a reference - if (!is_object($data) || !$config->getByReference() || $form->getData() !== $this->propertyAccessor->getValue($data, $propertyPath)) { - $this->propertyAccessor->setValue($data, $propertyPath, $form->getData()); - } - } - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php deleted file mode 100644 index 6929fb886..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ArrayToPartsTransformer.php +++ /dev/null @@ -1,86 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * @author Bernhard Schussek - */ -class ArrayToPartsTransformer implements DataTransformerInterface -{ - private $partMapping; - - public function __construct(array $partMapping) - { - $this->partMapping = $partMapping; - } - - public function transform($array) - { - if (null === $array) { - $array = array(); - } - - if (!is_array($array)) { - throw new TransformationFailedException('Expected an array.'); - } - - $result = array(); - - foreach ($this->partMapping as $partKey => $originalKeys) { - if (empty($array)) { - $result[$partKey] = null; - } else { - $result[$partKey] = array_intersect_key($array, array_flip($originalKeys)); - } - } - - return $result; - } - - public function reverseTransform($array) - { - if (!is_array($array)) { - throw new TransformationFailedException('Expected an array.'); - } - - $result = array(); - $emptyKeys = array(); - - foreach ($this->partMapping as $partKey => $originalKeys) { - if (!empty($array[$partKey])) { - foreach ($originalKeys as $originalKey) { - if (isset($array[$partKey][$originalKey])) { - $result[$originalKey] = $array[$partKey][$originalKey]; - } - } - } else { - $emptyKeys[] = $partKey; - } - } - - if (count($emptyKeys) > 0) { - if (count($emptyKeys) === count($this->partMapping)) { - // All parts empty - return; - } - - throw new TransformationFailedException( - sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys) - )); - } - - return $result; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php deleted file mode 100644 index 0cf9741dc..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/BaseDateTimeTransformer.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -abstract class BaseDateTimeTransformer implements DataTransformerInterface -{ - protected static $formats = array( - \IntlDateFormatter::NONE, - \IntlDateFormatter::FULL, - \IntlDateFormatter::LONG, - \IntlDateFormatter::MEDIUM, - \IntlDateFormatter::SHORT, - ); - - protected $inputTimezone; - - protected $outputTimezone; - - /** - * Constructor. - * - * @param string $inputTimezone The name of the input timezone - * @param string $outputTimezone The name of the output timezone - * - * @throws UnexpectedTypeException if a timezone is not a string - * @throws InvalidArgumentException if a timezone is not valid - */ - public function __construct($inputTimezone = null, $outputTimezone = null) - { - if (!is_string($inputTimezone) && null !== $inputTimezone) { - throw new UnexpectedTypeException($inputTimezone, 'string'); - } - - if (!is_string($outputTimezone) && null !== $outputTimezone) { - throw new UnexpectedTypeException($outputTimezone, 'string'); - } - - $this->inputTimezone = $inputTimezone ?: date_default_timezone_get(); - $this->outputTimezone = $outputTimezone ?: date_default_timezone_get(); - - // Check if input and output timezones are valid - try { - new \DateTimeZone($this->inputTimezone); - } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Input timezone is invalid: %s.', $this->inputTimezone), $e->getCode(), $e); - } - - try { - new \DateTimeZone($this->outputTimezone); - } catch (\Exception $e) { - throw new InvalidArgumentException(sprintf('Output timezone is invalid: %s.', $this->outputTimezone), $e->getCode(), $e); - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php deleted file mode 100644 index b75b98914..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/BooleanToStringTransformer.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * Transforms between a Boolean and a string. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - */ -class BooleanToStringTransformer implements DataTransformerInterface -{ - /** - * The value emitted upon transform if the input is true. - * - * @var string - */ - private $trueValue; - - /** - * Sets the value emitted upon transform if the input is true. - * - * @param string $trueValue - */ - public function __construct($trueValue) - { - $this->trueValue = $trueValue; - } - - /** - * Transforms a Boolean into a string. - * - * @param bool $value Boolean value. - * - * @return string String value. - * - * @throws TransformationFailedException If the given value is not a Boolean. - */ - public function transform($value) - { - if (null === $value) { - return; - } - - if (!is_bool($value)) { - throw new TransformationFailedException('Expected a Boolean.'); - } - - return $value ? $this->trueValue : null; - } - - /** - * Transforms a string into a Boolean. - * - * @param string $value String value. - * - * @return bool Boolean value. - * - * @throws TransformationFailedException If the given value is not a string. - */ - public function reverseTransform($value) - { - if (null === $value) { - return false; - } - - if (!is_string($value)) { - throw new TransformationFailedException('Expected a string.'); - } - - return true; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php deleted file mode 100644 index a91ed55c3..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToBooleanArrayTransformer.php +++ /dev/null @@ -1,116 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * @author Bernhard Schussek - */ -class ChoiceToBooleanArrayTransformer implements DataTransformerInterface -{ - private $choiceList; - - private $placeholderPresent; - - /** - * Constructor. - * - * @param ChoiceListInterface $choiceList - * @param bool $placeholderPresent - */ - public function __construct(ChoiceListInterface $choiceList, $placeholderPresent) - { - $this->choiceList = $choiceList; - $this->placeholderPresent = $placeholderPresent; - } - - /** - * Transforms a single choice to a format appropriate for the nested - * checkboxes/radio buttons. - * - * The result is an array with the options as keys and true/false as values, - * depending on whether a given option is selected. If this field is rendered - * as select tag, the value is not modified. - * - * @param mixed $choice An array if "multiple" is set to true, a scalar - * value otherwise. - * - * @return mixed An array - * - * @throws TransformationFailedException If the given value is not scalar or - * if the choices can not be retrieved. - */ - public function transform($choice) - { - try { - $values = $this->choiceList->getValues(); - } catch (\Exception $e) { - throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); - } - - $valueMap = array_flip($this->choiceList->getValuesForChoices(array($choice))); - - foreach ($values as $i => $value) { - $values[$i] = isset($valueMap[$value]); - } - - if ($this->placeholderPresent) { - $values['placeholder'] = 0 === count($valueMap); - } - - return $values; - } - - /** - * Transforms a checkbox/radio button array to a single choice. - * - * The input value is an array with the choices as keys and true/false as - * values, depending on whether a given choice is selected. The output - * is the selected choice. - * - * @param array $values An array of values - * - * @return mixed A scalar value - * - * @throws TransformationFailedException If the given value is not an array, - * if the recuperation of the choices - * fails or if some choice can't be - * found. - */ - public function reverseTransform($values) - { - if (!is_array($values)) { - throw new TransformationFailedException('Expected an array.'); - } - - try { - $choices = $this->choiceList->getChoices(); - } catch (\Exception $e) { - throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); - } - - foreach ($values as $i => $selected) { - if ($selected) { - if (isset($choices[$i])) { - return $choices[$i] === '' ? null : $choices[$i]; - } elseif ($this->placeholderPresent && 'placeholder' === $i) { - return; - } else { - throw new TransformationFailedException(sprintf('The choice "%s" does not exist', $i)); - } - } - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php deleted file mode 100644 index 087faf4d3..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoiceToValueTransformer.php +++ /dev/null @@ -1,62 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; - -/** - * @author Bernhard Schussek - */ -class ChoiceToValueTransformer implements DataTransformerInterface -{ - private $choiceList; - - /** - * Constructor. - * - * @param ChoiceListInterface $choiceList - */ - public function __construct(ChoiceListInterface $choiceList) - { - $this->choiceList = $choiceList; - } - - public function transform($choice) - { - return (string) current($this->choiceList->getValuesForChoices(array($choice))); - } - - public function reverseTransform($value) - { - if (null !== $value && !is_scalar($value)) { - throw new TransformationFailedException('Expected a scalar.'); - } - - // These are now valid ChoiceList values, so we can return null - // right away - if ('' === $value || null === $value) { - return; - } - - $choices = $this->choiceList->getChoicesForValues(array($value)); - - if (1 !== count($choices)) { - throw new TransformationFailedException(sprintf('The choice "%s" does not exist or is not unique', $value)); - } - - $choice = current($choices); - - return '' === $choice ? null : $choice; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php deleted file mode 100644 index f1f13fda2..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToBooleanArrayTransformer.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * @author Bernhard Schussek - */ -class ChoicesToBooleanArrayTransformer implements DataTransformerInterface -{ - private $choiceList; - - public function __construct(ChoiceListInterface $choiceList) - { - $this->choiceList = $choiceList; - } - - /** - * Transforms an array of choices to a format appropriate for the nested - * checkboxes/radio buttons. - * - * The result is an array with the options as keys and true/false as values, - * depending on whether a given option is selected. If this field is rendered - * as select tag, the value is not modified. - * - * @param mixed $array An array - * - * @return mixed An array - * - * @throws TransformationFailedException If the given value is not an array - * or if the choices can not be retrieved. - */ - public function transform($array) - { - if (null === $array) { - return array(); - } - - if (!is_array($array)) { - throw new TransformationFailedException('Expected an array.'); - } - - try { - $values = $this->choiceList->getValues(); - } catch (\Exception $e) { - throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); - } - - $valueMap = array_flip($this->choiceList->getValuesForChoices($array)); - - foreach ($values as $i => $value) { - $values[$i] = isset($valueMap[$value]); - } - - return $values; - } - - /** - * Transforms a checkbox/radio button array to an array of choices. - * - * The input value is an array with the choices as keys and true/false as - * values, depending on whether a given choice is selected. The output - * is an array with the selected choices. - * - * @param mixed $values An array - * - * @return mixed An array - * - * @throws TransformationFailedException If the given value is not an array, - * if the recuperation of the choices - * fails or if some choice can't be - * found. - */ - public function reverseTransform($values) - { - if (!is_array($values)) { - throw new TransformationFailedException('Expected an array.'); - } - - try { - $choices = $this->choiceList->getChoices(); - } catch (\Exception $e) { - throw new TransformationFailedException('Can not get the choice list', $e->getCode(), $e); - } - - $result = array(); - $unknown = array(); - - foreach ($values as $i => $selected) { - if ($selected) { - if (isset($choices[$i])) { - $result[] = $choices[$i]; - } else { - $unknown[] = $i; - } - } - } - - if (count($unknown) > 0) { - throw new TransformationFailedException(sprintf('The choices "%s" were not found', implode('", "', $unknown))); - } - - return $result; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php deleted file mode 100644 index 0ee0b0fef..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ChoicesToValuesTransformer.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; - -/** - * @author Bernhard Schussek - */ -class ChoicesToValuesTransformer implements DataTransformerInterface -{ - private $choiceList; - - /** - * Constructor. - * - * @param ChoiceListInterface $choiceList - */ - public function __construct(ChoiceListInterface $choiceList) - { - $this->choiceList = $choiceList; - } - - /** - * @param array $array - * - * @return array - * - * @throws TransformationFailedException If the given value is not an array. - */ - public function transform($array) - { - if (null === $array) { - return array(); - } - - if (!is_array($array)) { - throw new TransformationFailedException('Expected an array.'); - } - - return $this->choiceList->getValuesForChoices($array); - } - - /** - * @param array $array - * - * @return array - * - * @throws TransformationFailedException If the given value is not an array - * or if no matching choice could be - * found for some given value. - */ - public function reverseTransform($array) - { - if (null === $array) { - return array(); - } - - if (!is_array($array)) { - throw new TransformationFailedException('Expected an array.'); - } - - $choices = $this->choiceList->getChoicesForValues($array); - - if (count($choices) !== count($array)) { - throw new TransformationFailedException('Could not find all matching choices for the given values'); - } - - return $choices; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DataTransformerChain.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DataTransformerChain.php deleted file mode 100644 index f52bb97eb..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DataTransformerChain.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * Passes a value through multiple value transformers. - * - * @author Bernhard Schussek - */ -class DataTransformerChain implements DataTransformerInterface -{ - /** - * The value transformers. - * - * @var DataTransformerInterface[] - */ - protected $transformers; - - /** - * Uses the given value transformers to transform values. - * - * @param array $transformers - */ - public function __construct(array $transformers) - { - $this->transformers = $transformers; - } - - /** - * Passes the value through the transform() method of all nested transformers. - * - * The transformers receive the value in the same order as they were passed - * to the constructor. Each transformer receives the result of the previous - * transformer as input. The output of the last transformer is returned - * by this method. - * - * @param mixed $value The original value - * - * @return mixed The transformed value - * - * @throws TransformationFailedException - */ - public function transform($value) - { - foreach ($this->transformers as $transformer) { - $value = $transformer->transform($value); - } - - return $value; - } - - /** - * Passes the value through the reverseTransform() method of all nested - * transformers. - * - * The transformers receive the value in the reverse order as they were passed - * to the constructor. Each transformer receives the result of the previous - * transformer as input. The output of the last transformer is returned - * by this method. - * - * @param mixed $value The transformed value - * - * @return mixed The reverse-transformed value - * - * @throws TransformationFailedException - */ - public function reverseTransform($value) - { - for ($i = count($this->transformers) - 1; $i >= 0; --$i) { - $value = $this->transformers[$i]->reverseTransform($value); - } - - return $value; - } - - /** - * @return DataTransformerInterface[] - */ - public function getTransformers() - { - return $this->transformers; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php deleted file mode 100644 index e36be1200..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToArrayTransformer.php +++ /dev/null @@ -1,196 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -/** - * Transforms between a normalized time and a localized time string/array. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - */ -class DateTimeToArrayTransformer extends BaseDateTimeTransformer -{ - private $pad; - - private $fields; - - /** - * Constructor. - * - * @param string $inputTimezone The input timezone - * @param string $outputTimezone The output timezone - * @param array $fields The date fields - * @param bool $pad Whether to use padding - * - * @throws UnexpectedTypeException if a timezone is not a string - */ - public function __construct($inputTimezone = null, $outputTimezone = null, array $fields = null, $pad = false) - { - parent::__construct($inputTimezone, $outputTimezone); - - if (null === $fields) { - $fields = array('year', 'month', 'day', 'hour', 'minute', 'second'); - } - - $this->fields = $fields; - $this->pad = (bool) $pad; - } - - /** - * Transforms a normalized date into a localized date. - * - * @param \DateTime $dateTime Normalized date. - * - * @return array Localized date. - * - * @throws TransformationFailedException If the given value is not an - * instance of \DateTime or if the - * output timezone is not supported. - */ - public function transform($dateTime) - { - if (null === $dateTime) { - return array_intersect_key(array( - 'year' => '', - 'month' => '', - 'day' => '', - 'hour' => '', - 'minute' => '', - 'second' => '', - ), array_flip($this->fields)); - } - - if (!$dateTime instanceof \DateTime) { - throw new TransformationFailedException('Expected a \DateTime.'); - } - - $dateTime = clone $dateTime; - if ($this->inputTimezone !== $this->outputTimezone) { - try { - $dateTime->setTimezone(new \DateTimeZone($this->outputTimezone)); - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - } - - $result = array_intersect_key(array( - 'year' => $dateTime->format('Y'), - 'month' => $dateTime->format('m'), - 'day' => $dateTime->format('d'), - 'hour' => $dateTime->format('H'), - 'minute' => $dateTime->format('i'), - 'second' => $dateTime->format('s'), - ), array_flip($this->fields)); - - if (!$this->pad) { - foreach ($result as &$entry) { - // remove leading zeros - $entry = (string) (int) $entry; - } - } - - return $result; - } - - /** - * Transforms a localized date into a normalized date. - * - * @param array $value Localized date - * - * @return \DateTime Normalized date - * - * @throws TransformationFailedException If the given value is not an array, - * if the value could not be transformed - * or if the input timezone is not - * supported. - */ - public function reverseTransform($value) - { - if (null === $value) { - return; - } - - if (!is_array($value)) { - throw new TransformationFailedException('Expected an array.'); - } - - if ('' === implode('', $value)) { - return; - } - - $emptyFields = array(); - - foreach ($this->fields as $field) { - if (!isset($value[$field])) { - $emptyFields[] = $field; - } - } - - if (count($emptyFields) > 0) { - throw new TransformationFailedException( - sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields) - )); - } - - if (isset($value['month']) && !ctype_digit((string) $value['month'])) { - throw new TransformationFailedException('This month is invalid'); - } - - if (isset($value['day']) && !ctype_digit((string) $value['day'])) { - throw new TransformationFailedException('This day is invalid'); - } - - if (isset($value['year']) && !ctype_digit((string) $value['year'])) { - throw new TransformationFailedException('This year is invalid'); - } - - if (!empty($value['month']) && !empty($value['day']) && !empty($value['year']) && false === checkdate($value['month'], $value['day'], $value['year'])) { - throw new TransformationFailedException('This is an invalid date'); - } - - if (isset($value['hour']) && !ctype_digit((string) $value['hour'])) { - throw new TransformationFailedException('This hour is invalid'); - } - - if (isset($value['minute']) && !ctype_digit((string) $value['minute'])) { - throw new TransformationFailedException('This minute is invalid'); - } - - if (isset($value['second']) && !ctype_digit((string) $value['second'])) { - throw new TransformationFailedException('This second is invalid'); - } - - try { - $dateTime = new \DateTime(sprintf( - '%s-%s-%s %s:%s:%s %s', - empty($value['year']) ? '1970' : $value['year'], - empty($value['month']) ? '1' : $value['month'], - empty($value['day']) ? '1' : $value['day'], - empty($value['hour']) ? '0' : $value['hour'], - empty($value['minute']) ? '0' : $value['minute'], - empty($value['second']) ? '0' : $value['second'], - $this->outputTimezone - )); - - if ($this->inputTimezone !== $this->outputTimezone) { - $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); - } - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - - return $dateTime; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php deleted file mode 100644 index e7ebcabc7..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformer.php +++ /dev/null @@ -1,177 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -/** - * Transforms between a normalized time and a localized time string. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - */ -class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer -{ - private $dateFormat; - private $timeFormat; - private $pattern; - private $calendar; - - /** - * Constructor. - * - * @see BaseDateTimeTransformer::formats for available format options - * - * @param string $inputTimezone The name of the input timezone - * @param string $outputTimezone The name of the output timezone - * @param int $dateFormat The date format - * @param int $timeFormat The time format - * @param int $calendar One of the \IntlDateFormatter calendar constants - * @param string $pattern A pattern to pass to \IntlDateFormatter - * - * @throws UnexpectedTypeException If a format is not supported or if a timezone is not a string - */ - public function __construct($inputTimezone = null, $outputTimezone = null, $dateFormat = null, $timeFormat = null, $calendar = \IntlDateFormatter::GREGORIAN, $pattern = null) - { - parent::__construct($inputTimezone, $outputTimezone); - - if (null === $dateFormat) { - $dateFormat = \IntlDateFormatter::MEDIUM; - } - - if (null === $timeFormat) { - $timeFormat = \IntlDateFormatter::SHORT; - } - - if (!in_array($dateFormat, self::$formats, true)) { - throw new UnexpectedTypeException($dateFormat, implode('", "', self::$formats)); - } - - if (!in_array($timeFormat, self::$formats, true)) { - throw new UnexpectedTypeException($timeFormat, implode('", "', self::$formats)); - } - - $this->dateFormat = $dateFormat; - $this->timeFormat = $timeFormat; - $this->calendar = $calendar; - $this->pattern = $pattern; - } - - /** - * Transforms a normalized date into a localized date string/array. - * - * @param \DateTime $dateTime Normalized date. - * - * @return string|array Localized date string/array. - * - * @throws TransformationFailedException If the given value is not an instance - * of \DateTime or if the date could not - * be transformed. - */ - public function transform($dateTime) - { - if (null === $dateTime) { - return ''; - } - - if (!$dateTime instanceof \DateTime) { - throw new TransformationFailedException('Expected a \DateTime.'); - } - - // convert time to UTC before passing it to the formatter - $dateTime = clone $dateTime; - if ('UTC' !== $this->inputTimezone) { - $dateTime->setTimezone(new \DateTimeZone('UTC')); - } - - $value = $this->getIntlDateFormatter()->format((int) $dateTime->format('U')); - - if (intl_get_error_code() != 0) { - throw new TransformationFailedException(intl_get_error_message()); - } - - return $value; - } - - /** - * Transforms a localized date string/array into a normalized date. - * - * @param string|array $value Localized date string/array - * - * @return \DateTime Normalized date - * - * @throws TransformationFailedException if the given value is not a string, - * if the date could not be parsed or - * if the input timezone is not supported - */ - public function reverseTransform($value) - { - if (!is_string($value)) { - throw new TransformationFailedException('Expected a string.'); - } - - if ('' === $value) { - return; - } - - $timestamp = $this->getIntlDateFormatter()->parse($value); - - if (intl_get_error_code() != 0) { - throw new TransformationFailedException(intl_get_error_message()); - } - - try { - // read timestamp into DateTime object - the formatter delivers in UTC - $dateTime = new \DateTime(sprintf('@%s UTC', $timestamp)); - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - - if ('UTC' !== $this->inputTimezone) { - try { - $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - } - - return $dateTime; - } - - /** - * Returns a preconfigured IntlDateFormatter instance. - * - * @return \IntlDateFormatter - * - * @throws TransformationFailedException in case the date formatter can not be constructed. - */ - protected function getIntlDateFormatter() - { - $dateFormat = $this->dateFormat; - $timeFormat = $this->timeFormat; - $timezone = $this->outputTimezone; - $calendar = $this->calendar; - $pattern = $this->pattern; - - $intlDateFormatter = new \IntlDateFormatter(\Locale::getDefault(), $dateFormat, $timeFormat, $timezone, $calendar, $pattern); - - // new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323 - if (!$intlDateFormatter) { - throw new TransformationFailedException(intl_get_error_message(), intl_get_error_code()); - } - - $intlDateFormatter->setLenient(false); - - return $intlDateFormatter; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php deleted file mode 100644 index e3297ffef..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToRfc3339Transformer.php +++ /dev/null @@ -1,82 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * @author Bernhard Schussek - */ -class DateTimeToRfc3339Transformer extends BaseDateTimeTransformer -{ - /** - * {@inheritdoc} - */ - public function transform($dateTime) - { - if (null === $dateTime) { - return ''; - } - - if (!$dateTime instanceof \DateTime) { - throw new TransformationFailedException('Expected a \DateTime.'); - } - - if ($this->inputTimezone !== $this->outputTimezone) { - $dateTime = clone $dateTime; - $dateTime->setTimezone(new \DateTimeZone($this->outputTimezone)); - } - - return preg_replace('/\+00:00$/', 'Z', $dateTime->format('c')); - } - - /** - * {@inheritdoc} - */ - public function reverseTransform($rfc3339) - { - if (!is_string($rfc3339)) { - throw new TransformationFailedException('Expected a string.'); - } - - if ('' === $rfc3339) { - return; - } - - try { - $dateTime = new \DateTime($rfc3339); - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - - if ($this->outputTimezone !== $dateTime->getTimezone()->getName()) { - try { - $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - } - - if (preg_match('/(\d{4})-(\d{2})-(\d{2})/', $rfc3339, $matches)) { - if (!checkdate($matches[2], $matches[3], $matches[1])) { - throw new TransformationFailedException(sprintf( - 'The date "%s-%s-%s" is not a valid date.', - $matches[1], - $matches[2], - $matches[3] - )); - } - } - - return $dateTime; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php deleted file mode 100644 index f5ba9948d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToStringTransformer.php +++ /dev/null @@ -1,232 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -/** - * Transforms between a date string and a DateTime object. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - */ -class DateTimeToStringTransformer extends BaseDateTimeTransformer -{ - /** - * Format used for generating strings. - * - * @var string - */ - private $generateFormat; - - /** - * Format used for parsing strings. - * - * Different than the {@link $generateFormat} because formats for parsing - * support additional characters in PHP that are not supported for - * generating strings. - * - * @var string - */ - private $parseFormat; - - /** - * Whether to parse by appending a pipe "|" to the parse format. - * - * This only works as of PHP 5.3.7. - * - * @var bool - */ - private $parseUsingPipe; - - /** - * Transforms a \DateTime instance to a string. - * - * @see \DateTime::format() for supported formats - * - * @param string $inputTimezone The name of the input timezone - * @param string $outputTimezone The name of the output timezone - * @param string $format The date format - * @param bool $parseUsingPipe Whether to parse by appending a pipe "|" to the parse format - * - * @throws UnexpectedTypeException if a timezone is not a string - */ - public function __construct($inputTimezone = null, $outputTimezone = null, $format = 'Y-m-d H:i:s', $parseUsingPipe = null) - { - parent::__construct($inputTimezone, $outputTimezone); - - $this->generateFormat = $this->parseFormat = $format; - - // The pipe in the parser pattern only works as of PHP 5.3.7 - // See http://bugs.php.net/54316 - $this->parseUsingPipe = null === $parseUsingPipe - ? PHP_VERSION_ID >= 50307 - : $parseUsingPipe; - - // See http://php.net/manual/en/datetime.createfromformat.php - // The character "|" in the format makes sure that the parts of a date - // that are *not* specified in the format are reset to the corresponding - // values from 1970-01-01 00:00:00 instead of the current time. - // Without "|" and "Y-m-d", "2010-02-03" becomes "2010-02-03 12:32:47", - // where the time corresponds to the current server time. - // With "|" and "Y-m-d", "2010-02-03" becomes "2010-02-03 00:00:00", - // which is at least deterministic and thus used here. - if ($this->parseUsingPipe && false === strpos($this->parseFormat, '|')) { - $this->parseFormat .= '|'; - } - } - - /** - * Transforms a DateTime object into a date string with the configured format - * and timezone. - * - * @param \DateTime $value A DateTime object - * - * @return string A value as produced by PHP's date() function - * - * @throws TransformationFailedException If the given value is not a \DateTime - * instance or if the output timezone - * is not supported. - */ - public function transform($value) - { - if (null === $value) { - return ''; - } - - if (!$value instanceof \DateTime) { - throw new TransformationFailedException('Expected a \DateTime.'); - } - - $value = clone $value; - try { - $value->setTimezone(new \DateTimeZone($this->outputTimezone)); - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - - return $value->format($this->generateFormat); - } - - /** - * Transforms a date string in the configured timezone into a DateTime object. - * - * @param string $value A value as produced by PHP's date() function - * - * @return \DateTime An instance of \DateTime - * - * @throws TransformationFailedException If the given value is not a string, - * if the date could not be parsed or - * if the input timezone is not supported. - */ - public function reverseTransform($value) - { - if (empty($value)) { - return; - } - - if (!is_string($value)) { - throw new TransformationFailedException('Expected a string.'); - } - - try { - $outputTz = new \DateTimeZone($this->outputTimezone); - $dateTime = \DateTime::createFromFormat($this->parseFormat, $value, $outputTz); - - $lastErrors = \DateTime::getLastErrors(); - - if (0 < $lastErrors['warning_count'] || 0 < $lastErrors['error_count']) { - throw new TransformationFailedException( - implode(', ', array_merge( - array_values($lastErrors['warnings']), - array_values($lastErrors['errors']) - )) - ); - } - - // On PHP versions < 5.3.7 we need to emulate the pipe operator - // and reset parts not given in the format to their equivalent - // of the UNIX base timestamp. - if (!$this->parseUsingPipe) { - list($year, $month, $day, $hour, $minute, $second) = explode('-', $dateTime->format('Y-m-d-H-i-s')); - - // Check which of the date parts are present in the pattern - preg_match( - '/('. - '(?P[djDl])|'. - '(?P[FMmn])|'. - '(?P[Yy])|'. - '(?P[ghGH])|'. - '(?Pi)|'. - '(?Ps)|'. - '(?Pz)|'. - '(?PU)|'. - '[^djDlFMmnYyghGHiszU]'. - ')*/', - $this->parseFormat, - $matches - ); - - // preg_match() does not guarantee to set all indices, so - // set them unless given - $matches = array_merge(array( - 'day' => false, - 'month' => false, - 'year' => false, - 'hour' => false, - 'minute' => false, - 'second' => false, - 'dayofyear' => false, - 'timestamp' => false, - ), $matches); - - // Reset all parts that don't exist in the format to the - // corresponding part of the UNIX base timestamp - if (!$matches['timestamp']) { - if (!$matches['dayofyear']) { - if (!$matches['day']) { - $day = 1; - } - if (!$matches['month']) { - $month = 1; - } - } - if (!$matches['year']) { - $year = 1970; - } - if (!$matches['hour']) { - $hour = 0; - } - if (!$matches['minute']) { - $minute = 0; - } - if (!$matches['second']) { - $second = 0; - } - $dateTime->setDate($year, $month, $day); - $dateTime->setTime($hour, $minute, $second); - } - } - - if ($this->inputTimezone !== $this->outputTimezone) { - $dateTime->setTimeZone(new \DateTimeZone($this->inputTimezone)); - } - } catch (TransformationFailedException $e) { - throw $e; - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - - return $dateTime; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php deleted file mode 100644 index bd51ea419..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/DateTimeToTimestampTransformer.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * Transforms between a timestamp and a DateTime object. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - */ -class DateTimeToTimestampTransformer extends BaseDateTimeTransformer -{ - /** - * Transforms a DateTime object into a timestamp in the configured timezone. - * - * @param \DateTime $value A \DateTime object - * - * @return int A timestamp - * - * @throws TransformationFailedException If the given value is not an instance - * of \DateTime or if the output - * timezone is not supported. - */ - public function transform($value) - { - if (null === $value) { - return; - } - - if (!$value instanceof \DateTime) { - throw new TransformationFailedException('Expected a \DateTime.'); - } - - $value = clone $value; - try { - $value->setTimezone(new \DateTimeZone($this->outputTimezone)); - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - - return (int) $value->format('U'); - } - - /** - * Transforms a timestamp in the configured timezone into a DateTime object. - * - * @param string $value A timestamp - * - * @return \DateTime A \DateTime object - * - * @throws TransformationFailedException If the given value is not a timestamp - * or if the given timestamp is invalid. - */ - public function reverseTransform($value) - { - if (null === $value) { - return; - } - - if (!is_numeric($value)) { - throw new TransformationFailedException('Expected a numeric.'); - } - - try { - $dateTime = new \DateTime(); - $dateTime->setTimezone(new \DateTimeZone($this->outputTimezone)); - $dateTime->setTimestamp($value); - - if ($this->inputTimezone !== $this->outputTimezone) { - $dateTime->setTimezone(new \DateTimeZone($this->inputTimezone)); - } - } catch (\Exception $e) { - throw new TransformationFailedException($e->getMessage(), $e->getCode(), $e); - } - - return $dateTime; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php deleted file mode 100644 index a14074ce9..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformer.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -/** - * Transforms between an integer and a localized number with grouping - * (each thousand) and comma separators. - * - * @author Bernhard Schussek - */ -class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransformer -{ - /** - * Constructs a transformer. - * - * @param int $precision Unused. - * @param bool $grouping Whether thousands should be grouped. - * @param int $roundingMode One of the ROUND_ constants in this class. - */ - public function __construct($precision = 0, $grouping = false, $roundingMode = self::ROUND_DOWN) - { - if (null === $roundingMode) { - $roundingMode = self::ROUND_DOWN; - } - - parent::__construct(0, $grouping, $roundingMode); - } - - /** - * {@inheritdoc} - */ - public function reverseTransform($value) - { - $result = parent::reverseTransform($value); - - return null !== $result ? (int) $result : null; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php deleted file mode 100644 index 7de1d0996..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformer.php +++ /dev/null @@ -1,88 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * Transforms between a normalized format and a localized money string. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - */ -class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransformer -{ - private $divisor; - - public function __construct($precision = 2, $grouping = true, $roundingMode = self::ROUND_HALF_UP, $divisor = 1) - { - if (null === $grouping) { - $grouping = true; - } - - if (null === $precision) { - $precision = 2; - } - - parent::__construct($precision, $grouping, $roundingMode); - - if (null === $divisor) { - $divisor = 1; - } - - $this->divisor = $divisor; - } - - /** - * Transforms a normalized format into a localized money string. - * - * @param int|float $value Normalized number - * - * @return string Localized money string. - * - * @throws TransformationFailedException If the given value is not numeric or - * if the value can not be transformed. - */ - public function transform($value) - { - if (null !== $value) { - if (!is_numeric($value)) { - throw new TransformationFailedException('Expected a numeric.'); - } - - $value /= $this->divisor; - } - - return parent::transform($value); - } - - /** - * Transforms a localized money string into a normalized format. - * - * @param string $value Localized money string - * - * @return int|float Normalized number - * - * @throws TransformationFailedException If the given value is not a string - * or if the value can not be transformed. - */ - public function reverseTransform($value) - { - $value = parent::reverseTransform($value); - - if (null !== $value) { - $value *= $this->divisor; - } - - return $value; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php deleted file mode 100644 index 86b9e9033..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/NumberToLocalizedStringTransformer.php +++ /dev/null @@ -1,285 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * Transforms between a number type and a localized number with grouping - * (each thousand) and comma separators. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - */ -class NumberToLocalizedStringTransformer implements DataTransformerInterface -{ - /** - * Rounds a number towards positive infinity. - * - * Rounds 1.4 to 2 and -1.4 to -1. - */ - const ROUND_CEILING = \NumberFormatter::ROUND_CEILING; - - /** - * Rounds a number towards negative infinity. - * - * Rounds 1.4 to 1 and -1.4 to -2. - */ - const ROUND_FLOOR = \NumberFormatter::ROUND_FLOOR; - - /** - * Rounds a number away from zero. - * - * Rounds 1.4 to 2 and -1.4 to -2. - */ - const ROUND_UP = \NumberFormatter::ROUND_UP; - - /** - * Rounds a number towards zero. - * - * Rounds 1.4 to 1 and -1.4 to -1. - */ - const ROUND_DOWN = \NumberFormatter::ROUND_DOWN; - - /** - * Rounds to the nearest number and halves to the next even number. - * - * Rounds 2.5, 1.6 and 1.5 to 2 and 1.4 to 1. - */ - const ROUND_HALF_EVEN = \NumberFormatter::ROUND_HALFEVEN; - - /** - * Rounds to the nearest number and halves away from zero. - * - * Rounds 2.5 to 3, 1.6 and 1.5 to 2 and 1.4 to 1. - */ - const ROUND_HALF_UP = \NumberFormatter::ROUND_HALFUP; - - /** - * Rounds to the nearest number and halves towards zero. - * - * Rounds 2.5 and 1.6 to 2, 1.5 and 1.4 to 1. - */ - const ROUND_HALF_DOWN = \NumberFormatter::ROUND_HALFDOWN; - - /** - * Alias for {@link self::ROUND_HALF_EVEN}. - * - * @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0. - */ - const ROUND_HALFEVEN = self::ROUND_HALF_EVEN; - - /** - * Alias for {@link self::ROUND_HALF_UP}. - * - * @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0. - */ - const ROUND_HALFUP = self::ROUND_HALF_UP; - - /** - * Alias for {@link self::ROUND_HALF_DOWN}. - * - * @deprecated Deprecated as of Symfony 2.4, to be removed in Symfony 3.0. - */ - const ROUND_HALFDOWN = self::ROUND_HALF_DOWN; - - protected $precision; - - protected $grouping; - - protected $roundingMode; - - public function __construct($precision = null, $grouping = false, $roundingMode = self::ROUND_HALF_UP) - { - if (null === $grouping) { - $grouping = false; - } - - if (null === $roundingMode) { - $roundingMode = self::ROUND_HALF_UP; - } - - $this->precision = $precision; - $this->grouping = $grouping; - $this->roundingMode = $roundingMode; - } - - /** - * Transforms a number type into localized number. - * - * @param int|float $value Number value. - * - * @return string Localized value. - * - * @throws TransformationFailedException If the given value is not numeric - * or if the value can not be transformed. - */ - public function transform($value) - { - if (null === $value) { - return ''; - } - - if (!is_numeric($value)) { - throw new TransformationFailedException('Expected a numeric.'); - } - - $formatter = $this->getNumberFormatter(); - $value = $formatter->format($value); - - if (intl_is_failure($formatter->getErrorCode())) { - throw new TransformationFailedException($formatter->getErrorMessage()); - } - - // Convert fixed spaces to normal ones - $value = str_replace("\xc2\xa0", ' ', $value); - - return $value; - } - - /** - * Transforms a localized number into an integer or float. - * - * @param string $value The localized value - * - * @return int|float The numeric value - * - * @throws TransformationFailedException If the given value is not a string - * or if the value can not be transformed. - */ - public function reverseTransform($value) - { - if (!is_string($value)) { - throw new TransformationFailedException('Expected a string.'); - } - - if ('' === $value) { - return; - } - - if ('NaN' === $value) { - throw new TransformationFailedException('"NaN" is not a valid number'); - } - - $position = 0; - $formatter = $this->getNumberFormatter(); - $groupSep = $formatter->getSymbol(\NumberFormatter::GROUPING_SEPARATOR_SYMBOL); - $decSep = $formatter->getSymbol(\NumberFormatter::DECIMAL_SEPARATOR_SYMBOL); - - if ('.' !== $decSep && (!$this->grouping || '.' !== $groupSep)) { - $value = str_replace('.', $decSep, $value); - } - - if (',' !== $decSep && (!$this->grouping || ',' !== $groupSep)) { - $value = str_replace(',', $decSep, $value); - } - - $result = $formatter->parse($value, \NumberFormatter::TYPE_DOUBLE, $position); - - if (intl_is_failure($formatter->getErrorCode())) { - throw new TransformationFailedException($formatter->getErrorMessage()); - } - - if ($result >= PHP_INT_MAX || $result <= -PHP_INT_MAX) { - throw new TransformationFailedException('I don\'t have a clear idea what infinity looks like'); - } - - if (function_exists('mb_detect_encoding') && false !== $encoding = mb_detect_encoding($value)) { - $length = mb_strlen($value, $encoding); - $remainder = mb_substr($value, $position, $length, $encoding); - } else { - $length = strlen($value); - $remainder = substr($value, $position, $length); - } - - // After parsing, position holds the index of the character where the - // parsing stopped - if ($position < $length) { - // Check if there are unrecognized characters at the end of the - // number (excluding whitespace characters) - $remainder = trim($remainder, " \t\n\r\0\x0b\xc2\xa0"); - - if ('' !== $remainder) { - throw new TransformationFailedException( - sprintf('The number contains unrecognized characters: "%s"', $remainder) - ); - } - } - - // NumberFormatter::parse() does not round - return $this->round($result); - } - - /** - * Returns a preconfigured \NumberFormatter instance. - * - * @return \NumberFormatter - */ - protected function getNumberFormatter() - { - $formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL); - - if (null !== $this->precision) { - $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->precision); - $formatter->setAttribute(\NumberFormatter::ROUNDING_MODE, $this->roundingMode); - } - - $formatter->setAttribute(\NumberFormatter::GROUPING_USED, $this->grouping); - - return $formatter; - } - - /** - * Rounds a number according to the configured precision and rounding mode. - * - * @param int|float $number A number. - * - * @return int|float The rounded number. - */ - private function round($number) - { - if (null !== $this->precision && null !== $this->roundingMode) { - // shift number to maintain the correct precision during rounding - $roundingCoef = pow(10, $this->precision); - $number *= $roundingCoef; - - switch ($this->roundingMode) { - case self::ROUND_CEILING: - $number = ceil($number); - break; - case self::ROUND_FLOOR: - $number = floor($number); - break; - case self::ROUND_UP: - $number = $number > 0 ? ceil($number) : floor($number); - break; - case self::ROUND_DOWN: - $number = $number > 0 ? floor($number) : ceil($number); - break; - case self::ROUND_HALF_EVEN: - $number = round($number, 0, PHP_ROUND_HALF_EVEN); - break; - case self::ROUND_HALF_UP: - $number = round($number, 0, PHP_ROUND_HALF_UP); - break; - case self::ROUND_HALF_DOWN: - $number = round($number, 0, PHP_ROUND_HALF_DOWN); - break; - } - - $number /= $roundingCoef; - } - - return $number; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php deleted file mode 100644 index 1db54bf43..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/PercentToLocalizedStringTransformer.php +++ /dev/null @@ -1,149 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -/** - * Transforms between a normalized format (integer or float) and a percentage value. - * - * @author Bernhard Schussek - * @author Florian Eckerstorfer - */ -class PercentToLocalizedStringTransformer implements DataTransformerInterface -{ - const FRACTIONAL = 'fractional'; - const INTEGER = 'integer'; - - protected static $types = array( - self::FRACTIONAL, - self::INTEGER, - ); - - private $type; - - private $precision; - - /** - * Constructor. - * - * @see self::$types for a list of supported types - * - * @param int $precision The precision - * @param string $type One of the supported types - * - * @throws UnexpectedTypeException if the given value of type is unknown - */ - public function __construct($precision = null, $type = null) - { - if (null === $precision) { - $precision = 0; - } - - if (null === $type) { - $type = self::FRACTIONAL; - } - - if (!in_array($type, self::$types, true)) { - throw new UnexpectedTypeException($type, implode('", "', self::$types)); - } - - $this->type = $type; - $this->precision = $precision; - } - - /** - * Transforms between a normalized format (integer or float) into a percentage value. - * - * @param int|float $value Normalized value - * - * @return string Percentage value - * - * @throws TransformationFailedException If the given value is not numeric or - * if the value could not be transformed. - */ - public function transform($value) - { - if (null === $value) { - return ''; - } - - if (!is_numeric($value)) { - throw new TransformationFailedException('Expected a numeric.'); - } - - if (self::FRACTIONAL == $this->type) { - $value *= 100; - } - - $formatter = $this->getNumberFormatter(); - $value = $formatter->format($value); - - if (intl_is_failure($formatter->getErrorCode())) { - throw new TransformationFailedException($formatter->getErrorMessage()); - } - - // replace the UTF-8 non break spaces - return $value; - } - - /** - * Transforms between a percentage value into a normalized format (integer or float). - * - * @param string $value Percentage value. - * - * @return int|float Normalized value. - * - * @throws TransformationFailedException If the given value is not a string or - * if the value could not be transformed. - */ - public function reverseTransform($value) - { - if (!is_string($value)) { - throw new TransformationFailedException('Expected a string.'); - } - - if ('' === $value) { - return; - } - - $formatter = $this->getNumberFormatter(); - // replace normal spaces so that the formatter can read them - $value = $formatter->parse(str_replace(' ', ' ', $value)); - - if (intl_is_failure($formatter->getErrorCode())) { - throw new TransformationFailedException($formatter->getErrorMessage()); - } - - if (self::FRACTIONAL == $this->type) { - $value /= 100; - } - - return $value; - } - - /** - * Returns a preconfigured \NumberFormatter instance. - * - * @return \NumberFormatter - */ - protected function getNumberFormatter() - { - $formatter = new \NumberFormatter(\Locale::getDefault(), \NumberFormatter::DECIMAL); - - $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->precision); - - return $formatter; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php deleted file mode 100644 index ffc9915fa..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/DataTransformer/ValueToDuplicatesTransformer.php +++ /dev/null @@ -1,91 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\DataTransformer; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * @author Bernhard Schussek - */ -class ValueToDuplicatesTransformer implements DataTransformerInterface -{ - private $keys; - - public function __construct(array $keys) - { - $this->keys = $keys; - } - - /** - * Duplicates the given value through the array. - * - * @param mixed $value The value - * - * @return array The array - */ - public function transform($value) - { - $result = array(); - - foreach ($this->keys as $key) { - $result[$key] = $value; - } - - return $result; - } - - /** - * Extracts the duplicated value from an array. - * - * @param array $array - * - * @return mixed The value - * - * @throws TransformationFailedException If the given value is not an array or - * if the given array can not be transformed. - */ - public function reverseTransform($array) - { - if (!is_array($array)) { - throw new TransformationFailedException('Expected an array.'); - } - - $result = current($array); - $emptyKeys = array(); - - foreach ($this->keys as $key) { - if (isset($array[$key]) && '' !== $array[$key] && false !== $array[$key] && array() !== $array[$key]) { - if ($array[$key] !== $result) { - throw new TransformationFailedException( - 'All values in the array should be the same' - ); - } - } else { - $emptyKeys[] = $key; - } - } - - if (count($emptyKeys) > 0) { - if (count($emptyKeys) == count($this->keys)) { - // All keys empty - return; - } - - throw new TransformationFailedException( - sprintf('The keys "%s" should not be empty', implode('", "', $emptyKeys) - )); - } - - return $result; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php deleted file mode 100644 index 8e72b0413..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixCheckboxInputListener.php +++ /dev/null @@ -1,96 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\EventListener; - -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; - -/** - * Takes care of converting the input from a list of checkboxes to a correctly - * indexed array. - * - * @author Bernhard Schussek - */ -class FixCheckboxInputListener implements EventSubscriberInterface -{ - private $choiceList; - - /** - * Constructor. - * - * @param ChoiceListInterface $choiceList - */ - public function __construct(ChoiceListInterface $choiceList) - { - $this->choiceList = $choiceList; - } - - public function preSubmit(FormEvent $event) - { - $data = $event->getData(); - - if (is_array($data)) { - // Flip the submitted values for faster lookup - // It's better to flip this array than $existingValues because - // $submittedValues is generally smaller. - $submittedValues = array_flip($data); - - // Since expanded choice fields are completely loaded anyway, we - // can just as well get the values again without losing performance. - $existingValues = $this->choiceList->getValues(); - - // Clear the data array and fill it with correct indices - $data = array(); - - foreach ($existingValues as $index => $value) { - if (isset($submittedValues[$value])) { - // Value was submitted - $data[$index] = $value; - unset($submittedValues[$value]); - } - } - - if (count($submittedValues) > 0) { - throw new TransformationFailedException(sprintf( - 'The following choices were not found: "%s"', - implode('", "', array_keys($submittedValues)) - )); - } - } elseif ('' === $data || null === $data) { - // Empty values are always accepted. - $data = array(); - } - - // Else leave the data unchanged to provoke an error during submission - - $event->setData($data); - } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - $this->preSubmit($event); - } - - public static function getSubscribedEvents() - { - return array(FormEvents::PRE_SUBMIT => 'preSubmit'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php deleted file mode 100644 index a3e27d57e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixRadioInputListener.php +++ /dev/null @@ -1,78 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\EventListener; - -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface; - -/** - * Takes care of converting the input from a single radio button - * to an array. - * - * @author Bernhard Schussek - */ -class FixRadioInputListener implements EventSubscriberInterface -{ - private $choiceList; - - private $placeholderPresent; - - /** - * Constructor. - * - * @param ChoiceListInterface $choiceList - * @param bool $placeholderPresent - */ - public function __construct(ChoiceListInterface $choiceList, $placeholderPresent) - { - $this->choiceList = $choiceList; - $this->placeholderPresent = $placeholderPresent; - } - - public function preSubmit(FormEvent $event) - { - $data = $event->getData(); - - // Since expanded choice fields are completely loaded anyway, we - // can just as well get the values again without losing performance. - $existingValues = $this->choiceList->getValues(); - - if (false !== ($index = array_search($data, $existingValues, true))) { - $data = array($index => $data); - } elseif ('' === $data || null === $data) { - // Empty values are always accepted. - $data = $this->placeholderPresent ? array('placeholder' => '') : array(); - } - - // Else leave the data unchanged to provoke an error during submission - - $event->setData($data); - } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - $this->preSubmit($event); - } - - public static function getSubscribedEvents() - { - return array(FormEvents::PRE_SUBMIT => 'preSubmit'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php deleted file mode 100644 index 4a5a1df6a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/FixUrlProtocolListener.php +++ /dev/null @@ -1,61 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\EventListener; - -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Adds a protocol to a URL if it doesn't already have one. - * - * @author Bernhard Schussek - */ -class FixUrlProtocolListener implements EventSubscriberInterface -{ - private $defaultProtocol; - - /** - * Constructor. - * - * @param string|null $defaultProtocol The URL scheme to add when there is none or null to not modify the data - */ - public function __construct($defaultProtocol = 'http') - { - $this->defaultProtocol = $defaultProtocol; - } - - public function onSubmit(FormEvent $event) - { - $data = $event->getData(); - - if ($this->defaultProtocol && $data && !preg_match('~^\w+://~', $data)) { - $event->setData($this->defaultProtocol.'://'.$data); - } - } - - /** - * Alias of {@link onSubmit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link onSubmit()} instead. - */ - public function onBind(FormEvent $event) - { - $this->onSubmit($event); - } - - public static function getSubscribedEvents() - { - return array(FormEvents::SUBMIT => 'onSubmit'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php deleted file mode 100644 index a14f99a98..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/MergeCollectionListener.php +++ /dev/null @@ -1,139 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -/** - * @author Bernhard Schussek - */ -class MergeCollectionListener implements EventSubscriberInterface -{ - /** - * Whether elements may be added to the collection. - * - * @var bool - */ - private $allowAdd; - - /** - * Whether elements may be removed from the collection. - * - * @var bool - */ - private $allowDelete; - - /** - * Creates a new listener. - * - * @param bool $allowAdd Whether values might be added to the - * collection. - * @param bool $allowDelete Whether values might be removed from the - * collection. - */ - public function __construct($allowAdd = false, $allowDelete = false) - { - $this->allowAdd = $allowAdd; - $this->allowDelete = $allowDelete; - } - - public static function getSubscribedEvents() - { - return array( - FormEvents::SUBMIT => 'onSubmit', - ); - } - - public function onSubmit(FormEvent $event) - { - $dataToMergeInto = $event->getForm()->getNormData(); - $data = $event->getData(); - - if (null === $data) { - $data = array(); - } - - if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) { - throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)'); - } - - if (null !== $dataToMergeInto && !is_array($dataToMergeInto) && !($dataToMergeInto instanceof \Traversable && $dataToMergeInto instanceof \ArrayAccess)) { - throw new UnexpectedTypeException($dataToMergeInto, 'array or (\Traversable and \ArrayAccess)'); - } - - // If we are not allowed to change anything, return immediately - if ((!$this->allowAdd && !$this->allowDelete) || $data === $dataToMergeInto) { - $event->setData($dataToMergeInto); - - return; - } - - if (!$dataToMergeInto) { - // No original data was set. Set it if allowed - if ($this->allowAdd) { - $dataToMergeInto = $data; - } - } else { - // Calculate delta - $itemsToAdd = is_object($data) ? clone $data : $data; - $itemsToDelete = array(); - - foreach ($dataToMergeInto as $beforeKey => $beforeItem) { - foreach ($data as $afterKey => $afterItem) { - if ($afterItem === $beforeItem) { - // Item found, next original item - unset($itemsToAdd[$afterKey]); - continue 2; - } - } - - // Item not found, remember for deletion - $itemsToDelete[] = $beforeKey; - } - - // Remove deleted items before adding to free keys that are to be - // replaced - if ($this->allowDelete) { - foreach ($itemsToDelete as $key) { - unset($dataToMergeInto[$key]); - } - } - - // Add remaining items - if ($this->allowAdd) { - foreach ($itemsToAdd as $key => $item) { - if (!isset($dataToMergeInto[$key])) { - $dataToMergeInto[$key] = $item; - } else { - $dataToMergeInto[] = $item; - } - } - } - } - - $event->setData($dataToMergeInto); - } - - /** - * Alias of {@link onSubmit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link onSubmit()} instead. - */ - public function onBind(FormEvent $event) - { - $this->onSubmit($event); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php deleted file mode 100644 index 043cc2759..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php +++ /dev/null @@ -1,205 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\EventListener; - -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Resize a collection form element based on the data sent from the client. - * - * @author Bernhard Schussek - */ -class ResizeFormListener implements EventSubscriberInterface -{ - /** - * @var string - */ - protected $type; - - /** - * @var array - */ - protected $options; - - /** - * Whether children could be added to the group. - * - * @var bool - */ - protected $allowAdd; - - /** - * Whether children could be removed from the group. - * - * @var bool - */ - protected $allowDelete; - - /** - * @var bool - */ - private $deleteEmpty; - - public function __construct($type, array $options = array(), $allowAdd = false, $allowDelete = false, $deleteEmpty = false) - { - $this->type = $type; - $this->allowAdd = $allowAdd; - $this->allowDelete = $allowDelete; - $this->options = $options; - $this->deleteEmpty = $deleteEmpty; - } - - public static function getSubscribedEvents() - { - return array( - FormEvents::PRE_SET_DATA => 'preSetData', - FormEvents::PRE_SUBMIT => 'preSubmit', - // (MergeCollectionListener, MergeDoctrineCollectionListener) - FormEvents::SUBMIT => array('onSubmit', 50), - ); - } - - public function preSetData(FormEvent $event) - { - $form = $event->getForm(); - $data = $event->getData(); - - if (null === $data) { - $data = array(); - } - - if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) { - throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)'); - } - - // First remove all rows - foreach ($form as $name => $child) { - $form->remove($name); - } - - // Then add all rows again in the correct order - foreach ($data as $name => $value) { - $form->add($name, $this->type, array_replace(array( - 'property_path' => '['.$name.']', - ), $this->options)); - } - } - - public function preSubmit(FormEvent $event) - { - $form = $event->getForm(); - $data = $event->getData(); - - if (null === $data || '' === $data) { - $data = array(); - } - - if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) { - throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)'); - } - - // Remove all empty rows - if ($this->allowDelete) { - foreach ($form as $name => $child) { - if (!isset($data[$name])) { - $form->remove($name); - } - } - } - - // Add all additional rows - if ($this->allowAdd) { - foreach ($data as $name => $value) { - if (!$form->has($name)) { - $form->add($name, $this->type, array_replace(array( - 'property_path' => '['.$name.']', - ), $this->options)); - } - } - } - } - - public function onSubmit(FormEvent $event) - { - $form = $event->getForm(); - $data = $event->getData(); - - // At this point, $data is an array or an array-like object that already contains the - // new entries, which were added by the data mapper. The data mapper ignores existing - // entries, so we need to manually unset removed entries in the collection. - - if (null === $data) { - $data = array(); - } - - if (!is_array($data) && !($data instanceof \Traversable && $data instanceof \ArrayAccess)) { - throw new UnexpectedTypeException($data, 'array or (\Traversable and \ArrayAccess)'); - } - - if ($this->deleteEmpty) { - $previousData = $event->getForm()->getData(); - foreach ($form as $name => $child) { - $isNew = !isset($previousData[$name]); - - // $isNew can only be true if allowAdd is true, so we don't - // need to check allowAdd again - if ($child->isEmpty() && ($isNew || $this->allowDelete)) { - unset($data[$name]); - $form->remove($name); - } - } - } - - // The data mapper only adds, but does not remove items, so do this - // here - if ($this->allowDelete) { - $toDelete = array(); - - foreach ($data as $name => $child) { - if (!$form->has($name)) { - $toDelete[] = $name; - } - } - - foreach ($toDelete as $name) { - unset($data[$name]); - } - } - - $event->setData($data); - } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - $this->preSubmit($event); - } - - /** - * Alias of {@link onSubmit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link onSubmit()} instead. - */ - public function onBind(FormEvent $event) - { - $this->onSubmit($event); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php deleted file mode 100644 index eaec5c163..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/EventListener/TrimListener.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\EventListener; - -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -/** - * Trims string data. - * - * @author Bernhard Schussek - */ -class TrimListener implements EventSubscriberInterface -{ - public function preSubmit(FormEvent $event) - { - $data = $event->getData(); - - if (!is_string($data)) { - return; - } - - if (null !== $result = @preg_replace('/^[\pZ\p{Cc}]+|[\pZ\p{Cc}]+$/u', '', $data)) { - $event->setData($result); - } else { - $event->setData(trim($data)); - } - } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - $this->preSubmit($event); - } - - public static function getSubscribedEvents() - { - return array(FormEvents::PRE_SUBMIT => 'preSubmit'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BaseType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BaseType.php deleted file mode 100644 index e9b733cf8..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BaseType.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * Encapsulates common logic of {@link FormType} and {@link ButtonType}. - * - * This type does not appear in the form's type inheritance chain and as such - * cannot be extended (via {@link FormTypeExtension}s) nor themed. - * - * @author Bernhard Schussek - */ -abstract class BaseType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->setDisabled($options['disabled']); - $builder->setAutoInitialize($options['auto_initialize']); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $name = $form->getName(); - $blockName = $options['block_name'] ?: $form->getName(); - $translationDomain = $options['translation_domain']; - $labelFormat = $options['label_format']; - - if ($view->parent) { - if ('' !== ($parentFullName = $view->parent->vars['full_name'])) { - $id = sprintf('%s_%s', $view->parent->vars['id'], $name); - $fullName = sprintf('%s[%s]', $parentFullName, $name); - $uniqueBlockPrefix = sprintf('%s_%s', $view->parent->vars['unique_block_prefix'], $blockName); - } else { - $id = $name; - $fullName = $name; - $uniqueBlockPrefix = '_'.$blockName; - } - - if (null === $translationDomain) { - $translationDomain = $view->parent->vars['translation_domain']; - } - - if (!$labelFormat) { - $labelFormat = $view->parent->vars['label_format']; - } - } else { - $id = $name; - $fullName = $name; - $uniqueBlockPrefix = '_'.$blockName; - - // Strip leading underscores and digits. These are allowed in - // form names, but not in HTML4 ID attributes. - // http://www.w3.org/TR/html401/struct/global.html#adef-id - $id = ltrim($id, '_0123456789'); - } - - $blockPrefixes = array(); - for ($type = $form->getConfig()->getType(); null !== $type; $type = $type->getParent()) { - array_unshift($blockPrefixes, $type->getName()); - } - $blockPrefixes[] = $uniqueBlockPrefix; - - $view->vars = array_replace($view->vars, array( - 'form' => $view, - 'id' => $id, - 'name' => $name, - 'full_name' => $fullName, - 'disabled' => $form->isDisabled(), - 'label' => $options['label'], - 'label_format' => $labelFormat, - 'multipart' => false, - 'attr' => $options['attr'], - 'block_prefixes' => $blockPrefixes, - 'unique_block_prefix' => $uniqueBlockPrefix, - 'translation_domain' => $translationDomain, - // Using the block name here speeds up performance in collection - // forms, where each entry has the same full block name. - // Including the type is important too, because if rows of a - // collection form have different types (dynamically), they should - // be rendered differently. - // https://github.com/symfony/symfony/issues/5038 - 'cache_key' => $uniqueBlockPrefix.'_'.$form->getConfig()->getType()->getName(), - )); - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'block_name' => null, - 'disabled' => false, - 'label' => null, - 'label_format' => null, - 'attr' => array(), - 'translation_domain' => null, - 'auto_initialize' => true, - )); - - $resolver->setAllowedTypes(array( - 'attr' => 'array', - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php deleted file mode 100644 index f90f57d4b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/BirthdayType.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class BirthdayType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'years' => range(date('Y') - 120, date('Y')), - )); - - $resolver->setAllowedTypes(array( - 'years' => 'array', - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'date'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'birthday'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ButtonType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ButtonType.php deleted file mode 100644 index c4b97652c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ButtonType.php +++ /dev/null @@ -1,50 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\ButtonTypeInterface; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * A form button. - * - * @author Bernhard Schussek - */ -class ButtonType extends BaseType implements ButtonTypeInterface -{ - /** - * {@inheritdoc} - */ - public function getParent() - { - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'button'; - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - parent::setDefaultOptions($resolver); - - $resolver->setDefaults(array( - 'auto_initialize' => false, - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php deleted file mode 100644 index 13c78041d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CheckboxType.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class CheckboxType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - // Unlike in other types, where the data is NULL by default, it - // needs to be a Boolean here. setData(null) is not acceptable - // for checkboxes and radio buttons (unless a custom model - // transformer handles this case). - // We cannot solve this case via overriding the "data" option, because - // doing so also calls setDataLocked(true). - $builder->setData(isset($options['data']) ? $options['data'] : false); - $builder->addViewTransformer(new BooleanToStringTransformer($options['value'])); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars = array_replace($view->vars, array( - 'value' => $options['value'], - 'checked' => null !== $form->getViewData(), - )); - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $emptyData = function (FormInterface $form, $viewData) { - return $viewData; - }; - - $resolver->setDefaults(array( - 'value' => '1', - 'empty_data' => $emptyData, - 'compound' => false, - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'checkbox'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php deleted file mode 100644 index a987c0528..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ /dev/null @@ -1,288 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Exception\LogicException; -use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; -use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener; -use Symfony\Component\Form\Extension\Core\EventListener\FixCheckboxInputListener; -use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener; -use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToValueTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToBooleanArrayTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToBooleanArrayTransformer; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class ChoiceType extends AbstractType -{ - /** - * Caches created choice lists. - * - * @var array - */ - private $choiceListCache = array(); - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - if (!$options['choice_list'] && !is_array($options['choices']) && !$options['choices'] instanceof \Traversable) { - throw new LogicException('Either the option "choices" or "choice_list" must be set.'); - } - - if ($options['expanded']) { - // Initialize all choices before doing the index check below. - // This helps in cases where index checks are optimized for non - // initialized choice lists. For example, when using an SQL driver, - // the index check would read in one SQL query and the initialization - // requires another SQL query. When the initialization is done first, - // one SQL query is sufficient. - $preferredViews = $options['choice_list']->getPreferredViews(); - $remainingViews = $options['choice_list']->getRemainingViews(); - - // Check if the choices already contain the empty value - // Only add the empty value option if this is not the case - if (null !== $options['placeholder'] && 0 === count($options['choice_list']->getChoicesForValues(array('')))) { - $placeholderView = new ChoiceView(null, '', $options['placeholder']); - - // "placeholder" is a reserved index - $this->addSubForms($builder, array('placeholder' => $placeholderView), $options); - } - - $this->addSubForms($builder, $preferredViews, $options); - $this->addSubForms($builder, $remainingViews, $options); - - if ($options['multiple']) { - $builder->addViewTransformer(new ChoicesToBooleanArrayTransformer($options['choice_list'])); - $builder->addEventSubscriber(new FixCheckboxInputListener($options['choice_list']), 10); - } else { - $builder->addViewTransformer(new ChoiceToBooleanArrayTransformer($options['choice_list'], $builder->has('placeholder'))); - $builder->addEventSubscriber(new FixRadioInputListener($options['choice_list'], $builder->has('placeholder')), 10); - } - } else { - if ($options['multiple']) { - $builder->addViewTransformer(new ChoicesToValuesTransformer($options['choice_list'])); - } else { - $builder->addViewTransformer(new ChoiceToValueTransformer($options['choice_list'])); - } - } - - if ($options['multiple'] && $options['by_reference']) { - // Make sure the collection created during the client->norm - // transformation is merged back into the original collection - $builder->addEventSubscriber(new MergeCollectionListener(true, true)); - } - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars = array_replace($view->vars, array( - 'multiple' => $options['multiple'], - 'expanded' => $options['expanded'], - 'preferred_choices' => $options['choice_list']->getPreferredViews(), - 'choices' => $options['choice_list']->getRemainingViews(), - 'separator' => '-------------------', - 'placeholder' => null, - )); - - // The decision, whether a choice is selected, is potentially done - // thousand of times during the rendering of a template. Provide a - // closure here that is optimized for the value of the form, to - // avoid making the type check inside the closure. - if ($options['multiple']) { - $view->vars['is_selected'] = function ($choice, array $values) { - return in_array($choice, $values, true); - }; - } else { - $view->vars['is_selected'] = function ($choice, $value) { - return $choice === $value; - }; - } - - // Check if the choices already contain the empty value - $view->vars['placeholder_in_choices'] = 0 !== count($options['choice_list']->getChoicesForValues(array(''))); - - // Only add the empty value option if this is not the case - if (null !== $options['placeholder'] && !$view->vars['placeholder_in_choices']) { - $view->vars['placeholder'] = $options['placeholder']; - } - - // BC - $view->vars['empty_value'] = $view->vars['placeholder']; - $view->vars['empty_value_in_choices'] = $view->vars['placeholder_in_choices']; - - if ($options['multiple'] && !$options['expanded']) { - // Add "[]" to the name in case a select tag with multiple options is - // displayed. Otherwise only one of the selected options is sent in the - // POST request. - $view->vars['full_name'] .= '[]'; - } - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - if ($options['expanded']) { - // Radio buttons should have the same name as the parent - $childName = $view->vars['full_name']; - - // Checkboxes should append "[]" to allow multiple selection - if ($options['multiple']) { - $childName .= '[]'; - } - - foreach ($view as $childView) { - $childView->vars['full_name'] = $childName; - } - } - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $choiceListCache = &$this->choiceListCache; - - $choiceList = function (Options $options) use (&$choiceListCache) { - // Harden against NULL values (like in EntityType and ModelType) - $choices = null !== $options['choices'] ? $options['choices'] : array(); - - // Reuse existing choice lists in order to increase performance - $hash = hash('sha256', serialize(array($choices, $options['preferred_choices']))); - - if (!isset($choiceListCache[$hash])) { - $choiceListCache[$hash] = new SimpleChoiceList($choices, $options['preferred_choices']); - } - - return $choiceListCache[$hash]; - }; - - $emptyData = function (Options $options) { - if ($options['multiple'] || $options['expanded']) { - return array(); - } - - return ''; - }; - - $emptyValue = function (Options $options) { - return $options['required'] ? null : ''; - }; - - // for BC with the "empty_value" option - $placeholder = function (Options $options) { - return $options['empty_value']; - }; - - $placeholderNormalizer = function (Options $options, $placeholder) { - if ($options['multiple']) { - // never use an empty value for this case - return; - } elseif (false === $placeholder) { - // an empty value should be added but the user decided otherwise - return; - } elseif ($options['expanded'] && '' === $placeholder) { - // never use an empty label for radio buttons - return 'None'; - } - - // empty value has been set explicitly - return $placeholder; - }; - - $compound = function (Options $options) { - return $options['expanded']; - }; - - $resolver->setDefaults(array( - 'multiple' => false, - 'expanded' => false, - 'choice_list' => $choiceList, - 'choices' => array(), - 'preferred_choices' => array(), - 'empty_data' => $emptyData, - 'empty_value' => $emptyValue, // deprecated - 'placeholder' => $placeholder, - 'error_bubbling' => false, - 'compound' => $compound, - // The view data is always a string, even if the "data" option - // is manually set to an object. - // See https://github.com/symfony/symfony/pull/5582 - 'data_class' => null, - )); - - $resolver->setNormalizers(array( - 'empty_value' => $placeholderNormalizer, - 'placeholder' => $placeholderNormalizer, - )); - - $resolver->setAllowedTypes(array( - 'choice_list' => array('null', 'Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface'), - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'choice'; - } - - /** - * Adds the sub fields for an expanded choice field. - * - * @param FormBuilderInterface $builder The form builder. - * @param array $choiceViews The choice view objects. - * @param array $options The build options. - */ - private function addSubForms(FormBuilderInterface $builder, array $choiceViews, array $options) - { - foreach ($choiceViews as $i => $choiceView) { - if (is_array($choiceView)) { - // Flatten groups - $this->addSubForms($builder, $choiceView, $options); - } else { - $choiceOpts = array( - 'value' => $choiceView->value, - 'label' => $choiceView->label, - 'translation_domain' => $options['translation_domain'], - 'block_name' => 'entry', - ); - - if ($options['multiple']) { - $choiceType = 'checkbox'; - // The user can check 0 or more checkboxes. If required - // is true, he is required to check all of them. - $choiceOpts['required'] = false; - } else { - $choiceType = 'radio'; - } - - $builder->add($i, $choiceType, $choiceOpts); - } - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php deleted file mode 100644 index 2fed7cea8..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CollectionType.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class CollectionType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - if ($options['allow_add'] && $options['prototype']) { - $prototype = $builder->create($options['prototype_name'], $options['type'], array_replace(array( - 'label' => $options['prototype_name'].'label__', - ), $options['options'])); - $builder->setAttribute('prototype', $prototype->getForm()); - } - - $resizeListener = new ResizeFormListener( - $options['type'], - $options['options'], - $options['allow_add'], - $options['allow_delete'], - $options['delete_empty'] - ); - - $builder->addEventSubscriber($resizeListener); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars = array_replace($view->vars, array( - 'allow_add' => $options['allow_add'], - 'allow_delete' => $options['allow_delete'], - )); - - if ($form->getConfig()->hasAttribute('prototype')) { - $view->vars['prototype'] = $form->getConfig()->getAttribute('prototype')->createView($view); - } - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - if ($form->getConfig()->hasAttribute('prototype') && $view->vars['prototype']->vars['multipart']) { - $view->vars['multipart'] = true; - } - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $optionsNormalizer = function (Options $options, $value) { - $value['block_name'] = 'entry'; - - return $value; - }; - - $resolver->setDefaults(array( - 'allow_add' => false, - 'allow_delete' => false, - 'prototype' => true, - 'prototype_name' => '__name__', - 'type' => 'text', - 'options' => array(), - 'delete_empty' => false, - )); - - $resolver->setNormalizers(array( - 'options' => $optionsNormalizer, - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'collection'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CountryType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CountryType.php deleted file mode 100644 index 3482ba663..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CountryType.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Intl\Intl; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class CountryType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'choices' => Intl::getRegionBundle()->getCountryNames(), - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'choice'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'country'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php deleted file mode 100644 index 3a925e3a3..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/CurrencyType.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Intl\Intl; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class CurrencyType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'choices' => Intl::getCurrencyBundle()->getCurrencyNames(), - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'choice'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'currency'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php deleted file mode 100644 index 252d37008..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php +++ /dev/null @@ -1,292 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\ReversedTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class DateTimeType extends AbstractType -{ - const DEFAULT_DATE_FORMAT = \IntlDateFormatter::MEDIUM; - - const DEFAULT_TIME_FORMAT = \IntlDateFormatter::MEDIUM; - - /** - * This is not quite the HTML5 format yet, because ICU lacks the - * capability of parsing and generating RFC 3339 dates, which - * are like the below pattern but with a timezone suffix. The - * timezone suffix is. - * - * * "Z" for UTC - * * "(-|+)HH:mm" for other timezones (note the colon!) - * - * For more information see: - * - * http://userguide.icu-project.org/formatparse/datetime#TOC-Date-Time-Format-Syntax - * http://www.w3.org/TR/html-markup/input.datetime.html - * http://tools.ietf.org/html/rfc3339 - * - * An ICU ticket was created: - * http://icu-project.org/trac/ticket/9421 - * - * It was supposedly fixed, but is not available in all PHP installations - * yet. To temporarily circumvent this issue, DateTimeToRfc3339Transformer - * is used when the format matches this constant. - */ - const HTML5_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZZZZZ"; - - private static $acceptedFormats = array( - \IntlDateFormatter::FULL, - \IntlDateFormatter::LONG, - \IntlDateFormatter::MEDIUM, - \IntlDateFormatter::SHORT, - ); - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $parts = array('year', 'month', 'day', 'hour'); - $dateParts = array('year', 'month', 'day'); - $timeParts = array('hour'); - - if ($options['with_minutes']) { - $parts[] = 'minute'; - $timeParts[] = 'minute'; - } - - if ($options['with_seconds']) { - $parts[] = 'second'; - $timeParts[] = 'second'; - } - - $dateFormat = is_int($options['date_format']) ? $options['date_format'] : self::DEFAULT_DATE_FORMAT; - $timeFormat = self::DEFAULT_TIME_FORMAT; - $calendar = \IntlDateFormatter::GREGORIAN; - $pattern = is_string($options['format']) ? $options['format'] : null; - - if (!in_array($dateFormat, self::$acceptedFormats, true)) { - throw new InvalidOptionsException('The "date_format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom format.'); - } - - if ('single_text' === $options['widget']) { - if (self::HTML5_FORMAT === $pattern) { - $builder->addViewTransformer(new DateTimeToRfc3339Transformer( - $options['model_timezone'], - $options['view_timezone'] - )); - } else { - $builder->addViewTransformer(new DateTimeToLocalizedStringTransformer( - $options['model_timezone'], - $options['view_timezone'], - $dateFormat, - $timeFormat, - $calendar, - $pattern - )); - } - } else { - // Only pass a subset of the options to children - $dateOptions = array_intersect_key($options, array_flip(array( - 'years', - 'months', - 'days', - 'empty_value', - 'placeholder', - 'required', - 'translation_domain', - 'html5', - 'invalid_message', - 'invalid_message_parameters', - ))); - - $timeOptions = array_intersect_key($options, array_flip(array( - 'hours', - 'minutes', - 'seconds', - 'with_minutes', - 'with_seconds', - 'empty_value', - 'placeholder', - 'required', - 'translation_domain', - 'html5', - 'invalid_message', - 'invalid_message_parameters', - ))); - - if (null !== $options['date_widget']) { - $dateOptions['widget'] = $options['date_widget']; - } - - if (null !== $options['time_widget']) { - $timeOptions['widget'] = $options['time_widget']; - } - - if (null !== $options['date_format']) { - $dateOptions['format'] = $options['date_format']; - } - - $dateOptions['input'] = $timeOptions['input'] = 'array'; - $dateOptions['error_bubbling'] = $timeOptions['error_bubbling'] = true; - - $builder - ->addViewTransformer(new DataTransformerChain(array( - new DateTimeToArrayTransformer($options['model_timezone'], $options['view_timezone'], $parts), - new ArrayToPartsTransformer(array( - 'date' => $dateParts, - 'time' => $timeParts, - )), - ))) - ->add('date', 'date', $dateOptions) - ->add('time', 'time', $timeOptions) - ; - } - - if ('string' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToStringTransformer($options['model_timezone'], $options['model_timezone']) - )); - } elseif ('timestamp' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToTimestampTransformer($options['model_timezone'], $options['model_timezone']) - )); - } elseif ('array' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToArrayTransformer($options['model_timezone'], $options['model_timezone'], $parts) - )); - } - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['widget'] = $options['widget']; - - // Change the input to a HTML5 datetime input if - // * the widget is set to "single_text" - // * the format matches the one expected by HTML5 - // * the html5 is set to true - if ($options['html5'] && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { - $view->vars['type'] = 'datetime'; - } - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $compound = function (Options $options) { - return $options['widget'] !== 'single_text'; - }; - - // Defaults to the value of "widget" - $dateWidget = function (Options $options) { - return $options['widget']; - }; - - // Defaults to the value of "widget" - $timeWidget = function (Options $options) { - return $options['widget']; - }; - - $resolver->setDefaults(array( - 'input' => 'datetime', - 'model_timezone' => null, - 'view_timezone' => null, - 'format' => self::HTML5_FORMAT, - 'date_format' => null, - 'widget' => null, - 'date_widget' => $dateWidget, - 'time_widget' => $timeWidget, - 'with_minutes' => true, - 'with_seconds' => false, - 'html5' => true, - // Don't modify \DateTime classes by reference, we treat - // them like immutable value objects - 'by_reference' => false, - 'error_bubbling' => false, - // If initialized with a \DateTime object, FormType initializes - // this option to "\DateTime". Since the internal, normalized - // representation is not \DateTime, but an array, we need to unset - // this option. - 'data_class' => null, - 'compound' => $compound, - )); - - // Don't add some defaults in order to preserve the defaults - // set in DateType and TimeType - $resolver->setDefined(array( - 'empty_value', // deprecated - 'placeholder', - 'years', - 'months', - 'days', - 'hours', - 'minutes', - 'seconds', - )); - - $resolver->setAllowedValues(array( - 'input' => array( - 'datetime', - 'string', - 'timestamp', - 'array', - ), - 'date_widget' => array( - null, // inherit default from DateType - 'single_text', - 'text', - 'choice', - ), - 'time_widget' => array( - null, // inherit default from TimeType - 'single_text', - 'text', - 'choice', - ), - // This option will overwrite "date_widget" and "time_widget" options - 'widget' => array( - null, // default, don't overwrite options - 'single_text', - 'text', - 'choice', - ), - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'datetime'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateType.php deleted file mode 100644 index dc553ad8d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/DateType.php +++ /dev/null @@ -1,328 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; -use Symfony\Component\Form\ReversedTransformer; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; -use Symfony\Component\OptionsResolver\Exception\InvalidOptionsException; - -class DateType extends AbstractType -{ - const DEFAULT_FORMAT = \IntlDateFormatter::MEDIUM; - - const HTML5_FORMAT = 'yyyy-MM-dd'; - - private static $acceptedFormats = array( - \IntlDateFormatter::FULL, - \IntlDateFormatter::LONG, - \IntlDateFormatter::MEDIUM, - \IntlDateFormatter::SHORT, - ); - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $dateFormat = is_int($options['format']) ? $options['format'] : self::DEFAULT_FORMAT; - $timeFormat = \IntlDateFormatter::NONE; - $calendar = \IntlDateFormatter::GREGORIAN; - $pattern = is_string($options['format']) ? $options['format'] : null; - - if (!in_array($dateFormat, self::$acceptedFormats, true)) { - throw new InvalidOptionsException('The "format" option must be one of the IntlDateFormatter constants (FULL, LONG, MEDIUM, SHORT) or a string representing a custom format.'); - } - - if (null !== $pattern && (false === strpos($pattern, 'y') || false === strpos($pattern, 'M') || false === strpos($pattern, 'd'))) { - throw new InvalidOptionsException(sprintf('The "format" option should contain the letters "y", "M" and "d". Its current value is "%s".', $pattern)); - } - - if ('single_text' === $options['widget']) { - $builder->addViewTransformer(new DateTimeToLocalizedStringTransformer( - null, - null, - $dateFormat, - $timeFormat, - $calendar, - $pattern - )); - } else { - $yearOptions = $monthOptions = $dayOptions = array( - 'error_bubbling' => true, - ); - - $formatter = new \IntlDateFormatter( - \Locale::getDefault(), - $dateFormat, - $timeFormat, - null, - $calendar, - $pattern - ); - - // new \intlDateFormatter may return null instead of false in case of failure, see https://bugs.php.net/bug.php?id=66323 - if (!$formatter) { - throw new InvalidOptionsException(intl_get_error_message(), intl_get_error_code()); - } - - $formatter->setLenient(false); - - if ('choice' === $options['widget']) { - // Only pass a subset of the options to children - $yearOptions['choices'] = $this->formatTimestamps($formatter, '/y+/', $this->listYears($options['years'])); - $yearOptions['placeholder'] = $options['placeholder']['year']; - $monthOptions['choices'] = $this->formatTimestamps($formatter, '/[M|L]+/', $this->listMonths($options['months'])); - $monthOptions['placeholder'] = $options['placeholder']['month']; - $dayOptions['choices'] = $this->formatTimestamps($formatter, '/d+/', $this->listDays($options['days'])); - $dayOptions['placeholder'] = $options['placeholder']['day']; - } - - // Append generic carry-along options - foreach (array('required', 'translation_domain') as $passOpt) { - $yearOptions[$passOpt] = $monthOptions[$passOpt] = $dayOptions[$passOpt] = $options[$passOpt]; - } - - $builder - ->add('year', $options['widget'], $yearOptions) - ->add('month', $options['widget'], $monthOptions) - ->add('day', $options['widget'], $dayOptions) - ->addViewTransformer(new DateTimeToArrayTransformer( - null, null, array('year', 'month', 'day') - )) - ->setAttribute('formatter', $formatter) - ; - } - - if ('string' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToStringTransformer(null, null, 'Y-m-d') - )); - } elseif ('timestamp' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToTimestampTransformer(null, null) - )); - } elseif ('array' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day')) - )); - } - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - $view->vars['widget'] = $options['widget']; - - // Change the input to a HTML5 date input if - // * the widget is set to "single_text" - // * the format matches the one expected by HTML5 - // * the html5 is set to true - if ($options['html5'] && 'single_text' === $options['widget'] && self::HTML5_FORMAT === $options['format']) { - $view->vars['type'] = 'date'; - } - - if ($form->getConfig()->hasAttribute('formatter')) { - $pattern = $form->getConfig()->getAttribute('formatter')->getPattern(); - - // remove special characters unless the format was explicitly specified - if (!is_string($options['format'])) { - $pattern = preg_replace('/[^yMd]+/', '', $pattern); - } - - // set right order with respect to locale (e.g.: de_DE=dd.MM.yy; en_US=M/d/yy) - // lookup various formats at http://userguide.icu-project.org/formatparse/datetime - if (preg_match('/^([yMd]+)[^yMd]*([yMd]+)[^yMd]*([yMd]+)$/', $pattern)) { - $pattern = preg_replace(array('/y+/', '/M+/', '/d+/'), array('{{ year }}', '{{ month }}', '{{ day }}'), $pattern); - } else { - // default fallback - $pattern = '{{ year }}{{ month }}{{ day }}'; - } - - $view->vars['date_pattern'] = $pattern; - } - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $compound = function (Options $options) { - return $options['widget'] !== 'single_text'; - }; - - $emptyValue = $placeholderDefault = function (Options $options) { - return $options['required'] ? null : ''; - }; - - $placeholder = function (Options $options) { - return $options['empty_value']; - }; - - $placeholderNormalizer = function (Options $options, $placeholder) use ($placeholderDefault) { - if (is_array($placeholder)) { - $default = $placeholderDefault($options); - - return array_merge( - array('year' => $default, 'month' => $default, 'day' => $default), - $placeholder - ); - } - - return array( - 'year' => $placeholder, - 'month' => $placeholder, - 'day' => $placeholder, - ); - }; - - $format = function (Options $options) { - return $options['widget'] === 'single_text' ? DateType::HTML5_FORMAT : DateType::DEFAULT_FORMAT; - }; - - $resolver->setDefaults(array( - 'years' => range(date('Y') - 5, date('Y') + 5), - 'months' => range(1, 12), - 'days' => range(1, 31), - 'widget' => 'choice', - 'input' => 'datetime', - 'format' => $format, - 'model_timezone' => null, - 'view_timezone' => null, - 'empty_value' => $emptyValue, // deprecated - 'placeholder' => $placeholder, - 'html5' => true, - // Don't modify \DateTime classes by reference, we treat - // them like immutable value objects - 'by_reference' => false, - 'error_bubbling' => false, - // If initialized with a \DateTime object, FormType initializes - // this option to "\DateTime". Since the internal, normalized - // representation is not \DateTime, but an array, we need to unset - // this option. - 'data_class' => null, - 'compound' => $compound, - )); - - $resolver->setNormalizers(array( - 'empty_value' => $placeholderNormalizer, - 'placeholder' => $placeholderNormalizer, - )); - - $resolver->setAllowedValues(array( - 'input' => array( - 'datetime', - 'string', - 'timestamp', - 'array', - ), - 'widget' => array( - 'single_text', - 'text', - 'choice', - ), - )); - - $resolver->setAllowedTypes(array( - 'format' => array('int', 'string'), - 'years' => 'array', - 'months' => 'array', - 'days' => 'array', - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'date'; - } - - private function formatTimestamps(\IntlDateFormatter $formatter, $regex, array $timestamps) - { - $pattern = $formatter->getPattern(); - $timezone = $formatter->getTimezoneId(); - - if ($setTimeZone = method_exists($formatter, 'setTimeZone')) { - $formatter->setTimeZone('UTC'); - } else { - $formatter->setTimeZoneId('UTC'); - } - - if (preg_match($regex, $pattern, $matches)) { - $formatter->setPattern($matches[0]); - - foreach ($timestamps as $key => $timestamp) { - $timestamps[$key] = $formatter->format($timestamp); - } - - // I'd like to clone the formatter above, but then we get a - // segmentation fault, so let's restore the old state instead - $formatter->setPattern($pattern); - } - - if ($setTimeZone) { - $formatter->setTimeZone($timezone); - } else { - $formatter->setTimeZoneId($timezone); - } - - return $timestamps; - } - - private function listYears(array $years) - { - $result = array(); - - foreach ($years as $year) { - if (false !== $y = gmmktime(0, 0, 0, 6, 15, $year)) { - $result[$year] = $y; - } - } - - return $result; - } - - private function listMonths(array $months) - { - $result = array(); - - foreach ($months as $month) { - $result[$month] = gmmktime(0, 0, 0, $month, 15); - } - - return $result; - } - - private function listDays(array $days) - { - $result = array(); - - foreach ($days as $day) { - $result[$day] = gmmktime(0, 0, 0, 5, $day); - } - - return $result; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/EmailType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/EmailType.php deleted file mode 100644 index 26652ef66..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/EmailType.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; - -class EmailType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'text'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'email'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FileType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FileType.php deleted file mode 100644 index 0f7bb3c7c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FileType.php +++ /dev/null @@ -1,67 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class FileType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - if ($options['multiple']) { - $view->vars['full_name'] .= '[]'; - $view->vars['attr']['multiple'] = 'multiple'; - } - - $view->vars = array_replace($view->vars, array( - 'type' => 'file', - 'value' => '', - )); - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - $view - ->vars['multipart'] = true - ; - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'compound' => false, - 'data_class' => 'Symfony\Component\HttpFoundation\File\File', - 'empty_data' => null, - 'multiple' => false, - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'file'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FormType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FormType.php deleted file mode 100644 index 627d1557b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/FormType.php +++ /dev/null @@ -1,231 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Extension\Core\EventListener\TrimListener; -use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; -use Symfony\Component\Form\Exception\LogicException; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; -use Symfony\Component\PropertyAccess\PropertyAccess; -use Symfony\Component\PropertyAccess\PropertyAccessorInterface; - -class FormType extends BaseType -{ - /** - * @var PropertyAccessorInterface - */ - private $propertyAccessor; - - public function __construct(PropertyAccessorInterface $propertyAccessor = null) - { - $this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor(); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - parent::buildForm($builder, $options); - - $isDataOptionSet = array_key_exists('data', $options); - - $builder - ->setRequired($options['required']) - ->setErrorBubbling($options['error_bubbling']) - ->setEmptyData($options['empty_data']) - ->setPropertyPath($options['property_path']) - ->setMapped($options['mapped']) - ->setByReference($options['by_reference']) - ->setInheritData($options['inherit_data']) - ->setCompound($options['compound']) - ->setData($isDataOptionSet ? $options['data'] : null) - ->setDataLocked($isDataOptionSet) - ->setDataMapper($options['compound'] ? new PropertyPathMapper($this->propertyAccessor) : null) - ->setMethod($options['method']) - ->setAction($options['action']); - - if ($options['trim']) { - $builder->addEventSubscriber(new TrimListener()); - } - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - parent::buildView($view, $form, $options); - - $name = $form->getName(); - $readOnly = $options['read_only']; - - if ($view->parent) { - if ('' === $name) { - throw new LogicException('Form node with empty name can be used only as root form node.'); - } - - // Complex fields are read-only if they themselves or their parents are. - if (!$readOnly) { - $readOnly = $view->parent->vars['read_only']; - } - } - - $view->vars = array_replace($view->vars, array( - 'read_only' => $readOnly, - 'errors' => $form->getErrors(), - 'valid' => $form->isSubmitted() ? $form->isValid() : true, - 'value' => $form->getViewData(), - 'data' => $form->getNormData(), - 'required' => $form->isRequired(), - 'max_length' => isset($options['attr']['maxlength']) ? $options['attr']['maxlength'] : null, // Deprecated - 'pattern' => isset($options['attr']['pattern']) ? $options['attr']['pattern'] : null, // Deprecated - 'size' => null, - 'label_attr' => $options['label_attr'], - 'compound' => $form->getConfig()->getCompound(), - 'method' => $form->getConfig()->getMethod(), - 'action' => $form->getConfig()->getAction(), - 'submitted' => $form->isSubmitted(), - )); - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - $multipart = false; - - foreach ($view->children as $child) { - if ($child->vars['multipart']) { - $multipart = true; - break; - } - } - - $view->vars['multipart'] = $multipart; - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - parent::setDefaultOptions($resolver); - - // Derive "data_class" option from passed "data" object - $dataClass = function (Options $options) { - return isset($options['data']) && is_object($options['data']) ? get_class($options['data']) : null; - }; - - // Derive "empty_data" closure from "data_class" option - $emptyData = function (Options $options) { - $class = $options['data_class']; - - if (null !== $class) { - return function (FormInterface $form) use ($class) { - return $form->isEmpty() && !$form->isRequired() ? null : new $class(); - }; - } - - return function (FormInterface $form) { - return $form->getConfig()->getCompound() ? array() : ''; - }; - }; - - // For any form that is not represented by a single HTML control, - // errors should bubble up by default - $errorBubbling = function (Options $options) { - return $options['compound']; - }; - - // BC with old "virtual" option - $inheritData = function (Options $options) { - if (null !== $options['virtual']) { - // Uncomment this as soon as the deprecation note should be shown - // trigger_error('The form option "virtual" is deprecated since version 2.3 and will be removed in 3.0. Use "inherit_data" instead.', E_USER_DEPRECATED); - return $options['virtual']; - } - - return false; - }; - - // If data is given, the form is locked to that data - // (independent of its value) - $resolver->setDefined(array( - 'data', - )); - - // BC clause for the "max_length" and "pattern" option - // Add these values to the "attr" option instead - $defaultAttr = function (Options $options) { - $attributes = array(); - - if (null !== $options['max_length']) { - $attributes['maxlength'] = $options['max_length']; - } - - if (null !== $options['pattern']) { - $attributes['pattern'] = $options['pattern']; - } - - return $attributes; - }; - - $resolver->setDefaults(array( - 'data_class' => $dataClass, - 'empty_data' => $emptyData, - 'trim' => true, - 'required' => true, - 'read_only' => false, - 'max_length' => null, - 'pattern' => null, - 'property_path' => null, - 'mapped' => true, - 'by_reference' => true, - 'error_bubbling' => $errorBubbling, - 'label_attr' => array(), - 'virtual' => null, - 'inherit_data' => $inheritData, - 'compound' => true, - 'method' => 'POST', - // According to RFC 2396 (http://www.ietf.org/rfc/rfc2396.txt) - // section 4.2., empty URIs are considered same-document references - 'action' => '', - 'attr' => $defaultAttr, - 'post_max_size_message' => 'The uploaded file was too large. Please try to upload a smaller file.', - )); - - $resolver->setAllowedTypes(array( - 'label_attr' => 'array', - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'form'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/HiddenType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/HiddenType.php deleted file mode 100644 index 352b34620..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/HiddenType.php +++ /dev/null @@ -1,40 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class HiddenType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - // hidden fields cannot have a required attribute - 'required' => false, - // Pass errors to the parent - 'error_bubbling' => true, - 'compound' => false, - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'hidden'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/IntegerType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/IntegerType.php deleted file mode 100644 index 575dcb1fb..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/IntegerType.php +++ /dev/null @@ -1,68 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class IntegerType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addViewTransformer( - new IntegerToLocalizedStringTransformer( - $options['precision'], - $options['grouping'], - $options['rounding_mode'] - )); - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - // default precision is locale specific (usually around 3) - 'precision' => null, - 'grouping' => false, - // Integer cast rounds towards 0, so do the same when displaying fractions - 'rounding_mode' => IntegerToLocalizedStringTransformer::ROUND_DOWN, - 'compound' => false, - )); - - $resolver->setAllowedValues(array( - 'rounding_mode' => array( - IntegerToLocalizedStringTransformer::ROUND_FLOOR, - IntegerToLocalizedStringTransformer::ROUND_DOWN, - IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN, - IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN, - IntegerToLocalizedStringTransformer::ROUND_HALF_UP, - IntegerToLocalizedStringTransformer::ROUND_UP, - IntegerToLocalizedStringTransformer::ROUND_CEILING, - ), - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'integer'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LanguageType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LanguageType.php deleted file mode 100644 index 37b2bf330..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LanguageType.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Intl\Intl; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class LanguageType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'choices' => Intl::getLanguageBundle()->getLanguageNames(), - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'choice'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'language'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LocaleType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LocaleType.php deleted file mode 100644 index 4610c1b45..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/LocaleType.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Intl\Intl; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class LocaleType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'choices' => Intl::getLocaleBundle()->getLocaleNames(), - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'choice'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'locale'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/MoneyType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/MoneyType.php deleted file mode 100644 index 9653d6f8a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/MoneyType.php +++ /dev/null @@ -1,111 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class MoneyType extends AbstractType -{ - protected static $patterns = array(); - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder - ->addViewTransformer(new MoneyToLocalizedStringTransformer( - $options['precision'], - $options['grouping'], - null, - $options['divisor'] - )) - ; - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['money_pattern'] = self::getPattern($options['currency']); - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'precision' => 2, - 'grouping' => false, - 'divisor' => 1, - 'currency' => 'EUR', - 'compound' => false, - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'money'; - } - - /** - * Returns the pattern for this locale. - * - * The pattern contains the placeholder "{{ widget }}" where the HTML tag should - * be inserted - */ - protected static function getPattern($currency) - { - if (!$currency) { - return '{{ widget }}'; - } - - $locale = \Locale::getDefault(); - - if (!isset(self::$patterns[$locale])) { - self::$patterns[$locale] = array(); - } - - if (!isset(self::$patterns[$locale][$currency])) { - $format = new \NumberFormatter($locale, \NumberFormatter::CURRENCY); - $pattern = $format->formatCurrency('123', $currency); - - // the spacings between currency symbol and number are ignored, because - // a single space leads to better readability in combination with input - // fields - - // the regex also considers non-break spaces (0xC2 or 0xA0 in UTF-8) - - preg_match('/^([^\s\xc2\xa0]*)[\s\xc2\xa0]*123(?:[,.]0+)?[\s\xc2\xa0]*([^\s\xc2\xa0]*)$/u', $pattern, $matches); - - if (!empty($matches[1])) { - self::$patterns[$locale][$currency] = $matches[1].' {{ widget }}'; - } elseif (!empty($matches[2])) { - self::$patterns[$locale][$currency] = '{{ widget }} '.$matches[2]; - } else { - self::$patterns[$locale][$currency] = '{{ widget }}'; - } - } - - return self::$patterns[$locale][$currency]; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/NumberType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/NumberType.php deleted file mode 100644 index 5b06e88bb..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/NumberType.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class NumberType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addViewTransformer(new NumberToLocalizedStringTransformer( - $options['precision'], - $options['grouping'], - $options['rounding_mode'] - )); - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - // default precision is locale specific (usually around 3) - 'precision' => null, - 'grouping' => false, - 'rounding_mode' => NumberToLocalizedStringTransformer::ROUND_HALF_UP, - 'compound' => false, - )); - - $resolver->setAllowedValues(array( - 'rounding_mode' => array( - NumberToLocalizedStringTransformer::ROUND_FLOOR, - NumberToLocalizedStringTransformer::ROUND_DOWN, - NumberToLocalizedStringTransformer::ROUND_HALF_DOWN, - NumberToLocalizedStringTransformer::ROUND_HALF_EVEN, - NumberToLocalizedStringTransformer::ROUND_HALF_UP, - NumberToLocalizedStringTransformer::ROUND_UP, - NumberToLocalizedStringTransformer::ROUND_CEILING, - ), - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'number'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PasswordType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PasswordType.php deleted file mode 100644 index 8f5633c6d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PasswordType.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class PasswordType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - if ($options['always_empty'] || !$form->isSubmitted()) { - $view->vars['value'] = ''; - } - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'always_empty' => true, - 'trim' => false, - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'text'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'password'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PercentType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PercentType.php deleted file mode 100644 index 079eca049..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/PercentType.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class PercentType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addViewTransformer(new PercentToLocalizedStringTransformer($options['precision'], $options['type'])); - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'precision' => 0, - 'type' => 'fractional', - 'compound' => false, - )); - - $resolver->setAllowedValues(array( - 'type' => array( - 'fractional', - 'integer', - ), - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'percent'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RadioType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RadioType.php deleted file mode 100644 index dfa7c7d53..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RadioType.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; - -class RadioType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'checkbox'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'radio'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php deleted file mode 100644 index 47a329935..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/RepeatedType.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class RepeatedType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - // Overwrite required option for child fields - $options['first_options']['required'] = $options['required']; - $options['second_options']['required'] = $options['required']; - - if (!isset($options['options']['error_bubbling'])) { - $options['options']['error_bubbling'] = $options['error_bubbling']; - } - - $builder - ->addViewTransformer(new ValueToDuplicatesTransformer(array( - $options['first_name'], - $options['second_name'], - ))) - ->add($options['first_name'], $options['type'], array_merge($options['options'], $options['first_options'])) - ->add($options['second_name'], $options['type'], array_merge($options['options'], $options['second_options'])) - ; - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'type' => 'text', - 'options' => array(), - 'first_options' => array(), - 'second_options' => array(), - 'first_name' => 'first', - 'second_name' => 'second', - 'error_bubbling' => false, - )); - - $resolver->setAllowedTypes(array( - 'options' => 'array', - 'first_options' => 'array', - 'second_options' => 'array', - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'repeated'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ResetType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ResetType.php deleted file mode 100644 index cf55f7c59..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/ResetType.php +++ /dev/null @@ -1,39 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\ButtonTypeInterface; - -/** - * A reset button. - * - * @author Bernhard Schussek - */ -class ResetType extends AbstractType implements ButtonTypeInterface -{ - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'button'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'reset'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SearchType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SearchType.php deleted file mode 100644 index bf82972d5..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SearchType.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; - -class SearchType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'text'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'search'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SubmitType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SubmitType.php deleted file mode 100644 index 6d160b969..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/SubmitType.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\SubmitButtonTypeInterface; - -/** - * A submit button. - * - * @author Bernhard Schussek - */ -class SubmitType extends AbstractType implements SubmitButtonTypeInterface -{ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['clicked'] = $form->isClicked(); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'button'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'submit'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextType.php deleted file mode 100644 index 11503261c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextType.php +++ /dev/null @@ -1,36 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class TextType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'compound' => false, - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'text'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextareaType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextareaType.php deleted file mode 100644 index 0e749b155..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TextareaType.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\FormInterface; - -class TextareaType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars['pattern'] = null; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'text'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'textarea'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimeType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimeType.php deleted file mode 100644 index 4fd2cba56..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimeType.php +++ /dev/null @@ -1,250 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\ReversedTransformer; -use Symfony\Component\Form\Exception\InvalidConfigurationException; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; -use Symfony\Component\Form\FormView; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class TimeType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $parts = array('hour'); - $format = 'H'; - - if ($options['with_seconds'] && !$options['with_minutes']) { - throw new InvalidConfigurationException('You can not disable minutes if you have enabled seconds.'); - } - - if ($options['with_minutes']) { - $format .= ':i'; - $parts[] = 'minute'; - } - - if ($options['with_seconds']) { - $format .= ':s'; - $parts[] = 'second'; - } - - if ('single_text' === $options['widget']) { - $builder->addViewTransformer(new DateTimeToStringTransformer(null, null, $format)); - } else { - $hourOptions = $minuteOptions = $secondOptions = array( - 'error_bubbling' => true, - ); - - if ('choice' === $options['widget']) { - $hours = $minutes = array(); - - foreach ($options['hours'] as $hour) { - $hours[$hour] = str_pad($hour, 2, '0', STR_PAD_LEFT); - } - - // Only pass a subset of the options to children - $hourOptions['choices'] = $hours; - $hourOptions['placeholder'] = $options['placeholder']['hour']; - - if ($options['with_minutes']) { - foreach ($options['minutes'] as $minute) { - $minutes[$minute] = str_pad($minute, 2, '0', STR_PAD_LEFT); - } - - $minuteOptions['choices'] = $minutes; - $minuteOptions['placeholder'] = $options['placeholder']['minute']; - } - - if ($options['with_seconds']) { - $seconds = array(); - - foreach ($options['seconds'] as $second) { - $seconds[$second] = str_pad($second, 2, '0', STR_PAD_LEFT); - } - - $secondOptions['choices'] = $seconds; - $secondOptions['placeholder'] = $options['placeholder']['second']; - } - - // Append generic carry-along options - foreach (array('required', 'translation_domain') as $passOpt) { - $hourOptions[$passOpt] = $options[$passOpt]; - - if ($options['with_minutes']) { - $minuteOptions[$passOpt] = $options[$passOpt]; - } - - if ($options['with_seconds']) { - $secondOptions[$passOpt] = $options[$passOpt]; - } - } - } - - $builder->add('hour', $options['widget'], $hourOptions); - - if ($options['with_minutes']) { - $builder->add('minute', $options['widget'], $minuteOptions); - } - - if ($options['with_seconds']) { - $builder->add('second', $options['widget'], $secondOptions); - } - - $builder->addViewTransformer(new DateTimeToArrayTransformer(null, null, $parts, 'text' === $options['widget'])); - } - - if ('string' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToStringTransformer(null, null, 'H:i:s') - )); - } elseif ('timestamp' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToTimestampTransformer(null, null) - )); - } elseif ('array' === $options['input']) { - $builder->addModelTransformer(new ReversedTransformer( - new DateTimeToArrayTransformer(null, null, $parts) - )); - } - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $view->vars = array_replace($view->vars, array( - 'widget' => $options['widget'], - 'with_minutes' => $options['with_minutes'], - 'with_seconds' => $options['with_seconds'], - )); - - // Change the input to a HTML5 time input if - // * the widget is set to "single_text" - // * the html5 is set to true - if ($options['html5'] && 'single_text' === $options['widget']) { - $view->vars['type'] = 'time'; - - // we need to force the browser to display the seconds by - // adding the HTML attribute step if not already defined. - // Otherwise the browser will not display and so not send the seconds - // therefore the value will always be considered as invalid. - if ($options['with_seconds'] && !isset($view->vars['attr']['step'])) { - $view->vars['attr']['step'] = 1; - } - } - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $compound = function (Options $options) { - return $options['widget'] !== 'single_text'; - }; - - $emptyValue = $placeholderDefault = function (Options $options) { - return $options['required'] ? null : ''; - }; - - // for BC with the "empty_value" option - $placeholder = function (Options $options) { - return $options['empty_value']; - }; - - $placeholderNormalizer = function (Options $options, $placeholder) use ($placeholderDefault) { - if (is_array($placeholder)) { - $default = $placeholderDefault($options); - - return array_merge( - array('hour' => $default, 'minute' => $default, 'second' => $default), - $placeholder - ); - } - - return array( - 'hour' => $placeholder, - 'minute' => $placeholder, - 'second' => $placeholder, - ); - }; - - $resolver->setDefaults(array( - 'hours' => range(0, 23), - 'minutes' => range(0, 59), - 'seconds' => range(0, 59), - 'widget' => 'choice', - 'input' => 'datetime', - 'with_minutes' => true, - 'with_seconds' => false, - 'model_timezone' => null, - 'view_timezone' => null, - 'empty_value' => $emptyValue, // deprecated - 'placeholder' => $placeholder, - 'html5' => true, - // Don't modify \DateTime classes by reference, we treat - // them like immutable value objects - 'by_reference' => false, - 'error_bubbling' => false, - // If initialized with a \DateTime object, FormType initializes - // this option to "\DateTime". Since the internal, normalized - // representation is not \DateTime, but an array, we need to unset - // this option. - 'data_class' => null, - 'compound' => $compound, - )); - - $resolver->setNormalizers(array( - 'empty_value' => $placeholderNormalizer, - 'placeholder' => $placeholderNormalizer, - )); - - $resolver->setAllowedValues(array( - 'input' => array( - 'datetime', - 'string', - 'timestamp', - 'array', - ), - 'widget' => array( - 'single_text', - 'text', - 'choice', - ), - )); - - $resolver->setAllowedTypes(array( - 'hours' => 'array', - 'minutes' => 'array', - 'seconds' => 'array', - )); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'time'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php deleted file mode 100644 index 96b140776..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/TimezoneType.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class TimezoneType extends AbstractType -{ - /** - * Stores the available timezone choices. - * - * @var array - */ - private static $timezones; - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'choices' => self::getTimezones(), - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'choice'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'timezone'; - } - - /** - * Returns the timezone choices. - * - * The choices are generated from the ICU function - * \DateTimeZone::listIdentifiers(). They are cached during a single request, - * so multiple timezone fields on the same page don't lead to unnecessary - * overhead. - * - * @return array The timezone choices - */ - public static function getTimezones() - { - if (null === static::$timezones) { - static::$timezones = array(); - - foreach (\DateTimeZone::listIdentifiers() as $timezone) { - $parts = explode('/', $timezone); - - if (count($parts) > 2) { - $region = $parts[0]; - $name = $parts[1].' - '.$parts[2]; - } elseif (count($parts) > 1) { - $region = $parts[0]; - $name = $parts[1]; - } else { - $region = 'Other'; - $name = $parts[0]; - } - - static::$timezones[$region][$timezone] = str_replace('_', ' ', $name); - } - } - - return static::$timezones; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/UrlType.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/UrlType.php deleted file mode 100644 index 5c414afc9..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/Type/UrlType.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -class UrlType extends AbstractType -{ - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - if (null !== $options['default_protocol']) { - $builder->addEventSubscriber(new FixUrlProtocolListener($options['default_protocol'])); - } - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'default_protocol' => 'http', - )); - - $resolver->setAllowedTypes(array( - 'default_protocol' => array('null', 'string'), - )); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return 'text'; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'url'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/View/ChoiceView.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Core/View/ChoiceView.php deleted file mode 100644 index 97cdd214c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Core/View/ChoiceView.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Core\View; - -/** - * Represents a choice in templates. - * - * @author Bernhard Schussek - */ -class ChoiceView -{ - /** - * The original choice value. - * - * @var mixed - */ - public $data; - - /** - * The view representation of the choice. - * - * @var string - */ - public $value; - - /** - * The label displayed to humans. - * - * @var string - */ - public $label; - - /** - * Creates a new ChoiceView. - * - * @param mixed $data The original choice. - * @param string $value The view representation of the choice. - * @param string $label The label displayed to humans. - */ - public function __construct($data, $value, $label) - { - $this->data = $data; - $this->value = $value; - $this->label = $label; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfExtension.php deleted file mode 100644 index 0bc8ca7db..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfExtension.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf; - -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderAdapter; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface; -use Symfony\Component\Form\AbstractExtension; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * This extension protects forms by using a CSRF token. - * - * @author Bernhard Schussek - */ -class CsrfExtension extends AbstractExtension -{ - /** - * @var CsrfTokenManagerInterface - */ - private $tokenManager; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var null|string - */ - private $translationDomain; - - /** - * Constructor. - * - * @param CsrfTokenManagerInterface $tokenManager The CSRF token manager - * @param TranslatorInterface $translator The translator for translating error messages - * @param null|string $translationDomain The translation domain for translating - */ - public function __construct($tokenManager, TranslatorInterface $translator = null, $translationDomain = null) - { - if ($tokenManager instanceof CsrfProviderInterface) { - $tokenManager = new CsrfProviderAdapter($tokenManager); - } elseif (!$tokenManager instanceof CsrfTokenManagerInterface) { - throw new UnexpectedTypeException($tokenManager, 'CsrfProviderInterface or CsrfTokenManagerInterface'); - } - - $this->tokenManager = $tokenManager; - $this->translator = $translator; - $this->translationDomain = $translationDomain; - } - - /** - * {@inheritdoc} - */ - protected function loadTypeExtensions() - { - return array( - new Type\FormTypeCsrfExtension($this->tokenManager, true, '_token', $this->translator, $this->translationDomain), - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php deleted file mode 100644 index 39d52e5c6..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderAdapter.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -use Symfony\Component\Form\Exception\BadMethodCallException; -use Symfony\Component\Security\Csrf\CsrfToken; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; - -/** - * Adapter for using old CSRF providers where the new {@link CsrfTokenManagerInterface} - * is expected. - * - * @since 2.4 - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.4, to be removed in Symfony 3.0. - */ -class CsrfProviderAdapter implements CsrfTokenManagerInterface -{ - /** - * @var CsrfProviderInterface - */ - private $csrfProvider; - - public function __construct(CsrfProviderInterface $csrfProvider) - { - $this->csrfProvider = $csrfProvider; - } - - public function getCsrfProvider() - { - return $this->csrfProvider; - } - - /** - * {@inheritdoc} - */ - public function getToken($tokenId) - { - return new CsrfToken($tokenId, $this->csrfProvider->generateCsrfToken($tokenId)); - } - - /** - * {@inheritdoc} - */ - public function refreshToken($tokenId) - { - throw new BadMethodCallException('Not supported'); - } - - /** - * {@inheritdoc} - */ - public function removeToken($tokenId) - { - throw new BadMethodCallException('Not supported'); - } - - /** - * {@inheritdoc} - */ - public function isTokenValid(CsrfToken $token) - { - return $this->csrfProvider->isCsrfTokenValid($token->getId(), $token->getValue()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.php deleted file mode 100644 index c1a1c5d54..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfProviderInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -/** - * Marks classes able to provide CSRF protection. - * - * You can generate a CSRF token by using the method generateCsrfToken(). To - * this method you should pass a value that is unique to the page that should - * be secured against CSRF attacks. This value doesn't necessarily have to be - * secret. Implementations of this interface are responsible for adding more - * secret information. - * - * If you want to secure a form submission against CSRF attacks, you could - * supply an "intention" string. This way you make sure that the form can only - * be submitted to pages that are designed to handle the form, that is, that use - * the same intention string to validate the CSRF token with isCsrfTokenValid(). - * - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.4, to be removed in Symfony 3.0. Use - * {@link \Symfony\Component\Security\Csrf\CsrfTokenManagerInterface} - * instead. - */ -interface CsrfProviderInterface -{ - /** - * Generates a CSRF token for a page of your application. - * - * @param string $intention Some value that identifies the action intention - * (i.e. "authenticate"). Doesn't have to be a secret value. - * - * @return string The generated token - */ - public function generateCsrfToken($intention); - - /** - * Validates a CSRF token. - * - * @param string $intention The intention used when generating the CSRF token - * @param string $token The token supplied by the browser - * - * @return bool Whether the token supplied by the browser is correct - */ - public function isCsrfTokenValid($intention, $token); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php deleted file mode 100644 index 5dbffc2cb..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/CsrfTokenManagerAdapter.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -use Symfony\Component\Security\Csrf\CsrfToken; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; - -/** - * Adapter for using the new token generator with the old interface. - * - * @since 2.4 - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.4, to be removed in Symfony 3.0. - */ -class CsrfTokenManagerAdapter implements CsrfProviderInterface -{ - /** - * @var CsrfTokenManagerInterface - */ - private $tokenManager; - - public function __construct(CsrfTokenManagerInterface $tokenManager) - { - $this->tokenManager = $tokenManager; - } - - public function getTokenManager() - { - return $this->tokenManager; - } - - /** - * {@inheritdoc} - */ - public function generateCsrfToken($intention) - { - return $this->tokenManager->getToken($intention)->getValue(); - } - - /** - * {@inheritdoc} - */ - public function isCsrfTokenValid($intention, $token) - { - return $this->tokenManager->isTokenValid(new CsrfToken($intention, $token)); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php deleted file mode 100644 index d9ac68d26..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/DefaultCsrfProvider.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -/** - * Default implementation of CsrfProviderInterface. - * - * This provider uses the session ID returned by session_id() as well as a - * user-defined secret value to secure the CSRF token. - * - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.4, to be removed in Symfony 3.0. Use - * {@link \Symfony\Component\Security\Csrf\CsrfTokenManager} in - * combination with {@link \Symfony\Component\Security\Csrf\TokenStorage\NativeSessionTokenStorage} - * instead. - */ -class DefaultCsrfProvider implements CsrfProviderInterface -{ - /** - * A secret value used for generating the CSRF token. - * - * @var string - */ - protected $secret; - - /** - * Initializes the provider with a secret value. - * - * A recommended value for the secret is a generated value with at least - * 32 characters and mixed letters, digits and special characters. - * - * @param string $secret A secret value included in the CSRF token - */ - public function __construct($secret) - { - $this->secret = $secret; - } - - /** - * {@inheritdoc} - */ - public function generateCsrfToken($intention) - { - return sha1($this->secret.$intention.$this->getSessionId()); - } - - /** - * {@inheritdoc} - */ - public function isCsrfTokenValid($intention, $token) - { - return $token === $this->generateCsrfToken($intention); - } - - /** - * Returns the ID of the user session. - * - * Automatically starts the session if necessary. - * - * @return string The session ID - */ - protected function getSessionId() - { - if (PHP_VERSION_ID >= 50400) { - if (PHP_SESSION_NONE === session_status()) { - session_start(); - } - } elseif (!session_id()) { - session_start(); - } - - return session_id(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/SessionCsrfProvider.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/SessionCsrfProvider.php deleted file mode 100644 index 5691c7c98..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/CsrfProvider/SessionCsrfProvider.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\CsrfProvider; - -use Symfony\Component\HttpFoundation\Session\Session; - -/** - * This provider uses a Symfony Session object to retrieve the user's - * session ID. - * - * @see DefaultCsrfProvider - * - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.4, to be removed in Symfony 3.0. Use - * {@link \Symfony\Component\Security\Csrf\CsrfTokenManager} in - * combination with {@link \Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage} - * instead. - */ -class SessionCsrfProvider extends DefaultCsrfProvider -{ - /** - * The user session from which the session ID is returned. - * - * @var Session - */ - protected $session; - - /** - * Initializes the provider with a Session object and a secret value. - * - * A recommended value for the secret is a generated value with at least - * 32 characters and mixed letters, digits and special characters. - * - * @param Session $session The user session - * @param string $secret A secret value included in the CSRF token - */ - public function __construct(Session $session, $secret) - { - parent::__construct($secret); - - $this->session = $session; - } - - /** - * {@inheritdoc} - */ - protected function getSessionId() - { - $this->session->start(); - - return $this->session->getId(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php deleted file mode 100644 index c6a467eb0..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/EventListener/CsrfValidationListener.php +++ /dev/null @@ -1,128 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderAdapter; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Security\Csrf\CsrfToken; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * @author Bernhard Schussek - */ -class CsrfValidationListener implements EventSubscriberInterface -{ - /** - * The name of the CSRF field. - * - * @var string - */ - private $fieldName; - - /** - * The generator for CSRF tokens. - * - * @var CsrfTokenManagerInterface - */ - private $tokenManager; - - /** - * A text mentioning the tokenId of the CSRF token. - * - * Validation of the token will only succeed if it was generated in the - * same session and with the same tokenId. - * - * @var string - */ - private $tokenId; - - /** - * The message displayed in case of an error. - * - * @var string - */ - private $errorMessage; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var null|string - */ - private $translationDomain; - - public static function getSubscribedEvents() - { - return array( - FormEvents::PRE_SUBMIT => 'preSubmit', - ); - } - - public function __construct($fieldName, $tokenManager, $tokenId, $errorMessage, TranslatorInterface $translator = null, $translationDomain = null) - { - if ($tokenManager instanceof CsrfProviderInterface) { - $tokenManager = new CsrfProviderAdapter($tokenManager); - } elseif (!$tokenManager instanceof CsrfTokenManagerInterface) { - throw new UnexpectedTypeException($tokenManager, 'CsrfProviderInterface or CsrfTokenManagerInterface'); - } - - $this->fieldName = $fieldName; - $this->tokenManager = $tokenManager; - $this->tokenId = $tokenId; - $this->errorMessage = $errorMessage; - $this->translator = $translator; - $this->translationDomain = $translationDomain; - } - - public function preSubmit(FormEvent $event) - { - $form = $event->getForm(); - $data = $event->getData(); - - if ($form->isRoot() && $form->getConfig()->getOption('compound')) { - if (!isset($data[$this->fieldName]) || !$this->tokenManager->isTokenValid(new CsrfToken($this->tokenId, $data[$this->fieldName]))) { - $errorMessage = $this->errorMessage; - - if (null !== $this->translator) { - $errorMessage = $this->translator->trans($errorMessage, array(), $this->translationDomain); - } - - $form->addError(new FormError($errorMessage)); - } - - if (is_array($data)) { - unset($data[$this->fieldName]); - } - } - - $event->setData($data); - } - - /** - * Alias of {@link preSubmit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link preSubmit()} instead. - */ - public function preBind(FormEvent $event) - { - $this->preSubmit($event); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php deleted file mode 100644 index 8043cbb3f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Csrf\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderAdapter; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfTokenManagerAdapter; -use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; -use Symfony\Component\Translation\TranslatorInterface; - -/** - * @author Bernhard Schussek - */ -class FormTypeCsrfExtension extends AbstractTypeExtension -{ - /** - * @var CsrfTokenManagerInterface - */ - private $defaultTokenManager; - - /** - * @var bool - */ - private $defaultEnabled; - - /** - * @var string - */ - private $defaultFieldName; - - /** - * @var TranslatorInterface - */ - private $translator; - - /** - * @var null|string - */ - private $translationDomain; - - public function __construct($defaultTokenManager, $defaultEnabled = true, $defaultFieldName = '_token', TranslatorInterface $translator = null, $translationDomain = null) - { - if ($defaultTokenManager instanceof CsrfProviderInterface) { - $defaultTokenManager = new CsrfProviderAdapter($defaultTokenManager); - } elseif (!$defaultTokenManager instanceof CsrfTokenManagerInterface) { - throw new UnexpectedTypeException($defaultTokenManager, 'CsrfProviderInterface or CsrfTokenManagerInterface'); - } - - $this->defaultTokenManager = $defaultTokenManager; - $this->defaultEnabled = $defaultEnabled; - $this->defaultFieldName = $defaultFieldName; - $this->translator = $translator; - $this->translationDomain = $translationDomain; - } - - /** - * Adds a CSRF field to the form when the CSRF protection is enabled. - * - * @param FormBuilderInterface $builder The form builder - * @param array $options The options - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - if (!$options['csrf_protection']) { - return; - } - - $builder - ->addEventSubscriber(new CsrfValidationListener( - $options['csrf_field_name'], - $options['csrf_token_manager'], - $options['csrf_token_id'] ?: ($builder->getName() ?: get_class($builder->getType()->getInnerType())), - $options['csrf_message'], - $this->translator, - $this->translationDomain - )) - ; - } - - /** - * Adds a CSRF field to the root form view. - * - * @param FormView $view The form view - * @param FormInterface $form The form - * @param array $options The options - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - if ($options['csrf_protection'] && !$view->parent && $options['compound']) { - $factory = $form->getConfig()->getFormFactory(); - $tokenId = $options['csrf_token_id'] ?: ($form->getName() ?: get_class($form->getConfig()->getType()->getInnerType())); - $data = (string) $options['csrf_token_manager']->getToken($tokenId); - - $csrfForm = $factory->createNamed($options['csrf_field_name'], 'hidden', $data, array( - 'mapped' => false, - )); - - $view->children[$options['csrf_field_name']] = $csrfForm->createView($view); - } - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - // BC clause for the "intention" option - $csrfTokenId = function (Options $options) { - return $options['intention']; - }; - - // BC clause for the "csrf_provider" option - $csrfTokenManager = function (Options $options) { - if ($options['csrf_provider'] instanceof CsrfTokenManagerInterface) { - return $options['csrf_provider']; - } - - return $options['csrf_provider'] instanceof CsrfTokenManagerAdapter - ? $options['csrf_provider']->getTokenManager() - : new CsrfProviderAdapter($options['csrf_provider']); - }; - - $resolver->setDefaults(array( - 'csrf_protection' => $this->defaultEnabled, - 'csrf_field_name' => $this->defaultFieldName, - 'csrf_message' => 'The CSRF token is invalid. Please try to resubmit the form.', - 'csrf_token_manager' => $csrfTokenManager, - 'csrf_token_id' => $csrfTokenId, - 'csrf_provider' => $this->defaultTokenManager, - 'intention' => null, - )); - } - - /** - * {@inheritdoc} - */ - public function getExtendedType() - { - return 'form'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/DataCollectorExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/DataCollectorExtension.php deleted file mode 100644 index fbdef26ed..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/DataCollectorExtension.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\AbstractExtension; - -/** - * Extension for collecting data of the forms on a page. - * - * @since 2.4 - * @author Robert Schönthal - * @author Bernhard Schussek - */ -class DataCollectorExtension extends AbstractExtension -{ - /** - * @var EventSubscriberInterface - */ - private $dataCollector; - - public function __construct(FormDataCollectorInterface $dataCollector) - { - $this->dataCollector = $dataCollector; - } - - /** - * {@inheritdoc} - */ - protected function loadTypeExtensions() - { - return array( - new Type\DataCollectorTypeExtension($this->dataCollector), - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php deleted file mode 100644 index 6419af477..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/EventListener/DataCollectorListener.php +++ /dev/null @@ -1,83 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; - -/** - * Listener that invokes a data collector for the {@link FormEvents::POST_SET_DATA} - * and {@link FormEvents::POST_SUBMIT} events. - * - * @since 2.4 - * @author Bernhard Schussek - */ -class DataCollectorListener implements EventSubscriberInterface -{ - /** - * @var FormDataCollectorInterface - */ - private $dataCollector; - - public function __construct(FormDataCollectorInterface $dataCollector) - { - $this->dataCollector = $dataCollector; - } - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return array( - // High priority in order to be called as soon as possible - FormEvents::POST_SET_DATA => array('postSetData', 255), - // Low priority in order to be called as late as possible - FormEvents::POST_SUBMIT => array('postSubmit', -255), - ); - } - - /** - * Listener for the {@link FormEvents::POST_SET_DATA} event. - * - * @param FormEvent $event The event object - */ - public function postSetData(FormEvent $event) - { - if ($event->getForm()->isRoot()) { - // Collect basic information about each form - $this->dataCollector->collectConfiguration($event->getForm()); - - // Collect the default data - $this->dataCollector->collectDefaultData($event->getForm()); - } - } - - /** - * Listener for the {@link FormEvents::POST_SUBMIT} event. - * - * @param FormEvent $event The event object - */ - public function postSubmit(FormEvent $event) - { - if ($event->getForm()->isRoot()) { - // Collect the submitted data of each form - $this->dataCollector->collectSubmittedData($event->getForm()); - - // Assemble a form tree - // This is done again after the view is built, but we need it here as the view is not always created. - $this->dataCollector->buildPreliminaryFormTree($event->getForm()); - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php deleted file mode 100644 index 752a3d066..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataCollector.php +++ /dev/null @@ -1,281 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\Response; -use Symfony\Component\HttpKernel\DataCollector\DataCollector; - -/** - * Data collector for {@link \Symfony\Component\Form\FormInterface} instances. - * - * @since 2.4 - * @author Robert Schönthal - * @author Bernhard Schussek - */ -class FormDataCollector extends DataCollector implements FormDataCollectorInterface -{ - /** - * @var FormDataExtractor - */ - private $dataExtractor; - - /** - * Stores the collected data per {@link FormInterface} instance. - * - * Uses the hashes of the forms as keys. This is preferable over using - * {@link \SplObjectStorage}, because in this way no references are kept - * to the {@link FormInterface} instances. - * - * @var array - */ - private $dataByForm; - - /** - * Stores the collected data per {@link FormView} instance. - * - * Uses the hashes of the views as keys. This is preferable over using - * {@link \SplObjectStorage}, because in this way no references are kept - * to the {@link FormView} instances. - * - * @var array - */ - private $dataByView; - - /** - * Connects {@link FormView} with {@link FormInterface} instances. - * - * Uses the hashes of the views as keys and the hashes of the forms as - * values. This is preferable over storing the objects directly, because - * this way they can safely be discarded by the GC. - * - * @var array - */ - private $formsByView; - - public function __construct(FormDataExtractorInterface $dataExtractor) - { - $this->dataExtractor = $dataExtractor; - $this->data = array( - 'forms' => array(), - 'forms_by_hash' => array(), - 'nb_errors' => 0, - ); - } - - /** - * Does nothing. The data is collected during the form event listeners. - */ - public function collect(Request $request, Response $response, \Exception $exception = null) - { - } - - /** - * {@inheritdoc} - */ - public function associateFormWithView(FormInterface $form, FormView $view) - { - $this->formsByView[spl_object_hash($view)] = spl_object_hash($form); - } - - /** - * {@inheritdoc} - */ - public function collectConfiguration(FormInterface $form) - { - $hash = spl_object_hash($form); - - if (!isset($this->dataByForm[$hash])) { - $this->dataByForm[$hash] = array(); - } - - $this->dataByForm[$hash] = array_replace( - $this->dataByForm[$hash], - $this->dataExtractor->extractConfiguration($form) - ); - - foreach ($form as $child) { - $this->collectConfiguration($child); - } - } - - /** - * {@inheritdoc} - */ - public function collectDefaultData(FormInterface $form) - { - $hash = spl_object_hash($form); - - if (!isset($this->dataByForm[$hash])) { - $this->dataByForm[$hash] = array(); - } - - $this->dataByForm[$hash] = array_replace( - $this->dataByForm[$hash], - $this->dataExtractor->extractDefaultData($form) - ); - - foreach ($form as $child) { - $this->collectDefaultData($child); - } - } - - /** - * {@inheritdoc} - */ - public function collectSubmittedData(FormInterface $form) - { - $hash = spl_object_hash($form); - - if (!isset($this->dataByForm[$hash])) { - // field was created by form event - $this->collectConfiguration($form); - $this->collectDefaultData($form); - } - - $this->dataByForm[$hash] = array_replace( - $this->dataByForm[$hash], - $this->dataExtractor->extractSubmittedData($form) - ); - - // Count errors - if (isset($this->dataByForm[$hash]['errors'])) { - $this->data['nb_errors'] += count($this->dataByForm[$hash]['errors']); - } - - foreach ($form as $child) { - $this->collectSubmittedData($child); - } - } - - /** - * {@inheritdoc} - */ - public function collectViewVariables(FormView $view) - { - $hash = spl_object_hash($view); - - if (!isset($this->dataByView[$hash])) { - $this->dataByView[$hash] = array(); - } - - $this->dataByView[$hash] = array_replace( - $this->dataByView[$hash], - $this->dataExtractor->extractViewVariables($view) - ); - - foreach ($view->children as $child) { - $this->collectViewVariables($child); - } - } - - /** - * {@inheritdoc} - */ - public function buildPreliminaryFormTree(FormInterface $form) - { - $this->data['forms'][$form->getName()] = array(); - - $this->recursiveBuildPreliminaryFormTree($form, $this->data['forms'][$form->getName()], $this->data['forms_by_hash']); - } - - /** - * {@inheritdoc} - */ - public function buildFinalFormTree(FormInterface $form, FormView $view) - { - $this->data['forms'][$form->getName()] = array(); - - $this->recursiveBuildFinalFormTree($form, $view, $this->data['forms'][$form->getName()], $this->data['forms_by_hash']); - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return 'form'; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return $this->data; - } - - private function recursiveBuildPreliminaryFormTree(FormInterface $form, &$output = null, array &$outputByHash) - { - $hash = spl_object_hash($form); - - $output = isset($this->dataByForm[$hash]) - ? $this->dataByForm[$hash] - : array(); - - $outputByHash[$hash] = &$output; - - $output['children'] = array(); - - foreach ($form as $name => $child) { - $output['children'][$name] = array(); - - $this->recursiveBuildPreliminaryFormTree($child, $output['children'][$name], $outputByHash); - } - } - - private function recursiveBuildFinalFormTree(FormInterface $form = null, FormView $view, &$output = null, array &$outputByHash) - { - $viewHash = spl_object_hash($view); - $formHash = null; - - if (null !== $form) { - $formHash = spl_object_hash($form); - } elseif (isset($this->formsByView[$viewHash])) { - // The FormInterface instance of the CSRF token is never contained in - // the FormInterface tree of the form, so we need to get the - // corresponding FormInterface instance for its view in a different way - $formHash = $this->formsByView[$viewHash]; - } - - $output = isset($this->dataByView[$viewHash]) - ? $this->dataByView[$viewHash] - : array(); - - if (null !== $formHash) { - $output = array_replace( - $output, - isset($this->dataByForm[$formHash]) - ? $this->dataByForm[$formHash] - : array() - ); - - $outputByHash[$formHash] = &$output; - } - - $output['children'] = array(); - - foreach ($view->children as $name => $childView) { - // The CSRF token, for example, is never added to the form tree. - // It is only present in the view. - $childForm = null !== $form && $form->has($name) - ? $form->get($name) - : null; - - $output['children'][$name] = array(); - - $this->recursiveBuildFinalFormTree($childForm, $childView, $output['children'][$name], $outputByHash); - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataCollectorInterface.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataCollectorInterface.php deleted file mode 100644 index db7c0f080..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataCollectorInterface.php +++ /dev/null @@ -1,101 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\HttpKernel\DataCollector\DataCollectorInterface; - -/** - * Collects and structures information about forms. - * - * @since 2.4 - * @author Bernhard Schussek - */ -interface FormDataCollectorInterface extends DataCollectorInterface -{ - /** - * Stores configuration data of the given form and its children. - * - * @param FormInterface $form A root form - */ - public function collectConfiguration(FormInterface $form); - - /** - * Stores the default data of the given form and its children. - * - * @param FormInterface $form A root form - */ - public function collectDefaultData(FormInterface $form); - - /** - * Stores the submitted data of the given form and its children. - * - * @param FormInterface $form A root form - */ - public function collectSubmittedData(FormInterface $form); - - /** - * Stores the view variables of the given form view and its children. - * - * @param FormView $view A root form view - */ - public function collectViewVariables(FormView $view); - - /** - * Specifies that the given objects represent the same conceptual form. - * - * @param FormInterface $form A form object - * @param FormView $view A view object - */ - public function associateFormWithView(FormInterface $form, FormView $view); - - /** - * Assembles the data collected about the given form and its children as - * a tree-like data structure. - * - * The result can be queried using {@link getData()}. - * - * @param FormInterface $form A root form - */ - public function buildPreliminaryFormTree(FormInterface $form); - - /** - * Assembles the data collected about the given form and its children as - * a tree-like data structure. - * - * The result can be queried using {@link getData()}. - * - * Contrary to {@link buildPreliminaryFormTree()}, a {@link FormView} - * object has to be passed. The tree structure of this view object will be - * used for structuring the resulting data. That means, if a child is - * present in the view, but not in the form, it will be present in the final - * data array anyway. - * - * When {@link FormView} instances are present in the view tree, for which - * no corresponding {@link FormInterface} objects can be found in the form - * tree, only the view data will be included in the result. If a - * corresponding {@link FormInterface} exists otherwise, call - * {@link associateFormWithView()} before calling this method. - * - * @param FormInterface $form A root form - * @param FormView $view A root view - */ - public function buildFinalFormTree(FormInterface $form, FormView $view); - - /** - * Returns all collected data. - * - * @return array - */ - public function getData(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php deleted file mode 100644 index 0ae5560af..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataExtractor.php +++ /dev/null @@ -1,204 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; -use Symfony\Component\Validator\ConstraintViolationInterface; - -/** - * Default implementation of {@link FormDataExtractorInterface}. - * - * @since 2.4 - * @author Bernhard Schussek - */ -class FormDataExtractor implements FormDataExtractorInterface -{ - /** - * @var ValueExporter - */ - private $valueExporter; - - /** - * Constructs a new data extractor. - */ - public function __construct(ValueExporter $valueExporter = null) - { - $this->valueExporter = $valueExporter ?: new ValueExporter(); - } - - /** - * {@inheritdoc} - */ - public function extractConfiguration(FormInterface $form) - { - $data = array( - 'id' => $this->buildId($form), - 'name' => $form->getName(), - 'type' => $form->getConfig()->getType()->getName(), - 'type_class' => get_class($form->getConfig()->getType()->getInnerType()), - 'synchronized' => $this->valueExporter->exportValue($form->isSynchronized()), - 'passed_options' => array(), - 'resolved_options' => array(), - ); - - foreach ($form->getConfig()->getAttribute('data_collector/passed_options', array()) as $option => $value) { - $data['passed_options'][$option] = $this->valueExporter->exportValue($value); - } - - foreach ($form->getConfig()->getOptions() as $option => $value) { - $data['resolved_options'][$option] = $this->valueExporter->exportValue($value); - } - - ksort($data['passed_options']); - ksort($data['resolved_options']); - - return $data; - } - - /** - * {@inheritdoc} - */ - public function extractDefaultData(FormInterface $form) - { - $data = array( - 'default_data' => array( - 'norm' => $this->valueExporter->exportValue($form->getNormData()), - ), - 'submitted_data' => array(), - ); - - if ($form->getData() !== $form->getNormData()) { - $data['default_data']['model'] = $this->valueExporter->exportValue($form->getData()); - } - - if ($form->getViewData() !== $form->getNormData()) { - $data['default_data']['view'] = $this->valueExporter->exportValue($form->getViewData()); - } - - return $data; - } - - /** - * {@inheritdoc} - */ - public function extractSubmittedData(FormInterface $form) - { - $data = array( - 'submitted_data' => array( - 'norm' => $this->valueExporter->exportValue($form->getNormData()), - ), - 'errors' => array(), - ); - - if ($form->getViewData() !== $form->getNormData()) { - $data['submitted_data']['view'] = $this->valueExporter->exportValue($form->getViewData()); - } - - if ($form->getData() !== $form->getNormData()) { - $data['submitted_data']['model'] = $this->valueExporter->exportValue($form->getData()); - } - - foreach ($form->getErrors() as $error) { - $errorData = array( - 'message' => $error->getMessage(), - 'origin' => is_object($error->getOrigin()) - ? spl_object_hash($error->getOrigin()) - : null, - 'trace' => array(), - ); - - $cause = $error->getCause(); - - while (null !== $cause) { - if ($cause instanceof ConstraintViolationInterface) { - $errorData['trace'][] = array( - 'class' => $this->valueExporter->exportValue(get_class($cause)), - 'root' => $this->valueExporter->exportValue($cause->getRoot()), - 'path' => $this->valueExporter->exportValue($cause->getPropertyPath()), - 'value' => $this->valueExporter->exportValue($cause->getInvalidValue()), - ); - - $cause = method_exists($cause, 'getCause') ? $cause->getCause() : null; - - continue; - } - - if ($cause instanceof \Exception) { - $errorData['trace'][] = array( - 'class' => $this->valueExporter->exportValue(get_class($cause)), - 'message' => $this->valueExporter->exportValue($cause->getMessage()), - ); - - $cause = $cause->getPrevious(); - - continue; - } - - $errorData['trace'][] = $cause; - - break; - } - - $data['errors'][] = $errorData; - } - - $data['synchronized'] = $this->valueExporter->exportValue($form->isSynchronized()); - - return $data; - } - - /** - * {@inheritdoc} - */ - public function extractViewVariables(FormView $view) - { - $data = array(); - - // Set the ID in case no FormInterface object was collected for this - // view - if (!isset($data['id'])) { - $data['id'] = isset($view->vars['id']) ? $view->vars['id'] : null; - } - - if (!isset($data['name'])) { - $data['name'] = isset($view->vars['name']) ? $view->vars['name'] : null; - } - - foreach ($view->vars as $varName => $value) { - $data['view_vars'][$varName] = $this->valueExporter->exportValue($value); - } - - ksort($data['view_vars']); - - return $data; - } - - /** - * Recursively builds an HTML ID for a form. - * - * @param FormInterface $form The form - * - * @return string The HTML ID - */ - private function buildId(FormInterface $form) - { - $id = $form->getName(); - - if (null !== $form->getParent()) { - $id = $this->buildId($form->getParent()).'_'.$id; - } - - return $id; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataExtractorInterface.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataExtractorInterface.php deleted file mode 100644 index d47496552..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/FormDataExtractorInterface.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; - -/** - * Extracts arrays of information out of forms. - * - * @since 2.4 - * @author Bernhard Schussek - */ -interface FormDataExtractorInterface -{ - /** - * Extracts the configuration data of a form. - * - * @param FormInterface $form The form - * - * @return array Information about the form's configuration - */ - public function extractConfiguration(FormInterface $form); - - /** - * Extracts the default data of a form. - * - * @param FormInterface $form The form - * - * @return array Information about the form's default data - */ - public function extractDefaultData(FormInterface $form); - - /** - * Extracts the submitted data of a form. - * - * @param FormInterface $form The form - * - * @return array Information about the form's submitted data - */ - public function extractSubmittedData(FormInterface $form); - - /** - * Extracts the view variables of a form. - * - * @param FormView $view The form view - * - * @return array Information about the view's variables - */ - public function extractViewVariables(FormView $view); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php deleted file mode 100644 index 960048a0c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeDataCollectorProxy.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector\Proxy; - -use Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormFactoryInterface; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\ResolvedFormTypeInterface; - -/** - * Proxy that invokes a data collector when creating a form and its view. - * - * @since 2.4 - * @author Bernhard Schussek - */ -class ResolvedTypeDataCollectorProxy implements ResolvedFormTypeInterface -{ - /** - * @var ResolvedFormTypeInterface - */ - private $proxiedType; - - /** - * @var FormDataCollectorInterface - */ - private $dataCollector; - - public function __construct(ResolvedFormTypeInterface $proxiedType, FormDataCollectorInterface $dataCollector) - { - $this->proxiedType = $proxiedType; - $this->dataCollector = $dataCollector; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->proxiedType->getName(); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return $this->proxiedType->getParent(); - } - - /** - * {@inheritdoc} - */ - public function getInnerType() - { - return $this->proxiedType->getInnerType(); - } - - /** - * {@inheritdoc} - */ - public function getTypeExtensions() - { - return $this->proxiedType->getTypeExtensions(); - } - - /** - * {@inheritdoc} - */ - public function createBuilder(FormFactoryInterface $factory, $name, array $options = array()) - { - $builder = $this->proxiedType->createBuilder($factory, $name, $options); - - $builder->setAttribute('data_collector/passed_options', $options); - $builder->setType($this); - - return $builder; - } - - /** - * {@inheritdoc} - */ - public function createView(FormInterface $form, FormView $parent = null) - { - return $this->proxiedType->createView($form, $parent); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $this->proxiedType->buildForm($builder, $options); - } - - /** - * {@inheritdoc} - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - $this->proxiedType->buildView($view, $form, $options); - } - - /** - * {@inheritdoc} - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - $this->proxiedType->finishView($view, $form, $options); - - // Remember which view belongs to which form instance, so that we can - // get the collected data for a view when its form instance is not - // available (e.g. CSRF token) - $this->dataCollector->associateFormWithView($form, $view); - - // Since the CSRF token is only present in the FormView tree, we also - // need to check the FormView tree instead of calling isRoot() on the - // FormInterface tree - if (null === $view->parent) { - $this->dataCollector->collectViewVariables($view); - - // Re-assemble data, in case FormView instances were added, for - // which no FormInterface instances were present (e.g. CSRF token). - // Since finishView() is called after finishing the views of all - // children, we can safely assume that information has been - // collected about the complete form tree. - $this->dataCollector->buildFinalFormTree($form, $view); - } - } - - /** - * {@inheritdoc} - */ - public function getOptionsResolver() - { - return $this->proxiedType->getOptionsResolver(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php deleted file mode 100644 index c2cb3a034..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Proxy/ResolvedTypeFactoryDataCollectorProxy.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector\Proxy; - -use Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface; -use Symfony\Component\Form\FormTypeInterface; -use Symfony\Component\Form\ResolvedFormTypeFactoryInterface; -use Symfony\Component\Form\ResolvedFormTypeInterface; - -/** - * Proxy that wraps resolved types into {@link ResolvedTypeDataCollectorProxy} - * instances. - * - * @since 2.4 - * @author Bernhard Schussek - */ -class ResolvedTypeFactoryDataCollectorProxy implements ResolvedFormTypeFactoryInterface -{ - /** - * @var ResolvedFormTypeFactoryInterface - */ - private $proxiedFactory; - - /** - * @var FormDataCollectorInterface - */ - private $dataCollector; - - public function __construct(ResolvedFormTypeFactoryInterface $proxiedFactory, FormDataCollectorInterface $dataCollector) - { - $this->proxiedFactory = $proxiedFactory; - $this->dataCollector = $dataCollector; - } - - /** - * {@inheritdoc} - */ - public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ResolvedFormTypeInterface $parent = null) - { - return new ResolvedTypeDataCollectorProxy( - $this->proxiedFactory->createResolvedType($type, $typeExtensions, $parent), - $this->dataCollector - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Type/DataCollectorTypeExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Type/DataCollectorTypeExtension.php deleted file mode 100644 index 2c6ddfe3e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DataCollector/Type/DataCollectorTypeExtension.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DataCollector\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener; -use Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface; -use Symfony\Component\Form\FormBuilderInterface; - -/** - * Type extension for collecting data of a form with this type. - * - * @since 2.4 - * @author Robert Schönthal - * @author Bernhard Schussek - */ -class DataCollectorTypeExtension extends AbstractTypeExtension -{ - /** - * @var \Symfony\Component\EventDispatcher\EventSubscriberInterface - */ - private $listener; - - public function __construct(FormDataCollectorInterface $dataCollector) - { - $this->listener = new DataCollectorListener($dataCollector); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addEventSubscriber($this->listener); - } - - /** - * {@inheritdoc} - */ - public function getExtendedType() - { - return 'form'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php deleted file mode 100644 index 685e8cf29..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/DependencyInjection/DependencyInjectionExtension.php +++ /dev/null @@ -1,98 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\DependencyInjection; - -use Symfony\Component\Form\FormExtensionInterface; -use Symfony\Component\Form\FormTypeGuesserChain; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\DependencyInjection\ContainerInterface; - -class DependencyInjectionExtension implements FormExtensionInterface -{ - private $container; - private $typeServiceIds; - private $typeExtensionServiceIds; - private $guesserServiceIds; - private $guesser; - private $guesserLoaded = false; - - public function __construct(ContainerInterface $container, - array $typeServiceIds, array $typeExtensionServiceIds, - array $guesserServiceIds) - { - $this->container = $container; - $this->typeServiceIds = $typeServiceIds; - $this->typeExtensionServiceIds = $typeExtensionServiceIds; - $this->guesserServiceIds = $guesserServiceIds; - } - - public function getType($name) - { - if (!isset($this->typeServiceIds[$name])) { - throw new InvalidArgumentException(sprintf('The field type "%s" is not registered with the service container.', $name)); - } - - $type = $this->container->get($this->typeServiceIds[$name]); - - if ($type->getName() !== $name) { - throw new InvalidArgumentException( - sprintf('The type name specified for the service "%s" does not match the actual name. Expected "%s", given "%s"', - $this->typeServiceIds[$name], - $name, - $type->getName() - )); - } - - return $type; - } - - public function hasType($name) - { - return isset($this->typeServiceIds[$name]); - } - - public function getTypeExtensions($name) - { - $extensions = array(); - - if (isset($this->typeExtensionServiceIds[$name])) { - foreach ($this->typeExtensionServiceIds[$name] as $serviceId) { - $extensions[] = $this->container->get($serviceId); - } - } - - return $extensions; - } - - public function hasTypeExtensions($name) - { - return isset($this->typeExtensionServiceIds[$name]); - } - - public function getTypeGuesser() - { - if (!$this->guesserLoaded) { - $this->guesserLoaded = true; - $guessers = array(); - - foreach ($this->guesserServiceIds as $serviceId) { - $guessers[] = $this->container->get($serviceId); - } - - if (count($guessers) > 0) { - $this->guesser = new FormTypeGuesserChain($guessers); - } - } - - return $this->guesser; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php deleted file mode 100644 index bb144ed65..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/EventListener/BindRequestListener.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\HttpFoundation\EventListener; - -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\HttpFoundation\Request; - -/** - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Pass the - * Request instance to {@link Form::handleRequest()} instead. - */ -class BindRequestListener implements EventSubscriberInterface -{ - public static function getSubscribedEvents() - { - // High priority in order to supersede other listeners - return array(FormEvents::PRE_SUBMIT => array('preBind', 128)); - } - - public function preBind(FormEvent $event) - { - $form = $event->getForm(); - - /* @var Request $request */ - $request = $event->getData(); - - // Only proceed if we actually deal with a Request - if (!$request instanceof Request) { - return; - } - - // Uncomment this as soon as the deprecation note should be shown - // trigger_error('Passing a Request instance to Form::submit() is deprecated since version 2.3 and will be disabled in 3.0. Call Form::process($request) instead.', E_USER_DEPRECATED); - - $name = $form->getConfig()->getName(); - $default = $form->getConfig()->getCompound() ? array() : null; - - // For request methods that must not have a request body we fetch data - // from the query string. Otherwise we look for data in the request body. - switch ($request->getMethod()) { - case 'GET': - case 'HEAD': - case 'TRACE': - $data = '' === $name - ? $request->query->all() - : $request->query->get($name, $default); - - break; - - default: - if ('' === $name) { - // Form bound without name - $params = $request->request->all(); - $files = $request->files->all(); - } else { - $params = $request->request->get($name, $default); - $files = $request->files->get($name, $default); - } - - if (is_array($params) && is_array($files)) { - $data = array_replace_recursive($params, $files); - } else { - $data = $params ?: $files; - } - - break; - } - - $event->setData($data); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationExtension.php deleted file mode 100644 index 08bd89c9e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationExtension.php +++ /dev/null @@ -1,29 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\HttpFoundation; - -use Symfony\Component\Form\AbstractExtension; - -/** - * Integrates the HttpFoundation component with the Form library. - * - * @author Bernhard Schussek - */ -class HttpFoundationExtension extends AbstractExtension -{ - protected function loadTypeExtensions() - { - return array( - new Type\FormTypeHttpFoundationExtension(), - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php b/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php deleted file mode 100644 index 98bbd4b9c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/HttpFoundationRequestHandler.php +++ /dev/null @@ -1,118 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\HttpFoundation; - -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\RequestHandlerInterface; -use Symfony\Component\Form\Util\ServerParams; -use Symfony\Component\HttpFoundation\Request; - -/** - * A request processor using the {@link Request} class of the HttpFoundation - * component. - * - * @author Bernhard Schussek - */ -class HttpFoundationRequestHandler implements RequestHandlerInterface -{ - /** - * @var ServerParams - */ - private $serverParams; - - /** - * {@inheritdoc} - */ - public function __construct(ServerParams $serverParams = null) - { - $this->serverParams = $serverParams ?: new ServerParams(); - } - - /** - * {@inheritdoc} - */ - public function handleRequest(FormInterface $form, $request = null) - { - if (!$request instanceof Request) { - throw new UnexpectedTypeException($request, 'Symfony\Component\HttpFoundation\Request'); - } - - $name = $form->getName(); - $method = $form->getConfig()->getMethod(); - - if ($method !== $request->getMethod()) { - return; - } - - // For request methods that must not have a request body we fetch data - // from the query string. Otherwise we look for data in the request body. - if ('GET' === $method || 'HEAD' === $method || 'TRACE' === $method) { - if ('' === $name) { - $data = $request->query->all(); - } else { - // Don't submit GET requests if the form's name does not exist - // in the request - if (!$request->query->has($name)) { - return; - } - - $data = $request->query->get($name); - } - } else { - // Mark the form with an error if the uploaded size was too large - // This is done here and not in FormValidator because $_POST is - // empty when that error occurs. Hence the form is never submitted. - $contentLength = $this->serverParams->getContentLength(); - $maxContentLength = $this->serverParams->getPostMaxSize(); - - if (!empty($maxContentLength) && $contentLength > $maxContentLength) { - // Submit the form, but don't clear the default values - $form->submit(null, false); - - $form->addError(new FormError( - $form->getConfig()->getOption('post_max_size_message'), - null, - array('{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize()) - )); - - return; - } - - if ('' === $name) { - $params = $request->request->all(); - $files = $request->files->all(); - } elseif ($request->request->has($name) || $request->files->has($name)) { - $default = $form->getConfig()->getCompound() ? array() : null; - $params = $request->request->get($name, $default); - $files = $request->files->get($name, $default); - } else { - // Don't submit the form if it is not present in the request - return; - } - - if (is_array($params) && is_array($files)) { - $data = array_replace_recursive($params, $files); - } else { - $data = $params ?: $files; - } - } - - // Don't auto-submit the form unless at least one field is present. - if ('' === $name && count(array_intersect_key($data, $form->all())) <= 0) { - return; - } - - $form->submit($data, 'PATCH' !== $method); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/Type/FormTypeHttpFoundationExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/Type/FormTypeHttpFoundationExtension.php deleted file mode 100644 index 9cb0dc447..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/HttpFoundation/Type/FormTypeHttpFoundationExtension.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\HttpFoundation\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener; -use Symfony\Component\Form\RequestHandlerInterface; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; - -/** - * @author Bernhard Schussek - */ -class FormTypeHttpFoundationExtension extends AbstractTypeExtension -{ - /** - * @var BindRequestListener - */ - private $listener; - - /** - * @var RequestHandlerInterface - */ - private $requestHandler; - - /** - * @param RequestHandlerInterface $requestHandler - */ - public function __construct(RequestHandlerInterface $requestHandler = null) - { - $this->listener = new BindRequestListener(); - $this->requestHandler = $requestHandler ?: new HttpFoundationRequestHandler(); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addEventSubscriber($this->listener); - $builder->setRequestHandler($this->requestHandler); - } - - /** - * {@inheritdoc} - */ - public function getExtendedType() - { - return 'form'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php deleted file mode 100644 index 3c29bef57..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingExtension.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Templating; - -use Symfony\Component\Form\AbstractExtension; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderAdapter; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface; -use Symfony\Component\Form\FormRenderer; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; -use Symfony\Component\Templating\PhpEngine; -use Symfony\Bundle\FrameworkBundle\Templating\Helper\FormHelper; - -/** - * Integrates the Templating component with the Form library. - * - * @author Bernhard Schussek - */ -class TemplatingExtension extends AbstractExtension -{ - public function __construct(PhpEngine $engine, $csrfTokenManager = null, array $defaultThemes = array()) - { - if ($csrfTokenManager instanceof CsrfProviderInterface) { - $csrfTokenManager = new CsrfProviderAdapter($csrfTokenManager); - } elseif (null !== $csrfTokenManager && !$csrfTokenManager instanceof CsrfTokenManagerInterface) { - throw new UnexpectedTypeException($csrfTokenManager, 'CsrfProviderInterface or CsrfTokenManagerInterface'); - } - - $engine->addHelpers(array( - new FormHelper(new FormRenderer(new TemplatingRendererEngine($engine, $defaultThemes), $csrfTokenManager)), - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php deleted file mode 100644 index a9003e003..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Templating/TemplatingRendererEngine.php +++ /dev/null @@ -1,125 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Templating; - -use Symfony\Component\Form\AbstractRendererEngine; -use Symfony\Component\Form\FormView; -use Symfony\Component\Templating\EngineInterface; - -/** - * @author Bernhard Schussek - */ -class TemplatingRendererEngine extends AbstractRendererEngine -{ - /** - * @var EngineInterface - */ - private $engine; - - public function __construct(EngineInterface $engine, array $defaultThemes = array()) - { - parent::__construct($defaultThemes); - - $this->engine = $engine; - } - - /** - * {@inheritdoc} - */ - public function renderBlock(FormView $view, $resource, $blockName, array $variables = array()) - { - return trim($this->engine->render($resource, $variables)); - } - - /** - * Loads the cache with the resource for a given block name. - * - * This implementation tries to load as few blocks as possible, since each block - * is represented by a template on the file system. - * - * @see getResourceForBlock() - * - * @param string $cacheKey The cache key of the form view. - * @param FormView $view The form view for finding the applying themes. - * @param string $blockName The name of the block to load. - * - * @return bool True if the resource could be loaded, false otherwise. - */ - protected function loadResourceForBlockName($cacheKey, FormView $view, $blockName) - { - // Recursively try to find the block in the themes assigned to $view, - // then of its parent form, then of the parent form of the parent and so on. - // When the root form is reached in this recursion, also the default - // themes are taken into account. - - // Check each theme whether it contains the searched block - if (isset($this->themes[$cacheKey])) { - for ($i = count($this->themes[$cacheKey]) - 1; $i >= 0; --$i) { - if ($this->loadResourceFromTheme($cacheKey, $blockName, $this->themes[$cacheKey][$i])) { - return true; - } - } - } - - // Check the default themes once we reach the root form without success - if (!$view->parent) { - for ($i = count($this->defaultThemes) - 1; $i >= 0; --$i) { - if ($this->loadResourceFromTheme($cacheKey, $blockName, $this->defaultThemes[$i])) { - return true; - } - } - } - - // If we did not find anything in the themes of the current view, proceed - // with the themes of the parent view - if ($view->parent) { - $parentCacheKey = $view->parent->vars[self::CACHE_KEY_VAR]; - - if (!isset($this->resources[$parentCacheKey][$blockName])) { - $this->loadResourceForBlockName($parentCacheKey, $view->parent, $blockName); - } - - // If a template exists in the parent themes, cache that template - // for the current theme as well to speed up further accesses - if ($this->resources[$parentCacheKey][$blockName]) { - $this->resources[$cacheKey][$blockName] = $this->resources[$parentCacheKey][$blockName]; - - return true; - } - } - - // Cache that we didn't find anything to speed up further accesses - $this->resources[$cacheKey][$blockName] = false; - - return false; - } - - /** - * Tries to load the resource for a block from a theme. - * - * @param string $cacheKey The cache key for storing the resource. - * @param string $blockName The name of the block to load a resource for. - * @param mixed $theme The theme to load the block from. - * - * @return bool True if the resource could be loaded, false otherwise. - */ - protected function loadResourceFromTheme($cacheKey, $blockName, $theme) - { - if ($this->engine->exists($templateName = $theme.':'.$blockName.'.html.php')) { - $this->resources[$cacheKey][$blockName] = $templateName; - - return true; - } - - return false; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Constraints/Form.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Constraints/Form.php deleted file mode 100644 index da1a92b5e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Constraints/Form.php +++ /dev/null @@ -1,42 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\Constraints; - -use Symfony\Component\Validator\Constraint; - -/** - * @author Bernhard Schussek - */ -class Form extends Constraint -{ - const NOT_SYNCHRONIZED_ERROR = 1; - const NO_SUCH_FIELD_ERROR = 2; - - /** - * @deprecated Deprecated since Symfony 2.6, to be removed in 3.0. Use - * {@self NOT_SYNCHRONIZED_ERROR} instead. - */ - const ERR_INVALID = 1; - - protected static $errorNames = array( - self::NOT_SYNCHRONIZED_ERROR => 'NOT_SYNCHRONIZED_ERROR', - self::NO_SUCH_FIELD_ERROR => 'NO_SUCH_FIELD_ERROR', - ); - - /** - * {@inheritdoc} - */ - public function getTargets() - { - return self::CLASS_CONSTRAINT; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php deleted file mode 100644 index a4e2d9f5f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Constraints/FormValidator.php +++ /dev/null @@ -1,206 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\Constraints; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\ConstraintValidator; -use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\Exception\UnexpectedTypeException; - -/** - * @author Bernhard Schussek - */ -class FormValidator extends ConstraintValidator -{ - /** - * {@inheritdoc} - */ - public function validate($form, Constraint $constraint) - { - if (!$constraint instanceof Form) { - throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Form'); - } - - if (!$form instanceof FormInterface) { - return; - } - - /* @var FormInterface $form */ - $config = $form->getConfig(); - $validator = null; - - if ($this->context instanceof ExecutionContextInterface) { - $validator = $this->context->getValidator()->inContext($this->context); - } - - if ($form->isSynchronized()) { - // Validate the form data only if transformation succeeded - $groups = self::getValidationGroups($form); - - // Validate the data against its own constraints - if (self::allowDataWalking($form)) { - foreach ($groups as $group) { - if ($validator) { - $validator->atPath('data')->validate($form->getData(), null, $group); - } else { - // 2.4 API - $this->context->validate($form->getData(), 'data', $group, true); - } - } - } - - // Validate the data against the constraints defined - // in the form - $constraints = $config->getOption('constraints'); - foreach ($constraints as $constraint) { - foreach ($groups as $group) { - if (in_array($group, $constraint->groups)) { - if ($validator) { - $validator->atPath('data')->validate($form->getData(), $constraint, $group); - } else { - // 2.4 API - $this->context->validateValue($form->getData(), $constraint, 'data', $group); - } - - // Prevent duplicate validation - continue 2; - } - } - } - } else { - $childrenSynchronized = true; - - foreach ($form as $child) { - if (!$child->isSynchronized()) { - $childrenSynchronized = false; - break; - } - } - - // Mark the form with an error if it is not synchronized BUT all - // of its children are synchronized. If any child is not - // synchronized, an error is displayed there already and showing - // a second error in its parent form is pointless, or worse, may - // lead to duplicate errors if error bubbling is enabled on the - // child. - // See also https://github.com/symfony/symfony/issues/4359 - if ($childrenSynchronized) { - $clientDataAsString = is_scalar($form->getViewData()) - ? (string) $form->getViewData() - : gettype($form->getViewData()); - - $this->buildViolation($config->getOption('invalid_message')) - ->setParameters(array_replace(array('{{ value }}' => $clientDataAsString), $config->getOption('invalid_message_parameters'))) - ->setInvalidValue($form->getViewData()) - ->setCode(Form::NOT_SYNCHRONIZED_ERROR) - ->setCause($form->getTransformationFailure()) - ->addViolation(); - } - } - - // Mark the form with an error if it contains extra fields - if (!$config->getOption('allow_extra_fields') && count($form->getExtraData()) > 0) { - $this->buildViolation($config->getOption('extra_fields_message')) - ->setParameter('{{ extra_fields }}', implode('", "', array_keys($form->getExtraData()))) - ->setInvalidValue($form->getExtraData()) - ->setCode(Form::NO_SUCH_FIELD_ERROR) - ->addViolation(); - } - } - - /** - * Returns whether the data of a form may be walked. - * - * @param FormInterface $form The form to test. - * - * @return bool Whether the graph walker may walk the data. - */ - private static function allowDataWalking(FormInterface $form) - { - $data = $form->getData(); - - // Scalar values cannot have mapped constraints - if (!is_object($data) && !is_array($data)) { - return false; - } - - // Root forms are always validated - if ($form->isRoot()) { - return true; - } - - // Non-root forms are validated if validation cascading - // is enabled in all ancestor forms - while (null !== ($form = $form->getParent())) { - if (!$form->getConfig()->getOption('cascade_validation')) { - return false; - } - } - - return true; - } - - /** - * Returns the validation groups of the given form. - * - * @param FormInterface $form The form. - * - * @return array The validation groups. - */ - private static function getValidationGroups(FormInterface $form) - { - // Determine the clicked button of the complete form tree - $clickedButton = null; - - if (method_exists($form, 'getClickedButton')) { - $clickedButton = $form->getClickedButton(); - } - - if (null !== $clickedButton) { - $groups = $clickedButton->getConfig()->getOption('validation_groups'); - - if (null !== $groups) { - return self::resolveValidationGroups($groups, $form); - } - } - - do { - $groups = $form->getConfig()->getOption('validation_groups'); - - if (null !== $groups) { - return self::resolveValidationGroups($groups, $form); - } - - $form = $form->getParent(); - } while (null !== $form); - - return array(Constraint::DEFAULT_GROUP); - } - - /** - * Post-processes the validation groups option for a given form. - * - * @param array|callable $groups The validation groups. - * @param FormInterface $form The validated form. - * - * @return array The validation groups. - */ - private static function resolveValidationGroups($groups, FormInterface $form) - { - if (!is_string($groups) && is_callable($groups)) { - $groups = call_user_func($groups, $form); - } - - return (array) $groups; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php deleted file mode 100644 index 4bebce09c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/EventListener/ValidationListener.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\EventListener; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface; -use Symfony\Component\Validator\Validator\ValidatorInterface; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Extension\Validator\Constraints\Form; - -/** - * @author Bernhard Schussek - */ -class ValidationListener implements EventSubscriberInterface -{ - private $validator; - - private $violationMapper; - - /** - * {@inheritdoc} - */ - public static function getSubscribedEvents() - { - return array(FormEvents::POST_SUBMIT => 'validateForm'); - } - - /** - * @param ValidatorInterface|LegacyValidatorInterface $validator - * @param ViolationMapperInterface $violationMapper - */ - public function __construct($validator, ViolationMapperInterface $violationMapper) - { - if (!$validator instanceof ValidatorInterface && !$validator instanceof LegacyValidatorInterface) { - throw new \InvalidArgumentException('Validator must be instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface'); - } - - $this->validator = $validator; - $this->violationMapper = $violationMapper; - } - - /** - * Validates the form and its domain object. - * - * @param FormEvent $event The event object - */ - public function validateForm(FormEvent $event) - { - $form = $event->getForm(); - - if ($form->isRoot()) { - // Validate the form in group "Default" - $violations = $this->validator->validate($form); - - foreach ($violations as $violation) { - // Allow the "invalid" constraint to be put onto - // non-synchronized forms - // ConstraintViolation::getConstraint() must not expect to provide a constraint as long as Symfony\Component\Validator\ExecutionContext exists (before 3.0) - $allowNonSynchronized = (null === $violation->getConstraint() || $violation->getConstraint() instanceof Form) && Form::NOT_SYNCHRONIZED_ERROR === $violation->getCode(); - - $this->violationMapper->mapViolation($violation, $form, $allowNonSynchronized); - } - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/BaseValidatorExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/BaseValidatorExtension.php deleted file mode 100644 index f5bc00daa..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/BaseValidatorExtension.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * Encapsulates common logic of {@link FormTypeValidatorExtension} and - * {@link SubmitTypeValidatorExtension}. - * - * @author Bernhard Schussek - */ -abstract class BaseValidatorExtension extends AbstractTypeExtension -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - // Make sure that validation groups end up as null, closure or array - $validationGroupsNormalizer = function (Options $options, $groups) { - if (false === $groups) { - return array(); - } - - if (empty($groups)) { - return; - } - - if (is_callable($groups)) { - return $groups; - } - - return (array) $groups; - }; - - $resolver->setDefaults(array( - 'validation_groups' => null, - )); - - $resolver->setNormalizers(array( - 'validation_groups' => $validationGroupsNormalizer, - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php deleted file mode 100644 index 89238be70..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/FormTypeValidatorExtension.php +++ /dev/null @@ -1,92 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\Type; - -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper; -use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener; -use Symfony\Component\Validator\Validator\ValidatorInterface; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * @author Bernhard Schussek - */ -class FormTypeValidatorExtension extends BaseValidatorExtension -{ - /** - * @var ValidatorInterface - */ - private $validator; - - /** - * @var ViolationMapper - */ - private $violationMapper; - - /** - * @param ValidatorInterface|LegacyValidatorInterface $validator - */ - public function __construct($validator) - { - if (!$validator instanceof ValidatorInterface && !$validator instanceof LegacyValidatorInterface) { - throw new \InvalidArgumentException('Validator must be instance of Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface'); - } - - $this->validator = $validator; - $this->violationMapper = new ViolationMapper(); - } - - /** - * {@inheritdoc} - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->addEventSubscriber(new ValidationListener($this->validator, $this->violationMapper)); - } - - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - parent::setDefaultOptions($resolver); - - // Constraint should always be converted to an array - $constraintsNormalizer = function (Options $options, $constraints) { - return is_object($constraints) ? array($constraints) : (array) $constraints; - }; - - $resolver->setDefaults(array( - 'error_mapping' => array(), - 'constraints' => array(), - 'cascade_validation' => false, - 'invalid_message' => 'This value is not valid.', - 'invalid_message_parameters' => array(), - 'allow_extra_fields' => false, - 'extra_fields_message' => 'This form should not contain extra fields.', - )); - - $resolver->setNormalizers(array( - 'constraints' => $constraintsNormalizer, - )); - } - - /** - * {@inheritdoc} - */ - public function getExtendedType() - { - return 'form'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php deleted file mode 100644 index 858ff0fae..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/RepeatedTypeValidatorExtension.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\Type; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\OptionsResolver\Options; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * @author Bernhard Schussek - */ -class RepeatedTypeValidatorExtension extends AbstractTypeExtension -{ - /** - * {@inheritdoc} - */ - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - // Map errors to the first field - $errorMapping = function (Options $options) { - return array('.' => $options['first_name']); - }; - - $resolver->setDefaults(array( - 'error_mapping' => $errorMapping, - )); - } - - /** - * {@inheritdoc} - */ - public function getExtendedType() - { - return 'repeated'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php deleted file mode 100644 index ff1c762ef..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Type/SubmitTypeValidatorExtension.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\Type; - -/** - * @author Bernhard Schussek - */ -class SubmitTypeValidatorExtension extends BaseValidatorExtension -{ - /** - * {@inheritdoc} - */ - public function getExtendedType() - { - return 'submit'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php deleted file mode 100644 index c058d60ca..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/Util/ServerParams.php +++ /dev/null @@ -1,19 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\Util; - -/** - * @author Bernhard Schussek - */ -class ServerParams extends \Symfony\Component\Form\Util\ServerParams -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php deleted file mode 100644 index f6ef3070c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ValidatorExtension.php +++ /dev/null @@ -1,79 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator; - -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Extension\Validator\Constraints\Form; -use Symfony\Component\Form\AbstractExtension; -use Symfony\Component\Validator\Constraints\Valid; -use Symfony\Component\Validator\Mapping\ClassMetadata; -use Symfony\Component\Validator\Validator\ValidatorInterface; -use Symfony\Component\Validator\ValidatorInterface as LegacyValidatorInterface; - -/** - * Extension supporting the Symfony Validator component in forms. - * - * @author Bernhard Schussek - */ -class ValidatorExtension extends AbstractExtension -{ - private $validator; - - /** - * @param ValidatorInterface|LegacyValidatorInterface $validator - * - * @throws UnexpectedTypeException If $validator is invalid - */ - public function __construct($validator) - { - // 2.5 API - if ($validator instanceof ValidatorInterface) { - $metadata = $validator->getMetadataFor('Symfony\Component\Form\Form'); - // 2.4 API - } elseif ($validator instanceof LegacyValidatorInterface) { - $metadata = $validator->getMetadataFactory()->getMetadataFor('Symfony\Component\Form\Form'); - } else { - throw new UnexpectedTypeException($validator, 'Symfony\Component\Validator\Validator\ValidatorInterface or Symfony\Component\Validator\ValidatorInterface'); - } - - // Register the form constraints in the validator programmatically. - // This functionality is required when using the Form component without - // the DIC, where the XML file is loaded automatically. Thus the following - // code must be kept synchronized with validation.xml - - /** @var $metadata ClassMetadata */ - $metadata->addConstraint(new Form()); - $metadata->addPropertyConstraint('children', new Valid()); - - $this->validator = $validator; - } - - public function loadTypeGuesser() - { - // 2.4 API - if ($this->validator instanceof LegacyValidatorInterface) { - return new ValidatorTypeGuesser($this->validator->getMetadataFactory()); - } - - // 2.5 API - ValidatorInterface extends MetadataFactoryInterface - return new ValidatorTypeGuesser($this->validator); - } - - protected function loadTypeExtensions() - { - return array( - new Type\FormTypeValidatorExtension($this->validator), - new Type\RepeatedTypeValidatorExtension(), - new Type\SubmitTypeValidatorExtension(), - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php deleted file mode 100644 index 6369115f4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ValidatorTypeGuesser.php +++ /dev/null @@ -1,288 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator; - -use Symfony\Component\Form\FormTypeGuesserInterface; -use Symfony\Component\Form\Guess\Guess; -use Symfony\Component\Form\Guess\TypeGuess; -use Symfony\Component\Form\Guess\ValueGuess; -use Symfony\Component\Validator\Constraint; -use Symfony\Component\Validator\Mapping\ClassMetadataInterface; -use Symfony\Component\Validator\MetadataFactoryInterface; - -class ValidatorTypeGuesser implements FormTypeGuesserInterface -{ - private $metadataFactory; - - public function __construct(MetadataFactoryInterface $metadataFactory) - { - $this->metadataFactory = $metadataFactory; - } - - /** - * {@inheritdoc} - */ - public function guessType($class, $property) - { - $guesser = $this; - - return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { - return $guesser->guessTypeForConstraint($constraint); - }); - } - - /** - * {@inheritdoc} - */ - public function guessRequired($class, $property) - { - $guesser = $this; - - return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { - return $guesser->guessRequiredForConstraint($constraint); - // If we don't find any constraint telling otherwise, we can assume - // that a field is not required (with LOW_CONFIDENCE) - }, false); - } - - /** - * {@inheritdoc} - */ - public function guessMaxLength($class, $property) - { - $guesser = $this; - - return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { - return $guesser->guessMaxLengthForConstraint($constraint); - }); - } - - /** - * {@inheritdoc} - */ - public function guessPattern($class, $property) - { - $guesser = $this; - - return $this->guess($class, $property, function (Constraint $constraint) use ($guesser) { - return $guesser->guessPatternForConstraint($constraint); - }); - } - - /** - * Guesses a field class name for a given constraint. - * - * @param Constraint $constraint The constraint to guess for - * - * @return TypeGuess|null The guessed field class and options - */ - public function guessTypeForConstraint(Constraint $constraint) - { - switch (get_class($constraint)) { - case 'Symfony\Component\Validator\Constraints\Type': - switch ($constraint->type) { - case 'array': - return new TypeGuess('collection', array(), Guess::MEDIUM_CONFIDENCE); - case 'boolean': - case 'bool': - return new TypeGuess('checkbox', array(), Guess::MEDIUM_CONFIDENCE); - - case 'double': - case 'float': - case 'numeric': - case 'real': - return new TypeGuess('number', array(), Guess::MEDIUM_CONFIDENCE); - - case 'integer': - case 'int': - case 'long': - return new TypeGuess('integer', array(), Guess::MEDIUM_CONFIDENCE); - - case '\DateTime': - return new TypeGuess('date', array(), Guess::MEDIUM_CONFIDENCE); - - case 'string': - return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE); - } - break; - - case 'Symfony\Component\Validator\Constraints\Country': - return new TypeGuess('country', array(), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Date': - return new TypeGuess('date', array('input' => 'string'), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\DateTime': - return new TypeGuess('datetime', array('input' => 'string'), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Email': - return new TypeGuess('email', array(), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\File': - case 'Symfony\Component\Validator\Constraints\Image': - return new TypeGuess('file', array(), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Language': - return new TypeGuess('language', array(), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Locale': - return new TypeGuess('locale', array(), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Time': - return new TypeGuess('time', array('input' => 'string'), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Url': - return new TypeGuess('url', array(), Guess::HIGH_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Ip': - return new TypeGuess('text', array(), Guess::MEDIUM_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Length': - case 'Symfony\Component\Validator\Constraints\Regex': - return new TypeGuess('text', array(), Guess::LOW_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Range': - return new TypeGuess('number', array(), Guess::LOW_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\Count': - return new TypeGuess('collection', array(), Guess::LOW_CONFIDENCE); - - case 'Symfony\Component\Validator\Constraints\True': - case 'Symfony\Component\Validator\Constraints\False': - return new TypeGuess('checkbox', array(), Guess::MEDIUM_CONFIDENCE); - } - } - - /** - * Guesses whether a field is required based on the given constraint. - * - * @param Constraint $constraint The constraint to guess for - * - * @return ValueGuess|null The guess whether the field is required - */ - public function guessRequiredForConstraint(Constraint $constraint) - { - switch (get_class($constraint)) { - case 'Symfony\Component\Validator\Constraints\NotNull': - case 'Symfony\Component\Validator\Constraints\NotBlank': - case 'Symfony\Component\Validator\Constraints\True': - return new ValueGuess(true, Guess::HIGH_CONFIDENCE); - } - } - - /** - * Guesses a field's maximum length based on the given constraint. - * - * @param Constraint $constraint The constraint to guess for - * - * @return ValueGuess|null The guess for the maximum length - */ - public function guessMaxLengthForConstraint(Constraint $constraint) - { - switch (get_class($constraint)) { - case 'Symfony\Component\Validator\Constraints\Length': - if (is_numeric($constraint->max)) { - return new ValueGuess($constraint->max, Guess::HIGH_CONFIDENCE); - } - break; - - case 'Symfony\Component\Validator\Constraints\Type': - if (in_array($constraint->type, array('double', 'float', 'numeric', 'real'))) { - return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); - } - break; - - case 'Symfony\Component\Validator\Constraints\Range': - if (is_numeric($constraint->max)) { - return new ValueGuess(strlen((string) $constraint->max), Guess::LOW_CONFIDENCE); - } - break; - } - } - - /** - * Guesses a field's pattern based on the given constraint. - * - * @param Constraint $constraint The constraint to guess for - * - * @return ValueGuess|null The guess for the pattern - */ - public function guessPatternForConstraint(Constraint $constraint) - { - switch (get_class($constraint)) { - case 'Symfony\Component\Validator\Constraints\Length': - if (is_numeric($constraint->min)) { - return new ValueGuess(sprintf('.{%s,}', (string) $constraint->min), Guess::LOW_CONFIDENCE); - } - break; - - case 'Symfony\Component\Validator\Constraints\Regex': - $htmlPattern = $constraint->getHtmlPattern(); - - if (null !== $htmlPattern) { - return new ValueGuess($htmlPattern, Guess::HIGH_CONFIDENCE); - } - break; - - case 'Symfony\Component\Validator\Constraints\Range': - if (is_numeric($constraint->min)) { - return new ValueGuess(sprintf('.{%s,}', strlen((string) $constraint->min)), Guess::LOW_CONFIDENCE); - } - break; - - case 'Symfony\Component\Validator\Constraints\Type': - if (in_array($constraint->type, array('double', 'float', 'numeric', 'real'))) { - return new ValueGuess(null, Guess::MEDIUM_CONFIDENCE); - } - break; - } - } - - /** - * Iterates over the constraints of a property, executes a constraints on - * them and returns the best guess. - * - * @param string $class The class to read the constraints from - * @param string $property The property for which to find constraints - * @param \Closure $closure The closure that returns a guess - * for a given constraint - * @param mixed $defaultValue The default value assumed if no other value - * can be guessed. - * - * @return Guess|null The guessed value with the highest confidence - */ - protected function guess($class, $property, \Closure $closure, $defaultValue = null) - { - $guesses = array(); - $classMetadata = $this->metadataFactory->getMetadataFor($class); - - if ($classMetadata instanceof ClassMetadataInterface && $classMetadata->hasPropertyMetadata($property)) { - $memberMetadatas = $classMetadata->getPropertyMetadata($property); - - foreach ($memberMetadatas as $memberMetadata) { - $constraints = $memberMetadata->getConstraints(); - - foreach ($constraints as $constraint) { - if ($guess = $closure($constraint)) { - $guesses[] = $guess; - } - } - } - } - - if (null !== $defaultValue) { - $guesses[] = new ValueGuess($defaultValue, Guess::LOW_CONFIDENCE); - } - - return Guess::getBestGuess($guesses); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php deleted file mode 100644 index 48b5ceace..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/MappingRule.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\ViolationMapper; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\Exception\ErrorMappingException; - -/** - * @author Bernhard Schussek - */ -class MappingRule -{ - /** - * @var FormInterface - */ - private $origin; - - /** - * @var string - */ - private $propertyPath; - - /** - * @var string - */ - private $targetPath; - - public function __construct(FormInterface $origin, $propertyPath, $targetPath) - { - $this->origin = $origin; - $this->propertyPath = $propertyPath; - $this->targetPath = $targetPath; - } - - /** - * @return FormInterface - */ - public function getOrigin() - { - return $this->origin; - } - - /** - * Matches a property path against the rule path. - * - * If the rule matches, the form mapped by the rule is returned. - * Otherwise this method returns false. - * - * @param string $propertyPath The property path to match against the rule. - * - * @return null|FormInterface The mapped form or null. - */ - public function match($propertyPath) - { - if ($propertyPath === (string) $this->propertyPath) { - return $this->getTarget(); - } - } - - /** - * Matches a property path against a prefix of the rule path. - * - * @param string $propertyPath The property path to match against the rule. - * - * @return bool Whether the property path is a prefix of the rule or not. - */ - public function isPrefix($propertyPath) - { - $length = strlen($propertyPath); - $prefix = substr($this->propertyPath, 0, $length); - $next = isset($this->propertyPath[$length]) ? $this->propertyPath[$length] : null; - - return $prefix === $propertyPath && ('[' === $next || '.' === $next); - } - - /** - * @return FormInterface - * - * @throws ErrorMappingException - */ - public function getTarget() - { - $childNames = explode('.', $this->targetPath); - $target = $this->origin; - - foreach ($childNames as $childName) { - if (!$target->has($childName)) { - throw new ErrorMappingException(sprintf('The child "%s" of "%s" mapped by the rule "%s" in "%s" does not exist.', $childName, $target->getName(), $this->targetPath, $this->origin->getName())); - } - $target = $target->get($childName); - } - - return $target; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/RelativePath.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/RelativePath.php deleted file mode 100644 index ef5c9fad0..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/RelativePath.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\ViolationMapper; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\PropertyAccess\PropertyPath; - -/** - * @author Bernhard Schussek - */ -class RelativePath extends PropertyPath -{ - /** - * @var FormInterface - */ - private $root; - - /** - * @param FormInterface $root - * @param string $propertyPath - */ - public function __construct(FormInterface $root, $propertyPath) - { - parent::__construct($propertyPath); - - $this->root = $root; - } - - /** - * @return FormInterface - */ - public function getRoot() - { - return $this->root; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php deleted file mode 100644 index 1007924b6..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapper.php +++ /dev/null @@ -1,300 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\ViolationMapper; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\Util\InheritDataAwareIterator; -use Symfony\Component\PropertyAccess\PropertyPathIterator; -use Symfony\Component\PropertyAccess\PropertyPathBuilder; -use Symfony\Component\PropertyAccess\PropertyPathIteratorInterface; -use Symfony\Component\Form\FormError; -use Symfony\Component\Validator\ConstraintViolation; - -/** - * @author Bernhard Schussek - */ -class ViolationMapper implements ViolationMapperInterface -{ - /** - * @var bool - */ - private $allowNonSynchronized; - - /** - * {@inheritdoc} - */ - public function mapViolation(ConstraintViolation $violation, FormInterface $form, $allowNonSynchronized = false) - { - $this->allowNonSynchronized = $allowNonSynchronized; - - // The scope is the currently found most specific form that - // an error should be mapped to. After setting the scope, the - // mapper will try to continue to find more specific matches in - // the children of scope. If it cannot, the error will be - // mapped to this scope. - $scope = null; - - $violationPath = null; - $relativePath = null; - $match = false; - - // Don't create a ViolationPath instance for empty property paths - if (strlen($violation->getPropertyPath()) > 0) { - $violationPath = new ViolationPath($violation->getPropertyPath()); - $relativePath = $this->reconstructPath($violationPath, $form); - } - - // This case happens if the violation path is empty and thus - // the violation should be mapped to the root form - if (null === $violationPath) { - $scope = $form; - } - - // In general, mapping happens from the root form to the leaf forms - // First, the rules of the root form are applied to determine - // the subsequent descendant. The rules of this descendant are then - // applied to find the next and so on, until we have found the - // most specific form that matches the violation. - - // If any of the forms found in this process is not synchronized, - // mapping is aborted. Non-synchronized forms could not reverse - // transform the value entered by the user, thus any further violations - // caused by the (invalid) reverse transformed value should be - // ignored. - - if (null !== $relativePath) { - // Set the scope to the root of the relative path - // This root will usually be $form. If the path contains - // an unmapped form though, the last unmapped form found - // will be the root of the path. - $scope = $relativePath->getRoot(); - $it = new PropertyPathIterator($relativePath); - - while ($this->acceptsErrors($scope) && null !== ($child = $this->matchChild($scope, $it))) { - $scope = $child; - $it->next(); - $match = true; - } - } - - // This case happens if an error happened in the data under a - // form inheriting its parent data that does not match any of the - // children of that form. - if (null !== $violationPath && !$match) { - // If we could not map the error to anything more specific - // than the root element, map it to the innermost directly - // mapped form of the violation path - // e.g. "children[foo].children[bar].data.baz" - // Here the innermost directly mapped child is "bar" - - $scope = $form; - $it = new ViolationPathIterator($violationPath); - - // Note: acceptsErrors() will always return true for forms inheriting - // their parent data, because these forms can never be non-synchronized - // (they don't do any data transformation on their own) - while ($this->acceptsErrors($scope) && $it->valid() && $it->mapsForm()) { - if (!$scope->has($it->current())) { - // Break if we find a reference to a non-existing child - break; - } - - $scope = $scope->get($it->current()); - $it->next(); - } - } - - // Follow dot rules until we have the final target - $mapping = $scope->getConfig()->getOption('error_mapping'); - - while ($this->acceptsErrors($scope) && isset($mapping['.'])) { - $dotRule = new MappingRule($scope, '.', $mapping['.']); - $scope = $dotRule->getTarget(); - $mapping = $scope->getConfig()->getOption('error_mapping'); - } - - // Only add the error if the form is synchronized - if ($this->acceptsErrors($scope)) { - $scope->addError(new FormError( - $violation->getMessage(), - $violation->getMessageTemplate(), - $violation->getMessageParameters(), - $violation->getMessagePluralization(), - $violation - )); - } - } - - /** - * Tries to match the beginning of the property path at the - * current position against the children of the scope. - * - * If a matching child is found, it is returned. Otherwise - * null is returned. - * - * @param FormInterface $form The form to search. - * @param PropertyPathIteratorInterface $it The iterator at its current position. - * - * @return null|FormInterface The found match or null. - */ - private function matchChild(FormInterface $form, PropertyPathIteratorInterface $it) - { - // Remember at what property path underneath "data" - // we are looking. Check if there is a child with that - // path, otherwise increase path by one more piece - $chunk = ''; - $foundChild = null; - $foundAtIndex = 0; - - // Construct mapping rules for the given form - $rules = array(); - - foreach ($form->getConfig()->getOption('error_mapping') as $propertyPath => $targetPath) { - // Dot rules are considered at the very end - if ('.' !== $propertyPath) { - $rules[] = new MappingRule($form, $propertyPath, $targetPath); - } - } - - // Skip forms inheriting their parent data when iterating the children - $childIterator = new \RecursiveIteratorIterator( - new InheritDataAwareIterator($form) - ); - - // Make the path longer until we find a matching child - while (true) { - if (!$it->valid()) { - return; - } - - if ($it->isIndex()) { - $chunk .= '['.$it->current().']'; - } else { - $chunk .= ('' === $chunk ? '' : '.').$it->current(); - } - - // Test mapping rules as long as we have any - foreach ($rules as $key => $rule) { - /* @var MappingRule $rule */ - - // Mapping rule matches completely, terminate. - if (null !== ($form = $rule->match($chunk))) { - return $form; - } - - // Keep only rules that have $chunk as prefix - if (!$rule->isPrefix($chunk)) { - unset($rules[$key]); - } - } - - // Test children unless we already found one - if (null === $foundChild) { - foreach ($childIterator as $child) { - /* @var FormInterface $child */ - $childPath = (string) $child->getPropertyPath(); - - // Child found, mark as return value - if ($chunk === $childPath) { - $foundChild = $child; - $foundAtIndex = $it->key(); - } - } - } - - // Add element to the chunk - $it->next(); - - // If we reached the end of the path or if there are no - // more matching mapping rules, return the found child - if (null !== $foundChild && (!$it->valid() || count($rules) === 0)) { - // Reset index in case we tried to find mapping - // rules further down the path - $it->seek($foundAtIndex); - - return $foundChild; - } - } - } - - /** - * Reconstructs a property path from a violation path and a form tree. - * - * @param ViolationPath $violationPath The violation path. - * @param FormInterface $origin The root form of the tree. - * - * @return RelativePath The reconstructed path. - */ - private function reconstructPath(ViolationPath $violationPath, FormInterface $origin) - { - $propertyPathBuilder = new PropertyPathBuilder($violationPath); - $it = $violationPath->getIterator(); - $scope = $origin; - - // Remember the current index in the builder - $i = 0; - - // Expand elements that map to a form (like "children[address]") - for ($it->rewind(); $it->valid() && $it->mapsForm(); $it->next()) { - if (!$scope->has($it->current())) { - // Scope relates to a form that does not exist - // Bail out - break; - } - - // Process child form - $scope = $scope->get($it->current()); - - if ($scope->getConfig()->getInheritData()) { - // Form inherits its parent data - // Cut the piece out of the property path and proceed - $propertyPathBuilder->remove($i); - } elseif (!$scope->getConfig()->getMapped()) { - // Form is not mapped - // Set the form as new origin and strip everything - // we have so far in the path - $origin = $scope; - $propertyPathBuilder->remove(0, $i + 1); - $i = 0; - } else { - /* @var \Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath */ - $propertyPath = $scope->getPropertyPath(); - - if (null === $propertyPath) { - // Property path of a mapped form is null - // Should not happen, bail out - break; - } - - $propertyPathBuilder->replace($i, 1, $propertyPath); - $i += $propertyPath->getLength(); - } - } - - $finalPath = $propertyPathBuilder->getPropertyPath(); - - return null !== $finalPath ? new RelativePath($origin, $finalPath) : null; - } - - /** - * @param FormInterface $form - * - * @return bool - */ - private function acceptsErrors(FormInterface $form) - { - // Ignore non-submitted forms. This happens, for example, in PATCH - // requests. - // https://github.com/symfony/symfony/pull/10567 - return $form->isSubmitted() && ($this->allowNonSynchronized || $form->isSynchronized()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapperInterface.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapperInterface.php deleted file mode 100644 index fb56a2bad..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationMapperInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\ViolationMapper; - -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Validator\ConstraintViolation; - -/** - * @author Bernhard Schussek - */ -interface ViolationMapperInterface -{ - /** - * Maps a constraint violation to a form in the form tree under - * the given form. - * - * @param ConstraintViolation $violation The violation to map. - * @param FormInterface $form The root form of the tree - * to map it to. - * @param bool $allowNonSynchronized Whether to allow - * mapping to non-synchronized forms. - */ - public function mapViolation(ConstraintViolation $violation, FormInterface $form, $allowNonSynchronized = false); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php deleted file mode 100644 index 8e406a9b0..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPath.php +++ /dev/null @@ -1,258 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\ViolationMapper; - -use Symfony\Component\Form\Exception\OutOfBoundsException; -use Symfony\Component\PropertyAccess\PropertyPath; -use Symfony\Component\PropertyAccess\PropertyPathInterface; - -/** - * @author Bernhard Schussek - */ -class ViolationPath implements \IteratorAggregate, PropertyPathInterface -{ - /** - * @var array - */ - private $elements = array(); - - /** - * @var array - */ - private $isIndex = array(); - - /** - * @var array - */ - private $mapsForm = array(); - - /** - * @var string - */ - private $pathAsString = ''; - - /** - * @var int - */ - private $length = 0; - - /** - * Creates a new violation path from a string. - * - * @param string $violationPath The property path of a {@link ConstraintViolation} - * object. - */ - public function __construct($violationPath) - { - $path = new PropertyPath($violationPath); - $elements = $path->getElements(); - $data = false; - - for ($i = 0, $l = count($elements); $i < $l; ++$i) { - if (!$data) { - // The element "data" has not yet been passed - if ('children' === $elements[$i] && $path->isProperty($i)) { - // Skip element "children" - ++$i; - - // Next element must exist and must be an index - // Otherwise consider this the end of the path - if ($i >= $l || !$path->isIndex($i)) { - break; - } - - // All the following index items (regardless if .children is - // explicitly used) are children and grand-children - for (; $i < $l && $path->isIndex($i); ++$i) { - $this->elements[] = $elements[$i]; - $this->isIndex[] = true; - $this->mapsForm[] = true; - } - - // Rewind the pointer as the last element above didn't match - // (even if the pointer was moved forward) - --$i; - } elseif ('data' === $elements[$i] && $path->isProperty($i)) { - // Skip element "data" - ++$i; - - // End of path - if ($i >= $l) { - break; - } - - $this->elements[] = $elements[$i]; - $this->isIndex[] = $path->isIndex($i); - $this->mapsForm[] = false; - $data = true; - } else { - // Neither "children" nor "data" property found - // Consider this the end of the path - break; - } - } else { - // Already after the "data" element - // Pick everything as is - $this->elements[] = $elements[$i]; - $this->isIndex[] = $path->isIndex($i); - $this->mapsForm[] = false; - } - } - - $this->length = count($this->elements); - - $this->buildString(); - } - - /** - * {@inheritdoc} - */ - public function __toString() - { - return $this->pathAsString; - } - - /** - * {@inheritdoc} - */ - public function getLength() - { - return $this->length; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - if ($this->length <= 1) { - return; - } - - $parent = clone $this; - - --$parent->length; - array_pop($parent->elements); - array_pop($parent->isIndex); - array_pop($parent->mapsForm); - - $parent->buildString(); - - return $parent; - } - - /** - * {@inheritdoc} - */ - public function getElements() - { - return $this->elements; - } - - /** - * {@inheritdoc} - */ - public function getElement($index) - { - if (!isset($this->elements[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path', $index)); - } - - return $this->elements[$index]; - } - - /** - * {@inheritdoc} - */ - public function isProperty($index) - { - if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path', $index)); - } - - return !$this->isIndex[$index]; - } - - /** - * {@inheritdoc} - */ - public function isIndex($index) - { - if (!isset($this->isIndex[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path', $index)); - } - - return $this->isIndex[$index]; - } - - /** - * Returns whether an element maps directly to a form. - * - * Consider the following violation path: - * - * - * children[address].children[office].data.street - * - * - * In this example, "address" and "office" map to forms, while - * "street does not. - * - * @param int $index The element index. - * - * @return bool Whether the element maps to a form. - * - * @throws OutOfBoundsException If the offset is invalid. - */ - public function mapsForm($index) - { - if (!isset($this->mapsForm[$index])) { - throw new OutOfBoundsException(sprintf('The index %s is not within the violation path', $index)); - } - - return $this->mapsForm[$index]; - } - - /** - * Returns a new iterator for this path. - * - * @return ViolationPathIterator - */ - public function getIterator() - { - return new ViolationPathIterator($this); - } - - /** - * Builds the string representation from the elements. - */ - private function buildString() - { - $this->pathAsString = ''; - $data = false; - - foreach ($this->elements as $index => $element) { - if ($this->mapsForm[$index]) { - $this->pathAsString .= ".children[$element]"; - } elseif (!$data) { - $this->pathAsString .= '.data'.($this->isIndex[$index] ? "[$element]" : ".$element"); - $data = true; - } else { - $this->pathAsString .= $this->isIndex[$index] ? "[$element]" : ".$element"; - } - } - - if ('' !== $this->pathAsString) { - // remove leading dot - $this->pathAsString = substr($this->pathAsString, 1); - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPathIterator.php b/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPathIterator.php deleted file mode 100644 index 50baa4533..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Extension/Validator/ViolationMapper/ViolationPathIterator.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Extension\Validator\ViolationMapper; - -use Symfony\Component\PropertyAccess\PropertyPathIterator; - -/** - * @author Bernhard Schussek - */ -class ViolationPathIterator extends PropertyPathIterator -{ - public function __construct(ViolationPath $violationPath) - { - parent::__construct($violationPath); - } - - public function mapsForm() - { - return $this->path->mapsForm($this->key()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Form.php b/vendor/symfony/form/Symfony/Component/Form/Form.php deleted file mode 100644 index b0528d1d2..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Form.php +++ /dev/null @@ -1,1204 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\RuntimeException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Exception\AlreadySubmittedException; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Exception\LogicException; -use Symfony\Component\Form\Exception\OutOfBoundsException; -use Symfony\Component\Form\Util\FormUtil; -use Symfony\Component\Form\Util\InheritDataAwareIterator; -use Symfony\Component\Form\Util\OrderedHashMap; -use Symfony\Component\PropertyAccess\PropertyPath; - -/** - * Form represents a form. - * - * To implement your own form fields, you need to have a thorough understanding - * of the data flow within a form. A form stores its data in three different - * representations: - * - * (1) the "model" format required by the form's object - * (2) the "normalized" format for internal processing - * (3) the "view" format used for display - * - * A date field, for example, may store a date as "Y-m-d" string (1) in the - * object. To facilitate processing in the field, this value is normalized - * to a DateTime object (2). In the HTML representation of your form, a - * localized string (3) is presented to and modified by the user. - * - * In most cases, format (1) and format (2) will be the same. For example, - * a checkbox field uses a Boolean value for both internal processing and - * storage in the object. In these cases you simply need to set a value - * transformer to convert between formats (2) and (3). You can do this by - * calling addViewTransformer(). - * - * In some cases though it makes sense to make format (1) configurable. To - * demonstrate this, let's extend our above date field to store the value - * either as "Y-m-d" string or as timestamp. Internally we still want to - * use a DateTime object for processing. To convert the data from string/integer - * to DateTime you can set a normalization transformer by calling - * addNormTransformer(). The normalized data is then converted to the displayed - * data as described before. - * - * The conversions (1) -> (2) -> (3) use the transform methods of the transformers. - * The conversions (3) -> (2) -> (1) use the reverseTransform methods of the transformers. - * - * @author Fabien Potencier - * @author Bernhard Schussek - */ -class Form implements \IteratorAggregate, FormInterface -{ - /** - * The form's configuration. - * - * @var FormConfigInterface - */ - private $config; - - /** - * The parent of this form. - * - * @var FormInterface - */ - private $parent; - - /** - * The children of this form. - * - * @var FormInterface[] A map of FormInterface instances - */ - private $children; - - /** - * The errors of this form. - * - * @var FormError[] An array of FormError instances - */ - private $errors = array(); - - /** - * Whether this form was submitted. - * - * @var bool - */ - private $submitted = false; - - /** - * The button that was used to submit the form. - * - * @var Button - */ - private $clickedButton; - - /** - * The form data in model format. - * - * @var mixed - */ - private $modelData; - - /** - * The form data in normalized format. - * - * @var mixed - */ - private $normData; - - /** - * The form data in view format. - * - * @var mixed - */ - private $viewData; - - /** - * The submitted values that don't belong to any children. - * - * @var array - */ - private $extraData = array(); - - /** - * Returns the transformation failure generated during submission, if any. - * - * @var TransformationFailedException|null - */ - private $transformationFailure; - - /** - * Whether the form's data has been initialized. - * - * When the data is initialized with its default value, that default value - * is passed through the transformer chain in order to synchronize the - * model, normalized and view format for the first time. This is done - * lazily in order to save performance when {@link setData()} is called - * manually, making the initialization with the configured default value - * superfluous. - * - * @var bool - */ - private $defaultDataSet = false; - - /** - * Whether setData() is currently being called. - * - * @var bool - */ - private $lockSetData = false; - - /** - * Creates a new form based on the given configuration. - * - * @param FormConfigInterface $config The form configuration. - * - * @throws LogicException if a data mapper is not provided for a compound form - */ - public function __construct(FormConfigInterface $config) - { - // Compound forms always need a data mapper, otherwise calls to - // `setData` and `add` will not lead to the correct population of - // the child forms. - if ($config->getCompound() && !$config->getDataMapper()) { - throw new LogicException('Compound forms need a data mapper'); - } - - // If the form inherits the data from its parent, it is not necessary - // to call setData() with the default data. - if ($config->getInheritData()) { - $this->defaultDataSet = true; - } - - $this->config = $config; - $this->children = new OrderedHashMap(); - } - - public function __clone() - { - $this->children = clone $this->children; - - foreach ($this->children as $key => $child) { - $this->children[$key] = clone $child; - } - } - - /** - * {@inheritdoc} - */ - public function getConfig() - { - return $this->config; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->config->getName(); - } - - /** - * {@inheritdoc} - */ - public function getPropertyPath() - { - if (null !== $this->config->getPropertyPath()) { - return $this->config->getPropertyPath(); - } - - if (null === $this->getName() || '' === $this->getName()) { - return; - } - - $parent = $this->parent; - - while ($parent && $parent->getConfig()->getInheritData()) { - $parent = $parent->getParent(); - } - - if ($parent && null === $parent->getConfig()->getDataClass()) { - return new PropertyPath('['.$this->getName().']'); - } - - return new PropertyPath($this->getName()); - } - - /** - * {@inheritdoc} - */ - public function isRequired() - { - if (null === $this->parent || $this->parent->isRequired()) { - return $this->config->getRequired(); - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function isDisabled() - { - if (null === $this->parent || !$this->parent->isDisabled()) { - return $this->config->getDisabled(); - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function setParent(FormInterface $parent = null) - { - if ($this->submitted) { - throw new AlreadySubmittedException('You cannot set the parent of a submitted form'); - } - - if (null !== $parent && '' === $this->config->getName()) { - throw new LogicException('A form with an empty name cannot have a parent form.'); - } - - $this->parent = $parent; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return $this->parent; - } - - /** - * {@inheritdoc} - */ - public function getRoot() - { - return $this->parent ? $this->parent->getRoot() : $this; - } - - /** - * {@inheritdoc} - */ - public function isRoot() - { - return null === $this->parent; - } - - /** - * {@inheritdoc} - */ - public function setData($modelData) - { - // If the form is submitted while disabled, it is set to submitted, but the data is not - // changed. In such cases (i.e. when the form is not initialized yet) don't - // abort this method. - if ($this->submitted && $this->defaultDataSet) { - throw new AlreadySubmittedException('You cannot change the data of a submitted form.'); - } - - // If the form inherits its parent's data, disallow data setting to - // prevent merge conflicts - if ($this->config->getInheritData()) { - throw new RuntimeException('You cannot change the data of a form inheriting its parent data.'); - } - - // Don't allow modifications of the configured data if the data is locked - if ($this->config->getDataLocked() && $modelData !== $this->config->getData()) { - return $this; - } - - if (is_object($modelData) && !$this->config->getByReference()) { - $modelData = clone $modelData; - } - - if ($this->lockSetData) { - throw new RuntimeException('A cycle was detected. Listeners to the PRE_SET_DATA event must not call setData(). You should call setData() on the FormEvent object instead.'); - } - - $this->lockSetData = true; - $dispatcher = $this->config->getEventDispatcher(); - - // Hook to change content of the data - if ($dispatcher->hasListeners(FormEvents::PRE_SET_DATA)) { - $event = new FormEvent($this, $modelData); - $dispatcher->dispatch(FormEvents::PRE_SET_DATA, $event); - $modelData = $event->getData(); - } - - // Treat data as strings unless a value transformer exists - if (!$this->config->getViewTransformers() && !$this->config->getModelTransformers() && is_scalar($modelData)) { - $modelData = (string) $modelData; - } - - // Synchronize representations - must not change the content! - $normData = $this->modelToNorm($modelData); - $viewData = $this->normToView($normData); - - // Validate if view data matches data class (unless empty) - if (!FormUtil::isEmpty($viewData)) { - $dataClass = $this->config->getDataClass(); - - $actualType = is_object($viewData) ? 'an instance of class '.get_class($viewData) : ' a(n) '.gettype($viewData); - - if (null === $dataClass && is_object($viewData) && !$viewData instanceof \ArrayAccess) { - $expectedType = 'scalar, array or an instance of \ArrayAccess'; - - throw new LogicException( - 'The form\'s view data is expected to be of type '.$expectedType.', '. - 'but is '.$actualType.'. You '. - 'can avoid this error by setting the "data_class" option to '. - '"'.get_class($viewData).'" or by adding a view transformer '. - 'that transforms '.$actualType.' to '.$expectedType.'.' - ); - } - - if (null !== $dataClass && !$viewData instanceof $dataClass) { - throw new LogicException( - 'The form\'s view data is expected to be an instance of class '. - $dataClass.', but is '.$actualType.'. You can avoid this error '. - 'by setting the "data_class" option to null or by adding a view '. - 'transformer that transforms '.$actualType.' to an instance of '. - $dataClass.'.' - ); - } - } - - $this->modelData = $modelData; - $this->normData = $normData; - $this->viewData = $viewData; - $this->defaultDataSet = true; - $this->lockSetData = false; - - // It is not necessary to invoke this method if the form doesn't have children, - // even if the form is compound. - if (count($this->children) > 0) { - // Update child forms from the data - $iterator = new InheritDataAwareIterator($this->children); - $iterator = new \RecursiveIteratorIterator($iterator); - $this->config->getDataMapper()->mapDataToForms($viewData, $iterator); - } - - if ($dispatcher->hasListeners(FormEvents::POST_SET_DATA)) { - $event = new FormEvent($this, $modelData); - $dispatcher->dispatch(FormEvents::POST_SET_DATA, $event); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - if ($this->config->getInheritData()) { - if (!$this->parent) { - throw new RuntimeException('The form is configured to inherit its parent\'s data, but does not have a parent.'); - } - - return $this->parent->getData(); - } - - if (!$this->defaultDataSet) { - $this->setData($this->config->getData()); - } - - return $this->modelData; - } - - /** - * {@inheritdoc} - */ - public function getNormData() - { - if ($this->config->getInheritData()) { - if (!$this->parent) { - throw new RuntimeException('The form is configured to inherit its parent\'s data, but does not have a parent.'); - } - - return $this->parent->getNormData(); - } - - if (!$this->defaultDataSet) { - $this->setData($this->config->getData()); - } - - return $this->normData; - } - - /** - * {@inheritdoc} - */ - public function getViewData() - { - if ($this->config->getInheritData()) { - if (!$this->parent) { - throw new RuntimeException('The form is configured to inherit its parent\'s data, but does not have a parent.'); - } - - return $this->parent->getViewData(); - } - - if (!$this->defaultDataSet) { - $this->setData($this->config->getData()); - } - - return $this->viewData; - } - - /** - * {@inheritdoc} - */ - public function getExtraData() - { - return $this->extraData; - } - - /** - * {@inheritdoc} - */ - public function initialize() - { - if (null !== $this->parent) { - throw new RuntimeException('Only root forms should be initialized.'); - } - - // Guarantee that the *_SET_DATA events have been triggered once the - // form is initialized. This makes sure that dynamically added or - // removed fields are already visible after initialization. - if (!$this->defaultDataSet) { - $this->setData($this->config->getData()); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function handleRequest($request = null) - { - $this->config->getRequestHandler()->handleRequest($this, $request); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function submit($submittedData, $clearMissing = true) - { - if ($this->submitted) { - throw new AlreadySubmittedException('A form can only be submitted once'); - } - - // Initialize errors in the very beginning so that we don't lose any - // errors added during listeners - $this->errors = array(); - - // Obviously, a disabled form should not change its data upon submission. - if ($this->isDisabled()) { - $this->submitted = true; - - return $this; - } - - // The data must be initialized if it was not initialized yet. - // This is necessary to guarantee that the *_SET_DATA listeners - // are always invoked before submit() takes place. - if (!$this->defaultDataSet) { - $this->setData($this->config->getData()); - } - - // Treat false as NULL to support binding false to checkboxes. - // Don't convert NULL to a string here in order to determine later - // whether an empty value has been submitted or whether no value has - // been submitted at all. This is important for processing checkboxes - // and radio buttons with empty values. - if (false === $submittedData) { - $submittedData = null; - } elseif (is_scalar($submittedData)) { - $submittedData = (string) $submittedData; - } - - $dispatcher = $this->config->getEventDispatcher(); - - $modelData = null; - $normData = null; - $viewData = null; - - try { - // Hook to change content of the data submitted by the browser - if ($dispatcher->hasListeners(FormEvents::PRE_SUBMIT)) { - $event = new FormEvent($this, $submittedData); - $dispatcher->dispatch(FormEvents::PRE_SUBMIT, $event); - $submittedData = $event->getData(); - } - - // Check whether the form is compound. - // This check is preferable over checking the number of children, - // since forms without children may also be compound. - // (think of empty collection forms) - if ($this->config->getCompound()) { - if (null === $submittedData) { - $submittedData = array(); - } - - if (!is_array($submittedData)) { - throw new TransformationFailedException('Compound forms expect an array or NULL on submission.'); - } - - foreach ($this->children as $name => $child) { - $isSubmitted = array_key_exists($name, $submittedData); - - if ($isSubmitted || $clearMissing) { - $child->submit($isSubmitted ? $submittedData[$name] : null, $clearMissing); - unset($submittedData[$name]); - - if (null !== $this->clickedButton) { - continue; - } - - if ($child instanceof ClickableInterface && $child->isClicked()) { - $this->clickedButton = $child; - - continue; - } - - if (method_exists($child, 'getClickedButton') && null !== $child->getClickedButton()) { - $this->clickedButton = $child->getClickedButton(); - } - } - } - - $this->extraData = $submittedData; - } - - // Forms that inherit their parents' data also are not processed, - // because then it would be too difficult to merge the changes in - // the child and the parent form. Instead, the parent form also takes - // changes in the grandchildren (i.e. children of the form that inherits - // its parent's data) into account. - // (see InheritDataAwareIterator below) - if (!$this->config->getInheritData()) { - // If the form is compound, the default data in view format - // is reused. The data of the children is merged into this - // default data using the data mapper. - // If the form is not compound, the submitted data is also the data in view format. - $viewData = $this->config->getCompound() ? $this->viewData : $submittedData; - - if (FormUtil::isEmpty($viewData)) { - $emptyData = $this->config->getEmptyData(); - - if ($emptyData instanceof \Closure) { - /* @var \Closure $emptyData */ - $emptyData = $emptyData($this, $viewData); - } - - $viewData = $emptyData; - } - - // Merge form data from children into existing view data - // It is not necessary to invoke this method if the form has no children, - // even if it is compound. - if (count($this->children) > 0) { - // Use InheritDataAwareIterator to process children of - // descendants that inherit this form's data. - // These descendants will not be submitted normally (see the check - // for $this->config->getInheritData() above) - $childrenIterator = new InheritDataAwareIterator($this->children); - $childrenIterator = new \RecursiveIteratorIterator($childrenIterator); - $this->config->getDataMapper()->mapFormsToData($childrenIterator, $viewData); - } - - // Normalize data to unified representation - $normData = $this->viewToNorm($viewData); - - // Hook to change content of the data in the normalized - // representation - if ($dispatcher->hasListeners(FormEvents::SUBMIT)) { - $event = new FormEvent($this, $normData); - $dispatcher->dispatch(FormEvents::SUBMIT, $event); - $normData = $event->getData(); - } - - // Synchronize representations - must not change the content! - $modelData = $this->normToModel($normData); - $viewData = $this->normToView($normData); - } - } catch (TransformationFailedException $e) { - $this->transformationFailure = $e; - - // If $viewData was not yet set, set it to $submittedData so that - // the erroneous data is accessible on the form. - // Forms that inherit data never set any data, because the getters - // forward to the parent form's getters anyway. - if (null === $viewData && !$this->config->getInheritData()) { - $viewData = $submittedData; - } - } - - $this->submitted = true; - $this->modelData = $modelData; - $this->normData = $normData; - $this->viewData = $viewData; - - if ($dispatcher->hasListeners(FormEvents::POST_SUBMIT)) { - $event = new FormEvent($this, $viewData); - $dispatcher->dispatch(FormEvents::POST_SUBMIT, $event); - } - - return $this; - } - - /** - * Alias of {@link submit()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link submit()} instead. - */ - public function bind($submittedData) - { - return $this->submit($submittedData); - } - - /** - * {@inheritdoc} - */ - public function addError(FormError $error) - { - if ($this->parent && $this->config->getErrorBubbling()) { - if (null === $error->getOrigin()) { - $error->setOrigin($this); - } - - $this->parent->addError($error); - } else { - $this->errors[] = $error; - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function isSubmitted() - { - return $this->submitted; - } - - /** - * Alias of {@link isSubmitted()}. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link isSubmitted()} instead. - */ - public function isBound() - { - return $this->submitted; - } - - /** - * {@inheritdoc} - */ - public function isSynchronized() - { - return null === $this->transformationFailure; - } - - /** - * {@inheritdoc} - */ - public function getTransformationFailure() - { - return $this->transformationFailure; - } - - /** - * {@inheritdoc} - */ - public function isEmpty() - { - foreach ($this->children as $child) { - if (!$child->isEmpty()) { - return false; - } - } - - return FormUtil::isEmpty($this->modelData) || - // arrays, countables - 0 === count($this->modelData) || - // traversables that are not countable - ($this->modelData instanceof \Traversable && 0 === iterator_count($this->modelData)); - } - - /** - * {@inheritdoc} - */ - public function isValid() - { - if (!$this->submitted) { - return false; - } - - if ($this->isDisabled()) { - return true; - } - - if (count($this->getErrors(true)) > 0) { - return false; - } - - return true; - } - - /** - * Returns the button that was used to submit the form. - * - * @return Button|null The clicked button or NULL if the form was not - * submitted - */ - public function getClickedButton() - { - if ($this->clickedButton) { - return $this->clickedButton; - } - - if ($this->parent && method_exists($this->parent, 'getClickedButton')) { - return $this->parent->getClickedButton(); - } - } - - /** - * {@inheritdoc} - */ - public function getErrors($deep = false, $flatten = true) - { - $errors = $this->errors; - - // Copy the errors of nested forms to the $errors array - if ($deep) { - foreach ($this as $child) { - /** @var FormInterface $child */ - if ($child->isSubmitted() && $child->isValid()) { - continue; - } - - $iterator = $child->getErrors(true, $flatten); - - if (0 === count($iterator)) { - continue; - } - - if ($flatten) { - foreach ($iterator as $error) { - $errors[] = $error; - } - } else { - $errors[] = $iterator; - } - } - } - - return new FormErrorIterator($this, $errors); - } - - /** - * Returns a string representation of all form errors (including children errors). - * - * This method should only be used to help debug a form. - * - * @param int $level The indentation level (used internally) - * - * @return string A string representation of all errors - * - * @deprecated Deprecated since version 2.5, to be removed in 3.0. Use - * {@link getErrors()} instead and cast the result to a string. - */ - public function getErrorsAsString($level = 0) - { - return self::indent((string) $this->getErrors(true, false), $level); - } - - /** - * {@inheritdoc} - */ - public function all() - { - return iterator_to_array($this->children); - } - - /** - * {@inheritdoc} - */ - public function add($child, $type = null, array $options = array()) - { - if ($this->submitted) { - throw new AlreadySubmittedException('You cannot add children to a submitted form'); - } - - if (!$this->config->getCompound()) { - throw new LogicException('You cannot add children to a simple form. Maybe you should set the option "compound" to true?'); - } - - // Obtain the view data - $viewData = null; - - // If setData() is currently being called, there is no need to call - // mapDataToForms() here, as mapDataToForms() is called at the end - // of setData() anyway. Not doing this check leads to an endless - // recursion when initializing the form lazily and an event listener - // (such as ResizeFormListener) adds fields depending on the data: - // - // * setData() is called, the form is not initialized yet - // * add() is called by the listener (setData() is not complete, so - // the form is still not initialized) - // * getViewData() is called - // * setData() is called since the form is not initialized yet - // * ... endless recursion ... - // - // Also skip data mapping if setData() has not been called yet. - // setData() will be called upon form initialization and data mapping - // will take place by then. - if (!$this->lockSetData && $this->defaultDataSet && !$this->config->getInheritData()) { - $viewData = $this->getViewData(); - } - - if (!$child instanceof FormInterface) { - if (!is_string($child) && !is_int($child)) { - throw new UnexpectedTypeException($child, 'string, integer or Symfony\Component\Form\FormInterface'); - } - - if (null !== $type && !is_string($type) && !$type instanceof FormTypeInterface) { - throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface'); - } - - // Never initialize child forms automatically - $options['auto_initialize'] = false; - - if (null === $type && null === $this->config->getDataClass()) { - $type = 'text'; - } - - if (null === $type) { - $child = $this->config->getFormFactory()->createForProperty($this->config->getDataClass(), $child, null, $options); - } else { - $child = $this->config->getFormFactory()->createNamed($child, $type, null, $options); - } - } elseif ($child->getConfig()->getAutoInitialize()) { - throw new RuntimeException(sprintf( - 'Automatic initialization is only supported on root forms. You '. - 'should set the "auto_initialize" option to false on the field "%s".', - $child->getName() - )); - } - - $this->children[$child->getName()] = $child; - - $child->setParent($this); - - if (!$this->lockSetData && $this->defaultDataSet && !$this->config->getInheritData()) { - $iterator = new InheritDataAwareIterator(new \ArrayIterator(array($child))); - $iterator = new \RecursiveIteratorIterator($iterator); - $this->config->getDataMapper()->mapDataToForms($viewData, $iterator); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - if ($this->submitted) { - throw new AlreadySubmittedException('You cannot remove children from a submitted form'); - } - - if (isset($this->children[$name])) { - if (!$this->children[$name]->isSubmitted()) { - $this->children[$name]->setParent(null); - } - - unset($this->children[$name]); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - return isset($this->children[$name]); - } - - /** - * {@inheritdoc} - */ - public function get($name) - { - if (isset($this->children[$name])) { - return $this->children[$name]; - } - - throw new OutOfBoundsException(sprintf('Child "%s" does not exist.', $name)); - } - - /** - * Returns whether a child with the given name exists (implements the \ArrayAccess interface). - * - * @param string $name The name of the child - * - * @return bool - */ - public function offsetExists($name) - { - return $this->has($name); - } - - /** - * Returns the child with the given name (implements the \ArrayAccess interface). - * - * @param string $name The name of the child - * - * @return FormInterface The child form - * - * @throws \OutOfBoundsException If the named child does not exist. - */ - public function offsetGet($name) - { - return $this->get($name); - } - - /** - * Adds a child to the form (implements the \ArrayAccess interface). - * - * @param string $name Ignored. The name of the child is used. - * @param FormInterface $child The child to be added. - * - * @throws AlreadySubmittedException If the form has already been submitted. - * @throws LogicException When trying to add a child to a non-compound form. - * - * @see self::add() - */ - public function offsetSet($name, $child) - { - $this->add($child); - } - - /** - * Removes the child with the given name from the form (implements the \ArrayAccess interface). - * - * @param string $name The name of the child to remove - * - * @throws AlreadySubmittedException If the form has already been submitted. - */ - public function offsetUnset($name) - { - $this->remove($name); - } - - /** - * Returns the iterator for this group. - * - * @return \Traversable - */ - public function getIterator() - { - return $this->children; - } - - /** - * Returns the number of form children (implements the \Countable interface). - * - * @return int The number of embedded form children - */ - public function count() - { - return count($this->children); - } - - /** - * {@inheritdoc} - */ - public function createView(FormView $parent = null) - { - if (null === $parent && $this->parent) { - $parent = $this->parent->createView(); - } - - $type = $this->config->getType(); - $options = $this->config->getOptions(); - - // The methods createView(), buildView() and finishView() are called - // explicitly here in order to be able to override either of them - // in a custom resolved form type. - $view = $type->createView($this, $parent); - - $type->buildView($view, $this, $options); - - foreach ($this->children as $name => $child) { - $view->children[$name] = $child->createView($view); - } - - $type->finishView($view, $this, $options); - - return $view; - } - - /** - * Normalizes the value if a normalization transformer is set. - * - * @param mixed $value The value to transform - * - * @throws TransformationFailedException If the value cannot be transformed to "normalized" format - * - * @return mixed - */ - private function modelToNorm($value) - { - try { - foreach ($this->config->getModelTransformers() as $transformer) { - $value = $transformer->transform($value); - } - } catch (TransformationFailedException $exception) { - throw new TransformationFailedException( - 'Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), - $exception->getCode(), - $exception - ); - } - - return $value; - } - - /** - * Reverse transforms a value if a normalization transformer is set. - * - * @param string $value The value to reverse transform - * - * @throws TransformationFailedException If the value cannot be transformed to "model" format - * - * @return mixed - */ - private function normToModel($value) - { - try { - $transformers = $this->config->getModelTransformers(); - - for ($i = count($transformers) - 1; $i >= 0; --$i) { - $value = $transformers[$i]->reverseTransform($value); - } - } catch (TransformationFailedException $exception) { - throw new TransformationFailedException( - 'Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), - $exception->getCode(), - $exception - ); - } - - return $value; - } - - /** - * Transforms the value if a value transformer is set. - * - * @param mixed $value The value to transform - * - * @throws TransformationFailedException If the value cannot be transformed to "view" format - * - * @return mixed - */ - private function normToView($value) - { - // Scalar values should be converted to strings to - // facilitate differentiation between empty ("") and zero (0). - // Only do this for simple forms, as the resulting value in - // compound forms is passed to the data mapper and thus should - // not be converted to a string before. - if (!$this->config->getViewTransformers() && !$this->config->getCompound()) { - return null === $value || is_scalar($value) ? (string) $value : $value; - } - - try { - foreach ($this->config->getViewTransformers() as $transformer) { - $value = $transformer->transform($value); - } - } catch (TransformationFailedException $exception) { - throw new TransformationFailedException( - 'Unable to transform value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), - $exception->getCode(), - $exception - ); - } - - return $value; - } - - /** - * Reverse transforms a value if a value transformer is set. - * - * @param string $value The value to reverse transform - * - * @throws TransformationFailedException If the value cannot be transformed to "normalized" format - * - * @return mixed - */ - private function viewToNorm($value) - { - $transformers = $this->config->getViewTransformers(); - - if (!$transformers) { - return '' === $value ? null : $value; - } - - try { - for ($i = count($transformers) - 1; $i >= 0; --$i) { - $value = $transformers[$i]->reverseTransform($value); - } - } catch (TransformationFailedException $exception) { - throw new TransformationFailedException( - 'Unable to reverse value for property path "'.$this->getPropertyPath().'": '.$exception->getMessage(), - $exception->getCode(), - $exception - ); - } - - return $value; - } - - /** - * Utility function for indenting multi-line strings. - * - * @param string $string The string - * @param int $level The number of spaces to use for indentation - * - * @return string The indented string - */ - private static function indent($string, $level) - { - $indentation = str_repeat(' ', $level); - - return rtrim($indentation.str_replace("\n", "\n".$indentation, $string), ' '); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormBuilder.php b/vendor/symfony/form/Symfony/Component/Form/FormBuilder.php deleted file mode 100644 index 8b5b91941..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormBuilder.php +++ /dev/null @@ -1,272 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\BadMethodCallException; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -/** - * A builder for creating {@link Form} instances. - * - * @author Bernhard Schussek - */ -class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormBuilderInterface -{ - /** - * The children of the form builder. - * - * @var FormBuilderInterface[] - */ - private $children = array(); - - /** - * The data of children who haven't been converted to form builders yet. - * - * @var array - */ - private $unresolvedChildren = array(); - - /** - * Creates a new form builder. - * - * @param string $name - * @param string $dataClass - * @param EventDispatcherInterface $dispatcher - * @param FormFactoryInterface $factory - * @param array $options - */ - public function __construct($name, $dataClass, EventDispatcherInterface $dispatcher, FormFactoryInterface $factory, array $options = array()) - { - parent::__construct($name, $dataClass, $dispatcher, $options); - - $this->setFormFactory($factory); - } - - /** - * {@inheritdoc} - */ - public function add($child, $type = null, array $options = array()) - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - if ($child instanceof self) { - $this->children[$child->getName()] = $child; - - // In case an unresolved child with the same name exists - unset($this->unresolvedChildren[$child->getName()]); - - return $this; - } - - if (!is_string($child) && !is_int($child)) { - throw new UnexpectedTypeException($child, 'string, integer or Symfony\Component\Form\FormBuilder'); - } - - if (null !== $type && !is_string($type) && !$type instanceof FormTypeInterface) { - throw new UnexpectedTypeException($type, 'string or Symfony\Component\Form\FormTypeInterface'); - } - - // Add to "children" to maintain order - $this->children[$child] = null; - $this->unresolvedChildren[$child] = array( - 'type' => $type, - 'options' => $options, - ); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function create($name, $type = null, array $options = array()) - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - if (null === $type && null === $this->getDataClass()) { - $type = 'text'; - } - - if (null !== $type) { - return $this->getFormFactory()->createNamedBuilder($name, $type, null, $options); - } - - return $this->getFormFactory()->createBuilderForProperty($this->getDataClass(), $name, null, $options); - } - - /** - * {@inheritdoc} - */ - public function get($name) - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - if (isset($this->unresolvedChildren[$name])) { - return $this->resolveChild($name); - } - - if (isset($this->children[$name])) { - return $this->children[$name]; - } - - throw new InvalidArgumentException(sprintf('The child with the name "%s" does not exist.', $name)); - } - - /** - * {@inheritdoc} - */ - public function remove($name) - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - unset($this->unresolvedChildren[$name], $this->children[$name]); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function has($name) - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - if (isset($this->unresolvedChildren[$name])) { - return true; - } - - if (isset($this->children[$name])) { - return true; - } - - return false; - } - - /** - * {@inheritdoc} - */ - public function all() - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->resolveChildren(); - - return $this->children; - } - - /** - * {@inheritdoc} - */ - public function count() - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - return count($this->children); - } - - /** - * {@inheritdoc} - */ - public function getFormConfig() - { - /** @var $config self */ - $config = parent::getFormConfig(); - - $config->children = array(); - $config->unresolvedChildren = array(); - - return $config; - } - - /** - * {@inheritdoc} - */ - public function getForm() - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->resolveChildren(); - - $form = new Form($this->getFormConfig()); - - foreach ($this->children as $child) { - // Automatic initialization is only supported on root forms - $form->add($child->setAutoInitialize(false)->getForm()); - } - - if ($this->getAutoInitialize()) { - // Automatically initialize the form if it is configured so - $form->initialize(); - } - - return $form; - } - - /** - * {@inheritdoc} - */ - public function getIterator() - { - if ($this->locked) { - throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - return new \ArrayIterator($this->all()); - } - - /** - * Converts an unresolved child into a {@link FormBuilder} instance. - * - * @param string $name The name of the unresolved child. - * - * @return FormBuilder The created instance. - */ - private function resolveChild($name) - { - $info = $this->unresolvedChildren[$name]; - $child = $this->create($name, $info['type'], $info['options']); - $this->children[$name] = $child; - unset($this->unresolvedChildren[$name]); - - return $child; - } - - /** - * Converts all unresolved children into {@link FormBuilder} instances. - */ - private function resolveChildren() - { - foreach ($this->unresolvedChildren as $name => $info) { - $this->children[$name] = $this->create($name, $info['type'], $info['options']); - } - - $this->unresolvedChildren = array(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormBuilderInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormBuilderInterface.php deleted file mode 100644 index 998d3ec0d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormBuilderInterface.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * @author Bernhard Schussek - */ -interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface -{ - /** - * Adds a new field to this group. A field must have a unique name within - * the group. Otherwise the existing field is overwritten. - * - * If you add a nested group, this group should also be represented in the - * object hierarchy. - * - * @param string|int|FormBuilderInterface $child - * @param string|FormTypeInterface $type - * @param array $options - * - * @return FormBuilderInterface The builder object. - */ - public function add($child, $type = null, array $options = array()); - - /** - * Creates a form builder. - * - * @param string $name The name of the form or the name of the property - * @param string|FormTypeInterface $type The type of the form or null if name is a property - * @param array $options The options - * - * @return FormBuilderInterface The created builder. - */ - public function create($name, $type = null, array $options = array()); - - /** - * Returns a child by name. - * - * @param string $name The name of the child - * - * @return FormBuilderInterface The builder for the child - * - * @throws Exception\InvalidArgumentException if the given child does not exist - */ - public function get($name); - - /** - * Removes the field with the given name. - * - * @param string $name - * - * @return FormBuilderInterface The builder object. - */ - public function remove($name); - - /** - * Returns whether a field with the given name exists. - * - * @param string $name - * - * @return bool - */ - public function has($name); - - /** - * Returns the children. - * - * @return array - */ - public function all(); - - /** - * Creates the form. - * - * @return Form The form - */ - public function getForm(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormConfigBuilder.php b/vendor/symfony/form/Symfony/Component/Form/FormConfigBuilder.php deleted file mode 100644 index ce776a7b0..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormConfigBuilder.php +++ /dev/null @@ -1,919 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\BadMethodCallException; -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\PropertyAccess\PropertyPath; -use Symfony\Component\PropertyAccess\PropertyPathInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\EventDispatcher\ImmutableEventDispatcher; - -/** - * A basic form configuration. - * - * @author Bernhard Schussek - */ -class FormConfigBuilder implements FormConfigBuilderInterface -{ - /** - * Caches a globally unique {@link NativeRequestHandler} instance. - * - * @var NativeRequestHandler - */ - private static $nativeRequestProcessor; - - /** - * The accepted request methods. - * - * @var array - */ - private static $allowedMethods = array( - 'GET', - 'PUT', - 'POST', - 'DELETE', - 'PATCH', - ); - - /** - * @var bool - */ - protected $locked = false; - - /** - * @var EventDispatcherInterface - */ - private $dispatcher; - - /** - * @var string - */ - private $name; - - /** - * @var PropertyPathInterface - */ - private $propertyPath; - - /** - * @var bool - */ - private $mapped = true; - - /** - * @var bool - */ - private $byReference = true; - - /** - * @var bool - */ - private $inheritData = false; - - /** - * @var bool - */ - private $compound = false; - - /** - * @var ResolvedFormTypeInterface - */ - private $type; - - /** - * @var array - */ - private $viewTransformers = array(); - - /** - * @var array - */ - private $modelTransformers = array(); - - /** - * @var DataMapperInterface - */ - private $dataMapper; - - /** - * @var bool - */ - private $required = true; - - /** - * @var bool - */ - private $disabled = false; - - /** - * @var bool - */ - private $errorBubbling = false; - - /** - * @var mixed - */ - private $emptyData; - - /** - * @var array - */ - private $attributes = array(); - - /** - * @var mixed - */ - private $data; - - /** - * @var string - */ - private $dataClass; - - /** - * @var bool - */ - private $dataLocked; - - /** - * @var FormFactoryInterface - */ - private $formFactory; - - /** - * @var string - */ - private $action; - - /** - * @var string - */ - private $method = 'POST'; - - /** - * @var RequestHandlerInterface - */ - private $requestHandler; - - /** - * @var bool - */ - private $autoInitialize = false; - - /** - * @var array - */ - private $options; - - /** - * Creates an empty form configuration. - * - * @param string|int $name The form name - * @param string $dataClass The class of the form's data - * @param EventDispatcherInterface $dispatcher The event dispatcher - * @param array $options The form options - * - * @throws InvalidArgumentException If the data class is not a valid class or if - * the name contains invalid characters. - */ - public function __construct($name, $dataClass, EventDispatcherInterface $dispatcher, array $options = array()) - { - self::validateName($name); - - if (null !== $dataClass && !class_exists($dataClass) && !interface_exists($dataClass)) { - throw new InvalidArgumentException(sprintf('Class "%s" not found. Is the "data_class" form option set correctly?', $dataClass)); - } - - $this->name = (string) $name; - $this->dataClass = $dataClass; - $this->dispatcher = $dispatcher; - $this->options = $options; - } - - /** - * {@inheritdoc} - */ - public function addEventListener($eventName, $listener, $priority = 0) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->dispatcher->addListener($eventName, $listener, $priority); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addEventSubscriber(EventSubscriberInterface $subscriber) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->dispatcher->addSubscriber($subscriber); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addViewTransformer(DataTransformerInterface $viewTransformer, $forcePrepend = false) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - if ($forcePrepend) { - array_unshift($this->viewTransformers, $viewTransformer); - } else { - $this->viewTransformers[] = $viewTransformer; - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function resetViewTransformers() - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->viewTransformers = array(); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - if ($forceAppend) { - $this->modelTransformers[] = $modelTransformer; - } else { - array_unshift($this->modelTransformers, $modelTransformer); - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function resetModelTransformers() - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->modelTransformers = array(); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getEventDispatcher() - { - if ($this->locked && !$this->dispatcher instanceof ImmutableEventDispatcher) { - $this->dispatcher = new ImmutableEventDispatcher($this->dispatcher); - } - - return $this->dispatcher; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getPropertyPath() - { - return $this->propertyPath; - } - - /** - * {@inheritdoc} - */ - public function getMapped() - { - return $this->mapped; - } - - /** - * {@inheritdoc} - */ - public function getByReference() - { - return $this->byReference; - } - - /** - * {@inheritdoc} - */ - public function getInheritData() - { - return $this->inheritData; - } - - /** - * Alias of {@link getInheritData()}. - * - * @return FormConfigBuilder The configuration object. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link getInheritData()} instead. - */ - public function getVirtual() - { - // Uncomment this as soon as the deprecation note should be shown - // trigger_error('getVirtual() is deprecated since version 2.3 and will be removed in 3.0. Use getInheritData() instead.', E_USER_DEPRECATED); - return $this->getInheritData(); - } - - /** - * {@inheritdoc} - */ - public function getCompound() - { - return $this->compound; - } - - /** - * {@inheritdoc} - */ - public function getType() - { - return $this->type; - } - - /** - * {@inheritdoc} - */ - public function getViewTransformers() - { - return $this->viewTransformers; - } - - /** - * {@inheritdoc} - */ - public function getModelTransformers() - { - return $this->modelTransformers; - } - - /** - * {@inheritdoc} - */ - public function getDataMapper() - { - return $this->dataMapper; - } - - /** - * {@inheritdoc} - */ - public function getRequired() - { - return $this->required; - } - - /** - * {@inheritdoc} - */ - public function getDisabled() - { - return $this->disabled; - } - - /** - * {@inheritdoc} - */ - public function getErrorBubbling() - { - return $this->errorBubbling; - } - - /** - * {@inheritdoc} - */ - public function getEmptyData() - { - return $this->emptyData; - } - - /** - * {@inheritdoc} - */ - public function getAttributes() - { - return $this->attributes; - } - - /** - * {@inheritdoc} - */ - public function hasAttribute($name) - { - return array_key_exists($name, $this->attributes); - } - - /** - * {@inheritdoc} - */ - public function getAttribute($name, $default = null) - { - return array_key_exists($name, $this->attributes) ? $this->attributes[$name] : $default; - } - - /** - * {@inheritdoc} - */ - public function getData() - { - return $this->data; - } - - /** - * {@inheritdoc} - */ - public function getDataClass() - { - return $this->dataClass; - } - - /** - * {@inheritdoc} - */ - public function getDataLocked() - { - return $this->dataLocked; - } - - /** - * {@inheritdoc} - */ - public function getFormFactory() - { - return $this->formFactory; - } - - /** - * {@inheritdoc} - */ - public function getAction() - { - return $this->action; - } - - /** - * {@inheritdoc} - */ - public function getMethod() - { - return $this->method; - } - - /** - * {@inheritdoc} - */ - public function getRequestHandler() - { - if (null === $this->requestHandler) { - if (null === self::$nativeRequestProcessor) { - self::$nativeRequestProcessor = new NativeRequestHandler(); - } - $this->requestHandler = self::$nativeRequestProcessor; - } - - return $this->requestHandler; - } - - /** - * {@inheritdoc} - */ - public function getAutoInitialize() - { - return $this->autoInitialize; - } - - /** - * {@inheritdoc} - */ - public function getOptions() - { - return $this->options; - } - - /** - * {@inheritdoc} - */ - public function hasOption($name) - { - return array_key_exists($name, $this->options); - } - - /** - * {@inheritdoc} - */ - public function getOption($name, $default = null) - { - return array_key_exists($name, $this->options) ? $this->options[$name] : $default; - } - - /** - * {@inheritdoc} - */ - public function setAttribute($name, $value) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->attributes[$name] = $value; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setAttributes(array $attributes) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->attributes = $attributes; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setDataMapper(DataMapperInterface $dataMapper = null) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->dataMapper = $dataMapper; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setDisabled($disabled) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->disabled = (bool) $disabled; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setEmptyData($emptyData) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->emptyData = $emptyData; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setErrorBubbling($errorBubbling) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->errorBubbling = null === $errorBubbling ? null : (bool) $errorBubbling; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setRequired($required) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->required = (bool) $required; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setPropertyPath($propertyPath) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - if (null !== $propertyPath && !$propertyPath instanceof PropertyPathInterface) { - $propertyPath = new PropertyPath($propertyPath); - } - - $this->propertyPath = $propertyPath; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setMapped($mapped) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->mapped = $mapped; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setByReference($byReference) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->byReference = $byReference; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setInheritData($inheritData) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->inheritData = $inheritData; - - return $this; - } - - /** - * Alias of {@link setInheritData()}. - * - * @param bool $inheritData Whether the form should inherit its parent's data. - * - * @return FormConfigBuilder The configuration object. - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link setInheritData()} instead. - */ - public function setVirtual($inheritData) - { - // Uncomment this as soon as the deprecation note should be shown - // trigger_error('setVirtual() is deprecated since version 2.3 and will be removed in 3.0. Use setInheritData() instead.', E_USER_DEPRECATED); - - $this->setInheritData($inheritData); - } - - /** - * {@inheritdoc} - */ - public function setCompound($compound) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->compound = $compound; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setType(ResolvedFormTypeInterface $type) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->type = $type; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setData($data) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->data = $data; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setDataLocked($locked) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->dataLocked = $locked; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setFormFactory(FormFactoryInterface $formFactory) - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - $this->formFactory = $formFactory; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setAction($action) - { - if ($this->locked) { - throw new BadMethodCallException('The config builder cannot be modified anymore.'); - } - - $this->action = $action; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setMethod($method) - { - if ($this->locked) { - throw new BadMethodCallException('The config builder cannot be modified anymore.'); - } - - $upperCaseMethod = strtoupper($method); - - if (!in_array($upperCaseMethod, self::$allowedMethods)) { - throw new InvalidArgumentException(sprintf( - 'The form method is "%s", but should be one of "%s".', - $method, - implode('", "', self::$allowedMethods) - )); - } - - $this->method = $upperCaseMethod; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setRequestHandler(RequestHandlerInterface $requestHandler) - { - if ($this->locked) { - throw new BadMethodCallException('The config builder cannot be modified anymore.'); - } - - $this->requestHandler = $requestHandler; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function setAutoInitialize($initialize) - { - $this->autoInitialize = (bool) $initialize; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getFormConfig() - { - if ($this->locked) { - throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.'); - } - - // This method should be idempotent, so clone the builder - $config = clone $this; - $config->locked = true; - - return $config; - } - - /** - * Validates whether the given variable is a valid form name. - * - * @param string|int $name The tested form name. - * - * @throws UnexpectedTypeException If the name is not a string or an integer. - * @throws InvalidArgumentException If the name contains invalid characters. - */ - public static function validateName($name) - { - if (null !== $name && !is_string($name) && !is_int($name)) { - throw new UnexpectedTypeException($name, 'string, integer or null'); - } - - if (!self::isValidName($name)) { - throw new InvalidArgumentException(sprintf( - 'The name "%s" contains illegal characters. Names should start with a letter, digit or underscore and only contain letters, digits, numbers, underscores ("_"), hyphens ("-") and colons (":").', - $name - )); - } - } - - /** - * Returns whether the given variable contains a valid form name. - * - * A name is accepted if it - * - * * is empty - * * starts with a letter, digit or underscore - * * contains only letters, digits, numbers, underscores ("_"), - * hyphens ("-") and colons (":") - * - * @param string $name The tested form name. - * - * @return bool Whether the name is valid. - */ - public static function isValidName($name) - { - return '' === $name || null === $name || preg_match('/^[a-zA-Z0-9_][a-zA-Z0-9_\-:]*$/D', $name); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormConfigBuilderInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormConfigBuilderInterface.php deleted file mode 100644 index ad8bf6932..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormConfigBuilderInterface.php +++ /dev/null @@ -1,288 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\EventDispatcher\EventSubscriberInterface; -use Symfony\Component\PropertyAccess\PropertyPathInterface; - -/** - * @author Bernhard Schussek - */ -interface FormConfigBuilderInterface extends FormConfigInterface -{ - /** - * Adds an event listener to an event on this form. - * - * @param string $eventName The name of the event to listen to. - * @param callable $listener The listener to execute. - * @param int $priority The priority of the listener. Listeners - * with a higher priority are called before - * listeners with a lower priority. - * - * @return self The configuration object. - */ - public function addEventListener($eventName, $listener, $priority = 0); - - /** - * Adds an event subscriber for events on this form. - * - * @param EventSubscriberInterface $subscriber The subscriber to attach. - * - * @return self The configuration object. - */ - public function addEventSubscriber(EventSubscriberInterface $subscriber); - - /** - * Appends / prepends a transformer to the view transformer chain. - * - * The transform method of the transformer is used to convert data from the - * normalized to the view format. - * The reverseTransform method of the transformer is used to convert from the - * view to the normalized format. - * - * @param DataTransformerInterface $viewTransformer - * @param bool $forcePrepend if set to true, prepend instead of appending - * - * @return self The configuration object. - */ - public function addViewTransformer(DataTransformerInterface $viewTransformer, $forcePrepend = false); - - /** - * Clears the view transformers. - * - * @return self The configuration object. - */ - public function resetViewTransformers(); - - /** - * Prepends / appends a transformer to the normalization transformer chain. - * - * The transform method of the transformer is used to convert data from the - * model to the normalized format. - * The reverseTransform method of the transformer is used to convert from the - * normalized to the model format. - * - * @param DataTransformerInterface $modelTransformer - * @param bool $forceAppend if set to true, append instead of prepending - * - * @return self The configuration object. - */ - public function addModelTransformer(DataTransformerInterface $modelTransformer, $forceAppend = false); - - /** - * Clears the normalization transformers. - * - * @return self The configuration object. - */ - public function resetModelTransformers(); - - /** - * Sets the value for an attribute. - * - * @param string $name The name of the attribute - * @param mixed $value The value of the attribute - * - * @return self The configuration object. - */ - public function setAttribute($name, $value); - - /** - * Sets the attributes. - * - * @param array $attributes The attributes. - * - * @return self The configuration object. - */ - public function setAttributes(array $attributes); - - /** - * Sets the data mapper used by the form. - * - * @param DataMapperInterface $dataMapper - * - * @return self The configuration object. - */ - public function setDataMapper(DataMapperInterface $dataMapper = null); - - /** - * Set whether the form is disabled. - * - * @param bool $disabled Whether the form is disabled - * - * @return self The configuration object. - */ - public function setDisabled($disabled); - - /** - * Sets the data used for the client data when no value is submitted. - * - * @param mixed $emptyData The empty data. - * - * @return self The configuration object. - */ - public function setEmptyData($emptyData); - - /** - * Sets whether errors bubble up to the parent. - * - * @param bool $errorBubbling - * - * @return self The configuration object. - */ - public function setErrorBubbling($errorBubbling); - - /** - * Sets whether this field is required to be filled out when submitted. - * - * @param bool $required - * - * @return self The configuration object. - */ - public function setRequired($required); - - /** - * Sets the property path that the form should be mapped to. - * - * @param null|string|PropertyPathInterface $propertyPath - * The property path or null if the path should be set - * automatically based on the form's name. - * - * @return self The configuration object. - */ - public function setPropertyPath($propertyPath); - - /** - * Sets whether the form should be mapped to an element of its - * parent's data. - * - * @param bool $mapped Whether the form should be mapped. - * - * @return self The configuration object. - */ - public function setMapped($mapped); - - /** - * Sets whether the form's data should be modified by reference. - * - * @param bool $byReference Whether the data should be - * modified by reference. - * - * @return self The configuration object. - */ - public function setByReference($byReference); - - /** - * Sets whether the form should read and write the data of its parent. - * - * @param bool $inheritData Whether the form should inherit its parent's data. - * - * @return self The configuration object. - */ - public function setInheritData($inheritData); - - /** - * Sets whether the form should be compound. - * - * @param bool $compound Whether the form should be compound. - * - * @return self The configuration object. - * - * @see FormConfigInterface::getCompound() - */ - public function setCompound($compound); - - /** - * Set the types. - * - * @param ResolvedFormTypeInterface $type The type of the form. - * - * @return self The configuration object. - */ - public function setType(ResolvedFormTypeInterface $type); - - /** - * Sets the initial data of the form. - * - * @param mixed $data The data of the form in application format. - * - * @return self The configuration object. - */ - public function setData($data); - - /** - * Locks the form's data to the data passed in the configuration. - * - * A form with locked data is restricted to the data passed in - * this configuration. The data can only be modified then by - * submitting the form. - * - * @param bool $locked Whether to lock the default data. - * - * @return self The configuration object. - */ - public function setDataLocked($locked); - - /** - * Sets the form factory used for creating new forms. - * - * @param FormFactoryInterface $formFactory The form factory. - */ - public function setFormFactory(FormFactoryInterface $formFactory); - - /** - * Sets the target URL of the form. - * - * @param string $action The target URL of the form. - * - * @return self The configuration object. - */ - public function setAction($action); - - /** - * Sets the HTTP method used by the form. - * - * @param string $method The HTTP method of the form. - * - * @return self The configuration object. - */ - public function setMethod($method); - - /** - * Sets the request handler used by the form. - * - * @param RequestHandlerInterface $requestHandler - * - * @return self The configuration object. - */ - public function setRequestHandler(RequestHandlerInterface $requestHandler); - - /** - * Sets whether the form should be initialized automatically. - * - * Should be set to true only for root forms. - * - * @param bool $initialize True to initialize the form automatically, - * false to suppress automatic initialization. - * In the second case, you need to call - * {@link FormInterface::initialize()} manually. - * - * @return self The configuration object. - */ - public function setAutoInitialize($initialize); - - /** - * Builds and returns the form configuration. - * - * @return FormConfigInterface - */ - public function getFormConfig(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormConfigInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormConfigInterface.php deleted file mode 100644 index 179905850..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormConfigInterface.php +++ /dev/null @@ -1,246 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\PropertyAccess\PropertyPathInterface; - -/** - * The configuration of a {@link Form} object. - * - * @author Bernhard Schussek - */ -interface FormConfigInterface -{ - /** - * Returns the event dispatcher used to dispatch form events. - * - * @return EventDispatcherInterface The dispatcher. - */ - public function getEventDispatcher(); - - /** - * Returns the name of the form used as HTTP parameter. - * - * @return string The form name. - */ - public function getName(); - - /** - * Returns the property path that the form should be mapped to. - * - * @return null|PropertyPathInterface The property path. - */ - public function getPropertyPath(); - - /** - * Returns whether the form should be mapped to an element of its - * parent's data. - * - * @return bool Whether the form is mapped. - */ - public function getMapped(); - - /** - * Returns whether the form's data should be modified by reference. - * - * @return bool Whether to modify the form's data by reference. - */ - public function getByReference(); - - /** - * Returns whether the form should read and write the data of its parent. - * - * @return bool Whether the form should inherit its parent's data. - */ - public function getInheritData(); - - /** - * Returns whether the form is compound. - * - * This property is independent of whether the form actually has - * children. A form can be compound and have no children at all, like - * for example an empty collection form. - * - * @return bool Whether the form is compound. - */ - public function getCompound(); - - /** - * Returns the form types used to construct the form. - * - * @return ResolvedFormTypeInterface The form's type. - */ - public function getType(); - - /** - * Returns the view transformers of the form. - * - * @return DataTransformerInterface[] An array of {@link DataTransformerInterface} instances. - */ - public function getViewTransformers(); - - /** - * Returns the model transformers of the form. - * - * @return DataTransformerInterface[] An array of {@link DataTransformerInterface} instances. - */ - public function getModelTransformers(); - - /** - * Returns the data mapper of the form. - * - * @return DataMapperInterface The data mapper. - */ - public function getDataMapper(); - - /** - * Returns whether the form is required. - * - * @return bool Whether the form is required. - */ - public function getRequired(); - - /** - * Returns whether the form is disabled. - * - * @return bool Whether the form is disabled. - */ - public function getDisabled(); - - /** - * Returns whether errors attached to the form will bubble to its parent. - * - * @return bool Whether errors will bubble up. - */ - public function getErrorBubbling(); - - /** - * Returns the data that should be returned when the form is empty. - * - * @return mixed The data returned if the form is empty. - */ - public function getEmptyData(); - - /** - * Returns additional attributes of the form. - * - * @return array An array of key-value combinations. - */ - public function getAttributes(); - - /** - * Returns whether the attribute with the given name exists. - * - * @param string $name The attribute name. - * - * @return bool Whether the attribute exists. - */ - public function hasAttribute($name); - - /** - * Returns the value of the given attribute. - * - * @param string $name The attribute name. - * @param mixed $default The value returned if the attribute does not exist. - * - * @return mixed The attribute value. - */ - public function getAttribute($name, $default = null); - - /** - * Returns the initial data of the form. - * - * @return mixed The initial form data. - */ - public function getData(); - - /** - * Returns the class of the form data or null if the data is scalar or an array. - * - * @return string The data class or null. - */ - public function getDataClass(); - - /** - * Returns whether the form's data is locked. - * - * A form with locked data is restricted to the data passed in - * this configuration. The data can only be modified then by - * submitting the form. - * - * @return bool Whether the data is locked. - */ - public function getDataLocked(); - - /** - * Returns the form factory used for creating new forms. - * - * @return FormFactoryInterface The form factory. - */ - public function getFormFactory(); - - /** - * Returns the target URL of the form. - * - * @return string The target URL of the form. - */ - public function getAction(); - - /** - * Returns the HTTP method used by the form. - * - * @return string The HTTP method of the form. - */ - public function getMethod(); - - /** - * Returns the request handler used by the form. - * - * @return RequestHandlerInterface The request handler. - */ - public function getRequestHandler(); - - /** - * Returns whether the form should be initialized upon creation. - * - * @return bool Returns true if the form should be initialized - * when created, false otherwise. - */ - public function getAutoInitialize(); - - /** - * Returns all options passed during the construction of the form. - * - * @return array The passed options. - */ - public function getOptions(); - - /** - * Returns whether a specific option exists. - * - * @param string $name The option name, - * - * @return bool Whether the option exists. - */ - public function hasOption($name); - - /** - * Returns the value of a specific option. - * - * @param string $name The option name. - * @param mixed $default The value returned if the option does not exist. - * - * @return mixed The option value. - */ - public function getOption($name, $default = null); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormError.php b/vendor/symfony/form/Symfony/Component/Form/FormError.php deleted file mode 100644 index 6b3938868..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormError.php +++ /dev/null @@ -1,190 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\BadMethodCallException; - -/** - * Wraps errors in forms. - * - * @author Bernhard Schussek - */ -class FormError implements \Serializable -{ - /** - * @var string - */ - private $message; - - /** - * The template for the error message. - * - * @var string - */ - protected $messageTemplate; - - /** - * The parameters that should be substituted in the message template. - * - * @var array - */ - protected $messageParameters; - - /** - * The value for error message pluralization. - * - * @var int|null - */ - protected $messagePluralization; - - /** - * The cause for this error. - * - * @var mixed - */ - private $cause; - - /** - * The form that spawned this error. - * - * @var FormInterface - */ - private $origin; - - /** - * Constructor. - * - * Any array key in $messageParameters will be used as a placeholder in - * $messageTemplate. - * - * @param string $message The translated error message - * @param string|null $messageTemplate The template for the error message - * @param array $messageParameters The parameters that should be - * substituted in the message template - * @param int|null $messagePluralization The value for error message pluralization - * @param mixed $cause The cause of the error - * - * @see \Symfony\Component\Translation\Translator - */ - public function __construct($message, $messageTemplate = null, array $messageParameters = array(), $messagePluralization = null, $cause = null) - { - $this->message = $message; - $this->messageTemplate = $messageTemplate ?: $message; - $this->messageParameters = $messageParameters; - $this->messagePluralization = $messagePluralization; - $this->cause = $cause; - } - - /** - * Returns the error message. - * - * @return string - */ - public function getMessage() - { - return $this->message; - } - - /** - * Returns the error message template. - * - * @return string - */ - public function getMessageTemplate() - { - return $this->messageTemplate; - } - - /** - * Returns the parameters to be inserted in the message template. - * - * @return array - */ - public function getMessageParameters() - { - return $this->messageParameters; - } - - /** - * Returns the value for error message pluralization. - * - * @return int|null - */ - public function getMessagePluralization() - { - return $this->messagePluralization; - } - - /** - * Returns the cause of this error. - * - * @return mixed The cause of this error - */ - public function getCause() - { - return $this->cause; - } - - /** - * Sets the form that caused this error. - * - * This method must only be called once. - * - * @param FormInterface $origin The form that caused this error - * - * @throws BadMethodCallException If the method is called more than once - */ - public function setOrigin(FormInterface $origin) - { - if (null !== $this->origin) { - throw new BadMethodCallException('setOrigin() must only be called once.'); - } - - $this->origin = $origin; - } - - /** - * Returns the form that caused this error. - * - * @return FormInterface The form that caused this error - */ - public function getOrigin() - { - return $this->origin; - } - - /** - * Serializes this error. - * - * @return string The serialized error - */ - public function serialize() - { - return serialize(array( - $this->message, - $this->messageTemplate, - $this->messageParameters, - $this->messagePluralization, - $this->cause, - )); - } - - /** - * Unserializes a serialized error. - * - * @param string $serialized The serialized error - */ - public function unserialize($serialized) - { - list($this->message, $this->messageTemplate, $this->messageParameters, $this->messagePluralization, $this->cause) = unserialize($serialized); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormErrorIterator.php b/vendor/symfony/form/Symfony/Component/Form/FormErrorIterator.php deleted file mode 100644 index 76e293890..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormErrorIterator.php +++ /dev/null @@ -1,281 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Exception\OutOfBoundsException; -use Symfony\Component\Form\Exception\BadMethodCallException; - -/** - * Iterates over the errors of a form. - * - * Optionally, this class supports recursive iteration. In order to iterate - * recursively, set the constructor argument $deep to true. Now each element - * returned by the iterator is either an instance of {@link FormError} or of - * {@link FormErrorIterator}, in case the errors belong to a sub-form. - * - * You can also wrap the iterator into a {@link \RecursiveIteratorIterator} to - * flatten the recursive structure into a flat list of errors. - * - * @author Bernhard Schussek - * - * @since 2.5 - */ -class FormErrorIterator implements \RecursiveIterator, \SeekableIterator, \ArrayAccess, \Countable -{ - /** - * The prefix used for indenting nested error messages. - * - * @var string - */ - const INDENTATION = ' '; - - /** - * @var FormInterface - */ - private $form; - - /** - * @var FormError[]|FormErrorIterator[] - */ - private $errors; - - /** - * Creates a new iterator. - * - * @param FormInterface $form The erroneous form - * @param array $errors The form errors - * - * @throws InvalidArgumentException If the errors are invalid - */ - public function __construct(FormInterface $form, array $errors) - { - foreach ($errors as $error) { - if (!($error instanceof FormError || $error instanceof self)) { - throw new InvalidArgumentException(sprintf( - 'The errors must be instances of '. - '"\Symfony\Component\Form\FormError" or "%s". Got: "%s".', - __CLASS__, - is_object($error) ? get_class($error) : gettype($error) - )); - } - } - - $this->form = $form; - $this->errors = $errors; - } - - /** - * Returns all iterated error messages as string. - * - * @return string The iterated error messages - */ - public function __toString() - { - $string = ''; - - foreach ($this->errors as $error) { - if ($error instanceof FormError) { - $string .= 'ERROR: '.$error->getMessage()."\n"; - } else { - /** @var $error FormErrorIterator */ - $string .= $error->form->getName().":\n"; - $string .= self::indent((string) $error); - } - } - - return $string; - } - - /** - * Returns the iterated form. - * - * @return FormInterface The form whose errors are iterated by this object. - */ - public function getForm() - { - return $this->form; - } - - /** - * Returns the current element of the iterator. - * - * @return FormError|FormErrorIterator An error or an iterator containing - * nested errors. - */ - public function current() - { - return current($this->errors); - } - - /** - * Advances the iterator to the next position. - */ - public function next() - { - next($this->errors); - } - - /** - * Returns the current position of the iterator. - * - * @return int The 0-indexed position. - */ - public function key() - { - return key($this->errors); - } - - /** - * Returns whether the iterator's position is valid. - * - * @return bool Whether the iterator is valid. - */ - public function valid() - { - return null !== key($this->errors); - } - - /** - * Sets the iterator's position to the beginning. - * - * This method detects if errors have been added to the form since the - * construction of the iterator. - */ - public function rewind() - { - reset($this->errors); - } - - /** - * Returns whether a position exists in the iterator. - * - * @param int $position The position - * - * @return bool Whether that position exists - */ - public function offsetExists($position) - { - return isset($this->errors[$position]); - } - - /** - * Returns the element at a position in the iterator. - * - * @param int $position The position - * - * @return FormError|FormErrorIterator The element at the given position - * - * @throws OutOfBoundsException If the given position does not exist - */ - public function offsetGet($position) - { - if (!isset($this->errors[$position])) { - throw new OutOfBoundsException('The offset '.$position.' does not exist.'); - } - - return $this->errors[$position]; - } - - /** - * Unsupported method. - * - * @throws BadMethodCallException - */ - public function offsetSet($position, $value) - { - throw new BadMethodCallException('The iterator doesn\'t support modification of elements.'); - } - - /** - * Unsupported method. - * - * @throws BadMethodCallException - */ - public function offsetUnset($position) - { - throw new BadMethodCallException('The iterator doesn\'t support modification of elements.'); - } - - /** - * Returns whether the current element of the iterator can be recursed - * into. - * - * @return bool Whether the current element is an instance of this class - */ - public function hasChildren() - { - return current($this->errors) instanceof self; - } - - /** - * Alias of {@link current()}. - */ - public function getChildren() - { - return current($this->errors); - } - - /** - * Returns the number of elements in the iterator. - * - * Note that this is not the total number of errors, if the constructor - * parameter $deep was set to true! In that case, you should wrap the - * iterator into a {@link \RecursiveIteratorIterator} with the standard mode - * {@link \RecursiveIteratorIterator::LEAVES_ONLY} and count the result. - * - * $iterator = new \RecursiveIteratorIterator($form->getErrors(true)); - * $count = count(iterator_to_array($iterator)); - * - * Alternatively, set the constructor argument $flatten to true as well. - * - * $count = count($form->getErrors(true, true)); - * - * @return int The number of iterated elements - */ - public function count() - { - return count($this->errors); - } - - /** - * Sets the position of the iterator. - * - * @param int $position The new position - * - * @throws OutOfBoundsException If the position is invalid - */ - public function seek($position) - { - if (!isset($this->errors[$position])) { - throw new OutOfBoundsException('The offset '.$position.' does not exist.'); - } - - reset($this->errors); - - while ($position !== key($this->errors)) { - next($this->errors); - } - } - - /** - * Utility function for indenting multi-line strings. - * - * @param string $string The string - * - * @return string The indented string - */ - private static function indent($string) - { - return rtrim(self::INDENTATION.str_replace("\n", "\n".self::INDENTATION, $string), ' '); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormEvent.php b/vendor/symfony/form/Symfony/Component/Form/FormEvent.php deleted file mode 100644 index 57cebade6..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormEvent.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\EventDispatcher\Event; - -/** - * @author Bernhard Schussek - */ -class FormEvent extends Event -{ - private $form; - protected $data; - - /** - * Constructs an event. - * - * @param FormInterface $form The associated form - * @param mixed $data The data - */ - public function __construct(FormInterface $form, $data) - { - $this->form = $form; - $this->data = $data; - } - - /** - * Returns the form at the source of the event. - * - * @return FormInterface - */ - public function getForm() - { - return $this->form; - } - - /** - * Returns the data associated with this event. - * - * @return mixed - */ - public function getData() - { - return $this->data; - } - - /** - * Allows updating with some filtered data. - * - * @param mixed $data - */ - public function setData($data) - { - $this->data = $data; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormEvents.php b/vendor/symfony/form/Symfony/Component/Form/FormEvents.php deleted file mode 100644 index 978e716e9..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormEvents.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * To learn more about how form events work check the documentation - * entry at {@link http://symfony.com/doc/any/components/form/form_events.html}. - * - * To learn how to dynamically modify forms using events check the cookbook - * entry at {@link http://symfony.com/doc/any/cookbook/form/dynamic_form_modification.html}. - * - * @author Bernhard Schussek - */ -final class FormEvents -{ - /** - * The PRE_SUBMIT event is dispatched at the beginning of the Form::submit() method. - * - * It can be used to: - * - Change data from the request, before submitting the data to the form. - * - Add or remove form fields, before submitting the data to the form. - * The event listener method receives a Symfony\Component\Form\FormEvent instance. - * - * @Event - */ - const PRE_SUBMIT = 'form.pre_bind'; - - /** - * The SUBMIT event is dispatched just before the Form::submit() method - * transforms back the normalized data to the model and view data. - * - * It can be used to change data from the normalized representation of the data. - * The event listener method receives a Symfony\Component\Form\FormEvent instance. - * - * @Event - */ - const SUBMIT = 'form.bind'; - - /** - * The FormEvents::POST_SUBMIT event is dispatched after the Form::submit() - * once the model and view data have been denormalized. - * - * It can be used to fetch data after denormalization. - * The event listener method receives a Symfony\Component\Form\FormEvent instance. - * - * @Event - */ - const POST_SUBMIT = 'form.post_bind'; - - /** - * The FormEvents::PRE_SET_DATA event is dispatched at the beginning of the Form::setData() method. - * - * It can be used to: - * - Modify the data given during pre-population; - * - Modify a form depending on the pre-populated data (adding or removing fields dynamically). - * The event listener method receives a Symfony\Component\Form\FormEvent instance. - * - * @Event - */ - const PRE_SET_DATA = 'form.pre_set_data'; - - /** - * The FormEvents::POST_SET_DATA event is dispatched at the end of the Form::setData() method. - * - * This event is mostly here for reading data after having pre-populated the form. - * The event listener method receives a Symfony\Component\Form\FormEvent instance. - * - * @Event - */ - const POST_SET_DATA = 'form.post_set_data'; - - /** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link PRE_SUBMIT} instead. - * - * @Event - */ - const PRE_BIND = 'form.pre_bind'; - - /** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link SUBMIT} instead. - * - * @Event - */ - const BIND = 'form.bind'; - - /** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link POST_SUBMIT} instead. - * - * @Event - */ - const POST_BIND = 'form.post_bind'; - - private function __construct() - { - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormExtensionInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormExtensionInterface.php deleted file mode 100644 index 1449b1f1e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormExtensionInterface.php +++ /dev/null @@ -1,63 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * Interface for extensions which provide types, type extensions and a guesser. - */ -interface FormExtensionInterface -{ - /** - * Returns a type by name. - * - * @param string $name The name of the type - * - * @return FormTypeInterface The type - * - * @throws Exception\InvalidArgumentException if the given type is not supported by this extension - */ - public function getType($name); - - /** - * Returns whether the given type is supported. - * - * @param string $name The name of the type - * - * @return bool Whether the type is supported by this extension - */ - public function hasType($name); - - /** - * Returns the extensions for the given type. - * - * @param string $name The name of the type - * - * @return FormTypeExtensionInterface[] An array of extensions as FormTypeExtensionInterface instances - */ - public function getTypeExtensions($name); - - /** - * Returns whether this extension provides type extensions for the given type. - * - * @param string $name The name of the type - * - * @return bool Whether the given type has extensions - */ - public function hasTypeExtensions($name); - - /** - * Returns the type guesser provided by this extension. - * - * @return FormTypeGuesserInterface|null The type guesser - */ - public function getTypeGuesser(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormFactory.php b/vendor/symfony/form/Symfony/Component/Form/FormFactory.php deleted file mode 100644 index cfca4588b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormFactory.php +++ /dev/null @@ -1,162 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -class FormFactory implements FormFactoryInterface -{ - /** - * @var FormRegistryInterface - */ - private $registry; - - /** - * @var ResolvedFormTypeFactoryInterface - */ - private $resolvedTypeFactory; - - public function __construct(FormRegistryInterface $registry, ResolvedFormTypeFactoryInterface $resolvedTypeFactory) - { - $this->registry = $registry; - $this->resolvedTypeFactory = $resolvedTypeFactory; - } - - /** - * {@inheritdoc} - */ - public function create($type = 'form', $data = null, array $options = array()) - { - return $this->createBuilder($type, $data, $options)->getForm(); - } - - /** - * {@inheritdoc} - */ - public function createNamed($name, $type = 'form', $data = null, array $options = array()) - { - return $this->createNamedBuilder($name, $type, $data, $options)->getForm(); - } - - /** - * {@inheritdoc} - */ - public function createForProperty($class, $property, $data = null, array $options = array()) - { - return $this->createBuilderForProperty($class, $property, $data, $options)->getForm(); - } - - /** - * {@inheritdoc} - */ - public function createBuilder($type = 'form', $data = null, array $options = array()) - { - $name = $type instanceof FormTypeInterface || $type instanceof ResolvedFormTypeInterface - ? $type->getName() - : $type; - - return $this->createNamedBuilder($name, $type, $data, $options); - } - - /** - * {@inheritdoc} - */ - public function createNamedBuilder($name, $type = 'form', $data = null, array $options = array()) - { - if (null !== $data && !array_key_exists('data', $options)) { - $options['data'] = $data; - } - - if ($type instanceof FormTypeInterface) { - $type = $this->resolveType($type); - } elseif (is_string($type)) { - $type = $this->registry->getType($type); - } elseif (!$type instanceof ResolvedFormTypeInterface) { - throw new UnexpectedTypeException($type, 'string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface'); - } - - $builder = $type->createBuilder($this, $name, $options); - - // Explicitly call buildForm() in order to be able to override either - // createBuilder() or buildForm() in the resolved form type - $type->buildForm($builder, $builder->getOptions()); - - return $builder; - } - - /** - * {@inheritdoc} - */ - public function createBuilderForProperty($class, $property, $data = null, array $options = array()) - { - if (null === $guesser = $this->registry->getTypeGuesser()) { - return $this->createNamedBuilder($property, 'text', $data, $options); - } - - $typeGuess = $guesser->guessType($class, $property); - $maxLengthGuess = $guesser->guessMaxLength($class, $property); - $requiredGuess = $guesser->guessRequired($class, $property); - $patternGuess = $guesser->guessPattern($class, $property); - - $type = $typeGuess ? $typeGuess->getType() : 'text'; - - $maxLength = $maxLengthGuess ? $maxLengthGuess->getValue() : null; - $pattern = $patternGuess ? $patternGuess->getValue() : null; - - if (null !== $pattern) { - $options = array_replace_recursive(array('attr' => array('pattern' => $pattern)), $options); - } - - if (null !== $maxLength) { - $options = array_replace_recursive(array('attr' => array('maxlength' => $maxLength)), $options); - } - - if ($requiredGuess) { - $options = array_merge(array('required' => $requiredGuess->getValue()), $options); - } - - // user options may override guessed options - if ($typeGuess) { - $options = array_merge($typeGuess->getOptions(), $options); - } - - return $this->createNamedBuilder($property, $type, $data, $options); - } - - /** - * Wraps a type into a ResolvedFormTypeInterface implementation and connects - * it with its parent type. - * - * @param FormTypeInterface $type The type to resolve. - * - * @return ResolvedFormTypeInterface The resolved type. - */ - private function resolveType(FormTypeInterface $type) - { - $parentType = $type->getParent(); - - if ($parentType instanceof FormTypeInterface) { - $parentType = $this->resolveType($parentType); - } elseif (null !== $parentType) { - $parentType = $this->registry->getType($parentType); - } - - return $this->resolvedTypeFactory->createResolvedType( - $type, - // Type extensions are not supported for unregistered type instances, - // i.e. type instances that are passed to the FormFactory directly, - // nor for their parents, if getParent() also returns a type instance. - array(), - $parentType - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormFactoryBuilder.php b/vendor/symfony/form/Symfony/Component/Form/FormFactoryBuilder.php deleted file mode 100644 index a5bf5b38f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormFactoryBuilder.php +++ /dev/null @@ -1,162 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * The default implementation of FormFactoryBuilderInterface. - * - * @author Bernhard Schussek - */ -class FormFactoryBuilder implements FormFactoryBuilderInterface -{ - /** - * @var ResolvedFormTypeFactoryInterface - */ - private $resolvedTypeFactory; - - /** - * @var FormExtensionInterface[] - */ - private $extensions = array(); - - /** - * @var FormTypeInterface[] - */ - private $types = array(); - - /** - * @var FormTypeExtensionInterface[] - */ - private $typeExtensions = array(); - - /** - * @var FormTypeGuesserInterface[] - */ - private $typeGuessers = array(); - - /** - * {@inheritdoc} - */ - public function setResolvedTypeFactory(ResolvedFormTypeFactoryInterface $resolvedTypeFactory) - { - $this->resolvedTypeFactory = $resolvedTypeFactory; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addExtension(FormExtensionInterface $extension) - { - $this->extensions[] = $extension; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addExtensions(array $extensions) - { - $this->extensions = array_merge($this->extensions, $extensions); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addType(FormTypeInterface $type) - { - $this->types[$type->getName()] = $type; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addTypes(array $types) - { - foreach ($types as $type) { - $this->types[$type->getName()] = $type; - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addTypeExtension(FormTypeExtensionInterface $typeExtension) - { - $this->typeExtensions[$typeExtension->getExtendedType()][] = $typeExtension; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addTypeExtensions(array $typeExtensions) - { - foreach ($typeExtensions as $typeExtension) { - $this->typeExtensions[$typeExtension->getExtendedType()][] = $typeExtension; - } - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addTypeGuesser(FormTypeGuesserInterface $typeGuesser) - { - $this->typeGuessers[] = $typeGuesser; - - return $this; - } - - /** - * {@inheritdoc} - */ - public function addTypeGuessers(array $typeGuessers) - { - $this->typeGuessers = array_merge($this->typeGuessers, $typeGuessers); - - return $this; - } - - /** - * {@inheritdoc} - */ - public function getFormFactory() - { - $extensions = $this->extensions; - - if (count($this->types) > 0 || count($this->typeExtensions) > 0 || count($this->typeGuessers) > 0) { - if (count($this->typeGuessers) > 1) { - $typeGuesser = new FormTypeGuesserChain($this->typeGuessers); - } else { - $typeGuesser = isset($this->typeGuessers[0]) ? $this->typeGuessers[0] : null; - } - - $extensions[] = new PreloadedExtension($this->types, $this->typeExtensions, $typeGuesser); - } - - $resolvedTypeFactory = $this->resolvedTypeFactory ?: new ResolvedFormTypeFactory(); - $registry = new FormRegistry($extensions, $resolvedTypeFactory); - - return new FormFactory($registry, $resolvedTypeFactory); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormFactoryBuilderInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormFactoryBuilderInterface.php deleted file mode 100644 index e32f1ce76..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormFactoryBuilderInterface.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * A builder for FormFactoryInterface objects. - * - * @author Bernhard Schussek - */ -interface FormFactoryBuilderInterface -{ - /** - * Sets the factory for creating ResolvedFormTypeInterface instances. - * - * @param ResolvedFormTypeFactoryInterface $resolvedTypeFactory - * - * @return FormFactoryBuilderInterface The builder. - */ - public function setResolvedTypeFactory(ResolvedFormTypeFactoryInterface $resolvedTypeFactory); - - /** - * Adds an extension to be loaded by the factory. - * - * @param FormExtensionInterface $extension The extension. - * - * @return FormFactoryBuilderInterface The builder. - */ - public function addExtension(FormExtensionInterface $extension); - - /** - * Adds a list of extensions to be loaded by the factory. - * - * @param FormExtensionInterface[] $extensions The extensions. - * - * @return FormFactoryBuilderInterface The builder. - */ - public function addExtensions(array $extensions); - - /** - * Adds a form type to the factory. - * - * @param FormTypeInterface $type The form type. - * - * @return FormFactoryBuilderInterface The builder. - */ - public function addType(FormTypeInterface $type); - - /** - * Adds a list of form types to the factory. - * - * @param FormTypeInterface[] $types The form types. - * - * @return FormFactoryBuilderInterface The builder. - */ - public function addTypes(array $types); - - /** - * Adds a form type extension to the factory. - * - * @param FormTypeExtensionInterface $typeExtension The form type extension. - * - * @return FormFactoryBuilderInterface The builder. - */ - public function addTypeExtension(FormTypeExtensionInterface $typeExtension); - - /** - * Adds a list of form type extensions to the factory. - * - * @param FormTypeExtensionInterface[] $typeExtensions The form type extensions. - * - * @return FormFactoryBuilderInterface The builder. - */ - public function addTypeExtensions(array $typeExtensions); - - /** - * Adds a type guesser to the factory. - * - * @param FormTypeGuesserInterface $typeGuesser The type guesser. - * - * @return FormFactoryBuilderInterface The builder. - */ - public function addTypeGuesser(FormTypeGuesserInterface $typeGuesser); - - /** - * Adds a list of type guessers to the factory. - * - * @param FormTypeGuesserInterface[] $typeGuessers The type guessers. - * - * @return FormFactoryBuilderInterface The builder. - */ - public function addTypeGuessers(array $typeGuessers); - - /** - * Builds and returns the factory. - * - * @return FormFactoryInterface The form factory. - */ - public function getFormFactory(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormFactoryInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormFactoryInterface.php deleted file mode 100644 index 220b47049..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormFactoryInterface.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * @author Bernhard Schussek - */ -interface FormFactoryInterface -{ - /** - * Returns a form. - * - * @see createBuilder() - * - * @param string|FormTypeInterface $type The type of the form - * @param mixed $data The initial data - * @param array $options The options - * - * @return FormInterface The form named after the type - * - * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type - */ - public function create($type = 'form', $data = null, array $options = array()); - - /** - * Returns a form. - * - * @see createNamedBuilder() - * - * @param string|int $name The name of the form - * @param string|FormTypeInterface $type The type of the form - * @param mixed $data The initial data - * @param array $options The options - * - * @return FormInterface The form - * - * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type - */ - public function createNamed($name, $type = 'form', $data = null, array $options = array()); - - /** - * Returns a form for a property of a class. - * - * @see createBuilderForProperty() - * - * @param string $class The fully qualified class name - * @param string $property The name of the property to guess for - * @param mixed $data The initial data - * @param array $options The options for the builder - * - * @return FormInterface The form named after the property - * - * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the form type - */ - public function createForProperty($class, $property, $data = null, array $options = array()); - - /** - * Returns a form builder. - * - * @param string|FormTypeInterface $type The type of the form - * @param mixed $data The initial data - * @param array $options The options - * - * @return FormBuilderInterface The form builder - * - * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type - */ - public function createBuilder($type = 'form', $data = null, array $options = array()); - - /** - * Returns a form builder. - * - * @param string|int $name The name of the form - * @param string|FormTypeInterface $type The type of the form - * @param mixed $data The initial data - * @param array $options The options - * - * @return FormBuilderInterface The form builder - * - * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type - */ - public function createNamedBuilder($name, $type = 'form', $data = null, array $options = array()); - - /** - * Returns a form builder for a property of a class. - * - * If any of the 'max_length', 'required' and type options can be guessed, - * and are not provided in the options argument, the guessed value is used. - * - * @param string $class The fully qualified class name - * @param string $property The name of the property to guess for - * @param mixed $data The initial data - * @param array $options The options for the builder - * - * @return FormBuilderInterface The form builder named after the property - * - * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the form type - */ - public function createBuilderForProperty($class, $property, $data = null, array $options = array()); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormInterface.php deleted file mode 100644 index b2131e1da..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormInterface.php +++ /dev/null @@ -1,308 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\TransformationFailedException; - -/** - * A form group bundling multiple forms in a hierarchical structure. - * - * @author Bernhard Schussek - */ -interface FormInterface extends \ArrayAccess, \Traversable, \Countable -{ - /** - * Sets the parent form. - * - * @param FormInterface|null $parent The parent form or null if it's the root. - * - * @return FormInterface The form instance - * - * @throws Exception\AlreadySubmittedException If the form has already been submitted. - * @throws Exception\LogicException When trying to set a parent for a form with - * an empty name. - */ - public function setParent(FormInterface $parent = null); - - /** - * Returns the parent form. - * - * @return FormInterface|null The parent form or null if there is none. - */ - public function getParent(); - - /** - * Adds or replaces a child to the form. - * - * @param FormInterface|string|int $child The FormInterface instance or the name of the child. - * @param string|null $type The child's type, if a name was passed. - * @param array $options The child's options, if a name was passed. - * - * @return FormInterface The form instance - * - * @throws Exception\AlreadySubmittedException If the form has already been submitted. - * @throws Exception\LogicException When trying to add a child to a non-compound form. - * @throws Exception\UnexpectedTypeException If $child or $type has an unexpected type. - */ - public function add($child, $type = null, array $options = array()); - - /** - * Returns the child with the given name. - * - * @param string $name The name of the child - * - * @return FormInterface The child form - * - * @throws \OutOfBoundsException If the named child does not exist. - */ - public function get($name); - - /** - * Returns whether a child with the given name exists. - * - * @param string $name The name of the child - * - * @return bool - */ - public function has($name); - - /** - * Removes a child from the form. - * - * @param string $name The name of the child to remove - * - * @return FormInterface The form instance - * - * @throws Exception\AlreadySubmittedException If the form has already been submitted. - */ - public function remove($name); - - /** - * Returns all children in this group. - * - * @return FormInterface[] An array of FormInterface instances - */ - public function all(); - - /** - * Returns the errors of this form. - * - * @param bool $deep Whether to include errors of child forms as well - * @param bool $flatten Whether to flatten the list of errors in case - * $deep is set to true - * - * @return FormErrorIterator An iterator over the {@link FormError} - * instances that where added to this form - * - * @since 2.5 Since version 2.5 this method returns a - * {@link FormErrorIterator} instance instead of an array - */ - public function getErrors($deep = false, $flatten = true); - - /** - * Updates the form with default data. - * - * @param mixed $modelData The data formatted as expected for the underlying object - * - * @return FormInterface The form instance - * - * @throws Exception\AlreadySubmittedException If the form has already been submitted. - * @throws Exception\LogicException If listeners try to call setData in a cycle. Or if - * the view data does not match the expected type - * according to {@link FormConfigInterface::getDataClass}. - */ - public function setData($modelData); - - /** - * Returns the data in the format needed for the underlying object. - * - * @return mixed - */ - public function getData(); - - /** - * Returns the normalized data of the field. - * - * @return mixed When the field is not submitted, the default data is returned. - * When the field is submitted, the normalized submitted data is - * returned if the field is valid, null otherwise. - */ - public function getNormData(); - - /** - * Returns the data transformed by the value transformer. - * - * @return mixed - */ - public function getViewData(); - - /** - * Returns the extra data. - * - * @return array The submitted data which do not belong to a child - */ - public function getExtraData(); - - /** - * Returns the form's configuration. - * - * @return FormConfigInterface The configuration. - */ - public function getConfig(); - - /** - * Returns whether the form is submitted. - * - * @return bool true if the form is submitted, false otherwise - */ - public function isSubmitted(); - - /** - * Returns the name by which the form is identified in forms. - * - * @return string The name of the form. - */ - public function getName(); - - /** - * Returns the property path that the form is mapped to. - * - * @return \Symfony\Component\PropertyAccess\PropertyPathInterface The property path. - */ - public function getPropertyPath(); - - /** - * Adds an error to this form. - * - * @param FormError $error - * - * @return FormInterface The form instance - */ - public function addError(FormError $error); - - /** - * Returns whether the form and all children are valid. - * - * If the form is not submitted, this method always returns false. - * - * @return bool - */ - public function isValid(); - - /** - * Returns whether the form is required to be filled out. - * - * If the form has a parent and the parent is not required, this method - * will always return false. Otherwise the value set with setRequired() - * is returned. - * - * @return bool - */ - public function isRequired(); - - /** - * Returns whether this form is disabled. - * - * The content of a disabled form is displayed, but not allowed to be - * modified. The validation of modified disabled forms should fail. - * - * Forms whose parents are disabled are considered disabled regardless of - * their own state. - * - * @return bool - */ - public function isDisabled(); - - /** - * Returns whether the form is empty. - * - * @return bool - */ - public function isEmpty(); - - /** - * Returns whether the data in the different formats is synchronized. - * - * If the data is not synchronized, you can get the transformation failure - * by calling {@link getTransformationFailure()}. - * - * @return bool - */ - public function isSynchronized(); - - /** - * Returns the data transformation failure, if any. - * - * @return TransformationFailedException|null The transformation failure - */ - public function getTransformationFailure(); - - /** - * Initializes the form tree. - * - * Should be called on the root form after constructing the tree. - * - * @return FormInterface The form instance. - */ - public function initialize(); - - /** - * Inspects the given request and calls {@link submit()} if the form was - * submitted. - * - * Internally, the request is forwarded to the configured - * {@link RequestHandlerInterface} instance, which determines whether to - * submit the form or not. - * - * @param mixed $request The request to handle. - * - * @return FormInterface The form instance. - */ - public function handleRequest($request = null); - - /** - * Submits data to the form, transforms and validates it. - * - * @param null|string|array $submittedData The submitted data. - * @param bool $clearMissing Whether to set fields to NULL - * when they are missing in the - * submitted data. - * - * @return FormInterface The form instance - * - * @throws Exception\AlreadySubmittedException If the form has already been submitted. - */ - public function submit($submittedData, $clearMissing = true); - - /** - * Returns the root of the form tree. - * - * @return FormInterface The root of the tree - */ - public function getRoot(); - - /** - * Returns whether the field is the root of the form tree. - * - * @return bool - */ - public function isRoot(); - - /** - * Creates a view. - * - * @param FormView $parent The parent view - * - * @return FormView The view - */ - public function createView(FormView $parent = null); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormRegistry.php b/vendor/symfony/form/Symfony/Component/Form/FormRegistry.php deleted file mode 100644 index 0dc21df2b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormRegistry.php +++ /dev/null @@ -1,176 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\ExceptionInterface; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Exception\InvalidArgumentException; - -/** - * The central registry of the Form component. - * - * @author Bernhard Schussek - */ -class FormRegistry implements FormRegistryInterface -{ - /** - * Extensions. - * - * @var FormExtensionInterface[] An array of FormExtensionInterface - */ - private $extensions = array(); - - /** - * @var FormTypeInterface[] - */ - private $types = array(); - - /** - * @var FormTypeGuesserInterface|false|null - */ - private $guesser = false; - - /** - * @var ResolvedFormTypeFactoryInterface - */ - private $resolvedTypeFactory; - - /** - * Constructor. - * - * @param FormExtensionInterface[] $extensions An array of FormExtensionInterface - * @param ResolvedFormTypeFactoryInterface $resolvedTypeFactory The factory for resolved form types. - * - * @throws UnexpectedTypeException if any extension does not implement FormExtensionInterface - */ - public function __construct(array $extensions, ResolvedFormTypeFactoryInterface $resolvedTypeFactory) - { - foreach ($extensions as $extension) { - if (!$extension instanceof FormExtensionInterface) { - throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormExtensionInterface'); - } - } - - $this->extensions = $extensions; - $this->resolvedTypeFactory = $resolvedTypeFactory; - } - - /** - * {@inheritdoc} - */ - public function getType($name) - { - if (!is_string($name)) { - throw new UnexpectedTypeException($name, 'string'); - } - - if (!isset($this->types[$name])) { - $type = null; - - foreach ($this->extensions as $extension) { - if ($extension->hasType($name)) { - $type = $extension->getType($name); - break; - } - } - - if (!$type) { - throw new InvalidArgumentException(sprintf('Could not load type "%s"', $name)); - } - - $this->resolveAndAddType($type); - } - - return $this->types[$name]; - } - - /** - * Wraps a type into a ResolvedFormTypeInterface implementation and connects - * it with its parent type. - * - * @param FormTypeInterface $type The type to resolve. - * - * @return ResolvedFormTypeInterface The resolved type. - */ - private function resolveAndAddType(FormTypeInterface $type) - { - $parentType = $type->getParent(); - - if ($parentType instanceof FormTypeInterface) { - $this->resolveAndAddType($parentType); - $parentType = $parentType->getName(); - } - - $typeExtensions = array(); - - foreach ($this->extensions as $extension) { - $typeExtensions = array_merge( - $typeExtensions, - $extension->getTypeExtensions($type->getName()) - ); - } - - $this->types[$type->getName()] = $this->resolvedTypeFactory->createResolvedType( - $type, - $typeExtensions, - $parentType ? $this->getType($parentType) : null - ); - } - - /** - * {@inheritdoc} - */ - public function hasType($name) - { - if (isset($this->types[$name])) { - return true; - } - - try { - $this->getType($name); - } catch (ExceptionInterface $e) { - return false; - } - - return true; - } - - /** - * {@inheritdoc} - */ - public function getTypeGuesser() - { - if (false === $this->guesser) { - $guessers = array(); - - foreach ($this->extensions as $extension) { - $guesser = $extension->getTypeGuesser(); - - if ($guesser) { - $guessers[] = $guesser; - } - } - - $this->guesser = !empty($guessers) ? new FormTypeGuesserChain($guessers) : null; - } - - return $this->guesser; - } - - /** - * {@inheritdoc} - */ - public function getExtensions() - { - return $this->extensions; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormRegistryInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormRegistryInterface.php deleted file mode 100644 index b42b2b581..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormRegistryInterface.php +++ /dev/null @@ -1,57 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * The central registry of the Form component. - * - * @author Bernhard Schussek - */ -interface FormRegistryInterface -{ - /** - * Returns a form type by name. - * - * This methods registers the type extensions from the form extensions. - * - * @param string $name The name of the type - * - * @return ResolvedFormTypeInterface The type - * - * @throws Exception\UnexpectedTypeException if the passed name is not a string - * @throws Exception\InvalidArgumentException if the type can not be retrieved from any extension - */ - public function getType($name); - - /** - * Returns whether the given form type is supported. - * - * @param string $name The name of the type - * - * @return bool Whether the type is supported - */ - public function hasType($name); - - /** - * Returns the guesser responsible for guessing types. - * - * @return FormTypeGuesserInterface|null - */ - public function getTypeGuesser(); - - /** - * Returns the extensions loaded by the framework. - * - * @return FormExtensionInterface[] - */ - public function getExtensions(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormRenderer.php b/vendor/symfony/form/Symfony/Component/Form/FormRenderer.php deleted file mode 100644 index b286ffdf4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormRenderer.php +++ /dev/null @@ -1,320 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\LogicException; -use Symfony\Component\Form\Exception\BadMethodCallException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderAdapter; -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\CsrfProviderInterface; -use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; - -/** - * Renders a form into HTML using a rendering engine. - * - * @author Bernhard Schussek - */ -class FormRenderer implements FormRendererInterface -{ - const CACHE_KEY_VAR = 'unique_block_prefix'; - - /** - * @var FormRendererEngineInterface - */ - private $engine; - - /** - * @var CsrfTokenManagerInterface - */ - private $csrfTokenManager; - - /** - * @var array - */ - private $blockNameHierarchyMap = array(); - - /** - * @var array - */ - private $hierarchyLevelMap = array(); - - /** - * @var array - */ - private $variableStack = array(); - - /** - * Constructor. - * - * @param FormRendererEngineInterface $engine - * @param CsrfTokenManagerInterface|null $csrfTokenManager - * - * @throws UnexpectedTypeException - */ - public function __construct(FormRendererEngineInterface $engine, $csrfTokenManager = null) - { - if ($csrfTokenManager instanceof CsrfProviderInterface) { - $csrfTokenManager = new CsrfProviderAdapter($csrfTokenManager); - } elseif (null !== $csrfTokenManager && !$csrfTokenManager instanceof CsrfTokenManagerInterface) { - throw new UnexpectedTypeException($csrfTokenManager, 'CsrfProviderInterface or CsrfTokenManagerInterface or null'); - } - - $this->engine = $engine; - $this->csrfTokenManager = $csrfTokenManager; - } - - /** - * {@inheritdoc} - */ - public function getEngine() - { - return $this->engine; - } - - /** - * {@inheritdoc} - */ - public function setTheme(FormView $view, $themes) - { - $this->engine->setTheme($view, $themes); - } - - /** - * {@inheritdoc} - */ - public function renderCsrfToken($tokenId) - { - if (null === $this->csrfTokenManager) { - throw new BadMethodCallException('CSRF tokens can only be generated if a CsrfTokenManagerInterface is injected in FormRenderer::__construct().'); - } - - return $this->csrfTokenManager->getToken($tokenId)->getValue(); - } - - /** - * {@inheritdoc} - */ - public function renderBlock(FormView $view, $blockName, array $variables = array()) - { - $resource = $this->engine->getResourceForBlockName($view, $blockName); - - if (!$resource) { - throw new LogicException(sprintf('No block "%s" found while rendering the form.', $blockName)); - } - - $viewCacheKey = $view->vars[self::CACHE_KEY_VAR]; - - // The variables are cached globally for a view (instead of for the - // current suffix) - if (!isset($this->variableStack[$viewCacheKey])) { - $this->variableStack[$viewCacheKey] = array(); - - // The default variable scope contains all view variables, merged with - // the variables passed explicitly to the helper - $scopeVariables = $view->vars; - - $varInit = true; - } else { - // Reuse the current scope and merge it with the explicitly passed variables - $scopeVariables = end($this->variableStack[$viewCacheKey]); - - $varInit = false; - } - - // Merge the passed with the existing attributes - if (isset($variables['attr']) && isset($scopeVariables['attr'])) { - $variables['attr'] = array_replace($scopeVariables['attr'], $variables['attr']); - } - - // Merge the passed with the exist *label* attributes - if (isset($variables['label_attr']) && isset($scopeVariables['label_attr'])) { - $variables['label_attr'] = array_replace($scopeVariables['label_attr'], $variables['label_attr']); - } - - // Do not use array_replace_recursive(), otherwise array variables - // cannot be overwritten - $variables = array_replace($scopeVariables, $variables); - - $this->variableStack[$viewCacheKey][] = $variables; - - // Do the rendering - $html = $this->engine->renderBlock($view, $resource, $blockName, $variables); - - // Clear the stack - array_pop($this->variableStack[$viewCacheKey]); - - if ($varInit) { - unset($this->variableStack[$viewCacheKey]); - } - - return $html; - } - - /** - * {@inheritdoc} - */ - public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $variables = array()) - { - $renderOnlyOnce = 'row' === $blockNameSuffix || 'widget' === $blockNameSuffix; - - if ($renderOnlyOnce && $view->isRendered()) { - return ''; - } - - // The cache key for storing the variables and types - $viewCacheKey = $view->vars[self::CACHE_KEY_VAR]; - $viewAndSuffixCacheKey = $viewCacheKey.$blockNameSuffix; - - // In templates, we have to deal with two kinds of block hierarchies: - // - // +---------+ +---------+ - // | Theme B | -------> | Theme A | - // +---------+ +---------+ - // - // form_widget -------> form_widget - // ^ - // | - // choice_widget -----> choice_widget - // - // The first kind of hierarchy is the theme hierarchy. This allows to - // override the block "choice_widget" from Theme A in the extending - // Theme B. This kind of inheritance needs to be supported by the - // template engine and, for example, offers "parent()" or similar - // functions to fall back from the custom to the parent implementation. - // - // The second kind of hierarchy is the form type hierarchy. This allows - // to implement a custom "choice_widget" block (no matter in which theme), - // or to fallback to the block of the parent type, which would be - // "form_widget" in this example (again, no matter in which theme). - // If the designer wants to explicitly fallback to "form_widget" in his - // custom "choice_widget", for example because he only wants to wrap - // a
around the original implementation, he can simply call the - // widget() function again to render the block for the parent type. - // - // The second kind is implemented in the following blocks. - if (!isset($this->blockNameHierarchyMap[$viewAndSuffixCacheKey])) { - // INITIAL CALL - // Calculate the hierarchy of template blocks and start on - // the bottom level of the hierarchy (= "__
" block) - $blockNameHierarchy = array(); - foreach ($view->vars['block_prefixes'] as $blockNamePrefix) { - $blockNameHierarchy[] = $blockNamePrefix.'_'.$blockNameSuffix; - } - $hierarchyLevel = count($blockNameHierarchy) - 1; - - $hierarchyInit = true; - } else { - // RECURSIVE CALL - // If a block recursively calls searchAndRenderBlock() again, resume rendering - // using the parent type in the hierarchy. - $blockNameHierarchy = $this->blockNameHierarchyMap[$viewAndSuffixCacheKey]; - $hierarchyLevel = $this->hierarchyLevelMap[$viewAndSuffixCacheKey] - 1; - - $hierarchyInit = false; - } - - // The variables are cached globally for a view (instead of for the - // current suffix) - if (!isset($this->variableStack[$viewCacheKey])) { - $this->variableStack[$viewCacheKey] = array(); - - // The default variable scope contains all view variables, merged with - // the variables passed explicitly to the helper - $scopeVariables = $view->vars; - - $varInit = true; - } else { - // Reuse the current scope and merge it with the explicitly passed variables - $scopeVariables = end($this->variableStack[$viewCacheKey]); - - $varInit = false; - } - - // Load the resource where this block can be found - $resource = $this->engine->getResourceForBlockNameHierarchy($view, $blockNameHierarchy, $hierarchyLevel); - - // Update the current hierarchy level to the one at which the resource was - // found. For example, if looking for "choice_widget", but only a resource - // is found for its parent "form_widget", then the level is updated here - // to the parent level. - $hierarchyLevel = $this->engine->getResourceHierarchyLevel($view, $blockNameHierarchy, $hierarchyLevel); - - // The actually existing block name in $resource - $blockName = $blockNameHierarchy[$hierarchyLevel]; - - // Escape if no resource exists for this block - if (!$resource) { - throw new LogicException(sprintf( - 'Unable to render the form as none of the following blocks exist: "%s".', - implode('", "', array_reverse($blockNameHierarchy)) - )); - } - - // Merge the passed with the existing attributes - if (isset($variables['attr']) && isset($scopeVariables['attr'])) { - $variables['attr'] = array_replace($scopeVariables['attr'], $variables['attr']); - } - - // Merge the passed with the exist *label* attributes - if (isset($variables['label_attr']) && isset($scopeVariables['label_attr'])) { - $variables['label_attr'] = array_replace($scopeVariables['label_attr'], $variables['label_attr']); - } - - // Do not use array_replace_recursive(), otherwise array variables - // cannot be overwritten - $variables = array_replace($scopeVariables, $variables); - - // In order to make recursive calls possible, we need to store the block hierarchy, - // the current level of the hierarchy and the variables so that this method can - // resume rendering one level higher of the hierarchy when it is called recursively. - // - // We need to store these values in maps (associative arrays) because within a - // call to widget() another call to widget() can be made, but for a different view - // object. These nested calls should not override each other. - $this->blockNameHierarchyMap[$viewAndSuffixCacheKey] = $blockNameHierarchy; - $this->hierarchyLevelMap[$viewAndSuffixCacheKey] = $hierarchyLevel; - - // We also need to store the variables for the view so that we can render other - // blocks for the same view using the same variables as in the outer block. - $this->variableStack[$viewCacheKey][] = $variables; - - // Do the rendering - $html = $this->engine->renderBlock($view, $resource, $blockName, $variables); - - // Clear the stack - array_pop($this->variableStack[$viewCacheKey]); - - // Clear the caches if they were filled for the first time within - // this function call - if ($hierarchyInit) { - unset($this->blockNameHierarchyMap[$viewAndSuffixCacheKey], $this->hierarchyLevelMap[$viewAndSuffixCacheKey]); - } - - if ($varInit) { - unset($this->variableStack[$viewCacheKey]); - } - - if ($renderOnlyOnce) { - $view->setRendered(); - } - - return $html; - } - - /** - * {@inheritdoc} - */ - public function humanize($text) - { - return ucfirst(trim(strtolower(preg_replace(array('/([A-Z])/', '/[_\s]+/'), array('_$1', ' '), $text)))); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormRendererEngineInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormRendererEngineInterface.php deleted file mode 100644 index b49ec9cc8..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormRendererEngineInterface.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * Adapter for rendering form templates with a specific templating engine. - * - * @author Bernhard Schussek - */ -interface FormRendererEngineInterface -{ - /** - * Sets the theme(s) to be used for rendering a view and its children. - * - * @param FormView $view The view to assign the theme(s) to. - * @param mixed $themes The theme(s). The type of these themes - * is open to the implementation. - */ - public function setTheme(FormView $view, $themes); - - /** - * Returns the resource for a block name. - * - * The resource is first searched in the themes attached to $view, then - * in the themes of its parent view and so on, until a resource was found. - * - * The type of the resource is decided by the implementation. The resource - * is later passed to {@link renderBlock()} by the rendering algorithm. - * - * @param FormView $view The view for determining the used themes. - * First the themes attached directly to the - * view with {@link setTheme()} are considered, - * then the ones of its parent etc. - * @param string $blockName The name of the block to render. - * - * @return mixed The renderer resource or false, if none was found. - */ - public function getResourceForBlockName(FormView $view, $blockName); - - /** - * Returns the resource for a block hierarchy. - * - * A block hierarchy is an array which starts with the root of the hierarchy - * and continues with the child of that root, the child of that child etc. - * The following is an example for a block hierarchy: - * - * - * form_widget - * text_widget - * url_widget - * - * - * In this example, "url_widget" is the most specific block, while the other - * blocks are its ancestors in the hierarchy. - * - * The second parameter $hierarchyLevel determines the level of the hierarchy - * that should be rendered. For example, if $hierarchyLevel is 2 for the - * above hierarchy, the engine will first look for the block "url_widget", - * then, if that does not exist, for the block "text_widget" etc. - * - * The type of the resource is decided by the implementation. The resource - * is later passed to {@link renderBlock()} by the rendering algorithm. - * - * @param FormView $view The view for determining the used themes. - * First the themes attached directly to - * the view with {@link setTheme()} are - * considered, then the ones of its parent etc. - * @param array $blockNameHierarchy The block name hierarchy, with the root block - * at the beginning. - * @param int $hierarchyLevel The level in the hierarchy at which to start - * looking. Level 0 indicates the root block, i.e. - * the first element of $blockNameHierarchy. - * - * @return mixed The renderer resource or false, if none was found. - */ - public function getResourceForBlockNameHierarchy(FormView $view, array $blockNameHierarchy, $hierarchyLevel); - - /** - * Returns the hierarchy level at which a resource can be found. - * - * A block hierarchy is an array which starts with the root of the hierarchy - * and continues with the child of that root, the child of that child etc. - * The following is an example for a block hierarchy: - * - * - * form_widget - * text_widget - * url_widget - * - * - * The second parameter $hierarchyLevel determines the level of the hierarchy - * that should be rendered. - * - * If we call this method with the hierarchy level 2, the engine will first - * look for a resource for block "url_widget". If such a resource exists, - * the method returns 2. Otherwise it tries to find a resource for block - * "text_widget" (at level 1) and, again, returns 1 if a resource was found. - * The method continues to look for resources until the root level was - * reached and nothing was found. In this case false is returned. - * - * The type of the resource is decided by the implementation. The resource - * is later passed to {@link renderBlock()} by the rendering algorithm. - * - * @param FormView $view The view for determining the used themes. - * First the themes attached directly to - * the view with {@link setTheme()} are - * considered, then the ones of its parent etc. - * @param array $blockNameHierarchy The block name hierarchy, with the root block - * at the beginning. - * @param int $hierarchyLevel The level in the hierarchy at which to start - * looking. Level 0 indicates the root block, i.e. - * the first element of $blockNameHierarchy. - * - * @return int|bool The hierarchy level or false, if no resource was found. - */ - public function getResourceHierarchyLevel(FormView $view, array $blockNameHierarchy, $hierarchyLevel); - - /** - * Renders a block in the given renderer resource. - * - * The resource can be obtained by calling {@link getResourceForBlock()} - * or {@link getResourceForBlockHierarchy()}. The type of the resource is - * decided by the implementation. - * - * @param FormView $view The view to render. - * @param mixed $resource The renderer resource. - * @param string $blockName The name of the block to render. - * @param array $variables The variables to pass to the template. - * - * @return string The HTML markup. - */ - public function renderBlock(FormView $view, $resource, $blockName, array $variables = array()); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php deleted file mode 100644 index 6dc9e86c3..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormRendererInterface.php +++ /dev/null @@ -1,103 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * Renders a form into HTML. - * - * @author Bernhard Schussek - */ -interface FormRendererInterface -{ - /** - * Returns the engine used by this renderer. - * - * @return FormRendererEngineInterface The renderer engine. - */ - public function getEngine(); - - /** - * Sets the theme(s) to be used for rendering a view and its children. - * - * @param FormView $view The view to assign the theme(s) to. - * @param mixed $themes The theme(s). The type of these themes - * is open to the implementation. - */ - public function setTheme(FormView $view, $themes); - - /** - * Renders a named block of the form theme. - * - * @param FormView $view The view for which to render the block. - * @param string $blockName The name of the block. - * @param array $variables The variables to pass to the template. - * - * @return string The HTML markup - */ - public function renderBlock(FormView $view, $blockName, array $variables = array()); - - /** - * Searches and renders a block for a given name suffix. - * - * The block is searched by combining the block names stored in the - * form view with the given suffix. If a block name is found, that - * block is rendered. - * - * If this method is called recursively, the block search is continued - * where a block was found before. - * - * @param FormView $view The view for which to render the block. - * @param string $blockNameSuffix The suffix of the block name. - * @param array $variables The variables to pass to the template. - * - * @return string The HTML markup - */ - public function searchAndRenderBlock(FormView $view, $blockNameSuffix, array $variables = array()); - - /** - * Renders a CSRF token. - * - * Use this helper for CSRF protection without the overhead of creating a - * form. - * - * - * - * - * - * Check the token in your action using the same token ID. - * - * - * $csrfProvider = $this->get('security.csrf.token_generator'); - * if (!$csrfProvider->isCsrfTokenValid('rm_user_'.$user->getId(), $token)) { - * throw new \RuntimeException('CSRF attack detected.'); - * } - * - * - * @param string $tokenId The ID of the CSRF token - * - * @return string A CSRF token - */ - public function renderCsrfToken($tokenId); - - /** - * Makes a technical name human readable. - * - * Sequences of underscores are replaced by single spaces. The first letter - * of the resulting string is capitalized, while all other letters are - * turned to lowercase. - * - * @param string $text The text to humanize. - * - * @return string The humanized text. - */ - public function humanize($text); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormTypeExtensionInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormTypeExtensionInterface.php deleted file mode 100644 index 946c7a74b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormTypeExtensionInterface.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * @author Bernhard Schussek - */ -interface FormTypeExtensionInterface -{ - /** - * Builds the form. - * - * This method is called after the extended type has built the form to - * further modify it. - * - * @see FormTypeInterface::buildForm() - * - * @param FormBuilderInterface $builder The form builder - * @param array $options The options - */ - public function buildForm(FormBuilderInterface $builder, array $options); - - /** - * Builds the view. - * - * This method is called after the extended type has built the view to - * further modify it. - * - * @see FormTypeInterface::buildView() - * - * @param FormView $view The view - * @param FormInterface $form The form - * @param array $options The options - */ - public function buildView(FormView $view, FormInterface $form, array $options); - - /** - * Finishes the view. - * - * This method is called after the extended type has finished the view to - * further modify it. - * - * @see FormTypeInterface::finishView() - * - * @param FormView $view The view - * @param FormInterface $form The form - * @param array $options The options - */ - public function finishView(FormView $view, FormInterface $form, array $options); - - /** - * Overrides the default options from the extended type. - * - * @param OptionsResolverInterface $resolver The resolver for the options. - */ - public function setDefaultOptions(OptionsResolverInterface $resolver); - - /** - * Returns the name of the type being extended. - * - * @return string The name of the type being extended - */ - public function getExtendedType(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormTypeGuesserChain.php b/vendor/symfony/form/Symfony/Component/Form/FormTypeGuesserChain.php deleted file mode 100644 index 7c4f65b43..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormTypeGuesserChain.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Guess\Guess; -use Symfony\Component\Form\Exception\UnexpectedTypeException; - -class FormTypeGuesserChain implements FormTypeGuesserInterface -{ - private $guessers = array(); - - /** - * Constructor. - * - * @param FormTypeGuesserInterface[] $guessers Guessers as instances of FormTypeGuesserInterface - * - * @throws UnexpectedTypeException if any guesser does not implement FormTypeGuesserInterface - */ - public function __construct(array $guessers) - { - foreach ($guessers as $guesser) { - if (!$guesser instanceof FormTypeGuesserInterface) { - throw new UnexpectedTypeException($guesser, 'Symfony\Component\Form\FormTypeGuesserInterface'); - } - - if ($guesser instanceof self) { - $this->guessers = array_merge($this->guessers, $guesser->guessers); - } else { - $this->guessers[] = $guesser; - } - } - } - - /** - * {@inheritdoc} - */ - public function guessType($class, $property) - { - return $this->guess(function ($guesser) use ($class, $property) { - return $guesser->guessType($class, $property); - }); - } - - /** - * {@inheritdoc} - */ - public function guessRequired($class, $property) - { - return $this->guess(function ($guesser) use ($class, $property) { - return $guesser->guessRequired($class, $property); - }); - } - - /** - * {@inheritdoc} - */ - public function guessMaxLength($class, $property) - { - return $this->guess(function ($guesser) use ($class, $property) { - return $guesser->guessMaxLength($class, $property); - }); - } - - /** - * {@inheritdoc} - */ - public function guessPattern($class, $property) - { - return $this->guess(function ($guesser) use ($class, $property) { - return $guesser->guessPattern($class, $property); - }); - } - - /** - * Executes a closure for each guesser and returns the best guess from the - * return values. - * - * @param \Closure $closure The closure to execute. Accepts a guesser - * as argument and should return a Guess instance - * - * @return Guess|null The guess with the highest confidence - */ - private function guess(\Closure $closure) - { - $guesses = array(); - - foreach ($this->guessers as $guesser) { - if ($guess = $closure($guesser)) { - $guesses[] = $guess; - } - } - - return Guess::getBestGuess($guesses); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormTypeGuesserInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormTypeGuesserInterface.php deleted file mode 100644 index f62112493..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormTypeGuesserInterface.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * @author Bernhard Schussek - */ -interface FormTypeGuesserInterface -{ - /** - * Returns a field guess for a property name of a class. - * - * @param string $class The fully qualified class name - * @param string $property The name of the property to guess for - * - * @return Guess\TypeGuess|null A guess for the field's type and options - */ - public function guessType($class, $property); - - /** - * Returns a guess whether a property of a class is required. - * - * @param string $class The fully qualified class name - * @param string $property The name of the property to guess for - * - * @return Guess\ValueGuess A guess for the field's required setting - */ - public function guessRequired($class, $property); - - /** - * Returns a guess about the field's maximum length. - * - * @param string $class The fully qualified class name - * @param string $property The name of the property to guess for - * - * @return Guess\ValueGuess|null A guess for the field's maximum length - */ - public function guessMaxLength($class, $property); - - /** - * Returns a guess about the field's pattern. - * - * - When you have a min value, you guess a min length of this min (LOW_CONFIDENCE) , lines below - * - If this value is a float type, this is wrong so you guess null with MEDIUM_CONFIDENCE to override the previous guess. - * Example: - * You want a float greater than 5, 4.512313 is not valid but length(4.512314) > length(5) - * - * @link https://github.com/symfony/symfony/pull/3927 - * - * @param string $class The fully qualified class name - * @param string $property The name of the property to guess for - * - * @return Guess\ValueGuess|null A guess for the field's required pattern - */ - public function guessPattern($class, $property); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormTypeInterface.php b/vendor/symfony/form/Symfony/Component/Form/FormTypeInterface.php deleted file mode 100644 index 78f8bd008..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormTypeInterface.php +++ /dev/null @@ -1,95 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * @author Bernhard Schussek - */ -interface FormTypeInterface -{ - /** - * Builds the form. - * - * This method is called for each type in the hierarchy starting from the - * top most type. Type extensions can further modify the form. - * - * @see FormTypeExtensionInterface::buildForm() - * - * @param FormBuilderInterface $builder The form builder - * @param array $options The options - */ - public function buildForm(FormBuilderInterface $builder, array $options); - - /** - * Builds the form view. - * - * This method is called for each type in the hierarchy starting from the - * top most type. Type extensions can further modify the view. - * - * A view of a form is built before the views of the child forms are built. - * This means that you cannot access child views in this method. If you need - * to do so, move your logic to {@link finishView()} instead. - * - * @see FormTypeExtensionInterface::buildView() - * - * @param FormView $view The view - * @param FormInterface $form The form - * @param array $options The options - */ - public function buildView(FormView $view, FormInterface $form, array $options); - - /** - * Finishes the form view. - * - * This method gets called for each type in the hierarchy starting from the - * top most type. Type extensions can further modify the view. - * - * When this method is called, views of the form's children have already - * been built and finished and can be accessed. You should only implement - * such logic in this method that actually accesses child views. For everything - * else you are recommended to implement {@link buildView()} instead. - * - * @see FormTypeExtensionInterface::finishView() - * - * @param FormView $view The view - * @param FormInterface $form The form - * @param array $options The options - */ - public function finishView(FormView $view, FormInterface $form, array $options); - - /** - * Sets the default options for this type. - * - * @param OptionsResolverInterface $resolver The resolver for the options. - */ - public function setDefaultOptions(OptionsResolverInterface $resolver); - - /** - * Returns the name of the parent type. - * - * You can also return a type instance from this method, although doing so - * is discouraged because it leads to a performance penalty. The support - * for returning type instances may be dropped from future releases. - * - * @return string|null|FormTypeInterface The name of the parent type if any, null otherwise. - */ - public function getParent(); - - /** - * Returns the name of this type. - * - * @return string The name of this type - */ - public function getName(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/FormView.php b/vendor/symfony/form/Symfony/Component/Form/FormView.php deleted file mode 100644 index ac50dc336..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/FormView.php +++ /dev/null @@ -1,162 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\BadMethodCallException; - -/** - * @author Bernhard Schussek - */ -class FormView implements \ArrayAccess, \IteratorAggregate, \Countable -{ - /** - * The variables assigned to this view. - * - * @var array - */ - public $vars = array( - 'value' => null, - 'attr' => array(), - ); - - /** - * The parent view. - * - * @var FormView - */ - public $parent; - - /** - * The child views. - * - * @var FormView[] - */ - public $children = array(); - - /** - * Is the form attached to this renderer rendered? - * - * Rendering happens when either the widget or the row method was called. - * Row implicitly includes widget, however certain rendering mechanisms - * have to skip widget rendering when a row is rendered. - * - * @var bool - */ - private $rendered = false; - - public function __construct(FormView $parent = null) - { - $this->parent = $parent; - } - - /** - * Returns whether the view was already rendered. - * - * @return bool Whether this view's widget is rendered. - */ - public function isRendered() - { - $hasChildren = 0 < count($this->children); - - if (true === $this->rendered || !$hasChildren) { - return $this->rendered; - } - - if ($hasChildren) { - foreach ($this->children as $child) { - if (!$child->isRendered()) { - return false; - } - } - - return $this->rendered = true; - } - - return false; - } - - /** - * Marks the view as rendered. - * - * @return FormView The view object. - */ - public function setRendered() - { - $this->rendered = true; - - return $this; - } - - /** - * Returns a child by name (implements \ArrayAccess). - * - * @param string $name The child name - * - * @return FormView The child view - */ - public function offsetGet($name) - { - return $this->children[$name]; - } - - /** - * Returns whether the given child exists (implements \ArrayAccess). - * - * @param string $name The child name - * - * @return bool Whether the child view exists - */ - public function offsetExists($name) - { - return isset($this->children[$name]); - } - - /** - * Implements \ArrayAccess. - * - * @throws BadMethodCallException always as setting a child by name is not allowed - */ - public function offsetSet($name, $value) - { - throw new BadMethodCallException('Not supported'); - } - - /** - * Removes a child (implements \ArrayAccess). - * - * @param string $name The child name - */ - public function offsetUnset($name) - { - unset($this->children[$name]); - } - - /** - * Returns an iterator to iterate over children (implements \IteratorAggregate). - * - * @return \ArrayIterator The iterator - */ - public function getIterator() - { - return new \ArrayIterator($this->children); - } - - /** - * Implements \Countable. - * - * @return int The number of children views - */ - public function count() - { - return count($this->children); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Forms.php b/vendor/symfony/form/Symfony/Component/Form/Forms.php deleted file mode 100644 index 96ac45129..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Forms.php +++ /dev/null @@ -1,132 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Extension\Core\CoreExtension; - -/** - * Entry point of the Form component. - * - * Use this class to conveniently create new form factories: - * - * - * use Symfony\Component\Form\Forms; - * - * $formFactory = Forms::createFormFactory(); - * - * $form = $formFactory->createBuilder() - * ->add('firstName', 'text') - * ->add('lastName', 'text') - * ->add('age', 'integer') - * ->add('gender', 'choice', array( - * 'choices' => array('m' => 'Male', 'f' => 'Female'), - * )) - * ->getForm(); - * - * - * You can also add custom extensions to the form factory: - * - * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new AcmeExtension()) - * ->getFormFactory(); - * - * - * If you create custom form types or type extensions, it is - * generally recommended to create your own extensions that lazily - * load these types and type extensions. In projects where performance - * does not matter that much, you can also pass them directly to the - * form factory: - * - * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addType(new PersonType()) - * ->addType(new PhoneNumberType()) - * ->addTypeExtension(new FormTypeHelpTextExtension()) - * ->getFormFactory(); - * - * - * Support for the Validator component is provided by ValidatorExtension. - * This extension needs a validator object to function properly: - * - * - * use Symfony\Component\Validator\Validation; - * use Symfony\Component\Form\Extension\Validator\ValidatorExtension; - * - * $validator = Validation::createValidator(); - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new ValidatorExtension($validator)) - * ->getFormFactory(); - * - * - * Support for the Templating component is provided by TemplatingExtension. - * This extension needs a PhpEngine object for rendering forms. As second - * argument you should pass the names of the default themes. Here is an - * example for using the default layout with "
" tags: - * - * - * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; - * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new TemplatingExtension($engine, null, array( - * 'FrameworkBundle:Form', - * ))) - * ->getFormFactory(); - * - * - * The next example shows how to include the "" layout: - * - * - * use Symfony\Component\Form\Extension\Templating\TemplatingExtension; - * - * $formFactory = Forms::createFormFactoryBuilder() - * ->addExtension(new TemplatingExtension($engine, null, array( - * 'FrameworkBundle:Form', - * 'FrameworkBundle:FormTable', - * ))) - * ->getFormFactory(); - * - * - * @author Bernhard Schussek - */ -final class Forms -{ - /** - * Creates a form factory with the default configuration. - * - * @return FormFactoryInterface The form factory. - */ - public static function createFormFactory() - { - return self::createFormFactoryBuilder()->getFormFactory(); - } - - /** - * Creates a form factory builder with the default configuration. - * - * @return FormFactoryBuilderInterface The form factory builder. - */ - public static function createFormFactoryBuilder() - { - $builder = new FormFactoryBuilder(); - $builder->addExtension(new CoreExtension()); - - return $builder; - } - - /** - * This class cannot be instantiated. - */ - private function __construct() - { - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Guess/Guess.php b/vendor/symfony/form/Symfony/Component/Form/Guess/Guess.php deleted file mode 100644 index 0595e7bba..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Guess/Guess.php +++ /dev/null @@ -1,117 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Guess; - -use Symfony\Component\Form\Exception\InvalidArgumentException; - -/** - * Base class for guesses made by TypeGuesserInterface implementation. - * - * Each instance contains a confidence value about the correctness of the guess. - * Thus an instance with confidence HIGH_CONFIDENCE is more likely to be - * correct than an instance with confidence LOW_CONFIDENCE. - * - * @author Bernhard Schussek - */ -abstract class Guess -{ - /** - * Marks an instance with a value that is extremely likely to be correct. - * - * @var int - */ - const VERY_HIGH_CONFIDENCE = 3; - - /** - * Marks an instance with a value that is very likely to be correct. - * - * @var int - */ - const HIGH_CONFIDENCE = 2; - - /** - * Marks an instance with a value that is likely to be correct. - * - * @var int - */ - const MEDIUM_CONFIDENCE = 1; - - /** - * Marks an instance with a value that may be correct. - * - * @var int - */ - const LOW_CONFIDENCE = 0; - - /** - * The confidence about the correctness of the value. - * - * One of VERY_HIGH_CONFIDENCE, HIGH_CONFIDENCE, MEDIUM_CONFIDENCE - * and LOW_CONFIDENCE. - * - * @var int - */ - private $confidence; - - /** - * Returns the guess most likely to be correct from a list of guesses. - * - * If there are multiple guesses with the same, highest confidence, the - * returned guess is any of them. - * - * @param Guess[] $guesses An array of guesses - * - * @return Guess|null The guess with the highest confidence - */ - public static function getBestGuess(array $guesses) - { - $result = null; - $maxConfidence = -1; - - foreach ($guesses as $guess) { - if ($maxConfidence < $confidence = $guess->getConfidence()) { - $maxConfidence = $confidence; - $result = $guess; - } - } - - return $result; - } - - /** - * Constructor. - * - * @param int $confidence The confidence - * - * @throws InvalidArgumentException if the given value of confidence is unknown - */ - public function __construct($confidence) - { - if (self::VERY_HIGH_CONFIDENCE !== $confidence && self::HIGH_CONFIDENCE !== $confidence && - self::MEDIUM_CONFIDENCE !== $confidence && self::LOW_CONFIDENCE !== $confidence) { - throw new InvalidArgumentException('The confidence should be one of the constants defined in Guess.'); - } - - $this->confidence = $confidence; - } - - /** - * Returns the confidence that the guessed value is correct. - * - * @return int One of the constants VERY_HIGH_CONFIDENCE, HIGH_CONFIDENCE, - * MEDIUM_CONFIDENCE and LOW_CONFIDENCE - */ - public function getConfidence() - { - return $this->confidence; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Guess/TypeGuess.php b/vendor/symfony/form/Symfony/Component/Form/Guess/TypeGuess.php deleted file mode 100644 index 87cc60a0f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Guess/TypeGuess.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Guess; - -/** - * Contains a guessed class name and a list of options for creating an instance - * of that class. - * - * @author Bernhard Schussek - */ -class TypeGuess extends Guess -{ - /** - * The guessed field type. - * - * @var string - */ - private $type; - - /** - * The guessed options for creating an instance of the guessed class. - * - * @var array - */ - private $options; - - /** - * Constructor. - * - * @param string $type The guessed field type - * @param array $options The options for creating instances of the - * guessed class - * @param int $confidence The confidence that the guessed class name - * is correct - */ - public function __construct($type, array $options, $confidence) - { - parent::__construct($confidence); - - $this->type = $type; - $this->options = $options; - } - - /** - * Returns the guessed field type. - * - * @return string - */ - public function getType() - { - return $this->type; - } - - /** - * Returns the guessed options for creating instances of the guessed type. - * - * @return array - */ - public function getOptions() - { - return $this->options; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Guess/ValueGuess.php b/vendor/symfony/form/Symfony/Component/Form/Guess/ValueGuess.php deleted file mode 100644 index fe40e020c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Guess/ValueGuess.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Guess; - -/** - * Contains a guessed value. - * - * @author Bernhard Schussek - */ -class ValueGuess extends Guess -{ - /** - * The guessed value. - * - * @var array - */ - private $value; - - /** - * Constructor. - * - * @param string $value The guessed value - * @param int $confidence The confidence that the guessed class name - * is correct - */ - public function __construct($value, $confidence) - { - parent::__construct($confidence); - - $this->value = $value; - } - - /** - * Returns the guessed value. - * - * @return mixed - */ - public function getValue() - { - return $this->value; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/LICENSE b/vendor/symfony/form/Symfony/Component/Form/LICENSE deleted file mode 100644 index 43028bc60..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/LICENSE +++ /dev/null @@ -1,19 +0,0 @@ -Copyright (c) 2004-2015 Fabien Potencier - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is furnished -to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. diff --git a/vendor/symfony/form/Symfony/Component/Form/NativeRequestHandler.php b/vendor/symfony/form/Symfony/Component/Form/NativeRequestHandler.php deleted file mode 100644 index 7c883f12e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/NativeRequestHandler.php +++ /dev/null @@ -1,230 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\Util\ServerParams; - -/** - * A request handler using PHP's super globals $_GET, $_POST and $_SERVER. - * - * @author Bernhard Schussek - */ -class NativeRequestHandler implements RequestHandlerInterface -{ - /** - * @var ServerParams - */ - private $serverParams; - - /** - * {@inheritdoc} - */ - public function __construct(ServerParams $params = null) - { - $this->serverParams = $params ?: new ServerParams(); - } - - /** - * The allowed keys of the $_FILES array. - * - * @var array - */ - private static $fileKeys = array( - 'error', - 'name', - 'size', - 'tmp_name', - 'type', - ); - - /** - * {@inheritdoc} - */ - public function handleRequest(FormInterface $form, $request = null) - { - if (null !== $request) { - throw new UnexpectedTypeException($request, 'null'); - } - - $name = $form->getName(); - $method = $form->getConfig()->getMethod(); - - if ($method !== self::getRequestMethod()) { - return; - } - - // For request methods that must not have a request body we fetch data - // from the query string. Otherwise we look for data in the request body. - if ('GET' === $method || 'HEAD' === $method || 'TRACE' === $method) { - if ('' === $name) { - $data = $_GET; - } else { - // Don't submit GET requests if the form's name does not exist - // in the request - if (!isset($_GET[$name])) { - return; - } - - $data = $_GET[$name]; - } - } else { - // Mark the form with an error if the uploaded size was too large - // This is done here and not in FormValidator because $_POST is - // empty when that error occurs. Hence the form is never submitted. - $contentLength = $this->serverParams->getContentLength(); - $maxContentLength = $this->serverParams->getPostMaxSize(); - - if (!empty($maxContentLength) && $contentLength > $maxContentLength) { - // Submit the form, but don't clear the default values - $form->submit(null, false); - - $form->addError(new FormError( - $form->getConfig()->getOption('post_max_size_message'), - null, - array('{{ max }}' => $this->serverParams->getNormalizedIniPostMaxSize()) - )); - - return; - } - - $fixedFiles = array(); - foreach ($_FILES as $fileKey => $file) { - $fixedFiles[$fileKey] = self::stripEmptyFiles(self::fixPhpFilesArray($file)); - } - - if ('' === $name) { - $params = $_POST; - $files = $fixedFiles; - } elseif (array_key_exists($name, $_POST) || array_key_exists($name, $fixedFiles)) { - $default = $form->getConfig()->getCompound() ? array() : null; - $params = array_key_exists($name, $_POST) ? $_POST[$name] : $default; - $files = array_key_exists($name, $fixedFiles) ? $fixedFiles[$name] : $default; - } else { - // Don't submit the form if it is not present in the request - return; - } - - if (is_array($params) && is_array($files)) { - $data = array_replace_recursive($params, $files); - } else { - $data = $params ?: $files; - } - } - - // Don't auto-submit the form unless at least one field is present. - if ('' === $name && count(array_intersect_key($data, $form->all())) <= 0) { - return; - } - - $form->submit($data, 'PATCH' !== $method); - } - - /** - * Returns the method used to submit the request to the server. - * - * @return string The request method. - */ - private static function getRequestMethod() - { - $method = isset($_SERVER['REQUEST_METHOD']) - ? strtoupper($_SERVER['REQUEST_METHOD']) - : 'GET'; - - if ('POST' === $method && isset($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'])) { - $method = strtoupper($_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE']); - } - - return $method; - } - - /** - * Fixes a malformed PHP $_FILES array. - * - * PHP has a bug that the format of the $_FILES array differs, depending on - * whether the uploaded file fields had normal field names or array-like - * field names ("normal" vs. "parent[child]"). - * - * This method fixes the array to look like the "normal" $_FILES array. - * - * It's safe to pass an already converted array, in which case this method - * just returns the original array unmodified. - * - * This method is identical to {@link Symfony\Component\HttpFoundation\FileBag::fixPhpFilesArray} - * and should be kept as such in order to port fixes quickly and easily. - * - * @param array $data - * - * @return array - */ - private static function fixPhpFilesArray($data) - { - if (!is_array($data)) { - return $data; - } - - $keys = array_keys($data); - sort($keys); - - if (self::$fileKeys !== $keys || !isset($data['name']) || !is_array($data['name'])) { - return $data; - } - - $files = $data; - foreach (self::$fileKeys as $k) { - unset($files[$k]); - } - - foreach ($data['name'] as $key => $name) { - $files[$key] = self::fixPhpFilesArray(array( - 'error' => $data['error'][$key], - 'name' => $name, - 'type' => $data['type'][$key], - 'tmp_name' => $data['tmp_name'][$key], - 'size' => $data['size'][$key], - )); - } - - return $files; - } - - /** - * Sets empty uploaded files to NULL in the given uploaded files array. - * - * @param mixed $data The file upload data. - * - * @return array|null Returns the stripped upload data. - */ - private static function stripEmptyFiles($data) - { - if (!is_array($data)) { - return $data; - } - - $keys = array_keys($data); - sort($keys); - - if (self::$fileKeys === $keys) { - if (UPLOAD_ERR_NO_FILE === $data['error']) { - return; - } - - return $data; - } - - foreach ($data as $key => $value) { - $data[$key] = self::stripEmptyFiles($value); - } - - return $data; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/PreloadedExtension.php b/vendor/symfony/form/Symfony/Component/Form/PreloadedExtension.php deleted file mode 100644 index f70ca8d45..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/PreloadedExtension.php +++ /dev/null @@ -1,97 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\InvalidArgumentException; - -/** - * A form extension with preloaded types, type exceptions and type guessers. - * - * @author Bernhard Schussek - */ -class PreloadedExtension implements FormExtensionInterface -{ - /** - * @var FormTypeInterface[] - */ - private $types = array(); - - /** - * @var array[FormTypeExtensionInterface[]] - */ - private $typeExtensions = array(); - - /** - * @var FormTypeGuesserInterface - */ - private $typeGuesser; - - /** - * Creates a new preloaded extension. - * - * @param FormTypeInterface[] $types The types that the extension should support. - * @param array[FormTypeExtensionInterface[]] typeExtensions The type extensions that the extension should support. - * @param FormTypeGuesserInterface|null $typeGuesser The guesser that the extension should support. - */ - public function __construct(array $types, array $typeExtensions, FormTypeGuesserInterface $typeGuesser = null) - { - $this->types = $types; - $this->typeExtensions = $typeExtensions; - $this->typeGuesser = $typeGuesser; - } - - /** - * {@inheritdoc} - */ - public function getType($name) - { - if (!isset($this->types[$name])) { - throw new InvalidArgumentException(sprintf('The type "%s" can not be loaded by this extension', $name)); - } - - return $this->types[$name]; - } - - /** - * {@inheritdoc} - */ - public function hasType($name) - { - return isset($this->types[$name]); - } - - /** - * {@inheritdoc} - */ - public function getTypeExtensions($name) - { - return isset($this->typeExtensions[$name]) - ? $this->typeExtensions[$name] - : array(); - } - - /** - * {@inheritdoc} - */ - public function hasTypeExtensions($name) - { - return !empty($this->typeExtensions[$name]); - } - - /** - * {@inheritdoc} - */ - public function getTypeGuesser() - { - return $this->typeGuesser; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/README.md b/vendor/symfony/form/Symfony/Component/Form/README.md deleted file mode 100644 index 9d8ddd56a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/README.md +++ /dev/null @@ -1,26 +0,0 @@ -Form Component -============== - -Form provides tools for defining forms, rendering and mapping request data to -related models. Furthermore it provides integration with the Validation -component. - -Resources ---------- - -Silex integration: - -https://github.com/fabpot/Silex/blob/master/src/Silex/Provider/FormServiceProvider.php - -Documentation: - -http://symfony.com/doc/2.6/book/forms.html - -Resources ---------- - -You can run the unit tests with the following command: - - $ cd path/to/Symfony/Component/Form/ - $ composer install - $ phpunit diff --git a/vendor/symfony/form/Symfony/Component/Form/RequestHandlerInterface.php b/vendor/symfony/form/Symfony/Component/Form/RequestHandlerInterface.php deleted file mode 100644 index d0a58e697..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/RequestHandlerInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * Submits forms if they were submitted. - * - * @author Bernhard Schussek - */ -interface RequestHandlerInterface -{ - /** - * Submits a form if it was submitted. - * - * @param FormInterface $form The form to submit. - * @param mixed $request The current request. - */ - public function handleRequest(FormInterface $form, $request = null); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/ResolvedFormType.php b/vendor/symfony/form/Symfony/Component/Form/ResolvedFormType.php deleted file mode 100644 index 065189a42..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/ResolvedFormType.php +++ /dev/null @@ -1,254 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\Form\Exception\InvalidArgumentException; -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\OptionsResolver\OptionsResolver; - -/** - * A wrapper for a form type and its extensions. - * - * @author Bernhard Schussek - */ -class ResolvedFormType implements ResolvedFormTypeInterface -{ - /** - * @var FormTypeInterface - */ - private $innerType; - - /** - * @var FormTypeExtensionInterface[] - */ - private $typeExtensions; - - /** - * @var ResolvedFormTypeInterface|null - */ - private $parent; - - /** - * @var OptionsResolver - */ - private $optionsResolver; - - public function __construct(FormTypeInterface $innerType, array $typeExtensions = array(), ResolvedFormTypeInterface $parent = null) - { - if (!preg_match('/^[a-z0-9_]*$/i', $innerType->getName())) { - throw new InvalidArgumentException(sprintf( - 'The "%s" form type name ("%s") is not valid. Names must only contain letters, numbers, and "_".', - get_class($innerType), - $innerType->getName() - )); - } - - foreach ($typeExtensions as $extension) { - if (!$extension instanceof FormTypeExtensionInterface) { - throw new UnexpectedTypeException($extension, 'Symfony\Component\Form\FormTypeExtensionInterface'); - } - } - - $this->innerType = $innerType; - $this->typeExtensions = $typeExtensions; - $this->parent = $parent; - } - - /** - * {@inheritdoc} - */ - public function getName() - { - return $this->innerType->getName(); - } - - /** - * {@inheritdoc} - */ - public function getParent() - { - return $this->parent; - } - - /** - * {@inheritdoc} - */ - public function getInnerType() - { - return $this->innerType; - } - - /** - * {@inheritdoc} - */ - public function getTypeExtensions() - { - // BC - if ($this->innerType instanceof AbstractType) { - return $this->innerType->getExtensions(); - } - - return $this->typeExtensions; - } - - /** - * {@inheritdoc} - */ - public function createBuilder(FormFactoryInterface $factory, $name, array $options = array()) - { - $options = $this->getOptionsResolver()->resolve($options); - - // Should be decoupled from the specific option at some point - $dataClass = isset($options['data_class']) ? $options['data_class'] : null; - - $builder = $this->newBuilder($name, $dataClass, $factory, $options); - $builder->setType($this); - - return $builder; - } - - /** - * {@inheritdoc} - */ - public function createView(FormInterface $form, FormView $parent = null) - { - return $this->newView($parent); - } - - /** - * Configures a form builder for the type hierarchy. - * - * @param FormBuilderInterface $builder The builder to configure. - * @param array $options The options used for the configuration. - */ - public function buildForm(FormBuilderInterface $builder, array $options) - { - if (null !== $this->parent) { - $this->parent->buildForm($builder, $options); - } - - $this->innerType->buildForm($builder, $options); - - foreach ($this->typeExtensions as $extension) { - $extension->buildForm($builder, $options); - } - } - - /** - * Configures a form view for the type hierarchy. - * - * This method is called before the children of the view are built. - * - * @param FormView $view The form view to configure. - * @param FormInterface $form The form corresponding to the view. - * @param array $options The options used for the configuration. - */ - public function buildView(FormView $view, FormInterface $form, array $options) - { - if (null !== $this->parent) { - $this->parent->buildView($view, $form, $options); - } - - $this->innerType->buildView($view, $form, $options); - - foreach ($this->typeExtensions as $extension) { - $extension->buildView($view, $form, $options); - } - } - - /** - * Finishes a form view for the type hierarchy. - * - * This method is called after the children of the view have been built. - * - * @param FormView $view The form view to configure. - * @param FormInterface $form The form corresponding to the view. - * @param array $options The options used for the configuration. - */ - public function finishView(FormView $view, FormInterface $form, array $options) - { - if (null !== $this->parent) { - $this->parent->finishView($view, $form, $options); - } - - $this->innerType->finishView($view, $form, $options); - - foreach ($this->typeExtensions as $extension) { - /* @var FormTypeExtensionInterface $extension */ - $extension->finishView($view, $form, $options); - } - } - - /** - * Returns the configured options resolver used for this type. - * - * @return \Symfony\Component\OptionsResolver\OptionsResolverInterface The options resolver. - */ - public function getOptionsResolver() - { - if (null === $this->optionsResolver) { - if (null !== $this->parent) { - $this->optionsResolver = clone $this->parent->getOptionsResolver(); - } else { - $this->optionsResolver = new OptionsResolver(); - } - - $this->innerType->setDefaultOptions($this->optionsResolver); - - foreach ($this->typeExtensions as $extension) { - $extension->setDefaultOptions($this->optionsResolver); - } - } - - return $this->optionsResolver; - } - - /** - * Creates a new builder instance. - * - * Override this method if you want to customize the builder class. - * - * @param string $name The name of the builder. - * @param string $dataClass The data class. - * @param FormFactoryInterface $factory The current form factory. - * @param array $options The builder options. - * - * @return FormBuilderInterface The new builder instance. - */ - protected function newBuilder($name, $dataClass, FormFactoryInterface $factory, array $options) - { - if ($this->innerType instanceof ButtonTypeInterface) { - return new ButtonBuilder($name, $options); - } - - if ($this->innerType instanceof SubmitButtonTypeInterface) { - return new SubmitButtonBuilder($name, $options); - } - - return new FormBuilder($name, $dataClass, new EventDispatcher(), $factory, $options); - } - - /** - * Creates a new view instance. - * - * Override this method if you want to customize the view class. - * - * @param FormView|null $parent The parent view, if available. - * - * @return FormView A new view instance. - */ - protected function newView(FormView $parent = null) - { - return new FormView($parent); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeFactory.php b/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeFactory.php deleted file mode 100644 index d93d1c06d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeFactory.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * @author Bernhard Schussek - */ -class ResolvedFormTypeFactory implements ResolvedFormTypeFactoryInterface -{ - /** - * {@inheritdoc} - */ - public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ResolvedFormTypeInterface $parent = null) - { - return new ResolvedFormType($type, $typeExtensions, $parent); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeFactoryInterface.php b/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeFactoryInterface.php deleted file mode 100644 index 3240d77f4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeFactoryInterface.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * Creates ResolvedFormTypeInterface instances. - * - * This interface allows you to use your custom ResolvedFormTypeInterface - * implementation, within which you can customize the concrete FormBuilderInterface - * implementations or FormView subclasses that are used by the framework. - * - * @author Bernhard Schussek - */ -interface ResolvedFormTypeFactoryInterface -{ - /** - * Resolves a form type. - * - * @param FormTypeInterface $type - * @param FormTypeExtensionInterface[] $typeExtensions - * @param ResolvedFormTypeInterface|null $parent - * - * @return ResolvedFormTypeInterface - * - * @throws Exception\UnexpectedTypeException if the types parent {@link FormTypeInterface::getParent()} is not a string - * @throws Exception\InvalidArgumentException if the types parent can not be retrieved from any extension - */ - public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ResolvedFormTypeInterface $parent = null); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeInterface.php b/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeInterface.php deleted file mode 100644 index e6a61c753..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/ResolvedFormTypeInterface.php +++ /dev/null @@ -1,108 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * A wrapper for a form type and its extensions. - * - * @author Bernhard Schussek - */ -interface ResolvedFormTypeInterface -{ - /** - * Returns the name of the type. - * - * @return string The type name. - */ - public function getName(); - - /** - * Returns the parent type. - * - * @return ResolvedFormTypeInterface|null The parent type or null. - */ - public function getParent(); - - /** - * Returns the wrapped form type. - * - * @return FormTypeInterface The wrapped form type. - */ - public function getInnerType(); - - /** - * Returns the extensions of the wrapped form type. - * - * @return FormTypeExtensionInterface[] An array of {@link FormTypeExtensionInterface} instances. - */ - public function getTypeExtensions(); - - /** - * Creates a new form builder for this type. - * - * @param FormFactoryInterface $factory The form factory. - * @param string $name The name for the builder. - * @param array $options The builder options. - * - * @return FormBuilderInterface The created form builder. - */ - public function createBuilder(FormFactoryInterface $factory, $name, array $options = array()); - - /** - * Creates a new form view for a form of this type. - * - * @param FormInterface $form The form to create a view for. - * @param FormView $parent The parent view or null. - * - * @return FormView The created form view. - */ - public function createView(FormInterface $form, FormView $parent = null); - - /** - * Configures a form builder for the type hierarchy. - * - * @param FormBuilderInterface $builder The builder to configure. - * @param array $options The options used for the configuration. - */ - public function buildForm(FormBuilderInterface $builder, array $options); - - /** - * Configures a form view for the type hierarchy. - * - * It is called before the children of the view are built. - * - * @param FormView $view The form view to configure. - * @param FormInterface $form The form corresponding to the view. - * @param array $options The options used for the configuration. - */ - public function buildView(FormView $view, FormInterface $form, array $options); - - /** - * Finishes a form view for the type hierarchy. - * - * It is called after the children of the view have been built. - * - * @param FormView $view The form view to configure. - * @param FormInterface $form The form corresponding to the view. - * @param array $options The options used for the configuration. - */ - public function finishView(FormView $view, FormInterface $form, array $options); - - /** - * Returns the configured options resolver used for this type. - * - * @return OptionsResolverInterface The options resolver. - */ - public function getOptionsResolver(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/config/validation.xml b/vendor/symfony/form/Symfony/Component/Form/Resources/config/validation.xml deleted file mode 100644 index 2f2364bde..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/config/validation.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ar.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ar.xlf deleted file mode 100644 index 990b039d6..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ar.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - هذا النموذج يجب الا يحتوى على اى حقول اضافية. - - - The uploaded file was too large. Please try to upload a smaller file. - مساحة الملف المرسل كبيرة. من فضلك حاول ارسال ملف اصغر. - - - The CSRF token is invalid. Please try to resubmit the form. - قيمة رمز الموقع غير صحيحة. من فضلك اعد ارسال النموذج. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.az.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.az.xlf deleted file mode 100644 index 69e447385..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.az.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Bu formada əlavə sahə olmamalıdır. - - - The uploaded file was too large. Please try to upload a smaller file. - Yüklənən fayl çox böyükdür. Lütfən daha kiçik fayl yükləyin. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF nişanı yanlışdır. Lütfen formanı yenidən göndərin. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.bg.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.bg.xlf deleted file mode 100644 index 5c768c305..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.bg.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Тази форма не трябва да съдържа допълнителни полета. - - - The uploaded file was too large. Please try to upload a smaller file. - Каченият файл е твърде голям. Моля, опитайте да качите по-малък файл. - - - The CSRF token is invalid. Please try to resubmit the form. - Невалиден CSRF токен. Моля, опитайте да изпратите формата отново. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ca.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ca.xlf deleted file mode 100644 index 3a2fa484f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ca.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Aquest formulari no hauria de contenir camps addicionals. - - - The uploaded file was too large. Please try to upload a smaller file. - L'arxiu pujat és massa gran. Per favor, pugi un arxiu més petit. - - - The CSRF token is invalid. Please try to resubmit the form. - El token CSRF no és vàlid. Per favor, provi d'enviar novament el formulari. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.cs.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.cs.xlf deleted file mode 100644 index 776da4948..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.cs.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Tato skupina polí nesmí obsahovat další pole. - - - The uploaded file was too large. Please try to upload a smaller file. - Nahraný soubor je příliš velký. Nahrajte prosím menší soubor. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF token je neplatný. Zkuste prosím znovu odeslat formulář. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.da.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.da.xlf deleted file mode 100644 index c2dd4601f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.da.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Feltgruppen må ikke indeholde ekstra felter. - - - The uploaded file was too large. Please try to upload a smaller file. - Den oploadede fil var for stor. Opload venligst en mindre fil. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF nøglen er ugyldig. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.de.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.de.xlf deleted file mode 100644 index a9a183197..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.de.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Dieses Formular sollte keine zusätzlichen Felder enthalten. - - - The uploaded file was too large. Please try to upload a smaller file. - Die hochgeladene Datei ist zu groß. Versuchen Sie bitte eine kleinere Datei hochzuladen. - - - The CSRF token is invalid. Please try to resubmit the form. - Der CSRF-Token ist ungültig. Versuchen Sie bitte das Formular erneut zu senden. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.el.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.el.xlf deleted file mode 100644 index ba2ced74b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.el.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Αυτή η φόρμα δεν πρέπει να περιέχει επιπλέον πεδία. - - - The uploaded file was too large. Please try to upload a smaller file. - Το αρχείο είναι πολύ μεγάλο. Παρακαλούμε προσπαθήστε να ανεβάσετε ένα μικρότερο αρχείο. - - - The CSRF token is invalid. Please try to resubmit the form. - Το CSRF token δεν είναι έγκυρο. Παρακαλούμε δοκιμάστε να υποβάλετε τη φόρμα ξανά. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.en.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.en.xlf deleted file mode 100644 index b8542d319..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.en.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - This form should not contain extra fields. - - - The uploaded file was too large. Please try to upload a smaller file. - The uploaded file was too large. Please try to upload a smaller file. - - - The CSRF token is invalid. Please try to resubmit the form. - The CSRF token is invalid. Please try to resubmit the form. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.es.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.es.xlf deleted file mode 100644 index b609e53e5..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.es.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Este formulario no debería contener campos adicionales. - - - The uploaded file was too large. Please try to upload a smaller file. - El archivo subido es demasiado grande. Por favor, suba un archivo más pequeño. - - - The CSRF token is invalid. Please try to resubmit the form. - El token CSRF no es válido. Por favor, pruebe a enviar nuevamente el formulario. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.et.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.et.xlf deleted file mode 100644 index 1a9867fa2..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.et.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Väljade grupp ei tohiks sisalda lisaväljasid. - - - The uploaded file was too large. Please try to upload a smaller file. - Üleslaaditud fail oli liiga suur. Palun proovi uuesti väiksema failiga. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF-märgis on vigane. Palun proovi vormi uuesti esitada. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.eu.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.eu.xlf deleted file mode 100644 index ba741ab0f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.eu.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Formulario honek ez luke aparteko eremurik eduki behar. - - - The uploaded file was too large. Please try to upload a smaller file. - Igotako fitxategia handiegia da. Mesedez saiatu fitxategi txikiago bat igotzen. - - - The CSRF token is invalid. - CSRF tokena ez da egokia. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fa.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fa.xlf deleted file mode 100644 index 468d2f6fd..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fa.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - این فرم نباید فیلد اضافی داشته باشد. - - - The uploaded file was too large. Please try to upload a smaller file. - فایل بارگذاری شده بسیار بزرگ است. لطفا فایل کوچکتری را بارگزاری کنید. - - - The CSRF token is invalid. Please try to resubmit the form. - مقدار CSRF نامعتبر است. لطفا فرم را مجددا ارسال فرمایید.. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fi.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fi.xlf deleted file mode 100644 index d223bb05c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fi.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This field group should not contain extra fields. - Tämä kenttäryhmä ei voi sisältää ylimääräisiä kenttiä. - - - The uploaded file was too large. Please try to upload a smaller file. - Ladattu tiedosto on liian iso. Ole hyvä ja lataa pienempi tiedosto. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF tarkiste on virheellinen. Olen hyvä ja yritä lähettää lomake uudestaan. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fr.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fr.xlf deleted file mode 100644 index 21f901014..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.fr.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Ce formulaire ne doit pas contenir des champs supplémentaires. - - - The uploaded file was too large. Please try to upload a smaller file. - Le fichier téléchargé est trop volumineux. Merci d'essayer d'envoyer un fichier plus petit. - - - The CSRF token is invalid. Please try to resubmit the form. - Le jeton CSRF est invalide. Veuillez renvoyer le formulaire. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.gl.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.gl.xlf deleted file mode 100644 index 88cc6536e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.gl.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Este formulario non debería conter campos adicionais. - - - The uploaded file was too large. Please try to upload a smaller file. - O arquivo subido é demasiado grande. Por favor, suba un arquivo máis pequeno. - - - The CSRF token is invalid. Please try to resubmit the form. - O token CSRF non é válido. Por favor, probe a enviar novamente o formulario. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.he.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.he.xlf deleted file mode 100644 index 74a71d05a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.he.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - הטופס לא צריך להכיל שדות נוספים. - - - The uploaded file was too large. Please try to upload a smaller file. - הקובץ שהועלה גדול מדי. נסה להעלות קובץ קטן יותר. - - - The CSRF token is invalid. Please try to resubmit the form. - אסימון CSRF אינו חוקי. אנא נסה לשלוח שוב את הטופס. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hr.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hr.xlf deleted file mode 100644 index 8d0bd2920..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hr.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Ovaj obrazac ne smije sadržavati dodatna polja. - - - The uploaded file was too large. Please try to upload a smaller file. - Prenesena datoteka je prevelika. Molim pokušajte prenijeti manju datoteku. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF vrijednost nije ispravna. Pokušajte ponovo poslati obrazac. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hu.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hu.xlf deleted file mode 100644 index 374cfaaea..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hu.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Ez a mezőcsoport nem tartalmazhat extra mezőket. - - - The uploaded file was too large. Please try to upload a smaller file. - A feltöltött fájl túl nagy. Kérem, próbáljon egy kisebb fájlt feltölteni. - - - The CSRF token is invalid. Please try to resubmit the form. - Érvénytelen CSRF token. Kérem, próbálja újra elküldeni az űrlapot. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hy.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hy.xlf deleted file mode 100644 index 5a6091f89..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.hy.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Այս ձևը չպետք է պարունակի լրացուցիչ տողեր. - - - The uploaded file was too large. Please try to upload a smaller file. - Վերբեռնված ֆայլը չափազանց մեծ է: Խնդրվում է վերբեռնել ավելի փոքր չափսի ֆայլ. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF արժեքը անթույլատրելի է: Փորձեք նորից ուղարկել ձևը. - - - - \ No newline at end of file diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.id.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.id.xlf deleted file mode 100644 index b067d9847..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.id.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Gabungan kolom tidak boleh mengandung kolom tambahan. - - - The uploaded file was too large. Please try to upload a smaller file. - Berkas yang di unggah terlalu besar. Silahkan coba unggah berkas yang lebih kecil. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF-Token tidak sah. Silahkan coba kirim ulang formulir. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.it.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.it.xlf deleted file mode 100644 index aa15264d9..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.it.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Questo form non dovrebbe contenere nessun campo extra. - - - The uploaded file was too large. Please try to upload a smaller file. - Il file caricato è troppo grande. Per favore caricare un file più piccolo. - - - The CSRF token is invalid. Please try to resubmit the form. - Il token CSRF non è valido. Provare a reinviare il form. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ja.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ja.xlf deleted file mode 100644 index 2e8585a75..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ja.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - フィールドグループに追加のフィールドを含んではなりません。 - - - The uploaded file was too large. Please try to upload a smaller file. - アップロードされたファイルが大きすぎます。小さなファイルで再度アップロードしてください。 - - - The CSRF token is invalid. - CSRFトークンが無効です。 - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lb.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lb.xlf deleted file mode 100644 index a111ffe39..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lb.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Dës Feldergrupp sollt keng zousätzlech Felder enthalen. - - - The uploaded file was too large. Please try to upload a smaller file. - De geschécktene Fichier ass ze grouss. Versicht wann ech gelift ee méi klenge Fichier eropzelueden. - - - The CSRF token is invalid. Please try to resubmit the form. - Den CSRF-Token ass ongëlteg. Versicht wann ech gelift de Formulaire nach eng Kéier ze schécken. - - - - \ No newline at end of file diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lt.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lt.xlf deleted file mode 100644 index 25f30887b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lt.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Forma negali turėti papildomų laukų. - - - The uploaded file was too large. Please try to upload a smaller file. - Įkelta byla yra per didelė. bandykite įkelti mažesnę. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF kodas nepriimtinas. Bandykite siųsti formos užklausą dar kartą. - - - - \ No newline at end of file diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lv.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lv.xlf deleted file mode 100644 index 9cdfb2cd4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.lv.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Šajā veidlapā nevajadzētu būt papildus ievades laukiem. - - - The uploaded file was too large. Please try to upload a smaller file. - Augšupielādētā faila izmērs bija par lielu. Lūdzu mēģiniet augšupielādēt mazāka izmēra failu. - - - The CSRF token is invalid. Please try to resubmit the form. - Dotais CSRF talons nav derīgs. Lūdzu mēģiniet vēlreiz iesniegt veidlapu. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.mn.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.mn.xlf deleted file mode 100644 index 002b01c17..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.mn.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Форм нэмэлт талбар багтаах боломжгүй. - - - The uploaded file was too large. Please try to upload a smaller file. - Upload хийсэн файл хэтэрхий том байна. Бага хэмжээтэй файл оруулна уу. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF token буруу байна. Формоо дахин илгээнэ үү. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.nb.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.nb.xlf deleted file mode 100644 index 5e36bd5fe..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.nb.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Feltgruppen må ikke inneholde ekstra felter. - - - The uploaded file was too large. Please try to upload a smaller file. - Den opplastede file var for stor. Vennligst last opp en mindre fil. - - - The CSRF token is invalid. - CSRF nøkkelen er ugyldig. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.nl.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.nl.xlf deleted file mode 100644 index 3d737d79c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.nl.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Dit formulier mag geen extra velden bevatten. - - - The uploaded file was too large. Please try to upload a smaller file. - Het geüploade bestand is te groot. Probeer een kleiner bestand te uploaden. - - - The CSRF token is invalid. Please try to resubmit the form. - De CSRF-token is ongeldig. Probeer het formulier opnieuw te versturen. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pl.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pl.xlf deleted file mode 100644 index 64def2a69..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pl.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Ten formularz nie powinien zawierać dodatkowych pól. - - - The uploaded file was too large. Please try to upload a smaller file. - Wgrany plik był za duży. Proszę spróbować wgrać mniejszy plik. - - - The CSRF token is invalid. Please try to resubmit the form. - Token CSRF jest nieprawidłowy. Proszę spróbować wysłać formularz ponownie. - - - - \ No newline at end of file diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pt.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pt.xlf deleted file mode 100644 index 554a810c6..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pt.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Este formulário não deveria conter campos extra. - - - The uploaded file was too large. Please try to upload a smaller file. - O arquivo enviado é muito grande. Por favor, tente enviar um ficheiro mais pequeno. - - - The CSRF token is invalid. Please try to resubmit the form. - O token CSRF é inválido. Por favor submeta o formulário novamente. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pt_BR.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pt_BR.xlf deleted file mode 100644 index 9ae4d7191..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.pt_BR.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Este formulário não deve conter campos adicionais. - - - The uploaded file was too large. Please try to upload a smaller file. - O arquivo enviado é muito grande. Por favor, tente enviar um arquivo menor. - - - The CSRF token is invalid. Please try to resubmit the form. - O token CSRF é inválido. Por favor, tente reenviar o formulário. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ro.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ro.xlf deleted file mode 100644 index 25abab3b6..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ro.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Aceast formular nu ar trebui să conțină câmpuri suplimentare. - - - The uploaded file was too large. Please try to upload a smaller file. - Fișierul încărcat a fost prea mare. Vă rugăm sa încărcați un fișier mai mic. - - - The CSRF token is invalid. Please try to resubmit the form. - Token-ul CSRF este invalid. Vă rugăm să trimiteți formularul incă o dată. - - - - \ No newline at end of file diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ru.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ru.xlf deleted file mode 100644 index 8d829f1b4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.ru.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Эта форма не должна содержать дополнительных полей. - - - The uploaded file was too large. Please try to upload a smaller file. - Загруженный файл слишком большой. Пожалуйста, попробуйте загрузить файл меньшего размера. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF значение недопустимо. Пожалуйста, попробуйте повторить отправку формы. - - - - \ No newline at end of file diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sk.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sk.xlf deleted file mode 100644 index 638d0cc4a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sk.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Polia by nemali obsahovať ďalšie prvky. - - - The uploaded file was too large. Please try to upload a smaller file. - Odoslaný súbor je príliš veľký. Prosím odošlite súbor s menšou veľkosťou. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF token je neplatný. Prosím skúste znovu odoslať formulár. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sl.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sl.xlf deleted file mode 100644 index cd68c1a1e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sl.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Ta obrazec ne sme vsebovati dodatnih polj. - - - The uploaded file was too large. Please try to upload a smaller file. - Naložena datoteka je prevelika. Prosimo, poizkusite naložiti manjšo. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF vrednost je napačna. Prosimo, ponovno pošljite obrazec. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sr_Cyrl.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sr_Cyrl.xlf deleted file mode 100644 index ff7f550ad..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sr_Cyrl.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Овај формулар не треба да садржи додатна поља. - - - The uploaded file was too large. Please try to upload a smaller file. - Отпремљена датотека је била превелика. Молим покушајте отпремање мање датотеке. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF вредност је невалидна. Покушајте поново. - - - - \ No newline at end of file diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sr_Latn.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sr_Latn.xlf deleted file mode 100644 index 6c4be3585..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sr_Latn.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Ovaj formular ne treba da sadrži dodatna polja. - - - The uploaded file was too large. Please try to upload a smaller file. - Otpremljena datoteka je bila prevelika. Molim pokušajte otpremanje manje datoteke. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF vrednost je nevalidna. Pokušajte ponovo. - - - - \ No newline at end of file diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sv.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sv.xlf deleted file mode 100644 index 4e2518b16..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.sv.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Formuläret kan inte innehålla extra fält. - - - The uploaded file was too large. Please try to upload a smaller file. - Den uppladdade filen var för stor. Försök ladda upp en mindre fil. - - - The CSRF token is invalid. - CSRF-symbolen är inte giltig. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.uk.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.uk.xlf deleted file mode 100644 index 4c739face..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.uk.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - Ця форма не повинна містити додаткових полів. - - - The uploaded file was too large. Please try to upload a smaller file. - Завантажений файл занадто великий. Будь-ласка, спробуйте завантажити файл меншого розміру. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF значення недопустиме. Будь-ласка, спробуйте відправити форму знову. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.zh_CN.xlf b/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.zh_CN.xlf deleted file mode 100644 index 8bdf7fb5c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Resources/translations/validators.zh_CN.xlf +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - This form should not contain extra fields. - 该表单中不可有额外字段. - - - The uploaded file was too large. Please try to upload a smaller file. - 上传文件太大, 请重新尝试上传一个较小的文件. - - - The CSRF token is invalid. Please try to resubmit the form. - CSRF 验证符无效, 请重新提交. - - - - diff --git a/vendor/symfony/form/Symfony/Component/Form/ReversedTransformer.php b/vendor/symfony/form/Symfony/Component/Form/ReversedTransformer.php deleted file mode 100644 index fc5cd12bc..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/ReversedTransformer.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * Reverses a transformer. - * - * When the transform() method is called, the reversed transformer's - * reverseTransform() method is called and vice versa. - * - * @author Bernhard Schussek - */ -class ReversedTransformer implements DataTransformerInterface -{ - /** - * The reversed transformer. - * - * @var DataTransformerInterface - */ - protected $reversedTransformer; - - /** - * Reverses this transformer. - * - * @param DataTransformerInterface $reversedTransformer - */ - public function __construct(DataTransformerInterface $reversedTransformer) - { - $this->reversedTransformer = $reversedTransformer; - } - - /** - * {@inheritdoc} - */ - public function transform($value) - { - return $this->reversedTransformer->reverseTransform($value); - } - - /** - * {@inheritdoc} - */ - public function reverseTransform($value) - { - return $this->reversedTransformer->transform($value); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/SubmitButton.php b/vendor/symfony/form/Symfony/Component/Form/SubmitButton.php deleted file mode 100644 index e95cdeeff..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/SubmitButton.php +++ /dev/null @@ -1,52 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * A button that submits the form. - * - * @author Bernhard Schussek - */ -class SubmitButton extends Button implements ClickableInterface -{ - /** - * @var bool - */ - private $clicked = false; - - /** - * {@inheritdoc} - */ - public function isClicked() - { - return $this->clicked; - } - - /** - * Submits data to the button. - * - * @param null|string $submittedData The data. - * @param bool $clearMissing Not used. - * - * @return SubmitButton The button instance - * - * @throws Exception\AlreadySubmittedException If the form has already been submitted. - */ - public function submit($submittedData, $clearMissing = true) - { - parent::submit($submittedData, $clearMissing); - - $this->clicked = null !== $submittedData; - - return $this; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/SubmitButtonBuilder.php b/vendor/symfony/form/Symfony/Component/Form/SubmitButtonBuilder.php deleted file mode 100644 index 931f399da..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/SubmitButtonBuilder.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * A builder for {@link SubmitButton} instances. - * - * @author Bernhard Schussek - */ -class SubmitButtonBuilder extends ButtonBuilder -{ - /** - * Creates the button. - * - * @return SubmitButton The button - */ - public function getForm() - { - return new SubmitButton($this->getFormConfig()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/SubmitButtonTypeInterface.php b/vendor/symfony/form/Symfony/Component/Form/SubmitButtonTypeInterface.php deleted file mode 100644 index f7ac13f7e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/SubmitButtonTypeInterface.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form; - -/** - * A type that should be converted into a {@link SubmitButton} instance. - * - * @author Bernhard Schussek - */ -interface SubmitButtonTypeInterface extends FormTypeInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Test/DeprecationErrorHandler.php b/vendor/symfony/form/Symfony/Component/Form/Test/DeprecationErrorHandler.php deleted file mode 100644 index a88ec7921..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Test/DeprecationErrorHandler.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\FormEvent; - -/** - * @deprecated since version 2.3, to be removed in 3.0. - */ -class DeprecationErrorHandler -{ - public static function handle($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & ~E_USER_DEPRECATED) { - return true; - } - - return \PHPUnit_Util_ErrorHandler::handleError($errorNumber, $message, $file, $line); - } - - public static function handleBC($errorNumber, $message, $file, $line, $context) - { - if ($errorNumber & ~E_USER_DEPRECATED) { - return true; - } - - return false; - } - - public static function preBind($listener, FormEvent $event) - { - set_error_handler(array('Symfony\Component\Form\Test\DeprecationErrorHandler', 'handle')); - $listener->preBind($event); - restore_error_handler(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Test/FormBuilderInterface.php b/vendor/symfony/form/Symfony/Component/Form/Test/FormBuilderInterface.php deleted file mode 100644 index 185a8a12d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Test/FormBuilderInterface.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\FormBuilderInterface as BaseFormBuilderInterface; - -interface FormBuilderInterface extends \Iterator, BaseFormBuilderInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Test/FormIntegrationTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Test/FormIntegrationTestCase.php deleted file mode 100644 index caab26970..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Test/FormIntegrationTestCase.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\Forms; -use Symfony\Component\Form\FormFactoryInterface; - -/** - * @author Bernhard Schussek - */ -abstract class FormIntegrationTestCase extends \PHPUnit_Framework_TestCase -{ - /** - * @var FormFactoryInterface - */ - protected $factory; - - protected function setUp() - { - $this->factory = Forms::createFormFactoryBuilder() - ->addExtensions($this->getExtensions()) - ->getFormFactory(); - } - - protected function getExtensions() - { - return array(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Test/FormInterface.php b/vendor/symfony/form/Symfony/Component/Form/Test/FormInterface.php deleted file mode 100644 index 4af460308..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Test/FormInterface.php +++ /dev/null @@ -1,18 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\FormInterface as BaseFormInterface; - -interface FormInterface extends \Iterator, BaseFormInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Test/FormPerformanceTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Test/FormPerformanceTestCase.php deleted file mode 100644 index 090eb8bc4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Test/FormPerformanceTestCase.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -/** - * Base class for performance tests. - * - * Copied from Doctrine 2's OrmPerformanceTestCase. - * - * @author robo - * @author Bernhard Schussek - */ -abstract class FormPerformanceTestCase extends FormIntegrationTestCase -{ - /** - * @var int - */ - protected $maxRunningTime = 0; - - /** - * {@inheritdoc} - */ - protected function runTest() - { - $s = microtime(true); - parent::runTest(); - $time = microtime(true) - $s; - - if ($this->maxRunningTime != 0 && $time > $this->maxRunningTime) { - $this->fail( - sprintf( - 'expected running time: <= %s but was: %s', - - $this->maxRunningTime, - $time - ) - ); - } - } - - /** - * @param int $maxRunningTime - * - * @throws \InvalidArgumentException - */ - public function setMaxRunningTime($maxRunningTime) - { - if (is_int($maxRunningTime) && $maxRunningTime >= 0) { - $this->maxRunningTime = $maxRunningTime; - } else { - throw new \InvalidArgumentException(); - } - } - - /** - * @since Method available since Release 2.3.0 - * - * @return int - */ - public function getMaxRunningTime() - { - return $this->maxRunningTime; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Test/TypeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Test/TypeTestCase.php deleted file mode 100644 index 87797757f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Test/TypeTestCase.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Test; - -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\EventDispatcher\EventDispatcher; - -abstract class TypeTestCase extends FormIntegrationTestCase -{ - /** - * @var FormBuilder - */ - protected $builder; - - /** - * @var EventDispatcher - */ - protected $dispatcher; - - protected function setUp() - { - parent::setUp(); - - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->builder = new FormBuilder(null, null, $this->dispatcher, $this->factory); - } - - public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual) - { - self::assertEquals($expected->format('c'), $actual->format('c')); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php deleted file mode 100644 index b5354e0bd..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractBootstrap3LayoutTest.php +++ /dev/null @@ -1,1818 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormError; - -abstract class AbstractBootstrap3LayoutTest extends AbstractLayoutTest -{ - public function testLabelOnForm() - { - $form = $this->factory->createNamed('name', 'date'); - $view = $form->createView(); - $this->renderWidget($view, array('label' => 'foo')); - $html = $this->renderLabel($view); - - $this->assertMatchesXpath($html, -'/label - [@class="control-label required"] - [.="[trans]Name[/trans]"] -' - ); - } - - public function testLabelDoesNotRenderFieldAttributes() - { - $form = $this->factory->createNamed('name', 'text'); - $html = $this->renderLabel($form->createView(), null, array( - 'attr' => array( - 'class' => 'my&class', - ), - )); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [@class="control-label required"] -' - ); - } - - public function testLabelWithCustomAttributesPassedDirectly() - { - $form = $this->factory->createNamed('name', 'text'); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( - 'class' => 'my&class', - ), - )); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [@class="my&class control-label required"] -' - ); - } - - public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() - { - $form = $this->factory->createNamed('name', 'text'); - $html = $this->renderLabel($form->createView(), 'Custom label', array( - 'label_attr' => array( - 'class' => 'my&class', - ), - )); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [@class="my&class control-label required"] - [.="[trans]Custom label[/trans]"] -' - ); - } - - public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'label' => 'Custom label', - )); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( - 'class' => 'my&class', - ), - )); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [@class="my&class control-label required"] - [.="[trans]Custom label[/trans]"] -' - ); - } - - public function testErrors() - { - $form = $this->factory->createNamed('name', 'text'); - $form->addError(new FormError('[trans]Error 1[/trans]')); - $form->addError(new FormError('[trans]Error 2[/trans]')); - $view = $form->createView(); - $html = $this->renderErrors($view); - - $this->assertMatchesXpath($html, -'/div - [@class="alert alert-danger"] - [ - ./ul - [@class="list-unstyled"] - [ - ./li - [.="[trans]Error 1[/trans]"] - [ - ./span[@class="glyphicon glyphicon-exclamation-sign"] - ] - /following-sibling::li - [.="[trans]Error 2[/trans]"] - [ - ./span[@class="glyphicon glyphicon-exclamation-sign"] - ] - ] - [count(./li)=2] - ] -' - ); - } - - public function testOverrideWidgetBlock() - { - // see custom_widgets.html.twig - $form = $this->factory->createNamed('text_id', 'text'); - $html = $this->renderWidget($form->createView()); - - $this->assertMatchesXpath($html, -'/div - [ - ./input - [@type="text"] - [@id="text_id"] - [@class="form-control"] - ] - [@id="container"] -' - ); - } - - public function testCheckedCheckbox() - { - $form = $this->factory->createNamed('name', 'checkbox', true); - - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), -'/div - [@class="checkbox"] - [ - ./label - [.="[trans]Name[/trans]"] - [ - ./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class"][@checked="checked"][@value="1"] - ] - ] -' - ); - } - - public function testUncheckedCheckbox() - { - $form = $this->factory->createNamed('name', 'checkbox', false); - - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), -'/div - [@class="checkbox"] - [ - ./label - [.="[trans]Name[/trans]"] - [ - ./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class"][not(@checked)] - ] - ] -' - ); - } - - public function testCheckboxWithValue() - { - $form = $this->factory->createNamed('name', 'checkbox', false, array( - 'value' => 'foo&bar', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), -'/div - [@class="checkbox"] - [ - ./label - [.="[trans]Name[/trans]"] - [ - ./input[@type="checkbox"][@name="name"][@id="my&id"][@class="my&class"][@value="foo&bar"] - ] - ] -' - ); - } - - public function testSingleChoice() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [not(@required)] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testSingleChoiceWithPreferred() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'preferred_choices' => array('&b'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => '-- sep --', 'attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [not(@required)] - [ - ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - /following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceWithPreferredAndNoSeparator() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'preferred_choices' => array('&b'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => null, 'attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [not(@required)] - [ - ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testSingleChoiceWithPreferredAndBlankSeparator() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'preferred_choices' => array('&b'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => '', 'attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [not(@required)] - [ - ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - /following-sibling::option[@disabled="disabled"][not(@selected)][.=""] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testChoiceWithOnlyPreferred() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'preferred_choices' => array('&a', '&b'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@class="my&class form-control"] - [count(./option)=2] -' - ); - } - - public function testSingleChoiceNonRequired() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => false, - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [not(@required)] - [ - ./option[@value=""][.="[trans][/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceNonRequiredNoneSelected() - { - $form = $this->factory->createNamed('name', 'choice', null, array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => false, - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [not(@required)] - [ - ./option[@value=""][.="[trans][/trans]"] - /following-sibling::option[@value="&a"][not(@selected)][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceNonRequiredWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => false, - 'expanded' => false, - 'required' => false, - 'placeholder' => 'Select&Anything&Not&Me', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [not(@required)] - [ - ./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Anything&Not&Me[/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceRequiredWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => true, - 'multiple' => false, - 'expanded' => false, - 'placeholder' => 'Test&Me', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [@required="required"] - [ - ./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Test&Me[/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceRequiredWithPlaceholderViaView() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => true, - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('placeholder' => '', 'attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [@required="required"] - [ - ./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceGrouped() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array( - 'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'Group&2' => array('&c' => 'Choice&C'), - ), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [./optgroup[@label="[trans]Group&1[/trans]"] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] - ] - [./optgroup[@label="[trans]Group&2[/trans]"] - [./option[@value="&c"][not(@selected)][.="[trans]Choice&C[/trans]"]] - [count(./option)=1] - ] - [count(./optgroup)=2] -' - ); - } - - public function testMultipleChoice() - { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => true, - 'multiple' => true, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name[]"] - [@class="my&class form-control"] - [@required="required"] - [@multiple="multiple"] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testMultipleChoiceSkipsPlaceholder() - { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => true, - 'expanded' => false, - 'placeholder' => 'Test&Me', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name[]"] - [@class="my&class form-control"] - [@multiple="multiple"] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testMultipleChoiceNonRequired() - { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => false, - 'multiple' => true, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name[]"] - [@class="my&class form-control"] - [@multiple="multiple"] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testSingleChoiceExpanded() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => false, - 'expanded' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [@class="radio"] - [ - ./label - [.="[trans]Choice&A[/trans]"] - [ - ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked] - ] - ] - /following-sibling::div - [@class="radio"] - [ - ./label - [.="[trans]Choice&B[/trans]"] - [ - ./input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)] - ] - ] - /following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"] - ] -' - ); - } - - public function testSingleChoiceExpandedWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => false, - 'expanded' => true, - 'placeholder' => 'Test&Me', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [@class="radio"] - [ - ./label - [.="[trans]Test&Me[/trans]"] - [ - ./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)] - ] - ] - /following-sibling::div - [@class="radio"] - [ - ./label - [.="[trans]Choice&A[/trans]"] - [ - ./input[@type="radio"][@name="name"][@id="name_0"][@checked] - ] - ] - /following-sibling::div - [@class="radio"] - [ - ./label - [.="[trans]Choice&B[/trans]"] - [ - ./input[@type="radio"][@name="name"][@id="name_1"][not(@checked)] - ] - ] - /following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"] - ] -' - ); - } - - public function testSingleChoiceExpandedWithBooleanValue() - { - $form = $this->factory->createNamed('name', 'choice', true, array( - 'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'), - 'multiple' => false, - 'expanded' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [@class="radio"] - [ - ./label - [.="[trans]Choice&A[/trans]"] - [ - ./input[@type="radio"][@name="name"][@id="name_0"][@checked] - ] - ] - /following-sibling::div - [@class="radio"] - [ - ./label - [.="[trans]Choice&B[/trans]"] - [ - ./input[@type="radio"][@name="name"][@id="name_1"][not(@checked)] - ] - ] - /following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"] - ] -' - ); - } - - public function testMultipleChoiceExpanded() - { - $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), - 'multiple' => true, - 'expanded' => true, - 'required' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [@class="checkbox"] - [ - ./label - [.="[trans]Choice&A[/trans]"] - [ - ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)] - ] - ] - /following-sibling::div - [@class="checkbox"] - [ - ./label - [.="[trans]Choice&B[/trans]"] - [ - ./input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)] - ] - ] - /following-sibling::div - [@class="checkbox"] - [ - ./label - [.="[trans]Choice&C[/trans]"] - [ - ./input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)] - ] - ] - /following-sibling::input[@type="hidden"][@id="name__token"][@class="form-control"] - ] -' - ); - } - - public function testCountry() - { - $form = $this->factory->createNamed('name', 'country', 'AT'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]] - [count(./option)>200] -' - ); - } - - public function testCountryWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'country', 'AT', array( - 'placeholder' => 'Select&Country', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]] - [./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]] - [count(./option)>201] -' - ); - } - - public function testDateTime() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'with_seconds' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [ - ./select - [@id="name_date_month"] - [@class="form-control"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_date_day"] - [@class="form-control"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_date_year"] - [@class="form-control"] - [./option[@value="2011"][@selected="selected"]] - /following-sibling::select - [@id="name_time_hour"] - [@class="form-control"] - [./option[@value="4"][@selected="selected"]] - /following-sibling::select - [@id="name_time_minute"] - [@class="form-control"] - [./option[@value="5"][@selected="selected"]] - ] - [count(.//select)=5] -' - ); - } - - public function testDateTimeWithPlaceholderGlobal() - { - $form = $this->factory->createNamed('name', 'datetime', null, array( - 'input' => 'string', - 'placeholder' => 'Change&Me', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_date_month"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_date_day"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_date_year"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_time_hour"] - [@class="form-control"] - [./option[@value=""][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_time_minute"] - [@class="form-control"] - [./option[@value=""][.="[trans]Change&Me[/trans]"]] - ] - [count(.//select)=5] -' - ); - } - - public function testDateTimeWithHourAndMinute() - { - $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); - - $form = $this->factory->createNamed('name', 'datetime', $data, array( - 'input' => 'array', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_date_month"] - [@class="form-control"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_date_day"] - [@class="form-control"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_date_year"] - [@class="form-control"] - [./option[@value="2011"][@selected="selected"]] - /following-sibling::select - [@id="name_time_hour"] - [@class="form-control"] - [./option[@value="4"][@selected="selected"]] - /following-sibling::select - [@id="name_time_minute"] - [@class="form-control"] - [./option[@value="5"][@selected="selected"]] - ] - [count(.//select)=5] -' - ); - } - - public function testDateTimeWithSeconds() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'with_seconds' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_date_month"] - [@class="form-control"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_date_day"] - [@class="form-control"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_date_year"] - [@class="form-control"] - [./option[@value="2011"][@selected="selected"]] - /following-sibling::select - [@id="name_time_hour"] - [@class="form-control"] - [./option[@value="4"][@selected="selected"]] - /following-sibling::select - [@id="name_time_minute"] - [@class="form-control"] - [./option[@value="5"][@selected="selected"]] - /following-sibling::select - [@id="name_time_second"] - [@class="form-control"] - [./option[@value="6"][@selected="selected"]] - ] - [count(.//select)=6] -' - ); - } - - public function testDateTimeSingleText() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'date_widget' => 'single_text', - 'time_widget' => 'single_text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./input - [@type="date"] - [@id="name_date"] - [@name="name[date]"] - [@class="form-control"] - [@value="2011-02-03"] - /following-sibling::input - [@type="time"] - [@id="name_time"] - [@name="name[time]"] - [@class="form-control"] - [@value="04:05"] - ] -' - ); - } - - public function testDateTimeWithWidgetSingleText() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'widget' => 'single_text', - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="datetime"] - [@name="name"] - [@class="my&class form-control"] - [@value="2011-02-03T04:05:06Z"] -' - ); - } - - public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - 'widget' => 'single_text', - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="datetime"] - [@name="name"] - [@class="my&class form-control"] - [@value="2011-02-03T04:05:06Z"] -' - ); - } - - public function testDateChoice() - { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( - 'input' => 'string', - 'widget' => 'choice', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_month"] - [@class="form-control"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_day"] - [@class="form-control"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_year"] - [@class="form-control"] - [./option[@value="2011"][@selected="selected"]] - ] - [count(./select)=3] -' - ); - } - - public function testDateChoiceWithPlaceholderGlobal() - { - $form = $this->factory->createNamed('name', 'date', null, array( - 'input' => 'string', - 'widget' => 'choice', - 'placeholder' => 'Change&Me', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_month"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_day"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_year"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - ] - [count(./select)=3] -' - ); - } - - public function testDateChoiceWithPlaceholderOnYear() - { - $form = $this->factory->createNamed('name', 'date', null, array( - 'input' => 'string', - 'widget' => 'choice', - 'required' => false, - 'placeholder' => array('year' => 'Change&Me'), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_month"] - [@class="form-control"] - [./option[@value="1"]] - /following-sibling::select - [@id="name_day"] - [@class="form-control"] - [./option[@value="1"]] - /following-sibling::select - [@id="name_year"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - ] - [count(./select)=3] -' - ); - } - - public function testDateText() - { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( - 'input' => 'string', - 'widget' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./input - [@id="name_month"] - [@type="text"] - [@class="form-control"] - [@value="2"] - /following-sibling::input - [@id="name_day"] - [@type="text"] - [@class="form-control"] - [@value="3"] - /following-sibling::input - [@id="name_year"] - [@type="text"] - [@class="form-control"] - [@value="2011"] - ] - [count(./input)=3] -' - ); - } - - public function testDateSingleText() - { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( - 'input' => 'string', - 'widget' => 'single_text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="date"] - [@name="name"] - [@class="my&class form-control"] - [@value="2011-02-03"] -' - ); - } - - public function testBirthDay() - { - $form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array( - 'input' => 'string', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_month"] - [@class="form-control"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_day"] - [@class="form-control"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_year"] - [@class="form-control"] - [./option[@value="2000"][@selected="selected"]] - ] - [count(./select)=3] -' - ); - } - - public function testBirthDayWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array( - 'input' => 'string', - 'placeholder' => '', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_month"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] - [./option[@value="1"][@selected="selected"]] - /following-sibling::select - [@id="name_day"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] - [./option[@value="1"][@selected="selected"]] - /following-sibling::select - [@id="name_year"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] - [./option[@value="1950"][@selected="selected"]] - ] - [count(./select)=3] -' - ); - } - - public function testEmail() - { - $form = $this->factory->createNamed('name', 'email', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="email"] - [@name="name"] - [@class="my&class form-control"] - [@value="foo&bar"] - [not(@maxlength)] -' - ); - } - - public function testEmailWithMaxLength() - { - $form = $this->factory->createNamed('name', 'email', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="email"] - [@name="name"] - [@class="my&class form-control"] - [@value="foo&bar"] - [@maxlength="123"] -' - ); - } - - public function testHidden() - { - $form = $this->factory->createNamed('name', 'hidden', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="hidden"] - [@name="name"] - [@class="my&class form-control"] - [@value="foo&bar"] -' - ); - } - - public function testReadOnly() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'read_only' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="text"] - [@name="name"] - [@class="my&class form-control"] - [@readonly="readonly"] -' - ); - } - - public function testDisabled() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'disabled' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="text"] - [@name="name"] - [@class="my&class form-control"] - [@disabled="disabled"] -' - ); - } - - public function testInteger() - { - $form = $this->factory->createNamed('name', 'integer', 123); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="number"] - [@name="name"] - [@class="my&class form-control"] - [@value="123"] -' - ); - } - - public function testLanguage() - { - $form = $this->factory->createNamed('name', 'language', 'de'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [./option[@value="de"][@selected="selected"][.="[trans]German[/trans]"]] - [count(./option)>200] -' - ); - } - - public function testLocale() - { - $form = $this->factory->createNamed('name', 'locale', 'de_AT'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [./option[@value="de_AT"][@selected="selected"][.="[trans]German (Austria)[/trans]"]] - [count(./option)>200] -' - ); - } - - public function testMoney() - { - $form = $this->factory->createNamed('name', 'money', 1234.56, array( - 'currency' => 'EUR', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), -'/div - [@class="input-group"] - [ - ./span - [@class="input-group-addon"] - [contains(.., "€")] - /following-sibling::input - [@id="my&id"] - [@type="text"] - [@name="name"] - [@class="my&class form-control"] - [@value="1234.56"] - ] -' - ); - } - - public function testNumber() - { - $form = $this->factory->createNamed('name', 'number', 1234.56); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="text"] - [@name="name"] - [@class="my&class form-control"] - [@value="1234.56"] -' - ); - } - - public function testPassword() - { - $form = $this->factory->createNamed('name', 'password', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="password"] - [@name="name"] - [@class="my&class form-control"] -' - ); - } - - public function testPasswordSubmittedWithNotAlwaysEmpty() - { - $form = $this->factory->createNamed('name', 'password', null, array( - 'always_empty' => false, - )); - $form->submit('foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="password"] - [@name="name"] - [@class="my&class form-control"] - [@value="foo&bar"] -' - ); - } - - public function testPasswordWithMaxLength() - { - $form = $this->factory->createNamed('name', 'password', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="password"] - [@name="name"] - [@class="my&class form-control"] - [@maxlength="123"] -' - ); - } - - public function testPercent() - { - $form = $this->factory->createNamed('name', 'percent', 0.1); - - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), -'/div - [@class="input-group"] - [ - ./input - [@id="my&id"] - [@type="text"] - [@name="name"] - [@class="my&class form-control"] - [@value="10"] - /following-sibling::span - [@class="input-group-addon"] - [contains(.., "%")] - ] -' - ); - } - - public function testCheckedRadio() - { - $form = $this->factory->createNamed('name', 'radio', true); - - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), -'/div - [@class="radio"] - [ - ./label - [@class="required"] - [ - ./input - [@id="my&id"] - [@type="radio"] - [@name="name"] - [@class="my&class"] - [@checked="checked"] - [@value="1"] - ] - ] -' - ); - } - - public function testUncheckedRadio() - { - $form = $this->factory->createNamed('name', 'radio', false); - - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), -'/div - [@class="radio"] - [ - ./label - [@class="required"] - [ - ./input - [@id="my&id"] - [@type="radio"] - [@name="name"] - [@class="my&class"] - [not(@checked)] - ] - ] -' - ); - } - - public function testRadioWithValue() - { - $form = $this->factory->createNamed('name', 'radio', false, array( - 'value' => 'foo&bar', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('id' => 'my&id', 'attr' => array('class' => 'my&class')), -'/div - [@class="radio"] - [ - ./label - [@class="required"] - [ - ./input - [@id="my&id"] - [@type="radio"] - [@name="name"] - [@class="my&class"] - [@value="foo&bar"] - ] - ] -' - ); - } - - public function testTextarea() - { - $form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array( - 'attr' => array('pattern' => 'foo'), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/textarea - [@name="name"] - [@pattern="foo"] - [@class="my&class form-control"] - [.="foo&bar"] -' - ); - } - - public function testText() - { - $form = $this->factory->createNamed('name', 'text', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="text"] - [@name="name"] - [@class="my&class form-control"] - [@value="foo&bar"] - [not(@maxlength)] -' - ); - } - - public function testTextWithMaxLength() - { - $form = $this->factory->createNamed('name', 'text', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="text"] - [@name="name"] - [@class="my&class form-control"] - [@value="foo&bar"] - [@maxlength="123"] -' - ); - } - - public function testSearch() - { - $form = $this->factory->createNamed('name', 'search', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="search"] - [@name="name"] - [@class="my&class form-control"] - [@value="foo&bar"] - [not(@maxlength)] -' - ); - } - - public function testTime() - { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( - 'input' => 'string', - 'with_seconds' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_hour"] - [@class="form-control"] - [not(@size)] - [./option[@value="4"][@selected="selected"]] - /following-sibling::select - [@id="name_minute"] - [@class="form-control"] - [not(@size)] - [./option[@value="5"][@selected="selected"]] - ] - [count(./select)=2] -' - ); - } - - public function testTimeWithSeconds() - { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( - 'input' => 'string', - 'with_seconds' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_hour"] - [@class="form-control"] - [not(@size)] - [./option[@value="4"][@selected="selected"]] - [count(./option)>23] - /following-sibling::select - [@id="name_minute"] - [@class="form-control"] - [not(@size)] - [./option[@value="5"][@selected="selected"]] - [count(./option)>59] - /following-sibling::select - [@id="name_second"] - [@class="form-control"] - [not(@size)] - [./option[@value="6"][@selected="selected"]] - [count(./option)>59] - ] - [count(./select)=3] -' - ); - } - - public function testTimeText() - { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( - 'input' => 'string', - 'widget' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./input - [@type="text"] - [@id="name_hour"] - [@name="name[hour]"] - [@class="form-control"] - [@value="04"] - [@required="required"] - [not(@size)] - /following-sibling::input - [@type="text"] - [@id="name_minute"] - [@name="name[minute]"] - [@class="form-control"] - [@value="05"] - [@required="required"] - [not(@size)] - ] - [count(./input)=2] -' - ); - } - - public function testTimeSingleText() - { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( - 'input' => 'string', - 'widget' => 'single_text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="time"] - [@name="name"] - [@class="my&class form-control"] - [@value="04:05"] - [not(@size)] -' - ); - } - - public function testTimeWithPlaceholderGlobal() - { - $form = $this->factory->createNamed('name', 'time', null, array( - 'input' => 'string', - 'placeholder' => 'Change&Me', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_hour"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - [count(./option)>24] - /following-sibling::select - [@id="name_minute"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - [count(./option)>60] - ] - [count(./select)=2] -' - ); - } - - public function testTimeWithPlaceholderOnYear() - { - $form = $this->factory->createNamed('name', 'time', null, array( - 'input' => 'string', - 'required' => false, - 'placeholder' => array('hour' => 'Change&Me'), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/div - [@class="my&class form-inline"] - [ - ./select - [@id="name_hour"] - [@class="form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - [count(./option)>24] - /following-sibling::select - [@id="name_minute"] - [./option[@value="1"]] - [count(./option)>59] - ] - [count(./select)=2] -' - ); - } - - public function testTimezone() - { - $form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@name="name"] - [@class="my&class form-control"] - [not(@required)] - [./optgroup - [@label="[trans]Europe[/trans]"] - [./option[@value="Europe/Vienna"][@selected="selected"][.="[trans]Vienna[/trans]"]] - ] - [count(./optgroup)>10] - [count(.//option)>200] -' - ); - } - - public function testTimezoneWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'timezone', null, array( - 'placeholder' => 'Select&Timezone', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/select - [@class="my&class form-control"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]] - [count(./optgroup)>10] - [count(.//option)>201] -' - ); - } - - public function testUrl() - { - $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; - $form = $this->factory->createNamed('name', 'url', $url); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), -'/input - [@type="url"] - [@name="name"] - [@class="my&class form-control"] - [@value="http://www.google.com?foo1=bar1&foo2=bar2"] -' - ); - } - - public function testButton() - { - $form = $this->factory->createNamed('name', 'button'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), - '/button[@type="button"][@name="name"][.="[trans]Name[/trans]"][@class="my&class btn"]' - ); - } - - public function testSubmit() - { - $form = $this->factory->createNamed('name', 'submit'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), - '/button[@type="submit"][@name="name"][@class="my&class btn"]' - ); - } - - public function testReset() - { - $form = $this->factory->createNamed('name', 'reset'); - - $this->assertWidgetMatchesXpath($form->createView(), array('attr' => array('class' => 'my&class')), - '/button[@type="reset"][@name="name"][@class="my&class btn"]' - ); - } - - public function testWidgetAttributes() - { - $form = $this->factory->createNamed('text', 'text', 'value', array( - 'required' => true, - 'disabled' => true, - 'read_only' => true, - 'attr' => array('maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'), - )); - - $html = $this->renderWidget($form->createView()); - - // compare plain HTML to check the whitespace - $this->assertSame('', $html); - } - - public function testWidgetAttributeNameRepeatedIfTrue() - { - $form = $this->factory->createNamed('text', 'text', 'value', array( - 'attr' => array('foo' => true), - )); - - $html = $this->renderWidget($form->createView()); - - // foo="foo" - $this->assertSame('', $html); - } - - public function testButtonAttributes() - { - $form = $this->factory->createNamed('button', 'button', null, array( - 'disabled' => true, - 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), - )); - - $html = $this->renderWidget($form->createView()); - - // compare plain HTML to check the whitespace - $this->assertSame('', $html); - } - - public function testButtonAttributeNameRepeatedIfTrue() - { - $form = $this->factory->createNamed('button', 'button', null, array( - 'attr' => array('foo' => true), - )); - - $html = $this->renderWidget($form->createView()); - - // foo="foo" - $this->assertSame('', $html); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php deleted file mode 100644 index 45b2f311c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php +++ /dev/null @@ -1,781 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Tests\Fixtures\AlternatingRowType; -use Symfony\Component\Security\Csrf\CsrfToken; - -abstract class AbstractDivLayoutTest extends AbstractLayoutTest -{ - public function testRow() - { - $form = $this->factory->createNamed('name', 'text'); - $form->addError(new FormError('[trans]Error![/trans]')); - $view = $form->createView(); - $html = $this->renderRow($view); - - $this->assertMatchesXpath($html, -'/div - [ - ./label[@for="name"] - /following-sibling::ul - [./li[.="[trans]Error![/trans]"]] - [count(./li)=1] - /following-sibling::input[@id="name"] - ] -' - ); - } - - public function testRowOverrideVariables() - { - $view = $this->factory->createNamed('name', 'text')->createView(); - $html = $this->renderRow($view, array( - 'attr' => array('class' => 'my&class'), - 'label' => 'foo&bar', - 'label_attr' => array('class' => 'my&label&class'), - )); - - $this->assertMatchesXpath($html, -'/div - [ - ./label[@for="name"][@class="my&label&class required"][.="[trans]foo&bar[/trans]"] - /following-sibling::input[@id="name"][@class="my&class"] - ] -' - ); - } - - public function testRepeatedRow() - { - $form = $this->factory->createNamed('name', 'repeated'); - $form->addError(new FormError('[trans]Error![/trans]')); - $view = $form->createView(); - $html = $this->renderRow($view); - - // The errors of the form are not rendered by intention! - // In practice, repeated fields cannot have errors as all errors - // on them are mapped to the first child. - // (see RepeatedTypeValidatorExtension) - - $this->assertMatchesXpath($html, -'/div - [ - ./label[@for="name_first"] - /following-sibling::input[@id="name_first"] - ] -/following-sibling::div - [ - ./label[@for="name_second"] - /following-sibling::input[@id="name_second"] - ] -' - ); - } - - public function testButtonRow() - { - $form = $this->factory->createNamed('name', 'button'); - $view = $form->createView(); - $html = $this->renderRow($view); - - $this->assertMatchesXpath($html, -'/div - [ - ./button[@type="button"][@name="name"] - ] - [count(//label)=0] -' - ); - } - - public function testRest() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'repeated') - ->add('field3', 'text') - ->add('field4', 'text') - ->getForm() - ->createView(); - - // Render field2 row -> does not implicitly call renderWidget because - // it is a repeated field! - $this->renderRow($view['field2']); - - // Render field3 widget - $this->renderWidget($view['field3']); - - // Rest should only contain field1 and field4 - $html = $this->renderRest($view); - - $this->assertMatchesXpath($html, -'/div - [ - ./label[@for="name_field1"] - /following-sibling::input[@type="text"][@id="name_field1"] - ] -/following-sibling::div - [ - ./label[@for="name_field4"] - /following-sibling::input[@type="text"][@id="name_field4"] - ] - [count(../div)=2] - [count(..//label)=2] - [count(..//input)=3] -/following-sibling::input - [@type="hidden"] - [@id="name__token"] -' - ); - } - - public function testRestWithChildrenForms() - { - $child1 = $this->factory->createNamedBuilder('child1', 'form') - ->add('field1', 'text') - ->add('field2', 'text'); - - $child2 = $this->factory->createNamedBuilder('child2', 'form') - ->add('field1', 'text') - ->add('field2', 'text'); - - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add($child1) - ->add($child2) - ->getForm() - ->createView(); - - // Render child1.field1 row - $this->renderRow($view['child1']['field1']); - - // Render child2.field2 widget (remember that widget don't render label) - $this->renderWidget($view['child2']['field2']); - - // Rest should only contain child1.field2 and child2.field1 - $html = $this->renderRest($view); - - $this->assertMatchesXpath($html, -'/div - [ - ./label[not(@for)] - /following-sibling::div[@id="parent_child1"] - [ - ./div - [ - ./label[@for="parent_child1_field2"] - /following-sibling::input[@id="parent_child1_field2"] - ] - ] - ] - -/following-sibling::div - [ - ./label[not(@for)] - /following-sibling::div[@id="parent_child2"] - [ - ./div - [ - ./label[@for="parent_child2_field1"] - /following-sibling::input[@id="parent_child2_field1"] - ] - ] - ] - [count(//label)=4] - [count(//input[@type="text"])=2] -/following-sibling::input[@type="hidden"][@id="parent__token"] -' - ); - } - - public function testRestAndRepeatedWithRow() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('first', 'text') - ->add('password', 'repeated') - ->getForm() - ->createView(); - - $this->renderRow($view['password']); - - $html = $this->renderRest($view); - - $this->assertMatchesXpath($html, -'/div - [ - ./label[@for="name_first"] - /following-sibling::input[@type="text"][@id="name_first"] - ] - [count(.//input)=1] -/following-sibling::input - [@type="hidden"] - [@id="name__token"] -' - ); - } - - public function testRestAndRepeatedWithRowPerChild() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('first', 'text') - ->add('password', 'repeated') - ->getForm() - ->createView(); - - $this->renderRow($view['password']['first']); - $this->renderRow($view['password']['second']); - - $html = $this->renderRest($view); - - $this->assertMatchesXpath($html, -'/div - [ - ./label[@for="name_first"] - /following-sibling::input[@type="text"][@id="name_first"] - ] - [count(.//input)=1] - [count(.//label)=1] -/following-sibling::input - [@type="hidden"] - [@id="name__token"] -' - ); - } - - public function testRestAndRepeatedWithWidgetPerChild() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('first', 'text') - ->add('password', 'repeated') - ->getForm() - ->createView(); - - // The password form is considered as rendered as all its children - // are rendered - $this->renderWidget($view['password']['first']); - $this->renderWidget($view['password']['second']); - - $html = $this->renderRest($view); - - $this->assertMatchesXpath($html, -'/div - [ - ./label[@for="name_first"] - /following-sibling::input[@type="text"][@id="name_first"] - ] - [count(//input)=2] - [count(//label)=1] -/following-sibling::input - [@type="hidden"] - [@id="name__token"] -' - ); - } - - public function testCollection() - { - $form = $this->factory->createNamed('names', 'collection', array('a', 'b'), array( - 'type' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div[./input[@type="text"][@value="a"]] - /following-sibling::div[./input[@type="text"][@value="b"]] - ] - [count(./div[./input])=2] -' - ); - } - - // https://github.com/symfony/symfony/issues/5038 - public function testCollectionWithAlternatingRowTypes() - { - $data = array( - array('title' => 'a'), - array('title' => 'b'), - ); - $form = $this->factory->createNamed('names', 'collection', $data, array( - 'type' => new AlternatingRowType(), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div[./div/div/input[@type="text"][@value="a"]] - /following-sibling::div[./div/div/textarea[.="b"]] - ] - [count(./div[./div/div/input])=1] - [count(./div[./div/div/textarea])=1] -' - ); - } - - public function testEmptyCollection() - { - $form = $this->factory->createNamed('names', 'collection', array(), array( - 'type' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [./input[@type="hidden"][@id="names__token"]] - [count(./div)=0] -' - ); - } - - public function testCollectionRow() - { - $collection = $this->factory->createNamedBuilder( - 'collection', - 'collection', - array('a', 'b'), - array('type' => 'text') - ); - - $form = $this->factory->createNamedBuilder('form', 'form') - ->add($collection) - ->getForm(); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [ - ./label[not(@for)] - /following-sibling::div - [ - ./div - [ - ./label[@for="form_collection_0"] - /following-sibling::input[@type="text"][@value="a"] - ] - /following-sibling::div - [ - ./label[@for="form_collection_1"] - /following-sibling::input[@type="text"][@value="b"] - ] - ] - ] - /following-sibling::input[@type="hidden"][@id="form__token"] - ] - [count(.//input)=3] -' - ); - } - - public function testForm() - { - $form = $this->factory->createNamedBuilder('name', 'form') - ->setMethod('PUT') - ->setAction('http://example.com') - ->add('firstName', 'text') - ->add('lastName', 'text') - ->getForm(); - - // include ampersands everywhere to validate escaping - $html = $this->renderForm($form->createView(), array( - 'id' => 'my&id', - 'attr' => array('class' => 'my&class'), - )); - - $this->assertMatchesXpath($html, -'/form - [ - ./input[@type="hidden"][@name="_method"][@value="PUT"] - /following-sibling::div - [ - ./div - [ - ./label[@for="name_firstName"] - /following-sibling::input[@type="text"][@id="name_firstName"] - ] - /following-sibling::div - [ - ./label[@for="name_lastName"] - /following-sibling::input[@type="text"][@id="name_lastName"] - ] - /following-sibling::input[@type="hidden"][@id="name__token"] - ] - [count(.//input)=3] - [@id="my&id"] - [@class="my&class"] - ] - [@method="post"] - [@action="http://example.com"] - [@class="my&class"] -' - ); - } - - public function testFormWidget() - { - $form = $this->factory->createNamedBuilder('name', 'form') - ->add('firstName', 'text') - ->add('lastName', 'text') - ->getForm(); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [ - ./label[@for="name_firstName"] - /following-sibling::input[@type="text"][@id="name_firstName"] - ] - /following-sibling::div - [ - ./label[@for="name_lastName"] - /following-sibling::input[@type="text"][@id="name_lastName"] - ] - /following-sibling::input[@type="hidden"][@id="name__token"] - ] - [count(.//input)=3] -' - ); - } - - // https://github.com/symfony/symfony/issues/2308 - public function testNestedFormError() - { - $form = $this->factory->createNamedBuilder('name', 'form') - ->add($this->factory - ->createNamedBuilder('child', 'form', null, array('error_bubbling' => false)) - ->add('grandChild', 'form') - ) - ->getForm(); - - $form->get('child')->addError(new FormError('[trans]Error![/trans]')); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div/label - /following-sibling::ul[./li[.="[trans]Error![/trans]"]] - ] - [count(.//li[.="[trans]Error![/trans]"])=1] -' - ); - } - - public function testCsrf() - { - $this->csrfTokenManager->expects($this->any()) - ->method('getToken') - ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); - - $form = $this->factory->createNamedBuilder('name', 'form') - ->add($this->factory - // No CSRF protection on nested forms - ->createNamedBuilder('child', 'form') - ->add($this->factory->createNamedBuilder('grandchild', 'text')) - ) - ->getForm(); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - /following-sibling::input[@type="hidden"][@id="name__token"][@value="foo&bar"] - ] - [count(.//input[@type="hidden"])=1] -' - ); - } - - public function testRepeated() - { - $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( - 'type' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [ - ./label[@for="name_first"] - /following-sibling::input[@type="text"][@id="name_first"] - ] - /following-sibling::div - [ - ./label[@for="name_second"] - /following-sibling::input[@type="text"][@id="name_second"] - ] - /following-sibling::input[@type="hidden"][@id="name__token"] - ] - [count(.//input)=3] -' - ); - } - - public function testRepeatedWithCustomOptions() - { - $form = $this->factory->createNamed('name', 'repeated', null, array( - // the global required value cannot be overridden - 'first_options' => array('label' => 'Test', 'required' => false), - 'second_options' => array('label' => 'Test2'), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [ - ./label[@for="name_first"][.="[trans]Test[/trans]"] - /following-sibling::input[@type="text"][@id="name_first"][@required="required"] - ] - /following-sibling::div - [ - ./label[@for="name_second"][.="[trans]Test2[/trans]"] - /following-sibling::input[@type="text"][@id="name_second"][@required="required"] - ] - /following-sibling::input[@type="hidden"][@id="name__token"] - ] - [count(.//input)=3] -' - ); - } - - public function testSearchInputName() - { - $form = $this->factory->createNamedBuilder('full', 'form') - ->add('name', 'search') - ->getForm(); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [ - ./label[@for="full_name"] - /following-sibling::input[@type="search"][@id="full_name"][@name="full[name]"] - ] - /following-sibling::input[@type="hidden"][@id="full__token"] - ] - [count(//input)=2] -' - ); - } - - public function testLabelHasNoId() - { - $form = $this->factory->createNamed('name', 'text'); - $html = $this->renderRow($form->createView()); - - $this->assertMatchesXpath($html, -'/div - [ - ./label[@for="name"][not(@id)] - /following-sibling::input[@id="name"] - ] -' - ); - } - - public function testLabelIsNotRenderedWhenSetToFalse() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'label' => false, - )); - $html = $this->renderRow($form->createView()); - - $this->assertMatchesXpath($html, -'/div - [ - ./input[@id="name"] - ] - [count(//label)=0] -' - ); - } - - /** - * @dataProvider themeBlockInheritanceProvider - */ - public function testThemeBlockInheritance($theme) - { - $view = $this->factory - ->createNamed('name', 'email') - ->createView() - ; - - $this->setTheme($view, $theme); - - $this->assertMatchesXpath( - $this->renderWidget($view), - '/input[@type="email"][@rel="theme"]' - ); - } - - /** - * @dataProvider themeInheritanceProvider - */ - public function testThemeInheritance($parentTheme, $childTheme) - { - $child = $this->factory->createNamedBuilder('child', 'form') - ->add('field', 'text'); - - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('field', 'text') - ->add($child) - ->getForm() - ->createView() - ; - - $this->setTheme($view, $parentTheme); - $this->setTheme($view['child'], $childTheme); - - $this->assertWidgetMatchesXpath($view, array(), -'/div - [ - ./div - [ - ./label[.="parent"] - /following-sibling::input[@type="text"] - ] - /following-sibling::div - [ - ./label[.="child"] - /following-sibling::div - [ - ./div - [ - ./label[.="child"] - /following-sibling::input[@type="text"] - ] - ] - ] - /following-sibling::input[@type="hidden"] - ] -' - ); - } - - /** - * The block "_name_child_label" should be overridden in the theme of the - * implemented driver. - */ - public function testCollectionRowWithCustomBlock() - { - $collection = array('one', 'two', 'three'); - $form = $this->factory->createNamedBuilder('names', 'collection', $collection) - ->getForm(); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div[./label[.="Custom label: [trans]0[/trans]"]] - /following-sibling::div[./label[.="Custom label: [trans]1[/trans]"]] - /following-sibling::div[./label[.="Custom label: [trans]2[/trans]"]] - ] -' - ); - } - - /** - * The block "_name_c_entry_label" should be overridden in the theme of the - * implemented driver. - */ - public function testChoiceRowWithCustomBlock() - { - $form = $this->factory->createNamedBuilder('name_c', 'choice', 'a', array( - 'choices' => array('a' => 'ChoiceA', 'b' => 'ChoiceB'), - 'expanded' => true, - )) - ->getForm(); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./label[.="Custom name label: [trans]ChoiceA[/trans]"] - /following-sibling::label[.="Custom name label: [trans]ChoiceB[/trans]"] - ] -' - ); - } - - public function testFormEndWithRest() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'text') - ->getForm() - ->createView(); - - $this->renderWidget($view['field1']); - - // Rest should only contain field2 - $html = $this->renderEnd($view); - - // Insert the start tag, the end tag should be rendered by the helper - $this->assertMatchesXpath('
'.$html, -'/form - [ - ./div - [ - ./label[@for="name_field2"] - /following-sibling::input[@type="text"][@id="name_field2"] - ] - /following-sibling::input - [@type="hidden"] - [@id="name__token"] - ] -' - ); - } - - public function testFormEndWithoutRest() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'text') - ->getForm() - ->createView(); - - $this->renderWidget($view['field1']); - - // Rest should only contain field2, but isn't rendered - $html = $this->renderEnd($view, array('render_rest' => false)); - - $this->assertEquals('', $html); - } - - public function testWidgetContainerAttributes() - { - $form = $this->factory->createNamed('form', 'form', null, array( - 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), - )); - - $form->add('text', 'text'); - - $html = $this->renderWidget($form->createView()); - - // compare plain HTML to check the whitespace - $this->assertContains('
', $html); - } - - public function testWidgetContainerAttributeNameRepeatedIfTrue() - { - $form = $this->factory->createNamed('form', 'form', null, array( - 'attr' => array('foo' => true), - )); - - $html = $this->renderWidget($form->createView()); - - // foo="foo" - $this->assertContains('
', $html); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractExtensionTest.php deleted file mode 100644 index c16cb2212..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractExtensionTest.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\AbstractExtension; -use Symfony\Component\Form\Tests\Fixtures\FooType; - -class AbstractExtensionTest extends \PHPUnit_Framework_TestCase -{ - public function testHasType() - { - $loader = new ConcreteExtension(); - $this->assertTrue($loader->hasType('foo')); - $this->assertFalse($loader->hasType('bar')); - } - - public function testGetType() - { - $loader = new ConcreteExtension(); - $this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('foo')); - } -} - -class ConcreteExtension extends AbstractExtension -{ - protected function loadTypes() - { - return array(new FooType()); - } - - protected function loadTypeGuesser() - { - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php deleted file mode 100644 index dc590c918..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractFormTest.php +++ /dev/null @@ -1,112 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; - -abstract class AbstractFormTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var EventDispatcherInterface - */ - protected $dispatcher; - - /** - * @var \Symfony\Component\Form\FormFactoryInterface - */ - protected $factory; - - /** - * @var \Symfony\Component\Form\FormInterface - */ - protected $form; - - protected function setUp() - { - // We need an actual dispatcher to use the deprecated - // bindRequest() method - $this->dispatcher = new EventDispatcher(); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->form = $this->createForm(); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->factory = null; - $this->form = null; - } - - /** - * @return \Symfony\Component\Form\FormInterface - */ - abstract protected function createForm(); - - /** - * @param string $name - * @param EventDispatcherInterface $dispatcher - * @param string $dataClass - * @param array $options - * - * @return FormBuilder - */ - protected function getBuilder($name = 'name', EventDispatcherInterface $dispatcher = null, $dataClass = null, array $options = array()) - { - return new FormBuilder($name, $dataClass, $dispatcher ?: $this->dispatcher, $this->factory, $options); - } - - /** - * @param string $name - * - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function getMockForm($name = 'name') - { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $config = $this->getMock('Symfony\Component\Form\FormConfigInterface'); - - $form->expects($this->any()) - ->method('getName') - ->will($this->returnValue($name)); - $form->expects($this->any()) - ->method('getConfig') - ->will($this->returnValue($config)); - - return $form; - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function getDataMapper() - { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function getDataTransformer() - { - return $this->getMock('Symfony\Component\Form\DataTransformerInterface'); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - protected function getFormValidator() - { - return $this->getMock('Symfony\Component\Form\FormValidatorInterface'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractLayoutTest.php deleted file mode 100644 index 6375542b2..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ /dev/null @@ -1,2136 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Extension\Csrf\CsrfExtension; - -abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormIntegrationTestCase -{ - protected $csrfTokenManager; - - protected function setUp() - { - if (!extension_loaded('intl')) { - $this->markTestSkipped('The "intl" extension is not available'); - } - - \Locale::setDefault('en'); - - $this->csrfTokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); - - parent::setUp(); - } - - protected function getExtensions() - { - return array( - new CsrfExtension($this->csrfTokenManager), - ); - } - - protected function tearDown() - { - $this->csrfTokenManager = null; - - parent::tearDown(); - } - - protected function assertXpathNodeValue(\DomElement $element, $expression, $nodeValue) - { - $xpath = new \DOMXPath($element->ownerDocument); - $nodeList = $xpath->evaluate($expression); - $this->assertEquals(1, $nodeList->length); - $this->assertEquals($nodeValue, $nodeList->item(0)->nodeValue); - } - - protected function assertMatchesXpath($html, $expression, $count = 1) - { - $dom = new \DomDocument('UTF-8'); - try { - // Wrap in node so we can load HTML with multiple tags at - // the top level - $dom->loadXml(''.$html.''); - } catch (\Exception $e) { - $this->fail(sprintf( - "Failed loading HTML:\n\n%s\n\nError: %s", - $html, - $e->getMessage() - )); - } - $xpath = new \DOMXPath($dom); - $nodeList = $xpath->evaluate('/root'.$expression); - - if ($nodeList->length != $count) { - $dom->formatOutput = true; - $this->fail(sprintf( - "Failed asserting that \n\n%s\n\nmatches exactly %s. Matches %s in \n\n%s", - $expression, - $count == 1 ? 'once' : $count.' times', - $nodeList->length == 1 ? 'once' : $nodeList->length.' times', - // strip away and - substr($dom->saveHTML(), 6, -8) - )); - } - } - - protected function assertWidgetMatchesXpath(FormView $view, array $vars, $xpath) - { - // include ampersands everywhere to validate escaping - $html = $this->renderWidget($view, array_merge(array( - 'id' => 'my&id', - 'attr' => array('class' => 'my&class'), - ), $vars)); - - if (!isset($vars['id'])) { - $xpath = trim($xpath).' - [@id="my&id"]'; - } - - if (!isset($vars['attr']['class'])) { - $xpath .= ' - [@class="my&class"]'; - } - - $this->assertMatchesXpath($html, $xpath); - } - - abstract protected function renderForm(FormView $view, array $vars = array()); - - protected function renderEnctype(FormView $view) - { - $this->markTestSkipped(sprintf('Legacy %s::renderEnctype() is not implemented.', get_class($this))); - } - - abstract protected function renderLabel(FormView $view, $label = null, array $vars = array()); - - abstract protected function renderErrors(FormView $view); - - abstract protected function renderWidget(FormView $view, array $vars = array()); - - abstract protected function renderRow(FormView $view, array $vars = array()); - - abstract protected function renderRest(FormView $view, array $vars = array()); - - abstract protected function renderStart(FormView $view, array $vars = array()); - - abstract protected function renderEnd(FormView $view, array $vars = array()); - - abstract protected function setTheme(FormView $view, array $themes); - - /** - * @group legacy - */ - public function testLegacyEnctype() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $form = $this->factory->createNamedBuilder('name', 'form') - ->add('file', 'file') - ->getForm(); - - $this->assertEquals('enctype="multipart/form-data"', $this->renderEnctype($form->createView())); - } - - /** - * @group legacy - */ - public function testLegacyNoEnctype() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $form = $this->factory->createNamedBuilder('name', 'form') - ->add('text', 'text') - ->getForm(); - - $this->assertEquals('', $this->renderEnctype($form->createView())); - } - - public function testLabel() - { - $form = $this->factory->createNamed('name', 'text'); - $view = $form->createView(); - $this->renderWidget($view, array('label' => 'foo')); - $html = $this->renderLabel($view); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [.="[trans]Name[/trans]"] -' - ); - } - - public function testLabelOnForm() - { - $form = $this->factory->createNamed('name', 'date'); - $view = $form->createView(); - $this->renderWidget($view, array('label' => 'foo')); - $html = $this->renderLabel($view); - - $this->assertMatchesXpath($html, -'/label - [@class="required"] - [.="[trans]Name[/trans]"] -' - ); - } - - public function testLabelWithCustomTextPassedAsOption() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'label' => 'Custom label', - )); - $html = $this->renderLabel($form->createView()); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [.="[trans]Custom label[/trans]"] -' - ); - } - - public function testLabelWithCustomTextPassedDirectly() - { - $form = $this->factory->createNamed('name', 'text'); - $html = $this->renderLabel($form->createView(), 'Custom label'); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [.="[trans]Custom label[/trans]"] -' - ); - } - - public function testLabelWithCustomTextPassedAsOptionAndDirectly() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'label' => 'Custom label', - )); - $html = $this->renderLabel($form->createView(), 'Overridden label'); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [.="[trans]Overridden label[/trans]"] -' - ); - } - - public function testLabelDoesNotRenderFieldAttributes() - { - $form = $this->factory->createNamed('name', 'text'); - $html = $this->renderLabel($form->createView(), null, array( - 'attr' => array( - 'class' => 'my&class', - ), - )); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [@class="required"] -' - ); - } - - public function testLabelWithCustomAttributesPassedDirectly() - { - $form = $this->factory->createNamed('name', 'text'); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( - 'class' => 'my&class', - ), - )); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [@class="my&class required"] -' - ); - } - - public function testLabelWithCustomTextAndCustomAttributesPassedDirectly() - { - $form = $this->factory->createNamed('name', 'text'); - $html = $this->renderLabel($form->createView(), 'Custom label', array( - 'label_attr' => array( - 'class' => 'my&class', - ), - )); - - $this->assertMatchesXpath($html, -'/label - [@for="name"] - [@class="my&class required"] - [.="[trans]Custom label[/trans]"] -' - ); - } - - // https://github.com/symfony/symfony/issues/5029 - public function testLabelWithCustomTextAsOptionAndCustomAttributesPassedDirectly() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'label' => 'Custom label', - )); - $html = $this->renderLabel($form->createView(), null, array( - 'label_attr' => array( - 'class' => 'my&class', - ), - )); - - $this->assertMatchesXpath($html, - '/label - [@for="name"] - [@class="my&class required"] - [.="[trans]Custom label[/trans]"] -' - ); - } - - public function testLabelFormatName() - { - $form = $this->factory->createNamedBuilder('myform') - ->add('myfield', 'text') - ->getForm(); - $view = $form->get('myfield')->createView(); - $html = $this->renderLabel($view, null, array('label_format' => 'form.%name%')); - - $this->assertMatchesXpath($html, -'/label - [@for="myform_myfield"] - [.="[trans]form.myfield[/trans]"] -' - ); - } - - public function testLabelFormatId() - { - $form = $this->factory->createNamedBuilder('myform') - ->add('myfield', 'text') - ->getForm(); - $view = $form->get('myfield')->createView(); - $html = $this->renderLabel($view, null, array('label_format' => 'form.%id%')); - - $this->assertMatchesXpath($html, -'/label - [@for="myform_myfield"] - [.="[trans]form.myform_myfield[/trans]"] -' - ); - } - - public function testLabelFormatAsFormOption() - { - $options = array('label_format' => 'form.%name%'); - - $form = $this->factory->createNamedBuilder('myform', 'form', null, $options) - ->add('myfield', 'text') - ->getForm(); - $view = $form->get('myfield')->createView(); - $html = $this->renderLabel($view); - - $this->assertMatchesXpath($html, -'/label - [@for="myform_myfield"] - [.="[trans]form.myfield[/trans]"] -' - ); - } - - public function testLabelFormatOverriddenOption() - { - $options = array('label_format' => 'form.%name%'); - - $form = $this->factory->createNamedBuilder('myform', 'form', null, $options) - ->add('myfield', 'text', array('label_format' => 'field.%name%')) - ->getForm(); - $view = $form->get('myfield')->createView(); - $html = $this->renderLabel($view); - - $this->assertMatchesXpath($html, -'/label - [@for="myform_myfield"] - [.="[trans]field.myfield[/trans]"] -' - ); - } - - public function testLabelFormatOnButton() - { - $form = $this->factory->createNamedBuilder('myform') - ->add('mybutton', 'button') - ->getForm(); - $view = $form->get('mybutton')->createView(); - $html = $this->renderWidget($view, array('label_format' => 'form.%name%')); - - $this->assertMatchesXpath($html, -'/button - [@type="button"] - [@name="myform[mybutton]"] - [.="[trans]form.mybutton[/trans]"] -' - ); - } - - public function testLabelFormatOnButtonId() - { - $form = $this->factory->createNamedBuilder('myform') - ->add('mybutton', 'button') - ->getForm(); - $view = $form->get('mybutton')->createView(); - $html = $this->renderWidget($view, array('label_format' => 'form.%id%')); - - $this->assertMatchesXpath($html, -'/button - [@type="button"] - [@name="myform[mybutton]"] - [.="[trans]form.myform_mybutton[/trans]"] -' - ); - } - - public function testErrors() - { - $form = $this->factory->createNamed('name', 'text'); - $form->addError(new FormError('[trans]Error 1[/trans]')); - $form->addError(new FormError('[trans]Error 2[/trans]')); - $view = $form->createView(); - $html = $this->renderErrors($view); - - $this->assertMatchesXpath($html, -'/ul - [ - ./li[.="[trans]Error 1[/trans]"] - /following-sibling::li[.="[trans]Error 2[/trans]"] - ] - [count(./li)=2] -' - ); - } - - public function testOverrideWidgetBlock() - { - // see custom_widgets.html.twig - $form = $this->factory->createNamed('text_id', 'text'); - $html = $this->renderWidget($form->createView()); - - $this->assertMatchesXpath($html, -'/div - [ - ./input - [@type="text"] - [@id="text_id"] - ] - [@id="container"] -' - ); - } - - public function testCheckedCheckbox() - { - $form = $this->factory->createNamed('name', 'checkbox', true); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="checkbox"] - [@name="name"] - [@checked="checked"] - [@value="1"] -' - ); - } - - public function testUncheckedCheckbox() - { - $form = $this->factory->createNamed('name', 'checkbox', false); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="checkbox"] - [@name="name"] - [not(@checked)] -' - ); - } - - public function testCheckboxWithValue() - { - $form = $this->factory->createNamed('name', 'checkbox', false, array( - 'value' => 'foo&bar', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="checkbox"] - [@name="name"] - [@value="foo&bar"] -' - ); - } - - public function testSingleChoice() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => false, - 'expanded' => false, - )); - - // If the field is collapsed, has no "multiple" attribute, is required but - // has *no* empty value, the "required" must not be added, otherwise - // the resulting HTML is invalid. - // https://github.com/symfony/symfony/issues/8942 - - // HTML 5 spec - // http://www.w3.org/html/wg/drafts/html/master/forms.html#placeholder-label-option - - // "If a select element has a required attribute specified, does not - // have a multiple attribute specified, and has a display size of 1, - // then the select element must have a placeholder label option." - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [not(@required)] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testSingleChoiceWithPreferred() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'preferred_choices' => array('&b'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => '-- sep --'), -'/select - [@name="name"] - [not(@required)] - [ - ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - /following-sibling::option[@disabled="disabled"][not(@selected)][.="-- sep --"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceWithPreferredAndNoSeparator() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'preferred_choices' => array('&b'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => null), -'/select - [@name="name"] - [not(@required)] - [ - ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testSingleChoiceWithPreferredAndBlankSeparator() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'preferred_choices' => array('&b'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array('separator' => ''), -'/select - [@name="name"] - [not(@required)] - [ - ./option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - /following-sibling::option[@disabled="disabled"][not(@selected)][.=""] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testChoiceWithOnlyPreferred() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'preferred_choices' => array('&a', '&b'), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [count(./option)=2] -' - ); - } - - public function testSingleChoiceNonRequired() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => false, - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [not(@required)] - [ - ./option[@value=""][.="[trans][/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceNonRequiredNoneSelected() - { - $form = $this->factory->createNamed('name', 'choice', null, array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => false, - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [not(@required)] - [ - ./option[@value=""][.="[trans][/trans]"] - /following-sibling::option[@value="&a"][not(@selected)][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceNonRequiredWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => false, - 'expanded' => false, - 'required' => false, - 'placeholder' => 'Select&Anything&Not&Me', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [not(@required)] - [ - ./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Anything&Not&Me[/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceRequiredWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => true, - 'multiple' => false, - 'expanded' => false, - 'placeholder' => 'Test&Me', - )); - - // The "disabled" attribute was removed again due to a bug in the - // BlackBerry 10 browser. - // See https://github.com/symfony/symfony/pull/7678 - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [@required="required"] - [ - ./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Test&Me[/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceRequiredWithPlaceholderViaView() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => true, - 'multiple' => false, - 'expanded' => false, - )); - - // The "disabled" attribute was removed again due to a bug in the - // BlackBerry 10 browser. - // See https://github.com/symfony/symfony/pull/7678 - $this->assertWidgetMatchesXpath($form->createView(), array('placeholder' => ''), -'/select - [@name="name"] - [@required="required"] - [ - ./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"] - /following-sibling::option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=3] -' - ); - } - - public function testSingleChoiceGrouped() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array( - 'Group&1' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'Group&2' => array('&c' => 'Choice&C'), - ), - 'multiple' => false, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [./optgroup[@label="[trans]Group&1[/trans]"] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] - ] - [./optgroup[@label="[trans]Group&2[/trans]"] - [./option[@value="&c"][not(@selected)][.="[trans]Choice&C[/trans]"]] - [count(./option)=1] - ] - [count(./optgroup)=2] -' - ); - } - - public function testMultipleChoice() - { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => true, - 'multiple' => true, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name[]"] - [@required="required"] - [@multiple="multiple"] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testMultipleChoiceSkipsPlaceholder() - { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => true, - 'expanded' => false, - 'placeholder' => 'Test&Me', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name[]"] - [@multiple="multiple"] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testMultipleChoiceNonRequired() - { - $form = $this->factory->createNamed('name', 'choice', array('&a'), array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'required' => false, - 'multiple' => true, - 'expanded' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name[]"] - [@multiple="multiple"] - [ - ./option[@value="&a"][@selected="selected"][.="[trans]Choice&A[/trans]"] - /following-sibling::option[@value="&b"][not(@selected)][.="[trans]Choice&B[/trans]"] - ] - [count(./option)=2] -' - ); - } - - public function testSingleChoiceExpanded() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => false, - 'expanded' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked] - /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] - /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)] - /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] - /following-sibling::input[@type="hidden"][@id="name__token"] - ] - [count(./input)=3] -' - ); - } - - public function testSingleChoiceExpandedWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'choice', '&a', array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B'), - 'multiple' => false, - 'expanded' => true, - 'placeholder' => 'Test&Me', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./input[@type="radio"][@name="name"][@id="name_placeholder"][not(@checked)] - /following-sibling::label[@for="name_placeholder"][.="[trans]Test&Me[/trans]"] - /following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked] - /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] - /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)] - /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] - /following-sibling::input[@type="hidden"][@id="name__token"] - ] - [count(./input)=4] -' - ); - } - - public function testSingleChoiceExpandedWithBooleanValue() - { - $form = $this->factory->createNamed('name', 'choice', true, array( - 'choices' => array('1' => 'Choice&A', '0' => 'Choice&B'), - 'multiple' => false, - 'expanded' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./input[@type="radio"][@name="name"][@id="name_0"][@checked] - /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] - /following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)] - /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] - /following-sibling::input[@type="hidden"][@id="name__token"] - ] - [count(./input)=3] -' - ); - } - - public function testMultipleChoiceExpanded() - { - $form = $this->factory->createNamed('name', 'choice', array('&a', '&c'), array( - 'choices' => array('&a' => 'Choice&A', '&b' => 'Choice&B', '&c' => 'Choice&C'), - 'multiple' => true, - 'expanded' => true, - 'required' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)] - /following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"] - /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)] - /following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"] - /following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)] - /following-sibling::label[@for="name_2"][.="[trans]Choice&C[/trans]"] - /following-sibling::input[@type="hidden"][@id="name__token"] - ] - [count(./input)=4] -' - ); - } - - public function testCountry() - { - $form = $this->factory->createNamed('name', 'country', 'AT'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]] - [count(./option)>200] -' - ); - } - - public function testCountryWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'country', 'AT', array( - 'placeholder' => 'Select&Country', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Country[/trans]"]] - [./option[@value="AT"][@selected="selected"][.="[trans]Austria[/trans]"]] - [count(./option)>201] -' - ); - } - - public function testDateTime() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'with_seconds' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [@id="name_date"] - [ - ./select - [@id="name_date_month"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_date_day"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] - ] - /following-sibling::div - [@id="name_time"] - [ - ./select - [@id="name_time_hour"] - [./option[@value="4"][@selected="selected"]] - /following-sibling::select - [@id="name_time_minute"] - [./option[@value="5"][@selected="selected"]] - ] - ] - [count(.//select)=5] -' - ); - } - - public function testDateTimeWithPlaceholderGlobal() - { - $form = $this->factory->createNamed('name', 'datetime', null, array( - 'input' => 'string', - 'placeholder' => 'Change&Me', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [@id="name_date"] - [ - ./select - [@id="name_date_month"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_date_day"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_date_year"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - ] - /following-sibling::div - [@id="name_time"] - [ - ./select - [@id="name_time_hour"] - [./option[@value=""][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_time_minute"] - [./option[@value=""][.="[trans]Change&Me[/trans]"]] - ] - ] - [count(.//select)=5] -' - ); - } - - public function testDateTimeWithHourAndMinute() - { - $data = array('year' => '2011', 'month' => '2', 'day' => '3', 'hour' => '4', 'minute' => '5'); - - $form = $this->factory->createNamed('name', 'datetime', $data, array( - 'input' => 'array', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [@id="name_date"] - [ - ./select - [@id="name_date_month"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_date_day"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] - ] - /following-sibling::div - [@id="name_time"] - [ - ./select - [@id="name_time_hour"] - [./option[@value="4"][@selected="selected"]] - /following-sibling::select - [@id="name_time_minute"] - [./option[@value="5"][@selected="selected"]] - ] - ] - [count(.//select)=5] -' - ); - } - - public function testDateTimeWithSeconds() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'with_seconds' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./div - [@id="name_date"] - [ - ./select - [@id="name_date_month"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_date_day"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_date_year"] - [./option[@value="2011"][@selected="selected"]] - ] - /following-sibling::div - [@id="name_time"] - [ - ./select - [@id="name_time_hour"] - [./option[@value="4"][@selected="selected"]] - /following-sibling::select - [@id="name_time_minute"] - [./option[@value="5"][@selected="selected"]] - /following-sibling::select - [@id="name_time_second"] - [./option[@value="6"][@selected="selected"]] - ] - ] - [count(.//select)=6] -' - ); - } - - public function testDateTimeSingleText() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'date_widget' => 'single_text', - 'time_widget' => 'single_text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./input - [@type="date"] - [@id="name_date"] - [@name="name[date]"] - [@value="2011-02-03"] - /following-sibling::input - [@type="time"] - [@id="name_time"] - [@name="name[time]"] - [@value="04:05"] - ] -' - ); - } - - public function testDateTimeWithWidgetSingleText() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'widget' => 'single_text', - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="datetime"] - [@name="name"] - [@value="2011-02-03T04:05:06Z"] -' - ); - } - - public function testDateTimeWithWidgetSingleTextIgnoreDateAndTimeWidgets() - { - $form = $this->factory->createNamed('name', 'datetime', '2011-02-03 04:05:06', array( - 'input' => 'string', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - 'widget' => 'single_text', - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="datetime"] - [@name="name"] - [@value="2011-02-03T04:05:06Z"] -' - ); - } - - public function testDateChoice() - { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( - 'input' => 'string', - 'widget' => 'choice', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_month"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_day"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_year"] - [./option[@value="2011"][@selected="selected"]] - ] - [count(./select)=3] -' - ); - } - - public function testDateChoiceWithPlaceholderGlobal() - { - $form = $this->factory->createNamed('name', 'date', null, array( - 'input' => 'string', - 'widget' => 'choice', - 'placeholder' => 'Change&Me', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_month"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_day"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - /following-sibling::select - [@id="name_year"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - ] - [count(./select)=3] -' - ); - } - - public function testDateChoiceWithPlaceholderOnYear() - { - $form = $this->factory->createNamed('name', 'date', null, array( - 'input' => 'string', - 'widget' => 'choice', - 'required' => false, - 'placeholder' => array('year' => 'Change&Me'), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_month"] - [./option[@value="1"]] - /following-sibling::select - [@id="name_day"] - [./option[@value="1"]] - /following-sibling::select - [@id="name_year"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - ] - [count(./select)=3] -' - ); - } - - public function testDateText() - { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( - 'input' => 'string', - 'widget' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./input - [@id="name_month"] - [@type="text"] - [@value="2"] - /following-sibling::input - [@id="name_day"] - [@type="text"] - [@value="3"] - /following-sibling::input - [@id="name_year"] - [@type="text"] - [@value="2011"] - ] - [count(./input)=3] -' - ); - } - - public function testDateSingleText() - { - $form = $this->factory->createNamed('name', 'date', '2011-02-03', array( - 'input' => 'string', - 'widget' => 'single_text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="date"] - [@name="name"] - [@value="2011-02-03"] -' - ); - } - - public function testDateErrorBubbling() - { - $form = $this->factory->createNamedBuilder('form', 'form') - ->add('date', 'date') - ->getForm(); - $form->get('date')->addError(new FormError('[trans]Error![/trans]')); - $view = $form->createView(); - - $this->assertEmpty($this->renderErrors($view)); - $this->assertNotEmpty($this->renderErrors($view['date'])); - } - - public function testBirthDay() - { - $form = $this->factory->createNamed('name', 'birthday', '2000-02-03', array( - 'input' => 'string', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_month"] - [./option[@value="2"][@selected="selected"]] - /following-sibling::select - [@id="name_day"] - [./option[@value="3"][@selected="selected"]] - /following-sibling::select - [@id="name_year"] - [./option[@value="2000"][@selected="selected"]] - ] - [count(./select)=3] -' - ); - } - - public function testBirthDayWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'birthday', '1950-01-01', array( - 'input' => 'string', - 'placeholder' => '', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_month"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] - [./option[@value="1"][@selected="selected"]] - /following-sibling::select - [@id="name_day"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] - [./option[@value="1"][@selected="selected"]] - /following-sibling::select - [@id="name_year"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans][/trans]"]] - [./option[@value="1950"][@selected="selected"]] - ] - [count(./select)=3] -' - ); - } - - public function testEmail() - { - $form = $this->factory->createNamed('name', 'email', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="email"] - [@name="name"] - [@value="foo&bar"] - [not(@maxlength)] -' - ); - } - - public function testEmailWithMaxLength() - { - $form = $this->factory->createNamed('name', 'email', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="email"] - [@name="name"] - [@value="foo&bar"] - [@maxlength="123"] -' - ); - } - - public function testFile() - { - $form = $this->factory->createNamed('name', 'file'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="file"] -' - ); - } - - public function testHidden() - { - $form = $this->factory->createNamed('name', 'hidden', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="hidden"] - [@name="name"] - [@value="foo&bar"] -' - ); - } - - public function testReadOnly() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'read_only' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="text"] - [@name="name"] - [@readonly="readonly"] -' - ); - } - - public function testDisabled() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'disabled' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="text"] - [@name="name"] - [@disabled="disabled"] -' - ); - } - - public function testInteger() - { - $form = $this->factory->createNamed('name', 'integer', 123); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="number"] - [@name="name"] - [@value="123"] -' - ); - } - - public function testLanguage() - { - $form = $this->factory->createNamed('name', 'language', 'de'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [./option[@value="de"][@selected="selected"][.="[trans]German[/trans]"]] - [count(./option)>200] -' - ); - } - - public function testLocale() - { - $form = $this->factory->createNamed('name', 'locale', 'de_AT'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [./option[@value="de_AT"][@selected="selected"][.="[trans]German (Austria)[/trans]"]] - [count(./option)>200] -' - ); - } - - public function testMoney() - { - $form = $this->factory->createNamed('name', 'money', 1234.56, array( - 'currency' => 'EUR', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="text"] - [@name="name"] - [@value="1234.56"] - [contains(.., "€")] -' - ); - } - - public function testNumber() - { - $form = $this->factory->createNamed('name', 'number', 1234.56); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="text"] - [@name="name"] - [@value="1234.56"] -' - ); - } - - public function testPassword() - { - $form = $this->factory->createNamed('name', 'password', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="password"] - [@name="name"] -' - ); - } - - public function testPasswordSubmittedWithNotAlwaysEmpty() - { - $form = $this->factory->createNamed('name', 'password', null, array( - 'always_empty' => false, - )); - $form->submit('foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="password"] - [@name="name"] - [@value="foo&bar"] -' - ); - } - - public function testPasswordWithMaxLength() - { - $form = $this->factory->createNamed('name', 'password', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="password"] - [@name="name"] - [@maxlength="123"] -' - ); - } - - public function testPercent() - { - $form = $this->factory->createNamed('name', 'percent', 0.1); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="text"] - [@name="name"] - [@value="10"] - [contains(.., "%")] -' - ); - } - - public function testCheckedRadio() - { - $form = $this->factory->createNamed('name', 'radio', true); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="radio"] - [@name="name"] - [@checked="checked"] - [@value="1"] -' - ); - } - - public function testUncheckedRadio() - { - $form = $this->factory->createNamed('name', 'radio', false); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="radio"] - [@name="name"] - [not(@checked)] -' - ); - } - - public function testRadioWithValue() - { - $form = $this->factory->createNamed('name', 'radio', false, array( - 'value' => 'foo&bar', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="radio"] - [@name="name"] - [@value="foo&bar"] -' - ); - } - - public function testTextarea() - { - $form = $this->factory->createNamed('name', 'textarea', 'foo&bar', array( - 'attr' => array('pattern' => 'foo'), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/textarea - [@name="name"] - [@pattern="foo"] - [.="foo&bar"] -' - ); - } - - public function testText() - { - $form = $this->factory->createNamed('name', 'text', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="text"] - [@name="name"] - [@value="foo&bar"] - [not(@maxlength)] -' - ); - } - - public function testTextWithMaxLength() - { - $form = $this->factory->createNamed('name', 'text', 'foo&bar', array( - 'attr' => array('maxlength' => 123), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="text"] - [@name="name"] - [@value="foo&bar"] - [@maxlength="123"] -' - ); - } - - public function testSearch() - { - $form = $this->factory->createNamed('name', 'search', 'foo&bar'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="search"] - [@name="name"] - [@value="foo&bar"] - [not(@maxlength)] -' - ); - } - - public function testTime() - { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( - 'input' => 'string', - 'with_seconds' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_hour"] - [not(@size)] - [./option[@value="4"][@selected="selected"]] - /following-sibling::select - [@id="name_minute"] - [not(@size)] - [./option[@value="5"][@selected="selected"]] - ] - [count(./select)=2] -' - ); - } - - public function testTimeWithSeconds() - { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( - 'input' => 'string', - 'with_seconds' => true, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_hour"] - [not(@size)] - [./option[@value="4"][@selected="selected"]] - [count(./option)>23] - /following-sibling::select - [@id="name_minute"] - [not(@size)] - [./option[@value="5"][@selected="selected"]] - [count(./option)>59] - /following-sibling::select - [@id="name_second"] - [not(@size)] - [./option[@value="6"][@selected="selected"]] - [count(./option)>59] - ] - [count(./select)=3] -' - ); - } - - public function testTimeText() - { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( - 'input' => 'string', - 'widget' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./input - [@type="text"] - [@id="name_hour"] - [@name="name[hour]"] - [@value="04"] - [@size="1"] - [@required="required"] - /following-sibling::input - [@type="text"] - [@id="name_minute"] - [@name="name[minute]"] - [@value="05"] - [@size="1"] - [@required="required"] - ] - [count(./input)=2] -' - ); - } - - public function testTimeSingleText() - { - $form = $this->factory->createNamed('name', 'time', '04:05:06', array( - 'input' => 'string', - 'widget' => 'single_text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="time"] - [@name="name"] - [@value="04:05"] - [not(@size)] -' - ); - } - - public function testTimeWithPlaceholderGlobal() - { - $form = $this->factory->createNamed('name', 'time', null, array( - 'input' => 'string', - 'placeholder' => 'Change&Me', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_hour"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - [count(./option)>24] - /following-sibling::select - [@id="name_minute"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - [count(./option)>60] - ] - [count(./select)=2] -' - ); - } - - public function testTimeWithPlaceholderOnYear() - { - $form = $this->factory->createNamed('name', 'time', null, array( - 'input' => 'string', - 'required' => false, - 'placeholder' => array('hour' => 'Change&Me'), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/div - [ - ./select - [@id="name_hour"] - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Change&Me[/trans]"]] - [count(./option)>24] - /following-sibling::select - [@id="name_minute"] - [./option[@value="1"]] - [count(./option)>59] - ] - [count(./select)=2] -' - ); - } - - public function testTimeErrorBubbling() - { - $form = $this->factory->createNamedBuilder('form', 'form') - ->add('time', 'time') - ->getForm(); - $form->get('time')->addError(new FormError('[trans]Error![/trans]')); - $view = $form->createView(); - - $this->assertEmpty($this->renderErrors($view)); - $this->assertNotEmpty($this->renderErrors($view['time'])); - } - - public function testTimezone() - { - $form = $this->factory->createNamed('name', 'timezone', 'Europe/Vienna'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [@name="name"] - [not(@required)] - [./optgroup - [@label="[trans]Europe[/trans]"] - [./option[@value="Europe/Vienna"][@selected="selected"][.="[trans]Vienna[/trans]"]] - ] - [count(./optgroup)>10] - [count(.//option)>200] -' - ); - } - - public function testTimezoneWithPlaceholder() - { - $form = $this->factory->createNamed('name', 'timezone', null, array( - 'placeholder' => 'Select&Timezone', - 'required' => false, - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/select - [./option[@value=""][not(@selected)][not(@disabled)][.="[trans]Select&Timezone[/trans]"]] - [count(./optgroup)>10] - [count(.//option)>201] -' - ); - } - - public function testUrl() - { - $url = 'http://www.google.com?foo1=bar1&foo2=bar2'; - $form = $this->factory->createNamed('name', 'url', $url); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/input - [@type="url"] - [@name="name"] - [@value="http://www.google.com?foo1=bar1&foo2=bar2"] -' - ); - } - - public function testCollectionPrototype() - { - $form = $this->factory->createNamedBuilder('name', 'form', array('items' => array('one', 'two', 'three'))) - ->add('items', 'collection', array('allow_add' => true)) - ->getForm() - ->createView(); - - $html = $this->renderWidget($form); - - $this->assertMatchesXpath($html, - '//div[@id="name_items"][@data-prototype] - | - //table[@id="name_items"][@data-prototype]' - ); - } - - public function testEmptyRootFormName() - { - $form = $this->factory->createNamedBuilder('', 'form') - ->add('child', 'text') - ->getForm(); - - $this->assertMatchesXpath($this->renderWidget($form->createView()), - '//input[@type="hidden"][@id="_token"][@name="_token"] - | - //input[@type="text"][@id="child"][@name="child"]', 2); - } - - public function testButton() - { - $form = $this->factory->createNamed('name', 'button'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), - '/button[@type="button"][@name="name"][.="[trans]Name[/trans]"]' - ); - } - - public function testButtonLabelIsEmpty() - { - $form = $this->factory->createNamed('name', 'button'); - - $this->assertSame('', $this->renderLabel($form->createView())); - } - - public function testSubmit() - { - $form = $this->factory->createNamed('name', 'submit'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), - '/button[@type="submit"][@name="name"]' - ); - } - - public function testReset() - { - $form = $this->factory->createNamed('name', 'reset'); - - $this->assertWidgetMatchesXpath($form->createView(), array(), - '/button[@type="reset"][@name="name"]' - ); - } - - public function testStartTag() - { - $form = $this->factory->create('form', null, array( - 'method' => 'get', - 'action' => 'http://example.com/directory', - )); - - $html = $this->renderStart($form->createView()); - - $this->assertSame('
', $html); - } - - public function testStartTagForPutRequest() - { - $form = $this->factory->create('form', null, array( - 'method' => 'put', - 'action' => 'http://example.com/directory', - )); - - $html = $this->renderStart($form->createView()); - - $this->assertMatchesXpath($html.'', -'/form - [./input[@type="hidden"][@name="_method"][@value="PUT"]] - [@method="post"] - [@action="http://example.com/directory"]' - ); - } - - public function testStartTagWithOverriddenVars() - { - $form = $this->factory->create('form', null, array( - 'method' => 'put', - 'action' => 'http://example.com/directory', - )); - - $html = $this->renderStart($form->createView(), array( - 'method' => 'post', - 'action' => 'http://foo.com/directory', - )); - - $this->assertSame('
', $html); - } - - public function testStartTagForMultipartForm() - { - $form = $this->factory->createBuilder('form', null, array( - 'method' => 'get', - 'action' => 'http://example.com/directory', - )) - ->add('file', 'file') - ->getForm(); - - $html = $this->renderStart($form->createView()); - - $this->assertSame('', $html); - } - - public function testStartTagWithExtraAttributes() - { - $form = $this->factory->create('form', null, array( - 'method' => 'get', - 'action' => 'http://example.com/directory', - )); - - $html = $this->renderStart($form->createView(), array( - 'attr' => array('class' => 'foobar'), - )); - - $this->assertSame('', $html); - } - - public function testWidgetAttributes() - { - $form = $this->factory->createNamed('text', 'text', 'value', array( - 'required' => true, - 'disabled' => true, - 'read_only' => true, - 'attr' => array('maxlength' => 10, 'pattern' => '\d+', 'class' => 'foobar', 'data-foo' => 'bar'), - )); - - $html = $this->renderWidget($form->createView()); - - // compare plain HTML to check the whitespace - $this->assertSame('', $html); - } - - public function testWidgetAttributeNameRepeatedIfTrue() - { - $form = $this->factory->createNamed('text', 'text', 'value', array( - 'attr' => array('foo' => true), - )); - - $html = $this->renderWidget($form->createView()); - - // foo="foo" - $this->assertSame('', $html); - } - - public function testWidgetAttributeHiddenIfFalse() - { - $form = $this->factory->createNamed('text', 'text', 'value', array( - 'attr' => array('foo' => false), - )); - - $html = $this->renderWidget($form->createView()); - - $this->assertNotContains('foo="', $html); - } - - public function testButtonAttributes() - { - $form = $this->factory->createNamed('button', 'button', null, array( - 'disabled' => true, - 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), - )); - - $html = $this->renderWidget($form->createView()); - - // compare plain HTML to check the whitespace - $this->assertSame('', $html); - } - - public function testButtonAttributeNameRepeatedIfTrue() - { - $form = $this->factory->createNamed('button', 'button', null, array( - 'attr' => array('foo' => true), - )); - - $html = $this->renderWidget($form->createView()); - - // foo="foo" - $this->assertSame('', $html); - } - - public function testButtonAttributeHiddenIfFalse() - { - $form = $this->factory->createNamed('button', 'button', null, array( - 'attr' => array('foo' => false), - )); - - $html = $this->renderWidget($form->createView()); - - $this->assertNotContains('foo="', $html); - } - - public function testTextareaWithWhitespaceOnlyContentRetainsValue() - { - $form = $this->factory->createNamed('textarea', 'textarea', ' '); - - $html = $this->renderWidget($form->createView()); - - $this->assertContains('> ', $html); - } - - public function testTextareaWithWhitespaceOnlyContentRetainsValueWhenRenderingForm() - { - $form = $this->factory->createBuilder('form', array('textarea' => ' ')) - ->add('textarea', 'textarea') - ->getForm(); - - $html = $this->renderForm($form->createView()); - - $this->assertContains('> ', $html); - } - - public function testWidgetContainerAttributeHiddenIfFalse() - { - $form = $this->factory->createNamed('form', 'form', null, array( - 'attr' => array('foo' => false), - )); - - $html = $this->renderWidget($form->createView()); - - // no foo - $this->assertNotContains('foo="', $html); - } - - public function testTranslatedAttributes() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('firstName', 'text', array('attr' => array('title' => 'Foo'))) - ->add('lastName', 'text', array('attr' => array('placeholder' => 'Bar'))) - ->getForm() - ->createView(); - - $html = $this->renderForm($view); - - $this->assertMatchesXpath($html, '/form//input[@title="[trans]Foo[/trans]"]'); - $this->assertMatchesXpath($html, '/form//input[@placeholder="[trans]Bar[/trans]"]'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php deleted file mode 100644 index 197ae392b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractRequestHandlerTest.php +++ /dev/null @@ -1,383 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormFactory; -use Symfony\Component\Form\Forms; -use Symfony\Component\Form\RequestHandlerInterface; - -/** - * @author Bernhard Schussek - */ -abstract class AbstractRequestHandlerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var RequestHandlerInterface - */ - protected $requestHandler; - - /** - * @var FormFactory - */ - protected $factory; - - protected $request; - - protected $serverParams; - - protected function setUp() - { - $this->serverParams = $this->getMock( - 'Symfony\Component\Form\Util\ServerParams', - array('getNormalizedIniPostMaxSize', 'getContentLength') - ); - $this->requestHandler = $this->getRequestHandler(); - $this->factory = Forms::createFormFactoryBuilder()->getFormFactory(); - $this->request = null; - } - - public function methodExceptGetProvider() - { - return array( - array('POST'), - array('PUT'), - array('DELETE'), - array('PATCH'), - ); - } - - public function methodProvider() - { - return array_merge(array( - array('GET'), - ), $this->methodExceptGetProvider()); - } - - /** - * @dataProvider methodProvider - */ - public function testSubmitIfNameInRequest($method) - { - $form = $this->getMockForm('param1', $method); - - $this->setRequestData($method, array( - 'param1' => 'DATA', - )); - - $form->expects($this->once()) - ->method('submit') - ->with('DATA', 'PATCH' !== $method); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodProvider - */ - public function testDoNotSubmitIfWrongRequestMethod($method) - { - $form = $this->getMockForm('param1', $method); - - $otherMethod = 'POST' === $method ? 'PUT' : 'POST'; - - $this->setRequestData($otherMethod, array( - 'param1' => 'DATA', - )); - - $form->expects($this->never()) - ->method('submit'); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodExceptGetProvider - */ - public function testDoNoSubmitSimpleFormIfNameNotInRequestAndNotGetRequest($method) - { - $form = $this->getMockForm('param1', $method, false); - - $this->setRequestData($method, array( - 'paramx' => array(), - )); - - $form->expects($this->never()) - ->method('submit'); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodExceptGetProvider - */ - public function testDoNotSubmitCompoundFormIfNameNotInRequestAndNotGetRequest($method) - { - $form = $this->getMockForm('param1', $method, true); - - $this->setRequestData($method, array( - 'paramx' => array(), - )); - - $form->expects($this->never()) - ->method('submit'); - - $this->requestHandler->handleRequest($form, $this->request); - } - - public function testDoNotSubmitIfNameNotInRequestAndGetRequest() - { - $form = $this->getMockForm('param1', 'GET'); - - $this->setRequestData('GET', array( - 'paramx' => array(), - )); - - $form->expects($this->never()) - ->method('submit'); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodProvider - */ - public function testSubmitFormWithEmptyNameIfAtLeastOneFieldInRequest($method) - { - $form = $this->getMockForm('', $method); - $form->expects($this->any()) - ->method('all') - ->will($this->returnValue(array( - 'param1' => $this->getMockForm('param1'), - 'param2' => $this->getMockForm('param2'), - ))); - - $this->setRequestData($method, $requestData = array( - 'param1' => 'submitted value', - 'paramx' => 'submitted value', - )); - - $form->expects($this->once()) - ->method('submit') - ->with($requestData, 'PATCH' !== $method); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodProvider - */ - public function testDoNotSubmitFormWithEmptyNameIfNoFieldInRequest($method) - { - $form = $this->getMockForm('', $method); - $form->expects($this->any()) - ->method('all') - ->will($this->returnValue(array( - 'param1' => $this->getMockForm('param1'), - 'param2' => $this->getMockForm('param2'), - ))); - - $this->setRequestData($method, array( - 'paramx' => 'submitted value', - )); - - $form->expects($this->never()) - ->method('submit'); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodExceptGetProvider - */ - public function testMergeParamsAndFiles($method) - { - $form = $this->getMockForm('param1', $method); - $file = $this->getMockFile(); - - $this->setRequestData($method, array( - 'param1' => array( - 'field1' => 'DATA', - ), - ), array( - 'param1' => array( - 'field2' => $file, - ), - )); - - $form->expects($this->once()) - ->method('submit') - ->with(array( - 'field1' => 'DATA', - 'field2' => $file, - ), 'PATCH' !== $method); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodExceptGetProvider - */ - public function testParamTakesPrecedenceOverFile($method) - { - $form = $this->getMockForm('param1', $method); - $file = $this->getMockFile(); - - $this->setRequestData($method, array( - 'param1' => 'DATA', - ), array( - 'param1' => $file, - )); - - $form->expects($this->once()) - ->method('submit') - ->with('DATA', 'PATCH' !== $method); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodExceptGetProvider - */ - public function testSubmitFileIfNoParam($method) - { - $form = $this->getMockForm('param1', $method); - $file = $this->getMockFile(); - - $this->setRequestData($method, array( - 'param1' => null, - ), array( - 'param1' => $file, - )); - - $form->expects($this->once()) - ->method('submit') - ->with($file, 'PATCH' !== $method); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodExceptGetProvider - */ - public function testSubmitMultipleFiles($method) - { - $form = $this->getMockForm('param1', $method); - $file = $this->getMockFile(); - - $this->setRequestData($method, array( - 'param1' => null, - ), array( - 'param2' => $this->getMockFile('2'), - 'param1' => $file, - 'param3' => $this->getMockFile('3'), - )); - - $form->expects($this->once()) - ->method('submit') - ->with($file, 'PATCH' !== $method); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider methodExceptGetProvider - */ - public function testSubmitFileWithNamelessForm($method) - { - $form = $this->getMockForm(null, $method); - $file = $this->getMockFile(); - - $this->setRequestData($method, array( - '' => null, - ), array( - '' => $file, - )); - - $form->expects($this->once()) - ->method('submit') - ->with($file, 'PATCH' !== $method); - - $this->requestHandler->handleRequest($form, $this->request); - } - - /** - * @dataProvider getPostMaxSizeFixtures - */ - public function testAddFormErrorIfPostMaxSizeExceeded($contentLength, $iniMax, $shouldFail, array $errorParams = array()) - { - $this->serverParams->expects($this->once()) - ->method('getContentLength') - ->will($this->returnValue($contentLength)); - $this->serverParams->expects($this->any()) - ->method('getNormalizedIniPostMaxSize') - ->will($this->returnValue($iniMax)); - - $options = array('post_max_size_message' => 'Max {{ max }}!'); - $form = $this->factory->createNamed('name', 'text', null, $options); - $this->setRequestData('POST', array(), array()); - - $this->requestHandler->handleRequest($form, $this->request); - - if ($shouldFail) { - $errors = array(new FormError($options['post_max_size_message'], null, $errorParams)); - - $this->assertEquals($errors, iterator_to_array($form->getErrors())); - $this->assertTrue($form->isSubmitted()); - } else { - $this->assertCount(0, $form->getErrors()); - $this->assertFalse($form->isSubmitted()); - } - } - - public function getPostMaxSizeFixtures() - { - return array( - array(pow(1024, 3) + 1, '1G', true, array('{{ max }}' => '1G')), - array(pow(1024, 3), '1G', false), - array(pow(1024, 2) + 1, '1M', true, array('{{ max }}' => '1M')), - array(pow(1024, 2), '1M', false), - array(1024 + 1, '1K', true, array('{{ max }}' => '1K')), - array(1024, '1K', false), - array(null, '1K', false), - array(1024, '', false), - array(1024, 0, false), - ); - } - - abstract protected function setRequestData($method, $data, $files = array()); - - abstract protected function getRequestHandler(); - - abstract protected function getMockFile($suffix = ''); - - protected function getMockForm($name, $method = null, $compound = true) - { - $config = $this->getMock('Symfony\Component\Form\FormConfigInterface'); - $config->expects($this->any()) - ->method('getMethod') - ->will($this->returnValue($method)); - $config->expects($this->any()) - ->method('getCompound') - ->will($this->returnValue($compound)); - - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $form->expects($this->any()) - ->method('getName') - ->will($this->returnValue($name)); - $form->expects($this->any()) - ->method('getConfig') - ->will($this->returnValue($config)); - - return $form; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php deleted file mode 100644 index f655d17cd..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/AbstractTableLayoutTest.php +++ /dev/null @@ -1,536 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormError; -use Symfony\Component\Security\Csrf\CsrfToken; - -abstract class AbstractTableLayoutTest extends AbstractLayoutTest -{ - public function testRow() - { - $form = $this->factory->createNamed('name', 'text'); - $form->addError(new FormError('[trans]Error![/trans]')); - $view = $form->createView(); - $html = $this->renderRow($view); - - $this->assertMatchesXpath($html, -'/tr - [ - ./td - [./label[@for="name"]] - /following-sibling::td - [ - ./ul - [./li[.="[trans]Error![/trans]"]] - [count(./li)=1] - /following-sibling::input[@id="name"] - ] - ] -' - ); - } - - public function testLabelIsNotRenderedWhenSetToFalse() - { - $form = $this->factory->createNamed('name', 'text', null, array( - 'label' => false, - )); - $html = $this->renderRow($form->createView()); - - $this->assertMatchesXpath($html, -'/tr - [ - ./td - [count(//label)=0] - /following-sibling::td - [./input[@id="name"]] - ] -' - ); - } - - public function testRepeatedRow() - { - $form = $this->factory->createNamed('name', 'repeated'); - $html = $this->renderRow($form->createView()); - - $this->assertMatchesXpath($html, -'/tr - [ - ./td - [./label[@for="name_first"]] - /following-sibling::td - [./input[@id="name_first"]] - ] -/following-sibling::tr - [ - ./td - [./label[@for="name_second"]] - /following-sibling::td - [./input[@id="name_second"]] - ] -/following-sibling::tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] - [count(../tr)=3] -' - ); - } - - public function testRepeatedRowWithErrors() - { - $form = $this->factory->createNamed('name', 'repeated'); - $form->addError(new FormError('[trans]Error![/trans]')); - $view = $form->createView(); - $html = $this->renderRow($view); - - // The errors of the form are not rendered by intention! - // In practice, repeated fields cannot have errors as all errors - // on them are mapped to the first child. - // (see RepeatedTypeValidatorExtension) - - $this->assertMatchesXpath($html, -'/tr - [ - ./td - [./label[@for="name_first"]] - /following-sibling::td - [./input[@id="name_first"]] - ] -/following-sibling::tr - [ - ./td - [./label[@for="name_second"]] - /following-sibling::td - [./input[@id="name_second"]] - ] -/following-sibling::tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] - [count(../tr)=3] -' - ); - } - - public function testButtonRow() - { - $form = $this->factory->createNamed('name', 'button'); - $view = $form->createView(); - $html = $this->renderRow($view); - - $this->assertMatchesXpath($html, -'/tr - [ - ./td - [.=""] - /following-sibling::td - [./button[@type="button"][@name="name"]] - ] - [count(//label)=0] -' - ); - } - - public function testRest() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'repeated') - ->add('field3', 'text') - ->add('field4', 'text') - ->getForm() - ->createView(); - - // Render field2 row -> does not implicitly call renderWidget because - // it is a repeated field! - $this->renderRow($view['field2']); - - // Render field3 widget - $this->renderWidget($view['field3']); - - // Rest should only contain field1 and field4 - $html = $this->renderRest($view); - - $this->assertMatchesXpath($html, -'/tr - [ - ./td - [./label[@for="name_field1"]] - /following-sibling::td - [./input[@id="name_field1"]] - ] -/following-sibling::tr - [ - ./td - [./label[@for="name_field4"]] - /following-sibling::td - [./input[@id="name_field4"]] - ] - [count(../tr)=3] - [count(..//label)=2] - [count(..//input)=3] -/following-sibling::tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] -' - ); - } - - public function testCollection() - { - $form = $this->factory->createNamed('names', 'collection', array('a', 'b'), array( - 'type' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/table - [ - ./tr[./td/input[@type="text"][@value="a"]] - /following-sibling::tr[./td/input[@type="text"][@value="b"]] - /following-sibling::tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="names__token"]] - ] - [count(./tr[./td/input])=3] -' - ); - } - - public function testEmptyCollection() - { - $form = $this->factory->createNamed('names', 'collection', array(), array( - 'type' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/table - [./tr[@style="display: none"][./td[@colspan="2"]/input[@type="hidden"][@id="names__token"]]] - [count(./tr[./td/input])=1] -' - ); - } - - public function testForm() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->setMethod('PUT') - ->setAction('http://example.com') - ->add('firstName', 'text') - ->add('lastName', 'text') - ->getForm() - ->createView(); - - $html = $this->renderForm($view, array( - 'id' => 'my&id', - 'attr' => array('class' => 'my&class'), - )); - - $this->assertMatchesXpath($html, -'/form - [ - ./input[@type="hidden"][@name="_method"][@value="PUT"] - /following-sibling::table - [ - ./tr - [ - ./td - [./label[@for="name_firstName"]] - /following-sibling::td - [./input[@id="name_firstName"]] - ] - /following-sibling::tr - [ - ./td - [./label[@for="name_lastName"]] - /following-sibling::td - [./input[@id="name_lastName"]] - ] - /following-sibling::tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] - ] - [count(.//input)=3] - [@id="my&id"] - [@class="my&class"] - ] - [@method="post"] - [@action="http://example.com"] - [@class="my&class"] -' - ); - } - - public function testFormWidget() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('firstName', 'text') - ->add('lastName', 'text') - ->getForm() - ->createView(); - - $this->assertWidgetMatchesXpath($view, array(), -'/table - [ - ./tr - [ - ./td - [./label[@for="name_firstName"]] - /following-sibling::td - [./input[@id="name_firstName"]] - ] - /following-sibling::tr - [ - ./td - [./label[@for="name_lastName"]] - /following-sibling::td - [./input[@id="name_lastName"]] - ] - /following-sibling::tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] - ] - [count(.//input)=3] -' - ); - } - - // https://github.com/symfony/symfony/issues/2308 - public function testNestedFormError() - { - $form = $this->factory->createNamedBuilder('name', 'form') - ->add($this->factory - ->createNamedBuilder('child', 'form', null, array('error_bubbling' => false)) - ->add('grandChild', 'form') - ) - ->getForm(); - - $form->get('child')->addError(new FormError('[trans]Error![/trans]')); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/table - [ - ./tr/td/ul[./li[.="[trans]Error![/trans]"]] - /following-sibling::table[@id="name_child"] - ] - [count(.//li[.="[trans]Error![/trans]"])=1] -' - ); - } - - public function testCsrf() - { - $this->csrfTokenManager->expects($this->any()) - ->method('getToken') - ->will($this->returnValue(new CsrfToken('token_id', 'foo&bar'))); - - $form = $this->factory->createNamedBuilder('name', 'form') - ->add($this->factory - // No CSRF protection on nested forms - ->createNamedBuilder('child', 'form') - ->add($this->factory->createNamedBuilder('grandchild', 'text')) - ) - ->getForm(); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/table - [ - ./tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] - ] - [count(.//input[@type="hidden"])=1] -' - ); - } - - public function testRepeated() - { - $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( - 'type' => 'text', - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/table - [ - ./tr - [ - ./td - [./label[@for="name_first"]] - /following-sibling::td - [./input[@type="text"][@id="name_first"]] - ] - /following-sibling::tr - [ - ./td - [./label[@for="name_second"]] - /following-sibling::td - [./input[@type="text"][@id="name_second"]] - ] - /following-sibling::tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] - ] - [count(.//input)=3] -' - ); - } - - public function testRepeatedWithCustomOptions() - { - $form = $this->factory->createNamed('name', 'repeated', 'foobar', array( - 'type' => 'password', - 'first_options' => array('label' => 'Test', 'required' => false), - 'second_options' => array('label' => 'Test2'), - )); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/table - [ - ./tr - [ - ./td - [./label[@for="name_first"][.="[trans]Test[/trans]"]] - /following-sibling::td - [./input[@type="password"][@id="name_first"][@required="required"]] - ] - /following-sibling::tr - [ - ./td - [./label[@for="name_second"][.="[trans]Test2[/trans]"]] - /following-sibling::td - [./input[@type="password"][@id="name_second"][@required="required"]] - ] - /following-sibling::tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] - ] - [count(.//input)=3] -' - ); - } - - /** - * The block "_name_child_label" should be overridden in the theme of the - * implemented driver. - */ - public function testCollectionRowWithCustomBlock() - { - $collection = array('one', 'two', 'three'); - $form = $this->factory->createNamedBuilder('names', 'collection', $collection) - ->getForm(); - - $this->assertWidgetMatchesXpath($form->createView(), array(), -'/table - [ - ./tr[./td/label[.="Custom label: [trans]0[/trans]"]] - /following-sibling::tr[./td/label[.="Custom label: [trans]1[/trans]"]] - /following-sibling::tr[./td/label[.="Custom label: [trans]2[/trans]"]] - ] -' - ); - } - - public function testFormEndWithRest() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'text') - ->getForm() - ->createView(); - - $this->renderWidget($view['field1']); - - // Rest should only contain field2 - $html = $this->renderEnd($view); - - // Insert the start tag, the end tag should be rendered by the helper - // Unfortunately this is not valid HTML, because the surrounding table - // tag is missing. If someone renders a form with table layout - // manually, she should call form_rest() explicitly within the
- // tag. - $this->assertMatchesXpath(''.$html, -'/form - [ - ./tr - [ - ./td - [./label[@for="name_field2"]] - /following-sibling::td - [./input[@id="name_field2"]] - ] - /following-sibling::tr[@style="display: none"] - [./td[@colspan="2"]/input - [@type="hidden"] - [@id="name__token"] - ] - ] -' - ); - } - - public function testFormEndWithoutRest() - { - $view = $this->factory->createNamedBuilder('name', 'form') - ->add('field1', 'text') - ->add('field2', 'text') - ->getForm() - ->createView(); - - $this->renderWidget($view['field1']); - - // Rest should only contain field2, but isn't rendered - $html = $this->renderEnd($view, array('render_rest' => false)); - - $this->assertEquals('', $html); - } - - public function testWidgetContainerAttributes() - { - $form = $this->factory->createNamed('form', 'form', null, array( - 'attr' => array('class' => 'foobar', 'data-foo' => 'bar'), - )); - - $form->add('text', 'text'); - - $html = $this->renderWidget($form->createView()); - - // compare plain HTML to check the whitespace - $this->assertContains('
', $html); - } - - public function testWidgetContainerAttributeNameRepeatedIfTrue() - { - $form = $this->factory->createNamed('form', 'form', null, array( - 'attr' => array('foo' => true), - )); - - $html = $this->renderWidget($form->createView()); - - // foo="foo" - $this->assertContains('
', $html); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/ButtonTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/ButtonTest.php deleted file mode 100644 index b0c766c73..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/ButtonTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\ButtonBuilder; -use Symfony\Component\Form\FormBuilder; - -/** - * @author Bernhard Schussek - */ -class ButtonTest extends \PHPUnit_Framework_TestCase -{ - private $dispatcher; - - private $factory; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - } - - /** - * @dataProvider getDisabledStates - */ - public function testDisabledIfParentIsDisabled($parentDisabled, $buttonDisabled, $result) - { - $form = $this->getFormBuilder('form') - ->setDisabled($parentDisabled) - ->getForm(); - - $button = $this->getButtonBuilder('button') - ->setDisabled($buttonDisabled) - ->getForm(); - - $button->setParent($form); - - $this->assertSame($result, $button->isDisabled()); - } - - public function getDisabledStates() - { - return array( - // parent, button, result - array(true, true, true), - array(true, false, true), - array(false, true, true), - array(false, false, false), - ); - } - - private function getButtonBuilder($name) - { - return new ButtonBuilder($name); - } - - private function getFormBuilder($name) - { - return new FormBuilder($name, null, $this->dispatcher, $this->factory); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/CallbackTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/CallbackTransformerTest.php deleted file mode 100644 index af49e69e6..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/CallbackTransformerTest.php +++ /dev/null @@ -1,46 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\CallbackTransformer; - -class CallbackTransformerTest extends \PHPUnit_Framework_TestCase -{ - public function testTransform() - { - $transformer = new CallbackTransformer( - function ($value) { return $value.' has been transformed'; }, - function ($value) { return $value.' has reversely been transformed'; } - ); - - $this->assertEquals('foo has been transformed', $transformer->transform('foo')); - $this->assertEquals('bar has reversely been transformed', $transformer->reverseTransform('bar')); - } - - /** - * @dataProvider invalidCallbacksProvider - * - * @expectedException \InvalidArgumentException - */ - public function testConstructorWithInvalidCallbacks($transformCallback, $reverseTransformCallback) - { - new CallbackTransformer($transformCallback, $reverseTransformCallback); - } - - public function invalidCallbacksProvider() - { - return array( - array(null, function () {}), - array(function () {}, null), - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php deleted file mode 100644 index 77873a71f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormPerformanceTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -/** - * @author Bernhard Schussek - */ -class CompoundFormPerformanceTest extends \Symfony\Component\Form\Test\FormPerformanceTestCase -{ - /** - * Create a compound form multiple times, as happens in a collection form. - * - * @group benchmark - */ - public function testArrayBasedForm() - { - $this->setMaxRunningTime(1); - - for ($i = 0; $i < 40; ++$i) { - $form = $this->factory->createBuilder('form') - ->add('firstName', 'text') - ->add('lastName', 'text') - ->add('gender', 'choice', array( - 'choices' => array('male' => 'Male', 'female' => 'Female'), - 'required' => false, - )) - ->add('age', 'number') - ->add('birthDate', 'birthday') - ->add('city', 'choice', array( - // simulate 300 different cities - 'choices' => range(1, 300), - )) - ->getForm(); - - // load the form into a view - $form->createView(); - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormTest.php deleted file mode 100644 index e552fc747..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/CompoundFormTest.php +++ /dev/null @@ -1,1067 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; -use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Forms; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\SubmitButtonBuilder; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; - -class CompoundFormTest extends AbstractFormTest -{ - public function testValidIfAllChildrenAreValid() - { - $this->form->add($this->getBuilder('firstName')->getForm()); - $this->form->add($this->getBuilder('lastName')->getForm()); - - $this->form->submit(array( - 'firstName' => 'Bernhard', - 'lastName' => 'Schussek', - )); - - $this->assertTrue($this->form->isValid()); - } - - public function testInvalidIfChildIsInvalid() - { - $this->form->add($this->getBuilder('firstName')->getForm()); - $this->form->add($this->getBuilder('lastName')->getForm()); - - $this->form->submit(array( - 'firstName' => 'Bernhard', - 'lastName' => 'Schussek', - )); - - $this->form->get('lastName')->addError(new FormError('Invalid')); - - $this->assertFalse($this->form->isValid()); - } - - public function testDisabledFormsValidEvenIfChildrenInvalid() - { - $form = $this->getBuilder('person') - ->setDisabled(true) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->add($this->getBuilder('name')) - ->getForm(); - - $form->submit(array('name' => 'Jacques Doe')); - - $form->get('name')->addError(new FormError('Invalid')); - - $this->assertTrue($form->isValid()); - } - - public function testSubmitForwardsNullIfNotClearMissingButValueIsExplicitlyNull() - { - $child = $this->getMockForm('firstName'); - - $this->form->add($child); - - $child->expects($this->once()) - ->method('submit') - ->with($this->equalTo(null)); - - $this->form->submit(array('firstName' => null), false); - } - - public function testSubmitForwardsNullIfValueIsMissing() - { - $child = $this->getMockForm('firstName'); - - $this->form->add($child); - - $child->expects($this->once()) - ->method('submit') - ->with($this->equalTo(null)); - - $this->form->submit(array()); - } - - public function testSubmitDoesNotForwardNullIfNotClearMissing() - { - $child = $this->getMockForm('firstName'); - - $this->form->add($child); - - $child->expects($this->never()) - ->method('submit'); - - $this->form->submit(array(), false); - } - - public function testSubmitDoesNotAddExtraFieldForNullValues() - { - $factory = Forms::createFormFactoryBuilder() - ->getFormFactory(); - - $child = $factory->create('file', null, array('auto_initialize' => false)); - - $this->form->add($child); - $this->form->submit(array('file' => null), false); - - $this->assertCount(0, $this->form->getExtraData()); - } - - public function testClearMissingFlagIsForwarded() - { - $child = $this->getMockForm('firstName'); - - $this->form->add($child); - - $child->expects($this->once()) - ->method('submit') - ->with($this->equalTo('foo'), false); - - $this->form->submit(array('firstName' => 'foo'), false); - } - - public function testCloneChildren() - { - $child = $this->getBuilder('child')->getForm(); - $this->form->add($child); - - $clone = clone $this->form; - - $this->assertNotSame($this->form, $clone); - $this->assertNotSame($child, $clone['child']); - $this->assertNotSame($this->form['child'], $clone['child']); - } - - public function testNotEmptyIfChildNotEmpty() - { - $child = $this->getMockForm(); - $child->expects($this->once()) - ->method('isEmpty') - ->will($this->returnValue(false)); - - $this->form->setData(null); - $this->form->add($child); - - $this->assertFalse($this->form->isEmpty()); - } - - public function testAdd() - { - $child = $this->getBuilder('foo')->getForm(); - $this->form->add($child); - - $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); - $this->assertSame(array('foo' => $child), $this->form->all()); - } - - public function testAddUsingNameAndType() - { - $child = $this->getBuilder('foo')->getForm(); - - $this->factory->expects($this->once()) - ->method('createNamed') - ->with('foo', 'text', null, array( - 'bar' => 'baz', - 'auto_initialize' => false, - )) - ->will($this->returnValue($child)); - - $this->form->add('foo', 'text', array('bar' => 'baz')); - - $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); - $this->assertSame(array('foo' => $child), $this->form->all()); - } - - public function testAddUsingIntegerNameAndType() - { - $child = $this->getBuilder(0)->getForm(); - - $this->factory->expects($this->once()) - ->method('createNamed') - ->with('0', 'text', null, array( - 'bar' => 'baz', - 'auto_initialize' => false, - )) - ->will($this->returnValue($child)); - - // in order to make casting unnecessary - $this->form->add(0, 'text', array('bar' => 'baz')); - - $this->assertTrue($this->form->has(0)); - $this->assertSame($this->form, $child->getParent()); - $this->assertSame(array(0 => $child), $this->form->all()); - } - - public function testAddWithoutType() - { - $child = $this->getBuilder('foo')->getForm(); - - $this->factory->expects($this->once()) - ->method('createNamed') - ->with('foo', 'text') - ->will($this->returnValue($child)); - - $this->form->add('foo'); - - $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); - $this->assertSame(array('foo' => $child), $this->form->all()); - } - - public function testAddUsingNameButNoType() - { - $this->form = $this->getBuilder('name', null, '\stdClass') - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - - $child = $this->getBuilder('foo')->getForm(); - - $this->factory->expects($this->once()) - ->method('createForProperty') - ->with('\stdClass', 'foo') - ->will($this->returnValue($child)); - - $this->form->add('foo'); - - $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); - $this->assertSame(array('foo' => $child), $this->form->all()); - } - - public function testAddUsingNameButNoTypeAndOptions() - { - $this->form = $this->getBuilder('name', null, '\stdClass') - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - - $child = $this->getBuilder('foo')->getForm(); - - $this->factory->expects($this->once()) - ->method('createForProperty') - ->with('\stdClass', 'foo', null, array( - 'bar' => 'baz', - 'auto_initialize' => false, - )) - ->will($this->returnValue($child)); - - $this->form->add('foo', null, array('bar' => 'baz')); - - $this->assertTrue($this->form->has('foo')); - $this->assertSame($this->form, $child->getParent()); - $this->assertSame(array('foo' => $child), $this->form->all()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException - */ - public function testAddThrowsExceptionIfAlreadySubmitted() - { - $this->form->submit(array()); - $this->form->add($this->getBuilder('foo')->getForm()); - } - - public function testRemove() - { - $child = $this->getBuilder('foo')->getForm(); - $this->form->add($child); - $this->form->remove('foo'); - - $this->assertNull($child->getParent()); - $this->assertCount(0, $this->form); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException - */ - public function testRemoveThrowsExceptionIfAlreadySubmitted() - { - $this->form->add($this->getBuilder('foo')->setCompound(false)->getForm()); - $this->form->submit(array('foo' => 'bar')); - $this->form->remove('foo'); - } - - public function testRemoveIgnoresUnknownName() - { - $this->form->remove('notexisting'); - } - - public function testArrayAccess() - { - $child = $this->getBuilder('foo')->getForm(); - - $this->form[] = $child; - - $this->assertTrue(isset($this->form['foo'])); - $this->assertSame($child, $this->form['foo']); - - unset($this->form['foo']); - - $this->assertFalse(isset($this->form['foo'])); - } - - public function testCountable() - { - $this->form->add($this->getBuilder('foo')->getForm()); - $this->form->add($this->getBuilder('bar')->getForm()); - - $this->assertCount(2, $this->form); - } - - public function testIterator() - { - $this->form->add($this->getBuilder('foo')->getForm()); - $this->form->add($this->getBuilder('bar')->getForm()); - - $this->assertSame($this->form->all(), iterator_to_array($this->form)); - } - - public function testAddMapsViewDataToFormIfInitialized() - { - $test = $this; - $mapper = $this->getDataMapper(); - $form = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($mapper) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'foo' => 'bar', - ))) - ->setData('foo') - ->getForm(); - - $child = $this->getBuilder()->getForm(); - $mapper->expects($this->once()) - ->method('mapDataToForms') - ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) - ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child, $test) { - $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); - $test->assertSame(array($child), iterator_to_array($iterator)); - })); - - $form->initialize(); - $form->add($child); - } - - public function testAddDoesNotMapViewDataToFormIfNotInitialized() - { - $mapper = $this->getDataMapper(); - $form = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($mapper) - ->getForm(); - - $child = $this->getBuilder()->getForm(); - $mapper->expects($this->never()) - ->method('mapDataToForms'); - - $form->add($child); - } - - public function testAddDoesNotMapViewDataToFormIfInheritData() - { - $mapper = $this->getDataMapper(); - $form = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($mapper) - ->setInheritData(true) - ->getForm(); - - $child = $this->getBuilder()->getForm(); - $mapper->expects($this->never()) - ->method('mapDataToForms'); - - $form->initialize(); - $form->add($child); - } - - public function testSetDataSupportsDynamicAdditionAndRemovalOfChildren() - { - $form = $this->getBuilder() - ->setCompound(true) - // We test using PropertyPathMapper on purpose. The traversal logic - // is currently contained in InheritDataAwareIterator, but even - // if that changes, this test should still function. - ->setDataMapper(new PropertyPathMapper()) - ->getForm(); - - $child = $this->getMockForm('child'); - $childToBeRemoved = $this->getMockForm('removed'); - $childToBeAdded = $this->getMockForm('added'); - - $form->add($child); - $form->add($childToBeRemoved); - - $child->expects($this->once()) - ->method('setData') - ->will($this->returnCallback(function () use ($form, $childToBeAdded) { - $form->remove('removed'); - $form->add($childToBeAdded); - })); - - $childToBeRemoved->expects($this->never()) - ->method('setData'); - - // once when it it is created, once when it is added - $childToBeAdded->expects($this->exactly(2)) - ->method('setData'); - - // pass NULL to all children - $form->setData(array()); - } - - public function testSetDataMapsViewDataToChildren() - { - $test = $this; - $mapper = $this->getDataMapper(); - $form = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($mapper) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'foo' => 'bar', - ))) - ->getForm(); - - $form->add($child1 = $this->getBuilder('firstName')->getForm()); - $form->add($child2 = $this->getBuilder('lastName')->getForm()); - - $mapper->expects($this->once()) - ->method('mapDataToForms') - ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator')) - ->will($this->returnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2, $test) { - $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); - $test->assertSame(array('firstName' => $child1, 'lastName' => $child2), iterator_to_array($iterator)); - })); - - $form->setData('foo'); - } - - public function testSubmitSupportsDynamicAdditionAndRemovalOfChildren() - { - $child = $this->getMockForm('child'); - $childToBeRemoved = $this->getMockForm('removed'); - $childToBeAdded = $this->getMockForm('added'); - - $this->form->add($child); - $this->form->add($childToBeRemoved); - - $form = $this->form; - - $child->expects($this->once()) - ->method('submit') - ->will($this->returnCallback(function () use ($form, $childToBeAdded) { - $form->remove('removed'); - $form->add($childToBeAdded); - })); - - $childToBeRemoved->expects($this->never()) - ->method('submit'); - - $childToBeAdded->expects($this->once()) - ->method('submit'); - - // pass NULL to all children - $this->form->submit(array()); - } - - public function testSubmitMapsSubmittedChildrenOntoExistingViewData() - { - $test = $this; - $mapper = $this->getDataMapper(); - $form = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($mapper) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'foo' => 'bar', - ))) - ->setData('foo') - ->getForm(); - - $form->add($child1 = $this->getBuilder('firstName')->setCompound(false)->getForm()); - $form->add($child2 = $this->getBuilder('lastName')->setCompound(false)->getForm()); - - $mapper->expects($this->once()) - ->method('mapFormsToData') - ->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar') - ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2, $test) { - $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); - $test->assertSame(array('firstName' => $child1, 'lastName' => $child2), iterator_to_array($iterator)); - $test->assertEquals('Bernhard', $child1->getData()); - $test->assertEquals('Schussek', $child2->getData()); - })); - - $form->submit(array( - 'firstName' => 'Bernhard', - 'lastName' => 'Schussek', - )); - } - - public function testMapFormsToDataIsNotInvokedIfInheritData() - { - $mapper = $this->getDataMapper(); - $form = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($mapper) - ->setInheritData(true) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'foo' => 'bar', - ))) - ->getForm(); - - $form->add($child1 = $this->getBuilder('firstName')->setCompound(false)->getForm()); - $form->add($child2 = $this->getBuilder('lastName')->setCompound(false)->getForm()); - - $mapper->expects($this->never()) - ->method('mapFormsToData'); - - $form->submit(array( - 'firstName' => 'Bernhard', - 'lastName' => 'Schussek', - )); - } - - /* - * https://github.com/symfony/symfony/issues/4480 - */ - public function testSubmitRestoresViewDataIfCompoundAndEmpty() - { - $mapper = $this->getDataMapper(); - $object = new \stdClass(); - $form = $this->getBuilder('name', null, 'stdClass') - ->setCompound(true) - ->setDataMapper($mapper) - ->setData($object) - ->getForm(); - - $form->submit(array()); - - $this->assertSame($object, $form->getData()); - } - - public function testSubmitMapsSubmittedChildrenOntoEmptyData() - { - $test = $this; - $mapper = $this->getDataMapper(); - $object = new \stdClass(); - $form = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($mapper) - ->setEmptyData($object) - ->setData(null) - ->getForm(); - - $form->add($child = $this->getBuilder('name')->setCompound(false)->getForm()); - - $mapper->expects($this->once()) - ->method('mapFormsToData') - ->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object) - ->will($this->returnCallback(function (\RecursiveIteratorIterator $iterator) use ($child, $test) { - $test->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); - $test->assertSame(array('name' => $child), iterator_to_array($iterator)); - })); - - $form->submit(array( - 'name' => 'Bernhard', - )); - } - - public function requestMethodProvider() - { - return array( - array('POST'), - array('PUT'), - array('DELETE'), - array('PATCH'), - ); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitPostOrPutRequest($method) - { - $path = tempnam(sys_get_temp_dir(), 'sf2'); - touch($path); - - $values = array( - 'author' => array( - 'name' => 'Bernhard', - 'image' => array('filename' => 'foobar.png'), - ), - ); - - $files = array( - 'author' => array( - 'error' => array('image' => UPLOAD_ERR_OK), - 'name' => array('image' => 'upload.png'), - 'size' => array('image' => 123), - 'tmp_name' => array('image' => $path), - 'type' => array('image' => 'image/png'), - ), - ); - - $request = new Request(array(), $values, array(), array(), $files, array( - 'REQUEST_METHOD' => $method, - )); - - $form = $this->getBuilder('author') - ->setMethod($method) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setRequestHandler(new HttpFoundationRequestHandler()) - ->getForm(); - $form->add($this->getBuilder('name')->getForm()); - $form->add($this->getBuilder('image')->getForm()); - - $form->handleRequest($request); - - $file = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); - - $this->assertEquals('Bernhard', $form['name']->getData()); - $this->assertEquals($file, $form['image']->getData()); - - unlink($path); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitPostOrPutRequestWithEmptyRootFormName($method) - { - $path = tempnam(sys_get_temp_dir(), 'sf2'); - touch($path); - - $values = array( - 'name' => 'Bernhard', - 'extra' => 'data', - ); - - $files = array( - 'image' => array( - 'error' => UPLOAD_ERR_OK, - 'name' => 'upload.png', - 'size' => 123, - 'tmp_name' => $path, - 'type' => 'image/png', - ), - ); - - $request = new Request(array(), $values, array(), array(), $files, array( - 'REQUEST_METHOD' => $method, - )); - - $form = $this->getBuilder('') - ->setMethod($method) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setRequestHandler(new HttpFoundationRequestHandler()) - ->getForm(); - $form->add($this->getBuilder('name')->getForm()); - $form->add($this->getBuilder('image')->getForm()); - - $form->handleRequest($request); - - $file = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); - - $this->assertEquals('Bernhard', $form['name']->getData()); - $this->assertEquals($file, $form['image']->getData()); - $this->assertEquals(array('extra' => 'data'), $form->getExtraData()); - - unlink($path); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitPostOrPutRequestWithSingleChildForm($method) - { - $path = tempnam(sys_get_temp_dir(), 'sf2'); - touch($path); - - $files = array( - 'image' => array( - 'error' => UPLOAD_ERR_OK, - 'name' => 'upload.png', - 'size' => 123, - 'tmp_name' => $path, - 'type' => 'image/png', - ), - ); - - $request = new Request(array(), array(), array(), array(), $files, array( - 'REQUEST_METHOD' => $method, - )); - - $form = $this->getBuilder('image') - ->setMethod($method) - ->setRequestHandler(new HttpFoundationRequestHandler()) - ->getForm(); - - $form->handleRequest($request); - - $file = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); - - $this->assertEquals($file, $form->getData()); - - unlink($path); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitPostOrPutRequestWithSingleChildFormUploadedFile($method) - { - $path = tempnam(sys_get_temp_dir(), 'sf2'); - touch($path); - - $values = array( - 'name' => 'Bernhard', - ); - - $request = new Request(array(), $values, array(), array(), array(), array( - 'REQUEST_METHOD' => $method, - )); - - $form = $this->getBuilder('name') - ->setMethod($method) - ->setRequestHandler(new HttpFoundationRequestHandler()) - ->getForm(); - - $form->handleRequest($request); - - $this->assertEquals('Bernhard', $form->getData()); - - unlink($path); - } - - public function testSubmitGetRequest() - { - $values = array( - 'author' => array( - 'firstName' => 'Bernhard', - 'lastName' => 'Schussek', - ), - ); - - $request = new Request($values, array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $form = $this->getBuilder('author') - ->setMethod('GET') - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setRequestHandler(new HttpFoundationRequestHandler()) - ->getForm(); - $form->add($this->getBuilder('firstName')->getForm()); - $form->add($this->getBuilder('lastName')->getForm()); - - $form->handleRequest($request); - - $this->assertEquals('Bernhard', $form['firstName']->getData()); - $this->assertEquals('Schussek', $form['lastName']->getData()); - } - - public function testSubmitGetRequestWithEmptyRootFormName() - { - $values = array( - 'firstName' => 'Bernhard', - 'lastName' => 'Schussek', - 'extra' => 'data', - ); - - $request = new Request($values, array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $form = $this->getBuilder('') - ->setMethod('GET') - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setRequestHandler(new HttpFoundationRequestHandler()) - ->getForm(); - $form->add($this->getBuilder('firstName')->getForm()); - $form->add($this->getBuilder('lastName')->getForm()); - - $form->handleRequest($request); - - $this->assertEquals('Bernhard', $form['firstName']->getData()); - $this->assertEquals('Schussek', $form['lastName']->getData()); - $this->assertEquals(array('extra' => 'data'), $form->getExtraData()); - } - - public function testGetErrorsAsStringDeep() - { - $parent = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - - $this->form->addError(new FormError('Error!')); - - $parent->add($this->form); - $parent->add($this->getBuilder('foo')->getForm()); - - $this->assertSame( - "name:\n". - " ERROR: Error!\n", - $parent->getErrorsAsString() - ); - } - - public function testGetErrorsAsStringDeepWithIndentation() - { - $parent = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - - $this->form->addError(new FormError('Error!')); - - $parent->add($this->form); - $parent->add($this->getBuilder('foo')->getForm()); - - $this->assertSame( - " name:\n". - " ERROR: Error!\n", - $parent->getErrorsAsString(4) - ); - } - - public function testGetErrors() - { - $this->form->addError($error1 = new FormError('Error 1')); - $this->form->addError($error2 = new FormError('Error 2')); - - $errors = $this->form->getErrors(); - - $this->assertSame( - "ERROR: Error 1\n". - "ERROR: Error 2\n", - (string) $errors - ); - - $this->assertSame(array($error1, $error2), iterator_to_array($errors)); - } - - public function testGetErrorsDeep() - { - $this->form->addError($error1 = new FormError('Error 1')); - $this->form->addError($error2 = new FormError('Error 2')); - - $childForm = $this->getBuilder('Child')->getForm(); - $childForm->addError($nestedError = new FormError('Nested Error')); - $this->form->add($childForm); - - $errors = $this->form->getErrors(true); - - $this->assertSame( - "ERROR: Error 1\n". - "ERROR: Error 2\n". - "ERROR: Nested Error\n", - (string) $errors - ); - - $this->assertSame( - array($error1, $error2, $nestedError), - iterator_to_array($errors) - ); - } - - public function testGetErrorsDeepRecursive() - { - $this->form->addError($error1 = new FormError('Error 1')); - $this->form->addError($error2 = new FormError('Error 2')); - - $childForm = $this->getBuilder('Child')->getForm(); - $childForm->addError($nestedError = new FormError('Nested Error')); - $this->form->add($childForm); - - $errors = $this->form->getErrors(true, false); - - $this->assertSame( - "ERROR: Error 1\n". - "ERROR: Error 2\n". - "Child:\n". - " ERROR: Nested Error\n", - (string) $errors - ); - - $errorsAsArray = iterator_to_array($errors); - - $this->assertSame($error1, $errorsAsArray[0]); - $this->assertSame($error2, $errorsAsArray[1]); - $this->assertInstanceOf('Symfony\Component\Form\FormErrorIterator', $errorsAsArray[2]); - - $nestedErrorsAsArray = iterator_to_array($errorsAsArray[2]); - - $this->assertCount(1, $nestedErrorsAsArray); - $this->assertSame($nestedError, $nestedErrorsAsArray[0]); - } - - // Basic cases are covered in SimpleFormTest - public function testCreateViewWithChildren() - { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $options = array('a' => 'Foo', 'b' => 'Bar'); - $field1 = $this->getMockForm('foo'); - $field2 = $this->getMockForm('bar'); - $view = new FormView(); - $field1View = new FormView(); - $field2View = new FormView(); - - $this->form = $this->getBuilder('form', null, null, $options) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setType($type) - ->getForm(); - $this->form->add($field1); - $this->form->add($field2); - - $test = $this; - - $assertChildViewsEqual = function (array $childViews) use ($test) { - return function (FormView $view) use ($test, $childViews) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertSame($childViews, $view->children); - }; - }; - - // First create the view - $type->expects($this->once()) - ->method('createView') - ->will($this->returnValue($view)); - - // Then build it for the form itself - $type->expects($this->once()) - ->method('buildView') - ->with($view, $this->form, $options) - ->will($this->returnCallback($assertChildViewsEqual(array()))); - - // Then add the first child form - $field1->expects($this->once()) - ->method('createView') - ->will($this->returnValue($field1View)); - - // Then the second child form - $field2->expects($this->once()) - ->method('createView') - ->will($this->returnValue($field2View)); - - // Again build the view for the form itself. This time the child views - // exist. - $type->expects($this->once()) - ->method('finishView') - ->with($view, $this->form, $options) - ->will($this->returnCallback($assertChildViewsEqual(array('foo' => $field1View, 'bar' => $field2View)))); - - $this->assertSame($view, $this->form->createView()); - } - - public function testNoClickedButtonBeforeSubmission() - { - $this->assertNull($this->form->getClickedButton()); - } - - public function testNoClickedButton() - { - $button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton') - ->setConstructorArgs(array(new SubmitButtonBuilder('submit'))) - ->setMethods(array('isClicked')) - ->getMock(); - - $button->expects($this->any()) - ->method('isClicked') - ->will($this->returnValue(false)); - - $parentForm = $this->getBuilder('parent')->getForm(); - $nestedForm = $this->getBuilder('nested')->getForm(); - - $this->form->setParent($parentForm); - $this->form->add($button); - $this->form->add($nestedForm); - $this->form->submit(array()); - - $this->assertNull($this->form->getClickedButton()); - } - - public function testClickedButton() - { - $button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton') - ->setConstructorArgs(array(new SubmitButtonBuilder('submit'))) - ->setMethods(array('isClicked')) - ->getMock(); - - $button->expects($this->any()) - ->method('isClicked') - ->will($this->returnValue(true)); - - $this->form->add($button); - $this->form->submit(array()); - - $this->assertSame($button, $this->form->getClickedButton()); - } - - public function testClickedButtonFromNestedForm() - { - $button = $this->getBuilder('submit')->getForm(); - - $nestedForm = $this->getMockBuilder('Symfony\Component\Form\Form') - ->setConstructorArgs(array($this->getBuilder('nested'))) - ->setMethods(array('getClickedButton')) - ->getMock(); - - $nestedForm->expects($this->any()) - ->method('getClickedButton') - ->will($this->returnValue($button)); - - $this->form->add($nestedForm); - $this->form->submit(array()); - - $this->assertSame($button, $this->form->getClickedButton()); - } - - public function testClickedButtonFromParentForm() - { - $button = $this->getBuilder('submit')->getForm(); - - $parentForm = $this->getMockBuilder('Symfony\Component\Form\Form') - ->setConstructorArgs(array($this->getBuilder('parent'))) - ->setMethods(array('getClickedButton')) - ->getMock(); - - $parentForm->expects($this->any()) - ->method('getClickedButton') - ->will($this->returnValue($button)); - - $this->form->setParent($parentForm); - $this->form->submit(array()); - - $this->assertSame($button, $this->form->getClickedButton()); - } - - protected function createForm() - { - return $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php deleted file mode 100644 index 68ef4dca4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/AbstractChoiceListTest.php +++ /dev/null @@ -1,345 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; - -/** - * @author Bernhard Schussek - */ -abstract class AbstractChoiceListTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface - */ - protected $list; - - /** - * @var array - */ - protected $choices; - - /** - * @var array - */ - protected $values; - - /** - * @var array - */ - protected $indices; - - /** - * @var array - */ - protected $labels; - - /** - * @var mixed - */ - protected $choice1; - - /** - * @var mixed - */ - protected $choice2; - - /** - * @var mixed - */ - protected $choice3; - - /** - * @var mixed - */ - protected $choice4; - - /** - * @var string - */ - protected $value1; - - /** - * @var string - */ - protected $value2; - - /** - * @var string - */ - protected $value3; - - /** - * @var string - */ - protected $value4; - - /** - * @var int|string - */ - protected $index1; - - /** - * @var int|string - */ - protected $index2; - - /** - * @var int|string - */ - protected $index3; - - /** - * @var int|string - */ - protected $index4; - - /** - * @var string - */ - protected $label1; - - /** - * @var string - */ - protected $label2; - - /** - * @var string - */ - protected $label3; - - /** - * @var string - */ - protected $label4; - - protected function setUp() - { - parent::setUp(); - - $this->list = $this->createChoiceList(); - - $this->choices = $this->getChoices(); - $this->indices = $this->getIndices(); - $this->values = $this->getValues(); - $this->labels = $this->getLabels(); - - // allow access to the individual entries without relying on their indices - reset($this->choices); - reset($this->indices); - reset($this->values); - reset($this->labels); - - for ($i = 1; $i <= 4; ++$i) { - $this->{'choice'.$i} = current($this->choices); - $this->{'index'.$i} = current($this->indices); - $this->{'value'.$i} = current($this->values); - $this->{'label'.$i} = current($this->labels); - - next($this->choices); - next($this->indices); - next($this->values); - next($this->labels); - } - } - - public function testGetChoices() - { - $this->assertSame($this->choices, $this->list->getChoices()); - } - - public function testGetValues() - { - $this->assertSame($this->values, $this->list->getValues()); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoices() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $choices = array($this->choice1, $this->choice2); - $this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesPreservesKeys() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $choices = array(5 => $this->choice1, 8 => $this->choice2); - $this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesPreservesOrder() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $choices = array($this->choice2, $this->choice1); - $this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesIgnoresNonExistingChoices() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $choices = array($this->choice1, $this->choice2, 'foobar'); - $this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesEmpty() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $this->assertSame(array(), $this->list->getIndicesForChoices(array())); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForValues() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - // values and indices are always the same - $values = array($this->value1, $this->value2); - $this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForValuesPreservesKeys() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - // values and indices are always the same - $values = array(5 => $this->value1, 8 => $this->value2); - $this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForValues($values)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForValuesPreservesOrder() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $values = array($this->value2, $this->value1); - $this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForValues($values)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForValuesIgnoresNonExistingValues() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $values = array($this->value1, $this->value2, 'foobar'); - $this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForValues($values)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForValuesEmpty() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $this->assertSame(array(), $this->list->getIndicesForValues(array())); - } - - public function testGetChoicesForValues() - { - $values = array($this->value1, $this->value2); - $this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values)); - } - - public function testGetChoicesForValuesPreservesKeys() - { - $values = array(5 => $this->value1, 8 => $this->value2); - $this->assertSame(array(5 => $this->choice1, 8 => $this->choice2), $this->list->getChoicesForValues($values)); - } - - public function testGetChoicesForValuesPreservesOrder() - { - $values = array($this->value2, $this->value1); - $this->assertSame(array($this->choice2, $this->choice1), $this->list->getChoicesForValues($values)); - } - - public function testGetChoicesForValuesIgnoresNonExistingValues() - { - $values = array($this->value1, $this->value2, 'foobar'); - $this->assertSame(array($this->choice1, $this->choice2), $this->list->getChoicesForValues($values)); - } - - // https://github.com/symfony/symfony/issues/3446 - public function testGetChoicesForValuesEmpty() - { - $this->assertSame(array(), $this->list->getChoicesForValues(array())); - } - - public function testGetValuesForChoices() - { - $choices = array($this->choice1, $this->choice2); - $this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices)); - } - - public function testGetValuesForChoicesPreservesKeys() - { - $choices = array(5 => $this->choice1, 8 => $this->choice2); - $this->assertSame(array(5 => $this->value1, 8 => $this->value2), $this->list->getValuesForChoices($choices)); - } - - public function testGetValuesForChoicesPreservesOrder() - { - $choices = array($this->choice2, $this->choice1); - $this->assertSame(array($this->value2, $this->value1), $this->list->getValuesForChoices($choices)); - } - - public function testGetValuesForChoicesIgnoresNonExistingChoices() - { - $choices = array($this->choice1, $this->choice2, 'foobar'); - $this->assertSame(array($this->value1, $this->value2), $this->list->getValuesForChoices($choices)); - } - - public function testGetValuesForChoicesEmpty() - { - $this->assertSame(array(), $this->list->getValuesForChoices(array())); - } - - /** - * @return \Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface - */ - abstract protected function createChoiceList(); - - abstract protected function getChoices(); - - abstract protected function getLabels(); - - abstract protected function getValues(); - - abstract protected function getIndices(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php deleted file mode 100644 index 538bbc1b3..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ChoiceListTest.php +++ /dev/null @@ -1,158 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; - -use Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceList; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; - -class ChoiceListTest extends AbstractChoiceListTest -{ - private $obj1; - - private $obj2; - - private $obj3; - - private $obj4; - - protected function setUp() - { - $this->obj1 = new \stdClass(); - $this->obj2 = new \stdClass(); - $this->obj3 = new \stdClass(); - $this->obj4 = new \stdClass(); - - parent::setUp(); - } - - public function testInitArray() - { - $this->list = new ChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - array('A', 'B', 'C', 'D'), - array($this->obj2) - ); - - $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); - $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); - $this->assertEquals(array(1 => new ChoiceView($this->obj2, '1', 'B')), $this->list->getPreferredViews()); - $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews()); - } - - /** - * Necessary for interoperability with MongoDB cursors or ORM relations as - * choices parameter. A choice itself that is an object implementing \Traversable - * is not treated as hierarchical structure, but as-is. - */ - public function testInitNestedTraversable() - { - $traversableChoice = new \ArrayIterator(array($this->obj3, $this->obj4)); - - $this->list = new ChoiceList( - new \ArrayIterator(array( - 'Group' => array($this->obj1, $this->obj2), - 'Not a Group' => $traversableChoice, - )), - array( - 'Group' => array('A', 'B'), - 'Not a Group' => 'C', - ), - array($this->obj2) - ); - - $this->assertSame(array($this->obj1, $this->obj2, $traversableChoice), $this->list->getChoices()); - $this->assertSame(array('0', '1', '2'), $this->list->getValues()); - $this->assertEquals(array( - 'Group' => array(1 => new ChoiceView($this->obj2, '1', 'B')), - ), $this->list->getPreferredViews()); - $this->assertEquals(array( - 'Group' => array(0 => new ChoiceView($this->obj1, '0', 'A')), - 2 => new ChoiceView($traversableChoice, '2', 'C'), - ), $this->list->getRemainingViews()); - } - - public function testInitNestedArray() - { - $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); - $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); - $this->assertEquals(array( - 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), - 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')), - ), $this->list->getPreferredViews()); - $this->assertEquals(array( - 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), - 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')), - ), $this->list->getRemainingViews()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInitWithInsufficientLabels() - { - $this->list = new ChoiceList( - array($this->obj1, $this->obj2), - array('A') - ); - } - - public function testInitWithLabelsContainingNull() - { - $this->list = new ChoiceList( - array($this->obj1, $this->obj2), - array('A', null) - ); - - $this->assertEquals( - array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', null)), - $this->list->getRemainingViews() - ); - } - - /** - * @return \Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface - */ - protected function createChoiceList() - { - return new ChoiceList( - array( - 'Group 1' => array($this->obj1, $this->obj2), - 'Group 2' => array($this->obj3, $this->obj4), - ), - array( - 'Group 1' => array('A', 'B'), - 'Group 2' => array('C', 'D'), - ), - array($this->obj2, $this->obj3) - ); - } - - protected function getChoices() - { - return array(0 => $this->obj1, 1 => $this->obj2, 2 => $this->obj3, 3 => $this->obj4); - } - - protected function getLabels() - { - return array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'); - } - - protected function getValues() - { - return array(0 => '0', 1 => '1', 2 => '2', 3 => '3'); - } - - protected function getIndices() - { - return array(0, 1, 2, 3); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php deleted file mode 100644 index 0e5e2e652..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/LazyChoiceListTest.php +++ /dev/null @@ -1,126 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; - -use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; -use Symfony\Component\Form\Extension\Core\ChoiceList\LazyChoiceList; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; - -class LazyChoiceListTest extends \PHPUnit_Framework_TestCase -{ - private $list; - - protected function setUp() - { - parent::setUp(); - - $this->list = new LazyChoiceListTest_Impl(new SimpleChoiceList(array( - 'a' => 'A', - 'b' => 'B', - 'c' => 'C', - ), array('b'))); - } - - protected function tearDown() - { - parent::tearDown(); - - $this->list = null; - } - - public function testGetChoices() - { - $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices()); - } - - public function testGetValues() - { - $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues()); - } - - public function testGetPreferredViews() - { - $this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews()); - } - - public function testGetRemainingViews() - { - $this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews()); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoices() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $choices = array('b', 'c'); - $this->assertSame(array(1, 2), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForValues() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $values = array('b', 'c'); - $this->assertSame(array(1, 2), $this->list->getIndicesForValues($values)); - } - - public function testGetChoicesForValues() - { - $values = array('b', 'c'); - $this->assertSame(array('b', 'c'), $this->list->getChoicesForValues($values)); - } - - public function testGetValuesForChoices() - { - $choices = array('b', 'c'); - $this->assertSame(array('b', 'c'), $this->list->getValuesForChoices($choices)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - */ - public function testLoadChoiceListShouldReturnChoiceList() - { - $list = new LazyChoiceListTest_InvalidImpl(); - - $list->getChoices(); - } -} - -class LazyChoiceListTest_Impl extends LazyChoiceList -{ - private $choiceList; - - public function __construct($choiceList) - { - $this->choiceList = $choiceList; - } - - protected function loadChoiceList() - { - return $this->choiceList; - } -} - -class LazyChoiceListTest_InvalidImpl extends LazyChoiceList -{ - protected function loadChoiceList() - { - return new \stdClass(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php deleted file mode 100644 index 2bb06349a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/ObjectChoiceListTest.php +++ /dev/null @@ -1,355 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; - -use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; - -class ObjectChoiceListTest_EntityWithToString -{ - private $property; - - public function __construct($property) - { - $this->property = $property; - } - - public function __toString() - { - return $this->property; - } -} - -class ObjectChoiceListTest extends AbstractChoiceListTest -{ - private $obj1; - - private $obj2; - - private $obj3; - - private $obj4; - - protected function setUp() - { - $this->obj1 = (object) array('name' => 'A'); - $this->obj2 = (object) array('name' => 'B'); - $this->obj3 = (object) array('name' => 'C'); - $this->obj4 = (object) array('name' => 'D'); - - parent::setUp(); - } - - public function testInitArray() - { - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array($this->obj2) - ); - - $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); - $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); - $this->assertEquals(array(1 => new ChoiceView($this->obj2, '1', 'B')), $this->list->getPreferredViews()); - $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews()); - } - - public function testInitNestedArray() - { - $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); - $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); - $this->assertEquals(array( - 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), - 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')), - ), $this->list->getPreferredViews()); - $this->assertEquals(array( - 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), - 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')), - ), $this->list->getRemainingViews()); - } - - public function testInitArrayWithGroupPath() - { - $this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1'); - $this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1'); - $this->obj3 = (object) array('name' => 'C', 'category' => 'Group 2'); - $this->obj4 = (object) array('name' => 'D', 'category' => 'Group 2'); - - // Objects with NULL groups are not grouped - $obj5 = (object) array('name' => 'E', 'category' => null); - - // Objects without the group property are not grouped either - // see https://github.com/symfony/symfony/commit/d9b7abb7c7a0f28e0ce970afc5e305dce5dccddf - $obj6 = (object) array('name' => 'F'); - - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4, $obj5, $obj6), - 'name', - array($this->obj2, $this->obj3), - 'category' - ); - - $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4, $obj5, $obj6), $this->list->getChoices()); - $this->assertSame(array('0', '1', '2', '3', '4', '5'), $this->list->getValues()); - $this->assertEquals(array( - 'Group 1' => array(1 => new ChoiceView($this->obj2, '1', 'B')), - 'Group 2' => array(2 => new ChoiceView($this->obj3, '2', 'C')), - ), $this->list->getPreferredViews()); - $this->assertEquals(array( - 'Group 1' => array(0 => new ChoiceView($this->obj1, '0', 'A')), - 'Group 2' => array(3 => new ChoiceView($this->obj4, '3', 'D')), - 4 => new ChoiceView($obj5, '4', 'E'), - 5 => new ChoiceView($obj6, '5', 'F'), - ), $this->list->getRemainingViews()); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInitArrayWithGroupPathThrowsExceptionIfNestedArray() - { - $this->obj1 = (object) array('name' => 'A', 'category' => 'Group 1'); - $this->obj2 = (object) array('name' => 'B', 'category' => 'Group 1'); - $this->obj3 = (object) array('name' => 'C', 'category' => 'Group 2'); - $this->obj4 = (object) array('name' => 'D', 'category' => 'Group 2'); - - new ObjectChoiceList( - array( - 'Group 1' => array($this->obj1, $this->obj2), - 'Group 2' => array($this->obj3, $this->obj4), - ), - 'name', - array($this->obj2, $this->obj3), - 'category' - ); - } - - public function testInitArrayWithValuePath() - { - $this->obj1 = (object) array('name' => 'A', 'id' => 10); - $this->obj2 = (object) array('name' => 'B', 'id' => 20); - $this->obj3 = (object) array('name' => 'C', 'id' => 30); - $this->obj4 = (object) array('name' => 'D', 'id' => 40); - - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array($this->obj2, $this->obj3), - null, - 'id' - ); - - $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); - $this->assertSame(array('10', '20', '30', '40'), $this->list->getValues()); - $this->assertEquals(array(1 => new ChoiceView($this->obj2, '20', 'B'), 2 => new ChoiceView($this->obj3, '30', 'C')), $this->list->getPreferredViews()); - $this->assertEquals(array(0 => new ChoiceView($this->obj1, '10', 'A'), 3 => new ChoiceView($this->obj4, '40', 'D')), $this->list->getRemainingViews()); - } - - public function testInitArrayUsesToString() - { - $this->obj1 = new ObjectChoiceListTest_EntityWithToString('A'); - $this->obj2 = new ObjectChoiceListTest_EntityWithToString('B'); - $this->obj3 = new ObjectChoiceListTest_EntityWithToString('C'); - $this->obj4 = new ObjectChoiceListTest_EntityWithToString('D'); - - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4) - ); - - $this->assertSame(array($this->obj1, $this->obj2, $this->obj3, $this->obj4), $this->list->getChoices()); - $this->assertSame(array('0', '1', '2', '3'), $this->list->getValues()); - $this->assertEquals(array(0 => new ChoiceView($this->obj1, '0', 'A'), 1 => new ChoiceView($this->obj2, '1', 'B'), 2 => new ChoiceView($this->obj3, '2', 'C'), 3 => new ChoiceView($this->obj4, '3', 'D')), $this->list->getRemainingViews()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\StringCastException - */ - public function testInitArrayThrowsExceptionIfToStringNotFound() - { - $this->obj1 = new ObjectChoiceListTest_EntityWithToString('A'); - $this->obj2 = new ObjectChoiceListTest_EntityWithToString('B'); - $this->obj3 = (object) array('name' => 'C'); - $this->obj4 = new ObjectChoiceListTest_EntityWithToString('D'); - - new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4) - ); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesWithValuePath() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array(), - null, - 'name' - ); - - // Compare by value, not by identity - $choices = array(clone $this->obj1, clone $this->obj2); - $this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesWithValuePathPreservesKeys() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array(), - null, - 'name' - ); - - $choices = array(5 => clone $this->obj1, 8 => clone $this->obj2); - $this->assertSame(array(5 => $this->index1, 8 => $this->index2), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesWithValuePathPreservesOrder() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array(), - null, - 'name' - ); - - $choices = array(clone $this->obj2, clone $this->obj1); - $this->assertSame(array($this->index2, $this->index1), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesWithValuePathIgnoresNonExistingChoices() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array(), - null, - 'name' - ); - - $choices = array(clone $this->obj1, clone $this->obj2, 'foobar'); - $this->assertSame(array($this->index1, $this->index2), $this->list->getIndicesForChoices($choices)); - } - - public function testGetValuesForChoicesWithValuePath() - { - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array(), - null, - 'name' - ); - - $choices = array(clone $this->obj1, clone $this->obj2); - $this->assertSame(array('A', 'B'), $this->list->getValuesForChoices($choices)); - } - - public function testGetValuesForChoicesWithValuePathPreservesKeys() - { - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array(), - null, - 'name' - ); - - $choices = array(5 => clone $this->obj1, 8 => clone $this->obj2); - $this->assertSame(array(5 => 'A', 8 => 'B'), $this->list->getValuesForChoices($choices)); - } - - public function testGetValuesForChoicesWithValuePathPreservesOrder() - { - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array(), - null, - 'name' - ); - - $choices = array(clone $this->obj2, clone $this->obj1); - $this->assertSame(array('B', 'A'), $this->list->getValuesForChoices($choices)); - } - - public function testGetValuesForChoicesWithValuePathIgnoresNonExistingChoices() - { - $this->list = new ObjectChoiceList( - array($this->obj1, $this->obj2, $this->obj3, $this->obj4), - 'name', - array(), - null, - 'name' - ); - - $choices = array(clone $this->obj1, clone $this->obj2, 'foobar'); - $this->assertSame(array('A', 'B'), $this->list->getValuesForChoices($choices)); - } - - /** - * @return \Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface - */ - protected function createChoiceList() - { - return new ObjectChoiceList( - array( - 'Group 1' => array($this->obj1, $this->obj2), - 'Group 2' => array($this->obj3, $this->obj4), - ), - 'name', - array($this->obj2, $this->obj3) - ); - } - - protected function getChoices() - { - return array(0 => $this->obj1, 1 => $this->obj2, 2 => $this->obj3, 3 => $this->obj4); - } - - protected function getLabels() - { - return array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'); - } - - protected function getValues() - { - return array(0 => '0', 1 => '1', 2 => '2', 3 => '3'); - } - - protected function getIndices() - { - return array(0, 1, 2, 3); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php deleted file mode 100644 index 3a5804ef2..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleChoiceListTest.php +++ /dev/null @@ -1,109 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; - -use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; - -class SimpleChoiceListTest extends AbstractChoiceListTest -{ - public function testInitArray() - { - $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C'); - $this->list = new SimpleChoiceList($choices, array('b')); - - $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getChoices()); - $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c'), $this->list->getValues()); - $this->assertEquals(array(1 => new ChoiceView('b', 'b', 'B')), $this->list->getPreferredViews()); - $this->assertEquals(array(0 => new ChoiceView('a', 'a', 'A'), 2 => new ChoiceView('c', 'c', 'C')), $this->list->getRemainingViews()); - } - - public function testInitNestedArray() - { - $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getChoices()); - $this->assertSame(array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'), $this->list->getValues()); - $this->assertEquals(array( - 'Group 1' => array(1 => new ChoiceView('b', 'b', 'B')), - 'Group 2' => array(2 => new ChoiceView('c', 'c', 'C')), - ), $this->list->getPreferredViews()); - $this->assertEquals(array( - 'Group 1' => array(0 => new ChoiceView('a', 'a', 'A')), - 'Group 2' => array(3 => new ChoiceView('d', 'd', 'D')), - ), $this->list->getRemainingViews()); - } - - /** - * @dataProvider dirtyValuesProvider - */ - public function testGetValuesForChoicesDealsWithDirtyValues($choice, $value) - { - $choices = array( - '0' => 'Zero', - '1' => 'One', - '' => 'Empty', - '1.23' => 'Float', - 'foo' => 'Foo', - 'foo10' => 'Foo 10', - ); - - $this->list = new SimpleChoiceList($choices, array()); - - $this->assertSame(array($value), $this->list->getValuesForChoices(array($choice))); - } - - public function dirtyValuesProvider() - { - return array( - array(0, '0'), - array('0', '0'), - array('1', '1'), - array(false, '0'), - array(true, '1'), - array('', ''), - array(null, ''), - array('1.23', '1.23'), - array('foo', 'foo'), - array('foo10', 'foo10'), - ); - } - - /** - * @return \Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface - */ - protected function createChoiceList() - { - return new SimpleChoiceList(array( - 'Group 1' => array('a' => 'A', 'b' => 'B'), - 'Group 2' => array('c' => 'C', 'd' => 'D'), - ), array('b', 'c')); - } - - protected function getChoices() - { - return array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'); - } - - protected function getLabels() - { - return array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'); - } - - protected function getValues() - { - return array(0 => 'a', 1 => 'b', 2 => 'c', 3 => 'd'); - } - - protected function getIndices() - { - return array(0, 1, 2, 3); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php deleted file mode 100644 index b351790c4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/ChoiceList/SimpleNumericChoiceListTest.php +++ /dev/null @@ -1,87 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\ChoiceList; - -use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; - -class SimpleNumericChoiceListTest extends AbstractChoiceListTest -{ - /** - * @group legacy - */ - public function testLegacyGetIndicesForChoicesDealsWithNumericChoices() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - // Pass choices as strings although they are integers - $choices = array('0', '1'); - $this->assertSame(array(0, 1), $this->list->getIndicesForChoices($choices)); - } - - /** - * @group legacy - */ - public function testLegacyGetIndicesForValuesDealsWithNumericValues() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - // Pass values as strings although they are integers - $values = array('0', '1'); - $this->assertSame(array(0, 1), $this->list->getIndicesForValues($values)); - } - - public function testGetChoicesForValuesDealsWithNumericValues() - { - // Pass values as strings although they are integers - $values = array('0', '1'); - $this->assertSame(array(0, 1), $this->list->getChoicesForValues($values)); - } - - public function testGetValuesForChoicesDealsWithNumericValues() - { - // Pass values as strings although they are integers - $values = array('0', '1'); - - $this->assertSame(array('0', '1'), $this->list->getValuesForChoices($values)); - } - - /** - * @return \Symfony\Component\Form\Extension\Core\ChoiceList\ChoiceListInterface - */ - protected function createChoiceList() - { - return new SimpleChoiceList(array( - 'Group 1' => array(0 => 'A', 1 => 'B'), - 'Group 2' => array(2 => 'C', 3 => 'D'), - ), array(1, 2)); - } - - protected function getChoices() - { - return array(0 => 0, 1 => 1, 2 => 2, 3 => 3); - } - - protected function getLabels() - { - return array(0 => 'A', 1 => 'B', 2 => 'C', 3 => 'D'); - } - - protected function getValues() - { - return array(0 => '0', 1 => '1', 2 => '2', 3 => '3'); - } - - protected function getIndices() - { - return array(0, 1, 2, 3); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php deleted file mode 100644 index 0f0f5dffa..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataMapper/PropertyPathMapperTest.php +++ /dev/null @@ -1,369 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataMapper; - -use Symfony\Component\Form\FormConfigBuilder; -use Symfony\Component\Form\FormConfigInterface; -use Symfony\Component\Form\Extension\Core\DataMapper\PropertyPathMapper; - -class PropertyPathMapperTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var PropertyPathMapper - */ - private $mapper; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dispatcher; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $propertyAccessor; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->propertyAccessor = $this->getMock('Symfony\Component\PropertyAccess\PropertyAccessorInterface'); - $this->mapper = new PropertyPathMapper($this->propertyAccessor); - } - - /** - * @param $path - * - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getPropertyPath($path) - { - return $this->getMockBuilder('Symfony\Component\PropertyAccess\PropertyPath') - ->setConstructorArgs(array($path)) - ->setMethods(array('getValue', 'setValue')) - ->getMock(); - } - - /** - * @param FormConfigInterface $config - * @param bool $synchronized - * @param bool $submitted - * - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getForm(FormConfigInterface $config, $synchronized = true, $submitted = true) - { - $form = $this->getMockBuilder('Symfony\Component\Form\Form') - ->setConstructorArgs(array($config)) - ->setMethods(array('isSynchronized', 'isSubmitted')) - ->getMock(); - - $form->expects($this->any()) - ->method('isSynchronized') - ->will($this->returnValue($synchronized)); - - $form->expects($this->any()) - ->method('isSubmitted') - ->will($this->returnValue($submitted)); - - return $form; - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getDataMapper() - { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); - } - - public function testMapDataToFormsPassesObjectRefIfByReference() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->once()) - ->method('getValue') - ->with($car, $propertyPath) - ->will($this->returnValue($engine)); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $form = $this->getForm($config); - - $this->mapper->mapDataToForms($car, array($form)); - - // Can't use isIdentical() above because mocks always clone their - // arguments which can't be disabled in PHPUnit 3.6 - $this->assertSame($engine, $form->getData()); - } - - public function testMapDataToFormsPassesObjectCloneIfNotByReference() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->once()) - ->method('getValue') - ->with($car, $propertyPath) - ->will($this->returnValue($engine)); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(false); - $config->setPropertyPath($propertyPath); - $form = $this->getForm($config); - - $this->mapper->mapDataToForms($car, array($form)); - - $this->assertNotSame($engine, $form->getData()); - $this->assertEquals($engine, $form->getData()); - } - - public function testMapDataToFormsIgnoresEmptyPropertyPath() - { - $car = new \stdClass(); - - $config = new FormConfigBuilder(null, '\stdClass', $this->dispatcher); - $config->setByReference(true); - $form = $this->getForm($config); - - $this->assertNull($form->getPropertyPath()); - - $this->mapper->mapDataToForms($car, array($form)); - - $this->assertNull($form->getData()); - } - - public function testMapDataToFormsIgnoresUnmapped() - { - $car = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->never()) - ->method('getValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setMapped(false); - $config->setPropertyPath($propertyPath); - $form = $this->getForm($config); - - $this->mapper->mapDataToForms($car, array($form)); - - $this->assertNull($form->getData()); - } - - public function testMapDataToFormsSetsDefaultDataIfPassedDataIsNull() - { - $default = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->never()) - ->method('getValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData($default); - - $form = $this->getMockBuilder('Symfony\Component\Form\Form') - ->setConstructorArgs(array($config)) - ->setMethods(array('setData')) - ->getMock(); - - $form->expects($this->once()) - ->method('setData') - ->with($default); - - $this->mapper->mapDataToForms(null, array($form)); - } - - public function testMapDataToFormsSetsDefaultDataIfPassedDataIsEmptyArray() - { - $default = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->never()) - ->method('getValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData($default); - - $form = $this->getMockBuilder('Symfony\Component\Form\Form') - ->setConstructorArgs(array($config)) - ->setMethods(array('setData')) - ->getMock(); - - $form->expects($this->once()) - ->method('setData') - ->with($default); - - $this->mapper->mapDataToForms(array(), array($form)); - } - - public function testMapFormsToDataWritesBackIfNotByReference() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->once()) - ->method('setValue') - ->with($car, $propertyPath, $engine); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(false); - $config->setPropertyPath($propertyPath); - $config->setData($engine); - $form = $this->getForm($config); - - $this->mapper->mapFormsToData(array($form), $car); - } - - public function testMapFormsToDataWritesBackIfByReferenceButNoReference() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->once()) - ->method('setValue') - ->with($car, $propertyPath, $engine); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData($engine); - $form = $this->getForm($config); - - $this->mapper->mapFormsToData(array($form), $car); - } - - public function testMapFormsToDataWritesBackIfByReferenceAndReference() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - // $car already contains the reference of $engine - $this->propertyAccessor->expects($this->once()) - ->method('getValue') - ->with($car, $propertyPath) - ->will($this->returnValue($engine)); - - $this->propertyAccessor->expects($this->never()) - ->method('setValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData($engine); - $form = $this->getForm($config); - - $this->mapper->mapFormsToData(array($form), $car); - } - - public function testMapFormsToDataIgnoresUnmapped() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->never()) - ->method('setValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData($engine); - $config->setMapped(false); - $form = $this->getForm($config); - - $this->mapper->mapFormsToData(array($form), $car); - } - - public function testMapFormsToDataIgnoresUnsubmittedForms() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->never()) - ->method('setValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData($engine); - $form = $this->getForm($config, true, false); - - $this->mapper->mapFormsToData(array($form), $car); - } - - public function testMapFormsToDataIgnoresEmptyData() - { - $car = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->never()) - ->method('setValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData(null); - $form = $this->getForm($config); - - $this->mapper->mapFormsToData(array($form), $car); - } - - public function testMapFormsToDataIgnoresUnsynchronized() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->never()) - ->method('setValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData($engine); - $form = $this->getForm($config, false); - - $this->mapper->mapFormsToData(array($form), $car); - } - - public function testMapFormsToDataIgnoresDisabled() - { - $car = new \stdClass(); - $engine = new \stdClass(); - $propertyPath = $this->getPropertyPath('engine'); - - $this->propertyAccessor->expects($this->never()) - ->method('setValue'); - - $config = new FormConfigBuilder('name', '\stdClass', $this->dispatcher); - $config->setByReference(true); - $config->setPropertyPath($propertyPath); - $config->setData($engine); - $config->setDisabled(true); - $form = $this->getForm($config); - - $this->mapper->mapFormsToData(array($form), $car); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php deleted file mode 100644 index bafe5c098..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php +++ /dev/null @@ -1,149 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\ArrayToPartsTransformer; - -class ArrayToPartsTransformerTest extends \PHPUnit_Framework_TestCase -{ - private $transformer; - - protected function setUp() - { - $this->transformer = new ArrayToPartsTransformer(array( - 'first' => array('a', 'b', 'c'), - 'second' => array('d', 'e', 'f'), - )); - } - - protected function tearDown() - { - $this->transformer = null; - } - - public function testTransform() - { - $input = array( - 'a' => '1', - 'b' => '2', - 'c' => '3', - 'd' => '4', - 'e' => '5', - 'f' => '6', - ); - - $output = array( - 'first' => array( - 'a' => '1', - 'b' => '2', - 'c' => '3', - ), - 'second' => array( - 'd' => '4', - 'e' => '5', - 'f' => '6', - ), - ); - - $this->assertSame($output, $this->transformer->transform($input)); - } - - public function testTransformEmpty() - { - $output = array( - 'first' => null, - 'second' => null, - ); - - $this->assertSame($output, $this->transformer->transform(null)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testTransformRequiresArray() - { - $this->transformer->transform('12345'); - } - - public function testReverseTransform() - { - $input = array( - 'first' => array( - 'a' => '1', - 'b' => '2', - 'c' => '3', - ), - 'second' => array( - 'd' => '4', - 'e' => '5', - 'f' => '6', - ), - ); - - $output = array( - 'a' => '1', - 'b' => '2', - 'c' => '3', - 'd' => '4', - 'e' => '5', - 'f' => '6', - ); - - $this->assertSame($output, $this->transformer->reverseTransform($input)); - } - - public function testReverseTransformCompletelyEmpty() - { - $input = array( - 'first' => '', - 'second' => '', - ); - - $this->assertNull($this->transformer->reverseTransform($input)); - } - - public function testReverseTransformCompletelyNull() - { - $input = array( - 'first' => null, - 'second' => null, - ); - - $this->assertNull($this->transformer->reverseTransform($input)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformPartiallyNull() - { - $input = array( - 'first' => array( - 'a' => '1', - 'b' => '2', - 'c' => '3', - ), - 'second' => null, - ); - - $this->transformer->reverseTransform($input); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformRequiresArray() - { - $this->transformer->reverseTransform('12345'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php deleted file mode 100644 index 8f2d16bb1..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php +++ /dev/null @@ -1,41 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -class BaseDateTimeTransformerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - * @expectedExceptionMessage this_timezone_does_not_exist - */ - public function testConstructFailsIfInputTimezoneIsInvalid() - { - $this->getMock( - 'Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer', - array(), - array('this_timezone_does_not_exist') - ); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - * @expectedExceptionMessage that_timezone_does_not_exist - */ - public function testConstructFailsIfOutputTimezoneIsInvalid() - { - $this->getMock( - 'Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer', - array(), - array(null, 'that_timezone_does_not_exist') - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php deleted file mode 100644 index a1217783d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\BooleanToStringTransformer; - -class BooleanToStringTransformerTest extends \PHPUnit_Framework_TestCase -{ - const TRUE_VALUE = '1'; - - /** - * @var BooleanToStringTransformer - */ - protected $transformer; - - protected function setUp() - { - $this->transformer = new BooleanToStringTransformer(self::TRUE_VALUE); - } - - protected function tearDown() - { - $this->transformer = null; - } - - public function testTransform() - { - $this->assertEquals(self::TRUE_VALUE, $this->transformer->transform(true)); - $this->assertNull($this->transformer->transform(false)); - } - - // https://github.com/symfony/symfony/issues/8989 - public function testTransformAcceptsNull() - { - $this->assertNull($this->transformer->transform(null)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testTransformFailsIfString() - { - $this->transformer->transform('1'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformFailsIfInteger() - { - $this->transformer->reverseTransform(1); - } - - public function testReverseTransform() - { - $this->assertTrue($this->transformer->reverseTransform(self::TRUE_VALUE)); - $this->assertTrue($this->transformer->reverseTransform('foobar')); - $this->assertTrue($this->transformer->reverseTransform('')); - $this->assertFalse($this->transformer->reverseTransform(null)); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php deleted file mode 100644 index bbae0621c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; -use Symfony\Component\Form\Extension\Core\DataTransformer\ChoiceToValueTransformer; - -class ChoiceToValueTransformerTest extends \PHPUnit_Framework_TestCase -{ - protected $transformer; - - protected function setUp() - { - $list = new SimpleChoiceList(array('' => 'A', 0 => 'B', 1 => 'C')); - $this->transformer = new ChoiceToValueTransformer($list); - } - - protected function tearDown() - { - $this->transformer = null; - } - - public function transformProvider() - { - return array( - // more extensive test set can be found in FormUtilTest - array(0, '0'), - array(false, '0'), - array('', ''), - ); - } - - /** - * @dataProvider transformProvider - */ - public function testTransform($in, $out) - { - $this->assertSame($out, $this->transformer->transform($in)); - } - - public function reverseTransformProvider() - { - return array( - // values are expected to be valid choice keys already and stay - // the same - array('0', 0), - array('', null), - array(null, null), - ); - } - - /** - * @dataProvider reverseTransformProvider - */ - public function testReverseTransform($in, $out) - { - $this->assertSame($out, $this->transformer->reverseTransform($in)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformExpectsScalar() - { - $this->transformer->reverseTransform(array()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php deleted file mode 100644 index 87f5018b0..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ChoicesToValuesTransformerTest.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; -use Symfony\Component\Form\Extension\Core\DataTransformer\ChoicesToValuesTransformer; - -class ChoicesToValuesTransformerTest extends \PHPUnit_Framework_TestCase -{ - protected $transformer; - - protected function setUp() - { - $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B', 2 => 'C')); - $this->transformer = new ChoicesToValuesTransformer($list); - } - - protected function tearDown() - { - $this->transformer = null; - } - - public function testTransform() - { - // Value strategy in SimpleChoiceList is to copy and convert to string - $in = array(0, 1, 2); - $out = array('0', '1', '2'); - - $this->assertSame($out, $this->transformer->transform($in)); - } - - public function testTransformNull() - { - $this->assertSame(array(), $this->transformer->transform(null)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testTransformExpectsArray() - { - $this->transformer->transform('foobar'); - } - - public function testReverseTransform() - { - // values are expected to be valid choices and stay the same - $in = array('0', '1', '2'); - $out = array(0, 1, 2); - - $this->assertSame($out, $this->transformer->reverseTransform($in)); - } - - public function testReverseTransformNull() - { - $this->assertSame(array(), $this->transformer->reverseTransform(null)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformExpectsArray() - { - $this->transformer->reverseTransform('foobar'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php deleted file mode 100644 index 2ee2f22db..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DataTransformerChainTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\DataTransformerChain; - -class DataTransformerChainTest extends \PHPUnit_Framework_TestCase -{ - public function testTransform() - { - $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); - $transformer1->expects($this->once()) - ->method('transform') - ->with($this->identicalTo('foo')) - ->will($this->returnValue('bar')); - $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); - $transformer2->expects($this->once()) - ->method('transform') - ->with($this->identicalTo('bar')) - ->will($this->returnValue('baz')); - - $chain = new DataTransformerChain(array($transformer1, $transformer2)); - - $this->assertEquals('baz', $chain->transform('foo')); - } - - public function testReverseTransform() - { - $transformer2 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); - $transformer2->expects($this->once()) - ->method('reverseTransform') - ->with($this->identicalTo('foo')) - ->will($this->returnValue('bar')); - $transformer1 = $this->getMock('Symfony\Component\Form\DataTransformerInterface'); - $transformer1->expects($this->once()) - ->method('reverseTransform') - ->with($this->identicalTo('bar')) - ->will($this->returnValue('baz')); - - $chain = new DataTransformerChain(array($transformer1, $transformer2)); - - $this->assertEquals('baz', $chain->reverseTransform('foo')); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php deleted file mode 100644 index f7722c496..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeTestCase.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -abstract class DateTimeTestCase extends \PHPUnit_Framework_TestCase -{ - public static function assertDateTimeEquals(\DateTime $expected, \DateTime $actual) - { - self::assertEquals($expected->format('c'), $actual->format('c')); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php deleted file mode 100644 index db5f2b163..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToArrayTransformerTest.php +++ /dev/null @@ -1,560 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToArrayTransformer; - -class DateTimeToArrayTransformerTest extends DateTimeTestCase -{ - public function testTransform() - { - $transformer = new DateTimeToArrayTransformer('UTC', 'UTC'); - - $input = new \DateTime('2010-02-03 04:05:06 UTC'); - - $output = array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - ); - - $this->assertSame($output, $transformer->transform($input)); - } - - public function testTransformEmpty() - { - $transformer = new DateTimeToArrayTransformer(); - - $output = array( - 'year' => '', - 'month' => '', - 'day' => '', - 'hour' => '', - 'minute' => '', - 'second' => '', - ); - - $this->assertSame($output, $transformer->transform(null)); - } - - public function testTransformEmptyWithFields() - { - $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'minute', 'second')); - - $output = array( - 'year' => '', - 'minute' => '', - 'second' => '', - ); - - $this->assertSame($output, $transformer->transform(null)); - } - - public function testTransformWithFields() - { - $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', array('year', 'month', 'minute', 'second')); - - $input = new \DateTime('2010-02-03 04:05:06 UTC'); - - $output = array( - 'year' => '2010', - 'month' => '2', - 'minute' => '5', - 'second' => '6', - ); - - $this->assertSame($output, $transformer->transform($input)); - } - - public function testTransformWithPadding() - { - $transformer = new DateTimeToArrayTransformer('UTC', 'UTC', null, true); - - $input = new \DateTime('2010-02-03 04:05:06 UTC'); - - $output = array( - 'year' => '2010', - 'month' => '02', - 'day' => '03', - 'hour' => '04', - 'minute' => '05', - 'second' => '06', - ); - - $this->assertSame($output, $transformer->transform($input)); - } - - public function testTransformDifferentTimezones() - { - $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong'); - - $input = new \DateTime('2010-02-03 04:05:06 America/New_York'); - - $dateTime = new \DateTime('2010-02-03 04:05:06 America/New_York'); - $dateTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); - $output = array( - 'year' => (string) (int) $dateTime->format('Y'), - 'month' => (string) (int) $dateTime->format('m'), - 'day' => (string) (int) $dateTime->format('d'), - 'hour' => (string) (int) $dateTime->format('H'), - 'minute' => (string) (int) $dateTime->format('i'), - 'second' => (string) (int) $dateTime->format('s'), - ); - - $this->assertSame($output, $transformer->transform($input)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testTransformRequiresDateTime() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform('12345'); - } - - public function testReverseTransform() - { - $transformer = new DateTimeToArrayTransformer('UTC', 'UTC'); - - $input = array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - ); - - $output = new \DateTime('2010-02-03 04:05:06 UTC'); - - $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); - } - - public function testReverseTransformWithSomeZero() - { - $transformer = new DateTimeToArrayTransformer('UTC', 'UTC'); - - $input = array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '0', - 'second' => '0', - ); - - $output = new \DateTime('2010-02-03 04:00:00 UTC'); - - $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); - } - - public function testReverseTransformCompletelyEmpty() - { - $transformer = new DateTimeToArrayTransformer(); - - $input = array( - 'year' => '', - 'month' => '', - 'day' => '', - 'hour' => '', - 'minute' => '', - 'second' => '', - ); - - $this->assertNull($transformer->reverseTransform($input)); - } - - public function testReverseTransformCompletelyEmptySubsetOfFields() - { - $transformer = new DateTimeToArrayTransformer(null, null, array('year', 'month', 'day')); - - $input = array( - 'year' => '', - 'month' => '', - 'day' => '', - ); - - $this->assertNull($transformer->reverseTransform($input)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformPartiallyEmptyYear() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformPartiallyEmptyMonth() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformPartiallyEmptyDay() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformPartiallyEmptyHour() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformPartiallyEmptyMinute() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformPartiallyEmptySecond() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - )); - } - - public function testReverseTransformNull() - { - $transformer = new DateTimeToArrayTransformer(); - - $this->assertNull($transformer->reverseTransform(null)); - } - - public function testReverseTransformDifferentTimezones() - { - $transformer = new DateTimeToArrayTransformer('America/New_York', 'Asia/Hong_Kong'); - - $input = array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - ); - - $output = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong'); - $output->setTimezone(new \DateTimeZone('America/New_York')); - - $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); - } - - public function testReverseTransformToDifferentTimezone() - { - $transformer = new DateTimeToArrayTransformer('Asia/Hong_Kong', 'UTC'); - - $input = array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - ); - - $output = new \DateTime('2010-02-03 04:05:06 UTC'); - $output->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); - - $this->assertDateTimeEquals($output, $transformer->reverseTransform($input)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformRequiresArray() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform('12345'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithNegativeYear() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '-1', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithNegativeMonth() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '-1', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithNegativeDay() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '-1', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithNegativeHour() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '-1', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithNegativeMinute() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '-1', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithNegativeSecond() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '-1', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithInvalidMonth() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '13', - 'day' => '3', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithInvalidDay() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '31', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithStringDay() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => 'bazinga', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithStringMonth() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => 'bazinga', - 'day' => '31', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithStringYear() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => 'bazinga', - 'month' => '2', - 'day' => '31', - 'hour' => '4', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithEmptyStringHour() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '31', - 'hour' => '', - 'minute' => '5', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithEmptyStringMinute() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '31', - 'hour' => '4', - 'minute' => '', - 'second' => '6', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithEmptyStringSecond() - { - $transformer = new DateTimeToArrayTransformer(); - $transformer->reverseTransform(array( - 'year' => '2010', - 'month' => '2', - 'day' => '31', - 'hour' => '4', - 'minute' => '5', - 'second' => '', - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php deleted file mode 100644 index cb50fc366..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ /dev/null @@ -1,275 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToLocalizedStringTransformer; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class DateTimeToLocalizedStringTransformerTest extends DateTimeTestCase -{ - protected $dateTime; - protected $dateTimeWithoutSeconds; - - protected function setUp() - { - parent::setUp(); - - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - - $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC'); - $this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC'); - } - - protected function tearDown() - { - $this->dateTime = null; - $this->dateTimeWithoutSeconds = null; - } - - public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) - { - if ($expected instanceof \DateTime && $actual instanceof \DateTime) { - $expected = $expected->format('c'); - $actual = $actual->format('c'); - } - - parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); - } - - public function dataProvider() - { - return array( - array(\IntlDateFormatter::SHORT, null, null, '03.02.10 04:05', '2010-02-03 04:05:00 UTC'), - array(\IntlDateFormatter::MEDIUM, null, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'), - array(\IntlDateFormatter::LONG, null, null, '03. Februar 2010 04:05', '2010-02-03 04:05:00 UTC'), - array(\IntlDateFormatter::FULL, null, null, 'Mittwoch, 03. Februar 2010 04:05', '2010-02-03 04:05:00 UTC'), - array(\IntlDateFormatter::SHORT, \IntlDateFormatter::NONE, null, '03.02.10', '2010-02-03 00:00:00 UTC'), - array(\IntlDateFormatter::MEDIUM, \IntlDateFormatter::NONE, null, '03.02.2010', '2010-02-03 00:00:00 UTC'), - array(\IntlDateFormatter::LONG, \IntlDateFormatter::NONE, null, '03. Februar 2010', '2010-02-03 00:00:00 UTC'), - array(\IntlDateFormatter::FULL, \IntlDateFormatter::NONE, null, 'Mittwoch, 03. Februar 2010', '2010-02-03 00:00:00 UTC'), - array(null, \IntlDateFormatter::SHORT, null, '03.02.2010 04:05', '2010-02-03 04:05:00 UTC'), - array(null, \IntlDateFormatter::MEDIUM, null, '03.02.2010 04:05:06', '2010-02-03 04:05:06 UTC'), - array(null, \IntlDateFormatter::LONG, null, '03.02.2010 04:05:06 GMT', '2010-02-03 04:05:06 UTC'), - // see below for extra test case for time format FULL - array(\IntlDateFormatter::NONE, \IntlDateFormatter::SHORT, null, '04:05', '1970-01-01 04:05:00 UTC'), - array(\IntlDateFormatter::NONE, \IntlDateFormatter::MEDIUM, null, '04:05:06', '1970-01-01 04:05:06 UTC'), - array(\IntlDateFormatter::NONE, \IntlDateFormatter::LONG, null, '04:05:06 GMT', '1970-01-01 04:05:06 UTC'), - array(null, null, 'yyyy-MM-dd HH:mm:00', '2010-02-03 04:05:00', '2010-02-03 04:05:00 UTC'), - array(null, null, 'yyyy-MM-dd HH:mm', '2010-02-03 04:05', '2010-02-03 04:05:00 UTC'), - array(null, null, 'yyyy-MM-dd HH', '2010-02-03 04', '2010-02-03 04:00:00 UTC'), - array(null, null, 'yyyy-MM-dd', '2010-02-03', '2010-02-03 00:00:00 UTC'), - array(null, null, 'yyyy-MM', '2010-02', '2010-02-01 00:00:00 UTC'), - array(null, null, 'yyyy', '2010', '2010-01-01 00:00:00 UTC'), - array(null, null, 'dd-MM-yyyy', '03-02-2010', '2010-02-03 00:00:00 UTC'), - array(null, null, 'HH:mm:ss', '04:05:06', '1970-01-01 04:05:06 UTC'), - array(null, null, 'HH:mm:00', '04:05:00', '1970-01-01 04:05:00 UTC'), - array(null, null, 'HH:mm', '04:05', '1970-01-01 04:05:00 UTC'), - array(null, null, 'HH', '04', '1970-01-01 04:00:00 UTC'), - ); - } - - /** - * @dataProvider dataProvider - */ - public function testTransform($dateFormat, $timeFormat, $pattern, $output, $input) - { - $transformer = new DateTimeToLocalizedStringTransformer( - 'UTC', - 'UTC', - $dateFormat, - $timeFormat, - \IntlDateFormatter::GREGORIAN, - $pattern - ); - - $input = new \DateTime($input); - - $this->assertEquals($output, $transformer->transform($input)); - } - - public function testTransformFullTime() - { - $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL); - - $this->assertEquals('03.02.2010 04:05:06 GMT', $transformer->transform($this->dateTime)); - } - - public function testTransformToDifferentLocale() - { - \Locale::setDefault('en_US'); - - $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC'); - - $this->assertEquals('Feb 3, 2010, 4:05 AM', $transformer->transform($this->dateTime)); - } - - public function testTransformEmpty() - { - $transformer = new DateTimeToLocalizedStringTransformer(); - - $this->assertSame('', $transformer->transform(null)); - } - - public function testTransformWithDifferentTimezones() - { - $transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong'); - - $input = new \DateTime('2010-02-03 04:05:06 America/New_York'); - - $dateTime = clone $input; - $dateTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); - - $this->assertEquals($dateTime->format('d.m.Y H:i'), $transformer->transform($input)); - } - - public function testTransformWithDifferentPatterns() - { - $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'); - - $this->assertEquals('02*2010*03 04|05|06', $transformer->transform($this->dateTime)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testTransformRequiresValidDateTime() - { - $transformer = new DateTimeToLocalizedStringTransformer(); - $transformer->transform('2010-01-01'); - } - - public function testTransformWrapsIntlErrors() - { - $transformer = new DateTimeToLocalizedStringTransformer(); - - // HOW TO REPRODUCE? - - //$this->setExpectedException('Symfony\Component\Form\Extension\Core\DataTransformer\Transdate_formationFailedException'); - - //$transformer->transform(1.5); - } - - /** - * @dataProvider dataProvider - */ - public function testReverseTransform($dateFormat, $timeFormat, $pattern, $input, $output) - { - $transformer = new DateTimeToLocalizedStringTransformer( - 'UTC', - 'UTC', - $dateFormat, - $timeFormat, - \IntlDateFormatter::GREGORIAN, - $pattern - ); - - $output = new \DateTime($output); - - $this->assertEquals($output, $transformer->reverseTransform($input)); - } - - public function testReverseTransformFullTime() - { - $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', null, \IntlDateFormatter::FULL); - - $this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('03.02.2010 04:05:06 GMT+00:00')); - } - - public function testReverseTransformFromDifferentLocale() - { - \Locale::setDefault('en_US'); - - $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC'); - - $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('Feb 3, 2010, 04:05 AM')); - } - - public function testReverseTransformWithDifferentTimezones() - { - $transformer = new DateTimeToLocalizedStringTransformer('America/New_York', 'Asia/Hong_Kong'); - - $dateTime = new \DateTime('2010-02-03 04:05:00 Asia/Hong_Kong'); - $dateTime->setTimezone(new \DateTimeZone('America/New_York')); - - $this->assertDateTimeEquals($dateTime, $transformer->reverseTransform('03.02.2010 04:05')); - } - - public function testReverseTransformWithDifferentPatterns() - { - $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::FULL, \IntlDateFormatter::FULL, \IntlDateFormatter::GREGORIAN, 'MM*yyyy*dd HH|mm|ss'); - - $this->assertDateTimeEquals($this->dateTime, $transformer->reverseTransform('02*2010*03 04|05|06')); - } - - public function testReverseTransformEmpty() - { - $transformer = new DateTimeToLocalizedStringTransformer(); - - $this->assertNull($transformer->reverseTransform('')); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformRequiresString() - { - $transformer = new DateTimeToLocalizedStringTransformer(); - $transformer->reverseTransform(12345); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWrapsIntlErrors() - { - $transformer = new DateTimeToLocalizedStringTransformer(); - $transformer->reverseTransform('12345'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testValidateDateFormatOption() - { - new DateTimeToLocalizedStringTransformer(null, null, 'foobar'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testValidateTimeFormatOption() - { - new DateTimeToLocalizedStringTransformer(null, null, null, 'foobar'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithNonExistingDate() - { - $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC', \IntlDateFormatter::SHORT); - - $this->assertDateTimeEquals($this->dateTimeWithoutSeconds, $transformer->reverseTransform('31.04.10 04:05')); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformOutOfTimestampRange() - { - $transformer = new DateTimeToLocalizedStringTransformer('UTC', 'UTC'); - $transformer->reverseTransform('1789-07-14'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php deleted file mode 100644 index a39f53aa7..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToRfc3339TransformerTest.php +++ /dev/null @@ -1,133 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToRfc3339Transformer; - -class DateTimeToRfc3339TransformerTest extends DateTimeTestCase -{ - protected $dateTime; - protected $dateTimeWithoutSeconds; - - protected function setUp() - { - parent::setUp(); - - $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC'); - $this->dateTimeWithoutSeconds = new \DateTime('2010-02-03 04:05:00 UTC'); - } - - protected function tearDown() - { - $this->dateTime = null; - $this->dateTimeWithoutSeconds = null; - } - - public static function assertEquals($expected, $actual, $message = '', $delta = 0, $maxDepth = 10, $canonicalize = false, $ignoreCase = false) - { - if ($expected instanceof \DateTime && $actual instanceof \DateTime) { - $expected = $expected->format('c'); - $actual = $actual->format('c'); - } - - parent::assertEquals($expected, $actual, $message, $delta, $maxDepth, $canonicalize, $ignoreCase); - } - - public function allProvider() - { - return array( - array('UTC', 'UTC', '2010-02-03 04:05:06 UTC', '2010-02-03T04:05:06Z'), - array('UTC', 'UTC', null, ''), - array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:06 America/New_York', '2010-02-03T17:05:06+08:00'), - array('America/New_York', 'Asia/Hong_Kong', null, ''), - array('UTC', 'Asia/Hong_Kong', '2010-02-03 04:05:06 UTC', '2010-02-03T12:05:06+08:00'), - array('America/New_York', 'UTC', '2010-02-03 04:05:06 America/New_York', '2010-02-03T09:05:06Z'), - ); - } - - public function transformProvider() - { - return $this->allProvider(); - } - - public function reverseTransformProvider() - { - return array_merge($this->allProvider(), array( - // format without seconds, as appears in some browsers - array('UTC', 'UTC', '2010-02-03 04:05:00 UTC', '2010-02-03T04:05Z'), - array('America/New_York', 'Asia/Hong_Kong', '2010-02-03 04:05:00 America/New_York', '2010-02-03T17:05+08:00'), - array('Europe/Amsterdam', 'Europe/Amsterdam', '2013-08-21 10:30:00 Europe/Amsterdam', '2013-08-21T08:30:00Z'), - )); - } - - /** - * @dataProvider transformProvider - */ - public function testTransform($fromTz, $toTz, $from, $to) - { - $transformer = new DateTimeToRfc3339Transformer($fromTz, $toTz); - - $this->assertSame($to, $transformer->transform(null !== $from ? new \DateTime($from) : null)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testTransformRequiresValidDateTime() - { - $transformer = new DateTimeToRfc3339Transformer(); - $transformer->transform('2010-01-01'); - } - - /** - * @dataProvider reverseTransformProvider - */ - public function testReverseTransform($toTz, $fromTz, $to, $from) - { - $transformer = new DateTimeToRfc3339Transformer($toTz, $fromTz); - - if (null !== $to) { - $this->assertDateTimeEquals(new \DateTime($to), $transformer->reverseTransform($from)); - } else { - $this->assertSame($to, $transformer->reverseTransform($from)); - } - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformRequiresString() - { - $transformer = new DateTimeToRfc3339Transformer(); - $transformer->reverseTransform(12345); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformWithNonExistingDate() - { - $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC'); - - $transformer->reverseTransform('2010-04-31T04:05Z'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformExpectsValidDateString() - { - $transformer = new DateTimeToRfc3339Transformer('UTC', 'UTC'); - - $transformer->reverseTransform('2010-2010-2010'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php deleted file mode 100644 index dbcdad0f9..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToStringTransformerTest.php +++ /dev/null @@ -1,181 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToStringTransformer; - -class DateTimeToStringTransformerTest extends DateTimeTestCase -{ - public function dataProvider() - { - $data = array( - array('Y-m-d H:i:s', '2010-02-03 16:05:06', '2010-02-03 16:05:06 UTC'), - array('Y-m-d H:i:00', '2010-02-03 16:05:00', '2010-02-03 16:05:00 UTC'), - array('Y-m-d H:i', '2010-02-03 16:05', '2010-02-03 16:05:00 UTC'), - array('Y-m-d H', '2010-02-03 16', '2010-02-03 16:00:00 UTC'), - array('Y-m-d', '2010-02-03', '2010-02-03 00:00:00 UTC'), - array('Y-m', '2010-12', '2010-12-01 00:00:00 UTC'), - array('Y', '2010', '2010-01-01 00:00:00 UTC'), - array('d-m-Y', '03-02-2010', '2010-02-03 00:00:00 UTC'), - array('H:i:s', '16:05:06', '1970-01-01 16:05:06 UTC'), - array('H:i:00', '16:05:00', '1970-01-01 16:05:00 UTC'), - array('H:i', '16:05', '1970-01-01 16:05:00 UTC'), - array('H', '16', '1970-01-01 16:00:00 UTC'), - - // different day representations - array('Y-m-j', '2010-02-3', '2010-02-03 00:00:00 UTC'), - array('z', '33', '1970-02-03 00:00:00 UTC'), - - // not bijective - // this will not work as PHP will use actual date to replace missing info - // and after change of date will lookup for closest Wednesday - // i.e. value: 2010-02, PHP value: 2010-02-(today i.e. 20), parsed date: 2010-02-24 - //array('Y-m-D', '2010-02-Wed', '2010-02-03 00:00:00 UTC'), - //array('Y-m-l', '2010-02-Wednesday', '2010-02-03 00:00:00 UTC'), - - // different month representations - array('Y-n-d', '2010-2-03', '2010-02-03 00:00:00 UTC'), - array('Y-M-d', '2010-Feb-03', '2010-02-03 00:00:00 UTC'), - array('Y-F-d', '2010-February-03', '2010-02-03 00:00:00 UTC'), - - // different year representations - array('y-m-d', '10-02-03', '2010-02-03 00:00:00 UTC'), - - // different time representations - array('G:i:s', '16:05:06', '1970-01-01 16:05:06 UTC'), - array('g:i:s a', '4:05:06 pm', '1970-01-01 16:05:06 UTC'), - array('h:i:s a', '04:05:06 pm', '1970-01-01 16:05:06 UTC'), - - // seconds since Unix - array('U', '1265213106', '2010-02-03 16:05:06 UTC'), - ); - - // This test will fail < 5.3.9 - see https://bugs.php.net/51994 - if (PHP_VERSION_ID >= 50309) { - $data[] = array('Y-z', '2010-33', '2010-02-03 00:00:00 UTC'); - } - - return $data; - } - - /** - * @dataProvider dataProvider - */ - public function testTransform($format, $output, $input) - { - $transformer = new DateTimeToStringTransformer('UTC', 'UTC', $format); - - $input = new \DateTime($input); - - $this->assertEquals($output, $transformer->transform($input)); - } - - public function testTransformEmpty() - { - $transformer = new DateTimeToStringTransformer(); - - $this->assertSame('', $transformer->transform(null)); - } - - public function testTransformWithDifferentTimezones() - { - $transformer = new DateTimeToStringTransformer('Asia/Hong_Kong', 'America/New_York', 'Y-m-d H:i:s'); - - $input = new \DateTime('2010-02-03 12:05:06 America/New_York'); - $output = $input->format('Y-m-d H:i:s'); - $input->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); - - $this->assertEquals($output, $transformer->transform($input)); - } - - public function testTransformExpectsDateTime() - { - $transformer = new DateTimeToStringTransformer(); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $transformer->transform('1234'); - } - - /** - * @dataProvider dataProvider - */ - public function testReverseTransformUsingPipe($format, $input, $output) - { - if (PHP_VERSION_ID < 50307) { - $this->markTestSkipped('Pipe usage requires PHP 5.3.7 or newer.'); - } - - $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, true); - - $output = new \DateTime($output); - - $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); - } - - /** - * @dataProvider dataProvider - */ - public function testReverseTransformWithoutUsingPipe($format, $input, $output) - { - $reverseTransformer = new DateTimeToStringTransformer('UTC', 'UTC', $format, false); - - $output = new \DateTime($output); - - $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); - } - - public function testReverseTransformEmpty() - { - $reverseTransformer = new DateTimeToStringTransformer(); - - $this->assertNull($reverseTransformer->reverseTransform('')); - } - - public function testReverseTransformWithDifferentTimezones() - { - $reverseTransformer = new DateTimeToStringTransformer('America/New_York', 'Asia/Hong_Kong', 'Y-m-d H:i:s'); - - $output = new \DateTime('2010-02-03 16:05:06 Asia/Hong_Kong'); - $input = $output->format('Y-m-d H:i:s'); - $output->setTimeZone(new \DateTimeZone('America/New_York')); - - $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); - } - - public function testReverseTransformExpectsString() - { - $reverseTransformer = new DateTimeToStringTransformer(); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $reverseTransformer->reverseTransform(1234); - } - - public function testReverseTransformExpectsValidDateString() - { - $reverseTransformer = new DateTimeToStringTransformer(); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $reverseTransformer->reverseTransform('2010-2010-2010'); - } - - public function testReverseTransformWithNonExistingDate() - { - $reverseTransformer = new DateTimeToStringTransformer(); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $reverseTransformer->reverseTransform('2010-04-31'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php deleted file mode 100644 index b54f0c4c5..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToTimestampTransformerTest.php +++ /dev/null @@ -1,104 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTransformer; - -class DateTimeToTimestampTransformerTest extends DateTimeTestCase -{ - public function testTransform() - { - $transformer = new DateTimeToTimestampTransformer('UTC', 'UTC'); - - $input = new \DateTime('2010-02-03 04:05:06 UTC'); - $output = $input->format('U'); - - $this->assertEquals($output, $transformer->transform($input)); - } - - public function testTransformEmpty() - { - $transformer = new DateTimeToTimestampTransformer(); - - $this->assertNull($transformer->transform(null)); - } - - public function testTransformWithDifferentTimezones() - { - $transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York'); - - $input = new \DateTime('2010-02-03 04:05:06 America/New_York'); - $output = $input->format('U'); - $input->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); - - $this->assertEquals($output, $transformer->transform($input)); - } - - public function testTransformFromDifferentTimezone() - { - $transformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'UTC'); - - $input = new \DateTime('2010-02-03 04:05:06 Asia/Hong_Kong'); - - $dateTime = clone $input; - $dateTime->setTimezone(new \DateTimeZone('UTC')); - $output = $dateTime->format('U'); - - $this->assertEquals($output, $transformer->transform($input)); - } - - public function testTransformExpectsDateTime() - { - $transformer = new DateTimeToTimestampTransformer(); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $transformer->transform('1234'); - } - - public function testReverseTransform() - { - $reverseTransformer = new DateTimeToTimestampTransformer('UTC', 'UTC'); - - $output = new \DateTime('2010-02-03 04:05:06 UTC'); - $input = $output->format('U'); - - $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); - } - - public function testReverseTransformEmpty() - { - $reverseTransformer = new DateTimeToTimestampTransformer(); - - $this->assertNull($reverseTransformer->reverseTransform(null)); - } - - public function testReverseTransformWithDifferentTimezones() - { - $reverseTransformer = new DateTimeToTimestampTransformer('Asia/Hong_Kong', 'America/New_York'); - - $output = new \DateTime('2010-02-03 04:05:06 America/New_York'); - $input = $output->format('U'); - $output->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); - - $this->assertDateTimeEquals($output, $reverseTransformer->reverseTransform($input)); - } - - public function testReverseTransformExpectsValidTimestamp() - { - $reverseTransformer = new DateTimeToTimestampTransformer(); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $reverseTransformer->reverseTransform('2010-2010-2010'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php deleted file mode 100644 index 840134da9..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php +++ /dev/null @@ -1,237 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\IntegerToLocalizedStringTransformer; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class IntegerToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - parent::setUp(); - - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - } - - public function transformWithRoundingProvider() - { - return array( - // towards positive infinity (1.6 -> 2, -1.6 -> -1) - array(1234.5, '1235', IntegerToLocalizedStringTransformer::ROUND_CEILING), - array(1234.4, '1235', IntegerToLocalizedStringTransformer::ROUND_CEILING), - array(-1234.5, '-1234', IntegerToLocalizedStringTransformer::ROUND_CEILING), - array(-1234.4, '-1234', IntegerToLocalizedStringTransformer::ROUND_CEILING), - // towards negative infinity (1.6 -> 1, -1.6 -> -2) - array(1234.5, '1234', IntegerToLocalizedStringTransformer::ROUND_FLOOR), - array(1234.4, '1234', IntegerToLocalizedStringTransformer::ROUND_FLOOR), - array(-1234.5, '-1235', IntegerToLocalizedStringTransformer::ROUND_FLOOR), - array(-1234.4, '-1235', IntegerToLocalizedStringTransformer::ROUND_FLOOR), - // away from zero (1.6 -> 2, -1.6 -> 2) - array(1234.5, '1235', IntegerToLocalizedStringTransformer::ROUND_UP), - array(1234.4, '1235', IntegerToLocalizedStringTransformer::ROUND_UP), - array(-1234.5, '-1235', IntegerToLocalizedStringTransformer::ROUND_UP), - array(-1234.4, '-1235', IntegerToLocalizedStringTransformer::ROUND_UP), - // towards zero (1.6 -> 1, -1.6 -> -1) - array(1234.5, '1234', IntegerToLocalizedStringTransformer::ROUND_DOWN), - array(1234.4, '1234', IntegerToLocalizedStringTransformer::ROUND_DOWN), - array(-1234.5, '-1234', IntegerToLocalizedStringTransformer::ROUND_DOWN), - array(-1234.4, '-1234', IntegerToLocalizedStringTransformer::ROUND_DOWN), - // round halves (.5) to the next even number - array(1234.6, '1235', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1234.5, '1234', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1234.4, '1234', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1233.5, '1234', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1232.5, '1232', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(-1234.6, '-1235', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(-1234.5, '-1234', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(-1234.4, '-1234', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(-1233.5, '-1234', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(-1232.5, '-1232', IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - // round halves (.5) away from zero - array(1234.6, '1235', IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array(1234.5, '1235', IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array(1234.4, '1234', IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array(-1234.6, '-1235', IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array(-1234.5, '-1235', IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array(-1234.4, '-1234', IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - // round halves (.5) towards zero - array(1234.6, '1235', IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1234.5, '1234', IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1234.4, '1234', IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(-1234.6, '-1235', IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(-1234.5, '-1234', IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(-1234.4, '-1234', IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - ); - } - - /** - * @dataProvider transformWithRoundingProvider - */ - public function testTransformWithRounding($input, $output, $roundingMode) - { - $transformer = new IntegerToLocalizedStringTransformer(null, null, $roundingMode); - - $this->assertEquals($output, $transformer->transform($input)); - } - - public function testReverseTransform() - { - $transformer = new IntegerToLocalizedStringTransformer(); - - $this->assertEquals(1, $transformer->reverseTransform('1')); - $this->assertEquals(1, $transformer->reverseTransform('1,5')); - $this->assertEquals(1234, $transformer->reverseTransform('1234,5')); - $this->assertEquals(12345, $transformer->reverseTransform('12345,912')); - } - - public function testReverseTransformEmpty() - { - $transformer = new IntegerToLocalizedStringTransformer(); - - $this->assertNull($transformer->reverseTransform('')); - } - - public function testReverseTransformWithGrouping() - { - $transformer = new IntegerToLocalizedStringTransformer(null, true); - - $this->assertEquals(1234, $transformer->reverseTransform('1.234,5')); - $this->assertEquals(12345, $transformer->reverseTransform('12.345,912')); - $this->assertEquals(1234, $transformer->reverseTransform('1234,5')); - $this->assertEquals(12345, $transformer->reverseTransform('12345,912')); - } - - public function reverseTransformWithRoundingProvider() - { - return array( - // towards positive infinity (1.6 -> 2, -1.6 -> -1) - array('1234,5', 1235, IntegerToLocalizedStringTransformer::ROUND_CEILING), - array('1234,4', 1235, IntegerToLocalizedStringTransformer::ROUND_CEILING), - array('-1234,5', -1234, IntegerToLocalizedStringTransformer::ROUND_CEILING), - array('-1234,4', -1234, IntegerToLocalizedStringTransformer::ROUND_CEILING), - // towards negative infinity (1.6 -> 1, -1.6 -> -2) - array('1234,5', 1234, IntegerToLocalizedStringTransformer::ROUND_FLOOR), - array('1234,4', 1234, IntegerToLocalizedStringTransformer::ROUND_FLOOR), - array('-1234,5', -1235, IntegerToLocalizedStringTransformer::ROUND_FLOOR), - array('-1234,4', -1235, IntegerToLocalizedStringTransformer::ROUND_FLOOR), - // away from zero (1.6 -> 2, -1.6 -> 2) - array('1234,5', 1235, IntegerToLocalizedStringTransformer::ROUND_UP), - array('1234,4', 1235, IntegerToLocalizedStringTransformer::ROUND_UP), - array('-1234,5', -1235, IntegerToLocalizedStringTransformer::ROUND_UP), - array('-1234,4', -1235, IntegerToLocalizedStringTransformer::ROUND_UP), - // towards zero (1.6 -> 1, -1.6 -> -1) - array('1234,5', 1234, IntegerToLocalizedStringTransformer::ROUND_DOWN), - array('1234,4', 1234, IntegerToLocalizedStringTransformer::ROUND_DOWN), - array('-1234,5', -1234, IntegerToLocalizedStringTransformer::ROUND_DOWN), - array('-1234,4', -1234, IntegerToLocalizedStringTransformer::ROUND_DOWN), - // round halves (.5) to the next even number - array('1234,6', 1235, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('1234,5', 1234, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('1234,4', 1234, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('1233,5', 1234, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('1232,5', 1232, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('-1234,6', -1235, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('-1234,5', -1234, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('-1234,4', -1234, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('-1233,5', -1234, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - array('-1232,5', -1232, IntegerToLocalizedStringTransformer::ROUND_HALF_EVEN), - // round halves (.5) away from zero - array('1234,6', 1235, IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array('1234,5', 1235, IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array('1234,4', 1234, IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array('-1234,6', -1235, IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array('-1234,5', -1235, IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - array('-1234,4', -1234, IntegerToLocalizedStringTransformer::ROUND_HALF_UP), - // round halves (.5) towards zero - array('1234,6', 1235, IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array('1234,5', 1234, IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array('1234,4', 1234, IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array('-1234,6', -1235, IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array('-1234,5', -1234, IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - array('-1234,4', -1234, IntegerToLocalizedStringTransformer::ROUND_HALF_DOWN), - ); - } - - /** - * @dataProvider reverseTransformWithRoundingProvider - */ - public function testReverseTransformWithRounding($input, $output, $roundingMode) - { - $transformer = new IntegerToLocalizedStringTransformer(null, null, $roundingMode); - - $this->assertEquals($output, $transformer->reverseTransform($input)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformExpectsString() - { - $transformer = new IntegerToLocalizedStringTransformer(); - - $transformer->reverseTransform(1); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformExpectsValidNumber() - { - $transformer = new IntegerToLocalizedStringTransformer(); - - $transformer->reverseTransform('foo'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsNaN() - { - $transformer = new IntegerToLocalizedStringTransformer(); - - $transformer->reverseTransform('NaN'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsNaN2() - { - $transformer = new IntegerToLocalizedStringTransformer(); - - $transformer->reverseTransform('nan'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsInfinity() - { - $transformer = new IntegerToLocalizedStringTransformer(); - - $transformer->reverseTransform('∞'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsNegativeInfinity() - { - $transformer = new IntegerToLocalizedStringTransformer(); - - $transformer->reverseTransform('-∞'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php deleted file mode 100644 index 8b91fe10a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\MoneyToLocalizedStringTransformer; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class MoneyToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - parent::setUp(); - - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - } - - public function testTransform() - { - $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); - - $this->assertEquals('1,23', $transformer->transform(123)); - } - - public function testTransformExpectsNumeric() - { - $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $transformer->transform('abcd'); - } - - public function testTransformEmpty() - { - $transformer = new MoneyToLocalizedStringTransformer(); - - $this->assertSame('', $transformer->transform(null)); - } - - public function testReverseTransform() - { - $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); - - $this->assertEquals(123, $transformer->reverseTransform('1,23')); - } - - public function testReverseTransformExpectsString() - { - $transformer = new MoneyToLocalizedStringTransformer(null, null, null, 100); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $transformer->reverseTransform(12345); - } - - public function testReverseTransformEmpty() - { - $transformer = new MoneyToLocalizedStringTransformer(); - - $this->assertNull($transformer->reverseTransform('')); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php deleted file mode 100644 index d66216ac4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php +++ /dev/null @@ -1,596 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\NumberToLocalizedStringTransformer; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class NumberToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - parent::setUp(); - - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - } - - public function provideTransformations() - { - return array( - array(null, '', 'de_AT'), - array(1, '1', 'de_AT'), - array(1.5, '1,5', 'de_AT'), - array(1234.5, '1234,5', 'de_AT'), - array(12345.912, '12345,912', 'de_AT'), - array(1234.5, '1234,5', 'ru'), - array(1234.5, '1234,5', 'fi'), - ); - } - - /** - * @dataProvider provideTransformations - */ - public function testTransform($from, $to, $locale) - { - \Locale::setDefault($locale); - - $transformer = new NumberToLocalizedStringTransformer(); - - $this->assertSame($to, $transformer->transform($from)); - } - - public function provideTransformationsWithGrouping() - { - return array( - array(1234.5, '1.234,5', 'de_AT'), - array(12345.912, '12.345,912', 'de_AT'), - array(1234.5, '1 234,5', 'fr'), - array(1234.5, '1 234,5', 'ru'), - array(1234.5, '1 234,5', 'fi'), - ); - } - - /** - * @dataProvider provideTransformationsWithGrouping - */ - public function testTransformWithGrouping($from, $to, $locale) - { - \Locale::setDefault($locale); - - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $this->assertSame($to, $transformer->transform($from)); - } - - public function testTransformWithPrecision() - { - $transformer = new NumberToLocalizedStringTransformer(2); - - $this->assertEquals('1234,50', $transformer->transform(1234.5)); - $this->assertEquals('678,92', $transformer->transform(678.916)); - } - - public function transformWithRoundingProvider() - { - return array( - // towards positive infinity (1.6 -> 2, -1.6 -> -1) - array(0, 1234.5, '1235', NumberToLocalizedStringTransformer::ROUND_CEILING), - array(0, 1234.4, '1235', NumberToLocalizedStringTransformer::ROUND_CEILING), - array(0, -1234.5, '-1234', NumberToLocalizedStringTransformer::ROUND_CEILING), - array(0, -1234.4, '-1234', NumberToLocalizedStringTransformer::ROUND_CEILING), - array(1, 123.45, '123,5', NumberToLocalizedStringTransformer::ROUND_CEILING), - array(1, 123.44, '123,5', NumberToLocalizedStringTransformer::ROUND_CEILING), - array(1, -123.45, '-123,4', NumberToLocalizedStringTransformer::ROUND_CEILING), - array(1, -123.44, '-123,4', NumberToLocalizedStringTransformer::ROUND_CEILING), - // towards negative infinity (1.6 -> 1, -1.6 -> -2) - array(0, 1234.5, '1234', NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(0, 1234.4, '1234', NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(0, -1234.5, '-1235', NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(0, -1234.4, '-1235', NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(1, 123.45, '123,4', NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(1, 123.44, '123,4', NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(1, -123.45, '-123,5', NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(1, -123.44, '-123,5', NumberToLocalizedStringTransformer::ROUND_FLOOR), - // away from zero (1.6 -> 2, -1.6 -> 2) - array(0, 1234.5, '1235', NumberToLocalizedStringTransformer::ROUND_UP), - array(0, 1234.4, '1235', NumberToLocalizedStringTransformer::ROUND_UP), - array(0, -1234.5, '-1235', NumberToLocalizedStringTransformer::ROUND_UP), - array(0, -1234.4, '-1235', NumberToLocalizedStringTransformer::ROUND_UP), - array(1, 123.45, '123,5', NumberToLocalizedStringTransformer::ROUND_UP), - array(1, 123.44, '123,5', NumberToLocalizedStringTransformer::ROUND_UP), - array(1, -123.45, '-123,5', NumberToLocalizedStringTransformer::ROUND_UP), - array(1, -123.44, '-123,5', NumberToLocalizedStringTransformer::ROUND_UP), - // towards zero (1.6 -> 1, -1.6 -> -1) - array(0, 1234.5, '1234', NumberToLocalizedStringTransformer::ROUND_DOWN), - array(0, 1234.4, '1234', NumberToLocalizedStringTransformer::ROUND_DOWN), - array(0, -1234.5, '-1234', NumberToLocalizedStringTransformer::ROUND_DOWN), - array(0, -1234.4, '-1234', NumberToLocalizedStringTransformer::ROUND_DOWN), - array(1, 123.45, '123,4', NumberToLocalizedStringTransformer::ROUND_DOWN), - array(1, 123.44, '123,4', NumberToLocalizedStringTransformer::ROUND_DOWN), - array(1, -123.45, '-123,4', NumberToLocalizedStringTransformer::ROUND_DOWN), - array(1, -123.44, '-123,4', NumberToLocalizedStringTransformer::ROUND_DOWN), - // round halves (.5) to the next even number - array(0, 1234.6, '1235', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, 1234.5, '1234', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, 1234.4, '1234', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, 1233.5, '1234', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, 1232.5, '1232', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, -1234.6, '-1235', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, -1234.5, '-1234', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, -1234.4, '-1234', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, -1233.5, '-1234', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, -1232.5, '-1232', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, 123.46, '123,5', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, 123.45, '123,4', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, 123.44, '123,4', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, 123.35, '123,4', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, 123.25, '123,2', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, -123.46, '-123,5', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, -123.45, '-123,4', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, -123.44, '-123,4', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, -123.35, '-123,4', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, -123.25, '-123,2', NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - // round halves (.5) away from zero - array(0, 1234.6, '1235', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, 1234.5, '1235', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, 1234.4, '1234', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, -1234.6, '-1235', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, -1234.5, '-1235', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, -1234.4, '-1234', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, 123.46, '123,5', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, 123.45, '123,5', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, 123.44, '123,4', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, -123.46, '-123,5', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, -123.45, '-123,5', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, -123.44, '-123,4', NumberToLocalizedStringTransformer::ROUND_HALF_UP), - // round halves (.5) towards zero - array(0, 1234.6, '1235', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, 1234.5, '1234', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, 1234.4, '1234', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, -1234.6, '-1235', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, -1234.5, '-1234', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, -1234.4, '-1234', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, 123.46, '123,5', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, 123.45, '123,4', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, 123.44, '123,4', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, -123.46, '-123,5', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, -123.45, '-123,4', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, -123.44, '-123,4', NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - ); - } - - /** - * @dataProvider transformWithRoundingProvider - */ - public function testTransformWithRounding($precision, $input, $output, $roundingMode) - { - $transformer = new NumberToLocalizedStringTransformer($precision, null, $roundingMode); - - $this->assertEquals($output, $transformer->transform($input)); - } - - public function testTransformDoesNotRoundIfNoPrecision() - { - $transformer = new NumberToLocalizedStringTransformer(null, null, NumberToLocalizedStringTransformer::ROUND_DOWN); - - $this->assertEquals('1234,547', $transformer->transform(1234.547)); - } - - /** - * @dataProvider provideTransformations - */ - public function testReverseTransform($to, $from, $locale) - { - \Locale::setDefault($locale); - - $transformer = new NumberToLocalizedStringTransformer(); - - $this->assertEquals($to, $transformer->reverseTransform($from)); - } - - /** - * @dataProvider provideTransformationsWithGrouping - */ - public function testReverseTransformWithGrouping($to, $from, $locale) - { - \Locale::setDefault($locale); - - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $this->assertEquals($to, $transformer->reverseTransform($from)); - } - - // https://github.com/symfony/symfony/issues/7609 - public function testReverseTransformWithGroupingAndFixedSpaces() - { - if (!function_exists('mb_detect_encoding')) { - $this->markTestSkipped('The "mbstring" extension is required for this test.'); - } - - \Locale::setDefault('ru'); - - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $this->assertEquals(1234.5, $transformer->reverseTransform("1\xc2\xa0234,5")); - } - - public function testReverseTransformWithGroupingButWithoutGroupSeparator() - { - $transformer = new NumberToLocalizedStringTransformer(null, true); - - // omit group separator - $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); - $this->assertEquals(12345.912, $transformer->reverseTransform('12345,912')); - } - - public function reverseTransformWithRoundingProvider() - { - return array( - // towards positive infinity (1.6 -> 2, -1.6 -> -1) - array(0, '1234,5', 1235, NumberToLocalizedStringTransformer::ROUND_CEILING), - array(0, '1234,4', 1235, NumberToLocalizedStringTransformer::ROUND_CEILING), - array(0, '-1234,5', -1234, NumberToLocalizedStringTransformer::ROUND_CEILING), - array(0, '-1234,4', -1234, NumberToLocalizedStringTransformer::ROUND_CEILING), - array(1, '123,45', 123.5, NumberToLocalizedStringTransformer::ROUND_CEILING), - array(1, '123,44', 123.5, NumberToLocalizedStringTransformer::ROUND_CEILING), - array(1, '-123,45', -123.4, NumberToLocalizedStringTransformer::ROUND_CEILING), - array(1, '-123,44', -123.4, NumberToLocalizedStringTransformer::ROUND_CEILING), - // towards negative infinity (1.6 -> 1, -1.6 -> -2) - array(0, '1234,5', 1234, NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(0, '1234,4', 1234, NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(0, '-1234,5', -1235, NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(0, '-1234,4', -1235, NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(1, '123,45', 123.4, NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(1, '123,44', 123.4, NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(1, '-123,45', -123.5, NumberToLocalizedStringTransformer::ROUND_FLOOR), - array(1, '-123,44', -123.5, NumberToLocalizedStringTransformer::ROUND_FLOOR), - // away from zero (1.6 -> 2, -1.6 -> 2) - array(0, '1234,5', 1235, NumberToLocalizedStringTransformer::ROUND_UP), - array(0, '1234,4', 1235, NumberToLocalizedStringTransformer::ROUND_UP), - array(0, '-1234,5', -1235, NumberToLocalizedStringTransformer::ROUND_UP), - array(0, '-1234,4', -1235, NumberToLocalizedStringTransformer::ROUND_UP), - array(1, '123,45', 123.5, NumberToLocalizedStringTransformer::ROUND_UP), - array(1, '123,44', 123.5, NumberToLocalizedStringTransformer::ROUND_UP), - array(1, '-123,45', -123.5, NumberToLocalizedStringTransformer::ROUND_UP), - array(1, '-123,44', -123.5, NumberToLocalizedStringTransformer::ROUND_UP), - // towards zero (1.6 -> 1, -1.6 -> -1) - array(0, '1234,5', 1234, NumberToLocalizedStringTransformer::ROUND_DOWN), - array(0, '1234,4', 1234, NumberToLocalizedStringTransformer::ROUND_DOWN), - array(0, '-1234,5', -1234, NumberToLocalizedStringTransformer::ROUND_DOWN), - array(0, '-1234,4', -1234, NumberToLocalizedStringTransformer::ROUND_DOWN), - array(1, '123,45', 123.4, NumberToLocalizedStringTransformer::ROUND_DOWN), - array(1, '123,44', 123.4, NumberToLocalizedStringTransformer::ROUND_DOWN), - array(1, '-123,45', -123.4, NumberToLocalizedStringTransformer::ROUND_DOWN), - array(1, '-123,44', -123.4, NumberToLocalizedStringTransformer::ROUND_DOWN), - // round halves (.5) to the next even number - array(0, '1234,6', 1235, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '1234,5', 1234, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '1234,4', 1234, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '1233,5', 1234, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '1232,5', 1232, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '-1234,6', -1235, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '-1234,5', -1234, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '-1234,4', -1234, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '-1233,5', -1234, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(0, '-1232,5', -1232, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '123,46', 123.5, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '123,45', 123.4, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '123,44', 123.4, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '123,35', 123.4, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '123,25', 123.2, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '-123,46', -123.5, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '-123,45', -123.4, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '-123,44', -123.4, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '-123,35', -123.4, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - array(1, '-123,25', -123.2, NumberToLocalizedStringTransformer::ROUND_HALF_EVEN), - // round halves (.5) away from zero - array(0, '1234,6', 1235, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, '1234,5', 1235, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, '1234,4', 1234, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, '-1234,6', -1235, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, '-1234,5', -1235, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(0, '-1234,4', -1234, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, '123,46', 123.5, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, '123,45', 123.5, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, '123,44', 123.4, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, '-123,46', -123.5, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, '-123,45', -123.5, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - array(1, '-123,44', -123.4, NumberToLocalizedStringTransformer::ROUND_HALF_UP), - // round halves (.5) towards zero - array(0, '1234,6', 1235, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, '1234,5', 1234, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, '1234,4', 1234, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, '-1234,6', -1235, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, '-1234,5', -1234, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(0, '-1234,4', -1234, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, '123,46', 123.5, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, '123,45', 123.4, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, '123,44', 123.4, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, '-123,46', -123.5, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, '-123,45', -123.4, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - array(1, '-123,44', -123.4, NumberToLocalizedStringTransformer::ROUND_HALF_DOWN), - ); - } - - /** - * @dataProvider reverseTransformWithRoundingProvider - */ - public function testReverseTransformWithRounding($precision, $input, $output, $roundingMode) - { - $transformer = new NumberToLocalizedStringTransformer($precision, null, $roundingMode); - - $this->assertEquals($output, $transformer->reverseTransform($input)); - } - - public function testReverseTransformDoesNotRoundIfNoPrecision() - { - $transformer = new NumberToLocalizedStringTransformer(null, null, NumberToLocalizedStringTransformer::ROUND_DOWN); - - $this->assertEquals(1234.547, $transformer->reverseTransform('1234,547')); - } - - public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsNotDot() - { - \Locale::setDefault('fr'); - $transformer = new NumberToLocalizedStringTransformer(null, true); - - // completely valid format - $this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5')); - // accept dots - $this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5')); - // omit group separator - $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); - $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDot() - { - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $transformer->reverseTransform('1.234.5'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testDecimalSeparatorMayNotBeDotIfGroupingSeparatorIsDotWithNoGroupSep() - { - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $transformer->reverseTransform('1234.5'); - } - - public function testDecimalSeparatorMayBeDotIfGroupingSeparatorIsDotButNoGroupingUsed() - { - \Locale::setDefault('fr'); - $transformer = new NumberToLocalizedStringTransformer(); - - $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); - $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); - } - - public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsNotComma() - { - \Locale::setDefault('bg'); - $transformer = new NumberToLocalizedStringTransformer(null, true); - - // completely valid format - $this->assertEquals(1234.5, $transformer->reverseTransform('1 234.5')); - // accept commas - $this->assertEquals(1234.5, $transformer->reverseTransform('1 234,5')); - // omit group separator - $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); - $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsComma() - { - \Locale::setDefault('en'); - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $transformer->reverseTransform('1,234,5'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testDecimalSeparatorMayNotBeCommaIfGroupingSeparatorIsCommaWithNoGroupSep() - { - \Locale::setDefault('en'); - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $transformer->reverseTransform('1234,5'); - } - - public function testDecimalSeparatorMayBeCommaIfGroupingSeparatorIsCommaButNoGroupingUsed() - { - \Locale::setDefault('en'); - $transformer = new NumberToLocalizedStringTransformer(); - - $this->assertEquals(1234.5, $transformer->reverseTransform('1234,5')); - $this->assertEquals(1234.5, $transformer->reverseTransform('1234.5')); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testTransformExpectsNumeric() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->transform('foo'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformExpectsString() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform(1); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformExpectsValidNumber() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('foo'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - * - * @link https://github.com/symfony/symfony/issues/3161 - */ - public function testReverseTransformDisallowsNaN() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('NaN'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsNaN2() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('nan'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsInfinity() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('∞'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsInfinity2() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('∞,123'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsNegativeInfinity() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('-∞'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDisallowsLeadingExtraCharacters() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('foo123'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - * @expectedExceptionMessage The number contains unrecognized characters: "foo3" - */ - public function testReverseTransformDisallowsCenteredExtraCharacters() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('12foo3'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - * @expectedExceptionMessage The number contains unrecognized characters: "foo8" - */ - public function testReverseTransformDisallowsCenteredExtraCharactersMultibyte() - { - if (!function_exists('mb_detect_encoding')) { - $this->markTestSkipped('The "mbstring" extension is required for this test.'); - } - - \Locale::setDefault('ru'); - - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $transformer->reverseTransform("12\xc2\xa0345,67foo8"); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - * @expectedExceptionMessage The number contains unrecognized characters: "foo8" - */ - public function testReverseTransformIgnoresTrailingSpacesInExceptionMessage() - { - if (!function_exists('mb_detect_encoding')) { - $this->markTestSkipped('The "mbstring" extension is required for this test.'); - } - - \Locale::setDefault('ru'); - - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $transformer->reverseTransform("12\xc2\xa0345,67foo8 \xc2\xa0\t"); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - * @expectedExceptionMessage The number contains unrecognized characters: "foo" - */ - public function testReverseTransformDisallowsTrailingExtraCharacters() - { - $transformer = new NumberToLocalizedStringTransformer(); - - $transformer->reverseTransform('123foo'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - * @expectedExceptionMessage The number contains unrecognized characters: "foo" - */ - public function testReverseTransformDisallowsTrailingExtraCharactersMultibyte() - { - if (!function_exists('mb_detect_encoding')) { - $this->markTestSkipped('The "mbstring" extension is required for this test.'); - } - - \Locale::setDefault('ru'); - - $transformer = new NumberToLocalizedStringTransformer(null, true); - - $transformer->reverseTransform("12\xc2\xa0345,678foo"); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php deleted file mode 100644 index 104941c9b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php +++ /dev/null @@ -1,114 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\PercentToLocalizedStringTransformer; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class PercentToLocalizedStringTransformerTest extends \PHPUnit_Framework_TestCase -{ - protected function setUp() - { - parent::setUp(); - - // Since we test against "de_AT", we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - } - - public function testTransform() - { - $transformer = new PercentToLocalizedStringTransformer(); - - $this->assertEquals('10', $transformer->transform(0.1)); - $this->assertEquals('15', $transformer->transform(0.15)); - $this->assertEquals('12', $transformer->transform(0.1234)); - $this->assertEquals('200', $transformer->transform(2)); - } - - public function testTransformEmpty() - { - $transformer = new PercentToLocalizedStringTransformer(); - - $this->assertEquals('', $transformer->transform(null)); - } - - public function testTransformWithInteger() - { - $transformer = new PercentToLocalizedStringTransformer(null, 'integer'); - - $this->assertEquals('0', $transformer->transform(0.1)); - $this->assertEquals('1', $transformer->transform(1)); - $this->assertEquals('15', $transformer->transform(15)); - $this->assertEquals('16', $transformer->transform(15.9)); - } - - public function testTransformWithPrecision() - { - $transformer = new PercentToLocalizedStringTransformer(2); - - $this->assertEquals('12,34', $transformer->transform(0.1234)); - } - - public function testReverseTransform() - { - $transformer = new PercentToLocalizedStringTransformer(); - - $this->assertEquals(0.1, $transformer->reverseTransform('10')); - $this->assertEquals(0.15, $transformer->reverseTransform('15')); - $this->assertEquals(0.12, $transformer->reverseTransform('12')); - $this->assertEquals(2, $transformer->reverseTransform('200')); - } - - public function testReverseTransformEmpty() - { - $transformer = new PercentToLocalizedStringTransformer(); - - $this->assertNull($transformer->reverseTransform('')); - } - - public function testReverseTransformWithInteger() - { - $transformer = new PercentToLocalizedStringTransformer(null, 'integer'); - - $this->assertEquals(10, $transformer->reverseTransform('10')); - $this->assertEquals(15, $transformer->reverseTransform('15')); - $this->assertEquals(12, $transformer->reverseTransform('12')); - $this->assertEquals(200, $transformer->reverseTransform('200')); - } - - public function testReverseTransformWithPrecision() - { - $transformer = new PercentToLocalizedStringTransformer(2); - - $this->assertEquals(0.1234, $transformer->reverseTransform('12,34')); - } - - public function testTransformExpectsNumeric() - { - $transformer = new PercentToLocalizedStringTransformer(); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $transformer->transform('foo'); - } - - public function testReverseTransformExpectsString() - { - $transformer = new PercentToLocalizedStringTransformer(); - - $this->setExpectedException('Symfony\Component\Form\Exception\TransformationFailedException'); - - $transformer->reverseTransform(1); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php deleted file mode 100644 index 6dc9785c2..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/ValueToDuplicatesTransformerTest.php +++ /dev/null @@ -1,142 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\DataTransformer; - -use Symfony\Component\Form\Extension\Core\DataTransformer\ValueToDuplicatesTransformer; - -class ValueToDuplicatesTransformerTest extends \PHPUnit_Framework_TestCase -{ - private $transformer; - - protected function setUp() - { - $this->transformer = new ValueToDuplicatesTransformer(array('a', 'b', 'c')); - } - - protected function tearDown() - { - $this->transformer = null; - } - - public function testTransform() - { - $output = array( - 'a' => 'Foo', - 'b' => 'Foo', - 'c' => 'Foo', - ); - - $this->assertSame($output, $this->transformer->transform('Foo')); - } - - public function testTransformEmpty() - { - $output = array( - 'a' => null, - 'b' => null, - 'c' => null, - ); - - $this->assertSame($output, $this->transformer->transform(null)); - } - - public function testReverseTransform() - { - $input = array( - 'a' => 'Foo', - 'b' => 'Foo', - 'c' => 'Foo', - ); - - $this->assertSame('Foo', $this->transformer->reverseTransform($input)); - } - - public function testReverseTransformCompletelyEmpty() - { - $input = array( - 'a' => '', - 'b' => '', - 'c' => '', - ); - - $this->assertNull($this->transformer->reverseTransform($input)); - } - - public function testReverseTransformCompletelyNull() - { - $input = array( - 'a' => null, - 'b' => null, - 'c' => null, - ); - - $this->assertNull($this->transformer->reverseTransform($input)); - } - - public function testReverseTransformEmptyArray() - { - $input = array( - 'a' => array(), - 'b' => array(), - 'c' => array(), - ); - - $this->assertNull($this->transformer->reverseTransform($input)); - } - - public function testReverseTransformZeroString() - { - $input = array( - 'a' => '0', - 'b' => '0', - 'c' => '0', - ); - - $this->assertSame('0', $this->transformer->reverseTransform($input)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformPartiallyNull() - { - $input = array( - 'a' => 'Foo', - 'b' => 'Foo', - 'c' => null, - ); - - $this->transformer->reverseTransform($input); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformDifferences() - { - $input = array( - 'a' => 'Foo', - 'b' => 'Bar', - 'c' => 'Foo', - ); - - $this->transformer->reverseTransform($input); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - */ - public function testReverseTransformRequiresArray() - { - $this->transformer->reverseTransform('12345'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php deleted file mode 100644 index 426293395..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixRadioInputListenerTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; - -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Extension\Core\EventListener\FixRadioInputListener; -use Symfony\Component\Form\Extension\Core\ChoiceList\SimpleChoiceList; - -class FixRadioInputListenerTest extends \PHPUnit_Framework_TestCase -{ - private $choiceList; - - protected function setUp() - { - parent::setUp(); - - $this->choiceList = new SimpleChoiceList(array('' => 'Empty', 0 => 'A', 1 => 'B')); - } - - protected function tearDown() - { - parent::tearDown(); - - $listener = null; - } - - public function testFixRadio() - { - $data = '1'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $listener = new FixRadioInputListener($this->choiceList, true); - $listener->preSubmit($event); - - // Indices in SimpleChoiceList are zero-based generated integers - $this->assertEquals(array(2 => '1'), $event->getData()); - } - - public function testFixZero() - { - $data = '0'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $listener = new FixRadioInputListener($this->choiceList, true); - $listener->preSubmit($event); - - // Indices in SimpleChoiceList are zero-based generated integers - $this->assertEquals(array(1 => '0'), $event->getData()); - } - - public function testFixEmptyString() - { - $data = ''; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $listener = new FixRadioInputListener($this->choiceList, true); - $listener->preSubmit($event); - - // Indices in SimpleChoiceList are zero-based generated integers - $this->assertEquals(array(0 => ''), $event->getData()); - } - - public function testConvertEmptyStringToPlaceholderIfNotFound() - { - $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B')); - - $data = ''; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $listener = new FixRadioInputListener($list, true); - $listener->preSubmit($event); - - $this->assertEquals(array('placeholder' => ''), $event->getData()); - } - - public function testDontConvertEmptyStringToPlaceholderIfNoPlaceholderUsed() - { - $list = new SimpleChoiceList(array(0 => 'A', 1 => 'B')); - - $data = ''; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $listener = new FixRadioInputListener($list, false); - $listener->preSubmit($event); - - $this->assertEquals(array(), $event->getData()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php deleted file mode 100644 index a971ea215..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/FixUrlProtocolListenerTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; - -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Extension\Core\EventListener\FixUrlProtocolListener; - -class FixUrlProtocolListenerTest extends \PHPUnit_Framework_TestCase -{ - public function testFixHttpUrl() - { - $data = 'www.symfony.com'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $filter = new FixUrlProtocolListener('http'); - $filter->onSubmit($event); - - $this->assertEquals('http://www.symfony.com', $event->getData()); - } - - public function testSkipKnownUrl() - { - $data = 'http://www.symfony.com'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $filter = new FixUrlProtocolListener('http'); - $filter->onSubmit($event); - - $this->assertEquals('http://www.symfony.com', $event->getData()); - } - - public function testSkipOtherProtocol() - { - $data = 'ftp://www.symfony.com'; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $filter = new FixUrlProtocolListener('http'); - $filter->onSubmit($event); - - $this->assertEquals('ftp://www.symfony.com', $event->getData()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash deleted file mode 100644 index b636f4b8d..000000000 Binary files a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/Fixtures/randomhash and /dev/null differ diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php deleted file mode 100644 index 6f46c9d7f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; - -use Symfony\Component\Form\FormBuilder; - -class MergeCollectionListenerArrayObjectTest extends MergeCollectionListenerTest -{ - protected function getData(array $data) - { - return new \ArrayObject($data); - } - - protected function getBuilder($name = 'name') - { - return new FormBuilder($name, '\ArrayObject', $this->dispatcher, $this->factory); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php deleted file mode 100644 index c0f3d5973..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; - -use Symfony\Component\Form\FormBuilder; - -class MergeCollectionListenerArrayTest extends MergeCollectionListenerTest -{ - protected function getData(array $data) - { - return $data; - } - - protected function getBuilder($name = 'name') - { - return new FormBuilder($name, null, $this->dispatcher, $this->factory); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php deleted file mode 100644 index 5eb6c7b9f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerCustomArrayObjectTest.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; - -use Symfony\Component\Form\Tests\Fixtures\CustomArrayObject; -use Symfony\Component\Form\FormBuilder; - -class MergeCollectionListenerCustomArrayObjectTest extends MergeCollectionListenerTest -{ - protected function getData(array $data) - { - return new CustomArrayObject($data); - } - - protected function getBuilder($name = 'name') - { - return new FormBuilder($name, 'Symfony\Component\Form\Tests\Fixtures\CustomArrayObject', $this->dispatcher, $this->factory); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php deleted file mode 100644 index 2d7ecfec7..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerTest.php +++ /dev/null @@ -1,255 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; - -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Extension\Core\EventListener\MergeCollectionListener; - -abstract class MergeCollectionListenerTest extends \PHPUnit_Framework_TestCase -{ - protected $dispatcher; - protected $factory; - protected $form; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->form = $this->getForm('axes'); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->factory = null; - $this->form = null; - } - - abstract protected function getBuilder($name = 'name'); - - protected function getForm($name = 'name', $propertyPath = null) - { - $propertyPath = $propertyPath ?: $name; - - return $this->getBuilder($name)->setAttribute('property_path', $propertyPath)->getForm(); - } - - protected function getMockForm() - { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); - } - - public function getBooleanMatrix1() - { - return array( - array(true), - array(false), - ); - } - - public function getBooleanMatrix2() - { - return array( - array(true, true), - array(true, false), - array(false, true), - array(false, false), - ); - } - - abstract protected function getData(array $data); - - /** - * @dataProvider getBooleanMatrix1 - */ - public function testAddExtraEntriesIfAllowAdd($allowDelete) - { - $originalData = $this->getData(array(1 => 'second')); - $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); - - $listener = new MergeCollectionListener(true, $allowDelete); - - $this->form->setData($originalData); - - $event = new FormEvent($this->form, $newData); - $listener->onSubmit($event); - - // The original object was modified - if (is_object($originalData)) { - $this->assertSame($originalData, $event->getData()); - } - - // The original object matches the new object - $this->assertEquals($newData, $event->getData()); - } - - /** - * @dataProvider getBooleanMatrix1 - */ - public function testAddExtraEntriesIfAllowAddDontOverwriteExistingIndices($allowDelete) - { - $originalData = $this->getData(array(1 => 'first')); - $newData = $this->getData(array(0 => 'first', 1 => 'second')); - - $listener = new MergeCollectionListener(true, $allowDelete); - - $this->form->setData($originalData); - - $event = new FormEvent($this->form, $newData); - $listener->onSubmit($event); - - // The original object was modified - if (is_object($originalData)) { - $this->assertSame($originalData, $event->getData()); - } - - // The original object matches the new object - $this->assertEquals($this->getData(array(1 => 'first', 2 => 'second')), $event->getData()); - } - - /** - * @dataProvider getBooleanMatrix1 - */ - public function testDoNothingIfNotAllowAdd($allowDelete) - { - $originalDataArray = array(1 => 'second'); - $originalData = $this->getData($originalDataArray); - $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); - - $listener = new MergeCollectionListener(false, $allowDelete); - - $this->form->setData($originalData); - - $event = new FormEvent($this->form, $newData); - $listener->onSubmit($event); - - // We still have the original object - if (is_object($originalData)) { - $this->assertSame($originalData, $event->getData()); - } - - // Nothing was removed - $this->assertEquals($this->getData($originalDataArray), $event->getData()); - } - - /** - * @dataProvider getBooleanMatrix1 - */ - public function testRemoveMissingEntriesIfAllowDelete($allowAdd) - { - $originalData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); - $newData = $this->getData(array(1 => 'second')); - - $listener = new MergeCollectionListener($allowAdd, true); - - $this->form->setData($originalData); - - $event = new FormEvent($this->form, $newData); - $listener->onSubmit($event); - - // The original object was modified - if (is_object($originalData)) { - $this->assertSame($originalData, $event->getData()); - } - - // The original object matches the new object - $this->assertEquals($newData, $event->getData()); - } - - /** - * @dataProvider getBooleanMatrix1 - */ - public function testDoNothingIfNotAllowDelete($allowAdd) - { - $originalDataArray = array(0 => 'first', 1 => 'second', 2 => 'third'); - $originalData = $this->getData($originalDataArray); - $newData = $this->getData(array(1 => 'second')); - - $listener = new MergeCollectionListener($allowAdd, false); - - $this->form->setData($originalData); - - $event = new FormEvent($this->form, $newData); - $listener->onSubmit($event); - - // We still have the original object - if (is_object($originalData)) { - $this->assertSame($originalData, $event->getData()); - } - - // Nothing was removed - $this->assertEquals($this->getData($originalDataArray), $event->getData()); - } - - /** - * @dataProvider getBooleanMatrix2 - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testRequireArrayOrTraversable($allowAdd, $allowDelete) - { - $newData = 'no array or traversable'; - $event = new FormEvent($this->form, $newData); - $listener = new MergeCollectionListener($allowAdd, $allowDelete); - $listener->onSubmit($event); - } - - public function testDealWithNullData() - { - $originalData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); - $newData = null; - - $listener = new MergeCollectionListener(false, false); - - $this->form->setData($originalData); - - $event = new FormEvent($this->form, $newData); - $listener->onSubmit($event); - - $this->assertSame($originalData, $event->getData()); - } - - /** - * @dataProvider getBooleanMatrix1 - */ - public function testDealWithNullOriginalDataIfAllowAdd($allowDelete) - { - $originalData = null; - $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); - - $listener = new MergeCollectionListener(true, $allowDelete); - - $this->form->setData($originalData); - - $event = new FormEvent($this->form, $newData); - $listener->onSubmit($event); - - $this->assertSame($newData, $event->getData()); - } - - /** - * @dataProvider getBooleanMatrix1 - */ - public function testDontDealWithNullOriginalDataIfNotAllowAdd($allowDelete) - { - $originalData = null; - $newData = $this->getData(array(0 => 'first', 1 => 'second', 2 => 'third')); - - $listener = new MergeCollectionListener(false, $allowDelete); - - $this->form->setData($originalData); - - $event = new FormEvent($this->form, $newData); - $listener->onSubmit($event); - - $this->assertNull($event->getData()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php deleted file mode 100644 index bcfae9e06..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/ResizeFormListenerTest.php +++ /dev/null @@ -1,278 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; - -use Doctrine\Common\Collections\ArrayCollection; -use Symfony\Component\Form\Extension\Core\EventListener\ResizeFormListener; -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\FormEvent; - -class ResizeFormListenerTest extends \PHPUnit_Framework_TestCase -{ - private $dispatcher; - private $factory; - private $form; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->form = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->factory = null; - $this->form = null; - } - - protected function getBuilder($name = 'name') - { - return new FormBuilder($name, null, $this->dispatcher, $this->factory); - } - - protected function getForm($name = 'name') - { - return $this->getBuilder($name)->getForm(); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getDataMapper() - { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); - } - - protected function getMockForm() - { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); - } - - public function testPreSetDataResizesForm() - { - $this->form->add($this->getForm('0')); - $this->form->add($this->getForm('1')); - - $this->factory->expects($this->at(0)) - ->method('createNamed') - ->with(1, 'text', null, array('property_path' => '[1]', 'attr' => array('maxlength' => 10), 'auto_initialize' => false)) - ->will($this->returnValue($this->getForm('1'))); - $this->factory->expects($this->at(1)) - ->method('createNamed') - ->with(2, 'text', null, array('property_path' => '[2]', 'attr' => array('maxlength' => 10), 'auto_initialize' => false)) - ->will($this->returnValue($this->getForm('2'))); - - $data = array(1 => 'string', 2 => 'string'); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array('attr' => array('maxlength' => 10)), false, false); - $listener->preSetData($event); - - $this->assertFalse($this->form->has('0')); - $this->assertTrue($this->form->has('1')); - $this->assertTrue($this->form->has('2')); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testPreSetDataRequiresArrayOrTraversable() - { - $data = 'no array or traversable'; - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, false); - $listener->preSetData($event); - } - - public function testPreSetDataDealsWithNullData() - { - $this->factory->expects($this->never())->method('createNamed'); - - $data = null; - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, false); - $listener->preSetData($event); - } - - public function testPreSubmitResizesUpIfAllowAdd() - { - $this->form->add($this->getForm('0')); - - $this->factory->expects($this->once()) - ->method('createNamed') - ->with(1, 'text', null, array('property_path' => '[1]', 'attr' => array('maxlength' => 10), 'auto_initialize' => false)) - ->will($this->returnValue($this->getForm('1'))); - - $data = array(0 => 'string', 1 => 'string'); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array('attr' => array('maxlength' => 10)), true, false); - $listener->preSubmit($event); - - $this->assertTrue($this->form->has('0')); - $this->assertTrue($this->form->has('1')); - } - - public function testPreSubmitResizesDownIfAllowDelete() - { - $this->form->add($this->getForm('0')); - $this->form->add($this->getForm('1')); - - $data = array(0 => 'string'); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, true); - $listener->preSubmit($event); - - $this->assertTrue($this->form->has('0')); - $this->assertFalse($this->form->has('1')); - } - - // fix for https://github.com/symfony/symfony/pull/493 - public function testPreSubmitRemovesZeroKeys() - { - $this->form->add($this->getForm('0')); - - $data = array(); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, true); - $listener->preSubmit($event); - - $this->assertFalse($this->form->has('0')); - } - - public function testPreSubmitDoesNothingIfNotAllowAddNorAllowDelete() - { - $this->form->add($this->getForm('0')); - $this->form->add($this->getForm('1')); - - $data = array(0 => 'string', 2 => 'string'); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, false); - $listener->preSubmit($event); - - $this->assertTrue($this->form->has('0')); - $this->assertTrue($this->form->has('1')); - $this->assertFalse($this->form->has('2')); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testPreSubmitRequiresArrayOrTraversable() - { - $data = 'no array or traversable'; - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, false); - $listener->preSubmit($event); - } - - public function testPreSubmitDealsWithNullData() - { - $this->form->add($this->getForm('1')); - - $data = null; - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, true); - $listener->preSubmit($event); - - $this->assertFalse($this->form->has('1')); - } - - // fixes https://github.com/symfony/symfony/pull/40 - public function testPreSubmitDealsWithEmptyData() - { - $this->form->add($this->getForm('1')); - - $data = ''; - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, true); - $listener->preSubmit($event); - - $this->assertFalse($this->form->has('1')); - } - - public function testOnSubmitNormDataRemovesEntriesMissingInTheFormIfAllowDelete() - { - $this->form->add($this->getForm('1')); - - $data = array(0 => 'first', 1 => 'second', 2 => 'third'); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, true); - $listener->onSubmit($event); - - $this->assertEquals(array(1 => 'second'), $event->getData()); - } - - public function testOnSubmitNormDataDoesNothingIfNotAllowDelete() - { - $this->form->add($this->getForm('1')); - - $data = array(0 => 'first', 1 => 'second', 2 => 'third'); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, false); - $listener->onSubmit($event); - - $this->assertEquals($data, $event->getData()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testOnSubmitNormDataRequiresArrayOrTraversable() - { - $data = 'no array or traversable'; - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, false); - $listener->onSubmit($event); - } - - public function testOnSubmitNormDataDealsWithNullData() - { - $this->form->add($this->getForm('1')); - - $data = null; - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, true); - $listener->onSubmit($event); - - $this->assertEquals(array(), $event->getData()); - } - - public function testOnSubmitDealsWithObjectBackedIteratorAggregate() - { - $this->form->add($this->getForm('1')); - - $data = new \ArrayObject(array(0 => 'first', 1 => 'second', 2 => 'third')); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, true); - $listener->onSubmit($event); - - $this->assertArrayNotHasKey(0, $event->getData()); - $this->assertArrayNotHasKey(2, $event->getData()); - } - - public function testOnSubmitDealsWithArrayBackedIteratorAggregate() - { - $this->form->add($this->getForm('1')); - - $data = new ArrayCollection(array(0 => 'first', 1 => 'second', 2 => 'third')); - $event = new FormEvent($this->form, $data); - $listener = new ResizeFormListener('text', array(), false, true); - $listener->onSubmit($event); - - $this->assertArrayNotHasKey(0, $event->getData()); - $this->assertArrayNotHasKey(2, $event->getData()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php deleted file mode 100644 index 3818c7861..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/EventListener/TrimListenerTest.php +++ /dev/null @@ -1,105 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\EventListener; - -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Extension\Core\EventListener\TrimListener; - -class TrimListenerTest extends \PHPUnit_Framework_TestCase -{ - public function testTrim() - { - $data = ' Foo! '; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $filter = new TrimListener(); - $filter->preSubmit($event); - - $this->assertEquals('Foo!', $event->getData()); - } - - public function testTrimSkipNonStrings() - { - $data = 1234; - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $data); - - $filter = new TrimListener(); - $filter->preSubmit($event); - - $this->assertSame(1234, $event->getData()); - } - - /** - * @dataProvider spaceProvider - */ - public function testTrimUtf8Separators($hex) - { - if (!function_exists('mb_convert_encoding')) { - $this->markTestSkipped('The "mb_convert_encoding" function is not available'); - } - - // Convert hexadecimal representation into binary - // H: hex string, high nibble first (UCS-2BE) - // *: repeat until end of string - $binary = pack('H*', $hex); - - // Convert UCS-2BE to UTF-8 - $symbol = mb_convert_encoding($binary, 'UTF-8', 'UCS-2BE'); - $symbol = $symbol."ab\ncd".$symbol; - - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $event = new FormEvent($form, $symbol); - - $filter = new TrimListener(); - $filter->preSubmit($event); - - $this->assertSame("ab\ncd", $event->getData()); - } - - public function spaceProvider() - { - return array( - // separators - array('0020'), - array('00A0'), - array('1680'), -// array('180E'), - array('2000'), - array('2001'), - array('2002'), - array('2003'), - array('2004'), - array('2005'), - array('2006'), - array('2007'), - array('2008'), - array('2009'), - array('200A'), - array('2028'), - array('2029'), - array('202F'), - array('205F'), - array('3000'), - // controls - array('0009'), - array('000A'), - array('000B'), - array('000C'), - array('000D'), - array('0085'), - // zero width space -// array('200B'), - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php deleted file mode 100644 index 0048cf41c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BaseTypeTest.php +++ /dev/null @@ -1,135 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -/** - * @author Bernhard Schussek - */ -abstract class BaseTypeTest extends \Symfony\Component\Form\Test\TypeTestCase -{ - public function testPassDisabledAsOption() - { - $form = $this->factory->create($this->getTestedType(), null, array('disabled' => true)); - - $this->assertTrue($form->isDisabled()); - } - - public function testPassIdAndNameToView() - { - $view = $this->factory->createNamed('name', $this->getTestedType()) - ->createView(); - - $this->assertEquals('name', $view->vars['id']); - $this->assertEquals('name', $view->vars['name']); - $this->assertEquals('name', $view->vars['full_name']); - } - - public function testStripLeadingUnderscoresAndDigitsFromId() - { - $view = $this->factory->createNamed('_09name', $this->getTestedType()) - ->createView(); - - $this->assertEquals('name', $view->vars['id']); - $this->assertEquals('_09name', $view->vars['name']); - $this->assertEquals('_09name', $view->vars['full_name']); - } - - public function testPassIdAndNameToViewWithParent() - { - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', $this->getTestedType()) - ->getForm() - ->createView(); - - $this->assertEquals('parent_child', $view['child']->vars['id']); - $this->assertEquals('child', $view['child']->vars['name']); - $this->assertEquals('parent[child]', $view['child']->vars['full_name']); - } - - public function testPassIdAndNameToViewWithGrandParent() - { - $builder = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', 'form'); - $builder->get('child')->add('grand_child', $this->getTestedType()); - $view = $builder->getForm()->createView(); - - $this->assertEquals('parent_child_grand_child', $view['child']['grand_child']->vars['id']); - $this->assertEquals('grand_child', $view['child']['grand_child']->vars['name']); - $this->assertEquals('parent[child][grand_child]', $view['child']['grand_child']->vars['full_name']); - } - - public function testPassTranslationDomainToView() - { - $form = $this->factory->create($this->getTestedType(), null, array( - 'translation_domain' => 'domain', - )); - $view = $form->createView(); - - $this->assertSame('domain', $view->vars['translation_domain']); - } - - public function testInheritTranslationDomainFromParent() - { - $view = $this->factory - ->createNamedBuilder('parent', 'form', null, array( - 'translation_domain' => 'domain', - )) - ->add('child', $this->getTestedType()) - ->getForm() - ->createView(); - - $this->assertEquals('domain', $view['child']->vars['translation_domain']); - } - - public function testPreferOwnTranslationDomain() - { - $view = $this->factory - ->createNamedBuilder('parent', 'form', null, array( - 'translation_domain' => 'parent_domain', - )) - ->add('child', $this->getTestedType(), array( - 'translation_domain' => 'domain', - )) - ->getForm() - ->createView(); - - $this->assertEquals('domain', $view['child']->vars['translation_domain']); - } - - public function testDefaultTranslationDomain() - { - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', $this->getTestedType()) - ->getForm() - ->createView(); - - $this->assertNull($view['child']->vars['translation_domain']); - } - - public function testPassLabelToView() - { - $form = $this->factory->createNamed('__test___field', $this->getTestedType(), null, array('label' => 'My label')); - $view = $form->createView(); - - $this->assertSame('My label', $view->vars['label']); - } - - public function testPassMultipartFalseToView() - { - $form = $this->factory->create($this->getTestedType()); - $view = $form->createView(); - - $this->assertFalse($view->vars['multipart']); - } - - abstract protected function getTestedType(); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php deleted file mode 100644 index 755eac903..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/BirthdayTypeTest.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -/** - * @author Stepan Anchugov - */ -class BirthdayTypeTest extends BaseTypeTest -{ - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testSetInvalidYearsOption() - { - $this->factory->create('birthday', null, array( - 'years' => 'bad value', - )); - } - - protected function getTestedType() - { - return 'birthday'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php deleted file mode 100644 index 55835e77f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ButtonTypeTest.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -/** - * @author Bernhard Schussek - */ -class ButtonTypeTest extends BaseTypeTest -{ - public function testCreateButtonInstances() - { - $this->assertInstanceOf('Symfony\Component\Form\Button', $this->factory->create('button')); - } - - protected function getTestedType() - { - return 'button'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php deleted file mode 100644 index 9437bd7ee..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CheckboxTypeTest.php +++ /dev/null @@ -1,173 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\CallbackTransformer; - -class CheckboxTypeTest extends \Symfony\Component\Form\Test\TypeTestCase -{ - public function testDataIsFalseByDefault() - { - $form = $this->factory->create('checkbox'); - - $this->assertFalse($form->getData()); - $this->assertFalse($form->getNormData()); - $this->assertNull($form->getViewData()); - } - - public function testPassValueToView() - { - $form = $this->factory->create('checkbox', null, array('value' => 'foobar')); - $view = $form->createView(); - - $this->assertEquals('foobar', $view->vars['value']); - } - - public function testCheckedIfDataTrue() - { - $form = $this->factory->create('checkbox'); - $form->setData(true); - $view = $form->createView(); - - $this->assertTrue($view->vars['checked']); - } - - public function testCheckedIfDataTrueWithEmptyValue() - { - $form = $this->factory->create('checkbox', null, array('value' => '')); - $form->setData(true); - $view = $form->createView(); - - $this->assertTrue($view->vars['checked']); - } - - public function testNotCheckedIfDataFalse() - { - $form = $this->factory->create('checkbox'); - $form->setData(false); - $view = $form->createView(); - - $this->assertFalse($view->vars['checked']); - } - - public function testSubmitWithValueChecked() - { - $form = $this->factory->create('checkbox', null, array( - 'value' => 'foobar', - )); - $form->submit('foobar'); - - $this->assertTrue($form->getData()); - $this->assertEquals('foobar', $form->getViewData()); - } - - public function testSubmitWithRandomValueChecked() - { - $form = $this->factory->create('checkbox', null, array( - 'value' => 'foobar', - )); - $form->submit('krixikraxi'); - - $this->assertTrue($form->getData()); - $this->assertEquals('foobar', $form->getViewData()); - } - - public function testSubmitWithValueUnchecked() - { - $form = $this->factory->create('checkbox', null, array( - 'value' => 'foobar', - )); - $form->submit(null); - - $this->assertFalse($form->getData()); - $this->assertNull($form->getViewData()); - } - - public function testSubmitWithEmptyValueChecked() - { - $form = $this->factory->create('checkbox', null, array( - 'value' => '', - )); - $form->submit(''); - - $this->assertTrue($form->getData()); - $this->assertSame('', $form->getViewData()); - } - - public function testSubmitWithEmptyValueUnchecked() - { - $form = $this->factory->create('checkbox', null, array( - 'value' => '', - )); - $form->submit(null); - - $this->assertFalse($form->getData()); - $this->assertNull($form->getViewData()); - } - - public function testSubmitWithEmptyValueAndFalseUnchecked() - { - $form = $this->factory->create('checkbox', null, array( - 'value' => '', - )); - $form->submit(false); - - $this->assertFalse($form->getData()); - $this->assertNull($form->getViewData()); - } - - public function testSubmitWithEmptyValueAndTrueChecked() - { - $form = $this->factory->create('checkbox', null, array( - 'value' => '', - )); - $form->submit(true); - - $this->assertTrue($form->getData()); - $this->assertSame('', $form->getViewData()); - } - - /** - * @dataProvider provideCustomModelTransformerData - */ - public function testCustomModelTransformer($data, $checked) - { - // present a binary status field as a checkbox - $transformer = new CallbackTransformer( - function ($value) { - return 'checked' == $value; - }, - function ($value) { - return $value ? 'checked' : 'unchecked'; - } - ); - - $form = $this->factory->createBuilder('checkbox') - ->addModelTransformer($transformer) - ->getForm(); - - $form->setData($data); - $view = $form->createView(); - - $this->assertSame($data, $form->getData()); - $this->assertSame($checked, $form->getNormData()); - $this->assertEquals($checked, $view->vars['checked']); - } - - public function provideCustomModelTransformerData() - { - return array( - array('checked', true), - array('unchecked', false), - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php deleted file mode 100644 index 0685946fc..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Test\FormPerformanceTestCase; - -/** - * @author Bernhard Schussek - */ -class ChoiceTypePerformanceTest extends FormPerformanceTestCase -{ - /** - * This test case is realistic in collection forms where each - * row contains the same choice field. - * - * @group benchmark - */ - public function testSameChoiceFieldCreatedMultipleTimes() - { - $this->setMaxRunningTime(1); - $choices = range(1, 300); - - for ($i = 0; $i < 100; ++$i) { - $this->factory->create('choice', rand(1, 400), array( - 'choices' => $choices, - )); - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php deleted file mode 100644 index 17972cbc0..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypeTest.php +++ /dev/null @@ -1,1287 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Extension\Core\ChoiceList\ObjectChoiceList; -use Symfony\Component\Form\Extension\Core\View\ChoiceView; - -class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase -{ - private $choices = array( - 'a' => 'Bernhard', - 'b' => 'Fabien', - 'c' => 'Kris', - 'd' => 'Jon', - 'e' => 'Roman', - ); - - private $numericChoices = array( - 0 => 'Bernhard', - 1 => 'Fabien', - 2 => 'Kris', - 3 => 'Jon', - 4 => 'Roman', - ); - - private $objectChoices; - - protected $groupedChoices = array( - 'Symfony' => array( - 'a' => 'Bernhard', - 'b' => 'Fabien', - 'c' => 'Kris', - ), - 'Doctrine' => array( - 'd' => 'Jon', - 'e' => 'Roman', - ), - ); - - protected function setUp() - { - parent::setUp(); - - $this->objectChoices = array( - (object) array('id' => 1, 'name' => 'Bernhard'), - (object) array('id' => 2, 'name' => 'Fabien'), - (object) array('id' => 3, 'name' => 'Kris'), - (object) array('id' => 4, 'name' => 'Jon'), - (object) array('id' => 5, 'name' => 'Roman'), - ); - } - - protected function tearDown() - { - parent::tearDown(); - - $this->objectChoices = null; - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testChoiceListOptionExpectsChoiceListInterface() - { - $this->factory->create('choice', null, array( - 'choice_list' => array('foo' => 'foo'), - )); - } - - public function testChoiceListAndChoicesCanBeEmpty() - { - $this->factory->create('choice'); - } - - public function testExpandedChoicesOptionsTurnIntoChildren() - { - $form = $this->factory->create('choice', null, array( - 'expanded' => true, - 'choices' => $this->choices, - )); - - $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); - } - - public function testPlaceholderPresentOnNonRequiredExpandedSingleChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'choices' => $this->choices, - )); - - $this->assertTrue(isset($form['placeholder'])); - $this->assertCount(count($this->choices) + 1, $form, 'Each choice should become a new field'); - } - - public function testPlaceholderNotPresentIfRequired() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => true, - 'choices' => $this->choices, - )); - - $this->assertFalse(isset($form['placeholder'])); - $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); - } - - public function testPlaceholderNotPresentIfMultiple() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'required' => false, - 'choices' => $this->choices, - )); - - $this->assertFalse(isset($form['placeholder'])); - $this->assertCount(count($this->choices), $form, 'Each choice should become a new field'); - } - - public function testPlaceholderNotPresentIfEmptyChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'choices' => array( - '' => 'Empty', - 1 => 'Not empty', - ), - )); - - $this->assertFalse(isset($form['placeholder'])); - $this->assertCount(2, $form, 'Each choice should become a new field'); - } - - public function testExpandedChoicesOptionsAreFlattened() - { - $form = $this->factory->create('choice', null, array( - 'expanded' => true, - 'choices' => $this->groupedChoices, - )); - - $flattened = array(); - foreach ($this->groupedChoices as $choices) { - $flattened = array_merge($flattened, array_keys($choices)); - } - - $this->assertCount($form->count(), $flattened, 'Each nested choice should become a new field, not the groups'); - - foreach ($flattened as $value => $choice) { - $this->assertTrue($form->has($value), 'Flattened choice is named after it\'s value'); - } - } - - public function testExpandedCheckboxesAreNeverRequired() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'required' => true, - 'choices' => $this->choices, - )); - - foreach ($form as $child) { - $this->assertFalse($child->isRequired()); - } - } - - public function testExpandedRadiosAreRequiredIfChoiceChildIsRequired() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => true, - 'choices' => $this->choices, - )); - - foreach ($form as $child) { - $this->assertTrue($child->isRequired()); - } - } - - public function testExpandedRadiosAreNotRequiredIfChoiceChildIsNotRequired() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'choices' => $this->choices, - )); - - foreach ($form as $child) { - $this->assertFalse($child->isRequired()); - } - } - - public function testSubmitSingleNonExpanded() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => false, - 'choices' => $this->choices, - )); - - $form->submit('b'); - - $this->assertEquals('b', $form->getData()); - $this->assertEquals('b', $form->getViewData()); - } - - public function testSubmitSingleNonExpandedInvalidChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => false, - 'choices' => $this->choices, - )); - - $form->submit('foobar'); - - $this->assertNull($form->getData()); - $this->assertEquals('foobar', $form->getViewData()); - $this->assertFalse($form->isSynchronized()); - } - - public function testSubmitSingleNonExpandedObjectChoices() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => false, - 'choice_list' => new ObjectChoiceList( - $this->objectChoices, - // label path - 'name', - array(), - null, - // value path - 'id' - ), - )); - - // "id" value of the second entry - $form->submit('2'); - - $this->assertEquals($this->objectChoices[1], $form->getData()); - $this->assertEquals('2', $form->getViewData()); - } - - public function testSubmitMultipleNonExpanded() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => false, - 'choices' => $this->choices, - )); - - $form->submit(array('a', 'b')); - - $this->assertEquals(array('a', 'b'), $form->getData()); - $this->assertEquals(array('a', 'b'), $form->getViewData()); - } - - public function testSubmitMultipleNonExpandedInvalidScalarChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => false, - 'choices' => $this->choices, - )); - - $form->submit('foobar'); - - $this->assertNull($form->getData()); - $this->assertEquals('foobar', $form->getViewData()); - $this->assertFalse($form->isSynchronized()); - } - - public function testSubmitMultipleNonExpandedInvalidArrayChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => false, - 'choices' => $this->choices, - )); - - $form->submit(array('a', 'foobar')); - - $this->assertNull($form->getData()); - $this->assertEquals(array('a', 'foobar'), $form->getViewData()); - $this->assertFalse($form->isSynchronized()); - } - - public function testSubmitMultipleNonExpandedObjectChoices() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => false, - 'choice_list' => new ObjectChoiceList( - $this->objectChoices, - // label path - 'name', - array(), - null, - // value path - 'id' - ), - )); - - $form->submit(array('2', '3')); - - $this->assertEquals(array($this->objectChoices[1], $this->objectChoices[2]), $form->getData()); - $this->assertEquals(array('2', '3'), $form->getViewData()); - } - - public function testSubmitSingleExpandedRequired() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => true, - 'choices' => $this->choices, - )); - - $form->submit('b'); - - $this->assertSame('b', $form->getData()); - $this->assertSame(array( - 0 => false, - 1 => true, - 2 => false, - 3 => false, - 4 => false, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertTrue($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertSame('b', $form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedRequiredInvalidChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => true, - 'choices' => $this->choices, - )); - - $form->submit('foobar'); - - $this->assertNull($form->getData()); - $this->assertSame('foobar', $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertFalse($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedNonRequired() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'choices' => $this->choices, - )); - - $form->submit('b'); - - $this->assertSame('b', $form->getData()); - $this->assertSame(array( - 0 => false, - 1 => true, - 2 => false, - 3 => false, - 4 => false, - 'placeholder' => false, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertFalse($form['placeholder']->getData()); - $this->assertFalse($form[0]->getData()); - $this->assertTrue($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form['placeholder']->getViewData()); - $this->assertNull($form[0]->getViewData()); - $this->assertSame('b', $form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedNonRequiredInvalidChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'choices' => $this->choices, - )); - - $form->submit('foobar'); - - $this->assertNull($form->getData()); - $this->assertSame('foobar', $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertFalse($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedRequiredNull() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => true, - 'choices' => $this->choices, - )); - - $form->submit(null); - - $this->assertNull($form->getData()); - $this->assertSame(array( - 0 => false, - 1 => false, - 2 => false, - 3 => false, - 4 => false, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedRequiredEmpty() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => true, - 'choices' => $this->choices, - )); - - $form->submit(''); - - $this->assertNull($form->getData()); - $this->assertSame(array( - 0 => false, - 1 => false, - 2 => false, - 3 => false, - 4 => false, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedRequiredFalse() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => true, - 'choices' => $this->choices, - )); - - $form->submit(false); - - $this->assertNull($form->getData()); - $this->assertSame(array( - 0 => false, - 1 => false, - 2 => false, - 3 => false, - 4 => false, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedNonRequiredNull() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'choices' => $this->choices, - )); - - $form->submit(null); - - $this->assertNull($form->getData()); - $this->assertSame(array( - 0 => false, - 1 => false, - 2 => false, - 3 => false, - 4 => false, - 'placeholder' => true, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertTrue($form['placeholder']->getData()); - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertSame('', $form['placeholder']->getViewData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedNonRequiredEmpty() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'choices' => $this->choices, - )); - - $form->submit(''); - - $this->assertNull($form->getData()); - $this->assertSame(array( - 0 => false, - 1 => false, - 2 => false, - 3 => false, - 4 => false, - 'placeholder' => true, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertTrue($form['placeholder']->getData()); - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertSame('', $form['placeholder']->getViewData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedNonRequiredFalse() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'required' => false, - 'choices' => $this->choices, - )); - - $form->submit(false); - - $this->assertNull($form->getData()); - $this->assertSame(array( - 0 => false, - 1 => false, - 2 => false, - 3 => false, - 4 => false, - 'placeholder' => true, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertTrue($form['placeholder']->getData()); - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertSame('', $form['placeholder']->getViewData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedWithEmptyChild() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'choices' => array( - '' => 'Empty', - 1 => 'Not empty', - ), - )); - - $form->submit(''); - - $this->assertNull($form->getData()); - $this->assertTrue($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertSame('', $form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - } - - public function testSubmitSingleExpandedObjectChoices() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'choice_list' => new ObjectChoiceList( - $this->objectChoices, - // label path - 'name', - array(), - null, - // value path - 'id' - ), - )); - - $form->submit('2'); - - $this->assertSame($this->objectChoices[1], $form->getData()); - $this->assertFalse($form[0]->getData()); - $this->assertTrue($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertSame('2', $form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitSingleExpandedNumericChoices() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => true, - 'choices' => $this->numericChoices, - )); - - $form->submit('1'); - - $this->assertSame(1, $form->getData()); - $this->assertFalse($form[0]->getData()); - $this->assertTrue($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertSame('1', $form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitMultipleExpanded() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'choices' => $this->choices, - )); - - $form->submit(array('a', 'c')); - - $this->assertSame(array('a', 'c'), $form->getData()); - $this->assertSame(array( - 0 => true, - 1 => false, - 2 => true, - 3 => false, - 4 => false, - ), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertTrue($form->isSynchronized()); - - $this->assertTrue($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertTrue($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertSame('a', $form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertSame('c', $form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitMultipleExpandedInvalidScalarChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'choices' => $this->choices, - )); - - $form->submit('foobar'); - - $this->assertNull($form->getData()); - $this->assertSame('foobar', $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertFalse($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitMultipleExpandedInvalidArrayChoice() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'choices' => $this->choices, - )); - - $form->submit(array('a', 'foobar')); - - $this->assertNull($form->getData()); - $this->assertSame(array('a', 'foobar'), $form->getViewData()); - $this->assertEmpty($form->getExtraData()); - $this->assertFalse($form->isSynchronized()); - - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitMultipleExpandedEmpty() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'choices' => $this->choices, - )); - - $form->submit(array()); - - $this->assertSame(array(), $form->getData()); - $this->assertFalse($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitMultipleExpandedWithEmptyChild() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'choices' => array( - '' => 'Empty', - 1 => 'Not Empty', - 2 => 'Not Empty 2', - ), - )); - - $form->submit(array('', '2')); - - $this->assertSame(array('', 2), $form->getData()); - $this->assertTrue($form[0]->getData()); - $this->assertFalse($form[1]->getData()); - $this->assertTrue($form[2]->getData()); - $this->assertSame('', $form[0]->getViewData()); - $this->assertNull($form[1]->getViewData()); - $this->assertSame('2', $form[2]->getViewData()); - } - - public function testSubmitMultipleExpandedObjectChoices() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'choice_list' => new ObjectChoiceList( - $this->objectChoices, - // label path - 'name', - array(), - null, - // value path - 'id' - ), - )); - - $form->submit(array('1', '2')); - - $this->assertSame(array($this->objectChoices[0], $this->objectChoices[1]), $form->getData()); - $this->assertTrue($form[0]->getData()); - $this->assertTrue($form[1]->getData()); - $this->assertFalse($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertSame('1', $form[0]->getViewData()); - $this->assertSame('2', $form[1]->getViewData()); - $this->assertNull($form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - public function testSubmitMultipleExpandedNumericChoices() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => true, - 'choices' => $this->numericChoices, - )); - - $form->submit(array('1', '2')); - - $this->assertSame(array(1, 2), $form->getData()); - $this->assertFalse($form[0]->getData()); - $this->assertTrue($form[1]->getData()); - $this->assertTrue($form[2]->getData()); - $this->assertFalse($form[3]->getData()); - $this->assertFalse($form[4]->getData()); - $this->assertNull($form[0]->getViewData()); - $this->assertSame('1', $form[1]->getViewData()); - $this->assertSame('2', $form[2]->getViewData()); - $this->assertNull($form[3]->getViewData()); - $this->assertNull($form[4]->getViewData()); - } - - /* - * We need this functionality to create choice fields for Boolean types, - * e.g. false => 'No', true => 'Yes' - */ - public function testSetDataSingleNonExpandedAcceptsBoolean() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'expanded' => false, - 'choices' => $this->numericChoices, - )); - - $form->setData(false); - - $this->assertFalse($form->getData()); - $this->assertEquals('0', $form->getViewData()); - } - - public function testSetDataMultipleNonExpandedAcceptsBoolean() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'expanded' => false, - 'choices' => $this->numericChoices, - )); - - $form->setData(array(false, true)); - - $this->assertEquals(array(false, true), $form->getData()); - $this->assertEquals(array('0', '1'), $form->getViewData()); - } - - public function testPassRequiredToView() - { - $form = $this->factory->create('choice', null, array( - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertTrue($view->vars['required']); - } - - public function testPassNonRequiredToView() - { - $form = $this->factory->create('choice', null, array( - 'required' => false, - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertFalse($view->vars['required']); - } - - public function testPassMultipleToView() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => true, - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertTrue($view->vars['multiple']); - } - - public function testPassExpandedToView() - { - $form = $this->factory->create('choice', null, array( - 'expanded' => true, - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertTrue($view->vars['expanded']); - } - - public function testPlaceholderIsNullByDefaultIfRequired() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'required' => true, - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertNull($view->vars['placeholder']); - } - - public function testPlaceholderIsEmptyStringByDefaultIfNotRequired() - { - $form = $this->factory->create('choice', null, array( - 'multiple' => false, - 'required' => false, - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertSame('', $view->vars['placeholder']); - } - - /** - * @dataProvider getOptionsWithPlaceholder - */ - public function testPassPlaceholderToView($multiple, $expanded, $required, $placeholder, $viewValue) - { - $form = $this->factory->create('choice', null, array( - 'multiple' => $multiple, - 'expanded' => $expanded, - 'required' => $required, - 'placeholder' => $placeholder, - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertEquals($viewValue, $view->vars['placeholder']); - $this->assertFalse($view->vars['placeholder_in_choices']); - } - - /** - * @dataProvider getOptionsWithPlaceholder - */ - public function testPassEmptyValueBC($multiple, $expanded, $required, $placeholder, $viewValue) - { - $form = $this->factory->create('choice', null, array( - 'multiple' => $multiple, - 'expanded' => $expanded, - 'required' => $required, - 'empty_value' => $placeholder, - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertEquals($viewValue, $view->vars['placeholder']); - $this->assertFalse($view->vars['placeholder_in_choices']); - $this->assertEquals($viewValue, $view->vars['empty_value']); - $this->assertFalse($view->vars['empty_value_in_choices']); - } - - /** - * @dataProvider getOptionsWithPlaceholder - */ - public function testDontPassPlaceholderIfContainedInChoices($multiple, $expanded, $required, $placeholder, $viewValue) - { - $form = $this->factory->create('choice', null, array( - 'multiple' => $multiple, - 'expanded' => $expanded, - 'required' => $required, - 'placeholder' => $placeholder, - 'choices' => array('a' => 'A', '' => 'Empty'), - )); - $view = $form->createView(); - - $this->assertNull($view->vars['placeholder']); - $this->assertTrue($view->vars['placeholder_in_choices']); - } - - public function getOptionsWithPlaceholder() - { - return array( - // single non-expanded - array(false, false, false, 'foobar', 'foobar'), - array(false, false, false, '', ''), - array(false, false, false, null, null), - array(false, false, false, false, null), - array(false, false, true, 'foobar', 'foobar'), - array(false, false, true, '', ''), - array(false, false, true, null, null), - array(false, false, true, false, null), - // single expanded - array(false, true, false, 'foobar', 'foobar'), - // radios should never have an empty label - array(false, true, false, '', 'None'), - array(false, true, false, null, null), - array(false, true, false, false, null), - array(false, true, true, 'foobar', 'foobar'), - // radios should never have an empty label - array(false, true, true, '', 'None'), - array(false, true, true, null, null), - array(false, true, true, false, null), - // multiple non-expanded - array(true, false, false, 'foobar', null), - array(true, false, false, '', null), - array(true, false, false, null, null), - array(true, false, false, false, null), - array(true, false, true, 'foobar', null), - array(true, false, true, '', null), - array(true, false, true, null, null), - array(true, false, true, false, null), - // multiple expanded - array(true, true, false, 'foobar', null), - array(true, true, false, '', null), - array(true, true, false, null, null), - array(true, true, false, false, null), - array(true, true, true, 'foobar', null), - array(true, true, true, '', null), - array(true, true, true, null, null), - array(true, true, true, false, null), - ); - } - - public function testPassChoicesToView() - { - $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'); - $form = $this->factory->create('choice', null, array( - 'choices' => $choices, - )); - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('a', 'a', 'A'), - new ChoiceView('b', 'b', 'B'), - new ChoiceView('c', 'c', 'C'), - new ChoiceView('d', 'd', 'D'), - ), $view->vars['choices']); - } - - public function testPassPreferredChoicesToView() - { - $choices = array('a' => 'A', 'b' => 'B', 'c' => 'C', 'd' => 'D'); - $form = $this->factory->create('choice', null, array( - 'choices' => $choices, - 'preferred_choices' => array('b', 'd'), - )); - $view = $form->createView(); - - $this->assertEquals(array( - 0 => new ChoiceView('a', 'a', 'A'), - 2 => new ChoiceView('c', 'c', 'C'), - ), $view->vars['choices']); - $this->assertEquals(array( - 1 => new ChoiceView('b', 'b', 'B'), - 3 => new ChoiceView('d', 'd', 'D'), - ), $view->vars['preferred_choices']); - } - - public function testPassHierarchicalChoicesToView() - { - $form = $this->factory->create('choice', null, array( - 'choices' => $this->groupedChoices, - 'preferred_choices' => array('b', 'd'), - )); - $view = $form->createView(); - - $this->assertEquals(array( - 'Symfony' => array( - 0 => new ChoiceView('a', 'a', 'Bernhard'), - 2 => new ChoiceView('c', 'c', 'Kris'), - ), - 'Doctrine' => array( - 4 => new ChoiceView('e', 'e', 'Roman'), - ), - ), $view->vars['choices']); - $this->assertEquals(array( - 'Symfony' => array( - 1 => new ChoiceView('b', 'b', 'Fabien'), - ), - 'Doctrine' => array( - 3 => new ChoiceView('d', 'd', 'Jon'), - ), - ), $view->vars['preferred_choices']); - } - - public function testPassChoiceDataToView() - { - $obj1 = (object) array('value' => 'a', 'label' => 'A'); - $obj2 = (object) array('value' => 'b', 'label' => 'B'); - $obj3 = (object) array('value' => 'c', 'label' => 'C'); - $obj4 = (object) array('value' => 'd', 'label' => 'D'); - $form = $this->factory->create('choice', null, array( - 'choice_list' => new ObjectChoiceList(array($obj1, $obj2, $obj3, $obj4), 'label', array(), null, 'value'), - )); - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView($obj1, 'a', 'A'), - new ChoiceView($obj2, 'b', 'B'), - new ChoiceView($obj3, 'c', 'C'), - new ChoiceView($obj4, 'd', 'D'), - ), $view->vars['choices']); - } - - public function testAdjustFullNameForMultipleNonExpanded() - { - $form = $this->factory->createNamed('name', 'choice', null, array( - 'multiple' => true, - 'expanded' => false, - 'choices' => $this->choices, - )); - $view = $form->createView(); - - $this->assertSame('name[]', $view->vars['full_name']); - } - - // https://github.com/symfony/symfony/issues/3298 - public function testInitializeWithEmptyChoices() - { - $this->factory->createNamed('name', 'choice', null, array( - 'choices' => array(), - )); - } - - // https://github.com/symfony/symfony/issues/10409 - public function testReuseNonUtf8ChoiceLists() - { - $form1 = $this->factory->createNamed('name', 'choice', null, array( - 'choices' => array( - 'meter' => 'm', - 'millimeter' => 'mm', - 'micrometer' => chr(181).'meter', - ), - )); - - $form2 = $this->factory->createNamed('name', 'choice', null, array( - 'choices' => array( - 'meter' => 'm', - 'millimeter' => 'mm', - 'micrometer' => chr(181).'meter', - ), - )); - - $form3 = $this->factory->createNamed('name', 'choice', null, array( - 'choices' => array( - 'meter' => 'm', - 'millimeter' => 'mm', - 'micrometer' => null, - ), - )); - - // $form1 and $form2 use the same ChoiceList - $this->assertSame( - $form1->getConfig()->getOption('choice_list'), - $form2->getConfig()->getOption('choice_list') - ); - - // $form3 doesn't, but used to use the same when using json_encode() - // instead of serialize for the hashing algorithm - $this->assertNotSame( - $form1->getConfig()->getOption('choice_list'), - $form3->getConfig()->getOption('choice_list') - ); - } - - public function testInitializeWithDefaultObjectChoice() - { - $obj1 = (object) array('value' => 'a', 'label' => 'A'); - $obj2 = (object) array('value' => 'b', 'label' => 'B'); - $obj3 = (object) array('value' => 'c', 'label' => 'C'); - $obj4 = (object) array('value' => 'd', 'label' => 'D'); - - $form = $this->factory->create('choice', null, array( - 'choice_list' => new ObjectChoiceList(array($obj1, $obj2, $obj3, $obj4), 'label', array(), null, 'value'), - // Used to break because "data_class" was inferred, which needs to - // remain null in every case (because it refers to the view format) - 'data' => $obj3, - )); - - // Trigger data initialization - $form->getViewData(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php deleted file mode 100644 index 589ccdbb7..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CollectionTypeTest.php +++ /dev/null @@ -1,277 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Form; -use Symfony\Component\Form\Tests\Fixtures\Author; -use Symfony\Component\Form\Tests\Fixtures\AuthorType; - -class CollectionTypeTest extends \Symfony\Component\Form\Test\TypeTestCase -{ - public function testContainsNoChildByDefault() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - )); - - $this->assertCount(0, $form); - } - - public function testSetDataAdjustsSize() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - 'options' => array( - 'attr' => array('maxlength' => 20), - ), - )); - $form->setData(array('foo@foo.com', 'foo@bar.com')); - - $this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]); - $this->assertInstanceOf('Symfony\Component\Form\Form', $form[1]); - $this->assertCount(2, $form); - $this->assertEquals('foo@foo.com', $form[0]->getData()); - $this->assertEquals('foo@bar.com', $form[1]->getData()); - $formAttrs0 = $form[0]->getConfig()->getOption('attr'); - $formAttrs1 = $form[1]->getConfig()->getOption('attr'); - $this->assertEquals(20, $formAttrs0['maxlength']); - $this->assertEquals(20, $formAttrs1['maxlength']); - - $form->setData(array('foo@baz.com')); - $this->assertInstanceOf('Symfony\Component\Form\Form', $form[0]); - $this->assertFalse(isset($form[1])); - $this->assertCount(1, $form); - $this->assertEquals('foo@baz.com', $form[0]->getData()); - $formAttrs0 = $form[0]->getConfig()->getOption('attr'); - $this->assertEquals(20, $formAttrs0['maxlength']); - } - - public function testThrowsExceptionIfObjectIsNotTraversable() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - )); - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); - $form->setData(new \stdClass()); - } - - public function testNotResizedIfSubmittedWithMissingData() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - )); - $form->setData(array('foo@foo.com', 'bar@bar.com')); - $form->submit(array('foo@bar.com')); - - $this->assertTrue($form->has('0')); - $this->assertTrue($form->has('1')); - $this->assertEquals('foo@bar.com', $form[0]->getData()); - $this->assertEquals('', $form[1]->getData()); - } - - public function testResizedDownIfSubmittedWithMissingDataAndAllowDelete() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - 'allow_delete' => true, - )); - $form->setData(array('foo@foo.com', 'bar@bar.com')); - $form->submit(array('foo@foo.com')); - - $this->assertTrue($form->has('0')); - $this->assertFalse($form->has('1')); - $this->assertEquals('foo@foo.com', $form[0]->getData()); - $this->assertEquals(array('foo@foo.com'), $form->getData()); - } - - public function testResizedDownIfSubmittedWithEmptyDataAndDeleteEmpty() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - 'allow_delete' => true, - 'delete_empty' => true, - )); - - $form->setData(array('foo@foo.com', 'bar@bar.com')); - $form->submit(array('foo@foo.com', '')); - - $this->assertTrue($form->has('0')); - $this->assertFalse($form->has('1')); - $this->assertEquals('foo@foo.com', $form[0]->getData()); - $this->assertEquals(array('foo@foo.com'), $form->getData()); - } - - public function testDontAddEmptyDataIfDeleteEmpty() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - 'allow_add' => true, - 'delete_empty' => true, - )); - - $form->setData(array('foo@foo.com')); - $form->submit(array('foo@foo.com', '')); - - $this->assertTrue($form->has('0')); - $this->assertFalse($form->has('1')); - $this->assertEquals('foo@foo.com', $form[0]->getData()); - $this->assertEquals(array('foo@foo.com'), $form->getData()); - } - - public function testNoDeleteEmptyIfDeleteNotAllowed() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - 'allow_delete' => false, - 'delete_empty' => true, - )); - - $form->setData(array('foo@foo.com')); - $form->submit(array('')); - - $this->assertTrue($form->has('0')); - $this->assertEquals('', $form[0]->getData()); - } - - public function testResizedDownIfSubmittedWithCompoundEmptyDataAndDeleteEmpty() - { - $form = $this->factory->create('collection', null, array( - 'type' => new AuthorType(), - // If the field is not required, no new Author will be created if the - // form is completely empty - 'options' => array('required' => false), - 'allow_add' => true, - 'delete_empty' => true, - )); - - $form->setData(array(new Author('first', 'last'))); - $form->submit(array( - array('firstName' => 's_first', 'lastName' => 's_last'), - array('firstName' => '', 'lastName' => ''), - )); - - $this->assertTrue($form->has('0')); - $this->assertFalse($form->has('1')); - $this->assertEquals(new Author('s_first', 's_last'), $form[0]->getData()); - $this->assertEquals(array(new Author('s_first', 's_last')), $form->getData()); - } - - public function testNotResizedIfSubmittedWithExtraData() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - )); - $form->setData(array('foo@bar.com')); - $form->submit(array('foo@foo.com', 'bar@bar.com')); - - $this->assertTrue($form->has('0')); - $this->assertFalse($form->has('1')); - $this->assertEquals('foo@foo.com', $form[0]->getData()); - } - - public function testResizedUpIfSubmittedWithExtraDataAndAllowAdd() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'text', - 'allow_add' => true, - )); - $form->setData(array('foo@bar.com')); - $form->submit(array('foo@bar.com', 'bar@bar.com')); - - $this->assertTrue($form->has('0')); - $this->assertTrue($form->has('1')); - $this->assertEquals('foo@bar.com', $form[0]->getData()); - $this->assertEquals('bar@bar.com', $form[1]->getData()); - $this->assertEquals(array('foo@bar.com', 'bar@bar.com'), $form->getData()); - } - - public function testAllowAddButNoPrototype() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'form', - 'allow_add' => true, - 'prototype' => false, - )); - - $this->assertFalse($form->has('__name__')); - } - - public function testPrototypeMultipartPropagation() - { - $form = $this->factory - ->create('collection', null, array( - 'type' => 'file', - 'allow_add' => true, - 'prototype' => true, - )) - ; - - $this->assertTrue($form->createView()->vars['multipart']); - } - - public function testGetDataDoesNotContainsPrototypeNameBeforeDataAreSet() - { - $form = $this->factory->create('collection', array(), array( - 'type' => 'file', - 'prototype' => true, - 'allow_add' => true, - )); - - $data = $form->getData(); - $this->assertFalse(isset($data['__name__'])); - } - - public function testGetDataDoesNotContainsPrototypeNameAfterDataAreSet() - { - $form = $this->factory->create('collection', array(), array( - 'type' => 'file', - 'allow_add' => true, - 'prototype' => true, - )); - - $form->setData(array('foobar.png')); - $data = $form->getData(); - $this->assertFalse(isset($data['__name__'])); - } - - public function testPrototypeNameOption() - { - $form = $this->factory->create('collection', null, array( - 'type' => 'form', - 'prototype' => true, - 'allow_add' => true, - )); - - $this->assertSame('__name__', $form->getConfig()->getAttribute('prototype')->getName(), '__name__ is the default'); - - $form = $this->factory->create('collection', null, array( - 'type' => 'form', - 'prototype' => true, - 'allow_add' => true, - 'prototype_name' => '__test__', - )); - - $this->assertSame('__test__', $form->getConfig()->getAttribute('prototype')->getName()); - } - - public function testPrototypeDefaultLabel() - { - $form = $this->factory->create('collection', array(), array( - 'type' => 'file', - 'allow_add' => true, - 'prototype' => true, - 'prototype_name' => '__test__', - )); - - $this->assertSame('__test__label__', $form->createView()->vars['prototype']->vars['label']); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php deleted file mode 100644 index 7c2cebb54..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CountryTypeTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Extension\Core\View\ChoiceView; -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class CountryTypeTest extends TestCase -{ - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - - public function testCountriesAreSelectable() - { - $form = $this->factory->create('country'); - $view = $form->createView(); - $choices = $view->vars['choices']; - - // Don't check objects for identity - $this->assertContains(new ChoiceView('DE', 'DE', 'Germany'), $choices, '', false, false); - $this->assertContains(new ChoiceView('GB', 'GB', 'United Kingdom'), $choices, '', false, false); - $this->assertContains(new ChoiceView('US', 'US', 'United States'), $choices, '', false, false); - $this->assertContains(new ChoiceView('FR', 'FR', 'France'), $choices, '', false, false); - $this->assertContains(new ChoiceView('MY', 'MY', 'Malaysia'), $choices, '', false, false); - } - - public function testUnknownCountryIsNotIncluded() - { - $form = $this->factory->create('country', 'country'); - $view = $form->createView(); - $choices = $view->vars['choices']; - - foreach ($choices as $choice) { - if ('ZZ' === $choice->value) { - $this->fail('Should not contain choice "ZZ"'); - } - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php deleted file mode 100644 index 702262f58..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/CurrencyTypeTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Extension\Core\View\ChoiceView; -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class CurrencyTypeTest extends TestCase -{ - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - - public function testCurrenciesAreSelectable() - { - $form = $this->factory->create('currency'); - $view = $form->createView(); - $choices = $view->vars['choices']; - - $this->assertContains(new ChoiceView('EUR', 'EUR', 'Euro'), $choices, '', false, false); - $this->assertContains(new ChoiceView('USD', 'USD', 'US Dollar'), $choices, '', false, false); - $this->assertContains(new ChoiceView('SIT', 'SIT', 'Slovenian Tolar'), $choices, '', false, false); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php deleted file mode 100644 index f31cc04bd..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ /dev/null @@ -1,510 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class DateTimeTypeTest extends TestCase -{ - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - - public function testSubmitDateTime() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - 'input' => 'datetime', - )); - - $form->submit(array( - 'date' => array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ), - 'time' => array( - 'hour' => '3', - 'minute' => '4', - ), - )); - - $dateTime = new \DateTime('2010-06-02 03:04:00 UTC'); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - } - - public function testSubmitString() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'string', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - )); - - $form->submit(array( - 'date' => array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ), - 'time' => array( - 'hour' => '3', - 'minute' => '4', - ), - )); - - $this->assertEquals('2010-06-02 03:04:00', $form->getData()); - } - - public function testSubmitTimestamp() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'timestamp', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - )); - - $form->submit(array( - 'date' => array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ), - 'time' => array( - 'hour' => '3', - 'minute' => '4', - ), - )); - - $dateTime = new \DateTime('2010-06-02 03:04:00 UTC'); - - $this->assertEquals($dateTime->format('U'), $form->getData()); - } - - public function testSubmitWithoutMinutes() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - 'input' => 'datetime', - 'with_minutes' => false, - )); - - $form->setData(new \DateTime('2010-06-02 03:04:05 UTC')); - - $input = array( - 'date' => array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ), - 'time' => array( - 'hour' => '3', - ), - ); - - $form->submit($input); - - $this->assertDateTimeEquals(new \DateTime('2010-06-02 03:00:00 UTC'), $form->getData()); - } - - public function testSubmitWithSeconds() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - 'input' => 'datetime', - 'with_seconds' => true, - )); - - $form->setData(new \DateTime('2010-06-02 03:04:05 UTC')); - - $input = array( - 'date' => array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ), - 'time' => array( - 'hour' => '3', - 'minute' => '4', - 'second' => '5', - ), - ); - - $form->submit($input); - - $this->assertDateTimeEquals(new \DateTime('2010-06-02 03:04:05 UTC'), $form->getData()); - } - - public function testSubmitDifferentTimezones() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'America/New_York', - 'view_timezone' => 'Pacific/Tahiti', - 'date_widget' => 'choice', - 'time_widget' => 'choice', - 'input' => 'string', - 'with_seconds' => true, - )); - - $dateTime = new \DateTime('2010-06-02 03:04:05 Pacific/Tahiti'); - - $form->submit(array( - 'date' => array( - 'day' => (int) $dateTime->format('d'), - 'month' => (int) $dateTime->format('m'), - 'year' => (int) $dateTime->format('Y'), - ), - 'time' => array( - 'hour' => (int) $dateTime->format('H'), - 'minute' => (int) $dateTime->format('i'), - 'second' => (int) $dateTime->format('s'), - ), - )); - - $dateTime->setTimezone(new \DateTimeZone('America/New_York')); - - $this->assertEquals($dateTime->format('Y-m-d H:i:s'), $form->getData()); - } - - public function testSubmitDifferentTimezonesDateTime() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'America/New_York', - 'view_timezone' => 'Pacific/Tahiti', - 'widget' => 'single_text', - 'input' => 'datetime', - )); - - $outputTime = new \DateTime('2010-06-02 03:04:00 Pacific/Tahiti'); - - $form->submit('2010-06-02T03:04:00-10:00'); - - $outputTime->setTimezone(new \DateTimeZone('America/New_York')); - - $this->assertDateTimeEquals($outputTime, $form->getData()); - $this->assertEquals('2010-06-02T03:04:00-10:00', $form->getViewData()); - } - - public function testSubmitStringSingleText() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'string', - 'widget' => 'single_text', - )); - - $form->submit('2010-06-02T03:04:00Z'); - - $this->assertEquals('2010-06-02 03:04:00', $form->getData()); - $this->assertEquals('2010-06-02T03:04:00Z', $form->getViewData()); - } - - public function testSubmitStringSingleTextWithSeconds() - { - $form = $this->factory->create('datetime', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'string', - 'widget' => 'single_text', - 'with_seconds' => true, - )); - - $form->submit('2010-06-02T03:04:05Z'); - - $this->assertEquals('2010-06-02 03:04:05', $form->getData()); - $this->assertEquals('2010-06-02T03:04:05Z', $form->getViewData()); - } - - public function testSubmitDifferentPattern() - { - $form = $this->factory->create('datetime', null, array( - 'date_format' => 'MM*yyyy*dd', - 'date_widget' => 'single_text', - 'time_widget' => 'single_text', - 'input' => 'datetime', - )); - - $dateTime = new \DateTime('2010-06-02 03:04'); - - $form->submit(array( - 'date' => '06*2010*02', - 'time' => '03:04', - )); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - } - - // Bug fix - public function testInitializeWithDateTime() - { - // Throws an exception if "data_class" option is not explicitly set - // to null in the type - $this->factory->create('datetime', new \DateTime()); - } - - public function testSingleTextWidgetShouldUseTheRightInputType() - { - $form = $this->factory->create('datetime', null, array( - 'widget' => 'single_text', - )); - - $view = $form->createView(); - $this->assertEquals('datetime', $view->vars['type']); - } - - public function testPassDefaultPlaceholderToViewIfNotRequired() - { - $form = $this->factory->create('datetime', null, array( - 'required' => false, - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('', $view['date']['year']->vars['placeholder']); - $this->assertSame('', $view['date']['month']->vars['placeholder']); - $this->assertSame('', $view['date']['day']->vars['placeholder']); - $this->assertSame('', $view['time']['hour']->vars['placeholder']); - $this->assertSame('', $view['time']['minute']->vars['placeholder']); - $this->assertSame('', $view['time']['second']->vars['placeholder']); - } - - public function testPassNoPlaceholderToViewIfRequired() - { - $form = $this->factory->create('datetime', null, array( - 'required' => true, - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertNull($view['date']['year']->vars['placeholder']); - $this->assertNull($view['date']['month']->vars['placeholder']); - $this->assertNull($view['date']['day']->vars['placeholder']); - $this->assertNull($view['time']['hour']->vars['placeholder']); - $this->assertNull($view['time']['minute']->vars['placeholder']); - $this->assertNull($view['time']['second']->vars['placeholder']); - } - - public function testPassPlaceholderAsString() - { - $form = $this->factory->create('datetime', null, array( - 'placeholder' => 'Empty', - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty', $view['date']['year']->vars['placeholder']); - $this->assertSame('Empty', $view['date']['month']->vars['placeholder']); - $this->assertSame('Empty', $view['date']['day']->vars['placeholder']); - $this->assertSame('Empty', $view['time']['hour']->vars['placeholder']); - $this->assertSame('Empty', $view['time']['minute']->vars['placeholder']); - $this->assertSame('Empty', $view['time']['second']->vars['placeholder']); - } - - public function testPassEmptyValueBC() - { - $form = $this->factory->create('datetime', null, array( - 'empty_value' => 'Empty', - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty', $view['date']['year']->vars['placeholder']); - $this->assertSame('Empty', $view['date']['month']->vars['placeholder']); - $this->assertSame('Empty', $view['date']['day']->vars['placeholder']); - $this->assertSame('Empty', $view['time']['hour']->vars['placeholder']); - $this->assertSame('Empty', $view['time']['minute']->vars['placeholder']); - $this->assertSame('Empty', $view['time']['second']->vars['placeholder']); - $this->assertSame('Empty', $view['date']['year']->vars['empty_value']); - $this->assertSame('Empty', $view['date']['month']->vars['empty_value']); - $this->assertSame('Empty', $view['date']['day']->vars['empty_value']); - $this->assertSame('Empty', $view['time']['hour']->vars['empty_value']); - $this->assertSame('Empty', $view['time']['minute']->vars['empty_value']); - $this->assertSame('Empty', $view['time']['second']->vars['empty_value']); - } - - public function testPassPlaceholderAsArray() - { - $form = $this->factory->create('datetime', null, array( - 'placeholder' => array( - 'year' => 'Empty year', - 'month' => 'Empty month', - 'day' => 'Empty day', - 'hour' => 'Empty hour', - 'minute' => 'Empty minute', - 'second' => 'Empty second', - ), - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty year', $view['date']['year']->vars['placeholder']); - $this->assertSame('Empty month', $view['date']['month']->vars['placeholder']); - $this->assertSame('Empty day', $view['date']['day']->vars['placeholder']); - $this->assertSame('Empty hour', $view['time']['hour']->vars['placeholder']); - $this->assertSame('Empty minute', $view['time']['minute']->vars['placeholder']); - $this->assertSame('Empty second', $view['time']['second']->vars['placeholder']); - } - - public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() - { - $form = $this->factory->create('datetime', null, array( - 'required' => false, - 'placeholder' => array( - 'year' => 'Empty year', - 'day' => 'Empty day', - 'hour' => 'Empty hour', - 'second' => 'Empty second', - ), - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty year', $view['date']['year']->vars['placeholder']); - $this->assertSame('', $view['date']['month']->vars['placeholder']); - $this->assertSame('Empty day', $view['date']['day']->vars['placeholder']); - $this->assertSame('Empty hour', $view['time']['hour']->vars['placeholder']); - $this->assertSame('', $view['time']['minute']->vars['placeholder']); - $this->assertSame('Empty second', $view['time']['second']->vars['placeholder']); - } - - public function testPassPlaceholderAsPartialArrayAddNullIfRequired() - { - $form = $this->factory->create('datetime', null, array( - 'required' => true, - 'placeholder' => array( - 'year' => 'Empty year', - 'day' => 'Empty day', - 'hour' => 'Empty hour', - 'second' => 'Empty second', - ), - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty year', $view['date']['year']->vars['placeholder']); - $this->assertNull($view['date']['month']->vars['placeholder']); - $this->assertSame('Empty day', $view['date']['day']->vars['placeholder']); - $this->assertSame('Empty hour', $view['time']['hour']->vars['placeholder']); - $this->assertNull($view['time']['minute']->vars['placeholder']); - $this->assertSame('Empty second', $view['time']['second']->vars['placeholder']); - } - - public function testPassHtml5TypeIfSingleTextAndHtml5Format() - { - $form = $this->factory->create('datetime', null, array( - 'widget' => 'single_text', - )); - - $view = $form->createView(); - $this->assertSame('datetime', $view->vars['type']); - } - - public function testDontPassHtml5TypeIfHtml5NotAllowed() - { - $form = $this->factory->create('datetime', null, array( - 'widget' => 'single_text', - 'html5' => false, - )); - - $view = $form->createView(); - $this->assertFalse(isset($view->vars['type'])); - } - - public function testDontPassHtml5TypeIfNotHtml5Format() - { - $form = $this->factory->create('datetime', null, array( - 'widget' => 'single_text', - 'format' => 'yyyy-MM-dd HH:mm', - )); - - $view = $form->createView(); - $this->assertFalse(isset($view->vars['type'])); - } - - public function testDontPassHtml5TypeIfNotSingleText() - { - $form = $this->factory->create('datetime', null, array( - 'widget' => 'text', - )); - - $view = $form->createView(); - $this->assertFalse(isset($view->vars['type'])); - } - - public function testDateTypeChoiceErrorsBubbleUp() - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('datetime', null); - - $form['date']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['date']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - public function testDateTypeSingleTextErrorsBubbleUp() - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('datetime', null, array( - 'date_widget' => 'single_text', - )); - - $form['date']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['date']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - public function testTimeTypeChoiceErrorsBubbleUp() - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('datetime', null); - - $form['time']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['time']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - public function testTimeTypeSingleTextErrorsBubbleUp() - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('datetime', null, array( - 'time_widget' => 'single_text', - )); - - $form['time']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['time']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php deleted file mode 100644 index d8b3312b1..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php +++ /dev/null @@ -1,922 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Extension\Core\View\ChoiceView; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class DateTypeTest extends TestCase -{ - private $defaultTimezone; - - protected function setUp() - { - parent::setUp(); - - // we test against "de_AT", so we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_AT'); - - $this->defaultTimezone = date_default_timezone_get(); - } - - protected function tearDown() - { - date_default_timezone_set($this->defaultTimezone); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testInvalidWidgetOption() - { - $this->factory->create('date', null, array( - 'widget' => 'fake_widget', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testInvalidInputOption() - { - $this->factory->create('date', null, array( - 'input' => 'fake_input', - )); - } - - public function testSubmitFromSingleTextDateTimeWithDefaultFormat() - { - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'single_text', - 'input' => 'datetime', - )); - - $form->submit('2010-06-02'); - - $this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData()); - $this->assertEquals('2010-06-02', $form->getViewData()); - } - - public function testSubmitFromSingleTextDateTime() - { - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'single_text', - 'input' => 'datetime', - )); - - $form->submit('2.6.2010'); - - $this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData()); - $this->assertEquals('02.06.2010', $form->getViewData()); - } - - public function testSubmitFromSingleTextString() - { - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'single_text', - 'input' => 'string', - )); - - $form->submit('2.6.2010'); - - $this->assertEquals('2010-06-02', $form->getData()); - $this->assertEquals('02.06.2010', $form->getViewData()); - } - - public function testSubmitFromSingleTextTimestamp() - { - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'single_text', - 'input' => 'timestamp', - )); - - $form->submit('2.6.2010'); - - $dateTime = new \DateTime('2010-06-02 UTC'); - - $this->assertEquals($dateTime->format('U'), $form->getData()); - $this->assertEquals('02.06.2010', $form->getViewData()); - } - - public function testSubmitFromSingleTextRaw() - { - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'single_text', - 'input' => 'array', - )); - - $form->submit('2.6.2010'); - - $output = array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ); - - $this->assertEquals($output, $form->getData()); - $this->assertEquals('02.06.2010', $form->getViewData()); - } - - public function testSubmitFromText() - { - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'text', - )); - - $text = array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ); - - $form->submit($text); - - $dateTime = new \DateTime('2010-06-02 UTC'); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - $this->assertEquals($text, $form->getViewData()); - } - - public function testSubmitFromChoice() - { - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'choice', - )); - - $text = array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ); - - $form->submit($text); - - $dateTime = new \DateTime('2010-06-02 UTC'); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - $this->assertEquals($text, $form->getViewData()); - } - - public function testSubmitFromChoiceEmpty() - { - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'choice', - 'required' => false, - )); - - $text = array( - 'day' => '', - 'month' => '', - 'year' => '', - ); - - $form->submit($text); - - $this->assertNull($form->getData()); - $this->assertEquals($text, $form->getViewData()); - } - - public function testSubmitFromInputDateTimeDifferentPattern() - { - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'format' => 'MM*yyyy*dd', - 'widget' => 'single_text', - 'input' => 'datetime', - )); - - $form->submit('06*2010*02'); - - $this->assertDateTimeEquals(new \DateTime('2010-06-02 UTC'), $form->getData()); - $this->assertEquals('06*2010*02', $form->getViewData()); - } - - public function testSubmitFromInputStringDifferentPattern() - { - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'format' => 'MM*yyyy*dd', - 'widget' => 'single_text', - 'input' => 'string', - )); - - $form->submit('06*2010*02'); - - $this->assertEquals('2010-06-02', $form->getData()); - $this->assertEquals('06*2010*02', $form->getViewData()); - } - - public function testSubmitFromInputTimestampDifferentPattern() - { - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'format' => 'MM*yyyy*dd', - 'widget' => 'single_text', - 'input' => 'timestamp', - )); - - $form->submit('06*2010*02'); - - $dateTime = new \DateTime('2010-06-02 UTC'); - - $this->assertEquals($dateTime->format('U'), $form->getData()); - $this->assertEquals('06*2010*02', $form->getViewData()); - } - - public function testSubmitFromInputRawDifferentPattern() - { - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'format' => 'MM*yyyy*dd', - 'widget' => 'single_text', - 'input' => 'array', - )); - - $form->submit('06*2010*02'); - - $output = array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - ); - - $this->assertEquals($output, $form->getData()); - $this->assertEquals('06*2010*02', $form->getViewData()); - } - - /** - * @dataProvider provideDateFormats - */ - public function testDatePatternWithFormatOption($format, $pattern) - { - $form = $this->factory->create('date', null, array( - 'format' => $format, - )); - - $view = $form->createView(); - - $this->assertEquals($pattern, $view->vars['date_pattern']); - } - - public function provideDateFormats() - { - return array( - array('dMy', '{{ day }}{{ month }}{{ year }}'), - array('d-M-yyyy', '{{ day }}-{{ month }}-{{ year }}'), - array('M d y', '{{ month }} {{ day }} {{ year }}'), - ); - } - - /** - * This test is to check that the strings '0', '1', '2', '3' are not accepted - * as valid IntlDateFormatter constants for FULL, LONG, MEDIUM or SHORT respectively. - * - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfFormatIsNoPattern() - { - $this->factory->create('date', null, array( - 'format' => '0', - 'widget' => 'single_text', - 'input' => 'string', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfFormatDoesNotContainYearMonthAndDay() - { - $this->factory->create('date', null, array( - 'months' => array(6, 7), - 'format' => 'yy', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfFormatIsNoConstant() - { - $this->factory->create('date', null, array( - 'format' => 105, - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfFormatIsInvalid() - { - $this->factory->create('date', null, array( - 'format' => array(), - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfYearsIsInvalid() - { - $this->factory->create('date', null, array( - 'years' => 'bad value', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfMonthsIsInvalid() - { - $this->factory->create('date', null, array( - 'months' => 'bad value', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfDaysIsInvalid() - { - $this->factory->create('date', null, array( - 'days' => 'bad value', - )); - } - - public function testSetDataWithDifferentNegativeUTCTimezoneDateTime() - { - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'model_timezone' => 'America/New_York', - 'view_timezone' => 'Pacific/Tahiti', - 'input' => 'string', - 'widget' => 'single_text', - )); - - $form->setData('2010-06-02'); - - $this->assertEquals('01.06.2010', $form->getViewData()); - } - - public function testSetDataWithDifferentTimezonesDateTime() - { - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'model_timezone' => 'America/New_York', - 'view_timezone' => 'Pacific/Tahiti', - 'input' => 'datetime', - 'widget' => 'single_text', - )); - - $dateTime = new \DateTime('2010-06-02 America/New_York'); - - $form->setData($dateTime); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - $this->assertEquals('01.06.2010', $form->getViewData()); - } - - public function testSetDataWithDifferentPositiveUTCTimezoneDateTime() - { - date_default_timezone_set('Pacific/Tahiti'); - - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'input' => 'datetime', - 'widget' => 'single_text', - )); - - $dateTime = new \DateTime('2010-06-02 Australia/Melbourne'); - - $form->setData($dateTime); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - $this->assertEquals('02.06.2010', $form->getViewData()); - } - - public function testSetDataWithSamePositiveUTCTimezoneDateTime() - { - date_default_timezone_set('Australia/Melbourne'); - - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'input' => 'datetime', - 'widget' => 'single_text', - )); - - $dateTime = new \DateTime('2010-06-02 Australia/Melbourne'); - - $form->setData($dateTime); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - $this->assertEquals('02.06.2010', $form->getViewData()); - } - - public function testSetDataWithSameNegativeUTCTimezoneDateTime() - { - date_default_timezone_set('America/New_York'); - - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::MEDIUM, - 'input' => 'datetime', - 'widget' => 'single_text', - )); - - $dateTime = new \DateTime('2010-06-02 America/New_York'); - - $form->setData($dateTime); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - $this->assertEquals('02.06.2010', $form->getViewData()); - } - - public function testYearsOption() - { - $form = $this->factory->create('date', null, array( - 'years' => array(2010, 2011), - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('2010', '2010', '2010'), - new ChoiceView('2011', '2011', '2011'), - ), $view['year']->vars['choices']); - } - - public function testMonthsOption() - { - $form = $this->factory->create('date', null, array( - 'months' => array(6, 7), - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), - ), $view['month']->vars['choices']); - } - - public function testMonthsOptionShortFormat() - { - $form = $this->factory->create('date', null, array( - 'months' => array(1, 4), - 'format' => 'dd.MMM.yy', - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('1', '1', 'Jän'), - new ChoiceView('4', '4', 'Apr.'), - ), $view['month']->vars['choices']); - } - - public function testMonthsOptionLongFormat() - { - $form = $this->factory->create('date', null, array( - 'months' => array(1, 4), - 'format' => 'dd.MMMM.yy', - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('1', '1', 'Jänner'), - new ChoiceView('4', '4', 'April'), - ), $view['month']->vars['choices']); - } - - public function testMonthsOptionLongFormatWithDifferentTimezone() - { - $form = $this->factory->create('date', null, array( - 'months' => array(1, 4), - 'format' => 'dd.MMMM.yy', - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('1', '1', 'Jänner'), - new ChoiceView('4', '4', 'April'), - ), $view['month']->vars['choices']); - } - - public function testIsDayWithinRangeReturnsTrueIfWithin() - { - $form = $this->factory->create('date', null, array( - 'days' => array(6, 7), - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), - ), $view['day']->vars['choices']); - } - - public function testIsPartiallyFilledReturnsFalseIfSingleText() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'single_text', - )); - - $form->submit('7.6.2010'); - - $this->assertFalse($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyEmpty() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'choice', - )); - - $form->submit(array( - 'day' => '', - 'month' => '', - 'year' => '', - )); - - $this->assertFalse($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsFalseIfChoiceAndCompletelyFilled() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'choice', - )); - - $form->submit(array( - 'day' => '2', - 'month' => '6', - 'year' => '2010', - )); - - $this->assertFalse($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsTrueIfChoiceAndDayEmpty() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('date', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'widget' => 'choice', - )); - - $form->submit(array( - 'day' => '', - 'month' => '6', - 'year' => '2010', - )); - - $this->assertTrue($form->isPartiallyFilled()); - } - - public function testPassDatePatternToView() - { - $form = $this->factory->create('date'); - $view = $form->createView(); - - $this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']); - } - - public function testPassDatePatternToViewDifferentFormat() - { - $form = $this->factory->create('date', null, array( - 'format' => \IntlDateFormatter::LONG, - )); - - $view = $form->createView(); - - $this->assertSame('{{ day }}{{ month }}{{ year }}', $view->vars['date_pattern']); - } - - public function testPassDatePatternToViewDifferentPattern() - { - $form = $this->factory->create('date', null, array( - 'format' => 'MMyyyydd', - )); - - $view = $form->createView(); - - $this->assertSame('{{ month }}{{ year }}{{ day }}', $view->vars['date_pattern']); - } - - public function testPassDatePatternToViewDifferentPatternWithSeparators() - { - $form = $this->factory->create('date', null, array( - 'format' => 'MM*yyyy*dd', - )); - - $view = $form->createView(); - - $this->assertSame('{{ month }}*{{ year }}*{{ day }}', $view->vars['date_pattern']); - } - - public function testDontPassDatePatternIfText() - { - $form = $this->factory->create('date', null, array( - 'widget' => 'single_text', - )); - $view = $form->createView(); - - $this->assertFalse(isset($view->vars['date_pattern'])); - } - - public function testPassWidgetToView() - { - $form = $this->factory->create('date', null, array( - 'widget' => 'single_text', - )); - $view = $form->createView(); - - $this->assertSame('single_text', $view->vars['widget']); - } - - // Bug fix - public function testInitializeWithDateTime() - { - // Throws an exception if "data_class" option is not explicitly set - // to null in the type - $this->factory->create('date', new \DateTime()); - } - - public function testSingleTextWidgetShouldUseTheRightInputType() - { - $form = $this->factory->create('date', null, array( - 'widget' => 'single_text', - )); - - $view = $form->createView(); - $this->assertEquals('date', $view->vars['type']); - } - - public function testPassDefaultPlaceholderToViewIfNotRequired() - { - $form = $this->factory->create('date', null, array( - 'required' => false, - )); - - $view = $form->createView(); - $this->assertSame('', $view['year']->vars['placeholder']); - $this->assertSame('', $view['month']->vars['placeholder']); - $this->assertSame('', $view['day']->vars['placeholder']); - } - - public function testPassNoPlaceholderToViewIfRequired() - { - $form = $this->factory->create('date', null, array( - 'required' => true, - )); - - $view = $form->createView(); - $this->assertNull($view['year']->vars['placeholder']); - $this->assertNull($view['month']->vars['placeholder']); - $this->assertNull($view['day']->vars['placeholder']); - } - - public function testPassPlaceholderAsString() - { - $form = $this->factory->create('date', null, array( - 'placeholder' => 'Empty', - )); - - $view = $form->createView(); - $this->assertSame('Empty', $view['year']->vars['placeholder']); - $this->assertSame('Empty', $view['month']->vars['placeholder']); - $this->assertSame('Empty', $view['day']->vars['placeholder']); - } - - public function testPassEmptyValueBC() - { - $form = $this->factory->create('date', null, array( - 'empty_value' => 'Empty', - )); - - $view = $form->createView(); - $this->assertSame('Empty', $view['year']->vars['placeholder']); - $this->assertSame('Empty', $view['month']->vars['placeholder']); - $this->assertSame('Empty', $view['day']->vars['placeholder']); - $this->assertSame('Empty', $view['year']->vars['empty_value']); - $this->assertSame('Empty', $view['month']->vars['empty_value']); - $this->assertSame('Empty', $view['day']->vars['empty_value']); - } - - public function testPassPlaceholderAsArray() - { - $form = $this->factory->create('date', null, array( - 'placeholder' => array( - 'year' => 'Empty year', - 'month' => 'Empty month', - 'day' => 'Empty day', - ), - )); - - $view = $form->createView(); - $this->assertSame('Empty year', $view['year']->vars['placeholder']); - $this->assertSame('Empty month', $view['month']->vars['placeholder']); - $this->assertSame('Empty day', $view['day']->vars['placeholder']); - } - - public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() - { - $form = $this->factory->create('date', null, array( - 'required' => false, - 'placeholder' => array( - 'year' => 'Empty year', - 'day' => 'Empty day', - ), - )); - - $view = $form->createView(); - $this->assertSame('Empty year', $view['year']->vars['placeholder']); - $this->assertSame('', $view['month']->vars['placeholder']); - $this->assertSame('Empty day', $view['day']->vars['placeholder']); - } - - public function testPassPlaceholderAsPartialArrayAddNullIfRequired() - { - $form = $this->factory->create('date', null, array( - 'required' => true, - 'placeholder' => array( - 'year' => 'Empty year', - 'day' => 'Empty day', - ), - )); - - $view = $form->createView(); - $this->assertSame('Empty year', $view['year']->vars['placeholder']); - $this->assertNull($view['month']->vars['placeholder']); - $this->assertSame('Empty day', $view['day']->vars['placeholder']); - } - - public function testPassHtml5TypeIfSingleTextAndHtml5Format() - { - $form = $this->factory->create('date', null, array( - 'widget' => 'single_text', - )); - - $view = $form->createView(); - $this->assertSame('date', $view->vars['type']); - } - - public function testDontPassHtml5TypeIfHtml5NotAllowed() - { - $form = $this->factory->create('date', null, array( - 'widget' => 'single_text', - 'html5' => false, - )); - - $view = $form->createView(); - $this->assertFalse(isset($view->vars['type'])); - } - - public function testDontPassHtml5TypeIfNotHtml5Format() - { - $form = $this->factory->create('date', null, array( - 'widget' => 'single_text', - 'format' => \IntlDateFormatter::MEDIUM, - )); - - $view = $form->createView(); - $this->assertFalse(isset($view->vars['type'])); - } - - public function testDontPassHtml5TypeIfNotSingleText() - { - $form = $this->factory->create('date', null, array( - 'widget' => 'text', - )); - - $view = $form->createView(); - $this->assertFalse(isset($view->vars['type'])); - } - - public function provideCompoundWidgets() - { - return array( - array('text'), - array('choice'), - ); - } - - /** - * @dataProvider provideCompoundWidgets - */ - public function testYearErrorsBubbleUp($widget) - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('date', null, array( - 'widget' => $widget, - )); - $form['year']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['year']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - /** - * @dataProvider provideCompoundWidgets - */ - public function testMonthErrorsBubbleUp($widget) - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('date', null, array( - 'widget' => $widget, - )); - $form['month']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['month']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - /** - * @dataProvider provideCompoundWidgets - */ - public function testDayErrorsBubbleUp($widget) - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('date', null, array( - 'widget' => $widget, - )); - $form['day']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['day']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - public function testYearsFor32BitsMachines() - { - if (4 !== PHP_INT_SIZE) { - $this->markTestSkipped( - 'PHP must be compiled in 32 bit mode to run this test'); - } - - $form = $this->factory->create('date', null, array( - 'years' => range(1900, 2040), - )); - - $view = $form->createView(); - - $listChoices = array(); - foreach (range(1902, 2037) as $y) { - $listChoices[] = new ChoiceView($y, $y, $y); - } - - $this->assertEquals($listChoices, $view['year']->vars['choices']); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php deleted file mode 100644 index 55555efec..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FileTypeTest.php +++ /dev/null @@ -1,102 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -class FileTypeTest extends \Symfony\Component\Form\Test\TypeTestCase -{ - // https://github.com/symfony/symfony/pull/5028 - public function testSetData() - { - $form = $this->factory->createBuilder('file')->getForm(); - $data = $this->createUploadedFileMock('abcdef', 'original.jpg', true); - - $form->setData($data); - - $this->assertSame($data, $form->getData()); - } - - public function testSubmit() - { - $form = $this->factory->createBuilder('file')->getForm(); - $data = $this->createUploadedFileMock('abcdef', 'original.jpg', true); - - $form->submit($data); - - $this->assertSame($data, $form->getData()); - } - - // https://github.com/symfony/symfony/issues/6134 - public function testSubmitEmpty() - { - $form = $this->factory->createBuilder('file')->getForm(); - - $form->submit(null); - - $this->assertNull($form->getData()); - } - - public function testSubmitMultiple() - { - $form = $this->factory->createBuilder('file', null, array( - 'multiple' => true, - ))->getForm(); - - $data = array( - $this->createUploadedFileMock('abcdef', 'first.jpg', true), - $this->createUploadedFileMock('zyxwvu', 'second.jpg', true), - ); - - $form->submit($data); - $this->assertSame($data, $form->getData()); - - $view = $form->createView(); - $this->assertSame('file[]', $view->vars['full_name']); - $this->assertArrayHasKey('multiple', $view->vars['attr']); - } - - public function testDontPassValueToView() - { - $form = $this->factory->create('file'); - $form->submit(array( - 'file' => $this->createUploadedFileMock('abcdef', 'original.jpg', true), - )); - $view = $form->createView(); - - $this->assertEquals('', $view->vars['value']); - } - - private function createUploadedFileMock($name, $originalName, $valid) - { - $file = $this - ->getMockBuilder('Symfony\Component\HttpFoundation\File\UploadedFile') - ->setConstructorArgs(array(__DIR__.'/../../../Fixtures/foo', 'foo')) - ->getMock() - ; - $file - ->expects($this->any()) - ->method('getBasename') - ->will($this->returnValue($name)) - ; - $file - ->expects($this->any()) - ->method('getClientOriginalName') - ->will($this->returnValue($originalName)) - ; - $file - ->expects($this->any()) - ->method('isValid') - ->will($this->returnValue($valid)) - ; - - return $file; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php deleted file mode 100644 index 93d528540..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php +++ /dev/null @@ -1,658 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\PropertyAccess\PropertyPath; -use Symfony\Component\Form\CallbackTransformer; -use Symfony\Component\Form\Tests\Fixtures\Author; -use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; -use Symfony\Component\Form\FormError; - -class FormTest_AuthorWithoutRefSetter -{ - protected $reference; - - protected $referenceCopy; - - public function __construct($reference) - { - $this->reference = $reference; - $this->referenceCopy = $reference; - } - - // The returned object should be modified by reference without having - // to provide a setReference() method - public function getReference() - { - return $this->reference; - } - - // The returned object is a copy, so setReferenceCopy() must be used - // to update it - public function getReferenceCopy() - { - return is_object($this->referenceCopy) ? clone $this->referenceCopy : $this->referenceCopy; - } - - public function setReferenceCopy($reference) - { - $this->referenceCopy = $reference; - } -} - -class FormTypeTest extends BaseTypeTest -{ - public function testCreateFormInstances() - { - $this->assertInstanceOf('Symfony\Component\Form\Form', $this->factory->create('form')); - } - - public function testPassRequiredAsOption() - { - $form = $this->factory->create('form', null, array('required' => false)); - - $this->assertFalse($form->isRequired()); - - $form = $this->factory->create('form', null, array('required' => true)); - - $this->assertTrue($form->isRequired()); - } - - public function testSubmittedDataIsTrimmedBeforeTransforming() - { - $form = $this->factory->createBuilder('form') - ->addViewTransformer(new FixedDataTransformer(array( - null => '', - 'reverse[a]' => 'a', - ))) - ->setCompound(false) - ->getForm(); - - $form->submit(' a '); - - $this->assertEquals('a', $form->getViewData()); - $this->assertEquals('reverse[a]', $form->getData()); - } - - public function testSubmittedDataIsNotTrimmedBeforeTransformingIfNoTrimming() - { - $form = $this->factory->createBuilder('form', null, array('trim' => false)) - ->addViewTransformer(new FixedDataTransformer(array( - null => '', - 'reverse[ a ]' => ' a ', - ))) - ->setCompound(false) - ->getForm(); - - $form->submit(' a '); - - $this->assertEquals(' a ', $form->getViewData()); - $this->assertEquals('reverse[ a ]', $form->getData()); - } - - public function testNonReadOnlyFormWithReadOnlyParentIsReadOnly() - { - $view = $this->factory->createNamedBuilder('parent', 'form', null, array('read_only' => true)) - ->add('child', 'form') - ->getForm() - ->createView(); - - $this->assertTrue($view['child']->vars['read_only']); - } - - public function testReadOnlyFormWithNonReadOnlyParentIsReadOnly() - { - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', 'form', array('read_only' => true)) - ->getForm() - ->createView(); - - $this->assertTrue($view['child']->vars['read_only']); - } - - public function testNonReadOnlyFormWithNonReadOnlyParentIsNotReadOnly() - { - $view = $this->factory->createNamedBuilder('parent', 'form') - ->add('child', 'form') - ->getForm() - ->createView(); - - $this->assertFalse($view['child']->vars['read_only']); - } - - public function testPassMaxLengthToView() - { - $form = $this->factory->create('form', null, array('attr' => array('maxlength' => 10))); - $view = $form->createView(); - - $this->assertSame(10, $view->vars['attr']['maxlength']); - } - - public function testPassMaxLengthBCToView() - { - $form = $this->factory->create('form', null, array('max_length' => 10)); - $view = $form->createView(); - - $this->assertSame(10, $view->vars['attr']['maxlength']); - } - - public function testDataClassMayBeNull() - { - $this->factory->createBuilder('form', null, array( - 'data_class' => null, - )); - } - - public function testDataClassMayBeAbstractClass() - { - $this->factory->createBuilder('form', null, array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AbstractAuthor', - )); - } - - public function testDataClassMayBeInterface() - { - $this->factory->createBuilder('form', null, array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\AuthorInterface', - )); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - */ - public function testDataClassMustBeValidClassOrInterface() - { - $this->factory->createBuilder('form', null, array( - 'data_class' => 'foobar', - )); - } - - public function testSubmitWithEmptyDataCreatesObjectIfClassAvailable() - { - $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - 'required' => false, - )); - $builder->add('firstName', 'text'); - $builder->add('lastName', 'text'); - $form = $builder->getForm(); - - $form->setData(null); - // partially empty, still an object is created - $form->submit(array('firstName' => 'Bernhard', 'lastName' => '')); - - $author = new Author(); - $author->firstName = 'Bernhard'; - $author->setLastName(''); - - $this->assertEquals($author, $form->getData()); - } - - public function testSubmitWithEmptyDataCreatesObjectIfInitiallySubmittedWithObject() - { - $builder = $this->factory->createBuilder('form', null, array( - // data class is inferred from the passed object - 'data' => new Author(), - 'required' => false, - )); - $builder->add('firstName', 'text'); - $builder->add('lastName', 'text'); - $form = $builder->getForm(); - - $form->setData(null); - // partially empty, still an object is created - $form->submit(array('firstName' => 'Bernhard', 'lastName' => '')); - - $author = new Author(); - $author->firstName = 'Bernhard'; - $author->setLastName(''); - - $this->assertEquals($author, $form->getData()); - } - - public function testSubmitWithEmptyDataCreatesArrayIfDataClassIsNull() - { - $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => null, - 'required' => false, - )); - $builder->add('firstName', 'text'); - $form = $builder->getForm(); - - $form->setData(null); - $form->submit(array('firstName' => 'Bernhard')); - - $this->assertSame(array('firstName' => 'Bernhard'), $form->getData()); - } - - public function testSubmitEmptyWithEmptyDataCreatesNoObjectIfNotRequired() - { - $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - 'required' => false, - )); - $builder->add('firstName', 'text'); - $builder->add('lastName', 'text'); - $form = $builder->getForm(); - - $form->setData(null); - $form->submit(array('firstName' => '', 'lastName' => '')); - - $this->assertNull($form->getData()); - } - - public function testSubmitEmptyWithEmptyDataCreatesObjectIfRequired() - { - $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - 'required' => true, - )); - $builder->add('firstName', 'text'); - $builder->add('lastName', 'text'); - $form = $builder->getForm(); - - $form->setData(null); - $form->submit(array('firstName' => '', 'lastName' => '')); - - $this->assertEquals(new Author(), $form->getData()); - } - - /* - * We need something to write the field values into - */ - public function testSubmitWithEmptyDataStoresArrayIfNoClassAvailable() - { - $form = $this->factory->createBuilder('form') - ->add('firstName', 'text') - ->getForm(); - - $form->setData(null); - $form->submit(array('firstName' => 'Bernhard')); - - $this->assertSame(array('firstName' => 'Bernhard'), $form->getData()); - } - - public function testSubmitWithEmptyDataPassesEmptyStringToTransformerIfNotCompound() - { - $form = $this->factory->createBuilder('form') - ->addViewTransformer(new FixedDataTransformer(array( - // required for the initial, internal setData(null) - null => 'null', - // required to test that submit(null) is converted to '' - 'empty' => '', - ))) - ->setCompound(false) - ->getForm(); - - $form->submit(null); - - $this->assertSame('empty', $form->getData()); - } - - public function testSubmitWithEmptyDataUsesEmptyDataOption() - { - $author = new Author(); - - $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - 'empty_data' => $author, - )); - $builder->add('firstName', 'text'); - $form = $builder->getForm(); - - $form->submit(array('firstName' => 'Bernhard')); - - $this->assertSame($author, $form->getData()); - $this->assertEquals('Bernhard', $author->firstName); - } - - public function provideZeros() - { - return array( - array(0, '0'), - array('0', '0'), - array('00000', '00000'), - ); - } - - /** - * @dataProvider provideZeros - * - * @see https://github.com/symfony/symfony/issues/1986 - */ - public function testSetDataThroughParamsWithZero($data, $dataAsString) - { - $form = $this->factory->create('form', null, array( - 'data' => $data, - 'compound' => false, - )); - $view = $form->createView(); - - $this->assertFalse($form->isEmpty()); - - $this->assertSame($dataAsString, $view->vars['value']); - $this->assertSame($dataAsString, $form->getData()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testAttributesException() - { - $this->factory->create('form', null, array('attr' => '')); - } - - public function testNameCanBeEmptyString() - { - $form = $this->factory->createNamed('', 'form'); - - $this->assertEquals('', $form->getName()); - } - - public function testSubformDoesntCallSetters() - { - $author = new FormTest_AuthorWithoutRefSetter(new Author()); - - $builder = $this->factory->createBuilder('form', $author); - $builder->add('reference', 'form', array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - )); - $builder->get('reference')->add('firstName', 'text'); - $form = $builder->getForm(); - - $form->submit(array( - // reference has a getter, but not setter - 'reference' => array( - 'firstName' => 'Foo', - ), - )); - - $this->assertEquals('Foo', $author->getReference()->firstName); - } - - public function testSubformCallsSettersIfTheObjectChanged() - { - // no reference - $author = new FormTest_AuthorWithoutRefSetter(null); - $newReference = new Author(); - - $builder = $this->factory->createBuilder('form', $author); - $builder->add('referenceCopy', 'form', array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - )); - $builder->get('referenceCopy')->add('firstName', 'text'); - $form = $builder->getForm(); - - $form['referenceCopy']->setData($newReference); // new author object - - $form->submit(array( - // referenceCopy has a getter that returns a copy - 'referenceCopy' => array( - 'firstName' => 'Foo', - ), - )); - - $this->assertEquals('Foo', $author->getReferenceCopy()->firstName); - } - - public function testSubformCallsSettersIfByReferenceIsFalse() - { - $author = new FormTest_AuthorWithoutRefSetter(new Author()); - - $builder = $this->factory->createBuilder('form', $author); - $builder->add('referenceCopy', 'form', array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - 'by_reference' => false, - )); - $builder->get('referenceCopy')->add('firstName', 'text'); - $form = $builder->getForm(); - - $form->submit(array( - // referenceCopy has a getter that returns a copy - 'referenceCopy' => array( - 'firstName' => 'Foo', - ), - )); - - // firstName can only be updated if setReferenceCopy() was called - $this->assertEquals('Foo', $author->getReferenceCopy()->firstName); - } - - public function testSubformCallsSettersIfReferenceIsScalar() - { - $author = new FormTest_AuthorWithoutRefSetter('scalar'); - - $builder = $this->factory->createBuilder('form', $author); - $builder->add('referenceCopy', 'form'); - $builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer( - function () {}, - function ($value) { // reverseTransform - - return 'foobar'; - } - )); - $form = $builder->getForm(); - - $form->submit(array( - 'referenceCopy' => array(), // doesn't matter actually - )); - - // firstName can only be updated if setReferenceCopy() was called - $this->assertEquals('foobar', $author->getReferenceCopy()); - } - - public function testSubformAlwaysInsertsIntoArrays() - { - $ref1 = new Author(); - $ref2 = new Author(); - $author = array('referenceCopy' => $ref1); - - $builder = $this->factory->createBuilder('form'); - $builder->setData($author); - $builder->add('referenceCopy', 'form'); - $builder->get('referenceCopy')->addViewTransformer(new CallbackTransformer( - function () {}, - function ($value) use ($ref2) { // reverseTransform - - return $ref2; - } - )); - $form = $builder->getForm(); - - $form->submit(array( - 'referenceCopy' => array('a' => 'b'), // doesn't matter actually - )); - - // the new reference was inserted into the array - $author = $form->getData(); - $this->assertSame($ref2, $author['referenceCopy']); - } - - public function testPassMultipartTrueIfAnyChildIsMultipartToView() - { - $view = $this->factory->createBuilder('form') - ->add('foo', 'text') - ->add('bar', 'file') - ->getForm() - ->createView(); - - $this->assertTrue($view->vars['multipart']); - } - - public function testViewIsNotRenderedByDefault() - { - $view = $this->factory->createBuilder('form') - ->add('foo', 'form') - ->getForm() - ->createView(); - - $this->assertFalse($view->isRendered()); - } - - public function testErrorBubblingIfCompound() - { - $form = $this->factory->create('form', null, array( - 'compound' => true, - )); - - $this->assertTrue($form->getConfig()->getErrorBubbling()); - } - - public function testNoErrorBubblingIfNotCompound() - { - $form = $this->factory->create('form', null, array( - 'compound' => false, - )); - - $this->assertFalse($form->getConfig()->getErrorBubbling()); - } - - public function testOverrideErrorBubbling() - { - $form = $this->factory->create('form', null, array( - 'compound' => false, - 'error_bubbling' => true, - )); - - $this->assertTrue($form->getConfig()->getErrorBubbling()); - } - - public function testPropertyPath() - { - $form = $this->factory->create('form', null, array( - 'property_path' => 'foo', - )); - - $this->assertEquals(new PropertyPath('foo'), $form->getPropertyPath()); - $this->assertTrue($form->getConfig()->getMapped()); - } - - public function testPropertyPathNullImpliesDefault() - { - $form = $this->factory->createNamed('name', 'form', null, array( - 'property_path' => null, - )); - - $this->assertEquals(new PropertyPath('name'), $form->getPropertyPath()); - $this->assertTrue($form->getConfig()->getMapped()); - } - - public function testNotMapped() - { - $form = $this->factory->create('form', null, array( - 'property_path' => 'foo', - 'mapped' => false, - )); - - $this->assertEquals(new PropertyPath('foo'), $form->getPropertyPath()); - $this->assertFalse($form->getConfig()->getMapped()); - } - - public function testViewValidNotSubmitted() - { - $form = $this->factory->create('form'); - $view = $form->createView(); - $this->assertTrue($view->vars['valid']); - } - - public function testViewNotValidSubmitted() - { - $form = $this->factory->create('form'); - $form->submit(array()); - $form->addError(new FormError('An error')); - $view = $form->createView(); - $this->assertFalse($view->vars['valid']); - } - - public function testViewSubmittedNotSubmitted() - { - $form = $this->factory->create('form'); - $view = $form->createView(); - $this->assertFalse($view->vars['submitted']); - } - - public function testViewSubmittedSubmitted() - { - $form = $this->factory->create('form'); - $form->submit(array()); - $view = $form->createView(); - $this->assertTrue($view->vars['submitted']); - } - - public function testDataOptionSupersedesSetDataCalls() - { - $form = $this->factory->create('form', null, array( - 'data' => 'default', - 'compound' => false, - )); - - $form->setData('foobar'); - - $this->assertSame('default', $form->getData()); - } - - public function testDataOptionSupersedesSetDataCallsIfNull() - { - $form = $this->factory->create('form', null, array( - 'data' => null, - 'compound' => false, - )); - - $form->setData('foobar'); - - $this->assertNull($form->getData()); - } - - public function testNormDataIsPassedToView() - { - $view = $this->factory->createBuilder('form') - ->addViewTransformer(new FixedDataTransformer(array( - 'foo' => 'bar', - ))) - ->setData('foo') - ->getForm() - ->createView(); - - $this->assertSame('foo', $view->vars['data']); - $this->assertSame('bar', $view->vars['value']); - } - - // https://github.com/symfony/symfony/issues/6862 - public function testPassZeroLabelToView() - { - $view = $this->factory->create('form', null, array( - 'label' => '0', - )) - ->createView(); - - $this->assertSame('0', $view->vars['label']); - } - - public function testCanGetErrorsWhenButtonInForm() - { - $builder = $this->factory->createBuilder('form', null, array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - 'required' => false, - )); - $builder->add('foo', 'text'); - $builder->add('submit', 'submit'); - $form = $builder->getForm(); - - //This method should not throw a Fatal Error Exception. - $form->getErrorsAsString(); - } - - protected function getTestedType() - { - return 'form'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php deleted file mode 100644 index 85f91ff18..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/IntegerTypeTest.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class IntegerTypeTest extends TestCase -{ - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - - public function testSubmitCastsToInteger() - { - $form = $this->factory->create('integer'); - - $form->submit('1.678'); - - $this->assertSame(1, $form->getData()); - $this->assertSame('1', $form->getViewData()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php deleted file mode 100644 index e23481188..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LanguageTypeTest.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Extension\Core\View\ChoiceView; -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class LanguageTypeTest extends TestCase -{ - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - - public function testCountriesAreSelectable() - { - $form = $this->factory->create('language'); - $view = $form->createView(); - $choices = $view->vars['choices']; - - $this->assertContains(new ChoiceView('en', 'en', 'English'), $choices, '', false, false); - $this->assertContains(new ChoiceView('en_GB', 'en_GB', 'British English'), $choices, '', false, false); - $this->assertContains(new ChoiceView('en_US', 'en_US', 'American English'), $choices, '', false, false); - $this->assertContains(new ChoiceView('fr', 'fr', 'French'), $choices, '', false, false); - $this->assertContains(new ChoiceView('my', 'my', 'Burmese'), $choices, '', false, false); - } - - public function testMultipleLanguagesIsNotIncluded() - { - $form = $this->factory->create('language', 'language'); - $view = $form->createView(); - $choices = $view->vars['choices']; - - $this->assertNotContains(new ChoiceView('mul', 'mul', 'Mehrsprachig'), $choices, '', false, false); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php deleted file mode 100644 index 6c1951a4e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/LocaleTypeTest.php +++ /dev/null @@ -1,37 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Extension\Core\View\ChoiceView; -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class LocaleTypeTest extends TestCase -{ - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - - public function testLocalesAreSelectable() - { - $form = $this->factory->create('locale'); - $view = $form->createView(); - $choices = $view->vars['choices']; - - $this->assertContains(new ChoiceView('en', 'en', 'English'), $choices, '', false, false); - $this->assertContains(new ChoiceView('en_GB', 'en_GB', 'English (United Kingdom)'), $choices, '', false, false); - $this->assertContains(new ChoiceView('zh_Hant_MO', 'zh_Hant_MO', 'Chinese (Traditional, Macau SAR China)'), $choices, '', false, false); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php deleted file mode 100644 index c499908d7..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php +++ /dev/null @@ -1,60 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class MoneyTypeTest extends TestCase -{ - protected function setUp() - { - // we test against different locales, so we need the full - // implementation - IntlTestHelper::requireFullIntl($this); - - parent::setUp(); - } - - public function testPassMoneyPatternToView() - { - \Locale::setDefault('de_DE'); - - $form = $this->factory->create('money'); - $view = $form->createView(); - - $this->assertSame('{{ widget }} €', $view->vars['money_pattern']); - } - - public function testMoneyPatternWorksForYen() - { - \Locale::setDefault('en_US'); - - $form = $this->factory->create('money', null, array('currency' => 'JPY')); - $view = $form->createView(); - $this->assertTrue((bool) strstr($view->vars['money_pattern'], '¥')); - } - - // https://github.com/symfony/symfony/issues/5458 - public function testPassDifferentPatternsForDifferentCurrencies() - { - \Locale::setDefault('de_DE'); - - $form1 = $this->factory->create('money', null, array('currency' => 'GBP')); - $form2 = $this->factory->create('money', null, array('currency' => 'EUR')); - $view1 = $form1->createView(); - $view2 = $form2->createView(); - - $this->assertSame('{{ widget }} £', $view1->vars['money_pattern']); - $this->assertSame('{{ widget }} €', $view2->vars['money_pattern']); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php deleted file mode 100644 index d4a88dd26..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php +++ /dev/null @@ -1,64 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class NumberTypeTest extends TestCase -{ - protected function setUp() - { - parent::setUp(); - - // we test against "de_DE", so we need the full implementation - IntlTestHelper::requireFullIntl($this); - - \Locale::setDefault('de_DE'); - } - - public function testDefaultFormatting() - { - $form = $this->factory->create('number'); - $form->setData('12345.67890'); - $view = $form->createView(); - - $this->assertSame('12345,679', $view->vars['value']); - } - - public function testDefaultFormattingWithGrouping() - { - $form = $this->factory->create('number', null, array('grouping' => true)); - $form->setData('12345.67890'); - $view = $form->createView(); - - $this->assertSame('12.345,679', $view->vars['value']); - } - - public function testDefaultFormattingWithPrecision() - { - $form = $this->factory->create('number', null, array('precision' => 2)); - $form->setData('12345.67890'); - $view = $form->createView(); - - $this->assertSame('12345,68', $view->vars['value']); - } - - public function testDefaultFormattingWithRounding() - { - $form = $this->factory->create('number', null, array('precision' => 0, 'rounding_mode' => \NumberFormatter::ROUND_UP)); - $form->setData('12345.54321'); - $view = $form->createView(); - - $this->assertSame('12346', $view->vars['value']); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php deleted file mode 100644 index bccb6f7b7..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/PasswordTypeTest.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -class PasswordTypeTest extends \Symfony\Component\Form\Test\TypeTestCase -{ - public function testEmptyIfNotSubmitted() - { - $form = $this->factory->create('password'); - $form->setData('pAs5w0rd'); - $view = $form->createView(); - - $this->assertSame('', $view->vars['value']); - } - - public function testEmptyIfSubmitted() - { - $form = $this->factory->create('password'); - $form->submit('pAs5w0rd'); - $view = $form->createView(); - - $this->assertSame('', $view->vars['value']); - } - - public function testNotEmptyIfSubmittedAndNotAlwaysEmpty() - { - $form = $this->factory->create('password', null, array('always_empty' => false)); - $form->submit('pAs5w0rd'); - $view = $form->createView(); - - $this->assertSame('pAs5w0rd', $view->vars['value']); - } - - public function testNotTrimmed() - { - $form = $this->factory->create('password', null); - $form->submit(' pAs5w0rd '); - $data = $form->getData(); - - $this->assertSame(' pAs5w0rd ', $data); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php deleted file mode 100644 index 8e56b8feb..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/RepeatedTypeTest.php +++ /dev/null @@ -1,182 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -class RepeatedTypeTest extends \Symfony\Component\Form\Test\TypeTestCase -{ - protected $form; - - protected function setUp() - { - parent::setUp(); - - $this->form = $this->factory->create('repeated', null, array( - 'type' => 'text', - )); - $this->form->setData(null); - } - - public function testSetData() - { - $this->form->setData('foobar'); - - $this->assertEquals('foobar', $this->form['first']->getData()); - $this->assertEquals('foobar', $this->form['second']->getData()); - } - - public function testSetOptions() - { - $form = $this->factory->create('repeated', null, array( - 'type' => 'text', - 'options' => array('label' => 'Global'), - )); - - $this->assertEquals('Global', $form['first']->getConfig()->getOption('label')); - $this->assertEquals('Global', $form['second']->getConfig()->getOption('label')); - $this->assertTrue($form['first']->isRequired()); - $this->assertTrue($form['second']->isRequired()); - } - - public function testSetOptionsPerChild() - { - $form = $this->factory->create('repeated', null, array( - // the global required value cannot be overridden - 'type' => 'text', - 'first_options' => array('label' => 'Test', 'required' => false), - 'second_options' => array('label' => 'Test2'), - )); - - $this->assertEquals('Test', $form['first']->getConfig()->getOption('label')); - $this->assertEquals('Test2', $form['second']->getConfig()->getOption('label')); - $this->assertTrue($form['first']->isRequired()); - $this->assertTrue($form['second']->isRequired()); - } - - public function testSetRequired() - { - $form = $this->factory->create('repeated', null, array( - 'required' => false, - 'type' => 'text', - )); - - $this->assertFalse($form['first']->isRequired()); - $this->assertFalse($form['second']->isRequired()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testSetInvalidOptions() - { - $this->factory->create('repeated', null, array( - 'type' => 'text', - 'options' => 'bad value', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testSetInvalidFirstOptions() - { - $this->factory->create('repeated', null, array( - 'type' => 'text', - 'first_options' => 'bad value', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testSetInvalidSecondOptions() - { - $this->factory->create('repeated', null, array( - 'type' => 'text', - 'second_options' => 'bad value', - )); - } - - public function testSetErrorBubblingToTrue() - { - $form = $this->factory->create('repeated', null, array( - 'error_bubbling' => true, - )); - - $this->assertTrue($form->getConfig()->getOption('error_bubbling')); - $this->assertTrue($form['first']->getConfig()->getOption('error_bubbling')); - $this->assertTrue($form['second']->getConfig()->getOption('error_bubbling')); - } - - public function testSetErrorBubblingToFalse() - { - $form = $this->factory->create('repeated', null, array( - 'error_bubbling' => false, - )); - - $this->assertFalse($form->getConfig()->getOption('error_bubbling')); - $this->assertFalse($form['first']->getConfig()->getOption('error_bubbling')); - $this->assertFalse($form['second']->getConfig()->getOption('error_bubbling')); - } - - public function testSetErrorBubblingIndividually() - { - $form = $this->factory->create('repeated', null, array( - 'error_bubbling' => true, - 'options' => array('error_bubbling' => false), - 'second_options' => array('error_bubbling' => true), - )); - - $this->assertTrue($form->getConfig()->getOption('error_bubbling')); - $this->assertFalse($form['first']->getConfig()->getOption('error_bubbling')); - $this->assertTrue($form['second']->getConfig()->getOption('error_bubbling')); - } - - public function testSetOptionsPerChildAndOverwrite() - { - $form = $this->factory->create('repeated', null, array( - 'type' => 'text', - 'options' => array('label' => 'Label'), - 'second_options' => array('label' => 'Second label'), - )); - - $this->assertEquals('Label', $form['first']->getConfig()->getOption('label')); - $this->assertEquals('Second label', $form['second']->getConfig()->getOption('label')); - $this->assertTrue($form['first']->isRequired()); - $this->assertTrue($form['second']->isRequired()); - } - - public function testSubmitUnequal() - { - $input = array('first' => 'foo', 'second' => 'bar'); - - $this->form->submit($input); - - $this->assertEquals('foo', $this->form['first']->getViewData()); - $this->assertEquals('bar', $this->form['second']->getViewData()); - $this->assertFalse($this->form->isSynchronized()); - $this->assertEquals($input, $this->form->getViewData()); - $this->assertNull($this->form->getData()); - } - - public function testSubmitEqual() - { - $input = array('first' => 'foo', 'second' => 'foo'); - - $this->form->submit($input); - - $this->assertEquals('foo', $this->form['first']->getViewData()); - $this->assertEquals('foo', $this->form['second']->getViewData()); - $this->assertTrue($this->form->isSynchronized()); - $this->assertEquals($input, $this->form->getViewData()); - $this->assertEquals('foo', $this->form->getData()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php deleted file mode 100644 index 212ffd400..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/SubmitTypeTest.php +++ /dev/null @@ -1,65 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Test\TypeTestCase as TestCase; - -/** - * @author Bernhard Schussek - */ -class SubmitTypeTest extends TestCase -{ - public function testCreateSubmitButtonInstances() - { - $this->assertInstanceOf('Symfony\Component\Form\SubmitButton', $this->factory->create('submit')); - } - - public function testNotClickedByDefault() - { - $button = $this->factory->create('submit'); - - $this->assertFalse($button->isClicked()); - } - - public function testNotClickedIfSubmittedWithNull() - { - $button = $this->factory->create('submit'); - $button->submit(null); - - $this->assertFalse($button->isClicked()); - } - - public function testClickedIfSubmittedWithEmptyString() - { - $button = $this->factory->create('submit'); - $button->submit(''); - - $this->assertTrue($button->isClicked()); - } - - public function testClickedIfSubmittedWithUnemptyString() - { - $button = $this->factory->create('submit'); - $button->submit('foo'); - - $this->assertTrue($button->isClicked()); - } - - public function testSubmitCanBeAddedToForm() - { - $form = $this->factory - ->createBuilder('form') - ->getForm(); - - $this->assertSame($form, $form->add('send', 'submit')); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php deleted file mode 100644 index dfa8fbc5a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimeTypeTest.php +++ /dev/null @@ -1,734 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Extension\Core\View\ChoiceView; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Test\TypeTestCase as TestCase; -use Symfony\Component\Intl\Util\IntlTestHelper; - -class TimeTypeTest extends TestCase -{ - protected function setUp() - { - IntlTestHelper::requireIntl($this); - - parent::setUp(); - } - - public function testSubmitDateTime() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'datetime', - )); - - $input = array( - 'hour' => '3', - 'minute' => '4', - ); - - $form->submit($input); - - $dateTime = new \DateTime('1970-01-01 03:04:00 UTC'); - - $this->assertEquals($dateTime, $form->getData()); - $this->assertEquals($input, $form->getViewData()); - } - - public function testSubmitString() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'string', - )); - - $input = array( - 'hour' => '3', - 'minute' => '4', - ); - - $form->submit($input); - - $this->assertEquals('03:04:00', $form->getData()); - $this->assertEquals($input, $form->getViewData()); - } - - public function testSubmitTimestamp() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'timestamp', - )); - - $input = array( - 'hour' => '3', - 'minute' => '4', - ); - - $form->submit($input); - - $dateTime = new \DateTime('1970-01-01 03:04:00 UTC'); - - $this->assertEquals($dateTime->format('U'), $form->getData()); - $this->assertEquals($input, $form->getViewData()); - } - - public function testSubmitArray() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'array', - )); - - $input = array( - 'hour' => '3', - 'minute' => '4', - ); - - $form->submit($input); - - $this->assertEquals($input, $form->getData()); - $this->assertEquals($input, $form->getViewData()); - } - - public function testSubmitDatetimeSingleText() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'datetime', - 'widget' => 'single_text', - )); - - $form->submit('03:04'); - - $this->assertEquals(new \DateTime('1970-01-01 03:04:00 UTC'), $form->getData()); - $this->assertEquals('03:04', $form->getViewData()); - } - - public function testSubmitDatetimeSingleTextWithoutMinutes() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'datetime', - 'widget' => 'single_text', - 'with_minutes' => false, - )); - - $form->submit('03'); - - $this->assertEquals(new \DateTime('1970-01-01 03:00:00 UTC'), $form->getData()); - $this->assertEquals('03', $form->getViewData()); - } - - public function testSubmitArraySingleText() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'array', - 'widget' => 'single_text', - )); - - $data = array( - 'hour' => '3', - 'minute' => '4', - ); - - $form->submit('03:04'); - - $this->assertEquals($data, $form->getData()); - $this->assertEquals('03:04', $form->getViewData()); - } - - public function testSubmitArraySingleTextWithoutMinutes() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'array', - 'widget' => 'single_text', - 'with_minutes' => false, - )); - - $data = array( - 'hour' => '3', - ); - - $form->submit('03'); - - $this->assertEquals($data, $form->getData()); - $this->assertEquals('03', $form->getViewData()); - } - - public function testSubmitArraySingleTextWithSeconds() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'array', - 'widget' => 'single_text', - 'with_seconds' => true, - )); - - $data = array( - 'hour' => '3', - 'minute' => '4', - 'second' => '5', - ); - - $form->submit('03:04:05'); - - $this->assertEquals($data, $form->getData()); - $this->assertEquals('03:04:05', $form->getViewData()); - } - - public function testSubmitStringSingleText() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'string', - 'widget' => 'single_text', - )); - - $form->submit('03:04'); - - $this->assertEquals('03:04:00', $form->getData()); - $this->assertEquals('03:04', $form->getViewData()); - } - - public function testSubmitStringSingleTextWithoutMinutes() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'string', - 'widget' => 'single_text', - 'with_minutes' => false, - )); - - $form->submit('03'); - - $this->assertEquals('03:00:00', $form->getData()); - $this->assertEquals('03', $form->getViewData()); - } - - public function testSetDataWithoutMinutes() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'datetime', - 'with_minutes' => false, - )); - - $form->setData(new \DateTime('03:04:05 UTC')); - - $this->assertEquals(array('hour' => 3), $form->getViewData()); - } - - public function testSetDataWithSeconds() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'UTC', - 'view_timezone' => 'UTC', - 'input' => 'datetime', - 'with_seconds' => true, - )); - - $form->setData(new \DateTime('03:04:05 UTC')); - - $this->assertEquals(array('hour' => 3, 'minute' => 4, 'second' => 5), $form->getViewData()); - } - - public function testSetDataDifferentTimezones() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'America/New_York', - 'view_timezone' => 'Asia/Hong_Kong', - 'input' => 'string', - 'with_seconds' => true, - )); - - $dateTime = new \DateTime('2013-01-01 12:04:05'); - $dateTime->setTimezone(new \DateTimeZone('America/New_York')); - - $form->setData($dateTime->format('H:i:s')); - - $outputTime = clone $dateTime; - $outputTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); - - $displayedData = array( - 'hour' => (int) $outputTime->format('H'), - 'minute' => (int) $outputTime->format('i'), - 'second' => (int) $outputTime->format('s'), - ); - - $this->assertEquals($displayedData, $form->getViewData()); - } - - public function testSetDataDifferentTimezonesDateTime() - { - $form = $this->factory->create('time', null, array( - 'model_timezone' => 'America/New_York', - 'view_timezone' => 'Asia/Hong_Kong', - 'input' => 'datetime', - 'with_seconds' => true, - )); - - $dateTime = new \DateTime('12:04:05'); - $dateTime->setTimezone(new \DateTimeZone('America/New_York')); - - $form->setData($dateTime); - - $outputTime = clone $dateTime; - $outputTime->setTimezone(new \DateTimeZone('Asia/Hong_Kong')); - - $displayedData = array( - 'hour' => (int) $outputTime->format('H'), - 'minute' => (int) $outputTime->format('i'), - 'second' => (int) $outputTime->format('s'), - ); - - $this->assertDateTimeEquals($dateTime, $form->getData()); - $this->assertEquals($displayedData, $form->getViewData()); - } - - public function testHoursOption() - { - $form = $this->factory->create('time', null, array( - 'hours' => array(6, 7), - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), - ), $view['hour']->vars['choices']); - } - - public function testIsMinuteWithinRangeReturnsTrueIfWithin() - { - $form = $this->factory->create('time', null, array( - 'minutes' => array(6, 7), - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), - ), $view['minute']->vars['choices']); - } - - public function testIsSecondWithinRangeReturnsTrueIfWithin() - { - $form = $this->factory->create('time', null, array( - 'seconds' => array(6, 7), - 'with_seconds' => true, - )); - - $view = $form->createView(); - - $this->assertEquals(array( - new ChoiceView('6', '6', '06'), - new ChoiceView('7', '7', '07'), - ), $view['second']->vars['choices']); - } - - public function testIsPartiallyFilledReturnsFalseIfCompletelyEmpty() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('time', null, array( - 'widget' => 'choice', - )); - - $form->submit(array( - 'hour' => '', - 'minute' => '', - )); - - $this->assertFalse($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsFalseIfCompletelyEmptyWithSeconds() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('time', null, array( - 'widget' => 'choice', - 'with_seconds' => true, - )); - - $form->submit(array( - 'hour' => '', - 'minute' => '', - 'second' => '', - )); - - $this->assertFalse($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsFalseIfCompletelyFilled() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('time', null, array( - 'widget' => 'choice', - )); - - $form->submit(array( - 'hour' => '0', - 'minute' => '0', - )); - - $this->assertFalse($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsFalseIfCompletelyFilledWithSeconds() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('time', null, array( - 'widget' => 'choice', - 'with_seconds' => true, - )); - - $form->submit(array( - 'hour' => '0', - 'minute' => '0', - 'second' => '0', - )); - - $this->assertFalse($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsTrueIfChoiceAndHourEmpty() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('time', null, array( - 'widget' => 'choice', - 'with_seconds' => true, - )); - - $form->submit(array( - 'hour' => '', - 'minute' => '0', - 'second' => '0', - )); - - $this->assertTrue($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsTrueIfChoiceAndMinuteEmpty() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('time', null, array( - 'widget' => 'choice', - 'with_seconds' => true, - )); - - $form->submit(array( - 'hour' => '0', - 'minute' => '', - 'second' => '0', - )); - - $this->assertTrue($form->isPartiallyFilled()); - } - - public function testIsPartiallyFilledReturnsTrueIfChoiceAndSecondsEmpty() - { - $this->markTestIncomplete('Needs to be reimplemented using validators'); - - $form = $this->factory->create('time', null, array( - 'widget' => 'choice', - 'with_seconds' => true, - )); - - $form->submit(array( - 'hour' => '0', - 'minute' => '0', - 'second' => '', - )); - - $this->assertTrue($form->isPartiallyFilled()); - } - - // Bug fix - public function testInitializeWithDateTime() - { - // Throws an exception if "data_class" option is not explicitly set - // to null in the type - $this->factory->create('time', new \DateTime()); - } - - public function testSingleTextWidgetShouldUseTheRightInputType() - { - $form = $this->factory->create('time', null, array( - 'widget' => 'single_text', - )); - - $view = $form->createView(); - $this->assertEquals('time', $view->vars['type']); - } - - public function testSingleTextWidgetWithSecondsShouldHaveRightStepAttribute() - { - $form = $this->factory->create('time', null, array( - 'widget' => 'single_text', - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertArrayHasKey('step', $view->vars['attr']); - $this->assertEquals(1, $view->vars['attr']['step']); - } - - public function testSingleTextWidgetWithSecondsShouldNotOverrideStepAttribute() - { - $form = $this->factory->create('time', null, array( - 'widget' => 'single_text', - 'with_seconds' => true, - 'attr' => array( - 'step' => 30, - ), - )); - - $view = $form->createView(); - $this->assertArrayHasKey('step', $view->vars['attr']); - $this->assertEquals(30, $view->vars['attr']['step']); - } - - public function testDontPassHtml5TypeIfHtml5NotAllowed() - { - $form = $this->factory->create('time', null, array( - 'widget' => 'single_text', - 'html5' => false, - )); - - $view = $form->createView(); - $this->assertFalse(isset($view->vars['type'])); - } - - public function testPassDefaultPlaceholderToViewIfNotRequired() - { - $form = $this->factory->create('time', null, array( - 'required' => false, - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('', $view['hour']->vars['placeholder']); - $this->assertSame('', $view['minute']->vars['placeholder']); - $this->assertSame('', $view['second']->vars['placeholder']); - } - - public function testPassNoPlaceholderToViewIfRequired() - { - $form = $this->factory->create('time', null, array( - 'required' => true, - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertNull($view['hour']->vars['placeholder']); - $this->assertNull($view['minute']->vars['placeholder']); - $this->assertNull($view['second']->vars['placeholder']); - } - - public function testPassPlaceholderAsString() - { - $form = $this->factory->create('time', null, array( - 'placeholder' => 'Empty', - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty', $view['hour']->vars['placeholder']); - $this->assertSame('Empty', $view['minute']->vars['placeholder']); - $this->assertSame('Empty', $view['second']->vars['placeholder']); - } - - public function testPassEmptyValueBC() - { - $form = $this->factory->create('time', null, array( - 'empty_value' => 'Empty', - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty', $view['hour']->vars['placeholder']); - $this->assertSame('Empty', $view['minute']->vars['placeholder']); - $this->assertSame('Empty', $view['second']->vars['placeholder']); - $this->assertSame('Empty', $view['hour']->vars['empty_value']); - $this->assertSame('Empty', $view['minute']->vars['empty_value']); - $this->assertSame('Empty', $view['second']->vars['empty_value']); - } - - public function testPassPlaceholderAsArray() - { - $form = $this->factory->create('time', null, array( - 'placeholder' => array( - 'hour' => 'Empty hour', - 'minute' => 'Empty minute', - 'second' => 'Empty second', - ), - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty hour', $view['hour']->vars['placeholder']); - $this->assertSame('Empty minute', $view['minute']->vars['placeholder']); - $this->assertSame('Empty second', $view['second']->vars['placeholder']); - } - - public function testPassPlaceholderAsPartialArrayAddEmptyIfNotRequired() - { - $form = $this->factory->create('time', null, array( - 'required' => false, - 'placeholder' => array( - 'hour' => 'Empty hour', - 'second' => 'Empty second', - ), - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty hour', $view['hour']->vars['placeholder']); - $this->assertSame('', $view['minute']->vars['placeholder']); - $this->assertSame('Empty second', $view['second']->vars['placeholder']); - } - - public function testPassPlaceholderAsPartialArrayAddNullIfRequired() - { - $form = $this->factory->create('time', null, array( - 'required' => true, - 'placeholder' => array( - 'hour' => 'Empty hour', - 'second' => 'Empty second', - ), - 'with_seconds' => true, - )); - - $view = $form->createView(); - $this->assertSame('Empty hour', $view['hour']->vars['placeholder']); - $this->assertNull($view['minute']->vars['placeholder']); - $this->assertSame('Empty second', $view['second']->vars['placeholder']); - } - - public function provideCompoundWidgets() - { - return array( - array('text'), - array('choice'), - ); - } - - /** - * @dataProvider provideCompoundWidgets - */ - public function testHourErrorsBubbleUp($widget) - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('time', null, array( - 'widget' => $widget, - )); - $form['hour']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['hour']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - /** - * @dataProvider provideCompoundWidgets - */ - public function testMinuteErrorsBubbleUp($widget) - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('time', null, array( - 'widget' => $widget, - )); - $form['minute']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['minute']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - /** - * @dataProvider provideCompoundWidgets - */ - public function testSecondErrorsBubbleUp($widget) - { - $error = new FormError('Invalid!'); - $form = $this->factory->create('time', null, array( - 'widget' => $widget, - 'with_seconds' => true, - )); - $form['second']->addError($error); - - $this->assertSame(array(), iterator_to_array($form['second']->getErrors())); - $this->assertSame(array($error), iterator_to_array($form->getErrors())); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidConfigurationException - */ - public function testInitializeWithSecondsAndWithoutMinutes() - { - $this->factory->create('time', null, array( - 'with_minutes' => false, - 'with_seconds' => true, - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfHoursIsInvalid() - { - $this->factory->create('time', null, array( - 'hours' => 'bad value', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfMinutesIsInvalid() - { - $this->factory->create('time', null, array( - 'minutes' => 'bad value', - )); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfSecondsIsInvalid() - { - $this->factory->create('time', null, array( - 'seconds' => 'bad value', - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php deleted file mode 100644 index 81df20cbb..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TimezoneTypeTest.php +++ /dev/null @@ -1,30 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Extension\Core\View\ChoiceView; - -class TimezoneTypeTest extends \Symfony\Component\Form\Test\TypeTestCase -{ - public function testTimezonesAreSelectable() - { - $form = $this->factory->create('timezone'); - $view = $form->createView(); - $choices = $view->vars['choices']; - - $this->assertArrayHasKey('Africa', $choices); - $this->assertContains(new ChoiceView('Africa/Kinshasa', 'Africa/Kinshasa', 'Kinshasa'), $choices['Africa'], '', false, false); - - $this->assertArrayHasKey('America', $choices); - $this->assertContains(new ChoiceView('America/New_York', 'America/New_York', 'New York'), $choices['America'], '', false, false); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php deleted file mode 100644 index 733546e38..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/TypeTestCase.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase; - -/** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\TypeTestCase instead. - */ -abstract class TypeTestCase extends BaseTypeTestCase -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php deleted file mode 100644 index f5c38ea75..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Core/Type/UrlTypeTest.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Core\Type; - -use Symfony\Component\Form\Test\TypeTestCase as TestCase; - -class UrlTypeTest extends TestCase -{ - public function testSubmitAddsDefaultProtocolIfNoneIsIncluded() - { - $form = $this->factory->create('url', 'name'); - - $form->submit('www.domain.com'); - - $this->assertSame('http://www.domain.com', $form->getData()); - $this->assertSame('http://www.domain.com', $form->getViewData()); - } - - public function testSubmitAddsNoDefaultProtocolIfAlreadyIncluded() - { - $form = $this->factory->create('url', null, array( - 'default_protocol' => 'http', - )); - - $form->submit('ftp://www.domain.com'); - - $this->assertSame('ftp://www.domain.com', $form->getData()); - $this->assertSame('ftp://www.domain.com', $form->getViewData()); - } - - public function testSubmitAddsNoDefaultProtocolIfEmpty() - { - $form = $this->factory->create('url', null, array( - 'default_protocol' => 'http', - )); - - $form->submit(''); - - $this->assertNull($form->getData()); - $this->assertSame('', $form->getViewData()); - } - - public function testSubmitAddsNoDefaultProtocolIfNull() - { - $form = $this->factory->create('url', null, array( - 'default_protocol' => 'http', - )); - - $form->submit(null); - - $this->assertNull($form->getData()); - $this->assertSame('', $form->getViewData()); - } - - public function testSubmitAddsNoDefaultProtocolIfSetToNull() - { - $form = $this->factory->create('url', null, array( - 'default_protocol' => null, - )); - - $form->submit('www.domain.com'); - - $this->assertSame('www.domain.com', $form->getData()); - $this->assertSame('www.domain.com', $form->getViewData()); - } - - /** - * @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException - */ - public function testThrowExceptionIfDefaultProtocolIsInvalid() - { - $this->factory->create('url', null, array( - 'default_protocol' => array(), - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php deleted file mode 100644 index c1cf35444..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php +++ /dev/null @@ -1,84 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Csrf\CsrfProvider; - -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\DefaultCsrfProvider; - -/** - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - * @group legacy - */ -class LegacyDefaultCsrfProviderTest extends \PHPUnit_Framework_TestCase -{ - protected $provider; - - public static function setUpBeforeClass() - { - ini_set('session.save_handler', 'files'); - ini_set('session.save_path', sys_get_temp_dir()); - ini_set('error_reporting', -1 & ~E_USER_DEPRECATED); - } - - protected function setUp() - { - $this->provider = new DefaultCsrfProvider('SECRET'); - } - - protected function tearDown() - { - $this->provider = null; - } - - public function testGenerateCsrfToken() - { - session_start(); - - $token = $this->provider->generateCsrfToken('foo'); - - $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token); - } - - public function testGenerateCsrfTokenOnUnstartedSession() - { - session_id('touti'); - - if (PHP_VERSION_ID < 50400) { - $this->markTestSkipped('This test requires PHP >= 5.4'); - } - - $this->assertSame(PHP_SESSION_NONE, session_status()); - - $token = $this->provider->generateCsrfToken('foo'); - - $this->assertEquals(sha1('SECRET'.'foo'.session_id()), $token); - $this->assertSame(PHP_SESSION_ACTIVE, session_status()); - } - - public function testIsCsrfTokenValidSucceeds() - { - session_start(); - - $token = sha1('SECRET'.'foo'.session_id()); - - $this->assertTrue($this->provider->isCsrfTokenValid('foo', $token)); - } - - public function testIsCsrfTokenValidFails() - { - session_start(); - - $token = sha1('SECRET'.'bar'.session_id()); - - $this->assertFalse($this->provider->isCsrfTokenValid('foo', $token)); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php deleted file mode 100644 index eb4f58c8b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacySessionCsrfProviderTest.php +++ /dev/null @@ -1,76 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Csrf\CsrfProvider; - -use Symfony\Component\Form\Extension\Csrf\CsrfProvider\SessionCsrfProvider; - -/** - * @group legacy - */ -class LegacySessionCsrfProviderTest extends \PHPUnit_Framework_TestCase -{ - protected $provider; - protected $session; - - protected function setUp() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $this->session = $this->getMock( - 'Symfony\Component\HttpFoundation\Session\Session', - array(), - array(), - '', - false // don't call constructor - ); - $this->provider = new SessionCsrfProvider($this->session, 'SECRET'); - } - - protected function tearDown() - { - $this->provider = null; - $this->session = null; - } - - public function testGenerateCsrfToken() - { - $this->session->expects($this->once()) - ->method('getId') - ->will($this->returnValue('ABCDEF')); - - $token = $this->provider->generateCsrfToken('foo'); - - $this->assertEquals(sha1('SECRET'.'foo'.'ABCDEF'), $token); - } - - public function testIsCsrfTokenValidSucceeds() - { - $this->session->expects($this->once()) - ->method('getId') - ->will($this->returnValue('ABCDEF')); - - $token = sha1('SECRET'.'foo'.'ABCDEF'); - - $this->assertTrue($this->provider->isCsrfTokenValid('foo', $token)); - } - - public function testIsCsrfTokenValidFails() - { - $this->session->expects($this->once()) - ->method('getId') - ->will($this->returnValue('ABCDEF')); - - $token = sha1('SECRET'.'bar'.'ABCDEF'); - - $this->assertFalse($this->provider->isCsrfTokenValid('foo', $token)); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php deleted file mode 100644 index 7206ceede..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Csrf\EventListener; - -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener; - -class CsrfValidationListenerTest extends \PHPUnit_Framework_TestCase -{ - protected $dispatcher; - protected $factory; - protected $tokenManager; - protected $form; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); - $this->form = $this->getBuilder('post') - ->setDataMapper($this->getDataMapper()) - ->getForm(); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->factory = null; - $this->tokenManager = null; - $this->form = null; - } - - protected function getBuilder($name = 'name') - { - return new FormBuilder($name, null, $this->dispatcher, $this->factory, array('compound' => true)); - } - - protected function getForm($name = 'name') - { - return $this->getBuilder($name)->getForm(); - } - - protected function getDataMapper() - { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); - } - - protected function getMockForm() - { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); - } - - // https://github.com/symfony/symfony/pull/5838 - public function testStringFormData() - { - $data = 'XP4HUzmHPi'; - $event = new FormEvent($this->form, $data); - - $validation = new CsrfValidationListener('csrf', $this->tokenManager, 'unknown', 'Invalid.'); - $validation->preSubmit($event); - - // Validate accordingly - $this->assertSame($data, $event->getData()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php deleted file mode 100644 index 53e3d3a6b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Csrf/Type/FormTypeCsrfExtensionTest.php +++ /dev/null @@ -1,400 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Csrf\Type; - -use Symfony\Component\Form\AbstractType; -use Symfony\Component\Form\FormBuilderInterface; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Test\TypeTestCase; -use Symfony\Component\Form\Extension\Csrf\CsrfExtension; -use Symfony\Component\Security\Csrf\CsrfToken; - -class FormTypeCsrfExtensionTest_ChildType extends AbstractType -{ - public function buildForm(FormBuilderInterface $builder, array $options) - { - // The form needs a child in order to trigger CSRF protection by - // default - $builder->add('name', 'text'); - } - - public function getName() - { - return 'csrf_collection_test'; - } -} - -class FormTypeCsrfExtensionTest extends TypeTestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $tokenManager; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $translator; - - protected function setUp() - { - $this->tokenManager = $this->getMock('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface'); - $this->translator = $this->getMock('Symfony\Component\Translation\TranslatorInterface'); - - parent::setUp(); - } - - protected function tearDown() - { - $this->tokenManager = null; - $this->translator = null; - - parent::tearDown(); - } - - protected function getExtensions() - { - return array_merge(parent::getExtensions(), array( - new CsrfExtension($this->tokenManager, $this->translator), - )); - } - - public function testCsrfProtectionByDefaultIfRootAndCompound() - { - $view = $this->factory - ->create('form', null, array( - 'csrf_field_name' => 'csrf', - 'compound' => true, - )) - ->createView(); - - $this->assertTrue(isset($view['csrf'])); - } - - public function testNoCsrfProtectionByDefaultIfCompoundButNotRoot() - { - $view = $this->factory - ->createNamedBuilder('root', 'form') - ->add($this->factory - ->createNamedBuilder('form', 'form', null, array( - 'csrf_field_name' => 'csrf', - 'compound' => true, - )) - ) - ->getForm() - ->get('form') - ->createView(); - - $this->assertFalse(isset($view['csrf'])); - } - - public function testNoCsrfProtectionByDefaultIfRootButNotCompound() - { - $view = $this->factory - ->create('form', null, array( - 'csrf_field_name' => 'csrf', - 'compound' => false, - )) - ->createView(); - - $this->assertFalse(isset($view['csrf'])); - } - - public function testCsrfProtectionCanBeDisabled() - { - $view = $this->factory - ->create('form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_protection' => false, - 'compound' => true, - )) - ->createView(); - - $this->assertFalse(isset($view['csrf'])); - } - - public function testGenerateCsrfToken() - { - $this->tokenManager->expects($this->once()) - ->method('getToken') - ->with('TOKEN_ID') - ->will($this->returnValue(new CsrfToken('TOKEN_ID', 'token'))); - - $view = $this->factory - ->create('form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'csrf_token_id' => 'TOKEN_ID', - 'compound' => true, - )) - ->createView(); - - $this->assertEquals('token', $view['csrf']->vars['value']); - } - - public function testGenerateCsrfTokenUsesFormNameAsIntentionByDefault() - { - $this->tokenManager->expects($this->once()) - ->method('getToken') - ->with('FORM_NAME') - ->will($this->returnValue('token')); - - $view = $this->factory - ->createNamed('FORM_NAME', 'form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'compound' => true, - )) - ->createView(); - - $this->assertEquals('token', $view['csrf']->vars['value']); - } - - public function testGenerateCsrfTokenUsesTypeClassAsIntentionIfEmptyFormName() - { - $this->tokenManager->expects($this->once()) - ->method('getToken') - ->with('Symfony\Component\Form\Extension\Core\Type\FormType') - ->will($this->returnValue('token')); - - $view = $this->factory - ->createNamed('', 'form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'compound' => true, - )) - ->createView(); - - $this->assertEquals('token', $view['csrf']->vars['value']); - } - - public function provideBoolean() - { - return array( - array(true), - array(false), - ); - } - - /** - * @dataProvider provideBoolean - */ - public function testValidateTokenOnSubmitIfRootAndCompound($valid) - { - $this->tokenManager->expects($this->once()) - ->method('isTokenValid') - ->with(new CsrfToken('TOKEN_ID', 'token')) - ->will($this->returnValue($valid)); - - $form = $this->factory - ->createBuilder('form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'csrf_token_id' => 'TOKEN_ID', - 'compound' => true, - )) - ->add('child', 'text') - ->getForm(); - - $form->submit(array( - 'child' => 'foobar', - 'csrf' => 'token', - )); - - // Remove token from data - $this->assertSame(array('child' => 'foobar'), $form->getData()); - - // Validate accordingly - $this->assertSame($valid, $form->isValid()); - } - - /** - * @dataProvider provideBoolean - */ - public function testValidateTokenOnSubmitIfRootAndCompoundUsesFormNameAsIntentionByDefault($valid) - { - $this->tokenManager->expects($this->once()) - ->method('isTokenValid') - ->with(new CsrfToken('FORM_NAME', 'token')) - ->will($this->returnValue($valid)); - - $form = $this->factory - ->createNamedBuilder('FORM_NAME', 'form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'compound' => true, - )) - ->add('child', 'text') - ->getForm(); - - $form->submit(array( - 'child' => 'foobar', - 'csrf' => 'token', - )); - - // Remove token from data - $this->assertSame(array('child' => 'foobar'), $form->getData()); - - // Validate accordingly - $this->assertSame($valid, $form->isValid()); - } - - /** - * @dataProvider provideBoolean - */ - public function testValidateTokenOnSubmitIfRootAndCompoundUsesTypeClassAsIntentionIfEmptyFormName($valid) - { - $this->tokenManager->expects($this->once()) - ->method('isTokenValid') - ->with(new CsrfToken('Symfony\Component\Form\Extension\Core\Type\FormType', 'token')) - ->will($this->returnValue($valid)); - - $form = $this->factory - ->createNamedBuilder('', 'form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'compound' => true, - )) - ->add('child', 'text') - ->getForm(); - - $form->submit(array( - 'child' => 'foobar', - 'csrf' => 'token', - )); - - // Remove token from data - $this->assertSame(array('child' => 'foobar'), $form->getData()); - - // Validate accordingly - $this->assertSame($valid, $form->isValid()); - } - - public function testFailIfRootAndCompoundAndTokenMissing() - { - $this->tokenManager->expects($this->never()) - ->method('isTokenValid'); - - $form = $this->factory - ->createBuilder('form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'csrf_token_id' => 'TOKEN_ID', - 'compound' => true, - )) - ->add('child', 'text') - ->getForm(); - - $form->submit(array( - 'child' => 'foobar', - // token is missing - )); - - // Remove token from data - $this->assertSame(array('child' => 'foobar'), $form->getData()); - - // Validate accordingly - $this->assertFalse($form->isValid()); - } - - public function testDontValidateTokenIfCompoundButNoRoot() - { - $this->tokenManager->expects($this->never()) - ->method('isTokenValid'); - - $form = $this->factory - ->createNamedBuilder('root', 'form') - ->add($this->factory - ->createNamedBuilder('form', 'form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'csrf_token_id' => 'TOKEN_ID', - 'compound' => true, - )) - ) - ->getForm() - ->get('form'); - - $form->submit(array( - 'child' => 'foobar', - 'csrf' => 'token', - )); - } - - public function testDontValidateTokenIfRootButNotCompound() - { - $this->tokenManager->expects($this->never()) - ->method('isTokenValid'); - - $form = $this->factory - ->create('form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'csrf_token_id' => 'TOKEN_ID', - 'compound' => false, - )); - - $form->submit(array( - 'csrf' => 'token', - )); - } - - public function testNoCsrfProtectionOnPrototype() - { - $prototypeView = $this->factory - ->create('collection', null, array( - 'type' => new FormTypeCsrfExtensionTest_ChildType(), - 'options' => array( - 'csrf_field_name' => 'csrf', - ), - 'prototype' => true, - 'allow_add' => true, - )) - ->createView() - ->vars['prototype']; - - $this->assertFalse(isset($prototypeView['csrf'])); - $this->assertCount(1, $prototypeView); - } - - public function testsTranslateCustomErrorMessage() - { - $this->tokenManager->expects($this->once()) - ->method('isTokenValid') - ->with(new CsrfToken('TOKEN_ID', 'token')) - ->will($this->returnValue(false)); - - $this->translator->expects($this->once()) - ->method('trans') - ->with('Foobar') - ->will($this->returnValue('[trans]Foobar[/trans]')); - - $form = $this->factory - ->createBuilder('form', null, array( - 'csrf_field_name' => 'csrf', - 'csrf_token_manager' => $this->tokenManager, - 'csrf_message' => 'Foobar', - 'csrf_token_id' => 'TOKEN_ID', - 'compound' => true, - )) - ->getForm(); - - $form->submit(array( - 'csrf' => 'token', - )); - - $errors = $form->getErrors(); - - $this->assertGreaterThan(0, count($errors)); - $this->assertEquals(new FormError('[trans]Foobar[/trans]'), $errors[0]); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php deleted file mode 100644 index ce4367cbe..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/DataCollectorExtensionTest.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\DataCollector; - -use Symfony\Component\Form\Extension\DataCollector\DataCollectorExtension; - -/** - * @covers Symfony\Component\Form\Extension\DataCollector\DataCollectorExtension - */ -class DataCollectorExtensionTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var DataCollectorExtension - */ - private $extension; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dataCollector; - - protected function setUp() - { - $this->dataCollector = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface'); - $this->extension = new DataCollectorExtension($this->dataCollector); - } - - public function testLoadTypeExtensions() - { - $typeExtensions = $this->extension->getTypeExtensions('form'); - - $this->assertInternalType('array', $typeExtensions); - $this->assertCount(1, $typeExtensions); - $this->assertInstanceOf('Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension', array_shift($typeExtensions)); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php deleted file mode 100644 index f4774a5cc..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataCollectorTest.php +++ /dev/null @@ -1,538 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\DataCollector; - -use Symfony\Component\Form\Extension\DataCollector\FormDataCollector; -use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\FormView; - -class FormDataCollectorTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dataExtractor; - - /** - * @var FormDataCollector - */ - private $dataCollector; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dispatcher; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $factory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dataMapper; - - /** - * @var Form - */ - private $form; - - /** - * @var Form - */ - private $childForm; - - /** - * @var FormView - */ - private $view; - - /** - * @var FormView - */ - private $childView; - - protected function setUp() - { - $this->dataExtractor = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataExtractorInterface'); - $this->dataCollector = new FormDataCollector($this->dataExtractor); - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->dataMapper = $this->getMock('Symfony\Component\Form\DataMapperInterface'); - $this->form = $this->createForm('name'); - $this->childForm = $this->createForm('child'); - $this->view = new FormView(); - $this->childView = new FormView(); - } - - public function testBuildPreliminaryFormTree() - { - $this->form->add($this->childForm); - - $this->dataExtractor->expects($this->at(0)) - ->method('extractConfiguration') - ->with($this->form) - ->will($this->returnValue(array('config' => 'foo'))); - $this->dataExtractor->expects($this->at(1)) - ->method('extractConfiguration') - ->with($this->childForm) - ->will($this->returnValue(array('config' => 'bar'))); - - $this->dataExtractor->expects($this->at(2)) - ->method('extractDefaultData') - ->with($this->form) - ->will($this->returnValue(array('default_data' => 'foo'))); - $this->dataExtractor->expects($this->at(3)) - ->method('extractDefaultData') - ->with($this->childForm) - ->will($this->returnValue(array('default_data' => 'bar'))); - - $this->dataExtractor->expects($this->at(4)) - ->method('extractSubmittedData') - ->with($this->form) - ->will($this->returnValue(array('submitted_data' => 'foo'))); - $this->dataExtractor->expects($this->at(5)) - ->method('extractSubmittedData') - ->with($this->childForm) - ->will($this->returnValue(array('submitted_data' => 'bar'))); - - $this->dataCollector->collectConfiguration($this->form); - $this->dataCollector->collectDefaultData($this->form); - $this->dataCollector->collectSubmittedData($this->form); - $this->dataCollector->buildPreliminaryFormTree($this->form); - - $childFormData = array( - 'config' => 'bar', - 'default_data' => 'bar', - 'submitted_data' => 'bar', - 'children' => array(), - ); - - $formData = array( - 'config' => 'foo', - 'default_data' => 'foo', - 'submitted_data' => 'foo', - 'children' => array( - 'child' => $childFormData, - ), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - spl_object_hash($this->childForm) => $childFormData, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - } - - public function testBuildMultiplePreliminaryFormTrees() - { - $form1 = $this->createForm('form1'); - $form2 = $this->createForm('form2'); - - $this->dataExtractor->expects($this->at(0)) - ->method('extractConfiguration') - ->with($form1) - ->will($this->returnValue(array('config' => 'foo'))); - $this->dataExtractor->expects($this->at(1)) - ->method('extractConfiguration') - ->with($form2) - ->will($this->returnValue(array('config' => 'bar'))); - - $this->dataCollector->collectConfiguration($form1); - $this->dataCollector->collectConfiguration($form2); - $this->dataCollector->buildPreliminaryFormTree($form1); - - $form1Data = array( - 'config' => 'foo', - 'children' => array(), - ); - - $this->assertSame(array( - 'forms' => array( - 'form1' => $form1Data, - ), - 'forms_by_hash' => array( - spl_object_hash($form1) => $form1Data, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - - $this->dataCollector->buildPreliminaryFormTree($form2); - - $form2Data = array( - 'config' => 'bar', - 'children' => array(), - ); - - $this->assertSame(array( - 'forms' => array( - 'form1' => $form1Data, - 'form2' => $form2Data, - ), - 'forms_by_hash' => array( - spl_object_hash($form1) => $form1Data, - spl_object_hash($form2) => $form2Data, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - } - - public function testBuildSamePreliminaryFormTreeMultipleTimes() - { - $this->dataExtractor->expects($this->at(0)) - ->method('extractConfiguration') - ->with($this->form) - ->will($this->returnValue(array('config' => 'foo'))); - - $this->dataExtractor->expects($this->at(1)) - ->method('extractDefaultData') - ->with($this->form) - ->will($this->returnValue(array('default_data' => 'foo'))); - - $this->dataCollector->collectConfiguration($this->form); - $this->dataCollector->buildPreliminaryFormTree($this->form); - - $formData = array( - 'config' => 'foo', - 'children' => array(), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - - $this->dataCollector->collectDefaultData($this->form); - $this->dataCollector->buildPreliminaryFormTree($this->form); - - $formData = array( - 'config' => 'foo', - 'default_data' => 'foo', - 'children' => array(), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - } - - public function testBuildPreliminaryFormTreeWithoutCollectingAnyData() - { - $this->dataCollector->buildPreliminaryFormTree($this->form); - - $formData = array( - 'children' => array(), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - } - - public function testBuildFinalFormTree() - { - $this->form->add($this->childForm); - $this->view->children['child'] = $this->childView; - - $this->dataExtractor->expects($this->at(0)) - ->method('extractConfiguration') - ->with($this->form) - ->will($this->returnValue(array('config' => 'foo'))); - $this->dataExtractor->expects($this->at(1)) - ->method('extractConfiguration') - ->with($this->childForm) - ->will($this->returnValue(array('config' => 'bar'))); - - $this->dataExtractor->expects($this->at(2)) - ->method('extractDefaultData') - ->with($this->form) - ->will($this->returnValue(array('default_data' => 'foo'))); - $this->dataExtractor->expects($this->at(3)) - ->method('extractDefaultData') - ->with($this->childForm) - ->will($this->returnValue(array('default_data' => 'bar'))); - - $this->dataExtractor->expects($this->at(4)) - ->method('extractSubmittedData') - ->with($this->form) - ->will($this->returnValue(array('submitted_data' => 'foo'))); - $this->dataExtractor->expects($this->at(5)) - ->method('extractSubmittedData') - ->with($this->childForm) - ->will($this->returnValue(array('submitted_data' => 'bar'))); - - $this->dataExtractor->expects($this->at(6)) - ->method('extractViewVariables') - ->with($this->view) - ->will($this->returnValue(array('view_vars' => 'foo'))); - - $this->dataExtractor->expects($this->at(7)) - ->method('extractViewVariables') - ->with($this->childView) - ->will($this->returnValue(array('view_vars' => 'bar'))); - - $this->dataCollector->collectConfiguration($this->form); - $this->dataCollector->collectDefaultData($this->form); - $this->dataCollector->collectSubmittedData($this->form); - $this->dataCollector->collectViewVariables($this->view); - $this->dataCollector->buildFinalFormTree($this->form, $this->view); - - $childFormData = array( - 'view_vars' => 'bar', - 'config' => 'bar', - 'default_data' => 'bar', - 'submitted_data' => 'bar', - 'children' => array(), - ); - - $formData = array( - 'view_vars' => 'foo', - 'config' => 'foo', - 'default_data' => 'foo', - 'submitted_data' => 'foo', - 'children' => array( - 'child' => $childFormData, - ), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - spl_object_hash($this->childForm) => $childFormData, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - } - - public function testFinalFormReliesOnFormViewStructure() - { - $this->form->add($child1 = $this->createForm('first')); - $this->form->add($child2 = $this->createForm('second')); - - $this->view->children['second'] = $this->childView; - - $this->dataCollector->buildPreliminaryFormTree($this->form); - - $child1Data = array( - 'children' => array(), - ); - - $child2Data = array( - 'children' => array(), - ); - - $formData = array( - 'children' => array( - 'first' => $child1Data, - 'second' => $child2Data, - ), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - spl_object_hash($child1) => $child1Data, - spl_object_hash($child2) => $child2Data, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - - $this->dataCollector->buildFinalFormTree($this->form, $this->view); - - $formData = array( - 'children' => array( - // "first" not present in FormView - 'second' => $child2Data, - ), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - spl_object_hash($child1) => $child1Data, - spl_object_hash($child2) => $child2Data, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - } - - public function testChildViewsCanBeWithoutCorrespondingChildForms() - { - // don't add $this->childForm to $this->form! - - $this->view->children['child'] = $this->childView; - - $this->dataExtractor->expects($this->at(0)) - ->method('extractConfiguration') - ->with($this->form) - ->will($this->returnValue(array('config' => 'foo'))); - $this->dataExtractor->expects($this->at(1)) - ->method('extractConfiguration') - ->with($this->childForm) - ->will($this->returnValue(array('config' => 'bar'))); - - // explicitly call collectConfiguration(), since $this->childForm is not - // contained in the form tree - $this->dataCollector->collectConfiguration($this->form); - $this->dataCollector->collectConfiguration($this->childForm); - $this->dataCollector->buildFinalFormTree($this->form, $this->view); - - $childFormData = array( - // no "config" key - 'children' => array(), - ); - - $formData = array( - 'config' => 'foo', - 'children' => array( - 'child' => $childFormData, - ), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - // no child entry - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - } - - public function testChildViewsWithoutCorrespondingChildFormsMayBeExplicitlyAssociated() - { - // don't add $this->childForm to $this->form! - - $this->view->children['child'] = $this->childView; - - // but associate the two - $this->dataCollector->associateFormWithView($this->childForm, $this->childView); - - $this->dataExtractor->expects($this->at(0)) - ->method('extractConfiguration') - ->with($this->form) - ->will($this->returnValue(array('config' => 'foo'))); - $this->dataExtractor->expects($this->at(1)) - ->method('extractConfiguration') - ->with($this->childForm) - ->will($this->returnValue(array('config' => 'bar'))); - - // explicitly call collectConfiguration(), since $this->childForm is not - // contained in the form tree - $this->dataCollector->collectConfiguration($this->form); - $this->dataCollector->collectConfiguration($this->childForm); - $this->dataCollector->buildFinalFormTree($this->form, $this->view); - - $childFormData = array( - 'config' => 'bar', - 'children' => array(), - ); - - $formData = array( - 'config' => 'foo', - 'children' => array( - 'child' => $childFormData, - ), - ); - - $this->assertSame(array( - 'forms' => array( - 'name' => $formData, - ), - 'forms_by_hash' => array( - spl_object_hash($this->form) => $formData, - spl_object_hash($this->childForm) => $childFormData, - ), - 'nb_errors' => 0, - ), $this->dataCollector->getData()); - } - - public function testCollectSubmittedDataCountsErrors() - { - $form1 = $this->createForm('form1'); - $childForm1 = $this->createForm('child1'); - $form2 = $this->createForm('form2'); - - $form1->add($childForm1); - $this->dataExtractor - ->method('extractConfiguration') - ->will($this->returnValue(array())); - $this->dataExtractor - ->method('extractDefaultData') - ->will($this->returnValue(array())); - $this->dataExtractor->expects($this->at(4)) - ->method('extractSubmittedData') - ->with($form1) - ->will($this->returnValue(array('errors' => array('foo')))); - $this->dataExtractor->expects($this->at(5)) - ->method('extractSubmittedData') - ->with($childForm1) - ->will($this->returnValue(array('errors' => array('bar', 'bam')))); - $this->dataExtractor->expects($this->at(8)) - ->method('extractSubmittedData') - ->with($form2) - ->will($this->returnValue(array('errors' => array('baz')))); - - $this->dataCollector->collectSubmittedData($form1); - - $data = $this->dataCollector->getData(); - $this->assertSame(3, $data['nb_errors']); - - $this->dataCollector->collectSubmittedData($form2); - - $data = $this->dataCollector->getData(); - $this->assertSame(4, $data['nb_errors']); - } - - private function createForm($name) - { - $builder = new FormBuilder($name, null, $this->dispatcher, $this->factory); - $builder->setCompound(true); - $builder->setDataMapper($this->dataMapper); - - return $builder->getForm(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php deleted file mode 100644 index deb6069ee..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/FormDataExtractorTest.php +++ /dev/null @@ -1,432 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\DataCollector; - -use Symfony\Component\Form\CallbackTransformer; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\Extension\DataCollector\FormDataExtractor; -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; -use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter; - -class FormDataExtractorTest_SimpleValueExporter extends ValueExporter -{ - /** - * {@inheritdoc} - */ - public function exportValue($value, $depth = 1, $deep = false) - { - return is_object($value) ? sprintf('object(%s)', get_class($value)) : var_export($value, true); - } -} - -/** - * @author Bernhard Schussek - */ -class FormDataExtractorTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var FormDataExtractorTest_SimpleValueExporter - */ - private $valueExporter; - - /** - * @var FormDataExtractor - */ - private $dataExtractor; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dispatcher; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $factory; - - protected function setUp() - { - $this->valueExporter = new FormDataExtractorTest_SimpleValueExporter(); - $this->dataExtractor = new FormDataExtractor($this->valueExporter); - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - } - - public function testExtractConfiguration() - { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $type->expects($this->any()) - ->method('getName') - ->will($this->returnValue('type_name')); - $type->expects($this->any()) - ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); - - $form = $this->createBuilder('name') - ->setType($type) - ->getForm(); - - $this->assertSame(array( - 'id' => 'name', - 'name' => 'name', - 'type' => 'type_name', - 'type_class' => 'stdClass', - 'synchronized' => 'true', - 'passed_options' => array(), - 'resolved_options' => array(), - ), $this->dataExtractor->extractConfiguration($form)); - } - - public function testExtractConfigurationSortsPassedOptions() - { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $type->expects($this->any()) - ->method('getName') - ->will($this->returnValue('type_name')); - $type->expects($this->any()) - ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); - - $options = array( - 'b' => 'foo', - 'a' => 'bar', - 'c' => 'baz', - ); - - $form = $this->createBuilder('name') - ->setType($type) - // passed options are stored in an attribute by - // ResolvedTypeDataCollectorProxy - ->setAttribute('data_collector/passed_options', $options) - ->getForm(); - - $this->assertSame(array( - 'id' => 'name', - 'name' => 'name', - 'type' => 'type_name', - 'type_class' => 'stdClass', - 'synchronized' => 'true', - 'passed_options' => array( - 'a' => "'bar'", - 'b' => "'foo'", - 'c' => "'baz'", - ), - 'resolved_options' => array(), - ), $this->dataExtractor->extractConfiguration($form)); - } - - public function testExtractConfigurationSortsResolvedOptions() - { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $type->expects($this->any()) - ->method('getName') - ->will($this->returnValue('type_name')); - $type->expects($this->any()) - ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); - - $options = array( - 'b' => 'foo', - 'a' => 'bar', - 'c' => 'baz', - ); - - $form = $this->createBuilder('name', $options) - ->setType($type) - ->getForm(); - - $this->assertSame(array( - 'id' => 'name', - 'name' => 'name', - 'type' => 'type_name', - 'type_class' => 'stdClass', - 'synchronized' => 'true', - 'passed_options' => array(), - 'resolved_options' => array( - 'a' => "'bar'", - 'b' => "'foo'", - 'c' => "'baz'", - ), - ), $this->dataExtractor->extractConfiguration($form)); - } - - public function testExtractConfigurationBuildsIdRecursively() - { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $type->expects($this->any()) - ->method('getName') - ->will($this->returnValue('type_name')); - $type->expects($this->any()) - ->method('getInnerType') - ->will($this->returnValue(new \stdClass())); - - $grandParent = $this->createBuilder('grandParent') - ->setCompound(true) - ->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')) - ->getForm(); - $parent = $this->createBuilder('parent') - ->setCompound(true) - ->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')) - ->getForm(); - $form = $this->createBuilder('name') - ->setType($type) - ->getForm(); - - $grandParent->add($parent); - $parent->add($form); - - $this->assertSame(array( - 'id' => 'grandParent_parent_name', - 'name' => 'name', - 'type' => 'type_name', - 'type_class' => 'stdClass', - 'synchronized' => 'true', - 'passed_options' => array(), - 'resolved_options' => array(), - ), $this->dataExtractor->extractConfiguration($form)); - } - - public function testExtractDefaultData() - { - $form = $this->createBuilder('name')->getForm(); - - $form->setData('Foobar'); - - $this->assertSame(array( - 'default_data' => array( - 'norm' => "'Foobar'", - ), - 'submitted_data' => array(), - ), $this->dataExtractor->extractDefaultData($form)); - } - - public function testExtractDefaultDataStoresModelDataIfDifferent() - { - $form = $this->createBuilder('name') - ->addModelTransformer(new FixedDataTransformer(array( - 'Foo' => 'Bar', - ))) - ->getForm(); - - $form->setData('Foo'); - - $this->assertSame(array( - 'default_data' => array( - 'norm' => "'Bar'", - 'model' => "'Foo'", - ), - 'submitted_data' => array(), - ), $this->dataExtractor->extractDefaultData($form)); - } - - public function testExtractDefaultDataStoresViewDataIfDifferent() - { - $form = $this->createBuilder('name') - ->addViewTransformer(new FixedDataTransformer(array( - 'Foo' => 'Bar', - ))) - ->getForm(); - - $form->setData('Foo'); - - $this->assertSame(array( - 'default_data' => array( - 'norm' => "'Foo'", - 'view' => "'Bar'", - ), - 'submitted_data' => array(), - ), $this->dataExtractor->extractDefaultData($form)); - } - - public function testExtractSubmittedData() - { - $form = $this->createBuilder('name')->getForm(); - - $form->submit('Foobar'); - - $this->assertSame(array( - 'submitted_data' => array( - 'norm' => "'Foobar'", - ), - 'errors' => array(), - 'synchronized' => 'true', - ), $this->dataExtractor->extractSubmittedData($form)); - } - - public function testExtractSubmittedDataStoresModelDataIfDifferent() - { - $form = $this->createBuilder('name') - ->addModelTransformer(new FixedDataTransformer(array( - 'Foo' => 'Bar', - '' => '', - ))) - ->getForm(); - - $form->submit('Bar'); - - $this->assertSame(array( - 'submitted_data' => array( - 'norm' => "'Bar'", - 'model' => "'Foo'", - ), - 'errors' => array(), - 'synchronized' => 'true', - ), $this->dataExtractor->extractSubmittedData($form)); - } - - public function testExtractSubmittedDataStoresViewDataIfDifferent() - { - $form = $this->createBuilder('name') - ->addViewTransformer(new FixedDataTransformer(array( - 'Foo' => 'Bar', - '' => '', - ))) - ->getForm(); - - $form->submit('Bar'); - - $this->assertSame(array( - 'submitted_data' => array( - 'norm' => "'Foo'", - 'view' => "'Bar'", - ), - 'errors' => array(), - 'synchronized' => 'true', - ), $this->dataExtractor->extractSubmittedData($form)); - } - - public function testExtractSubmittedDataStoresErrors() - { - $form = $this->createBuilder('name')->getForm(); - - $form->submit('Foobar'); - $form->addError(new FormError('Invalid!')); - - $this->assertSame(array( - 'submitted_data' => array( - 'norm' => "'Foobar'", - ), - 'errors' => array( - array('message' => 'Invalid!', 'origin' => null, 'trace' => array()), - ), - 'synchronized' => 'true', - ), $this->dataExtractor->extractSubmittedData($form)); - } - - public function testExtractSubmittedDataStoresErrorOrigin() - { - $form = $this->createBuilder('name')->getForm(); - - $error = new FormError('Invalid!'); - $error->setOrigin($form); - - $form->submit('Foobar'); - $form->addError($error); - - $this->assertSame(array( - 'submitted_data' => array( - 'norm' => "'Foobar'", - ), - 'errors' => array( - array('message' => 'Invalid!', 'origin' => spl_object_hash($form), 'trace' => array()), - ), - 'synchronized' => 'true', - ), $this->dataExtractor->extractSubmittedData($form)); - } - - public function testExtractSubmittedDataStoresErrorCause() - { - $form = $this->createBuilder('name')->getForm(); - - $exception = new \Exception(); - - $form->submit('Foobar'); - $form->addError(new FormError('Invalid!', null, array(), null, $exception)); - - $this->assertSame(array( - 'submitted_data' => array( - 'norm' => "'Foobar'", - ), - 'errors' => array( - array('message' => 'Invalid!', 'origin' => null, 'trace' => array( - array( - 'class' => "'Exception'", - 'message' => "''", - ), - )), - ), - 'synchronized' => 'true', - ), $this->dataExtractor->extractSubmittedData($form)); - } - - public function testExtractSubmittedDataRemembersIfNonSynchronized() - { - $form = $this->createBuilder('name') - ->addModelTransformer(new CallbackTransformer( - function () {}, - function () { - throw new TransformationFailedException('Fail!'); - } - )) - ->getForm(); - - $form->submit('Foobar'); - - $this->assertSame(array( - 'submitted_data' => array( - 'norm' => "'Foobar'", - 'model' => 'NULL', - ), - 'errors' => array(), - 'synchronized' => 'false', - ), $this->dataExtractor->extractSubmittedData($form)); - } - - public function testExtractViewVariables() - { - $view = new FormView(); - - $view->vars = array( - 'b' => 'foo', - 'a' => 'bar', - 'c' => 'baz', - 'id' => 'foo_bar', - 'name' => 'bar', - ); - - $this->assertSame(array( - 'id' => 'foo_bar', - 'name' => 'bar', - 'view_vars' => array( - 'a' => "'bar'", - 'b' => "'foo'", - 'c' => "'baz'", - 'id' => "'foo_bar'", - 'name' => "'bar'", - ), - ), $this->dataExtractor->extractViewVariables($view)); - } - - /** - * @param string $name - * @param array $options - * - * @return FormBuilder - */ - private function createBuilder($name, array $options = array()) - { - return new FormBuilder($name, null, $this->dispatcher, $this->factory, $options); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php deleted file mode 100644 index d88112768..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/DataCollector/Type/DataCollectorTypeExtensionTest.php +++ /dev/null @@ -1,47 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\DataCollector\Type; - -use Symfony\Component\Form\Extension\DataCollector\Type\DataCollectorTypeExtension; - -class DataCollectorTypeExtensionTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var DataCollectorTypeExtension - */ - private $extension; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dataCollector; - - protected function setUp() - { - $this->dataCollector = $this->getMock('Symfony\Component\Form\Extension\DataCollector\FormDataCollectorInterface'); - $this->extension = new DataCollectorTypeExtension($this->dataCollector); - } - - public function testGetExtendedType() - { - $this->assertEquals('form', $this->extension->getExtendedType()); - } - - public function testBuildForm() - { - $builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); - $builder->expects($this->atLeastOnce()) - ->method('addEventSubscriber') - ->with($this->isInstanceOf('Symfony\Component\Form\Extension\DataCollector\EventListener\DataCollectorListener')); - - $this->extension->buildForm($builder, array()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php deleted file mode 100644 index 521f7b3c1..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/EventListener/LegacyBindRequestListenerTest.php +++ /dev/null @@ -1,256 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\HttpFoundation\EventListener; - -use Symfony\Component\Form\Extension\HttpFoundation\EventListener\BindRequestListener; -use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormConfigBuilder; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * @author Bernhard Schussek - * @group legacy - */ -class LegacyBindRequestListenerTest extends \PHPUnit_Framework_TestCase -{ - private $values; - - private $filesPlain; - - private $filesNested; - - /** - * @var UploadedFile - */ - private $uploadedFile; - - protected function setUp() - { - $this->iniSet('error_reporting', -1 & ~E_USER_DEPRECATED); - - $path = tempnam(sys_get_temp_dir(), 'sf2'); - touch($path); - - $this->values = array( - 'name' => 'Bernhard', - 'image' => array('filename' => 'foobar.png'), - ); - - $this->filesPlain = array( - 'image' => array( - 'error' => UPLOAD_ERR_OK, - 'name' => 'upload.png', - 'size' => 123, - 'tmp_name' => $path, - 'type' => 'image/png', - ), - ); - - $this->filesNested = array( - 'error' => array('image' => UPLOAD_ERR_OK), - 'name' => array('image' => 'upload.png'), - 'size' => array('image' => 123), - 'tmp_name' => array('image' => $path), - 'type' => array('image' => 'image/png'), - ); - - $this->uploadedFile = new UploadedFile($path, 'upload.png', 'image/png', 123, UPLOAD_ERR_OK); - } - - protected function tearDown() - { - unlink($this->uploadedFile->getRealPath()); - } - - public function requestMethodProvider() - { - return array( - array('POST'), - array('PUT'), - array('DELETE'), - array('PATCH'), - ); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitRequest($method) - { - $values = array('author' => $this->values); - $files = array('author' => $this->filesNested); - $request = new Request(array(), $values, array(), array(), $files, array( - 'REQUEST_METHOD' => $method, - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array( - 'name' => 'Bernhard', - 'image' => $this->uploadedFile, - ), $event->getData()); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitRequestWithEmptyName($method) - { - $request = new Request(array(), $this->values, array(), array(), $this->filesPlain, array( - 'REQUEST_METHOD' => $method, - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('', null, $dispatcher); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array( - 'name' => 'Bernhard', - 'image' => $this->uploadedFile, - ), $event->getData()); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitEmptyRequestToCompoundForm($method) - { - $request = new Request(array(), array(), array(), array(), array(), array( - 'REQUEST_METHOD' => $method, - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $config->setCompound(true); - $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - // Default to empty array - $this->assertEquals(array(), $event->getData()); - } - - /** - * @dataProvider requestMethodProvider - */ - public function testSubmitEmptyRequestToSimpleForm($method) - { - $request = new Request(array(), array(), array(), array(), array(), array( - 'REQUEST_METHOD' => $method, - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $config->setCompound(false); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - // Default to null - $this->assertNull($event->getData()); - } - - public function testSubmitGetRequest() - { - $values = array('author' => $this->values); - $request = new Request($values, array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array( - 'name' => 'Bernhard', - 'image' => array('filename' => 'foobar.png'), - ), $event->getData()); - } - - public function testSubmitGetRequestWithEmptyName() - { - $request = new Request($this->values, array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('', null, $dispatcher); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array( - 'name' => 'Bernhard', - 'image' => array('filename' => 'foobar.png'), - ), $event->getData()); - } - - public function testSubmitEmptyGetRequestToCompoundForm() - { - $request = new Request(array(), array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $config->setCompound(true); - $config->setDataMapper($this->getMock('Symfony\Component\Form\DataMapperInterface')); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertEquals(array(), $event->getData()); - } - - public function testSubmitEmptyGetRequestToSimpleForm() - { - $request = new Request(array(), array(), array(), array(), array(), array( - 'REQUEST_METHOD' => 'GET', - )); - - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $config = new FormConfigBuilder('author', null, $dispatcher); - $config->setCompound(false); - $form = new Form($config); - $event = new FormEvent($form, $request); - - $listener = new BindRequestListener(); - $listener->preBind($event); - - $this->assertNull($event->getData()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php deleted file mode 100644 index 4d4ac86fe..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/HttpFoundation/HttpFoundationRequestHandlerTest.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\HttpFoundation; - -use Symfony\Component\Form\Extension\HttpFoundation\HttpFoundationRequestHandler; -use Symfony\Component\Form\Tests\AbstractRequestHandlerTest; -use Symfony\Component\HttpFoundation\Request; -use Symfony\Component\HttpFoundation\File\UploadedFile; - -/** - * @author Bernhard Schussek - */ -class HttpFoundationRequestHandlerTest extends AbstractRequestHandlerTest -{ - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testRequestShouldNotBeNull() - { - $this->requestHandler->handleRequest($this->getMockForm('name', 'GET')); - } - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testRequestShouldBeInstanceOfRequest() - { - $this->requestHandler->handleRequest($this->getMockForm('name', 'GET'), new \stdClass()); - } - - protected function setRequestData($method, $data, $files = array()) - { - $this->request = Request::create('http://localhost', $method, $data, array(), $files); - } - - protected function getRequestHandler() - { - return new HttpFoundationRequestHandler($this->serverParams); - } - - protected function getMockFile($suffix = '') - { - return new UploadedFile(__DIR__.'/../../Fixtures/foo'.$suffix, 'foo'.$suffix); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorPerformanceTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorPerformanceTest.php deleted file mode 100644 index 65df79c85..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorPerformanceTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Constraints; - -use Symfony\Component\Form\Extension\Validator\ValidatorExtension; -use Symfony\Component\Form\Test\FormPerformanceTestCase; -use Symfony\Component\Validator\Validation; - -/** - * @author Bernhard Schussek - */ -class FormValidatorPerformanceTest extends FormPerformanceTestCase -{ - protected function getExtensions() - { - return array( - new ValidatorExtension(Validation::createValidator()), - ); - } - - /** - * findClickedButton() used to have an exponential number of calls. - * - * @group benchmark - */ - public function testValidationPerformance() - { - $this->setMaxRunningTime(1); - - $builder = $this->factory->createBuilder('form'); - - for ($i = 0; $i < 40; ++$i) { - $builder->add($i, 'form'); - - $builder->get($i) - ->add('a') - ->add('b') - ->add('c'); - } - - $form = $builder->getForm(); - - $form->submit(null); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php deleted file mode 100644 index 3dd8a83a3..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/FormValidatorTest.php +++ /dev/null @@ -1,648 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Constraints; - -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\CallbackTransformer; -use Symfony\Component\Form\FormInterface; -use Symfony\Component\Form\Extension\Validator\Constraints\Form; -use Symfony\Component\Form\Extension\Validator\Constraints\FormValidator; -use Symfony\Component\Form\SubmitButtonBuilder; -use Symfony\Component\Validator\Context\ExecutionContextInterface; -use Symfony\Component\Validator\Constraints\NotNull; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\Tests\Constraints\AbstractConstraintValidatorTest; -use Symfony\Component\Validator\Validation; - -/** - * @author Bernhard Schussek - */ -class FormValidatorTest extends AbstractConstraintValidatorTest -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dispatcher; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $factory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - protected $serverParams; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->serverParams = $this->getMock( - 'Symfony\Component\Form\Extension\Validator\Util\ServerParams', - array('getNormalizedIniPostMaxSize', 'getContentLength') - ); - - parent::setUp(); - } - - protected function getApiVersion() - { - return Validation::API_VERSION_2_5; - } - - protected function createValidator() - { - return new FormValidator($this->serverParams); - } - - public function testValidate() - { - $object = $this->getMock('\stdClass'); - $options = array('validation_groups' => array('group1', 'group2')); - $form = $this->getBuilder('name', '\stdClass', $options) - ->setData($object) - ->getForm(); - - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testValidateConstraints() - { - $object = $this->getMock('\stdClass'); - $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); - $constraint2 = new NotBlank(array('groups' => 'group2')); - - $options = array( - 'validation_groups' => array('group1', 'group2'), - 'constraints' => array($constraint1, $constraint2), - ); - $form = $this->getBuilder('name', '\stdClass', $options) - ->setData($object) - ->getForm(); - - // First default constraints - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); - - // Then custom constraints - $this->expectValidateValueAt(2, 'data', $object, $constraint1, 'group1'); - $this->expectValidateValueAt(3, 'data', $object, $constraint2, 'group2'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testDontValidateIfParentWithoutCascadeValidation() - { - $object = $this->getMock('\stdClass'); - - $parent = $this->getBuilder('parent', null, array('cascade_validation' => false)) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $options = array('validation_groups' => array('group1', 'group2')); - $form = $this->getBuilder('name', '\stdClass', $options)->getForm(); - $parent->add($form); - - $form->setData($object); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testValidateConstraintsEvenIfNoCascadeValidation() - { - $object = $this->getMock('\stdClass'); - $constraint1 = new NotNull(array('groups' => array('group1', 'group2'))); - $constraint2 = new NotBlank(array('groups' => 'group2')); - - $parent = $this->getBuilder('parent', null, array('cascade_validation' => false)) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $options = array( - 'validation_groups' => array('group1', 'group2'), - 'constraints' => array($constraint1, $constraint2), - ); - $form = $this->getBuilder('name', '\stdClass', $options) - ->setData($object) - ->getForm(); - $parent->add($form); - - $this->expectValidateValueAt(0, 'data', $object, $constraint1, 'group1'); - $this->expectValidateValueAt(1, 'data', $object, $constraint2, 'group2'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testDontValidateIfNoValidationGroups() - { - $object = $this->getMock('\stdClass'); - - $form = $this->getBuilder('name', '\stdClass', array( - 'validation_groups' => array(), - )) - ->setData($object) - ->getForm(); - - $form->setData($object); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testDontValidateConstraintsIfNoValidationGroups() - { - $object = $this->getMock('\stdClass'); - $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint'); - $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint'); - - $options = array( - 'validation_groups' => array(), - 'constraints' => array($constraint1, $constraint2), - ); - $form = $this->getBuilder('name', '\stdClass', $options) - ->setData($object) - ->getForm(); - - // Launch transformer - $form->submit(array()); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testDontValidateIfNotSynchronized() - { - $object = $this->getMock('\stdClass'); - - $form = $this->getBuilder('name', '\stdClass', array( - 'invalid_message' => 'invalid_message_key', - // Invalid message parameters must be supported, because the - // invalid message can be a translation key - // see https://github.com/symfony/symfony/issues/5144 - 'invalid_message_parameters' => array('{{ foo }}' => 'bar'), - )) - ->setData($object) - ->addViewTransformer(new CallbackTransformer( - function ($data) { return $data; }, - function () { throw new TransformationFailedException(); } - )) - ->getForm(); - - // Launch transformer - $form->submit('foo'); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->buildViolation('invalid_message_key') - ->setParameter('{{ value }}', 'foo') - ->setParameter('{{ foo }}', 'bar') - ->setInvalidValue('foo') - ->setCode(Form::NOT_SYNCHRONIZED_ERROR) - ->setCause($this->context instanceof ExecutionContextInterface ? $form->getTransformationFailure() : null) - ->assertRaised(); - } - - public function testAddInvalidErrorEvenIfNoValidationGroups() - { - $object = $this->getMock('\stdClass'); - - $form = $this->getBuilder('name', '\stdClass', array( - 'invalid_message' => 'invalid_message_key', - // Invalid message parameters must be supported, because the - // invalid message can be a translation key - // see https://github.com/symfony/symfony/issues/5144 - 'invalid_message_parameters' => array('{{ foo }}' => 'bar'), - 'validation_groups' => array(), - )) - ->setData($object) - ->addViewTransformer(new CallbackTransformer( - function ($data) { return $data; }, - function () { throw new TransformationFailedException(); } - )) - ->getForm(); - - // Launch transformer - $form->submit('foo'); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->buildViolation('invalid_message_key') - ->setParameter('{{ value }}', 'foo') - ->setParameter('{{ foo }}', 'bar') - ->setInvalidValue('foo') - ->setCode(Form::NOT_SYNCHRONIZED_ERROR) - ->setCause($this->context instanceof ExecutionContextInterface ? $form->getTransformationFailure() : null) - ->assertRaised(); - } - - public function testDontValidateConstraintsIfNotSynchronized() - { - $object = $this->getMock('\stdClass'); - $constraint1 = $this->getMock('Symfony\Component\Validator\Constraint'); - $constraint2 = $this->getMock('Symfony\Component\Validator\Constraint'); - - $options = array( - 'invalid_message' => 'invalid_message_key', - 'validation_groups' => array('group1', 'group2'), - 'constraints' => array($constraint1, $constraint2), - ); - $form = $this->getBuilder('name', '\stdClass', $options) - ->setData($object) - ->addViewTransformer(new CallbackTransformer( - function ($data) { return $data; }, - function () { throw new TransformationFailedException(); } - )) - ->getForm(); - - // Launch transformer - $form->submit('foo'); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->buildViolation('invalid_message_key') - ->setParameter('{{ value }}', 'foo') - ->setInvalidValue('foo') - ->setCode(Form::NOT_SYNCHRONIZED_ERROR) - ->setCause($this->context instanceof ExecutionContextInterface ? $form->getTransformationFailure() : null) - ->assertRaised(); - } - - // https://github.com/symfony/symfony/issues/4359 - public function testDontMarkInvalidIfAnyChildIsNotSynchronized() - { - $object = $this->getMock('\stdClass'); - - $failingTransformer = new CallbackTransformer( - function ($data) { return $data; }, - function () { throw new TransformationFailedException(); } - ); - - $form = $this->getBuilder('name', '\stdClass') - ->setData($object) - ->addViewTransformer($failingTransformer) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->add( - $this->getBuilder('child') - ->addViewTransformer($failingTransformer) - ) - ->getForm(); - - // Launch transformer - $form->submit(array('child' => 'foo')); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testHandleCallbackValidationGroups() - { - $object = $this->getMock('\stdClass'); - $options = array('validation_groups' => array($this, 'getValidationGroups')); - $form = $this->getBuilder('name', '\stdClass', $options) - ->setData($object) - ->getForm(); - - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testDontExecuteFunctionNames() - { - $object = $this->getMock('\stdClass'); - $options = array('validation_groups' => 'header'); - $form = $this->getBuilder('name', '\stdClass', $options) - ->setData($object) - ->getForm(); - - $this->expectValidateAt(0, 'data', $object, 'header'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testHandleClosureValidationGroups() - { - $object = $this->getMock('\stdClass'); - $options = array('validation_groups' => function (FormInterface $form) { - return array('group1', 'group2'); - }); - $form = $this->getBuilder('name', '\stdClass', $options) - ->setData($object) - ->getForm(); - - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testUseValidationGroupOfClickedButton() - { - $object = $this->getMock('\stdClass'); - - $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $form = $this->getForm('name', '\stdClass', array( - 'validation_groups' => 'form_group', - )); - - $parent->add($form); - $parent->add($this->getSubmitButton('submit', array( - 'validation_groups' => 'button_group', - ))); - - $parent->submit(array('name' => $object, 'submit' => '')); - - $this->expectValidateAt(0, 'data', $object, 'button_group'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testDontUseValidationGroupOfUnclickedButton() - { - $object = $this->getMock('\stdClass'); - - $parent = $this->getBuilder('parent', null, array('cascade_validation' => true)) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $form = $this->getForm('name', '\stdClass', array( - 'validation_groups' => 'form_group', - )); - - $parent->add($form); - $parent->add($this->getSubmitButton('submit', array( - 'validation_groups' => 'button_group', - ))); - - $form->setData($object); - - $this->expectValidateAt(0, 'data', $object, 'form_group'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testUseInheritedValidationGroup() - { - $object = $this->getMock('\stdClass'); - - $parentOptions = array( - 'validation_groups' => 'group', - 'cascade_validation' => true, - ); - $parent = $this->getBuilder('parent', null, $parentOptions) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $form = $this->getBuilder('name', '\stdClass')->getForm(); - $parent->add($form); - - $form->setData($object); - - $this->expectValidateAt(0, 'data', $object, 'group'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testUseInheritedCallbackValidationGroup() - { - $object = $this->getMock('\stdClass'); - - $parentOptions = array( - 'validation_groups' => array($this, 'getValidationGroups'), - 'cascade_validation' => true, - ); - $parent = $this->getBuilder('parent', null, $parentOptions) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $form = $this->getBuilder('name', '\stdClass')->getForm(); - $parent->add($form); - - $form->setData($object); - - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testUseInheritedClosureValidationGroup() - { - $object = $this->getMock('\stdClass'); - - $parentOptions = array( - 'validation_groups' => function (FormInterface $form) { - return array('group1', 'group2'); - }, - 'cascade_validation' => true, - ); - $parent = $this->getBuilder('parent', null, $parentOptions) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $form = $this->getBuilder('name', '\stdClass')->getForm(); - $parent->add($form); - - $form->setData($object); - - $this->expectValidateAt(0, 'data', $object, 'group1'); - $this->expectValidateAt(1, 'data', $object, 'group2'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testAppendPropertyPath() - { - $object = $this->getMock('\stdClass'); - $form = $this->getBuilder('name', '\stdClass') - ->setData($object) - ->getForm(); - - $this->expectValidateAt(0, 'data', $object, 'Default'); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testDontWalkScalars() - { - $form = $this->getBuilder() - ->setData('scalar') - ->getForm(); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->assertNoViolation(); - } - - public function testViolationIfExtraData() - { - $form = $this->getBuilder('parent', null, array('extra_fields_message' => 'Extra!')) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->add($this->getBuilder('child')) - ->getForm(); - - $form->submit(array('foo' => 'bar')); - - $this->expectNoValidate(); - - $this->validator->validate($form, new Form()); - - $this->buildViolation('Extra!') - ->setParameter('{{ extra_fields }}', 'foo') - ->setInvalidValue(array('foo' => 'bar')) - ->setCode(Form::NO_SUCH_FIELD_ERROR) - ->assertRaised(); - } - - public function testNoViolationIfAllowExtraData() - { - $context = $this->getMockExecutionContext(); - - $form = $this - ->getBuilder('parent', null, array('allow_extra_fields' => true)) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->add($this->getBuilder('child')) - ->getForm(); - - $form->bind(array('foo' => 'bar')); - - $context->expects($this->never()) - ->method('addViolation'); - $context->expects($this->never()) - ->method('addViolationAt'); - - $this->validator->initialize($context); - $this->validator->validate($form, new Form()); - } - - /** - * Access has to be public, as this method is called via callback array - * in {@link testValidateFormDataCanHandleCallbackValidationGroups()} - * and {@link testValidateFormDataUsesInheritedCallbackValidationGroup()}. - */ - public function getValidationGroups(FormInterface $form) - { - return array('group1', 'group2'); - } - - private function getMockExecutionContext() - { - $context = $this->getMock('Symfony\Component\Validator\Context\ExecutionContextInterface'); - $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); - $contextualValidator = $this->getMock('Symfony\Component\Validator\Validator\ContextualValidatorInterface'); - - $validator->expects($this->any()) - ->method('inContext') - ->with($context) - ->will($this->returnValue($contextualValidator)); - - $context->expects($this->any()) - ->method('getValidator') - ->will($this->returnValue($validator)); - - return $context; - } - - /** - * @param string $name - * @param string $dataClass - * @param array $options - * - * @return FormBuilder - */ - private function getBuilder($name = 'name', $dataClass = null, array $options = array()) - { - $options = array_replace(array( - 'constraints' => array(), - 'invalid_message_parameters' => array(), - ), $options); - - return new FormBuilder($name, $dataClass, $this->dispatcher, $this->factory, $options); - } - - private function getForm($name = 'name', $dataClass = null, array $options = array()) - { - return $this->getBuilder($name, $dataClass, $options)->getForm(); - } - - private function getSubmitButton($name = 'name', array $options = array()) - { - $builder = new SubmitButtonBuilder($name, $options); - - return $builder->getForm(); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getDataMapper() - { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidator2Dot4ApiTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidator2Dot4ApiTest.php deleted file mode 100644 index f94df0c7e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidator2Dot4ApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyFormValidator2Dot4ApiTest extends FormValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_4; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidatorLegacyApiTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidatorLegacyApiTest.php deleted file mode 100644 index 9adb364a3..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Constraints/LegacyFormValidatorLegacyApiTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Constraints; - -use Symfony\Component\Validator\Validation; - -/** - * @since 2.5.3 - * @author Bernhard Schussek - * @group legacy - */ -class LegacyFormValidatorLegacyApiTest extends FormValidatorTest -{ - protected function getApiVersion() - { - return Validation::API_VERSION_2_5_BC; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php deleted file mode 100644 index 91608aebe..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/EventListener/ValidationListenerTest.php +++ /dev/null @@ -1,208 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\EventListener; - -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\Extension\Validator\Constraints\Form; -use Symfony\Component\Form\Extension\Validator\EventListener\ValidationListener; -use Symfony\Component\PropertyAccess\PropertyPath; -use Symfony\Component\Validator\ConstraintViolation; -use Symfony\Component\Validator\ConstraintViolationList; - -class ValidationListenerTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dispatcher; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $factory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $validator; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $violationMapper; - - /** - * @var ValidationListener - */ - private $listener; - - private $message; - - private $messageTemplate; - - private $params; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); - $this->violationMapper = $this->getMock('Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapperInterface'); - $this->listener = new ValidationListener($this->validator, $this->violationMapper); - $this->message = 'Message'; - $this->messageTemplate = 'Message template'; - $this->params = array('foo' => 'bar'); - } - - private function getConstraintViolation($code = null, $constraint = null) - { - return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, 'prop.path', null, null, $code, $constraint); - } - - private function getBuilder($name = 'name', $propertyPath = null, $dataClass = null) - { - $builder = new FormBuilder($name, $dataClass, $this->dispatcher, $this->factory); - $builder->setPropertyPath(new PropertyPath($propertyPath ?: $name)); - $builder->setAttribute('error_mapping', array()); - $builder->setErrorBubbling(false); - $builder->setMapped(true); - - return $builder; - } - - private function getForm($name = 'name', $propertyPath = null, $dataClass = null) - { - return $this->getBuilder($name, $propertyPath, $dataClass)->getForm(); - } - - private function getMockForm() - { - return $this->getMock('Symfony\Component\Form\Test\FormInterface'); - } - - // More specific mapping tests can be found in ViolationMapperTest - public function testMapViolation() - { - $violation = $this->getConstraintViolation(null, new Form()); - $form = $this->getForm('street'); - - $this->validator->expects($this->once()) - ->method('validate') - ->will($this->returnValue(array($violation))); - - $this->violationMapper->expects($this->once()) - ->method('mapViolation') - ->with($violation, $form, false); - - $this->listener->validateForm(new FormEvent($form, null)); - } - - public function testMapViolationAllowsNonSyncIfInvalid() - { - $violation = $this->getConstraintViolation(Form::NOT_SYNCHRONIZED_ERROR, new Form()); - $form = $this->getForm('street'); - - $this->validator->expects($this->once()) - ->method('validate') - ->will($this->returnValue(array($violation))); - - $this->violationMapper->expects($this->once()) - ->method('mapViolation') - // pass true now - ->with($violation, $form, true); - - $this->listener->validateForm(new FormEvent($form, null)); - } - - public function testMapViolationAllowsNonSyncIfInvalidWithoutConstraintReference() - { - // constraint violations have no reference to the constraint if they are created by - // Symfony\Component\Validator\ExecutionContext - // which is deprecated in favor of - // Symfony\Component\Validator\Context\ExecutionContext - $violation = $this->getConstraintViolation(Form::NOT_SYNCHRONIZED_ERROR, null); - $form = $this->getForm('street'); - - $this->validator->expects($this->once()) - ->method('validate') - ->will($this->returnValue(array($violation))); - - $this->violationMapper->expects($this->once()) - ->method('mapViolation') - // pass true now - ->with($violation, $form, true); - - $this->listener->validateForm(new FormEvent($form, null)); - } - - public function testValidateIgnoresNonRoot() - { - $form = $this->getMockForm(); - $form->expects($this->once()) - ->method('isRoot') - ->will($this->returnValue(false)); - - $this->validator->expects($this->never()) - ->method('validate'); - - $this->violationMapper->expects($this->never()) - ->method('mapViolation'); - - $this->listener->validateForm(new FormEvent($form, null)); - } - - public function testValidateWithEmptyViolationList() - { - $form = $this->getMockForm(); - $form->expects($this->once()) - ->method('isRoot') - ->will($this->returnValue(true)); - - $this->validator - ->expects($this->once()) - ->method('validate') - ->will($this->returnValue(new ConstraintViolationList())); - - $this->violationMapper - ->expects($this->never()) - ->method('mapViolation'); - - $this->listener->validateForm(new FormEvent($form, null)); - } - - public function testValidatorInterfaceSinceSymfony25() - { - // Mock of ValidatorInterface since apiVersion 2.5 - $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); - - $listener = new ValidationListener($validator, $this->violationMapper); - $this->assertAttributeSame($validator, 'validator', $listener); - } - - public function testValidatorInterfaceUntilSymfony24() - { - // Mock of ValidatorInterface until apiVersion 2.4 - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); - - $listener = new ValidationListener($validator, $this->violationMapper); - $this->assertAttributeSame($validator, 'validator', $listener); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidValidatorInterface() - { - new ValidationListener(null, $this->violationMapper); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php deleted file mode 100644 index e26bf7f1b..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/BaseValidatorExtensionTest.php +++ /dev/null @@ -1,74 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Type; - -use Symfony\Component\Form\Test\FormInterface; - -/** - * @author Bernhard Schussek - */ -abstract class BaseValidatorExtensionTest extends TypeTestCase -{ - public function testValidationGroupNullByDefault() - { - $form = $this->createForm(); - - $this->assertNull($form->getConfig()->getOption('validation_groups')); - } - - public function testValidationGroupsTransformedToArray() - { - $form = $this->createForm(array( - 'validation_groups' => 'group', - )); - - $this->assertEquals(array('group'), $form->getConfig()->getOption('validation_groups')); - } - - public function testValidationGroupsCanBeSetToArray() - { - $form = $this->createForm(array( - 'validation_groups' => array('group1', 'group2'), - )); - - $this->assertEquals(array('group1', 'group2'), $form->getConfig()->getOption('validation_groups')); - } - - public function testValidationGroupsCanBeSetToFalse() - { - $form = $this->createForm(array( - 'validation_groups' => false, - )); - - $this->assertEquals(array(), $form->getConfig()->getOption('validation_groups')); - } - - public function testValidationGroupsCanBeSetToCallback() - { - $form = $this->createForm(array( - 'validation_groups' => array($this, 'testValidationGroupsCanBeSetToCallback'), - )); - - $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); - } - - public function testValidationGroupsCanBeSetToClosure() - { - $form = $this->createForm(array( - 'validation_groups' => function (FormInterface $form) { return; }, - )); - - $this->assertTrue(is_callable($form->getConfig()->getOption('validation_groups'))); - } - - abstract protected function createForm(array $options = array()); -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php deleted file mode 100644 index 4ca10da50..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/FormTypeValidatorExtensionTest.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Type; - -use Symfony\Component\Form\Extension\Validator\Type\FormTypeValidatorExtension; -use Symfony\Component\Validator\ConstraintViolationList; - -class FormTypeValidatorExtensionTest extends BaseValidatorExtensionTest -{ - public function testSubmitValidatesData() - { - $builder = $this->factory->createBuilder( - 'form', - null, - array( - 'validation_groups' => 'group', - ) - ); - $builder->add('firstName', 'form'); - $form = $builder->getForm(); - - $this->validator->expects($this->once()) - ->method('validate') - ->with($this->equalTo($form)) - ->will($this->returnValue(new ConstraintViolationList())); - - // specific data is irrelevant - $form->submit(array()); - } - - public function testValidatorInterfaceSinceSymfony25() - { - // Mock of ValidatorInterface since apiVersion 2.5 - $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); - - $formTypeValidatorExtension = new FormTypeValidatorExtension($validator); - $this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); - } - - public function testValidatorInterfaceUntilSymfony24() - { - // Mock of ValidatorInterface until apiVersion 2.4 - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); - - $formTypeValidatorExtension = new FormTypeValidatorExtension($validator); - $this->assertAttributeSame($validator, 'validator', $formTypeValidatorExtension); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testInvalidValidatorInterface() - { - new FormTypeValidatorExtension(null); - } - - protected function createForm(array $options = array()) - { - return $this->factory->create('form', null, $options); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php deleted file mode 100644 index c37cf6733..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/SubmitTypeValidatorExtensionTest.php +++ /dev/null @@ -1,20 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Type; - -class SubmitTypeValidatorExtensionTest extends BaseValidatorExtensionTest -{ - protected function createForm(array $options = array()) - { - return $this->factory->create('submit', null, $options); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php deleted file mode 100644 index f197b1985..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Type/TypeTestCase.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Type; - -use Symfony\Component\Form\Test\TypeTestCase as BaseTypeTestCase; -use Symfony\Component\Form\Extension\Validator\ValidatorExtension; - -abstract class TypeTestCase extends BaseTypeTestCase -{ - protected $validator; - - protected function setUp() - { - $this->validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); - $metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); - $this->validator->expects($this->once())->method('getMetadataFactory')->will($this->returnValue($metadataFactory)); - $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata')->disableOriginalConstructor()->getMock(); - $metadataFactory->expects($this->once())->method('getMetadataFor')->will($this->returnValue($metadata)); - - parent::setUp(); - } - - protected function tearDown() - { - $this->validator = null; - - parent::tearDown(); - } - - protected function getExtensions() - { - return array_merge(parent::getExtensions(), array( - new ValidatorExtension($this->validator), - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php deleted file mode 100644 index 957b59702..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/Util/ServerParamsTest.php +++ /dev/null @@ -1,71 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\Util; - -use Symfony\Component\Form\Extension\Validator\Util\ServerParams; -use Symfony\Component\HttpFoundation\Request; - -class ServerParamsTest extends \PHPUnit_Framework_TestCase -{ - public function testGetContentLengthFromSuperglobals() - { - $serverParams = new ServerParams(); - $this->assertNull($serverParams->getContentLength()); - - $_SERVER['CONTENT_LENGTH'] = 1024; - - $this->assertEquals(1024, $serverParams->getContentLength()); - - unset($_SERVER['CONTENT_LENGTH']); - } - - public function testGetContentLengthFromRequest() - { - $request = Request::create('http://foo', 'GET', array(), array(), array(), array('CONTENT_LENGTH' => 1024)); - $requestStack = $this->getMock('Symfony\Component\HttpFoundation\RequestStack', array('getCurrentRequest')); - $requestStack->expects($this->once())->method('getCurrentRequest')->will($this->returnValue($request)); - $serverParams = new ServerParams($requestStack); - - $this->assertEquals(1024, $serverParams->getContentLength()); - } - - /** @dataProvider getGetPostMaxSizeTestData */ - public function testGetPostMaxSize($size, $bytes) - { - $serverParams = $this->getMock('Symfony\Component\Form\Extension\Validator\Util\ServerParams', array('getNormalizedIniPostMaxSize')); - $serverParams - ->expects($this->any()) - ->method('getNormalizedIniPostMaxSize') - ->will($this->returnValue(strtoupper($size))); - - $this->assertEquals($bytes, $serverParams->getPostMaxSize()); - } - - public function getGetPostMaxSizeTestData() - { - return array( - array('2k', 2048), - array('2 k', 2048), - array('8m', 8 * 1024 * 1024), - array('+2 k', 2048), - array('+2???k', 2048), - array('0x10', 16), - array('0xf', 15), - array('010', 8), - array('+0x10 k', 16 * 1024), - array('1g', 1024 * 1024 * 1024), - array('-1', -1), - array('0', 0), - array('2mk', 2048), // the unit must be the last char, so in this case 'k', not 'm' - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php deleted file mode 100644 index eca087381..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ValidatorExtensionTest.php +++ /dev/null @@ -1,84 +0,0 @@ - -* -* For the full copyright and license information, please view the LICENSE -* file that was distributed with this source code. -*/ - -namespace Symfony\Component\Form\Tests\Extension\Validator; - -use Symfony\Component\Form\Extension\Validator\ValidatorExtension; - -class ValidatorExtensionTest extends \PHPUnit_Framework_TestCase -{ - public function test2Dot5ValidationApi() - { - $validator = $this->getMock('Symfony\Component\Validator\Validator\ValidatorInterface'); - $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata') - ->disableOriginalConstructor() - ->getMock(); - - $validator->expects($this->once()) - ->method('getMetadataFor') - ->with($this->identicalTo('Symfony\Component\Form\Form')) - ->will($this->returnValue($metadata)); - - // Verify that the constraints are added - $metadata->expects($this->once()) - ->method('addConstraint') - ->with($this->isInstanceOf('Symfony\Component\Form\Extension\Validator\Constraints\Form')); - - $metadata->expects($this->once()) - ->method('addPropertyConstraint') - ->with('children', $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid')); - - $extension = new ValidatorExtension($validator); - $guesser = $extension->loadTypeGuesser(); - - $this->assertInstanceOf('Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser', $guesser); - } - - public function test2Dot4ValidationApi() - { - $factory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); - $validator = $this->getMock('Symfony\Component\Validator\ValidatorInterface'); - $metadata = $this->getMockBuilder('Symfony\Component\Validator\Mapping\ClassMetadata') - ->disableOriginalConstructor() - ->getMock(); - - $validator->expects($this->any()) - ->method('getMetadataFactory') - ->will($this->returnValue($factory)); - - $factory->expects($this->once()) - ->method('getMetadataFor') - ->with($this->identicalTo('Symfony\Component\Form\Form')) - ->will($this->returnValue($metadata)); - - // Verify that the constraints are added - $metadata->expects($this->once()) - ->method('addConstraint') - ->with($this->isInstanceOf('Symfony\Component\Form\Extension\Validator\Constraints\Form')); - - $metadata->expects($this->once()) - ->method('addPropertyConstraint') - ->with('children', $this->isInstanceOf('Symfony\Component\Validator\Constraints\Valid')); - - $extension = new ValidatorExtension($validator); - $guesser = $extension->loadTypeGuesser(); - - $this->assertInstanceOf('Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser', $guesser); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testInvalidValidatorInterface() - { - new ValidatorExtension(null); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php deleted file mode 100644 index 61b2a917e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ValidatorTypeGuesserTest.php +++ /dev/null @@ -1,137 +0,0 @@ - -* -* For the full copyright and license information, please view the LICENSE -* file that was distributed with this source code. -*/ - -namespace Symfony\Component\Form\Tests\Extension\Validator; - -use Symfony\Component\Form\Extension\Validator\ValidatorTypeGuesser; -use Symfony\Component\Form\Guess\Guess; -use Symfony\Component\Form\Guess\ValueGuess; -use Symfony\Component\Validator\Constraints\Email; -use Symfony\Component\Validator\Constraints\Length; -use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\Constraints\NotNull; -use Symfony\Component\Validator\Constraints\Range; -use Symfony\Component\Validator\Constraints\True; -use Symfony\Component\Validator\Constraints\Type; -use Symfony\Component\Validator\Mapping\ClassMetadata; - -/** - * @author franek - * @author Bernhard Schussek - */ -class ValidatorTypeGuesserTest extends \PHPUnit_Framework_TestCase -{ - const TEST_CLASS = 'Symfony\Component\Form\Tests\Extension\Validator\ValidatorTypeGuesserTest_TestClass'; - - const TEST_PROPERTY = 'property'; - - /** - * @var ValidatorTypeGuesser - */ - private $guesser; - - /** - * @var ClassMetadata - */ - private $metadata; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $metadataFactory; - - protected function setUp() - { - $this->metadata = new ClassMetadata(self::TEST_CLASS); - $this->metadataFactory = $this->getMock('Symfony\Component\Validator\MetadataFactoryInterface'); - $this->metadataFactory->expects($this->any()) - ->method('getMetadataFor') - ->with(self::TEST_CLASS) - ->will($this->returnValue($this->metadata)); - $this->guesser = new ValidatorTypeGuesser($this->metadataFactory); - } - - public function guessRequiredProvider() - { - return array( - array(new NotNull(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), - array(new NotBlank(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), - array(new True(), new ValueGuess(true, Guess::HIGH_CONFIDENCE)), - array(new Length(10), new ValueGuess(false, Guess::LOW_CONFIDENCE)), - array(new Range(array('min' => 1, 'max' => 20)), new ValueGuess(false, Guess::LOW_CONFIDENCE)), - ); - } - - /** - * @dataProvider guessRequiredProvider - */ - public function testGuessRequired($constraint, $guess) - { - // add distracting constraint - $this->metadata->addPropertyConstraint(self::TEST_PROPERTY, new Email()); - - // add constraint under test - $this->metadata->addPropertyConstraint(self::TEST_PROPERTY, $constraint); - - $this->assertEquals($guess, $this->guesser->guessRequired(self::TEST_CLASS, self::TEST_PROPERTY)); - } - - public function testGuessRequiredReturnsFalseForUnmappedProperties() - { - $this->assertEquals(new ValueGuess(false, Guess::LOW_CONFIDENCE), $this->guesser->guessRequired(self::TEST_CLASS, self::TEST_PROPERTY)); - } - - public function testGuessMaxLengthForConstraintWithMaxValue() - { - $constraint = new Length(array('max' => '2')); - - $result = $this->guesser->guessMaxLengthForConstraint($constraint); - $this->assertInstanceOf('Symfony\Component\Form\Guess\ValueGuess', $result); - $this->assertEquals(2, $result->getValue()); - $this->assertEquals(Guess::HIGH_CONFIDENCE, $result->getConfidence()); - } - - public function testGuessMaxLengthForConstraintWithMinValue() - { - $constraint = new Length(array('min' => '2')); - - $result = $this->guesser->guessMaxLengthForConstraint($constraint); - $this->assertNull($result); - } - - public function maxLengthTypeProvider() - { - return array( - array('double'), - array('float'), - array('numeric'), - array('real'), - ); - } - - /** - * @dataProvider maxLengthTypeProvider - */ - public function testGuessMaxLengthForConstraintWithType($type) - { - $constraint = new Type($type); - - $result = $this->guesser->guessMaxLengthForConstraint($constraint); - $this->assertInstanceOf('Symfony\Component\Form\Guess\ValueGuess', $result); - $this->assertNull($result->getValue()); - $this->assertEquals(Guess::MEDIUM_CONFIDENCE, $result->getConfidence()); - } -} - -class ValidatorTypeGuesserTest_TestClass -{ - private $property; -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php deleted file mode 100644 index dc25e747f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationMapperTest.php +++ /dev/null @@ -1,1538 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper; - -use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationMapper; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\Form\CallbackTransformer; -use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormConfigBuilder; -use Symfony\Component\Form\FormError; -use Symfony\Component\PropertyAccess\PropertyPath; -use Symfony\Component\Validator\ConstraintViolation; -use Symfony\Component\Validator\ConstraintViolationInterface; - -/** - * @author Bernhard Schussek - */ -class ViolationMapperTest extends \PHPUnit_Framework_TestCase -{ - const LEVEL_0 = 0; - - const LEVEL_1 = 1; - - const LEVEL_1B = 2; - - const LEVEL_2 = 3; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dispatcher; - - /** - * @var ViolationMapper - */ - private $mapper; - - /** - * @var string - */ - private $message; - - /** - * @var string - */ - private $messageTemplate; - - /** - * @var array - */ - private $params; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->mapper = new ViolationMapper(); - $this->message = 'Message'; - $this->messageTemplate = 'Message template'; - $this->params = array('foo' => 'bar'); - } - - protected function getForm($name = 'name', $propertyPath = null, $dataClass = null, $errorMapping = array(), $inheritData = false, $synchronized = true) - { - $config = new FormConfigBuilder($name, $dataClass, $this->dispatcher, array( - 'error_mapping' => $errorMapping, - )); - $config->setMapped(true); - $config->setInheritData($inheritData); - $config->setPropertyPath($propertyPath); - $config->setCompound(true); - $config->setDataMapper($this->getDataMapper()); - - if (!$synchronized) { - $config->addViewTransformer(new CallbackTransformer( - function ($normData) { return $normData; }, - function () { throw new TransformationFailedException(); } - )); - } - - return new Form($config); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getDataMapper() - { - return $this->getMock('Symfony\Component\Form\DataMapperInterface'); - } - - /** - * @param $propertyPath - * - * @return ConstraintViolation - */ - protected function getConstraintViolation($propertyPath) - { - return new ConstraintViolation($this->message, $this->messageTemplate, $this->params, null, $propertyPath, null); - } - - /** - * @return FormError - */ - protected function getFormError(ConstraintViolationInterface $violation) - { - return new FormError($this->message, $this->messageTemplate, $this->params, null, $violation); - } - - public function testMapToFormInheritingParentDataIfDataDoesNotMatch() - { - $violation = $this->getConstraintViolation('children[address].data.foo'); - $parent = $this->getForm('parent'); - $child = $this->getForm('address', 'address', null, array(), true); - $grandChild = $this->getForm('street'); - - $parent->add($child); - $child->add($grandChild); - - $parent->submit(array()); - - $this->mapper->mapViolation($violation, $parent); - - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($child->getErrors()), $child->getName().' should have an error, but has none'); - $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); - } - - public function testFollowDotRules() - { - $violation = $this->getConstraintViolation('data.foo'); - $parent = $this->getForm('parent', null, null, array( - 'foo' => 'address', - )); - $child = $this->getForm('address', null, null, array( - '.' => 'street', - )); - $grandChild = $this->getForm('street', null, null, array( - '.' => 'name', - )); - $grandGrandChild = $this->getForm('name'); - - $parent->add($child); - $child->add($grandChild); - $grandChild->add($grandGrandChild); - - $parent->submit(array()); - - $this->mapper->mapViolation($violation, $parent); - - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($grandGrandChild->getErrors()), $grandGrandChild->getName().' should have an error, but has none'); - } - - public function testAbortMappingIfNotSynchronized() - { - $violation = $this->getConstraintViolation('children[address].data.street'); - $parent = $this->getForm('parent'); - $child = $this->getForm('address', 'address', null, array(), false, false); - // even though "street" is synchronized, it should not have any errors - // due to its parent not being synchronized - $grandChild = $this->getForm('street', 'street'); - - $parent->add($child); - $child->add($grandChild); - - // invoke the transformer and mark the form unsynchronized - $parent->submit(array()); - - $this->mapper->mapViolation($violation, $parent); - - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); - } - - public function testAbortDotRuleMappingIfNotSynchronized() - { - $violation = $this->getConstraintViolation('data.address'); - $parent = $this->getForm('parent'); - $child = $this->getForm('address', 'address', null, array( - '.' => 'street', - ), false, false); - // even though "street" is synchronized, it should not have any errors - // due to its parent not being synchronized - $grandChild = $this->getForm('street'); - - $parent->add($child); - $child->add($grandChild); - - // invoke the transformer and mark the form unsynchronized - $parent->submit(array()); - - $this->mapper->mapViolation($violation, $parent); - - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); - } - - public function testAbortMappingIfNotSubmitted() - { - $violation = $this->getConstraintViolation('children[address].data.street'); - $parent = $this->getForm('parent'); - $child = $this->getForm('address', 'address'); - $grandChild = $this->getForm('street', 'street'); - - $parent->add($child); - $child->add($grandChild); - - // Disable automatic submission of missing fields - $parent->submit(array(), false); - $child->submit(array(), false); - - // $grandChild is not submitted - - $this->mapper->mapViolation($violation, $parent); - - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); - } - - public function testAbortDotRuleMappingIfNotSubmitted() - { - $violation = $this->getConstraintViolation('data.address'); - $parent = $this->getForm('parent'); - $child = $this->getForm('address', 'address', null, array( - '.' => 'street', - )); - $grandChild = $this->getForm('street'); - - $parent->add($child); - $child->add($grandChild); - - // Disable automatic submission of missing fields - $parent->submit(array(), false); - $child->submit(array(), false); - - // $grandChild is not submitted - - $this->mapper->mapViolation($violation, $parent); - - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $child->getName().' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChild->getName().' should not have an error, but has one'); - } - - public function provideDefaultTests() - { - // The mapping must be deterministic! If a child has the property path "[street]", - // "data[street]" should be mapped, but "data.street" should not! - return array( - // mapping target, child name, its property path, grand child name, its property path, violation path - array(self::LEVEL_0, 'address', 'address', 'street', 'street', ''), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data'), - - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street].prop'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.address.street'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.address.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'data.address[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'data.address[street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street]'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street].prop'), - - array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data'), - array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'children[address].data.street.prop'), - array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address].data[street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'data.address.street'), - array(self::LEVEL_1, 'address', 'address', 'street', '[street]', 'data.address.street.prop'), - array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'data.address[street]'), - array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'data.address[street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address].street'), - array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address].street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address][street]'), - array(self::LEVEL_0, 'address', 'address', 'street', '[street]', 'data[address][street].prop'), - - array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'children[address].data[street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address.street'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address.street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address[street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'street', 'data.address[street].prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'data[address].street'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'data[address].street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'data[address][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'street', 'data[address][street].prop'), - - array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'children[address].data.street.prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address].data[street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address.street'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address.street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address[street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[street]', 'data.address[street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'data[address].street'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[street]', 'data[address].street.prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'data[address][street]'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'data[address][street].prop'), - - array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data'), - array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'children[address].data[street].prop'), - array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'data.person.address.street'), - array(self::LEVEL_2, 'address', 'person.address', 'street', 'street', 'data.person.address.street.prop'), - array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'data.person.address[street]'), - array(self::LEVEL_1, 'address', 'person.address', 'street', 'street', 'data.person.address[street].prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address].street'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address].street.prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address][street]'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.person[address][street].prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address.street'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address.street.prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address[street]'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person].address[street].prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address].street'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address].street.prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address][street]'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data[person][address][street].prop'), - - array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data'), - array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'children[address].data.street.prop'), - array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'children[address].data[street].prop'), - array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'data.person.address.street'), - array(self::LEVEL_1, 'address', 'person.address', 'street', '[street]', 'data.person.address.street.prop'), - array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'data.person.address[street]'), - array(self::LEVEL_2, 'address', 'person.address', 'street', '[street]', 'data.person.address[street].prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address].street'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address].street.prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address][street]'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data.person[address][street].prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address.street'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address.street.prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address[street]'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person].address[street].prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address].street'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address].street.prop'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address][street]'), - array(self::LEVEL_0, 'address', 'person.address', 'street', '[street]', 'data[person][address][street].prop'), - - array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'children[address].data[street].prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address.street'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address.street.prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address[street]'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data.person.address[street].prop'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'data.person[address].street'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', 'street', 'data.person[address].street.prop'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'data.person[address][street]'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', 'street', 'data.person[address][street].prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address.street'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address.street.prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address[street]'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person].address[street].prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address].street'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address].street.prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address][street]'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', 'street', 'data[person][address][street].prop'), - - array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'children[address].data.street.prop'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'children[address].data[street].prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address.street'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address.street.prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address[street]'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data.person.address[street].prop'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'data.person[address].street'), - array(self::LEVEL_1, 'address', 'person[address]', 'street', '[street]', 'data.person[address].street.prop'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'data.person[address][street]'), - array(self::LEVEL_2, 'address', 'person[address]', 'street', '[street]', 'data.person[address][street].prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address.street'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address.street.prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address[street]'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person].address[street].prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address].street'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address].street.prop'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address][street]'), - array(self::LEVEL_0, 'address', 'person[address]', 'street', '[street]', 'data[person][address][street].prop'), - - array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data'), - array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'children[address].data[street].prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address.street'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address.street.prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address[street]'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person.address[street].prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address].street'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address].street.prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address][street]'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data.person[address][street].prop'), - array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'data[person].address.street'), - array(self::LEVEL_2, 'address', '[person].address', 'street', 'street', 'data[person].address.street.prop'), - array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'data[person].address[street]'), - array(self::LEVEL_1, 'address', '[person].address', 'street', 'street', 'data[person].address[street].prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address].street'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address].street.prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address][street]'), - array(self::LEVEL_0, 'address', '[person].address', 'street', 'street', 'data[person][address][street].prop'), - - array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data'), - array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'children[address].data.street.prop'), - array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'children[address].data[street].prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address.street'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address.street.prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address[street]'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person.address[street].prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address].street'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address].street.prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address][street]'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data.person[address][street].prop'), - array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'data[person].address.street'), - array(self::LEVEL_1, 'address', '[person].address', 'street', '[street]', 'data[person].address.street.prop'), - array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'data[person].address[street]'), - array(self::LEVEL_2, 'address', '[person].address', 'street', '[street]', 'data[person].address[street].prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address].street'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address].street.prop'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address][street]'), - array(self::LEVEL_0, 'address', '[person].address', 'street', '[street]', 'data[person][address][street].prop'), - - array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address]'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'children[address].data[street].prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address.street'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address.street.prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address[street]'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person.address[street].prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address].street'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address].street.prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address][street]'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data.person[address][street].prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address.street'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address.street.prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address[street]'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', 'street', 'data[person].address[street].prop'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'data[person][address].street'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', 'street', 'data[person][address].street.prop'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'data[person][address][street]'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', 'street', 'data[person][address][street].prop'), - - array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'children[address].data.street.prop'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'children[address].data[street].prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address.street'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address.street.prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address[street]'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person.address[street].prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address].street'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address].street.prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address][street]'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data.person[address][street].prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address.street'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address.street.prop'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address[street]'), - array(self::LEVEL_0, 'address', '[person][address]', 'street', '[street]', 'data[person].address[street].prop'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'data[person][address].street'), - array(self::LEVEL_1, 'address', '[person][address]', 'street', '[street]', 'data[person][address].street.prop'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'data[person][address][street]'), - array(self::LEVEL_2, 'address', '[person][address]', 'street', '[street]', 'data[person][address][street].prop'), - - array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].data.office.street'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'children[address].data.office.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.office[street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office].street'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office].street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office][street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data[office][street].prop'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'data.address.office.street'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office.street', 'data.address.office.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.office[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.office[street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office].street'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office].street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office][street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address[office][street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office.street'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office.street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office[street]'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address].office[street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office].street'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office].street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office][street]'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office.street', 'data[address][office][street].prop'), - - array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].data.office.street'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'children[address].data.office.street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office[street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data.office[street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office].street'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office].street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'children[address].data[office][street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office.street'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office.street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office[street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address.office[street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office].street'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office].street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office][street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office.street', 'data.address[office][street].prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'data[address].office.street'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office.street', 'data[address].office.street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address].office[street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address].office[street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office].street'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office].street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office.street', 'data[address][office][street].prop'), - - array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office.street'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data.office.street.prop'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].data.office[street]'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'children[address].data.office[street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office].street'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office].street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office][street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'children[address].data[office][street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address.office.street'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address.office.street.prop'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'data.address.office[street]'), - array(self::LEVEL_2, 'address', 'address', 'street', 'office[street]', 'data.address.office[street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office].street'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office].street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office][street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office[street]', 'data.address[office][street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office.street'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office.street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office[street]'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address].office[street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office].street'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office].street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office][street]'), - array(self::LEVEL_0, 'address', 'address', 'street', 'office[street]', 'data[address][office][street].prop'), - - array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office.street'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office.street.prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office[street]'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'children[address].data.office[street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office].street'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office].street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'children[address].data[office][street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office.street'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office.street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office[street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address.office[street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office].street'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office].street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office][street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', 'office[street]', 'data.address[office][street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address].office.street'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address].office.street.prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'data[address].office[street]'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'office[street]', 'data[address].office[street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office].street'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office].street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', 'office[street]', 'data[address][office][street].prop'), - - array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office.street'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data.office[street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office]'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].data[office].street'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'children[address].data[office].street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office][street]'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'children[address].data[office][street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office.street'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address.office[street].prop'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'data.address[office].street'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office].street', 'data.address[office].street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address[office][street]'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office].street', 'data.address[office][street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office.street'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office.street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office[street]'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address].office[street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office].street'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office].street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office][street]'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office].street', 'data[address][office][street].prop'), - - array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office.street'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office.street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office[street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data.office[street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office]'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].data[office].street'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'children[address].data[office].street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'children[address].data[office][street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office.street'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office.street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office[street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address.office[street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office].street'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office].street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office][street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office].street', 'data.address[office][street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office.street'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office.street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office[street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address].office[street].prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'data[address][office].street'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office].street', 'data[address][office].street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address][office][street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office].street', 'data[address][office][street].prop'), - - array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office.street'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data.office[street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office]'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office].street'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'children[address].data[office].street.prop'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].data[office][street]'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'children[address].data[office][street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office.street'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address.office[street].prop'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address[office].street'), - array(self::LEVEL_1, 'address', 'address', 'street', '[office][street]', 'data.address[office].street.prop'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'data.address[office][street]'), - array(self::LEVEL_2, 'address', 'address', 'street', '[office][street]', 'data.address[office][street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office.street'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office.street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office[street]'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address].office[street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office].street'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office].street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office][street]'), - array(self::LEVEL_0, 'address', 'address', 'street', '[office][street]', 'data[address][office][street].prop'), - - array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office.street'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office.street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office[street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data.office[street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office]'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office].street'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office].street.prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office][street]'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'children[address].data[office][street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office.street'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office.street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office[street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address.office[street].prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office].street'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office].street.prop'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office][street]'), - array(self::LEVEL_0, 'address', '[address]', 'street', '[office][street]', 'data.address[office][street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office.street'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office.street.prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office[street]'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address].office[street].prop'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address][office].street'), - array(self::LEVEL_1, 'address', '[address]', 'street', '[office][street]', 'data[address][office].street.prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'data[address][office][street]'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[office][street]', 'data[address][office][street].prop'), - - // Edge cases which must not occur - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address][street]'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address][street].prop'), - array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address][street]'), - array(self::LEVEL_2, 'address', 'address', 'street', '[street]', 'children[address][street].prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address][street]'), - array(self::LEVEL_2, 'address', '[address]', 'street', 'street', 'children[address][street].prop'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address][street]'), - array(self::LEVEL_2, 'address', '[address]', 'street', '[street]', 'children[address][street].prop'), - - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].children[address].children[street]'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].children[address].data.street'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'children[person].data.address.street'), - array(self::LEVEL_0, 'address', 'person.address', 'street', 'street', 'data.address.street'), - - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].children[office].children[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].children[office].data.street'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'children[address].data.street'), - array(self::LEVEL_1, 'address', 'address', 'street', 'office.street', 'data.address.street'), - ); - } - - /** - * @dataProvider provideDefaultTests - */ - public function testDefaultErrorMapping($target, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath) - { - $violation = $this->getConstraintViolation($violationPath); - $parent = $this->getForm('parent'); - $child = $this->getForm($childName, $childPath); - $grandChild = $this->getForm($grandChildName, $grandChildPath); - - $parent->add($child); - $child->add($grandChild); - - $parent->submit(array()); - - $this->mapper->mapViolation($violation, $parent); - - if (self::LEVEL_0 === $target) { - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($parent->getErrors()), $parent->getName().' should have an error, but has none'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } elseif (self::LEVEL_1 === $target) { - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($child->getErrors()), $childName.' should have an error, but has none'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } else { - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($grandChild->getErrors()), $grandChildName.' should have an error, but has none'); - } - } - - public function provideCustomDataErrorTests() - { - return array( - // mapping target, error mapping, child name, its property path, grand child name, its property path, violation path - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo'), - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo]'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].prop'), - - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address'), - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address]'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].prop'), - - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo]'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].prop'), - - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.prop'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address]'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo]'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].prop'), - - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo]'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address]'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'), - array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'), - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.street'), - array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address.street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address[street]'), - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', 'street', 'data.address[street].prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].street'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address].street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address][street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', 'street', 'data[address][street].prop'), - - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street'), - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street.prop'), - array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street]'), - array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street].prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street].prop'), - - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address.street'), - array(self::LEVEL_1, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address.street.prop'), - array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address[street]'), - array(self::LEVEL_2, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data.address[street].prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address].street'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address].street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address][street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', 'address', 'street', '[street]', 'data[address][street].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'), - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'), - - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.street'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address.street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address[street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.address[street].prop'), - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].street'), - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address].street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address][street]'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[address][street].prop'), - - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street.prop'), - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street]'), - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street].prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street].prop'), - - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street].prop'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street.prop'), - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street]'), - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'), - - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.street'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address.street.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address[street]'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.address[street].prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address].street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address][street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[address][street].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[street].prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].street.prop'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street]'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][street].prop'), - - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address.street'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address.street.prop'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address[street]'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data.address[street].prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address].street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address].street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address][street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', '[street]', 'data[address][street].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'), - array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'), - array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address.street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address[street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data.address[street].prop'), - array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].street'), - array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address].street.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address][street]'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', 'street', 'data[address][street].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo.street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.foo[street].prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo].street.prop'), - array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street]'), - array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[foo][street].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address.street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data.address[street].prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street'), - array(self::LEVEL_1, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address].street.prop'), - array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street]'), - array(self::LEVEL_2, '[foo]', 'address', 'address', '[address]', 'street', '[street]', 'data[address][street].prop'), - - array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'), - array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), - - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), - array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'), - array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), - - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), - array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'), - array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), - - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar]'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), - array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar]'), - array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), - - array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'), - array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'), - array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'), - array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'), - - array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'), - array(self::LEVEL_1, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'), - array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'), - array(self::LEVEL_2, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'), - array(self::LEVEL_0, 'foo.bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'), - - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'), - array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'), - array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'), - array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'), - array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'), - - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'), - array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'), - array(self::LEVEL_1, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'), - array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'), - array(self::LEVEL_2, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'), - array(self::LEVEL_0, 'foo[bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'), - - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'), - array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'), - array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'), - array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'), - array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'), - - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'), - array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'), - array(self::LEVEL_1, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'), - array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'), - array(self::LEVEL_2, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'), - array(self::LEVEL_0, '[foo].bar', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'), - - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar.street.prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street]'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo.bar[street].prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar].street.prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street]'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data.foo[bar][street].prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar.street.prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street]'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo].bar[street].prop'), - array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street'), - array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar].street.prop'), - array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street]'), - array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', 'street', 'data[foo][bar][street].prop'), - - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar.street.prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street]'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo.bar[street].prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar].street.prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street]'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data.foo[bar][street].prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar.street.prop'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street]'), - array(self::LEVEL_0, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo].bar[street].prop'), - array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street'), - array(self::LEVEL_1, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar].street.prop'), - array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street]'), - array(self::LEVEL_2, '[foo][bar]', 'address', 'address', 'address', 'street', '[street]', 'data[foo][bar][street].prop'), - - array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', 'street', 'data.foo'), - array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.prop'), - array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo]'), - array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].prop'), - - array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo'), - array(self::LEVEL_2, 'foo', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.prop'), - array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo]'), - array(self::LEVEL_2, '[foo]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].prop'), - - array(self::LEVEL_2, 'foo', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo'), - array(self::LEVEL_2, 'foo', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.prop'), - array(self::LEVEL_2, '[foo]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo]'), - array(self::LEVEL_2, '[foo]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].prop'), - - array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.bar'), - array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', 'street', 'data.foo.bar.prop'), - array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', 'street', 'data.foo[bar]'), - array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', 'street', 'data.foo[bar].prop'), - array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].bar'), - array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', 'street', 'data[foo].bar.prop'), - array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo][bar]'), - array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', 'street', 'data[foo][bar].prop'), - - array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.bar'), - array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo.bar.prop'), - array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo[bar]'), - array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data.foo[bar].prop'), - array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].bar'), - array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo].bar.prop'), - array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo][bar]'), - array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', 'address', 'street', '[street]', 'data[foo][bar].prop'), - - array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.bar'), - array(self::LEVEL_2, 'foo.bar', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo.bar.prop'), - array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo[bar]'), - array(self::LEVEL_2, 'foo[bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data.foo[bar].prop'), - array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].bar'), - array(self::LEVEL_2, '[foo].bar', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo].bar.prop'), - array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo][bar]'), - array(self::LEVEL_2, '[foo][bar]', 'address.street', 'address', '[address]', 'street', 'street', 'data[foo][bar].prop'), - - // Edge cases - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street'), - array(self::LEVEL_2, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo.street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street]'), - array(self::LEVEL_1, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data.foo[street].prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo].street.prop'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street]'), - array(self::LEVEL_0, 'foo', 'address', 'address', '[address]', 'street', 'street', 'data[foo][street].prop'), - - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo.street.prop'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street]'), - array(self::LEVEL_0, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data.foo[street].prop'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street'), - array(self::LEVEL_2, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo].street.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street]'), - array(self::LEVEL_1, '[foo]', 'address', 'address', 'address', 'street', 'street', 'data[foo][street].prop'), - ); - } - - /** - * @dataProvider provideCustomDataErrorTests - */ - public function testCustomDataErrorMapping($target, $mapFrom, $mapTo, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath) - { - $violation = $this->getConstraintViolation($violationPath); - $parent = $this->getForm('parent', null, null, array($mapFrom => $mapTo)); - $child = $this->getForm($childName, $childPath); - $grandChild = $this->getForm($grandChildName, $grandChildPath); - - $parent->add($child); - $child->add($grandChild); - - // Add a field mapped to the first element of $mapFrom - // to try to distract the algorithm - // Only add it if we expect the error to come up on a different - // level than LEVEL_0, because in this case the error would - // (correctly) be mapped to the distraction field - if ($target !== self::LEVEL_0) { - $mapFromPath = new PropertyPath($mapFrom); - $mapFromPrefix = $mapFromPath->isIndex(0) - ? '['.$mapFromPath->getElement(0).']' - : $mapFromPath->getElement(0); - $distraction = $this->getForm('distraction', $mapFromPrefix); - - $parent->add($distraction); - } - - $parent->submit(array()); - - $this->mapper->mapViolation($violation, $parent); - - if ($target !== self::LEVEL_0) { - $this->assertCount(0, $distraction->getErrors(), 'distraction should not have an error, but has one'); - } - - if (self::LEVEL_0 === $target) { - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($parent->getErrors()), $parent->getName().' should have an error, but has none'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } elseif (self::LEVEL_1 === $target) { - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($child->getErrors()), $childName.' should have an error, but has none'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } else { - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($grandChild->getErrors()), $grandChildName.' should have an error, but has none'); - } - } - - public function provideCustomFormErrorTests() - { - // This case is different than the data errors, because here the - // left side of the mapping refers to the property path of the actual - // children. In other words, a child error only works if - // 1) the error actually maps to an existing child and - // 2) the property path of that child (relative to the form providing - // the mapping) matches the left side of the mapping - return array( - // mapping target, map from, map to, child name, its property path, grand child name, its property path, violation path - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street]'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street].prop'), - - // Property path of the erroneous field and mapping must match exactly - array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), - array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'), - array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street'), - array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'), - array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street]'), - array(self::LEVEL_1B, 'foo', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'), - - array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), - array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'), - array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street'), - array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'), - array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street]'), - array(self::LEVEL_1B, '[foo]', 'address', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'), - - array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data'), - array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].children[street].data.prop'), - array(self::LEVEL_2, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street'), - array(self::LEVEL_2, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data.street.prop'), - array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street]'), - array(self::LEVEL_1, '[foo]', 'address', 'foo', '[foo]', 'address', 'address', 'street', 'street', 'children[foo].data[street].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].children[street].data'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].children[street].data.prop'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data.street'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data.street.prop'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data[street]'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo].data[street].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street.prop'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street].prop'), - - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].children[street].data'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].children[street].data.prop'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data.street'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data.street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data[street]'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo].data[street].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].children[street].data'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].children[street].data.prop'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data.street'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data.street.prop'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data[street]'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo].data[street].prop'), - - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street].data'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street].data.prop'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street.prop'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'foo', 'address', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street].prop'), - - // Map to a nested child - array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[foo]'), - array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[foo]'), - array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[foo]'), - array(self::LEVEL_2, 'foo', 'address.street', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[foo]'), - - // Map from a nested child - array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'), - array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'), - array(self::LEVEL_1B, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'), - array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'), - array(self::LEVEL_1, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_2, 'address.street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), - - array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'), - array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'), - array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1B, 'address[street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'), - array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'), - array(self::LEVEL_1, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_2, 'address[street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), - - array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'), - array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'), - array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'), - array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_1, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'), - array(self::LEVEL_1B, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_2, '[address].street', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), - - array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].children[street]'), - array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].children[street]'), - array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', 'address', 'street', '[street]', 'children[address].data[street]'), - array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].children[street]'), - array(self::LEVEL_2, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].children[street]'), - array(self::LEVEL_1, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data.street'), - array(self::LEVEL_1B, '[address][street]', 'foo', 'foo', 'foo', 'address', '[address]', 'street', '[street]', 'children[address].data[street]'), - ); - } - - /** - * @dataProvider provideCustomFormErrorTests - */ - public function testCustomFormErrorMapping($target, $mapFrom, $mapTo, $errorName, $errorPath, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath) - { - $violation = $this->getConstraintViolation($violationPath); - $parent = $this->getForm('parent', null, null, array($mapFrom => $mapTo)); - $child = $this->getForm($childName, $childPath); - $grandChild = $this->getForm($grandChildName, $grandChildPath); - $errorChild = $this->getForm($errorName, $errorPath); - - $parent->add($child); - $parent->add($errorChild); - $child->add($grandChild); - - $parent->submit(array()); - - $this->mapper->mapViolation($violation, $parent); - - if (self::LEVEL_0 === $target) { - $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($parent->getErrors()), $parent->getName().' should have an error, but has none'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } elseif (self::LEVEL_1 === $target) { - $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one'); - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($child->getErrors()), $childName.' should have an error, but has none'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } elseif (self::LEVEL_1B === $target) { - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($errorChild->getErrors()), $errorName.' should have an error, but has none'); - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } else { - $this->assertCount(0, $errorChild->getErrors(), $errorName.' should not have an error, but has one'); - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($grandChild->getErrors()), $grandChildName.' should have an error, but has none'); - } - } - - public function provideErrorTestsForFormInheritingParentData() - { - return array( - // mapping target, child name, its property path, grand child name, its property path, violation path - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].children[street].data.prop'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'children[address].data.street.prop'), - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street]'), - array(self::LEVEL_1, 'address', 'address', 'street', 'street', 'children[address].data[street].prop'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.street'), - array(self::LEVEL_2, 'address', 'address', 'street', 'street', 'data.street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[street]'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address.street'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address.street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address[street]'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data.address[street].prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address].street.prop'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street]'), - array(self::LEVEL_0, 'address', 'address', 'street', 'street', 'data[address][street].prop'), - ); - } - - /** - * @dataProvider provideErrorTestsForFormInheritingParentData - */ - public function testErrorMappingForFormInheritingParentData($target, $childName, $childPath, $grandChildName, $grandChildPath, $violationPath) - { - $violation = $this->getConstraintViolation($violationPath); - $parent = $this->getForm('parent'); - $child = $this->getForm($childName, $childPath, null, array(), true); - $grandChild = $this->getForm($grandChildName, $grandChildPath); - - $parent->add($child); - $child->add($grandChild); - - $parent->submit(array()); - - $this->mapper->mapViolation($violation, $parent); - - if (self::LEVEL_0 === $target) { - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($parent->getErrors()), $parent->getName().' should have an error, but has none'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } elseif (self::LEVEL_1 === $target) { - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($child->getErrors()), $childName.' should have an error, but has none'); - $this->assertCount(0, $grandChild->getErrors(), $grandChildName.' should not have an error, but has one'); - } else { - $this->assertCount(0, $parent->getErrors(), $parent->getName().' should not have an error, but has one'); - $this->assertCount(0, $child->getErrors(), $childName.' should not have an error, but has one'); - $this->assertEquals(array($this->getFormError($violation)), iterator_to_array($grandChild->getErrors()), $grandChildName.' should have an error, but has none'); - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php deleted file mode 100644 index fdbf747f2..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Extension/Validator/ViolationMapper/ViolationPathTest.php +++ /dev/null @@ -1,246 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Extension\Validator\ViolationMapper; - -use Symfony\Component\Form\Extension\Validator\ViolationMapper\ViolationPath; - -/** - * @author Bernhard Schussek - */ -class ViolationPathTest extends \PHPUnit_Framework_TestCase -{ - public function providePaths() - { - return array( - array('children[address]', array( - array('address', true, true), - )), - array('children[address].children[street]', array( - array('address', true, true), - array('street', true, true), - )), - array('children[address][street]', array( - array('address', true, true), - array('street', true, true), - ), 'children[address].children[street]'), - array('children[address].data', array( - array('address', true, true), - ), 'children[address]'), - array('children[address].data.street', array( - array('address', true, true), - array('street', false, false), - )), - array('children[address].data[street]', array( - array('address', true, true), - array('street', false, true), - )), - array('children[address].children[street].data.name', array( - array('address', true, true), - array('street', true, true), - array('name', false, false), - )), - array('children[address].children[street].data[name]', array( - array('address', true, true), - array('street', true, true), - array('name', false, true), - )), - array('data.address', array( - array('address', false, false), - )), - array('data[address]', array( - array('address', false, true), - )), - array('data.address.street', array( - array('address', false, false), - array('street', false, false), - )), - array('data[address].street', array( - array('address', false, true), - array('street', false, false), - )), - array('data.address[street]', array( - array('address', false, false), - array('street', false, true), - )), - array('data[address][street]', array( - array('address', false, true), - array('street', false, true), - )), - // A few invalid examples - array('data', array(), ''), - array('children', array(), ''), - array('children.address', array(), ''), - array('children.address[street]', array(), ''), - ); - } - - /** - * @dataProvider providePaths - */ - public function testCreatePath($string, $entries, $slicedPath = null) - { - if (null === $slicedPath) { - $slicedPath = $string; - } - - $path = new ViolationPath($string); - - $this->assertSame($slicedPath, $path->__toString()); - $this->assertSame(count($entries), count($path->getElements())); - $this->assertSame(count($entries), $path->getLength()); - - foreach ($entries as $index => $entry) { - $this->assertEquals($entry[0], $path->getElement($index)); - $this->assertSame($entry[1], $path->mapsForm($index)); - $this->assertSame($entry[2], $path->isIndex($index)); - $this->assertSame(!$entry[2], $path->isProperty($index)); - } - } - - public function provideParents() - { - return array( - array('children[address]', null), - array('children[address].children[street]', 'children[address]'), - array('children[address].data.street', 'children[address]'), - array('children[address].data[street]', 'children[address]'), - array('data.address', null), - array('data.address.street', 'data.address'), - array('data.address[street]', 'data.address'), - array('data[address].street', 'data[address]'), - array('data[address][street]', 'data[address]'), - ); - } - - /** - * @dataProvider provideParents - */ - public function testGetParent($violationPath, $parentPath) - { - $path = new ViolationPath($violationPath); - $parent = null === $parentPath ? null : new ViolationPath($parentPath); - - $this->assertEquals($parent, $path->getParent()); - } - - public function testGetElement() - { - $path = new ViolationPath('children[address].data[street].name'); - - $this->assertEquals('street', $path->getElement(1)); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testGetElementDoesNotAcceptInvalidIndices() - { - $path = new ViolationPath('children[address].data[street].name'); - - $path->getElement(3); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testGetElementDoesNotAcceptNegativeIndices() - { - $path = new ViolationPath('children[address].data[street].name'); - - $path->getElement(-1); - } - - public function testIsProperty() - { - $path = new ViolationPath('children[address].data[street].name'); - - $this->assertFalse($path->isProperty(1)); - $this->assertTrue($path->isProperty(2)); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testIsPropertyDoesNotAcceptInvalidIndices() - { - $path = new ViolationPath('children[address].data[street].name'); - - $path->isProperty(3); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testIsPropertyDoesNotAcceptNegativeIndices() - { - $path = new ViolationPath('children[address].data[street].name'); - - $path->isProperty(-1); - } - - public function testIsIndex() - { - $path = new ViolationPath('children[address].data[street].name'); - - $this->assertTrue($path->isIndex(1)); - $this->assertFalse($path->isIndex(2)); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testIsIndexDoesNotAcceptInvalidIndices() - { - $path = new ViolationPath('children[address].data[street].name'); - - $path->isIndex(3); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testIsIndexDoesNotAcceptNegativeIndices() - { - $path = new ViolationPath('children[address].data[street].name'); - - $path->isIndex(-1); - } - - public function testMapsForm() - { - $path = new ViolationPath('children[address].data[street].name'); - - $this->assertTrue($path->mapsForm(0)); - $this->assertFalse($path->mapsForm(1)); - $this->assertFalse($path->mapsForm(2)); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testMapsFormDoesNotAcceptInvalidIndices() - { - $path = new ViolationPath('children[address].data[street].name'); - - $path->mapsForm(3); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testMapsFormDoesNotAcceptNegativeIndices() - { - $path = new ViolationPath('children[address].data[street].name'); - - $path->mapsForm(-1); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AbstractAuthor.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AbstractAuthor.php deleted file mode 100644 index 03a6b724f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AbstractAuthor.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -abstract class AbstractAuthor -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php deleted file mode 100644 index ee7d13533..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AlternatingRowType.php +++ /dev/null @@ -1,27 +0,0 @@ -getFormFactory(); - - $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($formFactory) { - $form = $event->getForm(); - $type = $form->getName() % 2 === 0 ? 'text' : 'textarea'; - $form->add('title', $type); - }); - } - - public function getName() - { - return 'alternating_row'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php deleted file mode 100644 index 39765d9df..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/Author.php +++ /dev/null @@ -1,77 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -class Author -{ - public $firstName; - private $lastName; - private $australian; - public $child; - private $readPermissions; - - private $privateProperty; - - public function __construct($firstName = null, $lastName = null) - { - $this->firstName = $firstName; - $this->lastName = $lastName; - } - - public function setLastName($lastName) - { - $this->lastName = $lastName; - } - - public function getLastName() - { - return $this->lastName; - } - - private function getPrivateGetter() - { - return 'foobar'; - } - - public function setAustralian($australian) - { - $this->australian = $australian; - } - - public function isAustralian() - { - return $this->australian; - } - - public function setReadPermissions($bool) - { - $this->readPermissions = $bool; - } - - public function hasReadPermissions() - { - return $this->readPermissions; - } - - private function isPrivateIsser() - { - return true; - } - - public function getPrivateSetter() - { - } - - private function setPrivateSetter($data) - { - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorInterface.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorInterface.php deleted file mode 100644 index 984cb541e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorInterface.php +++ /dev/null @@ -1,16 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -interface AuthorInterface -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php deleted file mode 100644 index 147f6e486..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/AuthorType.php +++ /dev/null @@ -1,30 +0,0 @@ -add('firstName') - ->add('lastName') - ; - } - - public function getName() - { - return 'author'; - } - - public function setDefaultOptions(OptionsResolverInterface $resolver) - { - $resolver->setDefaults(array( - 'data_class' => 'Symfony\Component\Form\Tests\Fixtures\Author', - )); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php deleted file mode 100644 index 950f677fd..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/CustomArrayObject.php +++ /dev/null @@ -1,70 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -/** - * This class is a hand written simplified version of PHP native `ArrayObject` - * class, to show that it behaves differently than the PHP native implementation. - */ -class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable -{ - private $array; - - public function __construct(array $array = null) - { - $this->array = $array ?: array(); - } - - public function offsetExists($offset) - { - return array_key_exists($offset, $this->array); - } - - public function offsetGet($offset) - { - return $this->array[$offset]; - } - - public function offsetSet($offset, $value) - { - if (null === $offset) { - $this->array[] = $value; - } else { - $this->array[$offset] = $value; - } - } - - public function offsetUnset($offset) - { - unset($this->array[$offset]); - } - - public function getIterator() - { - return new \ArrayIterator($this->array); - } - - public function count() - { - return count($this->array); - } - - public function serialize() - { - return serialize($this->array); - } - - public function unserialize($serialized) - { - $this->array = (array) unserialize((string) $serialized); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php deleted file mode 100644 index f7fba56c4..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedDataTransformer.php +++ /dev/null @@ -1,45 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\DataTransformerInterface; -use Symfony\Component\Form\Exception\TransformationFailedException; - -class FixedDataTransformer implements DataTransformerInterface -{ - private $mapping; - - public function __construct(array $mapping) - { - $this->mapping = $mapping; - } - - public function transform($value) - { - if (!array_key_exists($value, $this->mapping)) { - throw new TransformationFailedException(sprintf('No mapping for value "%s"', $value)); - } - - return $this->mapping[$value]; - } - - public function reverseTransform($value) - { - $result = array_search($value, $this->mapping, true); - - if ($result === false) { - throw new TransformationFailedException(sprintf('No reverse mapping for value "%s"', $value)); - } - - return $result; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php deleted file mode 100644 index 762a10b8c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FixedFilterListener.php +++ /dev/null @@ -1,66 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\FormEvents; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\EventDispatcher\EventSubscriberInterface; - -class FixedFilterListener implements EventSubscriberInterface -{ - private $mapping; - - public function __construct(array $mapping) - { - $this->mapping = array_merge(array( - 'preSubmit' => array(), - 'onSubmit' => array(), - 'preSetData' => array(), - ), $mapping); - } - - public function preSubmit(FormEvent $event) - { - $data = $event->getData(); - - if (isset($this->mapping['preSubmit'][$data])) { - $event->setData($this->mapping['preSubmit'][$data]); - } - } - - public function onSubmit(FormEvent $event) - { - $data = $event->getData(); - - if (isset($this->mapping['onSubmit'][$data])) { - $event->setData($this->mapping['onSubmit'][$data]); - } - } - - public function preSetData(FormEvent $event) - { - $data = $event->getData(); - - if (isset($this->mapping['preSetData'][$data])) { - $event->setData($this->mapping['preSetData'][$data]); - } - } - - public static function getSubscribedEvents() - { - return array( - FormEvents::PRE_SUBMIT => 'preSubmit', - FormEvents::SUBMIT => 'onSubmit', - FormEvents::PRE_SET_DATA => 'preSetData', - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php deleted file mode 100644 index 52cefb44c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubType.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\AbstractType; - -class FooSubType extends AbstractType -{ - public function getName() - { - return 'foo_sub_type'; - } - - public function getParent() - { - return 'foo'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php deleted file mode 100644 index 9416d7b4e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooSubTypeWithParentInstance.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\AbstractType; - -class FooSubTypeWithParentInstance extends AbstractType -{ - public function getName() - { - return 'foo_sub_type_parent_instance'; - } - - public function getParent() - { - return new FooType(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php deleted file mode 100644 index bc1911079..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooType.php +++ /dev/null @@ -1,26 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\AbstractType; - -class FooType extends AbstractType -{ - public function getName() - { - return 'foo'; - } - - public function getParent() - { - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php deleted file mode 100644 index c5f92e119..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBarExtension.php +++ /dev/null @@ -1,35 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\FormBuilderInterface; - -class FooTypeBarExtension extends AbstractTypeExtension -{ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->setAttribute('bar', 'x'); - } - - public function getAllowedOptionValues() - { - return array( - 'a_or_b' => array('c'), - ); - } - - public function getExtendedType() - { - return 'foo'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php deleted file mode 100644 index 2e3647544..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/FooTypeBazExtension.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\AbstractTypeExtension; -use Symfony\Component\Form\FormBuilderInterface; - -class FooTypeBazExtension extends AbstractTypeExtension -{ - public function buildForm(FormBuilderInterface $builder, array $options) - { - $builder->setAttribute('baz', 'x'); - } - - public function getExtendedType() - { - return 'foo'; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php deleted file mode 100644 index f9de560f0..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/TestExtension.php +++ /dev/null @@ -1,72 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Fixtures; - -use Symfony\Component\Form\FormTypeInterface; -use Symfony\Component\Form\FormTypeExtensionInterface; -use Symfony\Component\Form\FormTypeGuesserInterface; -use Symfony\Component\Form\FormExtensionInterface; - -class TestExtension implements FormExtensionInterface -{ - private $types = array(); - - private $extensions = array(); - - private $guesser; - - public function __construct(FormTypeGuesserInterface $guesser) - { - $this->guesser = $guesser; - } - - public function addType(FormTypeInterface $type) - { - $this->types[$type->getName()] = $type; - } - - public function getType($name) - { - return isset($this->types[$name]) ? $this->types[$name] : null; - } - - public function hasType($name) - { - return isset($this->types[$name]); - } - - public function addTypeExtension(FormTypeExtensionInterface $extension) - { - $type = $extension->getExtendedType(); - - if (!isset($this->extensions[$type])) { - $this->extensions[$type] = array(); - } - - $this->extensions[$type][] = $extension; - } - - public function getTypeExtensions($name) - { - return isset($this->extensions[$name]) ? $this->extensions[$name] : array(); - } - - public function hasTypeExtensions($name) - { - return isset($this->extensions[$name]); - } - - public function getTypeGuesser() - { - return $this->guesser; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo2 b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo2 deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo3 b/vendor/symfony/form/Symfony/Component/Form/Tests/Fixtures/foo3 deleted file mode 100644 index e69de29bb..000000000 diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormBuilderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormBuilderTest.php deleted file mode 100644 index da691838c..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormBuilderTest.php +++ /dev/null @@ -1,226 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormBuilder; - -class FormBuilderTest extends \PHPUnit_Framework_TestCase -{ - private $dispatcher; - private $factory; - private $builder; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); - } - - protected function tearDown() - { - $this->dispatcher = null; - $this->factory = null; - $this->builder = null; - } - - /** - * Changing the name is not allowed, otherwise the name and property path - * are not synchronized anymore. - * - * @see FormType::buildForm() - */ - public function testNoSetName() - { - $this->assertFalse(method_exists($this->builder, 'setName')); - } - - public function testAddNameNoStringAndNoInteger() - { - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); - $this->builder->add(true); - } - - public function testAddTypeNoString() - { - $this->setExpectedException('Symfony\Component\Form\Exception\UnexpectedTypeException'); - $this->builder->add('foo', 1234); - } - - public function testAddWithGuessFluent() - { - $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); - $builder = $this->builder->add('foo'); - $this->assertSame($builder, $this->builder); - } - - public function testAddIsFluent() - { - $builder = $this->builder->add('foo', 'text', array('bar' => 'baz')); - $this->assertSame($builder, $this->builder); - } - - public function testAdd() - { - $this->assertFalse($this->builder->has('foo')); - $this->builder->add('foo', 'text'); - $this->assertTrue($this->builder->has('foo')); - } - - public function testAddIntegerName() - { - $this->assertFalse($this->builder->has(0)); - $this->builder->add(0, 'text'); - $this->assertTrue($this->builder->has(0)); - } - - public function testAll() - { - $this->factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('foo', 'text') - ->will($this->returnValue(new FormBuilder('foo', null, $this->dispatcher, $this->factory))); - - $this->assertCount(0, $this->builder->all()); - $this->assertFalse($this->builder->has('foo')); - - $this->builder->add('foo', 'text'); - $children = $this->builder->all(); - - $this->assertTrue($this->builder->has('foo')); - $this->assertCount(1, $children); - $this->assertArrayHasKey('foo', $children); - } - - /* - * https://github.com/symfony/symfony/issues/4693 - */ - public function testMaintainOrderOfLazyAndExplicitChildren() - { - $this->builder->add('foo', 'text'); - $this->builder->add($this->getFormBuilder('bar')); - $this->builder->add('baz', 'text'); - - $children = $this->builder->all(); - - $this->assertSame(array('foo', 'bar', 'baz'), array_keys($children)); - } - - public function testAddFormType() - { - $this->assertFalse($this->builder->has('foo')); - $this->builder->add('foo', $this->getMock('Symfony\Component\Form\FormTypeInterface')); - $this->assertTrue($this->builder->has('foo')); - } - - public function testRemove() - { - $this->builder->add('foo', 'text'); - $this->builder->remove('foo'); - $this->assertFalse($this->builder->has('foo')); - } - - public function testRemoveUnknown() - { - $this->builder->remove('foo'); - $this->assertFalse($this->builder->has('foo')); - } - - // https://github.com/symfony/symfony/pull/4826 - public function testRemoveAndGetForm() - { - $this->builder->add('foo', 'text'); - $this->builder->remove('foo'); - $form = $this->builder->getForm(); - $this->assertInstanceOf('Symfony\Component\Form\Form', $form); - } - - public function testCreateNoTypeNo() - { - $this->factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('foo', 'text', null, array()) - ; - - $this->builder->create('foo'); - } - - public function testGetUnknown() - { - $this->setExpectedException('Symfony\Component\Form\Exception\InvalidArgumentException', 'The child with the name "foo" does not exist.'); - $this->builder->get('foo'); - } - - public function testGetExplicitType() - { - $expectedType = 'text'; - $expectedName = 'foo'; - $expectedOptions = array('bar' => 'baz'); - - $this->factory->expects($this->once()) - ->method('createNamedBuilder') - ->with($expectedName, $expectedType, null, $expectedOptions) - ->will($this->returnValue($this->getFormBuilder())); - - $this->builder->add($expectedName, $expectedType, $expectedOptions); - $builder = $this->builder->get($expectedName); - - $this->assertNotSame($builder, $this->builder); - } - - public function testGetGuessedType() - { - $expectedName = 'foo'; - $expectedOptions = array('bar' => 'baz'); - - $this->factory->expects($this->once()) - ->method('createBuilderForProperty') - ->with('stdClass', $expectedName, null, $expectedOptions) - ->will($this->returnValue($this->getFormBuilder())); - - $this->builder = new FormBuilder('name', 'stdClass', $this->dispatcher, $this->factory); - $this->builder->add($expectedName, null, $expectedOptions); - $builder = $this->builder->get($expectedName); - - $this->assertNotSame($builder, $this->builder); - } - - public function testGetFormConfigErasesReferences() - { - $builder = new FormBuilder('name', null, $this->dispatcher, $this->factory); - $builder->add(new FormBuilder('child', null, $this->dispatcher, $this->factory)); - - $config = $builder->getFormConfig(); - $reflClass = new \ReflectionClass($config); - $children = $reflClass->getProperty('children'); - $unresolvedChildren = $reflClass->getProperty('unresolvedChildren'); - - $children->setAccessible(true); - $unresolvedChildren->setAccessible(true); - - $this->assertEmpty($children->getValue($config)); - $this->assertEmpty($unresolvedChildren->getValue($config)); - } - - private function getFormBuilder($name = 'name') - { - $mock = $this->getMockBuilder('Symfony\Component\Form\FormBuilder') - ->disableOriginalConstructor() - ->getMock(); - - $mock->expects($this->any()) - ->method('getName') - ->will($this->returnValue($name)); - - return $mock; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormConfigTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormConfigTest.php deleted file mode 100644 index b77632c50..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormConfigTest.php +++ /dev/null @@ -1,148 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\Exception\UnexpectedTypeException; -use Symfony\Component\Form\FormConfigBuilder; -use Symfony\Component\Form\Exception\InvalidArgumentException; - -/** - * @author Bernhard Schussek - */ -class FormConfigTest extends \PHPUnit_Framework_TestCase -{ - public function getHtml4Ids() - { - return array( - array('z0', true), - array('A0', true), - array('A9', true), - array('Z0', true), - array('#', false), - array('a#', false), - array('a$', false), - array('a%', false), - array('a ', false), - array("a\t", false), - array("a\n", false), - array('a-', true), - array('a_', true), - array('a:', true), - // Periods are allowed by the HTML4 spec, but disallowed by us - // because they break the generated property paths - array('a.', false), - // Contrary to the HTML4 spec, we allow names starting with a - // number, otherwise naming fields by collection indices is not - // possible. - // For root forms, leading digits will be stripped from the - // "id" attribute to produce valid HTML4. - array('0', true), - array('9', true), - // Contrary to the HTML4 spec, we allow names starting with an - // underscore, since this is already a widely used practice in - // Symfony. - // For root forms, leading underscores will be stripped from the - // "id" attribute to produce valid HTML4. - array('_', true), - // Integers are allowed - array(0, true), - array(123, true), - // NULL is allowed - array(null, true), - // Other types are not - array(1.23, false), - array(5., false), - array(true, false), - array(new \stdClass(), false), - ); - } - - /** - * @dataProvider getHtml4Ids - */ - public function testNameAcceptsOnlyNamesValidAsIdsInHtml4($name, $accepted) - { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - - try { - new FormConfigBuilder($name, null, $dispatcher); - if (!$accepted) { - $this->fail(sprintf('The value "%s" should not be accepted', $name)); - } - } catch (UnexpectedTypeException $e) { - // if the value was not accepted, but should be, rethrow exception - if ($accepted) { - throw $e; - } - } catch (InvalidArgumentException $e) { - // if the value was not accepted, but should be, rethrow exception - if ($accepted) { - throw $e; - } - } - } - - public function testGetRequestHandlerCreatesNativeRequestHandlerIfNotSet() - { - $config = $this->getConfigBuilder()->getFormConfig(); - - $this->assertInstanceOf('Symfony\Component\Form\NativeRequestHandler', $config->getRequestHandler()); - } - - public function testGetRequestHandlerReusesNativeRequestHandlerInstance() - { - $config1 = $this->getConfigBuilder()->getFormConfig(); - $config2 = $this->getConfigBuilder()->getFormConfig(); - - $this->assertSame($config1->getRequestHandler(), $config2->getRequestHandler()); - } - - public function testSetMethodAllowsGet() - { - $this->getConfigBuilder()->setMethod('GET'); - } - - public function testSetMethodAllowsPost() - { - $this->getConfigBuilder()->setMethod('POST'); - } - - public function testSetMethodAllowsPut() - { - $this->getConfigBuilder()->setMethod('PUT'); - } - - public function testSetMethodAllowsDelete() - { - $this->getConfigBuilder()->setMethod('DELETE'); - } - - public function testSetMethodAllowsPatch() - { - $this->getConfigBuilder()->setMethod('PATCH'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - */ - public function testSetMethodDoesNotAllowOtherValues() - { - $this->getConfigBuilder()->setMethod('foo'); - } - - private function getConfigBuilder($name = 'name') - { - $dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - - return new FormConfigBuilder($name, null, $dispatcher); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php deleted file mode 100644 index 2c3ab000f..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryBuilderTest.php +++ /dev/null @@ -1,59 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormFactoryBuilder; -use Symfony\Component\Form\Tests\Fixtures\FooType; - -class FormFactoryBuilderTest extends \PHPUnit_Framework_TestCase -{ - private $registry; - private $guesser; - private $type; - - protected function setUp() - { - $factory = new \ReflectionClass('Symfony\Component\Form\FormFactory'); - $this->registry = $factory->getProperty('registry'); - $this->registry->setAccessible(true); - - $this->guesser = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->type = new FooType(); - } - - public function testAddType() - { - $factoryBuilder = new FormFactoryBuilder(); - $factoryBuilder->addType($this->type); - - $factory = $factoryBuilder->getFormFactory(); - $registry = $this->registry->getValue($factory); - $extensions = $registry->getExtensions(); - - $this->assertCount(1, $extensions); - $this->assertTrue($extensions[0]->hasType($this->type->getName())); - $this->assertNull($extensions[0]->getTypeGuesser()); - } - - public function testAddTypeGuesser() - { - $factoryBuilder = new FormFactoryBuilder(); - $factoryBuilder->addTypeGuesser($this->guesser); - - $factory = $factoryBuilder->getFormFactory(); - $registry = $this->registry->getValue($factory); - $extensions = $registry->getExtensions(); - - $this->assertCount(1, $extensions); - $this->assertNotNull($extensions[0]->getTypeGuesser()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryTest.php deleted file mode 100644 index d89969f02..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormFactoryTest.php +++ /dev/null @@ -1,624 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormTypeGuesserChain; -use Symfony\Component\Form\FormFactory; -use Symfony\Component\Form\Guess\Guess; -use Symfony\Component\Form\Guess\ValueGuess; -use Symfony\Component\Form\Guess\TypeGuess; -use Symfony\Component\Form\Tests\Fixtures\FooType; -use Symfony\Component\Form\Tests\Fixtures\FooSubType; -use Symfony\Component\Form\Tests\Fixtures\FooSubTypeWithParentInstance; - -/** - * @author Bernhard Schussek - */ -class FormFactoryTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $guesser1; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $guesser2; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $registry; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $resolvedTypeFactory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $builder; - - /** - * @var FormFactory - */ - private $factory; - - protected function setUp() - { - $this->resolvedTypeFactory = $this->getMock('Symfony\Component\Form\ResolvedFormTypeFactoryInterface'); - $this->guesser1 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->guesser2 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->registry = $this->getMock('Symfony\Component\Form\FormRegistryInterface'); - $this->builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); - $this->factory = new FormFactory($this->registry, $this->resolvedTypeFactory); - - $this->registry->expects($this->any()) - ->method('getTypeGuesser') - ->will($this->returnValue(new FormTypeGuesserChain(array( - $this->guesser1, - $this->guesser2, - )))); - } - - public function testCreateNamedBuilderWithTypeName() - { - $options = array('a' => '1', 'b' => '2'); - $resolvedOptions = array('a' => '2', 'b' => '3'); - $resolvedType = $this->getMockResolvedType(); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('type') - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', 'type', null, $options)); - } - - public function testCreateNamedBuilderWithTypeInstance() - { - $options = array('a' => '1', 'b' => '2'); - $resolvedOptions = array('a' => '2', 'b' => '3'); - $type = new FooType(); - $resolvedType = $this->getMockResolvedType(); - - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type) - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', $type, null, $options)); - } - - public function testCreateNamedBuilderWithTypeInstanceWithParentType() - { - $options = array('a' => '1', 'b' => '2'); - $resolvedOptions = array('a' => '2', 'b' => '3'); - $type = new FooSubType(); - $resolvedType = $this->getMockResolvedType(); - $parentResolvedType = $this->getMockResolvedType(); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('foo') - ->will($this->returnValue($parentResolvedType)); - - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type, array(), $parentResolvedType) - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', $type, null, $options)); - } - - public function testCreateNamedBuilderWithTypeInstanceWithParentTypeInstance() - { - $options = array('a' => '1', 'b' => '2'); - $resolvedOptions = array('a' => '2', 'b' => '3'); - $type = new FooSubTypeWithParentInstance(); - $resolvedType = $this->getMockResolvedType(); - $parentResolvedType = $this->getMockResolvedType(); - - $this->resolvedTypeFactory->expects($this->at(0)) - ->method('createResolvedType') - ->with($type->getParent()) - ->will($this->returnValue($parentResolvedType)); - - $this->resolvedTypeFactory->expects($this->at(1)) - ->method('createResolvedType') - ->with($type, array(), $parentResolvedType) - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', $type, null, $options)); - } - - public function testCreateNamedBuilderWithResolvedTypeInstance() - { - $options = array('a' => '1', 'b' => '2'); - $resolvedOptions = array('a' => '2', 'b' => '3'); - $resolvedType = $this->getMockResolvedType(); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', $resolvedType, null, $options)); - } - - public function testCreateNamedBuilderFillsDataOption() - { - $givenOptions = array('a' => '1', 'b' => '2'); - $expectedOptions = array_merge($givenOptions, array('data' => 'DATA')); - $resolvedOptions = array('a' => '2', 'b' => '3', 'data' => 'DATA'); - $resolvedType = $this->getMockResolvedType(); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('type') - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $expectedOptions) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', 'type', 'DATA', $givenOptions)); - } - - public function testCreateNamedBuilderDoesNotOverrideExistingDataOption() - { - $options = array('a' => '1', 'b' => '2', 'data' => 'CUSTOM'); - $resolvedOptions = array('a' => '2', 'b' => '3', 'data' => 'CUSTOM'); - $resolvedType = $this->getMockResolvedType(); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('type') - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->assertSame($this->builder, $this->factory->createNamedBuilder('name', 'type', 'DATA', $options)); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - * @expectedExceptionMessage Expected argument of type "string, Symfony\Component\Form\ResolvedFormTypeInterface or Symfony\Component\Form\FormTypeInterface", "stdClass" given - */ - public function testCreateNamedBuilderThrowsUnderstandableException() - { - $this->factory->createNamedBuilder('name', new \stdClass()); - } - - public function testCreateUsesTypeNameIfTypeGivenAsString() - { - $options = array('a' => '1', 'b' => '2'); - $resolvedOptions = array('a' => '2', 'b' => '3'); - $resolvedType = $this->getMockResolvedType(); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('TYPE') - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'TYPE', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->builder->expects($this->once()) - ->method('getForm') - ->will($this->returnValue('FORM')); - - $this->assertSame('FORM', $this->factory->create('TYPE', null, $options)); - } - - public function testCreateUsesTypeNameIfTypeGivenAsObject() - { - $options = array('a' => '1', 'b' => '2'); - $resolvedOptions = array('a' => '2', 'b' => '3'); - $resolvedType = $this->getMockResolvedType(); - - $resolvedType->expects($this->once()) - ->method('getName') - ->will($this->returnValue('TYPE')); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'TYPE', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->builder->expects($this->once()) - ->method('getForm') - ->will($this->returnValue('FORM')); - - $this->assertSame('FORM', $this->factory->create($resolvedType, null, $options)); - } - - public function testCreateNamed() - { - $options = array('a' => '1', 'b' => '2'); - $resolvedOptions = array('a' => '2', 'b' => '3'); - $resolvedType = $this->getMockResolvedType(); - - $this->registry->expects($this->once()) - ->method('getType') - ->with('type') - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->once()) - ->method('createBuilder') - ->with($this->factory, 'name', $options) - ->will($this->returnValue($this->builder)); - - $this->builder->expects($this->any()) - ->method('getOptions') - ->will($this->returnValue($resolvedOptions)); - - $resolvedType->expects($this->once()) - ->method('buildForm') - ->with($this->builder, $resolvedOptions); - - $this->builder->expects($this->once()) - ->method('getForm') - ->will($this->returnValue('FORM')); - - $this->assertSame('FORM', $this->factory->createNamed('name', 'type', null, $options)); - } - - public function testCreateBuilderForPropertyWithoutTypeGuesser() - { - $registry = $this->getMock('Symfony\Component\Form\FormRegistryInterface'); - $factory = $this->getMockBuilder('Symfony\Component\Form\FormFactory') - ->setMethods(array('createNamedBuilder')) - ->setConstructorArgs(array($registry, $this->resolvedTypeFactory)) - ->getMock(); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'text', null, array()) - ->will($this->returnValue('builderInstance')); - - $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); - - $this->assertEquals('builderInstance', $this->builder); - } - - public function testCreateBuilderForPropertyCreatesFormWithHighestConfidence() - { - $this->guesser1->expects($this->once()) - ->method('guessType') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( - 'text', - array('attr' => array('maxlength' => 10)), - Guess::MEDIUM_CONFIDENCE - ))); - - $this->guesser2->expects($this->once()) - ->method('guessType') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( - 'password', - array('attr' => array('maxlength' => 7)), - Guess::HIGH_CONFIDENCE - ))); - - $factory = $this->getMockFactory(array('createNamedBuilder')); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'password', null, array('attr' => array('maxlength' => 7))) - ->will($this->returnValue('builderInstance')); - - $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); - - $this->assertEquals('builderInstance', $this->builder); - } - - public function testCreateBuilderCreatesTextFormIfNoGuess() - { - $this->guesser1->expects($this->once()) - ->method('guessType') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(null)); - - $factory = $this->getMockFactory(array('createNamedBuilder')); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'text') - ->will($this->returnValue('builderInstance')); - - $this->builder = $factory->createBuilderForProperty('Application\Author', 'firstName'); - - $this->assertEquals('builderInstance', $this->builder); - } - - public function testOptionsCanBeOverridden() - { - $this->guesser1->expects($this->once()) - ->method('guessType') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new TypeGuess( - 'text', - array('attr' => array('maxlength' => 10)), - Guess::MEDIUM_CONFIDENCE - ))); - - $factory = $this->getMockFactory(array('createNamedBuilder')); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('attr' => array('maxlength' => 11))) - ->will($this->returnValue('builderInstance')); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName', - null, - array('attr' => array('maxlength' => 11)) - ); - - $this->assertEquals('builderInstance', $this->builder); - } - - public function testCreateBuilderUsesMaxLengthIfFound() - { - $this->guesser1->expects($this->once()) - ->method('guessMaxLength') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( - 15, - Guess::MEDIUM_CONFIDENCE - ))); - - $this->guesser2->expects($this->once()) - ->method('guessMaxLength') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( - 20, - Guess::HIGH_CONFIDENCE - ))); - - $factory = $this->getMockFactory(array('createNamedBuilder')); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('attr' => array('maxlength' => 20))) - ->will($this->returnValue('builderInstance')); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName' - ); - - $this->assertEquals('builderInstance', $this->builder); - } - - public function testCreateBuilderUsesMaxLengthAndPattern() - { - $this->guesser1->expects($this->once()) - ->method('guessMaxLength') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( - 20, - Guess::HIGH_CONFIDENCE - ))); - - $this->guesser2->expects($this->once()) - ->method('guessPattern') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( - '.{5,}', - Guess::HIGH_CONFIDENCE - ))); - - $factory = $this->getMockFactory(array('createNamedBuilder')); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('attr' => array('maxlength' => 20, 'pattern' => '.{5,}', 'class' => 'tinymce'))) - ->will($this->returnValue('builderInstance')); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName', - null, - array('attr' => array('class' => 'tinymce')) - ); - - $this->assertEquals('builderInstance', $this->builder); - } - - public function testCreateBuilderUsesRequiredSettingWithHighestConfidence() - { - $this->guesser1->expects($this->once()) - ->method('guessRequired') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( - true, - Guess::MEDIUM_CONFIDENCE - ))); - - $this->guesser2->expects($this->once()) - ->method('guessRequired') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( - false, - Guess::HIGH_CONFIDENCE - ))); - - $factory = $this->getMockFactory(array('createNamedBuilder')); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('required' => false)) - ->will($this->returnValue('builderInstance')); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName' - ); - - $this->assertEquals('builderInstance', $this->builder); - } - - public function testCreateBuilderUsesPatternIfFound() - { - $this->guesser1->expects($this->once()) - ->method('guessPattern') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( - '[a-z]', - Guess::MEDIUM_CONFIDENCE - ))); - - $this->guesser2->expects($this->once()) - ->method('guessPattern') - ->with('Application\Author', 'firstName') - ->will($this->returnValue(new ValueGuess( - '[a-zA-Z]', - Guess::HIGH_CONFIDENCE - ))); - - $factory = $this->getMockFactory(array('createNamedBuilder')); - - $factory->expects($this->once()) - ->method('createNamedBuilder') - ->with('firstName', 'text', null, array('attr' => array('pattern' => '[a-zA-Z]'))) - ->will($this->returnValue('builderInstance')); - - $this->builder = $factory->createBuilderForProperty( - 'Application\Author', - 'firstName' - ); - - $this->assertEquals('builderInstance', $this->builder); - } - - private function getMockFactory(array $methods = array()) - { - return $this->getMockBuilder('Symfony\Component\Form\FormFactory') - ->setMethods($methods) - ->setConstructorArgs(array($this->registry, $this->resolvedTypeFactory)) - ->getMock(); - } - - private function getMockResolvedType() - { - return $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - } - - private function getMockType() - { - return $this->getMock('Symfony\Component\Form\FormTypeInterface'); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormIntegrationTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormIntegrationTestCase.php deleted file mode 100644 index 763286c26..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormIntegrationTestCase.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\Test\FormIntegrationTestCase as BaseFormIntegrationTestCase; - -/** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\FormIntegrationTestCase instead. - */ -abstract class FormIntegrationTestCase extends BaseFormIntegrationTestCase -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormPerformanceTestCase.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormPerformanceTestCase.php deleted file mode 100644 index 39882e85e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormPerformanceTestCase.php +++ /dev/null @@ -1,21 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\Test\FormPerformanceTestCase as BaseFormPerformanceTestCase; - -/** - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use Symfony\Component\Form\Test\FormPerformanceTestCase instead. - */ -abstract class FormPerformanceTestCase extends BaseFormPerformanceTestCase -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormRegistryTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormRegistryTest.php deleted file mode 100644 index 0c8bb6b44..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormRegistryTest.php +++ /dev/null @@ -1,243 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\FormRegistry; -use Symfony\Component\Form\FormTypeGuesserChain; -use Symfony\Component\Form\Tests\Fixtures\TestExtension; -use Symfony\Component\Form\Tests\Fixtures\FooSubTypeWithParentInstance; -use Symfony\Component\Form\Tests\Fixtures\FooSubType; -use Symfony\Component\Form\Tests\Fixtures\FooTypeBazExtension; -use Symfony\Component\Form\Tests\Fixtures\FooTypeBarExtension; -use Symfony\Component\Form\Tests\Fixtures\FooType; - -/** - * @author Bernhard Schussek - */ -class FormRegistryTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var FormRegistry - */ - private $registry; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $resolvedTypeFactory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $guesser1; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $guesser2; - - /** - * @var TestExtension - */ - private $extension1; - - /** - * @var TestExtension - */ - private $extension2; - - protected function setUp() - { - $this->resolvedTypeFactory = $this->getMock('Symfony\Component\Form\ResolvedFormTypeFactory'); - $this->guesser1 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->guesser2 = $this->getMock('Symfony\Component\Form\FormTypeGuesserInterface'); - $this->extension1 = new TestExtension($this->guesser1); - $this->extension2 = new TestExtension($this->guesser2); - $this->registry = new FormRegistry(array( - $this->extension1, - $this->extension2, - ), $this->resolvedTypeFactory); - } - - public function testGetTypeFromExtension() - { - $type = new FooType(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - - $this->extension2->addType($type); - - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type) - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); - - $resolvedType = $this->registry->getType('foo'); - - $this->assertSame($resolvedType, $this->registry->getType('foo')); - } - - public function testGetTypeWithTypeExtensions() - { - $type = new FooType(); - $ext1 = new FooTypeBarExtension(); - $ext2 = new FooTypeBazExtension(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - - $this->extension2->addType($type); - $this->extension1->addTypeExtension($ext1); - $this->extension2->addTypeExtension($ext2); - - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type, array($ext1, $ext2)) - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); - - $this->assertSame($resolvedType, $this->registry->getType('foo')); - } - - public function testGetTypeConnectsParent() - { - $parentType = new FooType(); - $type = new FooSubType(); - $parentResolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - - $this->extension1->addType($parentType); - $this->extension2->addType($type); - - $this->resolvedTypeFactory->expects($this->at(0)) - ->method('createResolvedType') - ->with($parentType) - ->will($this->returnValue($parentResolvedType)); - - $this->resolvedTypeFactory->expects($this->at(1)) - ->method('createResolvedType') - ->with($type, array(), $parentResolvedType) - ->will($this->returnValue($resolvedType)); - - $parentResolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); - - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo_sub_type')); - - $this->assertSame($resolvedType, $this->registry->getType('foo_sub_type')); - } - - public function testGetTypeConnectsParentIfGetParentReturnsInstance() - { - $type = new FooSubTypeWithParentInstance(); - $parentResolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - - $this->extension1->addType($type); - - $this->resolvedTypeFactory->expects($this->at(0)) - ->method('createResolvedType') - ->with($this->isInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType')) - ->will($this->returnValue($parentResolvedType)); - - $this->resolvedTypeFactory->expects($this->at(1)) - ->method('createResolvedType') - ->with($type, array(), $parentResolvedType) - ->will($this->returnValue($resolvedType)); - - $parentResolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); - - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo_sub_type_parent_instance')); - - $this->assertSame($resolvedType, $this->registry->getType('foo_sub_type_parent_instance')); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testGetTypeThrowsExceptionIfParentNotFound() - { - $type = new FooSubType(); - - $this->extension1->addType($type); - - $this->registry->getType($type); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\InvalidArgumentException - */ - public function testGetTypeThrowsExceptionIfTypeNotFound() - { - $this->registry->getType('bar'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testGetTypeThrowsExceptionIfNoString() - { - $this->registry->getType(array()); - } - - public function testHasTypeAfterLoadingFromExtension() - { - $type = new FooType(); - $resolvedType = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - - $this->resolvedTypeFactory->expects($this->once()) - ->method('createResolvedType') - ->with($type) - ->will($this->returnValue($resolvedType)); - - $resolvedType->expects($this->any()) - ->method('getName') - ->will($this->returnValue('foo')); - - $this->assertFalse($this->registry->hasType('foo')); - - $this->extension2->addType($type); - - $this->assertTrue($this->registry->hasType('foo')); - } - - public function testGetTypeGuesser() - { - $expectedGuesser = new FormTypeGuesserChain(array($this->guesser1, $this->guesser2)); - - $this->assertEquals($expectedGuesser, $this->registry->getTypeGuesser()); - - $registry = new FormRegistry( - array($this->getMock('Symfony\Component\Form\FormExtensionInterface')), - $this->resolvedTypeFactory); - - $this->assertNull($registry->getTypeGuesser()); - } - - public function testGetExtensions() - { - $expectedExtensions = array($this->extension1, $this->extension2); - - $this->assertEquals($expectedExtensions, $this->registry->getExtensions()); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/FormRendererTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/FormRendererTest.php deleted file mode 100644 index eda35e36a..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/FormRendererTest.php +++ /dev/null @@ -1,27 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -class FormRendererTest extends \PHPUnit_Framework_TestCase -{ - public function testHumanize() - { - $renderer = $this->getMockBuilder('Symfony\Component\Form\FormRenderer') - ->setMethods(null) - ->disableOriginalConstructor() - ->getMock() - ; - - $this->assertEquals('Is active', $renderer->humanize('is_active')); - $this->assertEquals('Is active', $renderer->humanize('isActive')); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Guess/GuessTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Guess/GuessTest.php deleted file mode 100644 index 242266372..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Guess/GuessTest.php +++ /dev/null @@ -1,38 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Guess; - -use Symfony\Component\Form\Guess\Guess; - -class TestGuess extends Guess -{ -} - -class GuessTest extends \PHPUnit_Framework_TestCase -{ - public function testGetBestGuessReturnsGuessWithHighestConfidence() - { - $guess1 = new TestGuess(Guess::MEDIUM_CONFIDENCE); - $guess2 = new TestGuess(Guess::LOW_CONFIDENCE); - $guess3 = new TestGuess(Guess::HIGH_CONFIDENCE); - - $this->assertSame($guess3, Guess::getBestGuess(array($guess1, $guess2, $guess3))); - } - - /** - * @expectedException \InvalidArgumentException - */ - public function testGuessExpectsValidConfidence() - { - new TestGuess(5); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php deleted file mode 100644 index 38580063e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/NativeRequestHandlerTest.php +++ /dev/null @@ -1,219 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\NativeRequestHandler; - -/** - * @author Bernhard Schussek - */ -class NativeRequestHandlerTest extends AbstractRequestHandlerTest -{ - private static $serverBackup; - - public static function setUpBeforeClass() - { - self::$serverBackup = $_SERVER; - } - - protected function setUp() - { - parent::setUp(); - - $_GET = array(); - $_POST = array(); - $_FILES = array(); - $_SERVER = array( - // PHPUnit needs this entry - 'SCRIPT_NAME' => self::$serverBackup['SCRIPT_NAME'], - ); - } - - protected function tearDown() - { - parent::tearDown(); - - $_GET = array(); - $_POST = array(); - $_FILES = array(); - $_SERVER = self::$serverBackup; - } - - /** - * @expectedException \Symfony\Component\Form\Exception\UnexpectedTypeException - */ - public function testRequestShouldBeNull() - { - $this->requestHandler->handleRequest($this->getMockForm('name', 'GET'), 'request'); - } - - public function testMethodOverrideHeaderTakesPrecedenceIfPost() - { - $form = $this->getMockForm('param1', 'PUT'); - - $this->setRequestData('POST', array( - 'param1' => 'DATA', - )); - - $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT'; - - $form->expects($this->once()) - ->method('submit') - ->with('DATA'); - - $this->requestHandler->handleRequest($form, $this->request); - } - - public function testConvertEmptyUploadedFilesToNull() - { - $form = $this->getMockForm('param1', 'POST', false); - - $this->setRequestData('POST', array(), array('param1' => array( - 'name' => '', - 'type' => '', - 'tmp_name' => '', - 'error' => UPLOAD_ERR_NO_FILE, - 'size' => 0, - ))); - - $form->expects($this->once()) - ->method('submit') - ->with($this->identicalTo(null)); - - $this->requestHandler->handleRequest($form, $this->request); - } - - public function testFixBuggyFilesArray() - { - $form = $this->getMockForm('param1', 'POST', false); - - $this->setRequestData('POST', array(), array('param1' => array( - 'name' => array( - 'field' => 'upload.txt', - ), - 'type' => array( - 'field' => 'text/plain', - ), - 'tmp_name' => array( - 'field' => 'owfdskjasdfsa', - ), - 'error' => array( - 'field' => UPLOAD_ERR_OK, - ), - 'size' => array( - 'field' => 100, - ), - ))); - - $form->expects($this->once()) - ->method('submit') - ->with(array( - 'field' => array( - 'name' => 'upload.txt', - 'type' => 'text/plain', - 'tmp_name' => 'owfdskjasdfsa', - 'error' => UPLOAD_ERR_OK, - 'size' => 100, - ), - )); - - $this->requestHandler->handleRequest($form, $this->request); - } - - public function testFixBuggyNestedFilesArray() - { - $form = $this->getMockForm('param1', 'POST'); - - $this->setRequestData('POST', array(), array('param1' => array( - 'name' => array( - 'field' => array('subfield' => 'upload.txt'), - ), - 'type' => array( - 'field' => array('subfield' => 'text/plain'), - ), - 'tmp_name' => array( - 'field' => array('subfield' => 'owfdskjasdfsa'), - ), - 'error' => array( - 'field' => array('subfield' => UPLOAD_ERR_OK), - ), - 'size' => array( - 'field' => array('subfield' => 100), - ), - ))); - - $form->expects($this->once()) - ->method('submit') - ->with(array( - 'field' => array( - 'subfield' => array( - 'name' => 'upload.txt', - 'type' => 'text/plain', - 'tmp_name' => 'owfdskjasdfsa', - 'error' => UPLOAD_ERR_OK, - 'size' => 100, - ), - ), - )); - - $this->requestHandler->handleRequest($form, $this->request); - } - - public function testMethodOverrideHeaderIgnoredIfNotPost() - { - $form = $this->getMockForm('param1', 'POST'); - - $this->setRequestData('GET', array( - 'param1' => 'DATA', - )); - - $_SERVER['HTTP_X_HTTP_METHOD_OVERRIDE'] = 'PUT'; - - $form->expects($this->never()) - ->method('submit'); - - $this->requestHandler->handleRequest($form, $this->request); - } - - protected function setRequestData($method, $data, $files = array()) - { - if ('GET' === $method) { - $_GET = $data; - $_FILES = array(); - } else { - $_POST = $data; - $_FILES = $files; - } - - $_SERVER = array( - 'REQUEST_METHOD' => $method, - // PHPUnit needs this entry - 'SCRIPT_NAME' => self::$serverBackup['SCRIPT_NAME'], - ); - } - - protected function getRequestHandler() - { - return new NativeRequestHandler($this->serverParams); - } - - protected function getMockFile($suffix = '') - { - return array( - 'name' => 'upload'.$suffix.'.txt', - 'type' => 'text/plain', - 'tmp_name' => 'owfdskjasdfsa'.$suffix, - 'error' => UPLOAD_ERR_OK, - 'size' => 100, - ); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php deleted file mode 100644 index 2f3fe6102..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php +++ /dev/null @@ -1,343 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\ResolvedFormType; -use Symfony\Component\Form\FormView; -use Symfony\Component\Form\FormBuilder; -use Symfony\Component\OptionsResolver\OptionsResolverInterface; - -/** - * @author Bernhard Schussek - */ -class ResolvedFormTypeTest extends \PHPUnit_Framework_TestCase -{ - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dispatcher; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $factory; - - /** - * @var \PHPUnit_Framework_MockObject_MockObject - */ - private $dataMapper; - private $parentType; - private $type; - private $extension1; - private $extension2; - private $parentResolvedType; - private $resolvedType; - - protected function setUp() - { - $this->dispatcher = $this->getMock('Symfony\Component\EventDispatcher\EventDispatcherInterface'); - $this->factory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - $this->dataMapper = $this->getMock('Symfony\Component\Form\DataMapperInterface'); - $this->parentType = $this->getMockFormType(); - $this->type = $this->getMockFormType(); - $this->extension1 = $this->getMockFormTypeExtension(); - $this->extension2 = $this->getMockFormTypeExtension(); - $this->parentResolvedType = new ResolvedFormType($this->parentType); - $this->resolvedType = new ResolvedFormType($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType); - } - - public function testGetOptionsResolver() - { - $test = $this; - $i = 0; - - $assertIndexAndAddOption = function ($index, $option, $default) use (&$i, $test) { - return function (OptionsResolverInterface $resolver) use (&$i, $test, $index, $option, $default) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals($index, $i, 'Executed at index '.$index); - - ++$i; - - $resolver->setDefaults(array($option => $default)); - }; - }; - - // First the default options are generated for the super type - $this->parentType->expects($this->once()) - ->method('setDefaultOptions') - ->will($this->returnCallback($assertIndexAndAddOption(0, 'a', 'a_default'))); - - // The form type itself - $this->type->expects($this->once()) - ->method('setDefaultOptions') - ->will($this->returnCallback($assertIndexAndAddOption(1, 'b', 'b_default'))); - - // And its extensions - $this->extension1->expects($this->once()) - ->method('setDefaultOptions') - ->will($this->returnCallback($assertIndexAndAddOption(2, 'c', 'c_default'))); - - $this->extension2->expects($this->once()) - ->method('setDefaultOptions') - ->will($this->returnCallback($assertIndexAndAddOption(3, 'd', 'd_default'))); - - $givenOptions = array('a' => 'a_custom', 'c' => 'c_custom'); - $resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'); - - $resolver = $this->resolvedType->getOptionsResolver(); - - $this->assertEquals($resolvedOptions, $resolver->resolve($givenOptions)); - } - - public function testCreateBuilder() - { - $givenOptions = array('a' => 'a_custom', 'c' => 'c_custom'); - $resolvedOptions = array('a' => 'a_custom', 'b' => 'b_default', 'c' => 'c_custom', 'd' => 'd_default'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); - - $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') - ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) - ->setMethods(array('getOptionsResolver')) - ->getMock(); - - $this->resolvedType->expects($this->once()) - ->method('getOptionsResolver') - ->will($this->returnValue($optionsResolver)); - - $optionsResolver->expects($this->once()) - ->method('resolve') - ->with($givenOptions) - ->will($this->returnValue($resolvedOptions)); - - $factory = $this->getMockFormFactory(); - $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); - - $this->assertSame($this->resolvedType, $builder->getType()); - $this->assertSame($resolvedOptions, $builder->getOptions()); - $this->assertNull($builder->getDataClass()); - } - - public function testCreateBuilderWithDataClassOption() - { - $givenOptions = array('data_class' => 'Foo'); - $resolvedOptions = array('data_class' => '\stdClass'); - $optionsResolver = $this->getMock('Symfony\Component\OptionsResolver\OptionsResolverInterface'); - - $this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType') - ->setConstructorArgs(array($this->type, array($this->extension1, $this->extension2), $this->parentResolvedType)) - ->setMethods(array('getOptionsResolver')) - ->getMock(); - - $this->resolvedType->expects($this->once()) - ->method('getOptionsResolver') - ->will($this->returnValue($optionsResolver)); - - $optionsResolver->expects($this->once()) - ->method('resolve') - ->with($givenOptions) - ->will($this->returnValue($resolvedOptions)); - - $factory = $this->getMockFormFactory(); - $builder = $this->resolvedType->createBuilder($factory, 'name', $givenOptions); - - $this->assertSame($this->resolvedType, $builder->getType()); - $this->assertSame($resolvedOptions, $builder->getOptions()); - $this->assertSame('\stdClass', $builder->getDataClass()); - } - - public function testBuildForm() - { - $test = $this; - $i = 0; - - $assertIndex = function ($index) use (&$i, $test) { - return function () use (&$i, $test, $index) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals($index, $i, 'Executed at index '.$index); - - ++$i; - }; - }; - - $options = array('a' => 'Foo', 'b' => 'Bar'); - $builder = $this->getMock('Symfony\Component\Form\Test\FormBuilderInterface'); - - // First the form is built for the super type - $this->parentType->expects($this->once()) - ->method('buildForm') - ->with($builder, $options) - ->will($this->returnCallback($assertIndex(0))); - - // Then the type itself - $this->type->expects($this->once()) - ->method('buildForm') - ->with($builder, $options) - ->will($this->returnCallback($assertIndex(1))); - - // Then its extensions - $this->extension1->expects($this->once()) - ->method('buildForm') - ->with($builder, $options) - ->will($this->returnCallback($assertIndex(2))); - - $this->extension2->expects($this->once()) - ->method('buildForm') - ->with($builder, $options) - ->will($this->returnCallback($assertIndex(3))); - - $this->resolvedType->buildForm($builder, $options); - } - - public function testCreateView() - { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - - $view = $this->resolvedType->createView($form); - - $this->assertInstanceOf('Symfony\Component\Form\FormView', $view); - $this->assertNull($view->parent); - } - - public function testCreateViewWithParent() - { - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $parentView = $this->getMock('Symfony\Component\Form\FormView'); - - $view = $this->resolvedType->createView($form, $parentView); - - $this->assertInstanceOf('Symfony\Component\Form\FormView', $view); - $this->assertSame($parentView, $view->parent); - } - - public function testBuildView() - { - $options = array('a' => '1', 'b' => '2'); - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); - - $test = $this; - $i = 0; - - $assertIndex = function ($index) use (&$i, $test) { - return function () use (&$i, $test, $index) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals($index, $i, 'Executed at index '.$index); - - ++$i; - }; - }; - - // First the super type - $this->parentType->expects($this->once()) - ->method('buildView') - ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(0))); - - // Then the type itself - $this->type->expects($this->once()) - ->method('buildView') - ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(1))); - - // Then its extensions - $this->extension1->expects($this->once()) - ->method('buildView') - ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(2))); - - $this->extension2->expects($this->once()) - ->method('buildView') - ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(3))); - - $this->resolvedType->buildView($view, $form, $options); - } - - public function testFinishView() - { - $options = array('a' => '1', 'b' => '2'); - $form = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); - - $test = $this; - $i = 0; - - $assertIndex = function ($index) use (&$i, $test) { - return function () use (&$i, $test, $index) { - /* @var \PHPUnit_Framework_TestCase $test */ - $test->assertEquals($index, $i, 'Executed at index '.$index); - - ++$i; - }; - }; - - // First the super type - $this->parentType->expects($this->once()) - ->method('finishView') - ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(0))); - - // Then the type itself - $this->type->expects($this->once()) - ->method('finishView') - ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(1))); - - // Then its extensions - $this->extension1->expects($this->once()) - ->method('finishView') - ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(2))); - - $this->extension2->expects($this->once()) - ->method('finishView') - ->with($view, $form, $options) - ->will($this->returnCallback($assertIndex(3))); - - $this->resolvedType->finishView($view, $form, $options); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getMockFormType() - { - return $this->getMock('Symfony\Component\Form\FormTypeInterface'); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getMockFormTypeExtension() - { - return $this->getMock('Symfony\Component\Form\FormTypeExtensionInterface'); - } - - /** - * @return \PHPUnit_Framework_MockObject_MockObject - */ - private function getMockFormFactory() - { - return $this->getMock('Symfony\Component\Form\FormFactoryInterface'); - } - - /** - * @param string $name - * @param array $options - * - * @return FormBuilder - */ - protected function getBuilder($name = 'name', array $options = array()) - { - return new FormBuilder($name, null, $this->dispatcher, $this->factory, $options); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/SimpleFormTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/SimpleFormTest.php deleted file mode 100644 index 4c4e0ed8d..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/SimpleFormTest.php +++ /dev/null @@ -1,1061 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests; - -use Symfony\Component\Form\Form; -use Symfony\Component\Form\FormEvent; -use Symfony\Component\Form\FormEvents; -use Symfony\Component\PropertyAccess\PropertyPath; -use Symfony\Component\Form\FormConfigBuilder; -use Symfony\Component\Form\FormError; -use Symfony\Component\Form\Exception\TransformationFailedException; -use Symfony\Component\EventDispatcher\EventDispatcher; -use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; -use Symfony\Component\Form\Tests\Fixtures\FixedFilterListener; - -class SimpleFormTest_Countable implements \Countable -{ - private $count; - - public function __construct($count) - { - $this->count = $count; - } - - public function count() - { - return $this->count; - } -} - -class SimpleFormTest_Traversable implements \IteratorAggregate -{ - private $iterator; - - public function __construct($count) - { - $this->iterator = new \ArrayIterator($count > 0 ? array_fill(0, $count, 'Foo') : array()); - } - - public function getIterator() - { - return $this->iterator; - } -} - -class SimpleFormTest extends AbstractFormTest -{ - public function testDataIsInitializedToConfiguredValue() - { - $model = new FixedDataTransformer(array( - 'default' => 'foo', - )); - $view = new FixedDataTransformer(array( - 'foo' => 'bar', - )); - - $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addViewTransformer($view); - $config->addModelTransformer($model); - $config->setData('default'); - $form = new Form($config); - - $this->assertSame('default', $form->getData()); - $this->assertSame('foo', $form->getNormData()); - $this->assertSame('bar', $form->getViewData()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\TransformationFailedException - * @expectedExceptionMessage Unable to transform value for property path "name": No mapping for value "arg" - */ - public function testDataTransformationFailure() - { - $model = new FixedDataTransformer(array( - 'default' => 'foo', - )); - $view = new FixedDataTransformer(array( - 'foo' => 'bar', - )); - - $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addViewTransformer($view); - $config->addModelTransformer($model); - $config->setData('arg'); - $form = new Form($config); - - $form->getData(); - } - - // https://github.com/symfony/symfony/commit/d4f4038f6daf7cf88ca7c7ab089473cce5ebf7d8#commitcomment-1632879 - public function testDataIsInitializedFromSubmit() - { - $mock = $this->getMockBuilder('\stdClass') - ->setMethods(array('preSetData', 'preSubmit')) - ->getMock(); - $mock->expects($this->at(0)) - ->method('preSetData'); - $mock->expects($this->at(1)) - ->method('preSubmit'); - - $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addEventListener(FormEvents::PRE_SET_DATA, array($mock, 'preSetData')); - $config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preSubmit')); - $form = new Form($config); - - // no call to setData() or similar where the object would be - // initialized otherwise - - $form->submit('foobar'); - } - - // https://github.com/symfony/symfony/pull/7789 - public function testFalseIsConvertedToNull() - { - $mock = $this->getMockBuilder('\stdClass') - ->setMethods(array('preSubmit')) - ->getMock(); - $mock->expects($this->once()) - ->method('preSubmit') - ->with($this->callback(function ($event) { - return null === $event->getData(); - })); - - $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addEventListener(FormEvents::PRE_SUBMIT, array($mock, 'preSubmit')); - $form = new Form($config); - - $form->submit(false); - - $this->assertTrue($form->isValid()); - $this->assertNull($form->getData()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException - */ - public function testSubmitThrowsExceptionIfAlreadySubmitted() - { - $this->form->submit(array()); - $this->form->submit(array()); - } - - public function testSubmitIsIgnoredIfDisabled() - { - $form = $this->getBuilder() - ->setDisabled(true) - ->setData('initial') - ->getForm(); - - $form->submit('new'); - - $this->assertEquals('initial', $form->getData()); - $this->assertTrue($form->isSubmitted()); - } - - public function testNeverRequiredIfParentNotRequired() - { - $parent = $this->getBuilder()->setRequired(false)->getForm(); - $child = $this->getBuilder()->setRequired(true)->getForm(); - - $child->setParent($parent); - - $this->assertFalse($child->isRequired()); - } - - public function testRequired() - { - $parent = $this->getBuilder()->setRequired(true)->getForm(); - $child = $this->getBuilder()->setRequired(true)->getForm(); - - $child->setParent($parent); - - $this->assertTrue($child->isRequired()); - } - - public function testNotRequired() - { - $parent = $this->getBuilder()->setRequired(true)->getForm(); - $child = $this->getBuilder()->setRequired(false)->getForm(); - - $child->setParent($parent); - - $this->assertFalse($child->isRequired()); - } - - /** - * @dataProvider getDisabledStates - */ - public function testAlwaysDisabledIfParentDisabled($parentDisabled, $disabled, $result) - { - $parent = $this->getBuilder()->setDisabled($parentDisabled)->getForm(); - $child = $this->getBuilder()->setDisabled($disabled)->getForm(); - - $child->setParent($parent); - - $this->assertSame($result, $child->isDisabled()); - } - - public function getDisabledStates() - { - return array( - // parent, button, result - array(true, true, true), - array(true, false, true), - array(false, true, true), - array(false, false, false), - ); - } - - public function testGetRootReturnsRootOfParent() - { - $parent = $this->getMockForm(); - $parent->expects($this->once()) - ->method('getRoot') - ->will($this->returnValue('ROOT')); - - $this->form->setParent($parent); - - $this->assertEquals('ROOT', $this->form->getRoot()); - } - - public function testGetRootReturnsSelfIfNoParent() - { - $this->assertSame($this->form, $this->form->getRoot()); - } - - public function testEmptyIfEmptyArray() - { - $this->form->setData(array()); - - $this->assertTrue($this->form->isEmpty()); - } - - public function testEmptyIfEmptyCountable() - { - $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Countable', $this->dispatcher)); - - $this->form->setData(new SimpleFormTest_Countable(0)); - - $this->assertTrue($this->form->isEmpty()); - } - - public function testNotEmptyIfFilledCountable() - { - $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Countable', $this->dispatcher)); - - $this->form->setData(new SimpleFormTest_Countable(1)); - - $this->assertFalse($this->form->isEmpty()); - } - - public function testEmptyIfEmptyTraversable() - { - $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Traversable', $this->dispatcher)); - - $this->form->setData(new SimpleFormTest_Traversable(0)); - - $this->assertTrue($this->form->isEmpty()); - } - - public function testNotEmptyIfFilledTraversable() - { - $this->form = new Form(new FormConfigBuilder('name', __NAMESPACE__.'\SimpleFormTest_Traversable', $this->dispatcher)); - - $this->form->setData(new SimpleFormTest_Traversable(1)); - - $this->assertFalse($this->form->isEmpty()); - } - - public function testEmptyIfNull() - { - $this->form->setData(null); - - $this->assertTrue($this->form->isEmpty()); - } - - public function testEmptyIfEmptyString() - { - $this->form->setData(''); - - $this->assertTrue($this->form->isEmpty()); - } - - public function testNotEmptyIfText() - { - $this->form->setData('foobar'); - - $this->assertFalse($this->form->isEmpty()); - } - - public function testValidIfSubmitted() - { - $form = $this->getBuilder()->getForm(); - $form->submit('foobar'); - - $this->assertTrue($form->isValid()); - } - - public function testValidIfSubmittedAndDisabled() - { - $form = $this->getBuilder()->setDisabled(true)->getForm(); - $form->submit('foobar'); - - $this->assertTrue($form->isValid()); - } - - public function testNotValidIfNotSubmitted() - { - $this->assertFalse($this->form->isValid()); - } - - public function testNotValidIfErrors() - { - $form = $this->getBuilder()->getForm(); - $form->submit('foobar'); - $form->addError(new FormError('Error!')); - - $this->assertFalse($form->isValid()); - } - - public function testHasErrors() - { - $this->form->addError(new FormError('Error!')); - - $this->assertCount(1, $this->form->getErrors()); - } - - public function testHasNoErrors() - { - $this->assertCount(0, $this->form->getErrors()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException - */ - public function testSetParentThrowsExceptionIfAlreadySubmitted() - { - $this->form->submit(array()); - $this->form->setParent($this->getBuilder('parent')->getForm()); - } - - public function testSubmitted() - { - $form = $this->getBuilder()->getForm(); - $form->submit('foobar'); - - $this->assertTrue($form->isSubmitted()); - } - - public function testNotSubmitted() - { - $this->assertFalse($this->form->isSubmitted()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\AlreadySubmittedException - */ - public function testSetDataThrowsExceptionIfAlreadySubmitted() - { - $this->form->submit(array()); - $this->form->setData(null); - } - - public function testSetDataClonesObjectIfNotByReference() - { - $data = new \stdClass(); - $form = $this->getBuilder('name', null, '\stdClass')->setByReference(false)->getForm(); - $form->setData($data); - - $this->assertNotSame($data, $form->getData()); - $this->assertEquals($data, $form->getData()); - } - - public function testSetDataDoesNotCloneObjectIfByReference() - { - $data = new \stdClass(); - $form = $this->getBuilder('name', null, '\stdClass')->setByReference(true)->getForm(); - $form->setData($data); - - $this->assertSame($data, $form->getData()); - } - - public function testSetDataExecutesTransformationChain() - { - // use real event dispatcher now - $form = $this->getBuilder('name', new EventDispatcher()) - ->addEventSubscriber(new FixedFilterListener(array( - 'preSetData' => array( - 'app' => 'filtered', - ), - ))) - ->addModelTransformer(new FixedDataTransformer(array( - '' => '', - 'filtered' => 'norm', - ))) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'norm' => 'client', - ))) - ->getForm(); - - $form->setData('app'); - - $this->assertEquals('filtered', $form->getData()); - $this->assertEquals('norm', $form->getNormData()); - $this->assertEquals('client', $form->getViewData()); - } - - public function testSetDataExecutesViewTransformersInOrder() - { - $form = $this->getBuilder() - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'first' => 'second', - ))) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'second' => 'third', - ))) - ->getForm(); - - $form->setData('first'); - - $this->assertEquals('third', $form->getViewData()); - } - - public function testSetDataExecutesModelTransformersInReverseOrder() - { - $form = $this->getBuilder() - ->addModelTransformer(new FixedDataTransformer(array( - '' => '', - 'second' => 'third', - ))) - ->addModelTransformer(new FixedDataTransformer(array( - '' => '', - 'first' => 'second', - ))) - ->getForm(); - - $form->setData('first'); - - $this->assertEquals('third', $form->getNormData()); - } - - /* - * When there is no data transformer, the data must have the same format - * in all three representations - */ - public function testSetDataConvertsScalarToStringIfNoTransformer() - { - $form = $this->getBuilder()->getForm(); - - $form->setData(1); - - $this->assertSame('1', $form->getData()); - $this->assertSame('1', $form->getNormData()); - $this->assertSame('1', $form->getViewData()); - } - - /* - * Data in client format should, if possible, always be a string to - * facilitate differentiation between '0' and '' - */ - public function testSetDataConvertsScalarToStringIfOnlyModelTransformer() - { - $form = $this->getBuilder() - ->addModelTransformer(new FixedDataTransformer(array( - '' => '', - 1 => 23, - ))) - ->getForm(); - - $form->setData(1); - - $this->assertSame(1, $form->getData()); - $this->assertSame(23, $form->getNormData()); - $this->assertSame('23', $form->getViewData()); - } - - /* - * NULL remains NULL in app and norm format to remove the need to treat - * empty values and NULL explicitly in the application - */ - public function testSetDataConvertsNullToStringIfNoTransformer() - { - $form = $this->getBuilder()->getForm(); - - $form->setData(null); - - $this->assertNull($form->getData()); - $this->assertNull($form->getNormData()); - $this->assertSame('', $form->getViewData()); - } - - public function testSetDataIsIgnoredIfDataIsLocked() - { - $form = $this->getBuilder() - ->setData('default') - ->setDataLocked(true) - ->getForm(); - - $form->setData('foobar'); - - $this->assertSame('default', $form->getData()); - } - - public function testSubmitConvertsEmptyToNullIfNoTransformer() - { - $form = $this->getBuilder()->getForm(); - - $form->submit(''); - - $this->assertNull($form->getData()); - $this->assertNull($form->getNormData()); - $this->assertSame('', $form->getViewData()); - } - - public function testSubmitExecutesTransformationChain() - { - // use real event dispatcher now - $form = $this->getBuilder('name', new EventDispatcher()) - ->addEventSubscriber(new FixedFilterListener(array( - 'preSubmit' => array( - 'client' => 'filteredclient', - ), - 'onSubmit' => array( - 'norm' => 'filterednorm', - ), - ))) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - // direction is reversed! - 'norm' => 'filteredclient', - 'filterednorm' => 'cleanedclient', - ))) - ->addModelTransformer(new FixedDataTransformer(array( - '' => '', - // direction is reversed! - 'app' => 'filterednorm', - ))) - ->getForm(); - - $form->submit('client'); - - $this->assertEquals('app', $form->getData()); - $this->assertEquals('filterednorm', $form->getNormData()); - $this->assertEquals('cleanedclient', $form->getViewData()); - } - - public function testSubmitExecutesViewTransformersInReverseOrder() - { - $form = $this->getBuilder() - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'third' => 'second', - ))) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'second' => 'first', - ))) - ->getForm(); - - $form->submit('first'); - - $this->assertEquals('third', $form->getNormData()); - } - - public function testSubmitExecutesModelTransformersInOrder() - { - $form = $this->getBuilder() - ->addModelTransformer(new FixedDataTransformer(array( - '' => '', - 'second' => 'first', - ))) - ->addModelTransformer(new FixedDataTransformer(array( - '' => '', - 'third' => 'second', - ))) - ->getForm(); - - $form->submit('first'); - - $this->assertEquals('third', $form->getData()); - } - - public function testSynchronizedByDefault() - { - $this->assertTrue($this->form->isSynchronized()); - } - - public function testSynchronizedAfterSubmission() - { - $this->form->submit('foobar'); - - $this->assertTrue($this->form->isSynchronized()); - } - - public function testNotSynchronizedIfViewReverseTransformationFailed() - { - $transformer = $this->getDataTransformer(); - $transformer->expects($this->once()) - ->method('reverseTransform') - ->will($this->throwException(new TransformationFailedException())); - - $form = $this->getBuilder() - ->addViewTransformer($transformer) - ->getForm(); - - $form->submit('foobar'); - - $this->assertFalse($form->isSynchronized()); - } - - public function testNotSynchronizedIfModelReverseTransformationFailed() - { - $transformer = $this->getDataTransformer(); - $transformer->expects($this->once()) - ->method('reverseTransform') - ->will($this->throwException(new TransformationFailedException())); - - $form = $this->getBuilder() - ->addModelTransformer($transformer) - ->getForm(); - - $form->submit('foobar'); - - $this->assertFalse($form->isSynchronized()); - } - - public function testEmptyDataCreatedBeforeTransforming() - { - $form = $this->getBuilder() - ->setEmptyData('foo') - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - // direction is reversed! - 'bar' => 'foo', - ))) - ->getForm(); - - $form->submit(''); - - $this->assertEquals('bar', $form->getData()); - } - - public function testEmptyDataFromClosure() - { - $test = $this; - $form = $this->getBuilder() - ->setEmptyData(function ($form) use ($test) { - // the form instance is passed to the closure to allow use - // of form data when creating the empty value - $test->assertInstanceOf('Symfony\Component\Form\FormInterface', $form); - - return 'foo'; - }) - ->addViewTransformer(new FixedDataTransformer(array( - '' => '', - // direction is reversed! - 'bar' => 'foo', - ))) - ->getForm(); - - $form->submit(''); - - $this->assertEquals('bar', $form->getData()); - } - - public function testSubmitResetsErrors() - { - $this->form->addError(new FormError('Error!')); - $this->form->submit('foobar'); - - $this->assertCount(0, $this->form->getErrors()); - } - - public function testCreateView() - { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); - $form = $this->getBuilder()->setType($type)->getForm(); - - $type->expects($this->once()) - ->method('createView') - ->with($form) - ->will($this->returnValue($view)); - - $this->assertSame($view, $form->createView()); - } - - public function testCreateViewWithParent() - { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); - $parentForm = $this->getMock('Symfony\Component\Form\Test\FormInterface'); - $parentView = $this->getMock('Symfony\Component\Form\FormView'); - $form = $this->getBuilder()->setType($type)->getForm(); - $form->setParent($parentForm); - - $parentForm->expects($this->once()) - ->method('createView') - ->will($this->returnValue($parentView)); - - $type->expects($this->once()) - ->method('createView') - ->with($form, $parentView) - ->will($this->returnValue($view)); - - $this->assertSame($view, $form->createView()); - } - - public function testCreateViewWithExplicitParent() - { - $type = $this->getMock('Symfony\Component\Form\ResolvedFormTypeInterface'); - $view = $this->getMock('Symfony\Component\Form\FormView'); - $parentView = $this->getMock('Symfony\Component\Form\FormView'); - $form = $this->getBuilder()->setType($type)->getForm(); - - $type->expects($this->once()) - ->method('createView') - ->with($form, $parentView) - ->will($this->returnValue($view)); - - $this->assertSame($view, $form->createView($parentView)); - } - - public function testGetErrorsAsString() - { - $this->form->addError(new FormError('Error!')); - - $this->assertEquals("ERROR: Error!\n", $this->form->getErrorsAsString()); - } - - public function testFormCanHaveEmptyName() - { - $form = $this->getBuilder('')->getForm(); - - $this->assertEquals('', $form->getName()); - } - - public function testSetNullParentWorksWithEmptyName() - { - $form = $this->getBuilder('')->getForm(); - $form->setParent(null); - - $this->assertNull($form->getParent()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\LogicException - * @expectedExceptionMessage A form with an empty name cannot have a parent form. - */ - public function testFormCannotHaveEmptyNameNotInRootLevel() - { - $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->add($this->getBuilder('')) - ->getForm(); - } - - public function testGetPropertyPathReturnsConfiguredPath() - { - $form = $this->getBuilder()->setPropertyPath('address.street')->getForm(); - - $this->assertEquals(new PropertyPath('address.street'), $form->getPropertyPath()); - } - - // see https://github.com/symfony/symfony/issues/3903 - public function testGetPropertyPathDefaultsToNameIfParentHasDataClass() - { - $parent = $this->getBuilder(null, null, 'stdClass') - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $form = $this->getBuilder('name')->getForm(); - $parent->add($form); - - $this->assertEquals(new PropertyPath('name'), $form->getPropertyPath()); - } - - // see https://github.com/symfony/symfony/issues/3903 - public function testGetPropertyPathDefaultsToIndexedNameIfParentDataClassIsNull() - { - $parent = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $form = $this->getBuilder('name')->getForm(); - $parent->add($form); - - $this->assertEquals(new PropertyPath('[name]'), $form->getPropertyPath()); - } - - public function testGetPropertyPathDefaultsToNameIfFirstParentWithoutInheritDataHasDataClass() - { - $grandParent = $this->getBuilder(null, null, 'stdClass') - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $parent = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setInheritData(true) - ->getForm(); - $form = $this->getBuilder('name')->getForm(); - $grandParent->add($parent); - $parent->add($form); - - $this->assertEquals(new PropertyPath('name'), $form->getPropertyPath()); - } - - public function testGetPropertyPathDefaultsToIndexedNameIfDataClassOfFirstParentWithoutInheritDataIsNull() - { - $grandParent = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->getForm(); - $parent = $this->getBuilder() - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setInheritData(true) - ->getForm(); - $form = $this->getBuilder('name')->getForm(); - $grandParent->add($parent); - $parent->add($form); - - $this->assertEquals(new PropertyPath('[name]'), $form->getPropertyPath()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\LogicException - */ - public function testViewDataMustNotBeObjectIfDataClassIsNull() - { - $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'foo' => new \stdClass(), - ))); - $form = new Form($config); - - $form->setData('foo'); - } - - public function testViewDataMayBeArrayAccessIfDataClassIsNull() - { - $arrayAccess = $this->getMock('\ArrayAccess'); - $config = new FormConfigBuilder('name', null, $this->dispatcher); - $config->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'foo' => $arrayAccess, - ))); - $form = new Form($config); - - $form->setData('foo'); - - $this->assertSame($arrayAccess, $form->getViewData()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\LogicException - */ - public function testViewDataMustBeObjectIfDataClassIsSet() - { - $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); - $config->addViewTransformer(new FixedDataTransformer(array( - '' => '', - 'foo' => array('bar' => 'baz'), - ))); - $form = new Form($config); - - $form->setData('foo'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\RuntimeException - */ - public function testSetDataCannotInvokeItself() - { - // Cycle detection to prevent endless loops - $config = new FormConfigBuilder('name', 'stdClass', $this->dispatcher); - $config->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) { - $event->getForm()->setData('bar'); - }); - $form = new Form($config); - - $form->setData('foo'); - } - - public function testSubmittingWrongDataIsIgnored() - { - $test = $this; - - $child = $this->getBuilder('child', $this->dispatcher); - $child->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($test) { - // child form doesn't receive the wrong data that is submitted on parent - $test->assertNull($event->getData()); - }); - - $parent = $this->getBuilder('parent', new EventDispatcher()) - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->add($child) - ->getForm(); - - $parent->submit('not-an-array'); - } - - public function testHandleRequestForwardsToRequestHandler() - { - $handler = $this->getMock('Symfony\Component\Form\RequestHandlerInterface'); - - $form = $this->getBuilder() - ->setRequestHandler($handler) - ->getForm(); - - $handler->expects($this->once()) - ->method('handleRequest') - ->with($this->identicalTo($form), 'REQUEST'); - - $this->assertSame($form, $form->handleRequest('REQUEST')); - } - - public function testFormInheritsParentData() - { - $child = $this->getBuilder('child') - ->setInheritData(true); - - $parent = $this->getBuilder('parent') - ->setCompound(true) - ->setDataMapper($this->getDataMapper()) - ->setData('foo') - ->addModelTransformer(new FixedDataTransformer(array( - 'foo' => 'norm[foo]', - ))) - ->addViewTransformer(new FixedDataTransformer(array( - 'norm[foo]' => 'view[foo]', - ))) - ->add($child) - ->getForm(); - - $this->assertSame('foo', $parent->get('child')->getData()); - $this->assertSame('norm[foo]', $parent->get('child')->getNormData()); - $this->assertSame('view[foo]', $parent->get('child')->getViewData()); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\RuntimeException - */ - public function testInheritDataDisallowsSetData() - { - $form = $this->getBuilder() - ->setInheritData(true) - ->getForm(); - - $form->setData('foo'); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\RuntimeException - */ - public function testGetDataRequiresParentToBeSetIfInheritData() - { - $form = $this->getBuilder() - ->setInheritData(true) - ->getForm(); - - $form->getData(); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\RuntimeException - */ - public function testGetNormDataRequiresParentToBeSetIfInheritData() - { - $form = $this->getBuilder() - ->setInheritData(true) - ->getForm(); - - $form->getNormData(); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\RuntimeException - */ - public function testGetViewDataRequiresParentToBeSetIfInheritData() - { - $form = $this->getBuilder() - ->setInheritData(true) - ->getForm(); - - $form->getViewData(); - } - - public function testPostSubmitDataIsNullIfInheritData() - { - $test = $this; - $form = $this->getBuilder() - ->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) use ($test) { - $test->assertNull($event->getData()); - }) - ->setInheritData(true) - ->getForm(); - - $form->submit('foo'); - } - - public function testSubmitIsNeverFiredIfInheritData() - { - $test = $this; - $form = $this->getBuilder() - ->addEventListener(FormEvents::SUBMIT, function (FormEvent $event) use ($test) { - $test->fail('The SUBMIT event should not be fired'); - }) - ->setInheritData(true) - ->getForm(); - - $form->submit('foo'); - } - - public function testInitializeSetsDefaultData() - { - $config = $this->getBuilder()->setData('DEFAULT')->getFormConfig(); - $form = $this->getMock('Symfony\Component\Form\Form', array('setData'), array($config)); - - $form->expects($this->once()) - ->method('setData') - ->with($this->identicalTo('DEFAULT')); - - /* @var Form $form */ - $form->initialize(); - } - - /** - * @expectedException \Symfony\Component\Form\Exception\RuntimeException - */ - public function testInitializeFailsIfParent() - { - $parent = $this->getBuilder()->setRequired(false)->getForm(); - $child = $this->getBuilder()->setRequired(true)->getForm(); - - $child->setParent($parent); - - $child->initialize(); - } - - protected function createForm() - { - return $this->getBuilder()->getForm(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php b/vendor/symfony/form/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php deleted file mode 100644 index 7adff69a3..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Tests/Util/OrderedHashMapTest.php +++ /dev/null @@ -1,487 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Tests\Util; - -use Symfony\Component\Form\Util\OrderedHashMap; - -/** - * @author Bernhard Schussek - */ -class OrderedHashMapTest extends \PHPUnit_Framework_TestCase -{ - public function testGet() - { - $map = new OrderedHashMap(); - $map['first'] = 1; - - $this->assertSame(1, $map['first']); - } - - /** - * @expectedException \OutOfBoundsException - */ - public function testGetNonExistingFails() - { - $map = new OrderedHashMap(); - - $map['first']; - } - - public function testInsertStringKeys() - { - $map = new OrderedHashMap(); - $map['first'] = 1; - $map['second'] = 2; - - $this->assertSame(array('first' => 1, 'second' => 2), iterator_to_array($map)); - } - - public function testInsertNullKeys() - { - $map = new OrderedHashMap(); - $map[] = 1; - $map['foo'] = 2; - $map[] = 3; - - $this->assertSame(array(0 => 1, 'foo' => 2, 1 => 3), iterator_to_array($map)); - } - - /** - * Updates should not change the position of an element, otherwise we could - * turn foreach loops into endless loops if they change the current - * element. - * - * foreach ($map as $index => $value) { - * $map[$index] = $value + 1; - * } - * - * And we don't want this, right? :) - */ - public function testUpdateDoesNotChangeElementPosition() - { - $map = new OrderedHashMap(); - $map['first'] = 1; - $map['second'] = 2; - $map['first'] = 1; - - $this->assertSame(array('first' => 1, 'second' => 2), iterator_to_array($map)); - } - - public function testIsset() - { - $map = new OrderedHashMap(); - $map['first'] = 1; - - $this->assertTrue(isset($map['first'])); - } - - public function testIssetReturnsFalseForNonExisting() - { - $map = new OrderedHashMap(); - - $this->assertFalse(isset($map['first'])); - } - - public function testIssetReturnsFalseForNull() - { - $map = new OrderedHashMap(); - $map['first'] = null; - - $this->assertFalse(isset($map['first'])); - } - - public function testUnset() - { - $map = new OrderedHashMap(); - $map['first'] = 1; - $map['second'] = 2; - - unset($map['first']); - - $this->assertSame(array('second' => 2), iterator_to_array($map)); - } - - public function testUnsetNonExistingSucceeds() - { - $map = new OrderedHashMap(); - - unset($map['first']); - } - - public function testEmptyIteration() - { - $map = new OrderedHashMap(); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationSupportsInsertion() - { - $map = new OrderedHashMap(array('first' => 1)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('first', $it->key()); - $this->assertSame(1, $it->current()); - - // dynamic modification - $map['added'] = 2; - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('first', $it->key()); - $this->assertSame(1, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('added', $it->key()); - $this->assertSame(2, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationSupportsDeletionAndInsertion() - { - $map = new OrderedHashMap(array('first' => 1, 'removed' => 2)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('first', $it->key()); - $this->assertSame(1, $it->current()); - - // dynamic modification - unset($map['removed']); - $map['added'] = 3; - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('first', $it->key()); - $this->assertSame(1, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('added', $it->key()); - $this->assertSame(3, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationSupportsDeletionOfCurrentElement() - { - $map = new OrderedHashMap(array('removed' => 1, 'next' => 2)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('removed', $it->key()); - $this->assertSame(1, $it->current()); - - unset($map['removed']); - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('removed', $it->key()); - $this->assertSame(1, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('next', $it->key()); - $this->assertSame(2, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationIgnoresReplacementOfCurrentElement() - { - $map = new OrderedHashMap(array('replaced' => 1, 'next' => 2)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('replaced', $it->key()); - $this->assertSame(1, $it->current()); - - $map['replaced'] = 3; - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('replaced', $it->key()); - $this->assertSame(1, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('next', $it->key()); - $this->assertSame(2, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationSupportsDeletionOfCurrentAndLastElement() - { - $map = new OrderedHashMap(array('removed' => 1)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('removed', $it->key()); - $this->assertSame(1, $it->current()); - - unset($map['removed']); - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('removed', $it->key()); - $this->assertSame(1, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationIgnoresReplacementOfCurrentAndLastElement() - { - $map = new OrderedHashMap(array('replaced' => 1)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('replaced', $it->key()); - $this->assertSame(1, $it->current()); - - $map['replaced'] = 2; - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('replaced', $it->key()); - $this->assertSame(1, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationSupportsDeletionOfPreviousElement() - { - $map = new OrderedHashMap(array('removed' => 1, 'next' => 2, 'onemore' => 3)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('removed', $it->key()); - $this->assertSame(1, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('next', $it->key()); - $this->assertSame(2, $it->current()); - - unset($map['removed']); - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('next', $it->key()); - $this->assertSame(2, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('onemore', $it->key()); - $this->assertSame(3, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationIgnoresReplacementOfPreviousElement() - { - $map = new OrderedHashMap(array('replaced' => 1, 'next' => 2, 'onemore' => 3)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('replaced', $it->key()); - $this->assertSame(1, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('next', $it->key()); - $this->assertSame(2, $it->current()); - - $map['replaced'] = 4; - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('next', $it->key()); - $this->assertSame(2, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('onemore', $it->key()); - $this->assertSame(3, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testIterationSupportsDeletionOfMultiplePreviousElements() - { - $map = new OrderedHashMap(array('removed' => 1, 'alsoremoved' => 2, 'next' => 3, 'onemore' => 4)); - $it = $map->getIterator(); - - $it->rewind(); - $this->assertTrue($it->valid()); - $this->assertSame('removed', $it->key()); - $this->assertSame(1, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('alsoremoved', $it->key()); - $this->assertSame(2, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('next', $it->key()); - $this->assertSame(3, $it->current()); - - unset($map['removed'], $map['alsoremoved']); - - // iterator is unchanged - $this->assertTrue($it->valid()); - $this->assertSame('next', $it->key()); - $this->assertSame(3, $it->current()); - - // continue iteration - $it->next(); - $this->assertTrue($it->valid()); - $this->assertSame('onemore', $it->key()); - $this->assertSame(4, $it->current()); - - // end of map - $it->next(); - $this->assertFalse($it->valid()); - $this->assertNull($it->key()); - $this->assertNull($it->current()); - } - - public function testParallelIteration() - { - $map = new OrderedHashMap(array('first' => 1, 'second' => 2)); - $it1 = $map->getIterator(); - $it2 = $map->getIterator(); - - $it1->rewind(); - $this->assertTrue($it1->valid()); - $this->assertSame('first', $it1->key()); - $this->assertSame(1, $it1->current()); - - $it2->rewind(); - $this->assertTrue($it2->valid()); - $this->assertSame('first', $it2->key()); - $this->assertSame(1, $it2->current()); - - // 1: continue iteration - $it1->next(); - $this->assertTrue($it1->valid()); - $this->assertSame('second', $it1->key()); - $this->assertSame(2, $it1->current()); - - // 2: remains unchanged - $this->assertTrue($it2->valid()); - $this->assertSame('first', $it2->key()); - $this->assertSame(1, $it2->current()); - - // 1: advance to end of map - $it1->next(); - $this->assertFalse($it1->valid()); - $this->assertNull($it1->key()); - $this->assertNull($it1->current()); - - // 2: remains unchanged - $this->assertTrue($it2->valid()); - $this->assertSame('first', $it2->key()); - $this->assertSame(1, $it2->current()); - - // 2: continue iteration - $it2->next(); - $this->assertTrue($it2->valid()); - $this->assertSame('second', $it2->key()); - $this->assertSame(2, $it2->current()); - - // 1: remains unchanged - $this->assertFalse($it1->valid()); - $this->assertNull($it1->key()); - $this->assertNull($it1->current()); - - // 2: advance to end of map - $it2->next(); - $this->assertFalse($it2->valid()); - $this->assertNull($it2->key()); - $this->assertNull($it2->current()); - - // 1: remains unchanged - $this->assertFalse($it1->valid()); - $this->assertNull($it1->key()); - $this->assertNull($it1->current()); - } - - public function testCount() - { - $map = new OrderedHashMap(); - $map[] = 1; - $map['foo'] = 2; - unset($map[0]); - $map[] = 3; - - $this->assertSame(2, count($map)); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Util/FormUtil.php b/vendor/symfony/form/Symfony/Component/Form/Util/FormUtil.php deleted file mode 100644 index 0862179f5..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Util/FormUtil.php +++ /dev/null @@ -1,44 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Util; - -/** - * @author Bernhard Schussek - */ -class FormUtil -{ - /** - * This class should not be instantiated. - */ - private function __construct() - { - } - - /** - * Returns whether the given data is empty. - * - * This logic is reused multiple times throughout the processing of - * a form and needs to be consistent. PHP's keyword `empty` cannot - * be used as it also considers 0 and "0" to be empty. - * - * @param mixed $data - * - * @return bool - */ - public static function isEmpty($data) - { - // Should not do a check for array() === $data!!! - // This method is used in occurrences where arrays are - // not considered to be empty, ever. - return null === $data || '' === $data; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Util/InheritDataAwareIterator.php b/vendor/symfony/form/Symfony/Component/Form/Util/InheritDataAwareIterator.php deleted file mode 100644 index ba157b7d1..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Util/InheritDataAwareIterator.php +++ /dev/null @@ -1,28 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Util; - -/** - * Iterator that traverses an array of forms. - * - * Contrary to \ArrayIterator, this iterator recognizes changes in the original - * array during iteration. - * - * You can wrap the iterator into a {@link \RecursiveIterator} in order to - * enter any child form that inherits its parent's data and iterate the children - * of that form as well. - * - * @author Bernhard Schussek - */ -class InheritDataAwareIterator extends VirtualFormAwareIterator -{ -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Util/OrderedHashMap.php b/vendor/symfony/form/Symfony/Component/Form/Util/OrderedHashMap.php deleted file mode 100644 index 2ba53e261..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Util/OrderedHashMap.php +++ /dev/null @@ -1,190 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Util; - -/** - * A hash map which keeps track of deletions and additions. - * - * Like in associative arrays, elements can be mapped to integer or string keys. - * Unlike associative arrays, the map keeps track of the order in which keys - * were added and removed. This order is reflected during iteration. - * - * The map supports concurrent modification during iteration. That means that - * you can insert and remove elements from within a foreach loop and the - * iterator will reflect those changes accordingly. - * - * While elements that are added during the loop are recognized by the iterator, - * changed elements are not. Otherwise the loop could be infinite if each loop - * changes the current element: - * - * $map = new OrderedHashMap(); - * $map[1] = 1; - * $map[2] = 2; - * $map[3] = 3; - * - * foreach ($map as $index => $value) { - * echo "$index: $value\n" - * if (1 === $index) { - * $map[1] = 4; - * $map[] = 5; - * } - * } - * - * print_r(iterator_to_array($map)); - * - * // => 1: 1 - * // 2: 2 - * // 3: 3 - * // 4: 5 - * // Array - * // ( - * // [1] => 4 - * // [2] => 2 - * // [3] => 3 - * // [4] => 5 - * // ) - * - * The map also supports multiple parallel iterators. That means that you can - * nest foreach loops without affecting each other's iteration: - * - * foreach ($map as $index => $value) { - * foreach ($map as $index2 => $value2) { - * // ... - * } - * } - * - * @author Bernhard Schussek - * - * @since 2.2.6 - */ -class OrderedHashMap implements \ArrayAccess, \IteratorAggregate, \Countable -{ - /** - * The elements of the map, indexed by their keys. - * - * @var array - */ - private $elements = array(); - - /** - * The keys of the map in the order in which they were inserted or changed. - * - * @var array - */ - private $orderedKeys = array(); - - /** - * References to the cursors of all open iterators. - * - * @var array - */ - private $managedCursors = array(); - - /** - * Creates a new map. - * - * @param array $elements The elements to insert initially. - * - * @since 2.2.6 - */ - public function __construct(array $elements = array()) - { - $this->elements = $elements; - $this->orderedKeys = array_keys($elements); - } - - /** - * {@inheritdoc} - * - * @since 2.2.6 - */ - public function offsetExists($key) - { - return isset($this->elements[$key]); - } - - /** - * {@inheritdoc} - * - * @since 2.2.6 - */ - public function offsetGet($key) - { - if (!isset($this->elements[$key])) { - throw new \OutOfBoundsException('The offset "'.$key.'" does not exist.'); - } - - return $this->elements[$key]; - } - - /** - * {@inheritdoc} - * - * @since 2.2.6 - */ - public function offsetSet($key, $value) - { - if (null === $key || !isset($this->elements[$key])) { - if (null === $key) { - $key = array() === $this->orderedKeys - // If the array is empty, use 0 as key - ? 0 - // Imitate PHP's behavior of generating a key that equals - // the highest existing integer key + 1 - : max($this->orderedKeys) + 1; - } - - $this->orderedKeys[] = $key; - } - - $this->elements[$key] = $value; - } - - /** - * {@inheritdoc} - * - * @since 2.2.6 - */ - public function offsetUnset($key) - { - if (false !== ($position = array_search($key, $this->orderedKeys))) { - array_splice($this->orderedKeys, $position, 1); - unset($this->elements[$key]); - - foreach ($this->managedCursors as $i => $cursor) { - if ($cursor >= $position) { - --$this->managedCursors[$i]; - } - } - } - } - - /** - * {@inheritdoc} - * - * @since 2.2.6 - */ - public function getIterator() - { - return new OrderedHashMapIterator($this->elements, $this->orderedKeys, $this->managedCursors); - } - - /** - * {@inheritdoc} - * - * @since 2.2.6 - */ - public function count() - { - return count($this->elements); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Util/OrderedHashMapIterator.php b/vendor/symfony/form/Symfony/Component/Form/Util/OrderedHashMapIterator.php deleted file mode 100644 index f60662681..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Util/OrderedHashMapIterator.php +++ /dev/null @@ -1,163 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Util; - -/** - * Iterator for {@link OrderedHashMap} objects. - * - * This class is internal and should not be used. - * - * @author Bernhard Schussek - * - * @since 2.2.6 - */ -class OrderedHashMapIterator implements \Iterator -{ - /** - * @var array - */ - private $elements; - - /** - * @var array - */ - private $orderedKeys; - - /** - * @var int - */ - private $cursor; - - /** - * @var int - */ - private $cursorId; - - /** - * @var array - */ - private $managedCursors; - - /** - * @var string|int|null - */ - private $key; - - /** - * @var mixed - */ - private $current; - - /** - * Creates a new iterator. - * - * @param array $elements The elements of the map, indexed by their - * keys. - * @param array $orderedKeys The keys of the map in the order in which - * they should be iterated. - * @param array $managedCursors An array from which to reference the - * iterator's cursor as long as it is alive. - * This array is managed by the corresponding - * {@link OrderedHashMap} instance to support - * recognizing the deletion of elements. - * - * @since 2.2.6 - */ - public function __construct(array &$elements, array &$orderedKeys, array &$managedCursors) - { - $this->elements = &$elements; - $this->orderedKeys = &$orderedKeys; - $this->managedCursors = &$managedCursors; - $this->cursorId = count($managedCursors); - - $this->managedCursors[$this->cursorId] = &$this->cursor; - } - - /** - * Removes the iterator's cursors from the managed cursors of the - * corresponding {@link OrderedHashMap} instance. - * - * @since 2.2.6 - */ - public function __destruct() - { - // Use array_splice() instead of isset() to prevent holes in the - // array indices, which would break the initialization of $cursorId - array_splice($this->managedCursors, $this->cursorId, 1); - } - - /** - *{@inheritdoc} - * - * @since 2.2.6 - */ - public function current() - { - return $this->current; - } - - /** - * {@inheritdoc} - * - * @since 2.2.6 - */ - public function next() - { - ++$this->cursor; - - if (isset($this->orderedKeys[$this->cursor])) { - $this->key = $this->orderedKeys[$this->cursor]; - $this->current = $this->elements[$this->key]; - } else { - $this->key = null; - $this->current = null; - } - } - - /** - *{@inheritdoc} - * - * @since 2.2.6 - */ - public function key() - { - return $this->key; - } - - /** - *{@inheritdoc} - * - * @since 2.2.6 - */ - public function valid() - { - return null !== $this->key; - } - - /** - *{@inheritdoc} - * - * @since 2.2.6 - */ - public function rewind() - { - $this->cursor = 0; - - if (isset($this->orderedKeys[0])) { - $this->key = $this->orderedKeys[0]; - $this->current = $this->elements[$this->key]; - } else { - $this->key = null; - $this->current = null; - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Util/ServerParams.php b/vendor/symfony/form/Symfony/Component/Form/Util/ServerParams.php deleted file mode 100644 index d5367d916..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Util/ServerParams.php +++ /dev/null @@ -1,85 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Util; - -use Symfony\Component\HttpFoundation\RequestStack; - -/** - * @author Bernhard Schussek - */ -class ServerParams -{ - private $requestStack; - - public function __construct(RequestStack $requestStack = null) - { - $this->requestStack = $requestStack; - } - - /** - * Returns maximum post size in bytes. - * - * @return null|int The maximum post size in bytes - */ - public function getPostMaxSize() - { - $iniMax = strtolower($this->getNormalizedIniPostMaxSize()); - - if ('' === $iniMax) { - return; - } - - $max = ltrim($iniMax, '+'); - if (0 === strpos($max, '0x')) { - $max = intval($max, 16); - } elseif (0 === strpos($max, '0')) { - $max = intval($max, 8); - } else { - $max = (int) $max; - } - - switch (substr($iniMax, -1)) { - case 't': $max *= 1024; - case 'g': $max *= 1024; - case 'm': $max *= 1024; - case 'k': $max *= 1024; - } - - return $max; - } - - /** - * Returns the normalized "post_max_size" ini setting. - * - * @return string - */ - public function getNormalizedIniPostMaxSize() - { - return strtoupper(trim(ini_get('post_max_size'))); - } - - /** - * Returns the content length of the request. - * - * @return mixed The request content length. - */ - public function getContentLength() - { - if (null !== $this->requestStack && null !== $request = $this->requestStack->getCurrentRequest()) { - return $request->server->get('CONTENT_LENGTH'); - } - - return isset($_SERVER['CONTENT_LENGTH']) - ? (int) $_SERVER['CONTENT_LENGTH'] - : null; - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/Util/VirtualFormAwareIterator.php b/vendor/symfony/form/Symfony/Component/Form/Util/VirtualFormAwareIterator.php deleted file mode 100644 index 581e3540e..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/Util/VirtualFormAwareIterator.php +++ /dev/null @@ -1,43 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Form\Util; - -/** - * Iterator that traverses an array of forms. - * - * You can wrap the iterator into a {@link \RecursiveIterator} in order to - * enter any child form that inherits its parent's data and iterate the children - * of that form as well. - * - * @author Bernhard Schussek - * - * @deprecated Deprecated since version 2.3, to be removed in 3.0. Use - * {@link InheritDataAwareIterator} instead. - */ -class VirtualFormAwareIterator extends \IteratorIterator implements \RecursiveIterator -{ - /** - * {@inheritdoc} - */ - public function getChildren() - { - return new static($this->current()); - } - - /** - *{@inheritdoc} - */ - public function hasChildren() - { - return (bool) $this->current()->getConfig()->getInheritData(); - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/composer.json b/vendor/symfony/form/Symfony/Component/Form/composer.json deleted file mode 100644 index 4414f3966..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/composer.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "name": "symfony/form", - "type": "library", - "description": "Symfony Form Component", - "keywords": [], - "homepage": "http://symfony.com", - "license": "MIT", - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "http://symfony.com/contributors" - } - ], - "require": { - "php": ">=5.3.3", - "symfony/event-dispatcher": "~2.1", - "symfony/intl": "~2.3", - "symfony/options-resolver": "~2.6", - "symfony/property-access": "~2.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7", - "doctrine/collections": "~1.0", - "symfony/validator": "~2.6", - "symfony/http-foundation": "~2.2", - "symfony/http-kernel": "~2.4", - "symfony/security-csrf": "~2.4", - "symfony/translation": "~2.0,>=2.0.5" - }, - "suggest": { - "symfony/validator": "For form validation.", - "symfony/security-csrf": "For protecting forms against CSRF attacks.", - "symfony/twig-bridge": "For templating with Twig.", - "symfony/framework-bundle": "For templating with PHP." - }, - "autoload": { - "psr-0": { "Symfony\\Component\\Form\\": "" } - }, - "target-dir": "Symfony/Component/Form", - "minimum-stability": "dev", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - } -} diff --git a/vendor/symfony/form/Symfony/Component/Form/phpunit.xml.dist b/vendor/symfony/form/Symfony/Component/Form/phpunit.xml.dist deleted file mode 100644 index 104aee4b0..000000000 --- a/vendor/symfony/form/Symfony/Component/Form/phpunit.xml.dist +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - ./Tests/ - - - - - - ./ - - ./Tests - ./vendor - - - - diff --git a/vendor/symfony/intl/Symfony/Component/Intl/.gitignore b/vendor/symfony/intl/Symfony/Component/Intl/.gitignore deleted file mode 100644 index c49a5d8df..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -vendor/ -composer.lock -phpunit.xml diff --git a/vendor/symfony/intl/Symfony/Component/Intl/CONTRIBUTING.md b/vendor/symfony/intl/Symfony/Component/Intl/CONTRIBUTING.md deleted file mode 100644 index 971e0af7f..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/CONTRIBUTING.md +++ /dev/null @@ -1,91 +0,0 @@ -Contributing to the Intl component -================================== - -A very good way of contributing to the Intl component is by updating the -included data for the ICU version you have installed on your system. - -Preparation ------------ - -To prepare, you need to install the development dependencies of the component. - - $ cd /path/to/Symfony/Component/Intl - $ composer install - -Determining your ICU version ---------------------------- - -The ICU version installed in your PHP environment can be found by running -icu-version.php: - - $ php Resources/bin/icu-version.php - -Updating the ICU data ---------------------- - -To update the data files, run the update-icu-component.php script: - - $ php Resources/bin/update-icu-component.php - -The script needs the binaries "svn" and "make" to be available on your system. -It will download the latest version of the ICU sources for the ICU version -installed in your PHP environment. The script will then compile the "genrb" -binary and use it to compile the ICU data files to binaries. The binaries are -copied to the Resources/ directory of the Icu component found in the -vendor/symfony/icu/ directory. - -Updating the stub data ----------------------- - -In the previous step you updated the Icu component for the ICU version -installed on your system. If you are using the latest ICU version, you should -also create the stub data files which will be used by people who don't have -the intl extension installed. - -To update the stub files, run the update-stubs.php script: - - $ php Resources/bin/update-stubs.php - -The script will fail if you don't have the latest ICU version. If you want to -upgrade the ICU version, adjust the return value of the -`Intl::getIcuStubVersion()` before you run the script. - -The script creates copies of the binary resource bundles in the Icu component -and stores them in the Resources/ directory of the Intl component. The copies -are made for the locale "en" only and are stored in .php files, so that they -can be read even if the intl extension is not available. - -Creating a pull request ------------------------ - -You need to create up to two pull requests: - -* If you updated the Icu component, you need to push that change and create a - pull request in the `symfony/Icu` repository. Make sure to submit the pull - request to the correct master branch. If you updated the ICU data for version - 4.8, your pull request goes to branch `48-master`, for version 49 to - `49-master` and so on. - -* If you updated the stub files of the Intl component, you need to push that - change and create a pull request in the `symfony/symfony` repository. The - pull request should be based on the `master` branch. - -Combining .res files to a .dat-package --------------------------------------- - -The individual *.res files can be combined into a single .dat-file. -Unfortunately, PHP's `ResourceBundle` class is currently not able to handle -.dat-files. - -Once it is, the following steps have to be followed to build the .dat-file: - -1. Package the resource bundles into a single file - - $ find . -name *.res | sed -e "s/\.\///g" > packagelist.txt - $ pkgdata -p region -T build -d . packagelist.txt - -2. Clean up - - $ rm -rf build packagelist.txt - -3. You can now move region.dat to replace the version bundled with Symfony. diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Collator/Collator.php b/vendor/symfony/intl/Symfony/Component/Intl/Collator/Collator.php deleted file mode 100644 index 272a6c13e..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Collator/Collator.php +++ /dev/null @@ -1,295 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Collator; - -use Symfony\Component\Intl\Exception\MethodNotImplementedException; -use Symfony\Component\Intl\Exception\MethodArgumentValueNotImplementedException; -use Symfony\Component\Intl\Globals\IntlGlobals; -use Symfony\Component\Intl\Locale\Locale; - -/** - * Replacement for PHP's native {@link \Collator} class. - * - * The only methods currently supported in this class are: - * - * - {@link \__construct} - * - {@link create} - * - {@link asort} - * - {@link getErrorCode} - * - {@link getErrorMessage} - * - {@link getLocale} - * - * @author Igor Wiedler - * @author Bernhard Schussek - */ -class Collator -{ - /* Attribute constants */ - const FRENCH_COLLATION = 0; - const ALTERNATE_HANDLING = 1; - const CASE_FIRST = 2; - const CASE_LEVEL = 3; - const NORMALIZATION_MODE = 4; - const STRENGTH = 5; - const HIRAGANA_QUATERNARY_MODE = 6; - const NUMERIC_COLLATION = 7; - - /* Attribute constants values */ - const DEFAULT_VALUE = -1; - - const PRIMARY = 0; - const SECONDARY = 1; - const TERTIARY = 2; - const DEFAULT_STRENGTH = 2; - const QUATERNARY = 3; - const IDENTICAL = 15; - - const OFF = 16; - const ON = 17; - - const SHIFTED = 20; - const NON_IGNORABLE = 21; - - const LOWER_FIRST = 24; - const UPPER_FIRST = 25; - - /* Sorting options */ - const SORT_REGULAR = 0; - const SORT_NUMERIC = 2; - const SORT_STRING = 1; - - /** - * Constructor. - * - * @param string $locale The locale code. The only currently supported locale is "en". - * - * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed - */ - public function __construct($locale) - { - if ('en' != $locale) { - throw new MethodArgumentValueNotImplementedException(__METHOD__, 'locale', $locale, 'Only the locale "en" is supported'); - } - } - - /** - * Static constructor. - * - * @param string $locale The locale code. The only currently supported locale is "en". - * - * @return Collator - * - * @throws MethodArgumentValueNotImplementedException When $locale different than "en" is passed - */ - public static function create($locale) - { - return new self($locale); - } - - /** - * Sort array maintaining index association. - * - * @param array &$array Input array - * @param int $sortFlag Flags for sorting, can be one of the following: - * Collator::SORT_REGULAR - compare items normally (don't change types) - * Collator::SORT_NUMERIC - compare items numerically - * Collator::SORT_STRING - compare items as strings - * - * @return bool True on success or false on failure - */ - public function asort(&$array, $sortFlag = self::SORT_REGULAR) - { - $intlToPlainFlagMap = array( - self::SORT_REGULAR => \SORT_REGULAR, - self::SORT_NUMERIC => \SORT_NUMERIC, - self::SORT_STRING => \SORT_STRING, - ); - - $plainSortFlag = isset($intlToPlainFlagMap[$sortFlag]) ? $intlToPlainFlagMap[$sortFlag] : self::SORT_REGULAR; - - return asort($array, $plainSortFlag); - } - - /** - * Not supported. Compare two Unicode strings. - * - * @param string $str1 The first string to compare - * @param string $str2 The second string to compare - * - * @return bool|int Return the comparison result or false on failure: - * 1 if $str1 is greater than $str2 - * 0 if $str1 is equal than $str2 - * -1 if $str1 is less than $str2 - * - * @see http://www.php.net/manual/en/collator.compare.php - * - * @throws MethodNotImplementedException - */ - public function compare($str1, $str2) - { - throw new MethodNotImplementedException(__METHOD__); - } - - /** - * Not supported. Get a value of an integer collator attribute. - * - * @param int $attr An attribute specifier, one of the attribute constants - * - * @return bool|int The attribute value on success or false on error - * - * @see http://www.php.net/manual/en/collator.getattribute.php - * - * @throws MethodNotImplementedException - */ - public function getAttribute($attr) - { - throw new MethodNotImplementedException(__METHOD__); - } - - /** - * Returns collator's last error code. Always returns the U_ZERO_ERROR class constant value. - * - * @return int The error code from last collator call - */ - public function getErrorCode() - { - return IntlGlobals::U_ZERO_ERROR; - } - - /** - * Returns collator's last error message. Always returns the U_ZERO_ERROR_MESSAGE class constant value. - * - * @return string The error message from last collator call - */ - public function getErrorMessage() - { - return 'U_ZERO_ERROR'; - } - - /** - * Returns the collator's locale. - * - * @param int $type Not supported. The locale name type to return (Locale::VALID_LOCALE or Locale::ACTUAL_LOCALE) - * - * @return string The locale used to create the collator. Currently always - * returns "en". - */ - public function getLocale($type = Locale::ACTUAL_LOCALE) - { - return 'en'; - } - - /** - * Not supported. Get sorting key for a string. - * - * @param string $string The string to produce the key from - * - * @return string The collation key for $string - * - * @see http://www.php.net/manual/en/collator.getsortkey.php - * - * @throws MethodNotImplementedException - */ - public function getSortKey($string) - { - throw new MethodNotImplementedException(__METHOD__); - } - - /** - * Not supported. Get current collator's strength. - * - * @return bool|int The current collator's strength or false on failure - * - * @see http://www.php.net/manual/en/collator.getstrength.php - * - * @throws MethodNotImplementedException - */ - public function getStrength() - { - throw new MethodNotImplementedException(__METHOD__); - } - - /** - * Not supported. Set a collator's attribute. - * - * @param int $attr An attribute specifier, one of the attribute constants - * @param int $val The attribute value, one of the attribute value constants - * - * @return bool True on success or false on failure - * - * @see http://www.php.net/manual/en/collator.setattribute.php - * - * @throws MethodNotImplementedException - */ - public function setAttribute($attr, $val) - { - throw new MethodNotImplementedException(__METHOD__); - } - - /** - * Not supported. Set the collator's strength. - * - * @param int $strength Strength to set, possible values: - * Collator::PRIMARY - * Collator::SECONDARY - * Collator::TERTIARY - * Collator::QUATERNARY - * Collator::IDENTICAL - * Collator::DEFAULT - * - * @return bool True on success or false on failure - * - * @see http://www.php.net/manual/en/collator.setstrength.php - * - * @throws MethodNotImplementedException - */ - public function setStrength($strength) - { - throw new MethodNotImplementedException(__METHOD__); - } - - /** - * Not supported. Sort array using specified collator and sort keys. - * - * @param array &$arr Array of strings to sort - * - * @return bool True on success or false on failure - * - * @see http://www.php.net/manual/en/collator.sortwithsortkeys.php - * - * @throws MethodNotImplementedException - */ - public function sortWithSortKeys(&$arr) - { - throw new MethodNotImplementedException(__METHOD__); - } - - /** - * Not supported. Sort array using specified collator. - * - * @param array &$arr Array of string to sort - * @param int $sortFlag Optional sorting type, one of the following: - * Collator::SORT_REGULAR - * Collator::SORT_NUMERIC - * Collator::SORT_STRING - * - * @return bool True on success or false on failure - * - * @see http://www.php.net/manual/en/collator.sort.php - * - * @throws MethodNotImplementedException - */ - public function sort(&$arr, $sortFlag = self::SORT_REGULAR) - { - throw new MethodNotImplementedException(__METHOD__); - } -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Compiler/BundleCompilerInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Compiler/BundleCompilerInterface.php deleted file mode 100644 index 8c9d233d9..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Compiler/BundleCompilerInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Compiler; - -/** - * Compiles a resource bundle. - * - * @author Bernhard Schussek - * - * @internal - */ -interface BundleCompilerInterface -{ - /** - * Compiles a resource bundle at the given source to the given target - * directory. - * - * @param string $sourcePath - * @param string $targetDir - */ - public function compile($sourcePath, $targetDir); -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php deleted file mode 100644 index cf8ee1a74..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Compiler/GenrbCompiler.php +++ /dev/null @@ -1,73 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Compiler; - -use Symfony\Component\Intl\Exception\RuntimeException; - -/** - * Compiles .txt resource bundles to binary .res files. - * - * @author Bernhard Schussek - * - * @internal - */ -class GenrbCompiler implements BundleCompilerInterface -{ - /** - * @var string The path to the "genrb" executable. - */ - private $genrb; - - /** - * Creates a new compiler based on the "genrb" executable. - * - * @param string $genrb Optional. The path to the "genrb" executable. - * @param string $envVars Optional. Environment variables to be loaded when - * running "genrb". - * - * @throws RuntimeException If the "genrb" cannot be found. - */ - public function __construct($genrb = 'genrb', $envVars = '') - { - exec('which '.$genrb, $output, $status); - - if (0 !== $status) { - throw new RuntimeException(sprintf( - 'The command "%s" is not installed', - $genrb - )); - } - - $this->genrb = ($envVars ? $envVars.' ' : '').$genrb; - } - - /** - * {@inheritdoc} - */ - public function compile($sourcePath, $targetDir) - { - if (is_dir($sourcePath)) { - $sourcePath .= '/*.txt'; - } - - exec($this->genrb.' --quiet -e UTF-8 -d '.$targetDir.' '.$sourcePath, $output, $status); - - if ($status !== 0) { - throw new RuntimeException(sprintf( - 'genrb failed with status %d while compiling %s to %s.', - $status, - $sourcePath, - $targetDir - )); - } - } -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BufferedBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BufferedBundleReader.php deleted file mode 100644 index fede9cdb4..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BufferedBundleReader.php +++ /dev/null @@ -1,56 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Reader; - -use Symfony\Component\Intl\Data\Util\RingBuffer; - -/** - * @author Bernhard Schussek - * - * @internal - */ -class BufferedBundleReader implements BundleReaderInterface -{ - /** - * @var BundleReaderInterface - */ - private $reader; - - private $buffer; - - /** - * Buffers a given reader. - * - * @param BundleReaderInterface $reader The reader to buffer. - * @param int $bufferSize The number of entries to store - * in the buffer. - */ - public function __construct(BundleReaderInterface $reader, $bufferSize) - { - $this->reader = $reader; - $this->buffer = new RingBuffer($bufferSize); - } - - /** - * {@inheritdoc} - */ - public function read($path, $locale) - { - $hash = $path.'//'.$locale; - - if (!isset($this->buffer[$hash])) { - $this->buffer[$hash] = $this->reader->read($path, $locale); - } - - return $this->buffer[$hash]; - } -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReader.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReader.php deleted file mode 100644 index 5f991bfe2..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReader.php +++ /dev/null @@ -1,184 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Reader; - -use Symfony\Component\Intl\Exception\MissingResourceException; -use Symfony\Component\Intl\Exception\OutOfBoundsException; -use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException; -use Symfony\Component\Intl\Locale; -use Symfony\Component\Intl\Data\Util\RecursiveArrayAccess; - -/** - * Default implementation of {@link BundleEntryReaderInterface}. - * - * @author Bernhard Schussek - * - * @see BundleEntryReaderInterface - * - * @internal - */ -class BundleEntryReader implements BundleEntryReaderInterface -{ - /** - * @var BundleReaderInterface - */ - private $reader; - - /** - * A mapping of locale aliases to locales. - * - * @var array - */ - private $localeAliases = array(); - - /** - * Creates an entry reader based on the given resource bundle reader. - * - * @param BundleReaderInterface $reader A resource bundle reader to use. - */ - public function __construct(BundleReaderInterface $reader) - { - $this->reader = $reader; - } - - /** - * Stores a mapping of locale aliases to locales. - * - * This mapping is used when reading entries and merging them with their - * fallback locales. If an entry is read for a locale alias (e.g. "mo") - * that points to a locale with a fallback locale ("ro_MD"), the reader - * can continue at the correct fallback locale ("ro"). - * - * @param array $localeAliases A mapping of locale aliases to locales - */ - public function setLocaleAliases($localeAliases) - { - $this->localeAliases = $localeAliases; - } - - /** - * {@inheritdoc} - */ - public function read($path, $locale) - { - return $this->reader->read($path, $locale); - } - - /** - * {@inheritdoc} - */ - public function readEntry($path, $locale, array $indices, $fallback = true) - { - $entry = null; - $isMultiValued = false; - $readSucceeded = false; - $exception = null; - $currentLocale = $locale; - $testedLocales = array(); - - while (null !== $currentLocale) { - // Resolve any aliases to their target locales - if (isset($this->localeAliases[$currentLocale])) { - $currentLocale = $this->localeAliases[$currentLocale]; - } - - try { - $data = $this->reader->read($path, $currentLocale); - $currentEntry = RecursiveArrayAccess::get($data, $indices); - $readSucceeded = true; - - $isCurrentTraversable = $currentEntry instanceof \Traversable; - $isCurrentMultiValued = $isCurrentTraversable || is_array($currentEntry); - - // Return immediately if fallback is disabled or we are dealing - // with a scalar non-null entry - if (!$fallback || (!$isCurrentMultiValued && null !== $currentEntry)) { - return $currentEntry; - } - - // ========================================================= - // Fallback is enabled, entry is either multi-valued or NULL - // ========================================================= - - // If entry is multi-valued, convert to array - if ($isCurrentTraversable) { - $currentEntry = iterator_to_array($currentEntry); - } - - // If previously read entry was multi-valued too, merge them - if ($isCurrentMultiValued && $isMultiValued) { - $currentEntry = array_merge($currentEntry, $entry); - } - - // Keep the previous entry if the current entry is NULL - if (null !== $currentEntry) { - $entry = $currentEntry; - } - - // If this or the previous entry was multi-valued, we are dealing - // with a merged, multi-valued entry now - $isMultiValued = $isMultiValued || $isCurrentMultiValued; - } catch (ResourceBundleNotFoundException $e) { - // Continue if there is a fallback locale for the current - // locale - $exception = $e; - } catch (OutOfBoundsException $e) { - // Remember exception and rethrow if we cannot find anything in - // the fallback locales either - $exception = $e; - } - - // Remember which locales we tried - $testedLocales[] = $currentLocale; - - // Check whether fallback is allowed - if (!$fallback) { - break; - } - - // Then determine fallback locale - $currentLocale = Locale::getFallback($currentLocale); - } - - // Multi-valued entry was merged - if ($isMultiValued) { - return $entry; - } - - // Entry is still NULL, but no read error occurred - if ($readSucceeded) { - return $entry; - } - - // Entry is still NULL, read error occurred. Throw an exception - // containing the detailed path and locale - $errorMessage = sprintf( - 'Couldn\'t read the indices [%s] for the locale "%s" in "%s".', - implode('][', $indices), - $locale, - $path - ); - - // Append fallback locales, if any - if (count($testedLocales) > 1) { - // Remove original locale - array_shift($testedLocales); - - $errorMessage .= sprintf( - ' The indices also couldn\'t be found for the fallback locale(s) "%s".', - implode('", "', $testedLocales) - ); - } - - throw new MissingResourceException($errorMessage, 0, $exception); - } -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReaderInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReaderInterface.php deleted file mode 100644 index 8a4ecd8e6..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleEntryReaderInterface.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Reader; - -use Symfony\Component\Intl\Exception\MissingResourceException; - -/** - * Reads individual entries of a resource file. - * - * @author Bernhard Schussek - * - * @internal - */ -interface BundleEntryReaderInterface extends BundleReaderInterface -{ - /** - * Reads an entry from a resource bundle. - * - * An entry can be selected from the resource bundle by passing the path - * to that entry in the bundle. For example, if the bundle is structured - * like this: - * - * TopLevel - * NestedLevel - * Entry: Value - * - * Then the value can be read by calling: - * - * $reader->readEntry('...', 'en', array('TopLevel', 'NestedLevel', 'Entry')); - * - * @param string $path The path to the resource bundle. - * @param string $locale The locale to read. - * @param string[] $indices The indices to read from the bundle. - * @param bool $fallback Whether to merge the value with the value from - * the fallback locale (e.g. "en" for "en_GB"). - * Only applicable if the result is multivalued - * (i.e. array or \ArrayAccess) or cannot be found - * in the requested locale. - * - * @return mixed Returns an array or {@link \ArrayAccess} instance for - * complex data and a scalar value for simple data. - * - * @throws MissingResourceException If the indices cannot be accessed - */ - public function readEntry($path, $locale, array $indices, $fallback = true); -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleReaderInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleReaderInterface.php deleted file mode 100644 index 7257b0df7..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/BundleReaderInterface.php +++ /dev/null @@ -1,33 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Reader; - -/** - * Reads resource bundle files. - * - * @author Bernhard Schussek - * - * @internal - */ -interface BundleReaderInterface -{ - /** - * Reads a resource bundle. - * - * @param string $path The path to the resource bundle. - * @param string $locale The locale to read. - * - * @return mixed Returns an array or {@link \ArrayAccess} instance for - * complex data, a scalar value otherwise. - */ - public function read($path, $locale); -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/IntlBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/IntlBundleReader.php deleted file mode 100644 index 9f800ccac..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/IntlBundleReader.php +++ /dev/null @@ -1,55 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Reader; - -use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException; -use Symfony\Component\Intl\Data\Util\ArrayAccessibleResourceBundle; - -/** - * Reads binary .res resource bundles. - * - * @author Bernhard Schussek - * - * @internal - */ -class IntlBundleReader implements BundleReaderInterface -{ - /** - * {@inheritdoc} - */ - public function read($path, $locale) - { - // Point for future extension: Modify this class so that it works also - // if the \ResourceBundle class is not available. - try { - // Never enable fallback. We want to know if a bundle cannot be found - $bundle = new \ResourceBundle($locale, $path, false); - } catch (\Exception $e) { - // HHVM compatibility: constructor throws on invalid resource - $bundle = null; - } - - // The bundle is NULL if the path does not look like a resource bundle - // (i.e. contain a bunch of *.res files) - if (null === $bundle) { - throw new ResourceBundleNotFoundException(sprintf( - 'The resource bundle "%s/%s.res" could not be found.', - $path, - $locale - )); - } - - // Other possible errors are U_USING_FALLBACK_WARNING and U_ZERO_ERROR, - // which are OK for us. - return new ArrayAccessibleResourceBundle($bundle); - } -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php deleted file mode 100644 index 197384348..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/JsonBundleReader.php +++ /dev/null @@ -1,89 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Reader; - -use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException; -use Symfony\Component\Intl\Exception\RuntimeException; - -/** - * Reads .json resource bundles. - * - * @author Bernhard Schussek - * - * @internal - */ -class JsonBundleReader implements BundleReaderInterface -{ - /** - * {@inheritdoc} - */ - public function read($path, $locale) - { - $fileName = $path.'/'.$locale.'.json'; - - if (!file_exists($fileName)) { - throw new ResourceBundleNotFoundException(sprintf( - 'The resource bundle "%s/%s.json" does not exist.', - $path, - $locale - )); - } - - if (!is_file($fileName)) { - throw new RuntimeException(sprintf( - 'The resource bundle "%s/%s.json" is not a file.', - $path, - $locale - )); - } - - $data = json_decode(file_get_contents($fileName), true); - - if (null === $data) { - throw new RuntimeException(sprintf( - 'The resource bundle "%s/%s.json" contains invalid JSON: %s', - $path, - $locale, - self::getLastJsonError() - )); - } - - return $data; - } - - /** - * @return string The last error message created by {@link json_decode()} - * - * @link http://de2.php.net/manual/en/function.json-last-error-msg.php#113243 - */ - private static function getLastJsonError() - { - if (function_exists('json_last_error_msg')) { - return json_last_error_msg(); - } - - static $errors = array( - JSON_ERROR_NONE => null, - JSON_ERROR_DEPTH => 'Maximum stack depth exceeded', - JSON_ERROR_STATE_MISMATCH => 'Underflow or the modes mismatch', - JSON_ERROR_CTRL_CHAR => 'Unexpected control character found', - JSON_ERROR_SYNTAX => 'Syntax error, malformed JSON', - JSON_ERROR_UTF8 => 'Malformed UTF-8 characters, possibly incorrectly encoded', - ); - - $error = json_last_error(); - - return array_key_exists($error, $errors) - ? $errors[$error] - : sprintf('Unknown error (%s)', $error); - } -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php deleted file mode 100644 index 57391ce01..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Reader/PhpBundleReader.php +++ /dev/null @@ -1,51 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Reader; - -use Symfony\Component\Intl\Exception\ResourceBundleNotFoundException; -use Symfony\Component\Intl\Exception\RuntimeException; - -/** - * Reads .php resource bundles. - * - * @author Bernhard Schussek - * - * @internal - */ -class PhpBundleReader implements BundleReaderInterface -{ - /** - * {@inheritdoc} - */ - public function read($path, $locale) - { - $fileName = $path.'/'.$locale.'.php'; - - if (!file_exists($fileName)) { - throw new ResourceBundleNotFoundException(sprintf( - 'The resource bundle "%s/%s.php" does not exist.', - $path, - $locale - )); - } - - if (!is_file($fileName)) { - throw new RuntimeException(sprintf( - 'The resource bundle "%s/%s.php" is not a file.', - $path, - $locale - )); - } - - return include $fileName; - } -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/BundleWriterInterface.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/BundleWriterInterface.php deleted file mode 100644 index e85376dc6..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/BundleWriterInterface.php +++ /dev/null @@ -1,31 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Writer; - -/** - * Writes resource bundle files. - * - * @author Bernhard Schussek - * - * @internal - */ -interface BundleWriterInterface -{ - /** - * Writes data to a resource bundle. - * - * @param string $path The path to the resource bundle. - * @param string $locale The locale to (over-)write. - * @param mixed $data The data to write. - */ - public function write($path, $locale, $data); -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php deleted file mode 100644 index 6a79340c6..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/JsonBundleWriter.php +++ /dev/null @@ -1,48 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Writer; - -/** - * Writes .json resource bundles. - * - * @author Bernhard Schussek - * - * @internal - */ -class JsonBundleWriter implements BundleWriterInterface -{ - /** - * {@inheritdoc} - */ - public function write($path, $locale, $data) - { - if ($data instanceof \Traversable) { - $data = iterator_to_array($data); - } - - array_walk_recursive($data, function (&$value) { - if ($value instanceof \Traversable) { - $value = iterator_to_array($value); - } - }); - - if (PHP_VERSION_ID >= 50400) { - // Use JSON_PRETTY_PRINT so that we can see what changed in Git diffs - file_put_contents( - $path.'/'.$locale.'.json', - json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)."\n" - ); - } else { - file_put_contents($path.'/'.$locale.'.json', json_encode($data)."\n"); - } - } -} diff --git a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php b/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php deleted file mode 100644 index a29972cd0..000000000 --- a/vendor/symfony/intl/Symfony/Component/Intl/Data/Bundle/Writer/PhpBundleWriter.php +++ /dev/null @@ -1,53 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Symfony\Component\Intl\Data\Bundle\Writer; - -/** - * Writes .php resource bundles. - * - * @author Bernhard Schussek - * - * @internal - */ -class PhpBundleWriter implements BundleWriterInterface -{ - /** - * {@inheritdoc} - */ - public function write($path, $locale, $data) - { - $template = <<