diff --git a/.gitignore b/.gitignore index 74bac05da..26da5cd05 100755 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ npm-debug.log **/.DS_Store includes/freemius/assets/img/caldera-forms.png bin/caldera-forms + +wordpress/* +wp-content/* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 9736531fb..ccefc4088 100755 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,10 @@ notifications: on_failure: change -cache: false +cache: + directories: + - node_modules + - vendor env: - WP_VERSION=latest diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 24fe0fa7f..000000000 --- a/Dockerfile +++ /dev/null @@ -1,26 +0,0 @@ -ARG PHP_IMAGE_TAG -FROM php:$PHP_IMAGE_TAG -ARG WORDPRESS_DB_PASSWORD -ENV WORDPRESS_DB_PASSWORD=$WORDPRESS_DB_PASSWORD -ARG WORDPRESS_VERSION -RUN echo "http://dl-3.alpinelinux.org/alpine/edge/main" >> /etc/apk/repositories &&\ - apk add --update --no-cache subversion mysql mysql-client git bash g++ make autoconf && \ - set -ex; \ - docker-php-ext-install mysqli pdo pdo_mysql pcntl \ - && php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" \ - && php composer-setup.php --install-dir=/usr/bin --filename=composer \ - && docker-php-source extract \ - && docker-php-source delete \ - && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \ - && rm -rf /tmp/* \ - && curl -L https://github.com/vishnubob/wait-for-it/raw/master/wait-for-it.sh > /tmp/wait-for-it.sh \ - && chmod +x /tmp/wait-for-it.sh -WORKDIR /tmp -COPY ./bin/install-wp-tests.sh /tmp/install-wp-tests.sh -RUN /tmp/install-wp-tests.sh wordpress_test root $WORDPRESS_DB_PASSWORD mysql $WORDPRESS_VERSION -COPY ./db-error.php /tmp/wordpress/wp-content/db-error.php -WORKDIR /wordpress -COPY composer.json /wordpress -RUN composer install -COPY . /wordpress -CMD /tmp/wait-for-it.sh mysql:3306 -- bin/install-db.sh wordpress_test root $WORDPRESS_DB_PASSWORD mysql diff --git a/README.md b/README.md index afdc79777..3308802ff 100755 --- a/README.md +++ b/README.md @@ -60,7 +60,11 @@ This is the old stuff, built with grunt. ### Test Environment All PHP tests are based off of the WordPress "unit" test suite, and therefore need a full WordPress test environment. The install script in '/bin' is pretty standard and should work with VVV or whatever. -Alternatively, because this, isn't 2014, you can use the provided Docker environment. +We provide a docker-based development environment. It is recommended that you use this environment because the setup is scripted and all of the tests can be run with it. + +The local server is [http://localhost:8228](http://localhost:8228) + + #### Requirements * Docker - [Installation documentation](https://docs.docker.com/install/) @@ -69,18 +73,42 @@ Alternatively, because this, isn't 2014, you can use the provided Docker environ * npm - [Installation documentation](https://www.npmjs.com/get-npm) + +#### Install Test Environment +* Make sure all dependencies are installed: + - `composer update && npm update` +* Install local development environment + - `composer wp:install + - Runs installer. Make sure Docker is running. May take awhile. + - `composer wp:activate` + - Activates Caldera Forms and Gutenberg and sets permalinks. +* Go to [http://localhost:8228](http://localhost:8228) and make sure you have a WordPress site and can login. + - Username: admin + - password: password + +* Install the tests forms and pages for them. + - `composer wp:setup-tests` + - Adds forms needed for e2e tests and one page for each form. Useful for manual QA as well. + ### Test Structures * PHP tests go in /tests and are run using phpunit -* JavaScript tests go in clients/tests -- Unit tests go in clients/tests/unit and are run using [Jest](https://facebook.github.io/jest/docs/en/getting-started.html) -- Unit tests must have the word test in file name. For example, `formConfig.test.js` + - Integration tests, which require WordPress, are in tests. These used to be all the tests we have. + - Unit tests -- isolated tests that do NOT require WordPress -- go in `tests/Unit`. + - The trait `calderawp\calderaforms\Util\Traits` should have all of the factories used for integration and unit tests (aspirational.) +* JavaScript UNIT tests go in clients/tests + - Unit tests go in clients/tests/unit and are run using [Jest](https://facebook.github.io/jest/docs/en/getting-started.html) + - Unit tests must have the word test in file name. For example, `formConfig.test.js` +* End to end tests go in `cypress/integration` amd are written using [Cypress](https://cypress.io) + - See our [Cypress README for testing](./cypress/README.md) #### Commands -* `composer wp-install` - Installs Docker-based test environment. -* `composer wp-start` - Starts Docker-based test environment. -* `composer wp-tests` - Runs phpunit inside of Docker container. -* `composer wp-stop` - Stops Docker-based test environment, without destroying containers. -* `composer wp-remove` - Stops Docker-based test environment and destroys containers. +* `composer wp:install` - Installs Docker-based test environment. +* `composer wp:start` - Starts Docker-based test environment. +* `composer wp:activate` - Activate plugins in Docker-based environment. +* `composer wp:tests` - Runs the PHP integration tests using phpunit inside Docker-based environment . +* `composer wp:stop` - Stops Docker-based test environment, without destroying containers. +* `composer wp:destroy` - Removes (including the database) the test environment and destroys containers. +* `composer wp:setup-tests` - Adds test forms and puts them on pages. * `npm test` - Run JavaScript test watcher * `npm run test:once` - Run JavaScript unit tests once diff --git a/bin/activate-plugin.sh b/bin/activate-plugin.sh new file mode 100644 index 000000000..6438a9fa6 --- /dev/null +++ b/bin/activate-plugin.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env bash +docker-compose run --rm cli wp plugin activate caldera-forms +docker-compose run --rm cli wp plugin activate gutenberg +exit 0; +# Install test form importer/Ghost Inspector runner +docker-compose run --rm cli wp plugin activate ghost-runner/plugin +cd wp-content/plugins/ghost-runner +if [ ! -d wp-content/plugins/ghost-runner/vendor ] +then + composer install +fi + +if [ -d wp-content/plugins/ghost-runner/vendor ] +then + composer update --no-dev +fi \ No newline at end of file diff --git a/bin/install-docker.sh b/bin/install-docker.sh new file mode 100755 index 000000000..709fcec4e --- /dev/null +++ b/bin/install-docker.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +#Set WordPress version +WP_VERSION=${1-latest} + +# Exit if any command fails +set -e + +# Include useful functions +. "$(dirname "$0")/includes.sh" + +# Check that Docker is installed +if ! command_exists "docker"; then + echo -e $(error_message "Docker doesn't seem to be installed. Please head on over to the Docker site to download it: $(action_format "https://www.docker.com/community-edition#/download")") + exit 1 +fi + +# Check that Docker is running +if ! docker info >/dev/null 2>&1; then + echo -e $(error_message "Docker isn't running. Please check that you've started your Docker app, and see it in your system tray.") + exit 1 +fi + +# Stop existing containers +echo -e $(status_message "Stopping Docker containers...") +docker-compose down --remove-orphans >/dev/null 2>&1 + +# Download image updates +echo -e $(status_message "Downloading Docker image updates...") +docker-compose pull --parallel + +# Launch the containers +echo -e $(status_message "Starting Docker containers...") +docker-compose up -d >/dev/null + +HOST_PORT=$(docker-compose port wordpress 80 | awk -F : '{printf $2}') + +# Wait until the docker containers are setup properely +echo -en $(status_message "Attempting to connect to wordpress...") +until $(curl -L http://localhost:$HOST_PORT -so - 2>&1 | grep -q "WordPress"); do + echo -n '.' + sleep 3 +done +echo '' + +# Install WordPress +echo -e $(status_message "Installing WordPress...") +docker-compose run --rm -u 33 cli core install --url=localhost:$HOST_PORT --title=TestSite --admin_user=admin --admin_password=password --admin_email=test@test.com >/dev/null +# Check for WordPress updates, just in case the WordPress image isn't up to date. +docker-compose run --rm -u 33 cli core update >/dev/null + +# If the 'wordpress' volume wasn't during the down/up earlier, but the post port has changed, we need to update it. +CURRENT_URL=$(docker-compose run -T --rm cli option get siteurl) +if [ "$CURRENT_URL" != "http://localhost:$HOST_PORT" ]; then + docker-compose run --rm cli option update home "http://localhost:$HOST_PORT" >/dev/null + docker-compose run --rm cli option update siteurl "http://localhost:$HOST_PORT" >/dev/null +fi +echo -e $(status_message "Server is running at:") +echo -e $(status_message "http://localhost:$HOST_PORT") + +# Install Composer +echo -e $(status_message "Installing and updating Composer modules...") +docker-compose run --rm composer install + +# Install the PHPUnit test scaffolding +echo -e $(status_message "Installing PHPUnit test scaffolding...") +docker-compose run --rm wordpress_phpunit /app/bin/install-wp-tests.sh wordpress_test root example mysql "${WP_VERSION}" false >/dev/null +echo -e $(status_message "Completed installing tests") + + + diff --git a/bin/setup-test-forms.sh b/bin/setup-test-forms.sh new file mode 100644 index 000000000..5fd21673e --- /dev/null +++ b/bin/setup-test-forms.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash +docker-compose run --rm cli wp cf import-test-forms +docker-compose run --rm cli wp cf create-test-pages \ No newline at end of file diff --git a/caldera-core.php b/caldera-core.php index d28b1aabc..6d5facbde 100755 --- a/caldera-core.php +++ b/caldera-core.php @@ -119,14 +119,13 @@ function caldera_forms_load() * @since 1.3.5.3 */ do_action('caldera_forms_includes_complete'); - caldera_forms_freemius()->add_filter('plugin_icon', 'caldera_forms_freemius_icon_path'); } add_action('plugins_loaded', array('Caldera_Forms', 'get_instance')); add_action('plugins_loaded', array('Caldera_Forms_Tracking', 'get_instance')); -// Admin & Admin Ajax stuff. + // Admin & Admin Ajax stuff. if (is_admin() || defined('DOING_AJAX')) { add_action('plugins_loaded', array('Caldera_Forms_Admin', 'get_instance')); add_action('plugins_loaded', array('Caldera_Forms_Support', 'get_instance')); @@ -134,61 +133,6 @@ function caldera_forms_load() } - /** - * Get the Caldera Forms Freemius instance - * - * @since 1.6.0 - * - * @return Freemius - * @throws Freemius_Exception - */ - function caldera_forms_freemius() - { - global $caldera_forms_freemius; - if (!isset($caldera_forms_freemius)) { - // Include Freemius SDK. - require_once CFCORE_PATH . 'includes/freemius/start.php'; - $caldera_forms_freemius = fs_dynamic_init(array( - 'id' => '1767', - 'slug' => 'caldera-forms', - 'type' => 'plugin', - 'public_key' => 'pk_d8e6325777a98c1b3e0d8cdbfad1e', - 'is_premium' => false, - 'has_addons' => false, - 'has_paid_plans' => false, - 'menu' => array( - 'slug' => 'caldera-forms', - 'account' => false, - 'support' => false, - 'contact' => false, - ), - )); - /** - * Runs after Freemius loads - * - * @since 1.6.0 - * - * @param Freemius $caldera_forms_freemius - */ - do_action('caldera_forms_freemius_init', $caldera_forms_freemius); - } - return $caldera_forms_freemius; - } - - //Load freemius - caldera_forms_freemius(); - - /** - * Get the path for the icon used by Caldera Forms - * - * @since 1.6.0 - * - * @return string - */ - function caldera_forms_freemius_icon_path() - { - return CFCORE_PATH . 'assets/build/images/new-icon.png'; - } } diff --git a/composer.json b/composer.json index 4fea03ea5..7903ae0d2 100755 --- a/composer.json +++ b/composer.json @@ -21,28 +21,58 @@ "role": "Contributing Developer" } ], + "repositories": [ + { + "type": "git", + "url": "https://github.com/CalderaWP/caldera-interop" + }, + { + "type": "git", + "url": "https://github.com/CalderaWP/caldera-ghost-runner" + }, + { + "type":"composer", + "url":"https://wpackagist.org" + } + ], "homepage": "http://calderaforms.com", "require": { "php": ">=5.6.0", "inpsyde/wonolog": "^1.0", "calderawp/caldera-forms-query" : "dev-master", - "calderawp/caldera-containers": "^0.2.0" + "calderawp/caldera-containers": "^0.2.0", + "composer/installers": "^1.6" }, "autoload": { "psr-4": { "calderawp\\calderaforms\\pro\\": "includes/cf-pro-client/classes/" } }, + "autoload-dev": { + "psr-4": { + "calderawp\\calderaforms\\Tests\\Unit\\": "tests/Unit/", + "calderawp\\calderaforms\\Tests\\Util\\": "tests/Util/", + "calderawp\\calderaforms\\Tests\\Util\\Traits\\": "tests/Util/Traits/" + }, + "files" : [ + "./tests/testing-cli.php" + ] + }, "require-dev": { - "phpunit/phpunit":"~5.5.0" + "phpunit/phpunit":"~5.5.0", + "wpackagist-plugin/gutenberg":"*", + "johnpbloch/wordpress" : "*", + "brain/monkey": "^2.2", + "mockery/mockery": ">=0.9 <2" }, "scripts" : { - "wp-install" : "docker-compose up --build -d", - "wp-tests" : "composer wp-install && composer wp-unit-test", - "wp-unit-test" : "docker-compose run wordpress vendor/bin/phpunit", - "wp-start" : "docker-compose up", - "wp-stop" : "docker-compose stop", - "wp-remove": "docker-compose down" - + "wp:install": "bash ./bin/install-docker.sh && composer wp:config", + "wp:activate": "bash ./bin/activate-plugin.sh", + "wp:setup-tests": "bash ./bin/setup-test-forms.sh", + "wp:config": "docker-compose run --rm cli wp rewrite structure '/%postname%/'", + "wp:start": "docker-compose up -d", + "wp:tests": "docker-compose run --rm wordpress_phpunit phpunit --configuration phpunit-integration.xml.dist", + "wp:destroy": "docker-compose rm --stop --force", + "test:unit": "phpunit --configuration phpunit-unit.xml.dist" } } diff --git a/composer.lock b/composer.lock index cc59cb5d1..1f64fd768 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "57bcdad48633e11b8784675fce83f8f4", + "content-hash": "184582c7faa7beeeed318dd04f95fe29", "packages": [ { "name": "calderawp/caldera-containers", @@ -104,6 +104,126 @@ "description": "Caldera Forms Query Library", "time": "2018-07-10T21:12:12+00:00" }, + { + "name": "composer/installers", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/cfcca6b1b60bc4974324efb5783c13dca6932b5b", + "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "replace": { + "roundcube/plugin-installer": "*", + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "^4.8.36" + }, + "type": "composer-plugin", + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "https://composer.github.io/installers/", + "keywords": [ + "Craft", + "Dolibarr", + "Eliasis", + "Hurad", + "ImageCMS", + "Kanboard", + "Lan Management System", + "MODX Evo", + "Mautic", + "Maya", + "OXID", + "Plentymarkets", + "Porto", + "RadPHP", + "SMF", + "Thelia", + "WolfCMS", + "agl", + "aimeos", + "annotatecms", + "attogram", + "bitrix", + "cakephp", + "chef", + "cockpit", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "eZ Platform", + "elgg", + "expressionengine", + "fuelphp", + "grav", + "installer", + "itop", + "joomla", + "kohana", + "laravel", + "lavalite", + "lithium", + "magento", + "majima", + "mako", + "mediawiki", + "modulework", + "modx", + "moodle", + "osclass", + "phpbb", + "piwik", + "ppi", + "puppet", + "pxcms", + "reindex", + "roundcube", + "shopware", + "silverstripe", + "sydes", + "symfony", + "typo3", + "wordpress", + "yawik", + "zend", + "zikula" + ], + "time": "2018-08-27T06:10:37+00:00" + }, { "name": "inpsyde/wonolog", "version": "1.0.2", @@ -516,6 +636,111 @@ } ], "packages-dev": [ + { + "name": "antecedent/patchwork", + "version": "2.1.8", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "3bb81ace3914c220aa273d1c0603d5e1b454c0d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/3bb81ace3914c220aa273d1c0603d5e1b454c0d7", + "reference": "3bb81ace3914c220aa273d1c0603d5e1b454c0d7", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "type": "library", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "http://patchwork2.org/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ], + "time": "2018-02-19T18:52:50+00:00" + }, + { + "name": "brain/monkey", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/Brain-WP/BrainMonkey.git", + "reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/ed9e0698bc1292f33698719da8ca1aa2e18acc51", + "reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.0", + "mockery/mockery": ">=0.9 <2", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-version/1": "1.x-dev", + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Brain\\Monkey\\": "src/" + }, + "files": [ + "inc/api.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Giuseppe Mazzapica", + "email": "giuseppe.mazzapica@gmail.com", + "homepage": "https://gmazzap.me", + "role": "Developer" + } + ], + "description": "Mocking utility for PHP functions and WordPress plugin API", + "keywords": [ + "Monkey Patching", + "interception", + "mock", + "mock functions", + "mockery", + "patchwork", + "redefinition", + "runkit", + "test", + "testing" + ], + "time": "2017-12-01T16:32:09+00:00" + }, { "name": "doctrine/instantiator", "version": "1.1.0", @@ -570,6 +795,247 @@ ], "time": "2017-07-22T11:58:36+00:00" }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.0", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad", + "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "1.3.3", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ], + "time": "2016-01-20T08:20:44+00:00" + }, + { + "name": "johnpbloch/wordpress", + "version": "4.9.8", + "source": { + "type": "git", + "url": "https://github.com/johnpbloch/wordpress.git", + "reference": "de02cd79a41e06f36558040724414197cb7f6246" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/johnpbloch/wordpress/zipball/de02cd79a41e06f36558040724414197cb7f6246", + "reference": "de02cd79a41e06f36558040724414197cb7f6246", + "shasum": "" + }, + "require": { + "johnpbloch/wordpress-core": "4.9.8", + "johnpbloch/wordpress-core-installer": "^1.0", + "php": ">=5.3.2" + }, + "type": "package", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "WordPress Community", + "homepage": "http://wordpress.org/about/" + } + ], + "description": "WordPress is web software you can use to create a beautiful website or blog.", + "homepage": "http://wordpress.org/", + "keywords": [ + "blog", + "cms", + "wordpress" + ], + "time": "2018-08-02T21:48:39+00:00" + }, + { + "name": "johnpbloch/wordpress-core", + "version": "4.9.8", + "source": { + "type": "git", + "url": "https://github.com/johnpbloch/wordpress-core.git", + "reference": "50323f9b91d7689d615b4af02caf9d80584b1cfc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/johnpbloch/wordpress-core/zipball/50323f9b91d7689d615b4af02caf9d80584b1cfc", + "reference": "50323f9b91d7689d615b4af02caf9d80584b1cfc", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "provide": { + "wordpress/core-implementation": "4.9.8" + }, + "type": "wordpress-core", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "WordPress Community", + "homepage": "http://wordpress.org/about/" + } + ], + "description": "WordPress is web software you can use to create a beautiful website or blog.", + "homepage": "http://wordpress.org/", + "keywords": [ + "blog", + "cms", + "wordpress" + ], + "time": "2018-08-02T21:48:32+00:00" + }, + { + "name": "johnpbloch/wordpress-core-installer", + "version": "1.0.0.2", + "source": { + "type": "git", + "url": "https://github.com/johnpbloch/wordpress-core-installer.git", + "reference": "7941acd71725710a789daabe0557429da63e7ac6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/johnpbloch/wordpress-core-installer/zipball/7941acd71725710a789daabe0557429da63e7ac6", + "reference": "7941acd71725710a789daabe0557429da63e7ac6", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "conflict": { + "composer/installers": "<1.0.6" + }, + "require-dev": { + "composer/composer": "^1.0", + "phpunit/phpunit": ">=4.8.35" + }, + "type": "composer-plugin", + "extra": { + "class": "johnpbloch\\Composer\\WordPressCorePlugin" + }, + "autoload": { + "psr-0": { + "johnpbloch\\Composer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "John P. Bloch", + "email": "me@johnpbloch.com" + } + ], + "description": "A custom installer to handle deploying WordPress with composer", + "keywords": [ + "wordpress" + ], + "time": "2018-01-29T14:49:29+00:00" + }, + { + "name": "mockery/mockery", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "100633629bf76d57430b86b7098cd6beb996a35a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/100633629bf76d57430b86b7098cd6beb996a35a", + "reference": "100633629bf76d57430b86b7098cd6beb996a35a", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~2.0", + "lib-pcre": ">=7.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.10|~6.5|~7.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ], + "time": "2018-10-02T21:52:37+00:00" + }, { "name": "myclabs/deep-copy", "version": "1.8.1", @@ -1903,6 +2369,26 @@ "validate" ], "time": "2018-01-29T19:49:41+00:00" + }, + { + "name": "wpackagist-plugin/gutenberg", + "version": "4.0.0", + "source": { + "type": "svn", + "url": "https://plugins.svn.wordpress.org/gutenberg/", + "reference": "tags/4.0.0" + }, + "dist": { + "type": "zip", + "url": "https://downloads.wordpress.org/plugin/gutenberg.4.0.0.zip", + "reference": null, + "shasum": null + }, + "require": { + "composer/installers": "~1.0" + }, + "type": "wordpress-plugin", + "homepage": "https://wordpress.org/plugins/gutenberg/" } ], "aliases": [], diff --git a/cypress.json b/cypress.json new file mode 100644 index 000000000..99578bddd --- /dev/null +++ b/cypress.json @@ -0,0 +1,9 @@ +{ + "env": { + "wp_site" : { + "url" : "http://localhost:8228", + "user": "admin", + "pass": "password" + } + } +} diff --git a/cypress/README.md b/cypress/README.md new file mode 100644 index 000000000..d936e0bbb --- /dev/null +++ b/cypress/README.md @@ -0,0 +1,24 @@ + +## Start The Runner +Cypress opens a small app called "Cypress" and Chrome. You start this with the command `npm run test:e2e`. This is separate app then the Chrome you normally use, which [is confusing](https://docs.cypress.io/guides/guides/launching-browsers.html#Browser-Icon). + +In the Cypress app, you should se a list of tests, you can click one to launch it in Chrome or you can click the "Run All Specs" button to run all of the tests. + +### Run tests: + +1) Start local dev environment (See main readme) +2) Start test runner (See main readme) +3) Choose a test suite to run from Cypress menu + +## Runner Not Working? +* Cypress gets 404s for all pages? + - Did you start the development environment? `composer wp:start` + - Are you trying to use your own URL? You need to modify cypress.json's env, but then you will break it for everyone, please use the provided environment. +* Error in Cypress' Chrome `Whoops, we can't run your tests. This browser was not launched through Cypress. Tests cannot run.` +## How To Add A Test +* Export your form +* Save form in `cypress/forms` using form ID as file name +* Add an entry in `cypress/test.json` to `forms` with: + - `formId` - Required. The ID of the form + - `pageSlug` - Optional. Slug of page to put form on. Skip for admin tests. + - `ghostId` - Optional. ID of Ghost Inspector test if it exists. \ No newline at end of file diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json new file mode 100644 index 000000000..da18d9352 --- /dev/null +++ b/cypress/fixtures/example.json @@ -0,0 +1,5 @@ +{ + "name": "Using fixtures to represent data", + "email": "hello@cypress.io", + "body": "Fixtures are a great way to mock data for responses to routes" +} \ No newline at end of file diff --git a/cypress/forms/CF59ce6f1747efb.json b/cypress/forms/CF59ce6f1747efb.json new file mode 100644 index 000000000..2763c3aae --- /dev/null +++ b/cypress/forms/CF59ce6f1747efb.json @@ -0,0 +1 @@ +{"_last_updated":"Sun, 08 Oct 2017 06:17:07 +0000","ID":"CF59ce6f1747efb","cf_version":"1.5.5","name":"1979 Calculations Created@1.5.5 dev@1.5.6.2","scroll_top":0,"description":"\t\t\t\t\t\t\t","success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_9272690":"1:1","fld_7896676":"2:1","fld_1803763":"2:1","fld_6770247":"2:1","fld_3195385":"2:1","fld_1734684":"2:2","fld_6532733":"2:2"},"structure":"12|6:6"},"fields":{"fld_9272690":{"ID":"fld_9272690","type":"checkbox","label":"selections","slug":"selections","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","show_values":1,"default":"opt315190","option":{"opt315190":{"calc_value":100,"value":100,"label":"One"},"opt1234552":{"calc_value":200,"value":200,"label":"Two"},"opt2318664":{"calc_value":300,"value":300,"label":"Three"}}}},"fld_7896676":{"ID":"fld_7896676","type":"calculation","label":"total","slug":"total","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Sub Total: $","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","formular":"fld_9272690","config":{"group":[{"lines":[{"operator":"+","field":"fld_9272690"}]}]},"manual_formula":""}},"fld_1803763":{"ID":"fld_1803763","type":"hidden","label":"disc1","slug":"disc1","conditions":{"type":"con_4891587877948869"},"caption":"","config":{"custom_class":"","default":10}},"fld_6770247":{"ID":"fld_6770247","type":"hidden","label":"disc2","slug":"disc2","conditions":{"type":"con_7537350517214687"},"caption":"","config":{"custom_class":"","default":20}},"fld_3195385":{"ID":"fld_3195385","type":"summary","label":"summary","slug":"summary","conditions":{"type":""},"caption":"","config":{"custom_class":""}},"fld_1734684":{"ID":"fld_1734684","type":"calculation","label":"discount","slug":"discount","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Discount: $","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","manual":1,"formular":" ( fld_1803763+fld_6770247 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_1803763"},{"operator":"+","field":"fld_6770247"}]}]},"manual_formula":"%disc1% + %disc2%"}},"fld_6532733":{"ID":"fld_6532733","type":"calculation","label":"grand total","slug":"grand_total","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Grand Total: $","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","formular":" ( fld_9272690-fld_1803763-fld_6770247 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_9272690"},{"operator":"-","field":"fld_1803763"},{"operator":"-","field":"fld_6770247"}]}]},"manual_formula":""}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"dryheat3@hahn-tech.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"bug report","email_message":"{summary}"},"conditional_groups":{"conditions":{"con_4891587877948869":{"id":"con_4891587877948869","name":"chk1-2","type":"show","group":{"rw9238428028085778":{"cl8496363565190464":{"parent":"rw9238428028085778","field":"fld_9272690","compare":"is","value":"opt315190"},"cl7713839815922961":{"parent":"rw9238428028085778","field":"fld_9272690","compare":"is","value":"opt1234552"}}},"fields":{"cl8496363565190464":"fld_9272690","cl7713839815922961":"fld_9272690"}},"con_7537350517214687":{"id":"con_7537350517214687","name":"chk1-2-3","type":"show","fields":{"cl1451086636949535":"fld_9272690","cl279276517104136":"fld_9272690","cl1076875616164973":"fld_9272690"},"group":{"rw4474515994153653":{"cl1451086636949535":{"parent":"rw4474515994153653","field":"fld_9272690","compare":"is","value":"opt315190"},"cl279276517104136":{"parent":"rw4474515994153653","field":"fld_9272690","compare":"is","value":"opt1234552"},"cl1076875616164973":{"parent":"rw4474515994153653","field":"fld_9272690","compare":"is","value":"opt2318664"}}}}}},"variables":{"keys":["discount1","discount2"],"values":["%selections%",20],"types":["entryitem","entryitem"]},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.6.2-b-2","type":"primary","db_id":"1"} \ No newline at end of file diff --git a/cypress/forms/CF59d957b7acff7.json b/cypress/forms/CF59d957b7acff7.json new file mode 100644 index 000000000..f4439a6fa --- /dev/null +++ b/cypress/forms/CF59d957b7acff7.json @@ -0,0 +1,345 @@ +{ + "_last_updated": "Sun, 08 Oct 2017 06:17:43 +0000", + "ID": "CF59d957b7acff7", + "cf_version": "1.5.6.2-b-2", + "name": "1962 Calculations created@1.5.5 dev@1.5.6.2", + "scroll_top": 0, + "success": "Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t", + "db_support": 1, + "pinned": 0, + "hide_form": 1, + "check_honey": 1, + "avatar_field": "", + "form_ajax": 1, + "custom_callback": "", + "layout_grid": { + "fields": { + "fld_3296542": "1:1", + "fld_1740075": "1:1", + "fld_105161": "1:1", + "fld_5181257": "1:2", + "fld_693890": "1:2", + "fld_7680820": "1:2", + "fld_5656420": "2:1", + "fld_578758": "2:2", + "fld_5522707": "3:1" + }, + "structure": "6:6|6:6|12" + }, + "fields": { + "fld_3296542": { + "ID": "fld_3296542", + "type": "dropdown", + "label": "Dropdown", + "slug": "dropdown", + "conditions": { + "type": "" + }, + "caption": "", + "config": { + "custom_class": "", + "placeholder": "", + "default_option": "", + "auto_type": "", + "taxonomy": "category", + "post_type": "post", + "value_field": "name", + "orderby_tax": "name", + "orderby_post": "name", + "order": "ASC", + "show_values": 1, + "option": { + "opt1858354": { + "calc_value": 100, + "value": 10, + "label": "Calc 100 Value 10" + }, + "opt1112077": { + "calc_value": 200, + "value": 20, + "label": "Calc 200 Value 20" + } + }, + "default": "opt1112077" + } + }, + "fld_1740075": { + "ID": "fld_1740075", + "type": "checkbox", + "label": "Checkbox", + "slug": "checkbox", + "conditions": { + "type": "" + }, + "caption": "", + "config": { + "custom_class": "", + "default_option": "", + "auto_type": "", + "taxonomy": "category", + "post_type": "post", + "value_field": "name", + "orderby_tax": "name", + "orderby_post": "name", + "order": "ASC", + "show_values": 1, + "default": "opt1818955", + "option": { + "opt1818955": { + "calc_value": 100, + "value": 10, + "label": "Calc 100 Value 10" + }, + "opt2025041": { + "calc_value": 200, + "value": 20, + "label": "Calc 200 Value 20" + } + } + } + }, + "fld_105161": { + "ID": "fld_105161", + "type": "radio", + "label": "Radio", + "slug": "radio", + "conditions": { + "type": "" + }, + "caption": "", + "config": { + "custom_class": "", + "default_option": "", + "auto_type": "", + "taxonomy": "category", + "post_type": "post", + "value_field": "name", + "orderby_tax": "name", + "orderby_post": "name", + "order": "ASC", + "show_values": 1, + "default": "opt1358559", + "option": { + "opt1358559": { + "calc_value": 100, + "value": 10, + "label": "Calc 100 Value 10" + }, + "opt1311714": { + "calc_value": 200, + "value": 20, + "label": "Calc 200 Value 20" + } + } + } + }, + "fld_5181257": { + "ID": "fld_5181257", + "type": "calculation", + "label": "DropDown Calc", + "slug": "dropdown_calc", + "conditions": { + "type": "" + }, + "caption": "", + "config": { + "custom_class": "", + "element": "h3", + "classes": "total-line", + "before": "Total:", + "after": "", + "thousand_separator": ",", + "decimal_separator": ".", + "formular": "fld_3296542", + "config": { + "group": [ + { + "lines": [ + { + "operator": "+", + "field": "fld_3296542" + } + ] + } + ] + }, + "manual_formula": "" + } + }, + "fld_693890": { + "ID": "fld_693890", + "type": "calculation", + "label": "Checkbox Calc", + "slug": "checkbox_calc", + "conditions": { + "type": "" + }, + "caption": "", + "config": { + "custom_class": "", + "element": "h3", + "classes": "total-line", + "before": "Total:", + "after": "", + "thousand_separator": ",", + "decimal_separator": ".", + "formular": "fld_1740075", + "config": { + "group": [ + { + "lines": [ + { + "operator": "+", + "field": "fld_1740075" + } + ] + } + ] + }, + "manual_formula": "" + } + }, + "fld_7680820": { + "ID": "fld_7680820", + "type": "calculation", + "label": "Radio Calc", + "slug": "radio_calc", + "conditions": { + "type": "" + }, + "caption": "", + "config": { + "custom_class": "", + "element": "h3", + "classes": "total-line", + "before": "Total:", + "after": "", + "thousand_separator": ",", + "decimal_separator": ".", + "formular": "fld_105161", + "config": { + "group": [ + { + "lines": [ + { + "operator": "+", + "field": "fld_105161" + } + ] + } + ] + }, + "manual_formula": "" + } + }, + "fld_5656420": { + "ID": "fld_5656420", + "type": "number", + "label": "Number Field", + "slug": "number_field", + "conditions": { + "type": "" + }, + "caption": "", + "config": { + "custom_class": "", + "placeholder": "", + "default": 1, + "min": "", + "max": "", + "step": 9 + } + }, + "fld_578758": { + "ID": "fld_578758", + "type": "calculation", + "label": "Selects Divided By Number", + "slug": "selects_divided_by_number", + "conditions": { + "type": "" + }, + "caption": "All other calculation fields divided by number field.", + "config": { + "custom_class": "", + "element": "h3", + "classes": "total-line", + "before": "Total:", + "after": "", + "thousand_separator": ",", + "decimal_separator": ".", + "formular": " ( fld_5181257+fld_693890+fld_7680820 ) \/fld_5656420", + "config": { + "group": [ + { + "lines": [ + { + "operator": "+", + "field": "fld_5181257" + }, + { + "operator": "+", + "field": "fld_693890" + }, + { + "operator": "+", + "field": "fld_7680820" + } + ] + }, + { + "operator": "\/" + }, + { + "lines": [ + { + "operator": "+", + "field": "fld_5656420" + } + ] + } + ] + }, + "manual_formula": "" + } + }, + "fld_5522707": { + "ID": "fld_5522707", + "type": "button", + "label": "Submit Button", + "slug": "submit_button", + "conditions": { + "type": "" + }, + "caption": "", + "config": { + "custom_class": "", + "type": "submit", + "class": "btn btn-default", + "target": "" + } + } + }, + "page_names": [ + "Page 1" + ], + "mailer": { + "on_insert": 1, + "sender_name": "Caldera Forms Notification", + "sender_email": "josh@calderawp.com", + "reply_to": "", + "email_type": "html", + "recipients": "", + "bcc_to": "", + "email_subject": "1962 Calculations created@1.5.5 dev@1.5.6.2", + "email_message": "{summary}" + }, + "conditional_groups": [], + "settings": { + "responsive": { + "break_point": "sm" + } + }, + "version": "1.5.6.2-b-2", + "type": "primary", + "db_id": "2" +} \ No newline at end of file diff --git a/cypress/forms/CF59d9652a86fff.json b/cypress/forms/CF59d9652a86fff.json new file mode 100644 index 000000000..902bc99be --- /dev/null +++ b/cypress/forms/CF59d9652a86fff.json @@ -0,0 +1 @@ +{"_last_updated":"Sun, 08 Oct 2017 20:05:02 +0000","ID":"CF59d9652a86fff","cf_version":"1.5.6.2-b-2","name":"1993 Calculations created@1.5.5 dev@1.5.6.2","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_4476299":"1:1","fld_7265648":"1:1","fld_7335878":"1:2","fld_5821713":"1:2","fld_7400054":"2:1","fld_1467266":"2:2"},"structure":"6:6|6:6"},"fields":{"fld_4476299":{"ID":"fld_4476299","type":"number","label":"Number 1","slug":"number_1","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":1,"min":"","max":"","step":""}},"fld_7265648":{"ID":"fld_7265648","type":"number","label":"Number 2","slug":"number_2","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","min":"","max":"","step":""}},"fld_7335878":{"ID":"fld_7335878","type":"calculation","label":"Calc Number 1","slug":"calc_number_1","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","formular":"fld_4476299","config":{"group":[{"lines":[{"operator":"+","field":"fld_4476299"}]}]},"manual_formula":""}},"fld_5821713":{"ID":"fld_5821713","type":"calculation","label":"Calc Number 2","slug":"calc_number_2","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","formular":"fld_7265648","config":{"group":[{"lines":[{"operator":"+","field":"fld_7265648"}]}]},"manual_formula":""}},"fld_7400054":{"ID":"fld_7400054","type":"hidden","label":"One","slug":"one","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":1}},"fld_1467266":{"ID":"fld_1467266","type":"calculation","label":"Multiply","slug":"multiply","conditions":{"type":""},"caption":"1 + calc 1 * calc 2","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","formular":" ( fld_4476299*fld_7265648 ) +fld_7400054","config":{"group":[{"lines":[{"operator":"+","field":"fld_4476299"},{"operator":"*","field":"fld_7265648"}]},{"operator":"+"},{"lines":[{"operator":"+","field":"fld_7400054"}]}]},"manual_formula":"1+ %calc_number_1% * %calc_number_2%"}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"admin@example.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"1992 Caluculations","email_message":"{summary}"},"conditional_groups":[],"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.6.2-b-2","db_id":"6","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF59dd15667a03b.json b/cypress/forms/CF59dd15667a03b.json new file mode 100644 index 000000000..dbeb5b07a --- /dev/null +++ b/cypress/forms/CF59dd15667a03b.json @@ -0,0 +1 @@ +{"_last_updated":"Fri, 21 Aug 2015 00:33:50 +0000","ID":"CF59dd15667a03b","name":"X1 Calculations create@1.5.5 dev@1.5.6.2","description":"","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"success":"Form has been successfully submitted. Thank you.","avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_4338248":"1:1","fld_1316929":"1:1","fld_6796077":"1:1","fld_5987102":"1:1","fld_3993413":"2:1","fld_5161425":"2:2","fld_8997460":"3:1","fld_1338703":"3:2"},"structure":"12|6:6|6:6"},"fields":{"fld_1316929":{"ID":"fld_1316929","type":"hidden","label":"Two Big","slug":"two_big","caption":"","config":{"custom_class":"","default":5},"conditions":{"type":"hide","group":{"rw19946608611":{"cl3564295763":{"field":"fld_5161425","compare":"isnot","value":"opt1533135"}}}}},"fld_4338248":{"ID":"fld_4338248","type":"hidden","label":"One","slug":"one","caption":"","config":{"custom_class":"","default":10},"conditions":{"type":"hide","group":{"rw47185924125":{"cl5675243200":{"field":"fld_3993413","compare":"isnot","value":"opt1697235"}}}}},"fld_5987102":{"ID":"fld_5987102","type":"hidden","label":"Base","slug":"base","caption":"","config":{"custom_class":"","default":25},"conditions":{"type":""}},"fld_3993413":{"ID":"fld_3993413","type":"checkbox","label":"Want Option 1?","slug":"option_1","caption":"","config":{"custom_class":"","inline":1,"auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","default":"","option":{"opt1697235":{"value":"","label":"Yes"}}},"conditions":{"type":""}},"fld_5161425":{"ID":"fld_5161425","type":"dropdown","label":"Option 2 Type","slug":"option_2","caption":"","config":{"custom_class":"","placeholder":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","default":"","option":{"opt1533135":{"value":"","label":"Big"},"opt1786217":{"value":"","label":"Small"}}},"conditions":{"type":""}},"fld_8997460":{"ID":"fld_8997460","type":"calculation","label":"Total","slug":"total","caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","fixed":1,"thousand_separator":",","formular":" ( fld_5987102+fld_4338248+fld_6796077+fld_1316929 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_5987102"},{"operator":"+","field":"fld_4338248"},{"operator":"+","field":"fld_6796077"},{"operator":"+","field":"fld_1316929"}]}]},"manual_formula":""},"conditions":{"type":""}},"fld_1338703":{"ID":"fld_1338703","type":"button","label":"Pay","slug":"pay","caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default"},"conditions":{"type":""}},"fld_6796077":{"ID":"fld_6796077","type":"hidden","label":"Two Small","slug":"two_small","caption":"","config":{"custom_class":"","default":1},"conditions":{"type":"hide","group":{"rw74415141932":{"cl7168988428":{"field":"fld_5161425","compare":"isnot","value":"opt1786217"}}}}}},"page_names":["Page 1"],"settings":{"responsive":{"break_point":"sm"}},"mailer":{"on_insert":1},"template":"variable_price_example","db_id":"4","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF59dd5d8e95ffb.json b/cypress/forms/CF59dd5d8e95ffb.json new file mode 100644 index 000000000..f6262249c --- /dev/null +++ b/cypress/forms/CF59dd5d8e95ffb.json @@ -0,0 +1 @@ +{"_last_updated":"Tue, 10 Oct 2017 23:56:53 +0000","ID":"CF59dd5d8e95ffb","cf_version":"1.5.5","name":"X2 Calculations create@1.5.5 dev@1.5.6.2","scroll_top":0,"description":"\t\t\t\t\t\t\t","success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_8172473":"1:1","fld_8186270":"1:1","fld_6617658":"1:2"},"structure":"6:6"},"fields":{"fld_8172473":{"ID":"fld_8172473","type":"dropdown","label":"Item 1","slug":"item_1","conditions":{"type":""},"required":1,"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"","option":{"opt1929850":{"calc_value":"","value":3,"label":3},"opt1875187":{"calc_value":"","value":4,"label":4}}}},"fld_8186270":{"ID":"fld_8186270","type":"dropdown","label":"Item 2","slug":"item_2","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"","show_values":1,"option":{"opt1143191":{"calc_value":"","value":1,"label":"One"},"opt1159446":{"calc_value":2,"value":"Two","label":"Two"}}}},"fld_6617658":{"ID":"fld_6617658","type":"calculation","label":"Total With Tax","slug":"total","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","manual":1,"formular":"","config":"","manual_formula":"(%item_1% + %item_2% ) * 1.07"}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"X Calculations Sales Tax","email_message":"{summary}"},"conditional_groups":{"fields":[]},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.5","db_id":"16","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF59dd60bbe7ab6.json b/cypress/forms/CF59dd60bbe7ab6.json new file mode 100644 index 000000000..53e8b3f88 --- /dev/null +++ b/cypress/forms/CF59dd60bbe7ab6.json @@ -0,0 +1 @@ +{"_last_updated":"Wed, 11 Oct 2017 00:50:17 +0000","ID":"CF59dd60bbe7ab6","cf_version":"1.5.6.2-b-2","name":"X3 Calculations create@1.5.5 dev@1.5.6.2","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_2950569":"1:1","fld_6083669":"1:2","fld_9723683":"1:2"},"structure":"6:6"},"fields":{"fld_2950569":{"ID":"fld_2950569","type":"number","label":"Number","slug":"number","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","min":"","max":"","step":""}},"fld_6083669":{"ID":"fld_6083669","type":"calculation","label":"Math","slug":"math","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","manual":1,"formular":"","config":"","manual_formula":"tan( %number% ) "}},"fld_9723683":{"ID":"fld_9723683","type":"calculation","label":"Round Math","slug":"round_math","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","manual":1,"formular":"","config":"","manual_formula":"round( tan( %number% ) )"}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"X3 Calculations create@1.5.5 dev@1.5.6.2","email_message":"{summary}"},"conditional_groups":[],"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.6.2-b-2","db_id":"347","type":"primary","is_connected_form":false,"processors":[]} \ No newline at end of file diff --git a/cypress/forms/CF59e13e034fc2d.json b/cypress/forms/CF59e13e034fc2d.json new file mode 100644 index 000000000..111a8ca8a --- /dev/null +++ b/cypress/forms/CF59e13e034fc2d.json @@ -0,0 +1 @@ +{"_last_updated":"Fri, 13 Oct 2017 23:33:06 +0000","ID":"CF59e13e034fc2d","cf_version":"1.5.7-b-1","name":"2013 HTML\/Summary create@1.5.5 dev@1.5.6","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_3068283":"1:1","fld_4911252":"1:1","fld_7259588":"1:1","fld_7722492":"1:1","fld_5594906":"1:2"},"structure":"6:6"},"fields":{"fld_3068283":{"ID":"fld_3068283","type":"text","label":"Single Line","slug":"single_line","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_4911252":{"ID":"fld_4911252","type":"dropdown","label":"Dropdown","slug":"dropdown","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","easy-query":"CEQ59dea32bb14fc199","default":"","option":{"opt2078487":{"calc_value":"One","value":"One","label":"One"},"opt1615173":{"calc_value":"Two","value":"Two","label":"Two"}}}},"fld_5594906":{"ID":"fld_5594906","type":"summary","label":"Summary","slug":"sumamry","conditions":{"type":""},"caption":"","config":{"custom_class":""}},"fld_7259588":{"ID":"fld_7259588","type":"number","label":"Number 1","slug":"number_1","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","min":"","max":"","step":""}},"fld_7722492":{"ID":"fld_7722492","type":"number","label":"Number 2","slug":"number_2","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":2,"min":"","max":"","step":""}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"admin@example.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"2013 HTML\/Summary create@1.5.5 dev@1.5.6","email_message":"{summary}"},"conditional_groups":[],"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.7-b-1","db_id":"362","type":"primary","is_connected_form":false,"processors":[]} \ No newline at end of file diff --git a/cypress/forms/CF59e14e252a2c8.json b/cypress/forms/CF59e14e252a2c8.json new file mode 100644 index 000000000..8e29fe898 --- /dev/null +++ b/cypress/forms/CF59e14e252a2c8.json @@ -0,0 +1 @@ +{"_last_updated":"Fri, 13 Oct 2017 23:38:57 +0000","ID":"CF59e14e252a2c8","cf_version":"1.5.7-b-1","name":"2014 HTML\/Summary create@1.5.5 dev@1.5.7","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_17743":"1:1","fld_5391964":"1:1","fld_6022334":"1:1","fld_5594906":"1:2"},"structure":"6:6"},"fields":{"fld_17743":{"ID":"fld_17743","type":"checkbox","label":"Check1","slug":"check1","conditions":{"type":""},"caption":"No default, no calc values","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","easy-query":"CEQ59dea32bb14fc199","default":"","option":{"opt1486935":{"calc_value":"One","value":"One","label":"One"},"opt1475442":{"calc_value":"Two","value":"Two","label":"Two"}}}},"fld_5594906":{"ID":"fld_5594906","type":"summary","label":"Summary","slug":"sumamry","conditions":{"type":""},"caption":"","config":{"custom_class":""}},"fld_5391964":{"ID":"fld_5391964","type":"checkbox","label":"Check2","slug":"check2","conditions":{"type":""},"caption":"Has default","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","easy-query":"CEQ59dea32bb14fc199","default":"opt1612426","option":{"opt1612426":{"calc_value":"","value":"Three","label":"Three"}}}},"fld_6022334":{"ID":"fld_6022334","type":"checkbox","label":"Check3","slug":"check3","conditions":{"type":""},"caption":"No default, has calc values","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","easy-query":"CEQ59dea32bb14fc199","default":"","show_values":1,"option":{"opt1613104":{"calc_value":4,"value":"Four","label":"Four"},"opt1884174":{"calc_value":5,"value":"Five","label":"Five"}}}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"admin@example.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"2014 HTML\/Summary create@1.5.5 dev@1.5.7","email_message":"{summary}"},"conditional_groups":[],"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.7-b-1","db_id":"364","type":"primary","is_connected_form":false,"processors":[]} \ No newline at end of file diff --git a/cypress/forms/CF59f533d0a5e0b.json b/cypress/forms/CF59f533d0a5e0b.json new file mode 100644 index 000000000..24d06a798 --- /dev/null +++ b/cypress/forms/CF59f533d0a5e0b.json @@ -0,0 +1 @@ +{"_last_updated":"Sun, 29 Oct 2017 02:08:48 +0000","ID":"CF59f533d0a5e0b","cf_version":"1.5.5","name":"X8 Conditionals Hide create@1.5.5","scroll_top":0,"description":"\t\t\t\t\t\t\t","success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_5216203":"1:1","fld_1705245":"1:1","fld_7100783":"2:1","fld_313720":"3:1","fld_8846716":"3:1","fld_5619974":"4:1"},"structure":"12|12#12|12"},"fields":{"fld_1705245":{"ID":"fld_1705245","type":"number","label":"Number","slug":"number","conditions":{"type":"con_3840644613791445"},"caption":"Hidden by dropdown","config":{"custom_class":"","placeholder":"","default":"","min":"","max":"","step":""}},"fld_5216203":{"ID":"fld_5216203","type":"dropdown","label":"Dropdown","slug":"dropdown","conditions":{"type":"con_3156693554561454"},"caption":"Hidden if number is greater than 5 or number 2 is 10","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"opt1326030","option":{"opt1326030":{"calc_value":"","value":"Hide Number","label":"Hide Number"},"opt1184564":{"calc_value":"","value":"No","label":"No"}}}},"fld_8846716":{"ID":"fld_8846716","type":"number","label":"Number 2","slug":"number_2","conditions":{"type":"con_8761120514939434"},"caption":"Hide by either dropdwon","config":{"custom_class":"","placeholder":"","default":"","min":"","max":"","step":""}},"fld_313720":{"ID":"fld_313720","type":"dropdown","label":"Dropdown 2","slug":"dropdown_2","conditions":{"type":"con_3156693554561454"},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1326030":{"calc_value":"Hide Number","value":"Hide Number","label":"Hide Number"},"opt1140372":{"calc_value":"","value":"No","label":"No"}}}},"fld_7100783":{"ID":"fld_7100783","type":"button","label":"Next Page","slug":"next_page","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"next","class":"btn btn-default","target":""}},"fld_5619974":{"ID":"fld_5619974","type":"button","label":"Back","slug":"back","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"prev","class":"btn btn-default","target":""}}},"page_names":["Page 1","Page 2"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Hide Test","email_message":"{summary}"},"conditional_groups":{"conditions":{"con_3840644613791445":{"id":"con_3840644613791445","name":"Hide Number","type":"hide","fields":{"cl7544591620602851":"fld_5216203"},"group":{"rw2216294469904031":{"cl7544591620602851":{"parent":"rw2216294469904031","field":"fld_5216203","compare":"is","value":"opt1326030"}}}},"con_3156693554561454":{"id":"con_3156693554561454","name":"Hide Dropdown","type":"hide","fields":{"cl1059824988036823":"fld_1705245","cl181468538675662":"fld_8846716"},"group":{"rw7802324828821689":{"cl1059824988036823":{"parent":"rw7802324828821689","field":"fld_1705245","compare":"greater","value":"5"}},"rw5464489746314226":{"cl181468538675662":{"parent":"rw5464489746314226","field":"fld_8846716","compare":"is","value":"10"}}}},"con_8761120514939434":{"id":"con_8761120514939434","name":"Hide Number 2","type":"hide","group":{"rw8614452180961339":{"cl483565773895193":{"parent":"rw8614452180961339","field":"fld_5216203","compare":"is","value":"opt1326030"}},"rw4809818870119261":{"cl9529641586904005":{"parent":"rw4809818870119261","field":"fld_313720","compare":"is","value":"opt1326030"}}},"fields":{"cl483565773895193":"fld_5216203","cl9529641586904005":"fld_313720"}}}},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.5","db_id":"97","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF59f542781fc44.json b/cypress/forms/CF59f542781fc44.json new file mode 100644 index 000000000..8988ca136 --- /dev/null +++ b/cypress/forms/CF59f542781fc44.json @@ -0,0 +1 @@ +{"_last_updated":"Sun, 29 Oct 2017 04:15:14 +0000","ID":"CF59f542781fc44","cf_version":"1.5.5","name":"X9 Conditionals Show create@1.5.5","scroll_top":0,"description":"\t\t\t\t\t\t\t\t\t\t\t\t\t\t","success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_5262727":"1:1","fld_2960467":"1:1","fld_7869772":"1:1","fld_6983702":"2:1","fld_1932889":"3:1","fld_2047794":"3:1","fld_8556025":"3:1","fld_5419649":"4:1"},"structure":"12|12#12|12"},"fields":{"fld_5262727":{"ID":"fld_5262727","type":"checkbox","label":"Show Text Field","slug":"show_text_field","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"opt1154218","option":{"opt1154218":{"calc_value":"Yes","value":"Yes","label":"Yes"}}}},"fld_2960467":{"ID":"fld_2960467","type":"text","label":"Text Field","slug":"text_field","conditions":{"type":"con_678629489871150"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_7869772":{"ID":"fld_7869772","type":"number","label":"Number","slug":"number","conditions":{"type":"con_6865021079274483"},"caption":"","config":{"custom_class":"","placeholder":"","default":1,"min":"","max":"","step":""}},"fld_6983702":{"ID":"fld_6983702","type":"button","label":"Next","slug":"next","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"next","class":"btn btn-default","target":""}},"fld_1932889":{"ID":"fld_1932889","type":"text","label":"Text Field Two","slug":"text_field_two","conditions":{"type":"con_678629489871150"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_2047794":{"ID":"fld_2047794","type":"radio","label":"Show Numbers","slug":"show_numbers","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1061484":{"calc_value":"Yes","value":"Yes","label":"Yes"},"opt1161399":{"calc_value":"No","value":"No","label":"No"}}}},"fld_8556025":{"ID":"fld_8556025","type":"number","label":"Number 2","slug":"number_2","conditions":{"type":"con_6865021079274483"},"caption":"","config":{"custom_class":"","placeholder":"","default":2,"min":"","max":"","step":""}},"fld_5419649":{"ID":"fld_5419649","type":"button","label":"back","slug":"back","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"prev","class":"btn btn-default","target":""}}},"page_names":["Page 1","Page 2"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"X9 Conditionals Show create@1.5.5","email_message":"{summary}"},"conditional_groups":{"conditions":{"con_678629489871150":{"id":"con_678629489871150","name":"Show Text","type":"show","fields":{"cl9187398691353332":"fld_5262727"},"group":{"rw7104788064464449":{"cl9187398691353332":{"parent":"rw7104788064464449","field":"fld_5262727","compare":"is","value":"opt1154218"}}}},"con_6865021079274483":{"id":"con_6865021079274483","name":"Show Numbers","type":"show","fields":{"cl6646201099878921":"fld_2047794"},"group":{"rw555621137841073":{"cl6646201099878921":{"parent":"rw555621137841073","field":"fld_2047794","compare":"is","value":"opt1061484"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.5","db_id":"204","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF59f5446e46a71.json b/cypress/forms/CF59f5446e46a71.json new file mode 100644 index 000000000..bca5a8cd6 --- /dev/null +++ b/cypress/forms/CF59f5446e46a71.json @@ -0,0 +1 @@ +{"_last_updated":"Sun, 29 Oct 2017 03:02:04 +0000","ID":"CF59f5446e46a71","cf_version":"1.5.5","name":"X11 Conditionals Show Single Page create@1.5.5","scroll_top":0,"description":"\t\t\t\t\t\t\t","success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_5262727":"1:1","fld_6778974":"1:1","fld_2960467":"1:2","fld_7869772":"1:2"},"structure":"6:6"},"fields":{"fld_5262727":{"ID":"fld_5262727","type":"checkbox","label":"Show Text Field","slug":"show_text_field","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"opt1154218","option":{"opt1154218":{"calc_value":"Yes","value":"Yes","label":"Yes"}}}},"fld_2960467":{"ID":"fld_2960467","type":"text","label":"Text Field","slug":"text_field","conditions":{"type":"con_678629489871150"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_7869772":{"ID":"fld_7869772","type":"number","label":"Number","slug":"number","conditions":{"type":"con_6865021079274483"},"caption":"","config":{"custom_class":"","placeholder":"","default":1,"min":"","max":"","step":""}},"fld_6778974":{"ID":"fld_6778974","type":"radio","label":"Show Number","slug":"show_number","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"","option":{"opt1720237":{"calc_value":"","value":"Yes","label":"Yes"},"opt1172503":{"calc_value":"","value":"No","label":"No"}}}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"X11 Conditionals Show Single Page create@1.5.5","email_message":"{summary}"},"conditional_groups":{"conditions":{"con_678629489871150":{"id":"con_678629489871150","name":"Show Text","type":"show","group":{"rw7104788064464449":{"cl9187398691353332":{"parent":"rw7104788064464449","field":"fld_5262727","compare":"is","value":"opt1154218"}}},"fields":{"cl9187398691353332":"fld_5262727"}},"con_6865021079274483":{"id":"con_6865021079274483","name":"Show Numbers","type":"show","fields":{"cl6646201099878921":"fld_6778974"},"group":{"rw555621137841073":{"cl6646201099878921":{"parent":"rw555621137841073","field":"fld_6778974","compare":"is","value":"opt1720237"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.5","db_id":"134","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF59f54cb2b84bb.json b/cypress/forms/CF59f54cb2b84bb.json new file mode 100644 index 000000000..38122ceb4 --- /dev/null +++ b/cypress/forms/CF59f54cb2b84bb.json @@ -0,0 +1 @@ +{"_last_updated":"Sun, 29 Oct 2017 04:20:47 +0000","ID":"CF59f54cb2b84bb","cf_version":"1.5.5","name":"X10 Conditionals Hide Single Page create@1.5.5","scroll_top":0,"description":"\t\t\t\t\t\t\t\t\t\t\t\t\t\t","success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_1705245":"1:1","fld_6561874":"1:2","fld_5216203":"2:1","fld_6501179":"3:1","fld_4732555":"3:2","fld_1059582":"4:1"},"structure":"6:6|12|6:6|12"},"fields":{"fld_1705245":{"ID":"fld_1705245","type":"number","label":"Number","slug":"number","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":6,"min":"","max":"","step":""}},"fld_6561874":{"ID":"fld_6561874","type":"text","label":"Text","slug":"text","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_5216203":{"ID":"fld_5216203","type":"dropdown","label":"Dropdown","slug":"dropdown","conditions":{"type":"con_3156693554561454"},"caption":"Hidden if number is less than 5 or number is 10 or Text contains \"hats\"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","show_values":1,"default":"opt1326030","option":{"opt1326030":{"calc_value":"Hide Email","value":"Hide Email","label":"Hide Email"},"opt1184564":{"calc_value":"Show Email","value":"Show Email","label":"Show Email"}}}},"fld_6501179":{"ID":"fld_6501179","type":"text","label":"Text2","slug":"text2","conditions":{"type":"con_3031277197960830"},"caption":"Hidden if Text starts with \"hats\"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_4732555":{"ID":"fld_4732555","type":"text","label":"Text3","slug":"text3","conditions":{"type":"con_1346082461777133"},"caption":"Hidden if Text 2 ends with \"hats\"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_1059582":{"ID":"fld_1059582","type":"email","label":"Email","slug":"email","conditions":{"type":"con_876637087772768"},"caption":"","config":{"custom_class":"","placeholder":"","default":""}}},"page_names":["Page 1"],"mailer":{"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"X10 Conditionals Hide Single Page create@1.5.5","email_message":"{summary}"},"conditional_groups":{"conditions":{"con_3156693554561454":{"id":"con_3156693554561454","name":"Hide Dropdown","type":"hide","fields":{"cl1059824988036823":"fld_1705245","cl181468538675662":"fld_1705245","cl863151122638094":"fld_6561874"},"group":{"rw7802324828821689":{"cl1059824988036823":{"parent":"rw7802324828821689","field":"fld_1705245","compare":"smaller","value":"5"}},"rw5464489746314226":{"cl181468538675662":{"parent":"rw5464489746314226","field":"fld_1705245","compare":"is","value":"10"}},"rw4611607856703894":{"cl863151122638094":{"parent":"rw4611607856703894","field":"fld_6561874","compare":"contains","value":"hats"}}}},"con_1346082461777133":{"id":"con_1346082461777133","name":"Hide Text3","type":"hide","fields":{"cl263703647524538":"fld_6501179"},"group":{"rw2736641049396765":{"cl263703647524538":{"parent":"rw2736641049396765","field":"fld_6501179","compare":"endswith","value":"hats"}}}},"con_3031277197960830":{"id":"con_3031277197960830","name":"Hide Text2","type":"hide","fields":{"cl5576521414369008":"fld_6561874"},"group":{"rw9789871914067001":{"cl5576521414369008":{"parent":"rw9789871914067001","field":"fld_6561874","compare":"startswith","value":"hats"}}}},"con_876637087772768":{"id":"con_876637087772768","name":"Hide Email","type":"hide","fields":{"cl5003410896543415":"fld_5216203"},"group":{"rw8266089423085521":{"cl5003410896543415":{"parent":"rw8266089423085521","field":"fld_5216203","compare":"is","value":"opt1326030"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.5","db_id":"205","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF59fb854b2f05f.json b/cypress/forms/CF59fb854b2f05f.json new file mode 100644 index 000000000..a59aa8f74 --- /dev/null +++ b/cypress/forms/CF59fb854b2f05f.json @@ -0,0 +1 @@ +{"_last_updated":"Thu, 02 Nov 2017 21:31:21 +0000","ID":"CF59fb854b2f05f","cf_version":"1.5.7-b-1","name":"2049 HTML\/Summary create@? dev@1.5.7","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_30547":"1:1","fld_7212795":"1:1","fld_9766093":"1:2","fld_3490198":"1:2","fld_6130370":"2:1"},"structure":"6:6|12"},"fields":{"fld_30547":{"ID":"fld_30547","type":"dropdown","label":"DropDown","slug":"dropdown","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"B","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"","option":{"opt1828784":{"calc_value":"","value":"A","label":"A"},"opt1175292":{"calc_value":"","value":"B","label":"B"}}}},"fld_9766093":{"ID":"fld_9766093","type":"filtered_select2","label":"Auto","slug":"auto","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","color":"#5b9dd9","border":"#4b8dc9","default_option":"D","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"","option":{"opt1933716":{"calc_value":"","value":"C","label":"C"},"opt1657602":{"calc_value":"","value":"D","label":"D"}}}},"fld_6130370":{"ID":"fld_6130370","type":"summary","label":"SUMMARY","slug":"summary","conditions":{"type":""},"caption":"","config":{"custom_class":""}},"fld_7212795":{"ID":"fld_7212795","type":"text","label":"DropDownSync","slug":"dropdownsync","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"%dropdown%","type_override":"text","mask":""}},"fld_3490198":{"ID":"fld_3490198","type":"text","label":"AutoSync","slug":"autosync","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"%auto%","type_override":"text","mask":""}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"2049 HTML\/Summary create@? dev@1.5.7","email_message":"{summary}"},"conditional_groups":{"fields":[]},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.7-b-1","db_id":"127","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5a047196d398f.json b/cypress/forms/CF5a047196d398f.json new file mode 100644 index 000000000..a58332292 --- /dev/null +++ b/cypress/forms/CF5a047196d398f.json @@ -0,0 +1 @@ +{"_last_updated":"Thu, 09 Nov 2017 17:20:12 +0000","ID":"CF5a047196d398f","cf_version":"1.5.7.1-b-1","name":"2063 Calculations create@1.6.2.2 dev@1.5.7.1","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_6564773":"1:1","fld_8938360":"1:2","fld_1741771":"2:2","fld_4880767":"3:1"},"structure":"6:6|6:6|12"},"fields":{"fld_6564773":{"ID":"fld_6564773","type":"number","label":"Number","slug":"number","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":5,"min":"","max":"","step":""}},"fld_8938360":{"ID":"fld_8938360","type":"number","label":"Number 2","slug":"number_2","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":10,"min":"","max":"","step":""}},"fld_1741771":{"ID":"fld_1741771","type":"calculation","label":"Calculation","slug":"calculation","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","formular":" ( fld_6564773+fld_8938360 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_6564773"},{"operator":"+","field":"fld_8938360"}]}]},"manual_formula":""}},"fld_4880767":{"ID":"fld_4880767","type":"button","label":"Submit Button","slug":"submit_button","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"x? Calc With Summary No Conditionals","email_message":"{summary}"},"conditional_groups":[],"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.7.1-b-1","db_id":"268","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5a0479e6025a2.json b/cypress/forms/CF5a0479e6025a2.json new file mode 100644 index 000000000..62be900fa --- /dev/null +++ b/cypress/forms/CF5a0479e6025a2.json @@ -0,0 +1 @@ +{"_last_updated":"Thu, 09 Nov 2017 15:54:49 +0000","ID":"CF5a0479e6025a2","cf_version":"1.5.7","name":"2063.2 Calculations create@1.6.2.2 dev@1.5.7.1","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_6496833":"1:1","fld_5119751":"1:2","fld_6564773":"2:1","fld_8938360":"2:2","fld_6634118":"3:1","fld_1741771":"3:2","fld_4880767":"4:1"},"structure":"6:6|6:6|6:6|12"},"fields":{"fld_6564773":{"ID":"fld_6564773","type":"number","label":"Number 1","slug":"number_1","conditions":{"type":"con_5696386943347504"},"caption":"","config":{"custom_class":"","placeholder":"","default":5,"min":"","max":"","step":""}},"fld_8938360":{"ID":"fld_8938360","type":"number","label":"Number 2","slug":"number_2","conditions":{"type":"con_2375082050202321"},"caption":"","config":{"custom_class":"","placeholder":"","default":10,"min":"","max":"","step":""}},"fld_6634118":{"ID":"fld_6634118","type":"summary","label":"Summary","slug":"summary","conditions":{"type":""},"caption":"","config":{"custom_class":""}},"fld_1741771":{"ID":"fld_1741771","type":"calculation","label":"Calculation","slug":"calculation","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","formular":" ( fld_6564773+fld_8938360 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_6564773"},{"operator":"+","field":"fld_8938360"}]}]},"manual_formula":""}},"fld_4880767":{"ID":"fld_4880767","type":"button","label":"Submit Button","slug":"submit_button","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}},"fld_5119751":{"ID":"fld_5119751","type":"dropdown","label":"Hide Number 2","slug":"hide_number_2","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"","option":{"opt1291731":{"calc_value":"","value":"Yes","label":"Yes"}}}},"fld_6496833":{"ID":"fld_6496833","type":"dropdown","label":"Hide Number 1","slug":"hide_number_1","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1291731":{"calc_value":"Yes","value":"Yes","label":"Yes"}}}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"2063.2 Calculations create@1.6.2.2 dev@1.5.7.1","email_message":"{summary}"},"conditional_groups":{"conditions":{"con_2375082050202321":{"id":"con_2375082050202321","name":"Hide Number 2","type":"hide","fields":{"cl101714245988547":"fld_5119751"},"group":{"rw1180340896177891":{"cl101714245988547":{"parent":"rw1180340896177891","field":"fld_5119751","compare":"is","value":"opt1291731"}}}},"con_5696386943347504":{"id":"con_5696386943347504","name":"Hide Number 1","type":"hide","group":{"rw2915338787670172":{"cl2852054196036451":{"parent":"rw2915338787670172","field":"fld_6496833","compare":"is","value":"opt1291731"}}},"fields":{"cl2852054196036451":"fld_6496833"}}}},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.7","db_id":"195","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5a1163356fe7c.json b/cypress/forms/CF5a1163356fe7c.json new file mode 100644 index 000000000..1c8cc0358 --- /dev/null +++ b/cypress/forms/CF5a1163356fe7c.json @@ -0,0 +1 @@ +{"_last_updated":"Wed, 13 Dec 2017 19:22:41 +0000","ID":"CF5a1163356fe7c","cf_version":"1.5.8-b-2","name":"2090 Select created@1.5.7.1 dev@1.5.8","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_7960462":"1:1","fld_6647575":"1:2","fld_8814449":"2:1","fld_6157072":"2:2"},"structure":"6:6|6:6"},"fields":{"fld_7960462":{"ID":"fld_7960462","type":"dropdown","label":"dropdown with default zero","slug":"dropdown_with_default_zero","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","show_values":1,"default":"opt1994719","option":{"opt1994719":{"calc_value":"","value":0,"label":0},"opt1737043":{"calc_value":"","value":1,"label":1},"opt1271608":{"calc_value":"","value":2,"label":2}}}},"fld_6647575":{"ID":"fld_6647575","type":"dropdown","label":"dropdown with default not zero","slug":"dropdown_with_default_not_zero","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","show_values":1,"option":{"opt1994719":{"calc_value":"","value":0,"label":0},"opt1737043":{"calc_value":"","value":1,"label":1},"opt1271608":{"calc_value":"","value":2,"label":2}},"default":"opt1737043"}},"fld_8814449":{"ID":"fld_8814449","type":"text","label":"TextField","slug":"textfield","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_6157072":{"ID":"fld_6157072","type":"button","label":"Submit","slug":"submit","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"admin@localhost.localdomain","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"dropdown and default zero","email_message":"{summary}"},"conditional_groups":[],"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.8-b-2","db_id":"274","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5a1de64c110ae.json b/cypress/forms/CF5a1de64c110ae.json new file mode 100644 index 000000000..829ab0b87 --- /dev/null +++ b/cypress/forms/CF5a1de64c110ae.json @@ -0,0 +1 @@ +{"_last_updated":"Wed, 13 Dec 2017 18:09:25 +0000","ID":"CF5a1de64c110ae","cf_version":"1.5.8-b-2","name":"2107 Credit Card created@? dev@1.5.8","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_2587005":"1:1","fld_9594894":"1:1","fld_8591050":"2:1","fld_6124340":"3:1","fld_4200620":"3:2","fld_9177438":"4:1"},"structure":"12#12|6:6|12"},"fields":{"fld_2587005":{"ID":"fld_2587005","type":"text","label":"Random Field","slug":"random_field","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":""}},"fld_9594894":{"ID":"fld_9594894","type":"button","label":"Next Page","slug":"next_page","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"next","class":"btn btn-default","target":""}},"fld_8591050":{"ID":"fld_8591050","type":"credit_card_number","label":"CC2","slug":"cc2","conditions":{"type":""},"required":1,"caption":"","config":{"custom_class":"","placeholder":"","default":"","exp":"fld_4200620"}},"fld_6124340":{"ID":"fld_6124340","type":"credit_card_exp","label":"Exp","slug":"exp","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":" \/ ","default":""}},"fld_4200620":{"ID":"fld_4200620","type":"credit_card_cvc","label":"Cvc","slug":"cvc","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","credit_card_field":""}},"fld_9177438":{"ID":"fld_9177438","type":"button","label":"Submit","slug":"submit","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}}},"page_names":["Page 1","Page 2"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"CF5a1de64c110aeFrom@email.ghostinspector.com","reply_to":"CF5a1de64c110aeReplyTo@email.ghostinspector.com","email_type":"html","recipients":"CF5a1de64c110aeTo@email.ghostinspector.com","bcc_to":"","email_subject":"CF5a1de64c110ae Subject","email_message":"

Summary<\/h1>\n{summary}\n\n
\n\n

Field Magic Tags<\/h2>\ncc2\u00a0<\/strong>%cc2%\n\nexp<\/strong> %exp%\n\nCvc<\/strong> %cvv%"},"conditional_groups":[],"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.8-b-2","db_id":"271","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5a303ca839615.json b/cypress/forms/CF5a303ca839615.json new file mode 100644 index 000000000..41093ce6b --- /dev/null +++ b/cypress/forms/CF5a303ca839615.json @@ -0,0 +1 @@ +{"_last_updated":"Tue, 12 Dec 2017 20:34:59 +0000","ID":"CF5a303ca839615","cf_version":"1.5.7.1","name":"2021 Adv File created@1.5.7.1 dev@1.5.8","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_5448072":"1:1","fld_3746795":"2:1"},"structure":"12|12"},"fields":{"fld_5448072":{"ID":"fld_5448072","type":"advanced_file","label":"File","slug":"file","conditions":{"type":""},"required":1,"caption":"","config":{"custom_class":"","media_lib":1,"multi_upload_text":"","allowed":""}},"fld_3746795":{"ID":"fld_3746795","type":"button","label":"Submit","slug":"submit","conditions":{"type":""},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"josh@calderawp.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"2021 Adv File created@1.5.7.1 dev@1.5.8","email_message":"{summary}"},"conditional_groups":{"fields":[]},"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.7.1","db_id":"265","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5a3193046927c.json b/cypress/forms/CF5a3193046927c.json new file mode 100644 index 000000000..17c5c0091 --- /dev/null +++ b/cypress/forms/CF5a3193046927c.json @@ -0,0 +1 @@ +{"_last_updated":"Wed, 13 Dec 2017 22:02:56 +0000","ID":"CF5a3193046927c","cf_version":"1.5.7-b-1","name":"2082 Calculations created@1.5.7.1 dev@1.5.8","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"check_honey":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_5132042":"1:1","fld_60384":"1:2","fld_9859374":"2:1","fld_6307999":"2:2","fld_3581183":"3:1"},"structure":"6:6|6:6|12"},"fields":{"fld_5132042":{"ID":"fld_5132042","type":"dropdown","label":"Select Default 7","slug":"select_default_7","conditions":{"type":""},"caption":"","config":{"custom_class":"","limit":0,"error":"Value already exists","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","option":{"opt1432383":{"calc_value":"","value":5,"label":5},"opt1660284":{"calc_value":"","value":7,"label":7}},"default":"opt1660284"}},"fld_60384":{"ID":"fld_60384","type":"number","label":"Number","slug":"number","conditions":{"type":""},"caption":"","config":{"custom_class":"","limit":0,"error":"Value already exists","placeholder":"","default":13,"min":"","max":"","step":""}},"fld_9859374":{"ID":"fld_9859374","type":"calculation","label":"Calculation","slug":"calculation","conditions":{"type":""},"caption":"","config":{"custom_class":"","limit":0,"error":"Value already exists","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","formular":" ( fld_5132042+fld_60384 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_5132042"},{"operator":"+","field":"fld_60384"}]}]},"manual_formula":""}},"fld_6307999":{"ID":"fld_6307999","type":"summary","label":"Summary","slug":"summary","conditions":{"type":""},"caption":"","config":{"custom_class":"","limit":0,"error":"Value already exists"}},"fld_3581183":{"ID":"fld_3581183","type":"button","label":"Submit","slug":"submit","conditions":{"type":""},"caption":"","config":{"custom_class":"","limit":0,"error":"Value already exists","type":"submit","class":"btn btn-default","target":""}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"f@nopm.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"2101 CF Field: Adv File created@1.5.5 dev@1.5.8","email_message":"{summary}"},"conditional_groups":[],"settings":{"responsive":{"break_point":"sm"}},"version":"1.5.7-b-1","db_id":"229","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5bc200019a22f.json b/cypress/forms/CF5bc200019a22f.json new file mode 100644 index 000000000..afb90c80f --- /dev/null +++ b/cypress/forms/CF5bc200019a22f.json @@ -0,0 +1 @@ +{"_last_updated":"Sat, 13 Oct 2018 20:53:26 +0000","ID":"CF5bc200019a22f","cf_version":"1.7.3-a.1","name":"Conditionals Text Show Type","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_6391426":"1:1","fld_471602":"2:1","fld_6735870":"2:1","fld_8484460":"2:1","fld_9936249":"2:1","fld_2782690":"2:1","fld_4533316":"3:1","fld_8729978":"3:1","fld_8576859":"3:1","fld_53474":"4:1","fld_7507195":"4:1"},"structure":"12|12|12|12"},"fields":{"fld_471602":{"ID":"fld_471602","type":"dropdown","label":"Visibility Control For Text Fields","slug":"visibility_control_for_text_fields","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","show_values":1,"option":{"opt1924316":{"calc_value":"","value":"showNumber","label":"Show Number Text Fields"},"opt1130717":{"calc_value":"","value":"showText","label":"Show Regular Text Fields"},"opt1772262":{"calc_value":"","value":"showAll","label":"Show All"},"opt1472371":{"calc_value":"","value":"showNone","label":"Show None"}},"email_identifier":0,"personally_identifying":0}},"fld_6735870":{"ID":"fld_6735870","type":"text","label":"Single Line Text No Default","slug":"single_line_text_no_default","conditions":{"type":"con_5283081262353062"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_8484460":{"ID":"fld_8484460","type":"text","label":"Single Line Text With Default","slug":"single_line_text_with_default","conditions":{"type":"con_5283081262353062"},"caption":"","config":{"custom_class":"","placeholder":"","default":"Hi Roy","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_9936249":{"ID":"fld_9936249","type":"text","label":"Single Line Text As Number With Default","slug":"single_line_text_as_number_with_default","conditions":{"type":"con_2842315677364160"},"caption":"","config":{"custom_class":"","placeholder":"","default":5,"type_override":"number","mask":"","email_identifier":0,"personally_identifying":0}},"fld_2782690":{"ID":"fld_2782690","type":"text","label":"Single Line Text As Number No Default","slug":"single_line_text_as_number_no_default","conditions":{"type":"con_2842315677364160"},"caption":"","config":{"custom_class":"","placeholder":"","default":"{entry_id}","type_override":"number","mask":"","email_identifier":0,"personally_identifying":0}},"fld_4533316":{"ID":"fld_4533316","type":"text","label":"Vis2","slug":"vis2","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_8729978":{"ID":"fld_8729978","type":"button","label":"Show If Vis2 Is","slug":"show_if_vis2_is_show_1_or_show_both","conditions":{"type":"con_8381806833976234"},"caption":"","config":{"custom_class":"","type":"button","class":"btn btn-default","target":""}},"fld_8576859":{"ID":"fld_8576859","type":"button","label":"Show If Vis2 Is","slug":"show_if_vis2_is_show_2_or_show_both","conditions":{"type":"con_7931766290311572"},"caption":"","config":{"custom_class":"","type":"button","class":"btn btn-default","target":""}},"fld_53474":{"ID":"fld_53474","type":"radio","label":"Show Masked Input","slug":"show_masked_input","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1935682":{"calc_value":"Yes","value":"Yes","label":"Yes"},"opt1618498":{"calc_value":"No","value":"No","label":"No"}},"email_identifier":0,"personally_identifying":0}},"fld_7507195":{"ID":"fld_7507195","type":"text","label":"Masked Input","slug":"masked_input","conditions":{"type":"con_9694237985517405"},"caption":"Pattern is 99-aa-**","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","masked":1,"mask":"99-aa-**","email_identifier":0,"personally_identifying":0}},"fld_6391426":{"ID":"fld_6391426","type":"html","label":"html__fld_6391426","slug":"html__fld_6391426","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":"Conditionals Text Show Type - CF5bc200019a22f"}}},"page_names":["Page 1"],"mailer":{"sender_name":"Caldera Forms Notification","sender_email":"test@test.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Text Conditionals","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_2842315677364160":{"id":"con_2842315677364160","name":"Show Number","type":"show","fields":{"cl8998653135566126":"fld_471602","cl8707449198311875":"fld_471602","cl7003519235235600":"fld_471602"},"group":{"rw4925759191836256":{"cl8998653135566126":{"parent":"rw4925759191836256","field":"fld_471602","compare":"is","value":"opt1924316"},"cl8707449198311875":{"parent":"rw4925759191836256","field":"fld_471602","compare":"isnot","value":"opt1472371"}},"rw4972066392084834":{"cl7003519235235600":{"parent":"rw4972066392084834","field":"fld_471602","compare":"is","value":"opt1772262"}}}},"con_5283081262353062":{"id":"con_5283081262353062","name":"Show Text Fields","type":"show","fields":{"cl4798238071787380":"fld_471602","cl6926075533960256":"fld_471602","cl5277059380734608":"fld_471602"},"group":{"rw4423788458516388":{"cl4798238071787380":{"parent":"rw4423788458516388","field":"fld_471602","compare":"is","value":"opt1130717"},"cl6926075533960256":{"parent":"rw4423788458516388","field":"fld_471602","compare":"isnot","value":"opt1472371"}},"rw1026340556008674":{"cl5277059380734608":{"parent":"rw1026340556008674","field":"fld_471602","compare":"is","value":"opt1772262"}}}},"con_8381806833976234":{"id":"con_8381806833976234","name":"Show Buttons 1","type":"show","fields":{"cl6393163237314319":"fld_4533316","cl2248932654546381":"fld_4533316"},"group":{"rw4746308834181047":{"cl6393163237314319":{"parent":"rw4746308834181047","field":"fld_4533316","compare":"is","value":"Show 1"}},"rw4349370827694148":{"cl2248932654546381":{"parent":"rw4349370827694148","field":"fld_4533316","compare":"is","value":"Show Both"}}}},"con_7931766290311572":{"id":"con_7931766290311572","name":"Show Buttons 2","type":"show","fields":{"cl48303517758755":"fld_4533316","cl525953112834206":"fld_4533316"},"group":{"rw9095289061082106":{"cl48303517758755":{"parent":"rw9095289061082106","field":"fld_4533316","compare":"is","value":"Show 2"}},"rw853102255304160":{"cl525953112834206":{"parent":"rw853102255304160","field":"fld_4533316","compare":"is","value":"Show Both"}}}},"con_9694237985517405":{"id":"con_9694237985517405","name":"Show Masked","type":"show","fields":{"cl2016572680079284":"fld_53474"},"group":{"rw3283476396158588":{"cl2016572680079284":{"parent":"rw3283476396158588","field":"fld_53474","compare":"is","value":"opt1935682"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.7.3-a.1","db_id":"159","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5bc21a0e818ab.json b/cypress/forms/CF5bc21a0e818ab.json new file mode 100644 index 000000000..252b26ef1 --- /dev/null +++ b/cypress/forms/CF5bc21a0e818ab.json @@ -0,0 +1 @@ +{"_last_updated":"Sat, 13 Oct 2018 20:44:01 +0000","ID":"CF5bc21a0e818ab","cf_version":"1.7.3-a.1","name":"Conditionals Disable Type","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_1609278":"1:1","fld_3067684":"2:1","fld_6740475":"2:1","fld_4913550":"2:1","fld_3414426":"2:1","fld_5149973":"2:1","fld_8059884":"2:1","fld_7867333":"2:1","fld_8461580":"2:1","fld_9551037":"2:2","fld_9529943":"2:2"},"structure":"12|6:6"},"fields":{"fld_3067684":{"ID":"fld_3067684","type":"text","label":"Text Field","slug":"text_field","conditions":{"type":"con_478215290566727"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_6740475":{"ID":"fld_6740475","type":"color_picker","label":"Color","slug":"color","conditions":{"type":"con_35226924488563"},"caption":"","config":{"custom_class":"","default":"#FFFFFF","email_identifier":0,"personally_identifying":0}},"fld_4913550":{"ID":"fld_4913550","type":"phone_better","label":"Phone Better","slug":"phone_better","conditions":{"type":"con_5340877157515144"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","email_identifier":0,"personally_identifying":0}},"fld_3414426":{"ID":"fld_3414426","type":"phone","label":"Phone Basic","slug":"phone_basic","conditions":{"type":"con_1962102314995787"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type":"local","custom":"(999)999-9999","email_identifier":0,"personally_identifying":0}},"fld_5149973":{"ID":"fld_5149973","type":"calculation","label":"Calc","slug":"calc","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","formular":"fld_8059884","config":{"group":[{"lines":[{"operator":"+","field":"fld_8059884"}]}]},"manual_formula":"","email_identifier":0,"personally_identifying":0}},"fld_8059884":{"ID":"fld_8059884","type":"number","label":"Number","slug":"number","conditions":{"type":"con_4112921792900024"},"caption":"","config":{"custom_class":"","placeholder":"","default":5,"min":1,"max":22,"step":"","email_identifier":0,"personally_identifying":0}},"fld_7867333":{"ID":"fld_7867333","type":"email","label":"Email Field","slug":"email_field","conditions":{"type":"con_674955481691487"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","email_identifier":0,"personally_identifying":0}},"fld_8461580":{"ID":"fld_8461580","type":"url","label":"Url Field","slug":"url_field","conditions":{"type":"con_3484680456520917"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","email_identifier":0,"personally_identifying":0}},"fld_9551037":{"ID":"fld_9551037","type":"checkbox","label":"Disabler","slug":"disabler","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1575478":{"calc_value":"disableSubmit","value":"disableSubmit","label":"disableSubmit"},"opt1670685":{"calc_value":"disableText","value":"disableText","label":"disableText"},"opt1186417":{"calc_value":"disablePhoneBasic","value":"disablePhoneBasic","label":"disablePhoneBasic"},"opt1057165":{"calc_value":"disableColor","value":"disableColor","label":"disableColor"},"opt1795735":{"calc_value":"disableNone","value":"disableNone","label":"disableNone"},"opt1127181":{"calc_value":"disablePhoneBetter","value":"disablePhoneBetter","label":"disablePhoneBetter"},"opt1629374":{"calc_value":"disableNumber","value":"disableNumber","label":"disableNumber"},"opt1662521":{"calc_value":"disableUrl","value":"disableUrl","label":"disableUrl"},"opt1439102":{"calc_value":"disableEmail","value":"disableEmail","label":"disableEmail"}},"email_identifier":0,"personally_identifying":0}},"fld_9529943":{"ID":"fld_9529943","type":"button","label":"Submit","slug":"submit","conditions":{"type":"con_3164199445400861"},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}},"fld_1609278":{"ID":"fld_1609278","type":"html","label":"html__fld_1609278","slug":"html__fld_1609278","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":"Conditionals Disable Type - CF5bc21a0e818ab"}}},"page_names":["Page 1"],"mailer":{"sender_name":"Caldera Forms Notification","sender_email":"test@test.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Conditionals Disable","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_478215290566727":{"id":"con_478215290566727","name":"Disable Text","type":"disable","fields":{"cl856008058520048":"fld_9551037","cl1198483466396118":"fld_9551037"},"group":{"rw6586430039034362":{"cl856008058520048":{"parent":"rw6586430039034362","field":"fld_9551037","compare":"is","value":"opt1670685"},"cl1198483466396118":{"parent":"rw6586430039034362","field":"fld_9551037","compare":"isnot","value":"opt1795735"}}}},"con_5340877157515144":{"id":"con_5340877157515144","name":"Disable Phone Better","type":"disable","fields":{"cl331976511761738":"fld_9551037","cl5640809557568771":"fld_9551037"},"group":{"rw5046187487869534":{"cl331976511761738":{"parent":"rw5046187487869534","field":"fld_9551037","compare":"is","value":"opt1127181"},"cl5640809557568771":{"parent":"rw5046187487869534","field":"fld_9551037","compare":"isnot","value":"opt1795735"}}}},"con_1962102314995787":{"id":"con_1962102314995787","name":"Disable Phone Basic","type":"disable","fields":{"cl682141646554133":"fld_9551037","cl9332574820763505":"fld_9551037"},"group":{"rw954145040323850":{"cl682141646554133":{"parent":"rw954145040323850","field":"fld_9551037","compare":"is","value":"opt1186417"},"cl9332574820763505":{"parent":"rw954145040323850","field":"fld_9551037","compare":"isnot","value":"opt1795735"}}}},"con_35226924488563":{"id":"con_35226924488563","name":"Disable Color","type":"disable","fields":{"cl4399422340940034":"fld_9551037","cl4676915685605520":"fld_9551037"},"group":{"rw999516584283032":{"cl4399422340940034":{"parent":"rw999516584283032","field":"fld_9551037","compare":"is","value":"opt1057165"},"cl4676915685605520":{"parent":"rw999516584283032","field":"fld_9551037","compare":"isnot","value":"opt1795735"}}}},"con_3164199445400861":{"id":"con_3164199445400861","name":"Disable Submit","type":"disable","fields":{"cl5667487423603003":"fld_9551037","cl3009144394328042":"fld_9551037"},"group":{"rw4864496021207149":{"cl5667487423603003":{"parent":"rw4864496021207149","field":"fld_9551037","compare":"is","value":"opt1575478"},"cl3009144394328042":{"parent":"rw4864496021207149","field":"fld_9551037","compare":"isnot","value":"opt1795735"}}}},"con_4112921792900024":{"id":"con_4112921792900024","name":"Disable Number","type":"disable","fields":{"cl5107761046001036":"fld_9551037","cl9055219177682530":"fld_9551037"},"group":{"rw9054305766598436":{"cl5107761046001036":{"parent":"rw9054305766598436","field":"fld_9551037","compare":"is","value":"opt1629374"},"cl9055219177682530":{"parent":"rw9054305766598436","field":"fld_9551037","compare":"isnot","value":"opt1795735"}}}},"con_3484680456520917":{"id":"con_3484680456520917","name":"Disable Url","type":"disable","fields":{"cl3083244228819129":"fld_9551037","cl3346123091571619":"fld_9551037"},"group":{"rw7388374615074148":{"cl3083244228819129":{"parent":"rw7388374615074148","field":"fld_9551037","compare":"is","value":"opt1662521"},"cl3346123091571619":{"parent":"rw7388374615074148","field":"fld_9551037","compare":"isnot","value":"opt1795735"}}}},"con_674955481691487":{"id":"con_674955481691487","name":"Disable Email","type":"disable","fields":{"cl6502233271345673":"fld_9551037","cl339145884746241":"fld_9551037"},"group":{"rw8989949440948255":{"cl6502233271345673":{"parent":"rw8989949440948255","field":"fld_9551037","compare":"is","value":"opt1439102"},"cl339145884746241":{"parent":"rw8989949440948255","field":"fld_9551037","compare":"isnot","value":"opt1795735"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.7.3-a.1","db_id":"150","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5bc235072e2a8.json b/cypress/forms/CF5bc235072e2a8.json new file mode 100644 index 000000000..948907249 --- /dev/null +++ b/cypress/forms/CF5bc235072e2a8.json @@ -0,0 +1 @@ +{"_last_updated":"Sat, 13 Oct 2018 20:46:12 +0000","ID":"CF5bc235072e2a8","cf_version":"1.7.3-a.1","name":"Show Conditionals Select","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_7699993":"1:1","fld_7176956":"2:1","fld_1034558":"2:1","fld_5440278":"2:2","fld_921826":"2:2","fld_7631843":"3:1","fld_464591":"3:2","fld_1734075":"4:1","fld_520708":"4:2","fld_7673890":"4:2","fld_8736564":"4:2","fld_5313777":"4:2","fld_888212":"4:2"},"structure":"12|6:6|6:6|6:6"},"fields":{"fld_7176956":{"ID":"fld_7176956","type":"checkbox","label":"Vis1","slug":"vis1","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","show_values":1,"option":{"opt1222077":{"calc_value":1,"value":"show1","label":"Show Checkbox 1"},"opt1658939":{"calc_value":2,"value":"show2","label":"Show Checkbox 2"},"opt1374739":{"calc_value":0,"value":"showBoth","label":"Show Both"}},"email_identifier":0,"personally_identifying":0}},"fld_1034558":{"ID":"fld_1034558","type":"text","label":"Extra Field","slug":"extra_field","conditions":{"type":"con_3161308535177989"},"caption":"Show If ck1a and ck3b or ck2b","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_5440278":{"ID":"fld_5440278","type":"checkbox","label":"Checkbox 1","slug":"checkbox_1","conditions":{"type":"con_7012397333469882"},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","option":{"opt1422103":{"calc_value":"ck1a","value":"ck1a","label":"ck1a"},"opt1365401":{"calc_value":"ck1b","value":"ck1b","label":"ck1b"},"opt1810677":{"calc_value":"ck1c","value":"ck1c","label":"ck1c"}},"default":"opt1810677","email_identifier":0,"personally_identifying":0}},"fld_921826":{"ID":"fld_921826","type":"checkbox","label":"Checkbox2","slug":"checkbox2","conditions":{"type":"con_4593223126358631"},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1984556":{"calc_value":"ck2a","value":"ck2a","label":"ck2a"},"opt1354827":{"calc_value":"ck2b","value":"ck2b","label":"ck2b"},"opt1528096":{"calc_value":"ck3b","value":"ck3b","label":"ck3b"}},"email_identifier":0,"personally_identifying":0}},"fld_7631843":{"ID":"fld_7631843","type":"radio","label":"Show Radio 1","slug":"show_radio_1","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"opt1072479","option":{"opt1072479":{"calc_value":"Yes","value":"Yes","label":"Yes"},"opt1283109":{"calc_value":"No","value":"No","label":"No"}},"email_identifier":0,"personally_identifying":0}},"fld_464591":{"ID":"fld_464591","type":"radio","label":"Radio1","slug":"radio1","conditions":{"type":"con_5890923569910506"},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","option":{"opt1173457":{"calc_value":"r1a","value":"r1a","label":"r1a"},"opt1763725":{"calc_value":"r1b","value":"r1b","label":"r1b"},"opt1279042":{"calc_value":"r1c","value":"r1c","label":"r1c"}},"default":"opt1763725","email_identifier":0,"personally_identifying":0}},"fld_1734075":{"ID":"fld_1734075","type":"radio","label":"Show Others","slug":"show_others","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"opt1072479","option":{"opt1072479":{"calc_value":"Yes","value":"Yes","label":"Yes"},"opt1283109":{"calc_value":"No","value":"No","label":"No"}},"email_identifier":0,"personally_identifying":0}},"fld_520708":{"ID":"fld_520708","type":"dropdown","label":"Dropdown","slug":"dropdown","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","option":{"opt1285177":{"calc_value":"s1a","value":"s1a","label":"s1a"},"opt1057631":{"calc_value":"s1b","value":"s1b","label":"s1b"},"opt1802025":{"calc_value":"s1c","value":"s1c","label":"s1c"}},"default":"opt1057631","email_identifier":0,"personally_identifying":0}},"fld_7673890":{"ID":"fld_7673890","type":"filtered_select2","label":"Auto","slug":"auto","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","placeholder":"","color":"#5b9dd9","border":"#4b8dc9","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","option":{"opt1898315":{"calc_value":"a1a","value":"a1a","label":"a1a"},"opt1624156":{"calc_value":"a1b","value":"a1b","label":"a1b"},"opt1063712":{"calc_value":"a1c","value":"a1c","label":"a1c"}},"default":"opt1624156","email_identifier":0,"personally_identifying":0}},"fld_8736564":{"ID":"fld_8736564","type":"toggle_switch","label":"Toggle","slug":"toggle","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","orientation":"horizontal","selected_class":"btn-success","default_class":"btn-default","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1511276":{"calc_value":"t1a","value":"t1a","label":"t1a"},"opt1756040":{"calc_value":"t1b","value":"t1b","label":"t1b"}},"email_identifier":0,"personally_identifying":0}},"fld_5313777":{"ID":"fld_5313777","type":"states","label":"State or Providence","slug":"state_or_providence","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","email_identifier":0,"personally_identifying":0}},"fld_888212":{"ID":"fld_888212","type":"date_picker","label":"Date Picker","slug":"date_picker","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","default":"2112-12-12","format":"yyyy-mm-dd","autoclose":1,"start_view":"month","start_date":"","end_date":"","language":"","email_identifier":0,"personally_identifying":0}},"fld_7699993":{"ID":"fld_7699993","type":"html","label":"html__fld_7699993","slug":"html__fld_7699993","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":"Show Conditionals Select - CF5bc235072e2a8"}}},"page_names":["Page 1"],"mailer":{"sender_name":"Caldera Forms Notification","sender_email":"test@test.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Conditionals Based On Checkboxes","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_7012397333469882":{"id":"con_7012397333469882","name":"Show Checkbox 1","type":"show","fields":{"cl6452027818682914":"fld_7176956","cl7633168522686554":"fld_7176956"},"group":{"rw4304142764421899":{"cl6452027818682914":{"parent":"rw4304142764421899","field":"fld_7176956","compare":"is","value":"opt1222077"}},"rw3560795367993632":{"cl7633168522686554":{"parent":"rw3560795367993632","field":"fld_7176956","compare":"is","value":"opt1374739"}}}},"con_4593223126358631":{"id":"con_4593223126358631","name":"Show Checkbox 2","type":"show","fields":{"cl3433179449981586":"fld_7176956","cl2458761650173962":"fld_7176956"},"group":{"rw2081917712631571":{"cl3433179449981586":{"parent":"rw2081917712631571","field":"fld_7176956","compare":"is","value":"opt1658939"}},"rw4470892962462226":{"cl2458761650173962":{"parent":"rw4470892962462226","field":"fld_7176956","compare":"is","value":"opt1374739"}}}},"con_3161308535177989":{"id":"con_3161308535177989","name":"Show If ck1a and ck3b or ck2b","type":"show","fields":{"cl572863575635026":"fld_5440278","cl8123980017677754":"fld_921826","cl5783312018810441":"fld_921826"},"group":{"rw97879129151270":{"cl572863575635026":{"parent":"rw97879129151270","field":"fld_5440278","compare":"is","value":"opt1422103"},"cl8123980017677754":{"parent":"rw97879129151270","field":"fld_921826","compare":"is","value":"opt1528096"}},"rw726343265884916":{"cl5783312018810441":{"parent":"rw726343265884916","field":"fld_921826","compare":"is","value":"opt1354827"}}}},"con_5890923569910506":{"id":"con_5890923569910506","name":"Show Radio 1","type":"show","fields":{"cl1434661062391646":"fld_7631843"},"group":{"rw7403989478416969":{"cl1434661062391646":{"parent":"rw7403989478416969","field":"fld_7631843","compare":"is","value":"opt1072479"}}}},"con_1830889290198769":{"id":"con_1830889290198769","name":"Show Others","type":"show","fields":{"cl59227711206104":"fld_1734075"},"group":{"rw8684004351765245":{"cl59227711206104":{"parent":"rw8684004351765245","field":"fld_1734075","compare":"is","value":"opt1072479"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.7.3-a.1","db_id":"156","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5bc25738c82c2.json b/cypress/forms/CF5bc25738c82c2.json new file mode 100644 index 000000000..809d91330 --- /dev/null +++ b/cypress/forms/CF5bc25738c82c2.json @@ -0,0 +1 @@ +{"_last_updated":"Sat, 13 Oct 2018 20:52:58 +0000","ID":"CF5bc25738c82c2","cf_version":"1.7.3-a.1","name":"Conditionals Text Hide Type","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_9863227":"1:1","fld_471602":"2:1","fld_6735870":"2:1","fld_8484460":"2:1","fld_9936249":"2:1","fld_2782690":"2:1","fld_4533316":"3:1","fld_8729978":"3:1","fld_8576859":"3:1","fld_53474":"4:1","fld_7507195":"4:1"},"structure":"12|12|12|12"},"fields":{"fld_9863227":{"ID":"fld_9863227","type":"html","label":"html__fld_9863227","slug":"html__fld_9863227","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":"Conditionals Text Hide Type - CF5bc25738c82c2"}},"fld_471602":{"ID":"fld_471602","type":"dropdown","label":"Visibility Control For Text Fields","slug":"visibility_control_for_text_fields","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","show_values":1,"option":{"opt1924316":{"calc_value":1,"value":"hideNumber","label":"Hide Number Text Fields"},"opt1130717":{"calc_value":1,"value":"hideText","label":"Hide Regular Text Fields"},"opt1772262":{"calc_value":1,"value":"hideAll","label":"Hide All"},"opt1472371":{"calc_value":1,"value":"hideNone","label":"Hide None"}},"email_identifier":0,"personally_identifying":0}},"fld_6735870":{"ID":"fld_6735870","type":"text","label":"Single Line Text No Default","slug":"single_line_text_no_default","conditions":{"type":"con_5283081262353062"},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_8484460":{"ID":"fld_8484460","type":"text","label":"Single Line Text With Default","slug":"single_line_text_with_default","conditions":{"type":"con_5283081262353062"},"caption":"","config":{"custom_class":"","placeholder":"","default":"Hi Roy","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_9936249":{"ID":"fld_9936249","type":"text","label":"Single Line Text As Number With Default","slug":"single_line_text_as_number_with_default","conditions":{"type":"con_2842315677364160"},"caption":"","config":{"custom_class":"","placeholder":"","default":5,"type_override":"number","mask":"","email_identifier":0,"personally_identifying":0}},"fld_2782690":{"ID":"fld_2782690","type":"text","label":"Single Line Text As Number No Default","slug":"single_line_text_as_number_no_default","conditions":{"type":"con_2842315677364160"},"caption":"","config":{"custom_class":"","placeholder":"","default":"{entry_id}","type_override":"number","mask":"","email_identifier":0,"personally_identifying":0}},"fld_4533316":{"ID":"fld_4533316","type":"text","label":"Vis2","slug":"vis2","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_8729978":{"ID":"fld_8729978","type":"button","label":"Hide If Vis2 Is","slug":"hide_if_vis2_is_hide_1_or_hide_both","conditions":{"type":"con_8381806833976234"},"caption":"","config":{"custom_class":"","type":"button","class":"btn btn-default","target":""}},"fld_8576859":{"ID":"fld_8576859","type":"button","label":"Hide If Vis2 Is","slug":"hide_if_vis2_is_hide_2_or_hide_both","conditions":{"type":"con_7931766290311572"},"caption":"","config":{"custom_class":"","type":"button","class":"btn btn-default","target":""}},"fld_53474":{"ID":"fld_53474","type":"radio","label":"Hide Masked Input","slug":"hide_masked_input","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1935682":{"calc_value":"Yes","value":"Yes","label":"Yes"},"opt1618498":{"calc_value":"No","value":"No","label":"No"}},"email_identifier":0,"personally_identifying":0}},"fld_7507195":{"ID":"fld_7507195","type":"text","label":"Masked Input","slug":"masked_input","conditions":{"type":"con_9694237985517405"},"caption":"Pattern is 99-aa-**","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","masked":1,"mask":"99-aa-**","email_identifier":0,"personally_identifying":0}}},"page_names":["Page 1"],"mailer":{"sender_name":"Caldera Forms Notification","sender_email":"test@test.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Text Conditionals","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_2842315677364160":{"id":"con_2842315677364160","name":"Hide Number","type":"hide","fields":{"cl8998653135566126":"fld_471602","cl8707449198311875":"fld_471602","cl7003519235235600":"fld_471602"},"group":{"rw4925759191836256":{"cl8998653135566126":{"parent":"rw4925759191836256","field":"fld_471602","compare":"is","value":"opt1924316"},"cl8707449198311875":{"parent":"rw4925759191836256","field":"fld_471602","compare":"isnot","value":"opt1472371"}},"rw4972066392084834":{"cl7003519235235600":{"parent":"rw4972066392084834","field":"fld_471602","compare":"is","value":"opt1772262"}}}},"con_5283081262353062":{"id":"con_5283081262353062","name":"Hide Text Fields","type":"hide","fields":{"cl4798238071787380":"fld_471602","cl6926075533960256":"fld_471602","cl5277059380734608":"fld_471602"},"group":{"rw4423788458516388":{"cl4798238071787380":{"parent":"rw4423788458516388","field":"fld_471602","compare":"is","value":"opt1130717"},"cl6926075533960256":{"parent":"rw4423788458516388","field":"fld_471602","compare":"isnot","value":"opt1472371"}},"rw1026340556008674":{"cl5277059380734608":{"parent":"rw1026340556008674","field":"fld_471602","compare":"is","value":"opt1772262"}}}},"con_8381806833976234":{"id":"con_8381806833976234","name":"Hide Buttons 1","type":"hide","fields":{"cl6393163237314319":"fld_4533316","cl2248932654546381":"fld_4533316"},"group":{"rw4746308834181047":{"cl6393163237314319":{"parent":"rw4746308834181047","field":"fld_4533316","compare":"is","value":"Hide 1"}},"rw4349370827694148":{"cl2248932654546381":{"parent":"rw4349370827694148","field":"fld_4533316","compare":"is","value":"Hide Both"}}}},"con_7931766290311572":{"id":"con_7931766290311572","name":"Hide Buttons 2","type":"hide","fields":{"cl48303517758755":"fld_4533316","cl525953112834206":"fld_4533316"},"group":{"rw9095289061082106":{"cl48303517758755":{"parent":"rw9095289061082106","field":"fld_4533316","compare":"is","value":"Hide 2"}},"rw853102255304160":{"cl525953112834206":{"parent":"rw853102255304160","field":"fld_4533316","compare":"is","value":"Hide Both"}}}},"con_9694237985517405":{"id":"con_9694237985517405","name":"Hide Masked","type":"hide","fields":{"cl2016572680079284":"fld_53474"},"group":{"rw3283476396158588":{"cl2016572680079284":{"parent":"rw3283476396158588","field":"fld_53474","compare":"is","value":"opt1935682"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.7.3-a.1","db_id":"158","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5bc257d7eb85a.json b/cypress/forms/CF5bc257d7eb85a.json new file mode 100644 index 000000000..8ba179063 --- /dev/null +++ b/cypress/forms/CF5bc257d7eb85a.json @@ -0,0 +1 @@ +{"_last_updated":"Sat, 13 Oct 2018 20:44:27 +0000","ID":"CF5bc257d7eb85a","cf_version":"1.7.3-a.1","name":"Conditionals Select Hide Type","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":null,"form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_9010471":"1:1","fld_7176956":"2:1","fld_1034558":"2:1","fld_5440278":"2:2","fld_921826":"2:2","fld_7631843":"3:1","fld_464591":"3:2","fld_1734075":"4:1","fld_520708":"4:2","fld_7673890":"4:2","fld_8736564":"4:2","fld_5313777":"4:2","fld_888212":"4:2"},"structure":"12|6:6|6:6|6:6"},"fields":{"fld_7176956":{"ID":"fld_7176956","type":"checkbox","label":"Vis1","slug":"vis1","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","show_values":1,"option":{"opt1222077":{"calc_value":1,"value":"hide1","label":"Hide Checkbox 1"},"opt1658939":{"calc_value":1,"value":"hide2","label":"Hide Checkbox 2"},"opt1374739":{"calc_value":1,"value":"hideNone","label":"Hide Neither"}},"email_identifier":0,"personally_identifying":0}},"fld_1034558":{"ID":"fld_1034558","type":"text","label":"Extra Field","slug":"extra_field","conditions":{"type":"con_3161308535177989"},"caption":"Hide If ck1a and ck3b or ck2b","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_5440278":{"ID":"fld_5440278","type":"checkbox","label":"Checkbox 1","slug":"checkbox_1","conditions":{"type":"con_7012397333469882"},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1422103":{"calc_value":"ck1a","value":"ck1a","label":"ck1a"},"opt1365401":{"calc_value":"ck1b","value":"ck1b","label":"ck1b"},"opt1810677":{"calc_value":"ck1c","value":"ck1c","label":"ck1c"}},"email_identifier":0,"personally_identifying":0}},"fld_921826":{"ID":"fld_921826","type":"checkbox","label":"Checkbox2","slug":"checkbox2","conditions":{"type":"con_4593223126358631"},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1984556":{"calc_value":"ck2a","value":"ck2a","label":"ck2a"},"opt1354827":{"calc_value":"ck2b","value":"ck2b","label":"ck2b"},"opt1528096":{"calc_value":"ck3b","value":"ck3b","label":"ck3b"}},"email_identifier":0,"personally_identifying":0}},"fld_7631843":{"ID":"fld_7631843","type":"radio","label":"Hide Radio 1","slug":"hide_radio_1","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"opt1072479","option":{"opt1072479":{"calc_value":"Yes","value":"Yes","label":"Yes"},"opt1283109":{"calc_value":"No","value":"No","label":"No"}},"email_identifier":0,"personally_identifying":0}},"fld_464591":{"ID":"fld_464591","type":"radio","label":"Radio1","slug":"radio1","conditions":{"type":"con_5890923569910506"},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1173457":{"calc_value":"r1a","value":"r1a","label":"r1a"},"opt1763725":{"calc_value":"r2b","value":"r2b","label":"r2b"}},"email_identifier":0,"personally_identifying":0}},"fld_1734075":{"ID":"fld_1734075","type":"radio","label":"Hide Others","slug":"show_others","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"opt1072479","option":{"opt1072479":{"calc_value":"Yes","value":"Yes","label":"Yes"},"opt1283109":{"calc_value":"No","value":"No","label":"No"}},"email_identifier":0,"personally_identifying":0}},"fld_520708":{"ID":"fld_520708","type":"dropdown","label":"Dropdown","slug":"dropdown","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1285177":{"calc_value":"s1a","value":"s1a","label":"s1a"},"opt1057631":{"calc_value":"s1b","value":"s1b","label":"s1b"}},"email_identifier":0,"personally_identifying":0}},"fld_7673890":{"ID":"fld_7673890","type":"filtered_select2","label":"Auto","slug":"auto","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","placeholder":"","color":"#5b9dd9","border":"#4b8dc9","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","option":{"opt1898315":{"calc_value":"a1a","value":"a1a","label":"a1a"},"opt1624156":{"calc_value":"a1b","value":"a1b","label":"a1b"},"opt1063712":{"calc_value":"a1c","value":"a1c","label":"a1c"}},"default":"opt1624156","email_identifier":0,"personally_identifying":0}},"fld_8736564":{"ID":"fld_8736564","type":"toggle_switch","label":"Toggle","slug":"toggle","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","orientation":"horizontal","selected_class":"btn-success","default_class":"btn-default","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1511276":{"calc_value":"t1a","value":"t1a","label":"t1a"},"opt1756040":{"calc_value":"t1b","value":"t1b","label":"t1b"}},"email_identifier":0,"personally_identifying":0}},"fld_5313777":{"ID":"fld_5313777","type":"states","label":"State or Providence","slug":"state_or_providence","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","email_identifier":0,"personally_identifying":0}},"fld_888212":{"ID":"fld_888212","type":"date_picker","label":"Date Picker","slug":"date_picker","conditions":{"type":"con_1830889290198769"},"caption":"","config":{"custom_class":"","default":"2112-12-12","format":"yyyy-mm-dd","autoclose":1,"start_view":"month","start_date":"","end_date":"","language":"","email_identifier":0,"personally_identifying":0}},"fld_9010471":{"ID":"fld_9010471","type":"html","label":"html__fld_9010471","slug":"html__fld_9010471","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":"Conditionals Select Hide Type - CF5bc257d7eb85a"}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"test@test.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Conditionals Based On Checkboxes","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_7012397333469882":{"id":"con_7012397333469882","name":"Hide Checkbox 1","type":"hide","fields":{"cl6452027818682914":"fld_7176956","cl5619304692596079":"fld_7176956"},"group":{"rw4304142764421899":{"cl6452027818682914":{"parent":"rw4304142764421899","field":"fld_7176956","compare":"is","value":"opt1222077"},"cl5619304692596079":{"parent":"rw4304142764421899","field":"fld_7176956","compare":"isnot","value":"opt1374739"}}}},"con_4593223126358631":{"id":"con_4593223126358631","name":"Hide Checkbox 2","type":"hide","fields":{"cl3433179449981586":"fld_7176956","cl565772702213177":"fld_7176956"},"group":{"rw2081917712631571":{"cl3433179449981586":{"parent":"rw2081917712631571","field":"fld_7176956","compare":"is","value":"opt1658939"},"cl565772702213177":{"parent":"rw2081917712631571","field":"fld_7176956","compare":"isnot","value":"opt1374739"}}}},"con_3161308535177989":{"id":"con_3161308535177989","name":"Hide If ck1a and ck3b or ck2b","type":"hide","fields":{"cl572863575635026":"fld_5440278","cl8123980017677754":"fld_921826","cl5783312018810441":"fld_921826"},"group":{"rw97879129151270":{"cl572863575635026":{"parent":"rw97879129151270","field":"fld_5440278","compare":"is","value":"opt1422103"},"cl8123980017677754":{"parent":"rw97879129151270","field":"fld_921826","compare":"is","value":"opt1528096"}},"rw726343265884916":{"cl5783312018810441":{"parent":"rw726343265884916","field":"fld_921826","compare":"is","value":"opt1354827"}}}},"con_5890923569910506":{"id":"con_5890923569910506","name":"Hide Radio 1","type":"hide","fields":{"cl1434661062391646":"fld_7631843"},"group":{"rw7403989478416969":{"cl1434661062391646":{"parent":"rw7403989478416969","field":"fld_7631843","compare":"is","value":"opt1072479"}}}},"con_1830889290198769":{"id":"con_1830889290198769","name":"Hide Others","type":"hide","fields":{"cl59227711206104":"fld_1734075"},"group":{"rw8684004351765245":{"cl59227711206104":{"parent":"rw8684004351765245","field":"fld_1734075","compare":"is","value":"opt1072479"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.7.3-a.1","db_id":"151","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5bc25cfa53898.json b/cypress/forms/CF5bc25cfa53898.json new file mode 100644 index 000000000..0f4e7d259 --- /dev/null +++ b/cypress/forms/CF5bc25cfa53898.json @@ -0,0 +1 @@ +{"_last_updated":"Sat, 13 Oct 2018 21:26:27 +0000","ID":"CF5bc25cfa53898","cf_version":"1.7.3-a.1","name":"Calculation Money","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_4053061":"1:1","fld_3231357":"2:1","fld_3087149":"2:2","fld_9132898":"2:2","fld_8673305":"3:1","fld_7613122":"3:2","fld_6377680":"3:2","fld_8223213":"4:1","fld_3612279":"4:2","fld_3489682":"4:2","fld_1402277":"4:2"},"structure":"12|6:6|6:6|6:6"},"fields":{"fld_4053061":{"ID":"fld_4053061","type":"html","label":"html__fld_4053061","slug":"html__fld_4053061","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":"Calculation Automatic - CF5bc25cfa53898"}},"fld_3231357":{"ID":"fld_3231357","type":"calculation","label":"Calc1","slug":"calc1","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","formular":" ( fld_3087149*fld_9132898 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_3087149"},{"operator":"*","field":"fld_9132898"}]}]},"manual_formula":"","email_identifier":0,"personally_identifying":0}},"fld_3087149":{"ID":"fld_3087149","type":"number","label":"Quantity","slug":"quantity","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":5,"min":0,"max":50,"step":"","email_identifier":0,"personally_identifying":0}},"fld_9132898":{"ID":"fld_9132898","type":"dropdown","label":"Price Option","slug":"price_option","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","show_values":1,"option":{"opt1369752":{"calc_value":100,"value":1,"label":"Option 1 (cost 100)"},"opt1442507":{"calc_value":1,"value":2,"label":"Option 2 (cost 10)"}},"default":"opt1442507","email_identifier":0,"personally_identifying":0}},"fld_8673305":{"ID":"fld_8673305","type":"calculation","label":"Calc With Options 1+2","slug":"calc_with_options_12","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","formular":" ( fld_3231357+fld_7613122+fld_6377680 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_3231357"},{"operator":"+","field":"fld_7613122"},{"operator":"+","field":"fld_6377680"}]}]},"manual_formula":"","email_identifier":0,"personally_identifying":0}},"fld_7613122":{"ID":"fld_7613122","type":"radio","label":"Option 2","slug":"option_2","conditions":{"type":""},"caption":"Radio With No Value Or Option","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1756084":{"calc_value":1,"value":1,"label":1},"opt1675773":{"calc_value":2,"value":2,"label":2},"opt1412775":{"calc_value":3,"value":3,"label":3}},"email_identifier":0,"personally_identifying":0}},"fld_6377680":{"ID":"fld_6377680","type":"radio","label":"Option 3","slug":"option_3","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","show_values":1,"option":{"opt1922004":{"calc_value":10,"value":1,"label":"Calc 10"},"opt1717805":{"calc_value":20,"value":2,"label":"Calc 20"}},"email_identifier":0,"personally_identifying":0}},"fld_8223213":{"ID":"fld_8223213","type":"calculation","label":"Calc 1 + 2 Divided By Hidden Field","slug":"calc_1__2_divided_by_hidden_field","conditions":{"type":""},"caption":"Should divide other two calcs by 1 or 2","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","formular":" ( fld_3231357+fld_8673305 ) \/ ( fld_3612279+fld_1402277 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_3231357"},{"operator":"+","field":"fld_8673305"}]},{"operator":"\/"},{"lines":[{"operator":"+","field":"fld_3612279"},{"operator":"+","field":"fld_1402277"}]}]},"manual_formula":"","email_identifier":0,"personally_identifying":0}},"fld_3612279":{"ID":"fld_3612279","type":"hidden","label":"HiddenField","slug":"hiddenfield","conditions":{"type":"con_8809976241157390"},"caption":"","config":{"custom_class":"","default":1,"email_identifier":0,"personally_identifying":0}},"fld_3489682":{"ID":"fld_3489682","type":"checkbox","label":"Remove Hidden Value","slug":"disable_hidden_value","conditions":{"type":""},"caption":"If check calc will divide by 2, if not checked divide by 1","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1154910":{"calc_value":"Yes","value":"Yes","label":"Yes"}},"email_identifier":0,"personally_identifying":0}},"fld_1402277":{"ID":"fld_1402277","type":"hidden","label":"Hidden2","slug":"hidden2","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":1,"email_identifier":0,"personally_identifying":0}}},"page_names":["Page 1"],"mailer":{"sender_name":"Caldera Forms Notification","sender_email":"test@test.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Calculation Automatic","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_8809976241157390":{"id":"con_8809976241157390","name":"Hide Hidden","type":"hide","fields":{"cl9356169337750438":"fld_3489682"},"group":{"rw4721758818161178":{"cl9356169337750438":{"parent":"rw4721758818161178","field":"fld_3489682","compare":"is","value":"opt1154910"}}}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.7.3-a.1","db_id":"173","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5bc26604eaf3c.json b/cypress/forms/CF5bc26604eaf3c.json new file mode 100644 index 000000000..d018a68a7 --- /dev/null +++ b/cypress/forms/CF5bc26604eaf3c.json @@ -0,0 +1 @@ +{"_last_updated":"Sat, 13 Oct 2018 21:53:24 +0000","ID":"CF5bc26604eaf3c","cf_version":"1.7.3-a.1","name":"Calculations Checkbox","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_2069847":"1:1","fld_3100099":"2:1","fld_5764774":"2:1","fld_2526988":"2:1","fld_3364767":"2:2","fld_6418208":"2:2","fld_522650":"2:2","fld_1629134":"2:2"},"structure":"12|6:6"},"fields":{"fld_2069847":{"ID":"fld_2069847","type":"html","label":"html__fld_2069847","slug":"html__fld_2069847","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":"Calculations Checkbox - CF5bc26604eaf3c"}},"fld_3100099":{"ID":"fld_3100099","type":"checkbox","label":"Checkbox 1","slug":"checkbox_1","conditions":{"type":"con_8512128212820608"},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1077006":{"calc_value":1,"value":1,"label":1},"opt1564738":{"calc_value":2,"value":2,"label":2},"opt1328155":{"calc_value":3,"value":3,"label":3}},"email_identifier":0,"personally_identifying":0}},"fld_5764774":{"ID":"fld_5764774","type":"checkbox","label":"Checkbox 2","slug":"checkbox_2","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","show_values":1,"option":{"opt1140160":{"calc_value":10.001,"value":10001,"label":10.001},"opt1361898":{"calc_value":10.002,"value":10002,"label":10.002},"opt1427240":{"calc_value":10.003,"value":10003,"label":10.003}},"email_identifier":0,"personally_identifying":0}},"fld_3364767":{"ID":"fld_3364767","type":"calculation","label":"Auto Calc With Rounding","slug":"auto_calc_with_rounding","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","formular":" ( fld_3100099+fld_5764774 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_3100099"},{"operator":"+","field":"fld_5764774"}]}]},"manual_formula":"","email_identifier":0,"personally_identifying":0}},"fld_6418208":{"ID":"fld_6418208","type":"calculation","label":"Auto Calc Without Rounding","slug":"auto_calc_without_rounding","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","formular":" ( fld_3100099+fld_5764774 ) ","config":{"group":[{"lines":[{"operator":"+","field":"fld_3100099"},{"operator":"+","field":"fld_5764774"}]}]},"manual_formula":"","email_identifier":0,"personally_identifying":0}},"fld_522650":{"ID":"fld_522650","type":"calculation","label":"Manual Calc With Rounding","slug":"manual_calc_with_rounding","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","fixed":1,"thousand_separator":",","decimal_separator":".","manual":1,"formular":"","config":"","manual_formula":"%checkbox_2% + %checkbox_1%","email_identifier":0,"personally_identifying":0}},"fld_1629134":{"ID":"fld_1629134","type":"calculation","label":"Manual Calc Without Rounding","slug":"manual_calc_without_rounding","conditions":{"type":""},"caption":"","config":{"custom_class":"","element":"h3","classes":"total-line","before":"Total:","after":"","thousand_separator":",","decimal_separator":".","manual":1,"formular":"","config":"","manual_formula":"%checkbox_2% + %checkbox_1%","email_identifier":0,"personally_identifying":0}},"fld_2526988":{"ID":"fld_2526988","type":"dropdown","label":"Hide Check 1","slug":"hide_check_1","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"count","orderby_post":"ID","order":"ASC","default":"","option":{"opt1996944":{"calc_value":"","value":"Yes","label":"Yes"}},"email_identifier":0,"personally_identifying":0}}},"page_names":["Page 1"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"test@test.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Calculations Checkbox","email_message":"{summary}"},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_8512128212820608":{"id":"con_8512128212820608","name":"Hide Check 1","type":"hide","group":{"rw581696453396471":{"cl4357604965646677":{"parent":"rw581696453396471","field":"fld_2526988","compare":"is","value":"opt1996944"}}},"fields":{"cl4357604965646677":"fld_2526988"}}}},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.7.3-a.1","db_id":"178","type":"primary"} \ No newline at end of file diff --git a/cypress/forms/CF5bc64d633d2ea.json b/cypress/forms/CF5bc64d633d2ea.json new file mode 100644 index 000000000..5e1dd88ab --- /dev/null +++ b/cypress/forms/CF5bc64d633d2ea.json @@ -0,0 +1 @@ +{"_last_updated":"Tue, 16 Oct 2018 21:29:11 +0000","ID":"CF5bc64d633d2ea","cf_version":"1.7.3-a.1","name":"Editor Basic Test","scroll_top":0,"success":"Form has been successfully submitted. Thank you.\t\t\t\t\t\t\t\t\t","db_support":1,"pinned":0,"hide_form":1,"avatar_field":"","form_ajax":1,"custom_callback":"","layout_grid":{"fields":{"fld_6548786":"1:1","fld_6685689":"1:2","fld_4461453":"2:2","fld_8586141":"3:1","fld_3687093":"4:1"},"structure":"6:6|6:6#12|12"},"fields":{"fld_6548786":{"ID":"fld_6548786","type":"text","label":"First Name","slug":"first_name","conditions":{"type":""},"caption":"","config":{"custom_class":"","placeholder":"","default":"","type_override":"text","mask":"","email_identifier":0,"personally_identifying":0}},"fld_6685689":{"ID":"fld_6685689","type":"checkbox","label":"Hide Next","slug":"hide_next","conditions":{"type":""},"caption":"","config":{"custom_class":"","default_option":"","auto_type":"","taxonomy":"category","post_type":"post","value_field":"name","orderby_tax":"name","orderby_post":"name","order":"ASC","default":"","option":{"opt1751895":{"calc_value":"Yes","value":"Yes","label":"Yes"}},"email_identifier":0,"personally_identifying":0}},"fld_4461453":{"ID":"fld_4461453","type":"button","label":"Next Page","slug":"next_page","conditions":{"type":"con_6945743324258369"},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}},"fld_8586141":{"ID":"fld_8586141","type":"range_slider","label":"Range Field","slug":"range_field","conditions":{"type":""},"caption":"","config":{"custom_class":"","default":1,"trackcolor":"#e6e6e6","color":"#00ff00","handle":"#ffffff","handleborder":"#cccccc","step":1,"min":0,"max":100,"showval":1,"prefix":"","suffix":"","email_identifier":0,"personally_identifying":0}},"fld_3687093":{"ID":"fld_3687093","type":"button","label":"Submit","slug":"submit","conditions":{"type":"con_170893538465722"},"caption":"","config":{"custom_class":"","type":"submit","class":"btn btn-default","target":""}}},"page_names":["Page 1","Page 2"],"mailer":{"on_insert":1,"sender_name":"Caldera Forms Notification","sender_email":"test@test.com","reply_to":"","email_type":"html","recipients":"","bcc_to":"","email_subject":"Editor Basic Test","email_message":"{summary}"},"processors":{"fp_6427173":{"ID":"fp_6427173","runtimes":{"insert":1},"type":"form_redirect","config":{"url":"https:\/\/hiroy.club","message":"Redirecting"},"conditions":{"type":"use","group":{"rw72338736699":{"cl11397485325":{"field":"fld_6548786","compare":"is","value":"%last_name%"}},"rw97567363929":{"cl15148064223":{"field":"fld_6548786","compare":"isnot","value":"Sivan"}}}}}},"check_honey":1,"antispam":{"sender_name":"","sender_email":""},"conditional_groups":{"conditions":{"con_6945743324258369":{"id":"con_6945743324258369","name":"Hide Next","type":"hide","fields":{"cl8602605523463383":"fld_6685689"},"group":{"rw3096710729138817":{"cl8602605523463383":{"parent":"rw3096710729138817","field":"fld_6685689","compare":"is","value":"opt1751895"}}}},"con_170893538465722":{"id":"con_170893538465722","name":"Show","type":"show","fields":{"cl5743860315157803":"fld_6548786"},"group":{"rw4310698169151717":{"cl5743860315157803":{"parent":"rw4310698169151717","field":"fld_6548786","compare":"isnot","value":"%last_name%"}}}}}},"variables":{"keys":["static","entry","pass"],"values":["%first_name%","%last_name%","%first_name%%last_name%"],"types":["static","entryitem","static"]},"settings":{"responsive":{"break_point":"sm"}},"privacy_exporter_enabled":false,"version":"1.7.3-a.1","db_id":"199","type":"primary"} \ No newline at end of file diff --git a/cypress/integration/--TEMPLATE-integration-test.js b/cypress/integration/--TEMPLATE-integration-test.js new file mode 100644 index 000000000..7d20f587b --- /dev/null +++ b/cypress/integration/--TEMPLATE-integration-test.js @@ -0,0 +1,39 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('hello-world'); + }); + + const formId = 'cf111'; + + + function testInitialLoad() { + //Define how it loads here + } + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + it( 'Does something else', () => { + testInitialLoad(); + //test form + }); + +}); \ No newline at end of file diff --git a/cypress/integration/calculation-checkbox.test.js b/cypress/integration/calculation-checkbox.test.js new file mode 100644 index 000000000..ac0461e1a --- /dev/null +++ b/cypress/integration/calculation-checkbox.test.js @@ -0,0 +1,112 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Calculations - With Checkbox', () => { + beforeEach(() => { + visitPage('calculations-checkbox'); + }); + + const formId = 'CF5bc26604eaf3c'; + const calc1 = 'fld_3364767'; + const calc2 = 'fld_6418208'; + const calc3 = 'fld_522650'; + const calc4 = 'fld_1629134'; + const checkbox1 = 'fld_3100099'; + const checkbox2 = 'fld_5764774'; + const hideCheck = 'fld_2526988'; + + it( 'starts at zero', () => { + cfFieldCalcFieldValueIs(calc1, '0.00' ); + cfFieldCalcFieldValueIs(calc2, '0' ); + cfFieldCalcFieldValueIs(calc3, '0.00' ); + cfFieldCalcFieldValueIs(calc4, '0' ); + }); + + it( 'adds up checkbox', () => { + + cfFieldCheckValue(checkbox1, '1'); + cfFieldCalcFieldValueIs(calc1, '1.00' ); + cfFieldCalcFieldValueIs(calc2, '1' ); + cfFieldCalcFieldValueIs(calc3, '1.00' ); + cfFieldCalcFieldValueIs(calc4, '1' ); + + cfFieldCheckValue(checkbox1, '2'); + cfFieldCalcFieldValueIs(calc1, '3.00' ); + cfFieldCalcFieldValueIs(calc2, '3' ); + cfFieldCalcFieldValueIs(calc3, '3.00' ); + cfFieldCalcFieldValueIs(calc4, '3' ); + + cfFieldCheckValue(checkbox1, '3'); + cfFieldCalcFieldValueIs(calc1, '6.00' ); + cfFieldCalcFieldValueIs(calc2, '6' ); + cfFieldCalcFieldValueIs(calc3, '6.00' ); + cfFieldCalcFieldValueIs(calc4, '6' ); + + cfFieldUnCheckValue(checkbox1, '2'); + cfFieldCalcFieldValueIs(calc1, '4.00' ); + cfFieldCalcFieldValueIs(calc2, '4' ); + cfFieldCalcFieldValueIs(calc3, '4.00' ); + cfFieldCalcFieldValueIs(calc4, '4' ); + + }); + + it( 'adds up two checkbox fields', () => { + + cfFieldCheckValue(checkbox1, '1'); + cfFieldCalcFieldValueIs(calc1, '1.00' ); + cfFieldCalcFieldValueIs(calc2, '1' ); + cfFieldCalcFieldValueIs(calc3, '1.00' ); + cfFieldCalcFieldValueIs(calc4, '1' ); + + cfFieldCheckValue(checkbox2, '10002'); + cfFieldCalcFieldValueIs(calc1, '11.00' ); + cfFieldCalcFieldValueIs(calc2, '11.002' ); + cfFieldCalcFieldValueIs(calc3, '11.00' ); + cfFieldCalcFieldValueIs(calc4, '11.002' ); + + cfFieldCheckValue(checkbox2, '10003'); + cfFieldCalcFieldValueIs(calc1, '21.01' ); + cfFieldCalcFieldValueIs(calc2, '21.005000000000003' ); + cfFieldCalcFieldValueIs(calc3, '21.01' ); + cfFieldCalcFieldValueIs(calc4, '21.005000000000003' ); + + + }); + + it( 'Does not add hidden checkbox', () => { + cfFieldCheckValue(checkbox1, '2'); + cfFieldCheckValue(checkbox2, '10001'); + cfFieldCalcFieldValueIs(calc1, '12.00' ); + cfFieldCalcFieldValueIs(calc2, '12.001' ); + cfFieldCalcFieldValueIs(calc3, '12.00' ); + cfFieldCalcFieldValueIs(calc4, '12.001' ); + + cfFieldSelectValue(hideCheck, 'Yes' ); + cfFieldCalcFieldValueIs(calc1, '10.00' ); + cfFieldCalcFieldValueIs(calc2, '10.001' ); + cfFieldCalcFieldValueIs(calc3, '10.00' ); + cfFieldCalcFieldValueIs(calc4, '10.001' ); + + cfFieldSelectValue(hideCheck, '' ); + cfFieldCalcFieldValueIs(calc1, '12.00' ); + cfFieldCalcFieldValueIs(calc2, '12.001' ); + cfFieldCalcFieldValueIs(calc3, '12.00' ); + cfFieldCalcFieldValueIs(calc4, '12.001' ); + + }); +}); \ No newline at end of file diff --git a/cypress/integration/calculation-manual.test.js b/cypress/integration/calculation-manual.test.js new file mode 100644 index 000000000..d6c9fa4c6 --- /dev/null +++ b/cypress/integration/calculation-manual.test.js @@ -0,0 +1,41 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, cfFieldCheckAllValues, cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Calculations - manual', () => { + beforeEach(() => { + visitPage('calculations-manual'); + }); + + const formId = 'CF5bc26a30e6032'; + const calc1 = 'fld_4023263'; + const calc2 = 'fld_8621915'; + + const num1 = 'fld_5324532'; + const num2 = 'fld_8094639'; + + it( 'Has the right initial values', () => { + cfFieldCalcFieldValueIs(calc1,'-1.8386476455831817'); + cfFieldCalcFieldValueIs(calc2,'-2'); + cfFieldSetValue(num1,101.01); + cfFieldCalcFieldValueIs(calc1,'-1.0071353170445643'); + cfFieldCalcFieldValueIs(calc2,'-1'); + cfFieldSetValue(num1,22); + cfFieldCalcFieldValueIs(calc1,'0.0193404636415895'); + cfFieldCalcFieldValueIs(calc2,'0'); + + + }) +}); \ No newline at end of file diff --git a/cypress/integration/calculation-money.test.js b/cypress/integration/calculation-money.test.js new file mode 100644 index 000000000..23bbda631 --- /dev/null +++ b/cypress/integration/calculation-money.test.js @@ -0,0 +1,72 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, cfFieldCheckAllValues, cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Calculations - money style', () => { + beforeEach(() => { + visitPage('calculation-money'); + }); + + const formId = 'CF5bc25cfa53898'; + const calc1 = 'fld_3231357'; + const calc1Quantity = 'fld_3087149'; + const calc1Option = 'fld_9132898'; + + const calc2 = 'fld_8673305'; + const calc2Opt1 = 'fld_7613122'; + const calc2Opt2 = 'fld_6377680'; + + const calc3 = 'fld_8223213'; + const calc3opt = 'fld_3489682'; + + it( 'Price option + Quantity option', () => { + cfFieldCalcFieldValueIs(calc1, '5.00' ); + + cfFieldSetValue(calc1Quantity, 42 ); + cfFieldCalcFieldValueIs(calc1, '42.00' ); + + cfFieldSelectValue(calc1Option,'1'); + cfFieldCalcFieldValueIs(calc1, '4200.00' ); + + cfFieldSetValue(calc1Quantity, 41 ); + cfFieldCalcFieldValueIs(calc1, '4100.00' ); + + }); + + it( 'Radio-based options', () => { + cfFieldCalcFieldValueIs(calc2, '5.00' ); + cfFieldCheckValue(calc2Opt1, '2' ); + cfFieldCalcFieldValueIs(calc2, '7.00' ); + cfFieldCheckValue(calc2Opt1, '1' ); + cfFieldCalcFieldValueIs(calc2, '6.00' ); + + cfFieldCheckValue(calc2Opt2, '2'); + cfFieldCalcFieldValueIs(calc2, '26.00' ); + + cfFieldCheckValue(calc2Opt2, '1'); + cfFieldCalcFieldValueIs(calc2, '16.00' ); + }); + + it( 'Divides and accounts for hidden field being hidden', () => { + cfFieldCalcFieldValueIs(calc3,'5.00'); + cfFieldCheckValue(calc2Opt1, '2' ); + cfFieldCalcFieldValueIs(calc3,'6.00'); + cfFieldCheckValue(calc3opt, 'Yes'); + cfFieldCalcFieldValueIs(calc3,'12.00'); + cfFieldUnCheckValue(calc3opt, 'Yes'); + cfFieldCalcFieldValueIs(calc3,'6.00'); + + }); +}); \ No newline at end of file diff --git a/cypress/integration/calculations-1962.test.js b/cypress/integration/calculations-1962.test.js new file mode 100644 index 000000000..563cf8268 --- /dev/null +++ b/cypress/integration/calculations-1962.test.js @@ -0,0 +1,59 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('1993-calculations-created1-5-5-dev1-5-6-2'); + }); + + const formId = 'cf111'; + const dropDownCalc = 'fld_5181257'; + const checkboxCalc = 'fld_693890'; + const radioCalc = 'fld_7680820'; + const selectsDividedByCalc = 'fld_578758'; + const numberField = 'fld_5656420'; + const dropdown = 'fld_3296542'; + const radio = 'fld_105161'; + + function testInitialLoad() { + cfFieldCalcFieldValueIs(dropDownCalc, '200'); + cfFieldCalcFieldValueIs(checkboxCalc, '100'); + cfFieldCalcFieldValueIs(radioCalc, '100'); + cfFieldCalcFieldValueIs(selectsDividedByCalc, '400'); + } + + it( 'Has the right initial load', () => { + testInitialLoad(); + }); + + it( 'Does the math correctly after intial load', () => { + testInitialLoad(); + cfFieldSetValue(numberField,-10); + cfFieldCalcFieldValueIs(selectsDividedByCalc, '-40'); + + cfFieldSelectValue(dropdown, '10' ); + cfFieldCalcFieldValueIs(dropDownCalc, '100' ); + cfFieldCalcFieldValueIs(selectsDividedByCalc, '-30' ); + + cfFieldCheckValue(radio,'20' ); + cfFieldCalcFieldValueIs(radioCalc, '200'); + cfFieldCalcFieldValueIs(selectsDividedByCalc, '-40'); + + }); + +}); \ No newline at end of file diff --git a/cypress/integration/calculations-1979.test.js b/cypress/integration/calculations-1979.test.js new file mode 100644 index 000000000..6e4653559 --- /dev/null +++ b/cypress/integration/calculations-1979.test.js @@ -0,0 +1,56 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('1979-calculations-created1-5-5-dev1-5-6-2'); + }); + + const formId = 'CF59ce6f1747efb'; + const totalCalc = 'fld_7896676'; + const discountCalc = 'fld_1734684'; + const grandTotalCalc = 'fld_6532733'; + const selectionsCheckbox = 'fld_9272690'; + + + function testInitialLoad() { + cfFieldCalcFieldValueIs(discountCalc, '0.00'); + cfFieldCalcFieldValueIs(totalCalc, '100.00'); + cfFieldCalcFieldValueIs(grandTotalCalc, '100.00'); + } + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + + it( 'Updates and does math correctly', () => { + testInitialLoad(); + cfFieldCheckValue(selectionsCheckbox, '200' ); + cfFieldCalcFieldValueIs(discountCalc, '10.00'); + cfFieldCalcFieldValueIs(grandTotalCalc, '290.00'); + + cfFieldCheckValue(selectionsCheckbox, '300' ); + cfFieldCalcFieldValueIs(discountCalc, '30.00'); + cfFieldCalcFieldValueIs(grandTotalCalc, '570.00'); + + cfFieldUnCheckValue(selectionsCheckbox, '200' ); + cfFieldCalcFieldValueIs(discountCalc, '0.00'); + cfFieldCalcFieldValueIs(grandTotalCalc, '400.00'); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/calculations-1993.test.js b/cypress/integration/calculations-1993.test.js new file mode 100644 index 000000000..c6f74d711 --- /dev/null +++ b/cypress/integration/calculations-1993.test.js @@ -0,0 +1,60 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('1993-calculations-created1-5-5-dev1-5-6-2'); + }); + + const formId = 'CF59d9652a86fff'; + const calcNumber1 = 'fld_7335878'; + const calcNumber2 = 'fld_5821713'; + const multiplyCalc = 'fld_1467266'; + const number1 = 'fld_4476299'; + const number2 = 'fld_7265648'; + const hidden = 'fld_7400054'; + + function testIntialLoad() { + cfFieldCalcFieldValueIs(calcNumber1, '1'); + cfFieldCalcFieldValueIs(calcNumber2, '0'); + cfFieldCalcFieldValueIs(multiplyCalc, '1'); + } + + it( 'Has the right math on initial load', () => { + testIntialLoad(); + + }); + + it( 'Updates after initial load with correct math', () => { + cfFieldSetValue(number2, 5); + cfFieldCalcFieldValueIs(calcNumber1, '1'); + cfFieldCalcFieldValueIs(calcNumber2, '5'); + cfFieldCalcFieldValueIs(multiplyCalc, '6'); + + cfFieldSetValue(number1, 10); + cfFieldCalcFieldValueIs(calcNumber1, '10'); + cfFieldCalcFieldValueIs(calcNumber2, '5'); + cfFieldCalcFieldValueIs(multiplyCalc, '51'); + + cfFieldSetValue(number2, -50); + cfFieldCalcFieldValueIs(calcNumber1, '10'); + cfFieldCalcFieldValueIs(calcNumber2, '-50'); + cfFieldCalcFieldValueIs(multiplyCalc, '-499'); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/calculations-2063.1.test.js b/cypress/integration/calculations-2063.1.test.js new file mode 100644 index 000000000..a949fdfad --- /dev/null +++ b/cypress/integration/calculations-2063.1.test.js @@ -0,0 +1,64 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, cfFieldSummaryContainsValues +} from '../support/util'; + + +describe('2063.1 CONDITIONALS CREATE@1.6.2.2 DEV@1.5.7.1', () => { + beforeEach(() => { + visitPage('2063-1-conditionals-create1-6-2-2-dev1-5-7-1'); + }); + + const formId = 'CF5a0479e6025a2'; + const number1 = 'fld_6564773'; + const number2 = 'fld_8938360'; + const calc = 'fld_1741771'; + const summary = 'fld_6634118'; + + const hideNumber1Select = 'fld_6496833'; + const hideNumber2Select = 'fld_5119751'; + + const summaryContains = (containsValues) => { + return cfFieldSummaryContainsValues('#html-content-fld_6634118_1', containsValues); + }; + + function testInitialLoad() { + cfFieldHasValue(number1,'5'); + cfFieldHasValue(number2,'10'); + summaryContains([ + '1','5','10' + ]); + } + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + it( 'Does not include hidden', () => { + testInitialLoad(); + cfFieldSelectValue(hideNumber1Select,'Yes'); + cfFieldCalcFieldValueIs(calc,'10'); + cfFieldSelectValue(hideNumber1Select,'Yes'); + cfFieldCalcFieldValueIs(calc,'10'); + + cfFieldSelectValue(hideNumber2Select,'Yes'); + cfFieldCalcFieldValueIs(calc,'0'); + + cfFieldSelectValue(hideNumber1Select,''); + cfFieldCalcFieldValueIs(calc,'5'); + + + }); + +}); \ No newline at end of file diff --git a/cypress/integration/calculations-2063.test.js b/cypress/integration/calculations-2063.test.js new file mode 100644 index 000000000..ede940afc --- /dev/null +++ b/cypress/integration/calculations-2063.test.js @@ -0,0 +1,48 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('2063 CALCULATIONS CREATE@X DEV@1.5.7.1', () => { + beforeEach(() => { + visitPage('2063-calculations-createx-dev1-5-7-1'); + }); + + const formId = 'CF5a047196d398f'; + const number1 = 'fld_6564773'; + const number2 = 'fld_8938360'; + const calc = 'fld_1741771'; + + function testInitialLoad() { + cfFieldHasValue(number1,'5'); + cfFieldHasValue(number2,'10'); + cfFieldCalcFieldValueIs(calc,'15'); + } + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + it( 'Does math', () => { + testInitialLoad(); + cfFieldSetValue(number2, '25'); + cfFieldCalcFieldValueIs(calc,'30'); + + cfFieldSetValue(number1,'-50'); + cfFieldCalcFieldValueIs(calc,'-25'); + + }); + +}); \ No newline at end of file diff --git a/cypress/integration/calculations-2082.js b/cypress/integration/calculations-2082.js new file mode 100644 index 000000000..e891ba20e --- /dev/null +++ b/cypress/integration/calculations-2082.js @@ -0,0 +1,45 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('2082 CALCULATIONS CREATED@1.5.7.1 DEV@1.5.8', () => { + beforeEach(() => { + visitPage('2082-calculations-created1-5-7-1-dev1-5-8'); + }); + + const formId = 'CF5a3193046927c'; + const select = 'fld_5132042'; + const number = 'fld_60384'; + const calc = 'fld_9859374'; + + + function testInitialLoad() { + cfFieldCalcFieldValueIs(calc,'20'); + cfFieldHasValue(select,'7'); + cfFieldHasValue(number,'13'); + } + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + it( 'Does math based on select field without calc value set', () => { + testInitialLoad(); + cfFieldSelectValue(select,'5'); + cfFieldCalcFieldValueIs(calc,'18') + }); + +}); \ No newline at end of file diff --git a/cypress/integration/calculations-x1.test.js b/cypress/integration/calculations-x1.test.js new file mode 100644 index 000000000..723d1607f --- /dev/null +++ b/cypress/integration/calculations-x1.test.js @@ -0,0 +1,56 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('x1-calculations-create1-5-5-dev1-5-6-2'); + }); + + const formId = 'CF59dd15667a03b'; + const totalCalc = 'fld_8997460'; + const option1checkbox = 'fld_3993413'; + const option2Select = 'fld_5161425'; + + function testInitialLoad() { + cfFieldCalcFieldValueIs(totalCalc, '25.00'); + + } + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + + it( 'Updates and does math correctly', () => { + testInitialLoad(); + + cfFieldCheckValue(option1checkbox, 'Yes' ); + cfFieldCalcFieldValueIs(totalCalc, '35.00'); + + cfFieldSelectValue(option2Select, 'Big' ); + cfFieldCalcFieldValueIs(totalCalc, '40.00'); + + cfFieldSelectValue(option2Select, 'Small' ); + cfFieldCalcFieldValueIs(totalCalc, '36.00'); + + cfFieldUnCheckValue(option1checkbox, 'Yes' ); + cfFieldCalcFieldValueIs(totalCalc, '26.00'); + + + }); + +}); \ No newline at end of file diff --git a/cypress/integration/calculations-x2.test.js b/cypress/integration/calculations-x2.test.js new file mode 100644 index 000000000..4e6b1b6ce --- /dev/null +++ b/cypress/integration/calculations-x2.test.js @@ -0,0 +1,50 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('x2-calculations-create1-5-5-dev1-5-6-2'); + }); + + const formId = 'CF59dd5d8e95ffb'; + const totalCalc = 'fld_6617658'; + const option1Select = 'fld_8172473'; + const option2Select = 'fld_8186270'; + + function testInitialLoad() { + cfFieldCalcFieldValueIs(totalCalc, '0.00'); + + } + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + + it( 'Updates and does math correctly', () => { + testInitialLoad(); + + cfFieldSelectValue(option1Select, '4' ); + cfFieldCalcFieldValueIs(totalCalc, '4.28'); + + cfFieldSelectValue(option2Select, 'Two' ); + cfFieldCalcFieldValueIs(totalCalc, '6.42'); + + cfFieldSelectValue(option1Select, '3' ); + cfFieldCalcFieldValueIs(totalCalc, '5.35'); + }); +}); \ No newline at end of file diff --git a/cypress/integration/calculations-x3.test.js b/cypress/integration/calculations-x3.test.js new file mode 100644 index 000000000..8a5c5ec15 --- /dev/null +++ b/cypress/integration/calculations-x3.test.js @@ -0,0 +1,52 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('x3-calculations-create1-5-5-dev1-5-6-2'); + }); + + const formId = 'CF59dd60bbe7ab6'; + const mathCalc = 'fld_6083669'; + const roundMathCalc = 'fld_9723683'; + const numberField = 'fld_2950569'; + + + function testInitialLoad() { + cfFieldCalcFieldValueIs(mathCalc,'0'); + cfFieldCalcFieldValueIs(roundMathCalc,'0'); + } + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + it( 'Does something else', () => { + testInitialLoad(); + cfFieldSetValue(numberField, 10); + + cfFieldCalcFieldValueIs(mathCalc,'0.6483608274590866'); + cfFieldCalcFieldValueIs(roundMathCalc,'1'); + + cfFieldSetValue(numberField, -351); + + cfFieldCalcFieldValueIs(mathCalc,'1.1577507304420032'); + cfFieldCalcFieldValueIs(roundMathCalc,'1'); + + }); + +}); \ No newline at end of file diff --git a/cypress/integration/cc-2107.test.js b/cypress/integration/cc-2107.test.js new file mode 100644 index 000000000..9ded74436 --- /dev/null +++ b/cypress/integration/cc-2107.test.js @@ -0,0 +1,53 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, cfFieldClickButton, cfFieldGetWrapper, cfAlertHasText +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('2107-credit-card-created-dev1-5-8'); + }); + + const formId = 'CF5a1de64c110ae'; + const nextButton = 'fld_9594894'; + const cc2 = 'fld_8591050'; + const exp = 'fld_6124340'; + const cvc = 'fld_4200620'; + const submitButton = 'fld_9177438'; + + + + + it( 'CC fields validation works on page 2', () => { + cfFieldClickButton(nextButton); + cfFieldClickButton(submitButton); + cfFieldGetWrapper(cc2).find( '.parsley-required').contains( 'This value is required.'); + }); + + it( 'CC fields submit when has expiration and ccv', () => { + //4242 4242 4242 4242 + cfFieldClickButton(nextButton); + cfFieldClickButton(submitButton); + cfFieldSetValue(cc2,'4242 4242 4242 4242' ); + cfFieldSetValue(cc2,'4242 4242 4242 4242' ); + cfFieldSetValue(exp,'11/28' ); + cfFieldSetValue(cvc,'412' ); + cfFieldClickButton(submitButton); + cfAlertHasText(formId); + + + }) +}); \ No newline at end of file diff --git a/cypress/integration/conditionals-disable.test.js b/cypress/integration/conditionals-disable.test.js new file mode 100644 index 000000000..a1a47b5b4 --- /dev/null +++ b/cypress/integration/conditionals-disable.test.js @@ -0,0 +1,173 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, cfFieldCheckAllValues +} from '../support/util'; + + + +/** + * Tests for when conditions are hide type + */ +describe('Conditionals - disable type - text fields', () => { + beforeEach(() => { + visitPage('conditionals-disable-test'); + }); + + const disabler = 'fld_9551037'; + + const textField = 'fld_3067684'; + const colorField = 'fld_6740475'; + const phoneBetterField = 'fld_4913550'; + const phoneBasicField = 'fld_3414426'; + const numberField = 'fld_8059884'; + const submitButton = 'fld_9529943'; + const emailField = 'fld_7867333'; + const urlField = 'fld_8461580'; + const fields = [ + textField, + colorField, + phoneBasicField, + phoneBetterField, + numberField, + submitButton, + urlField, + emailField + ]; + + it( 'Disables text field',() => { + cfFieldCheckValue(disabler,'disableText'); + cfFieldIsDisabled(textField); + + cfFieldUnCheckValue(disabler,'disableText'); + cfFieldIsNotDisabled(textField); + cfFieldSetValue(textField,'Noms'); + cfFieldHasValue(textField,'Noms'); + + cfFieldCheckValue(disabler,'disableText'); + cfFieldCheckValue(disabler,'disableNone'); + cfFieldIsNotDisabled(textField); + + cfFieldSetValue(textField,'Noms!'); + cfFieldHasValue(textField,'Noms!'); + }); + + it( 'Disables color field',() => { + cfFieldCheckValue(disabler,'disableColor'); + cfFieldIsDisabled(colorField); + + cfFieldUnCheckValue(disabler,'disableColor'); + cfFieldIsNotDisabled(colorField); + cfFieldSetValue(colorField,'#FFFFFF'); + cfFieldHasValue(colorField,'#FFFFFF'); + + cfFieldCheckValue(disabler,'disableColor'); + cfFieldIsDisabled(colorField); + cfFieldCheckValue(disabler,'disableNone'); + cfFieldIsNotDisabled(colorField); + + cfFieldSetValue(colorField,'#FFFF00'); + cfFieldHasValue(colorField,'#FFFF00'); + }); + + it( 'Disables phone better field',() => { + cfFieldCheckValue(disabler,'disablePhoneBetter'); + cfFieldIsDisabled(phoneBetterField); + + cfFieldUnCheckValue(disabler,'disablePhoneBetter'); + cfFieldIsNotDisabled(phoneBetterField); + cfFieldSetValue(phoneBetterField,'(111) 123-4567'); + cfFieldHasValue(phoneBetterField,'(111) 123-4567'); + + cfFieldCheckValue(disabler,'disablePhoneBetter'); + cfFieldIsDisabled(phoneBetterField); + + cfFieldCheckValue(disabler,'disableNone'); + cfFieldIsNotDisabled(phoneBetterField); + cfFieldSetValue(phoneBetterField,'(111) 123-4561'); + cfFieldHasValue(phoneBetterField,'(111) 123-4561'); + + }); + + it( 'Disables phone basic field',() => { + cfFieldCheckValue(disabler,'disablePhoneBasic'); + cfFieldIsDisabled(phoneBasicField); + + cfFieldUnCheckValue(disabler,'disablePhoneBasic'); + cfFieldIsNotDisabled(phoneBasicField); + + cfFieldCheckValue(disabler,'disablePhoneBasic'); + cfFieldIsDisabled(phoneBasicField); + cfFieldCheckValue(disabler,'disableNone'); + cfFieldIsNotDisabled(phoneBasicField); + + }); + + + it( 'Disables phone basic field',() => { + cfFieldCheckValue(disabler,'disablePhoneBasic'); + cfFieldIsDisabled(phoneBasicField); + + cfFieldUnCheckValue(disabler,'disablePhoneBasic'); + cfFieldIsNotDisabled(phoneBasicField); + + cfFieldCheckValue(disabler,'disablePhoneBasic'); + cfFieldIsDisabled(phoneBasicField); + + cfFieldCheckValue(disabler,'disableNone'); + cfFieldIsNotDisabled(phoneBasicField); + }); + + it( 'Disables url field',() => { + cfFieldCheckValue(disabler,'disableUrl'); + cfFieldIsDisabled(urlField); + + cfFieldUnCheckValue(disabler,'disableUrl'); + cfFieldIsNotDisabled(urlField); + + cfFieldCheckValue(disabler,'disableUrl'); + cfFieldIsDisabled(urlField); + + cfFieldCheckValue(disabler,'disableNone'); + cfFieldIsNotDisabled(urlField); + }); + + it( 'Disables email field',() => { + cfFieldCheckValue(disabler,'disableEmail'); + cfFieldIsDisabled(emailField); + + cfFieldUnCheckValue(disabler,'disableEmail'); + cfFieldIsNotDisabled(emailField); + + cfFieldCheckValue(disabler,'disableEmail'); + cfFieldIsDisabled(emailField); + + cfFieldCheckValue(disabler,'disableNone'); + cfFieldIsNotDisabled(emailField); + }); + + it( 'Disables none when all are checked, including disable all', () => { + cfFieldCheckAllValues(disabler); + fields.forEach( fieldId => { + cfFieldIsNotDisabled(fieldId); + }); + }); + + it( 'Disables all when all are checked, except disable all', () => { + cfFieldCheckAllValues(disabler); + cfFieldUnCheckValue(disabler, 'disableNone') + fields.forEach( fieldId => { + cfFieldIsDisabled(fieldId); + }); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/conditionals-hide.test.js b/cypress/integration/conditionals-hide.test.js new file mode 100644 index 000000000..187154a7b --- /dev/null +++ b/cypress/integration/conditionals-hide.test.js @@ -0,0 +1,308 @@ +import { + visitPage, + getCfField, + getCfFieldIdAttr, + getCfFieldSelector, + getCfFormIdAttr, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldUnCheckValue, + getCfCheckboxOption, cfFieldOptionIsChecked, cfFieldOptionIsNotChecked, cfFieldOptionIsSelected +} from '../support/util'; + +const controlField = 'fld_471602'; +const controlField2 = 'fld_4533316'; +const textField = 'fld_6735870'; +const textFieldWithDefault = 'fld_8484460'; + +const textFieldAsNumber = 'fld_2782690'; +const textFieldAsNumberWithDefault = 'fld_9936249'; + +const button1 = 'fld_8729978'; +const button2 = 'fld_8576859'; + +const hideMaskedInput = 'fld_53474'; +const maskedInput = 'fld_7507195'; + +const formId = 'CF5bc25738c82c2'; + +/** + * Tests for when conditions are hide type + */ +describe('Conditionals - hide type - text fields', () => { + beforeEach(() => { + visitPage('conditional-hide-test'); + }); + + + it('Hide and update values of regular text fields', () => { + //Set a value in text field and then hide text fields + cfFieldSetValue(textField, 'Mike'); + cfFieldSelectValue(controlField, 'hideText'); + //Check that they are gone + cfFieldDoesNotExist(textField); + cfFieldDoesNotExist(textFieldWithDefault); + + //Unhide and check fields exist with the right values + cfFieldSelectValue(controlField, 'hideNone'); + cfFieldHasValue(textField, 'Mike'); + cfFieldHasValue(textFieldWithDefault, 'Hi Roy'); + + //change both fields + cfFieldSetValue(textField, 'Mike 3@1!'); + cfFieldSetValue(textFieldWithDefault, 'Röy'); + //hide them + cfFieldSelectValue(controlField, 'hideText'); + //unhide them and check their values are still correct + cfFieldSelectValue(controlField, 'hideNone'); + cfFieldHasValue(textField, 'Mike 3@1!'); + cfFieldHasValue(textFieldWithDefault, 'Röy'); + + }); + + it('Hide and update values of number-like text fields', () => { + //Set a value in text field and then hide text fields + cfFieldSetValue(textFieldAsNumber, 22); + cfFieldSelectValue(controlField, 'hideNumber'); + //Check that they are gone + cfFieldDoesNotExist(textFieldAsNumber); + cfFieldDoesNotExist(textFieldAsNumberWithDefault); + + //Unhide and check fields exist with the right values + cfFieldSelectValue(controlField, 'hideNone'); + cfFieldHasValue(textFieldAsNumber, 22); + cfFieldHasValue(textFieldAsNumberWithDefault, 5); + + //change both fields + cfFieldSetValue(textFieldAsNumber, 42); + cfFieldSetValue(textFieldAsNumberWithDefault, -42); + //hide them + cfFieldSelectValue(controlField, 'hideNumber'); + //unhide them and check their values are still correct + cfFieldSelectValue(controlField, 'hideNone'); + cfFieldHasValue(textFieldAsNumber, 42); + cfFieldHasValue(textFieldAsNumberWithDefault, -42); + }); + + it('Can hide and unhide all', () => { + //hide all + cfFieldSelectValue(controlField, 'hideAll'); + + //Check that they are gone + cfFieldDoesNotExist(textField); + cfFieldDoesNotExist(textFieldWithDefault); + cfFieldDoesNotExist(textFieldAsNumber); + cfFieldDoesNotExist(textFieldAsNumberWithDefault); + + //unhide all + cfFieldSelectValue(controlField, 'hideNone'); + + //Check field are not gone + cfFieldIsVisible(textField); + cfFieldIsVisible(textFieldWithDefault); + cfFieldIsVisible(textFieldAsNumber); + cfFieldIsVisible(textFieldAsNumberWithDefault); + }); + + it('can hide and show based on text value', () => { + cfFieldSetValue(controlField2, 'Hide 1'); + cfFieldDoesNotExist(button1); + cfFieldIsVisible(button2); + + cfFieldSetValue(controlField2, 'Hide 2'); + cfFieldIsVisible(button1); + cfFieldDoesNotExist(button2); + + cfFieldSetValue(controlField2, 'Hi Roy'); + cfFieldIsVisible(button1); + cfFieldIsVisible(button2); + + cfFieldSetValue(controlField2, 'Hide Both'); + cfFieldDoesNotExist(button1); + cfFieldDoesNotExist(button2); + }); + + it.skip('can hide masked input and it works right', () => { + const value = '11-ab-2a'; + cfFieldSetValue(maskedInput, value); + + //Hide it + cfFieldCheckValue(hideMaskedInput, 'Yes'); + cfFieldDoesNotExist(maskedInput); + + //Show it + cfFieldCheckValue(hideMaskedInput, 'No'); + cfFieldHasValue(maskedInput, value); + + //Attempt to set an invalid value + getCfField(maskedInput).type('Roy'); + cfFieldHasValue(maskedInput, value); + + //Set a valid value + const newValue = '11-ar-3s'; + cfFieldSetValue(maskedInput, newValue) + cfFieldHasValue(maskedInput, newValue); + getCfField(maskedInput, '1adadssada1'); + cfFieldHasValue(maskedInput, newValue); + + }); +}); + + +describe('state when using hide conditionals', () => { + beforeEach(() => { + visitPage('conditional-hide-test'); + }); + + it('Loads state object in window scope', () => { + cy.window().then((theWindow) => { + assert.isObject(theWindow.cfstate); + expect(theWindow.cfstate).to.have.property(getCfFormIdAttr(formId)); + const state = theWindow.cfstate[getCfFormIdAttr(formId)]; + assert.isObject(state); + }); + }); + + +}); + +describe('Conditionals - hide type - select fields', () => { + beforeEach(() => { + visitPage('hide-conditionals-select'); + }); + + const formId = 'CF5bc235072e2a8'; + const hideCheckbox = 'fld_7176956'; + const checkbox1 = 'fld_5440278'; + const checkbox2 = 'fld_921826'; + const extraField = 'fld_1034558'; + + const hideRadio = 'fld_7631843'; + const radio1 = 'fld_464591'; + + const hideOthers = 'fld_1734075'; + const dropDown = 'fld_520708'; + const autoComplete = 'fld_7673890'; + const toggle = 'fld_8736564'; + const stateProvidence = 'fld_5313777'; + const date = 'fld_888212'; + + const otherFields = [dropDown,toggle,stateProvidence,date]; + + it( 'Hides and shows based on checkbox', () => { + cfFieldIsVisible(checkbox1); + cfFieldIsVisible(checkbox2); + + cfFieldCheckValue(hideCheckbox, 'hide1'); + cfFieldDoesNotExist(checkbox1); + cfFieldIsVisible(checkbox2); + + cfFieldCheckValue(hideCheckbox, 'hide2'); + cfFieldDoesNotExist(checkbox1); + cfFieldDoesNotExist(checkbox2); + + cfFieldCheckValue(hideCheckbox, 'hideNone'); + cfFieldIsVisible(checkbox1); + cfFieldIsVisible(checkbox2); + + cfFieldIsVisible(extraField); + cfFieldCheckValue(checkbox1, 'ck1a'); + cfFieldIsVisible(extraField); + + + cfFieldCheckValue(checkbox2, 'ck3b'); + cfFieldDoesNotExist(extraField); + + cfFieldUnCheckValue(checkbox2, 'ck3b'); + cfFieldUnCheckValue(checkbox1, 'ck1a'); + cfFieldIsVisible(extraField); + + cfFieldCheckValue(checkbox2,'ck2b' ); + cfFieldDoesNotExist(extraField); + + + }); + + it( 'Hides and shows based on radio', () => { + cfFieldDoesNotExist(radio1); + cfFieldCheckValue(hideRadio,'No'); + cfFieldIsVisible(radio1); + cfFieldCheckValue(hideRadio,'Yes'); + cfFieldDoesNotExist(radio1); + }); + + it( 'preserves value of radio field', () => { + cfFieldCheckValue(hideRadio,'No'); + + cfFieldCheckValue(radio1, 'r2b' ); + cfFieldCheckValue(hideRadio,'Yes'); + cfFieldCheckValue(hideRadio,'No'); + cfFieldOptionIsChecked(radio1,'r2b'); + + }); + + + it('Hides/shows checkbox fields and keeps values', () => { + + cfFieldCheckValue(checkbox1, 'ck1b'); + cfFieldCheckValue(hideCheckbox, 'hide1'); + cfFieldUnCheckValue(hideCheckbox, 'hide1'); + cfFieldOptionIsChecked(checkbox1, 'ck1b'); + cfFieldOptionIsNotChecked(checkbox1, 'ck1a'); + cfFieldOptionIsNotChecked(checkbox1, 'ck1c'); + + cfFieldCheckValue(checkbox1, 'ck1c'); + cfFieldCheckValue(hideCheckbox, 'hide1'); + cfFieldUnCheckValue(hideCheckbox, 'hide1'); + cfFieldOptionIsNotChecked(checkbox1, 'ck1a'); + cfFieldOptionIsChecked(checkbox1, 'ck1b'); + cfFieldOptionIsChecked(checkbox1, 'ck1c'); + + }); + + it( 'Hides shows the other fields', () => { + otherFields.forEach(field => { + cfFieldDoesNotExist(field) + }); + cfFieldCheckValue(hideOthers, 'No'); + otherFields.forEach(field => { + cfFieldIsVisible(field) + }); + }); + + it( 'Keeps dropdown value', () => { + cfFieldCheckValue(hideOthers, 'No'); + cfFieldSelectValue(dropDown,'s1b'); + + cfFieldCheckValue(hideOthers, 'Yes'); + cfFieldDoesNotExist(dropDown); + cfFieldCheckValue(hideOthers, 'No'); + cfFieldOptionIsSelected(dropDown, 's1b'); + }); + + it( 'Keeps stateProvidence value', () => { + cfFieldCheckValue(hideOthers, 'No'); + cfFieldSelectValue(stateProvidence,'ON'); + + cfFieldCheckValue(hideOthers, 'Yes'); + cfFieldDoesNotExist(stateProvidence); + cfFieldCheckValue(hideOthers, 'No'); + cfFieldOptionIsSelected(stateProvidence, 'ON'); + }); + + it( 'Keeps date value', () => { + cfFieldCheckValue(hideOthers, 'No'); + cfFieldHasValue(date,'2112-12-12'); + cfFieldSetValue(date,'2111-11-11'); + + cfFieldCheckValue(hideOthers, 'Yes'); + cfFieldDoesNotExist(date); + cfFieldCheckValue(hideOthers, 'No'); + cfFieldHasValue(date,'2111-11-11'); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/conditionals-show.test.js b/cypress/integration/conditionals-show.test.js new file mode 100644 index 000000000..18084f2fe --- /dev/null +++ b/cypress/integration/conditionals-show.test.js @@ -0,0 +1,238 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, cfFieldUnCheckValue, cfFieldOptionIsChecked, cfFieldOptionIsSelected +} from '../support/util'; + +describe('Conditionals - show type - select fields', () => { + beforeEach(() => { + visitPage('show-conditionals-select'); + }); + + const formId = 'CF5bc235072e2a8'; + const showCheckbox = 'fld_7176956'; + const checkbox1 = 'fld_5440278'; + const checkbox2 = 'fld_921826'; + const extraField = 'fld_1034558'; + + const showRadio = 'fld_7631843'; + const radio1 = 'fld_464591'; + + const showOthers = 'fld_1734075'; + const dropDown = 'fld_520708'; + const stateProvidence = 'fld_5313777'; + const date = 'fld_888212'; + + + + it( 'Hides and shows based on checkbox', () => { + cfFieldDoesNotExist(checkbox1); + cfFieldDoesNotExist(checkbox2); + + cfFieldCheckValue(showCheckbox,'show1'); + cfFieldIsVisible(checkbox1); + cfFieldUnCheckValue(checkbox1, 'ck1c' );//uncheck default + cfFieldDoesNotExist(checkbox2); + + cfFieldCheckValue(showCheckbox,'show2'); + cfFieldIsVisible(checkbox1); + cfFieldIsVisible(checkbox2); + + cfFieldUnCheckValue(showCheckbox, 'show2' ); + cfFieldDoesNotExist(checkbox2); + + cfFieldUnCheckValue(showCheckbox, 'show1' ); + cfFieldDoesNotExist(checkbox1); + + cfFieldCheckValue(showCheckbox, 'showBoth'); + cfFieldIsVisible(checkbox1); + cfFieldIsVisible(checkbox2); + + cfFieldCheckValue(checkbox1,'ck1a'); + cfFieldCheckValue(checkbox2,'ck3b'); + cfFieldIsVisible(extraField); + + cfFieldUnCheckValue(checkbox1,'ck1a'); + cfFieldUnCheckValue(checkbox2,'ck3b'); + cfFieldDoesNotExist(extraField); + + cfFieldCheckValue(checkbox2,'ck2b'); + cfFieldIsVisible(extraField); + + }); + + it( 'hides and shows based on radio field', () => { + cfFieldIsVisible(radio1); + + cfFieldCheckValue(showRadio,'No'); + cfFieldDoesNotExist(radio1); + + cfFieldCheckValue(showRadio,'Yes'); + cfFieldIsVisible(radio1); + + }); + + it( 'Preserves values of checkboxes', () => { + cfFieldCheckValue(showCheckbox,'show1'); + cfFieldOptionIsChecked(checkbox1, 'ck1c'); + cfFieldCheckValue(checkbox1, 'ck1a'); + + cfFieldUnCheckValue(showCheckbox,'show1'); + cfFieldCheckValue(showRadio,'Yes' ); + cfFieldCheckValue(showCheckbox,'show1'); + cfFieldOptionIsChecked(checkbox1, 'ck1c'); + cfFieldOptionIsChecked(checkbox1, 'ck1a'); + + }); + + it( 'Preserves values of radios', () => { + + cfFieldCheckValue(showRadio,'Yes' ); + cfFieldOptionIsChecked(radio1, 'r1b'); + cfFieldCheckValue(radio1, 'r1c'); + cfFieldCheckValue(showRadio,'No' ); + cfFieldCheckValue(showRadio,'Yes' ); + cfFieldOptionIsChecked(radio1,'r1c'); + + }); + + it( 'Preserves values of dropdown', () => { + cfFieldCheckValue(showOthers,'Yes' ); + cfFieldOptionIsSelected(dropDown, 's1b'); + + cfFieldSelectValue(dropDown, 's1c' ); + + cfFieldCheckValue(showOthers,'No' ); + cfFieldCheckValue(showRadio,'Yes' ); + cfFieldCheckValue(showOthers,'Yes' ); + + cfFieldOptionIsSelected(dropDown,'s1c'); + }); + + it( 'preserves value of date', () => { + cfFieldCheckValue(showOthers, 'Yes' ); + cfFieldSetValue(date, '2019-01-01' ); + cfFieldCheckValue(showOthers, 'No' ); + cfFieldDoesNotExist(date); + cfFieldCheckValue(showOthers, 'Yes' ); + cfFieldHasValue(date, '2019-01-01'); + + }); + + it( 'preserves value of state/Providence field', () => { + cfFieldCheckValue(showOthers, 'Yes' ); + cfFieldSelectValue(stateProvidence, 'PA' ); + cfFieldCheckValue(showOthers, 'No' ); + cfFieldDoesNotExist(date); + cfFieldCheckValue(showOthers, 'Yes' ); + cfFieldHasValue(stateProvidence, 'PA'); + + }); +}); + +describe('Conditionals - show type - text fields', () => { + beforeEach(() => { + visitPage('conditional-show-test'); + }); + + const controlField = 'fld_471602'; + const controlField2 = 'fld_4533316'; + const textField = 'fld_6735870'; + const textFieldWithDefault = 'fld_8484460'; + + const textFieldAsNumber = 'fld_2782690'; + const textFieldAsNumberWithDefault = 'fld_9936249'; + + const button1 = 'fld_8729978'; + const button2 = 'fld_8576859'; + + const showMaskedInput = 'fld_53474'; + const maskedInput = 'fld_7507195'; + + + it( 'Does not show the fields that are not shown by default', () => { + cfFieldDoesNotExist(textField); + cfFieldDoesNotExist(textFieldWithDefault); + + cfFieldDoesNotExist(textFieldAsNumber); + cfFieldDoesNotExist(textFieldAsNumberWithDefault); + + cfFieldDoesNotExist(maskedInput); + }); + + + + it('Show and update values of regular text fields', () => { + cfFieldSelectValue(controlField,'showText'); + cfFieldIsVisible(textField); + cfFieldIsVisible(textFieldWithDefault); + + cfFieldDoesNotExist(textFieldAsNumber); + cfFieldDoesNotExist(textFieldAsNumberWithDefault); + + + const newValue = '! R%oœnom s 8 oõeê'; + cfFieldSetValue(textField,newValue); + cfFieldSelectValue(controlField,'showNone'); + cfFieldSelectValue(controlField,'showText'); + cfFieldHasValue(textField,newValue); + + }); + + it('Show and update values of number-like text fields', () => { + cfFieldSelectValue(controlField,'showNumber'); + cfFieldIsVisible(textFieldAsNumber); + cfFieldIsVisible(textFieldAsNumberWithDefault); + + cfFieldDoesNotExist(textField); + cfFieldDoesNotExist(textFieldWithDefault); + + const newValue = -42; + cfFieldSetValue(textFieldAsNumber,newValue); + cfFieldSelectValue(controlField,'showNone'); + cfFieldSelectValue(controlField,'showNumber'); + cfFieldHasValue(textFieldAsNumber,newValue); + cfFieldHasValue(textFieldAsNumberWithDefault,5); + + }); + + + it.skip( 'can show masked input and it works right', () => { + const value = '11-ab-2a'; + cfFieldCheckValue(showMaskedInput, 'Yes'); + cfFieldIsVisible(maskedInput); + cfFieldSetValue(maskedInput, value); + + //Hide it + cfFieldCheckValue(showMaskedInput, 'No' ); + cfFieldDoesNotExist(maskedInput); + + //Show it + cfFieldCheckValue(showMaskedInput, 'Yes' ); + cfFieldHasValue(maskedInput,value); + + //Attempt to set an invalid value + getCfField(maskedInput).type( 'Roy' ); + cfFieldHasValue(maskedInput,value); + + //Set a valid value + const newValue ='11-ar-3s'; + cfFieldSetValue(maskedInput,newValue); + cfFieldHasValue(maskedInput,newValue); + //set an invalid value + getCfField(maskedInput,'1adadssada1'); + //still has good value + cfFieldHasValue(maskedInput,newValue); + //hide and show again to make sure it still has valid value + cfFieldCheckValue(showMaskedInput, 'No' ); + cfFieldCheckValue(showMaskedInput, 'Yes' ); + cfFieldHasValue(maskedInput,newValue); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/conditionals-x10.test.js b/cypress/integration/conditionals-x10.test.js new file mode 100644 index 000000000..7dda78b29 --- /dev/null +++ b/cypress/integration/conditionals-x10.test.js @@ -0,0 +1,76 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('x10-conditionals-hide-single-page-create1-5-5'); + }); + + const formId = 'CF59f54cb2b84bb'; + const number1 = 'fld_1705245'; + const text1 = 'fld_6561874'; + const text2 = 'fld_6501179'; + const text3 = 'fld_4732555'; + const email = 'fld_1059582'; + const dropdown = 'fld_5216203'; + + function testInitialLoad() { + //Define how it loads here + } + + it( 'Hides based on dropdown', () => { + cfFieldSelectValue(dropdown, 'Show Email'); + cfFieldIsVisible(email); + }); + + it( 'hides if number is less than ', () => { + cfFieldSetValue(number1,4); + cfFieldDoesNotExist(dropdown); + + + }); + + it( 'hides if number is', () => { + cfFieldSetValue(number1,10); + cfFieldDoesNotExist(dropdown); + cfFieldSetValue(number1,6); + cfFieldIsVisible(dropdown); + + }); + + it( 'Hides if text starts with', () => { + cfFieldSetValue(text1, 'hats' ); + cfFieldDoesNotExist(text2); + cfFieldSetValue(text1, 'hat' ); + cfFieldIsVisible(text2); + cfFieldSetValue(text1, 'hatsa' ); + cfFieldDoesNotExist(text2); + + }); + + it.skip( 'Hides if text ends with', () => { + cfFieldSetValue(text1, 'asasddshats' ); + cfFieldDoesNotExist(text3); + cfFieldSetValue(text1, 'hata' ); + cfFieldIsVisible(text2); + cfFieldSetValue(text1, ' hats' ); + cfFieldDoesNotExist(text2); + }); + + +}); \ No newline at end of file diff --git a/cypress/integration/conditionals-x11.test.js b/cypress/integration/conditionals-x11.test.js new file mode 100644 index 000000000..861380753 --- /dev/null +++ b/cypress/integration/conditionals-x11.test.js @@ -0,0 +1,61 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs +} from '../support/util'; + + +describe('X11 Conditionals Show Single Page create@1.5.5', () => { + beforeEach(() => { + visitPage('x11-conditionals-show-single-page-create1-5-5'); + }); + + const formId = 'CF59f5446e46a71'; + const text1 = 'fld_2960467'; + const number1 = 'fld_7869772'; + const showTextCheckbox = 'fld_5262727'; + const showNumbersRadio = 'fld_6778974'; + + + it( 'Hides and shows a number field based on a radio and brings back its value', () =>{ + cfFieldDoesNotExist(number1); + cfFieldCheckValue(showNumbersRadio, 'Yes' ); + cfFieldIsVisible(number1); + + cfFieldSetValue(number1, '101' ); + cfFieldCheckValue(showNumbersRadio, 'No' ); + cfFieldDoesNotExist(number1); + cfFieldCheckValue(showNumbersRadio, 'Yes' ); + cfFieldHasValue(number1,'101'); + + cfFieldSetValue(number1,-100.01); + cfFieldCheckValue(showNumbersRadio, 'No' ); + cfFieldDoesNotExist(number1); + cfFieldCheckValue(showNumbersRadio, 'Yes' ); + cfFieldHasValue(number1,'-100.01'); + }); + + + it( 'Hides and shows a text field based on a checkbox and brings back its value', () => { + cfFieldIsVisible(text1); + const value = 'hī R&öy!'; + cfFieldSetValue(text1,value); + cfFieldUnCheckValue(showTextCheckbox, 'Yes' ); + cfFieldDoesNotExist(text1); + + cfFieldCheckValue(showTextCheckbox, 'Yes' ); + cfFieldHasValue(text1,value); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/conditionals-x8.test.js b/cypress/integration/conditionals-x8.test.js new file mode 100644 index 000000000..4cc1efafd --- /dev/null +++ b/cypress/integration/conditionals-x8.test.js @@ -0,0 +1,87 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, cfFieldIsNotVisible, cfFieldClickButton +} from '../support/util'; + + +describe('X8 Conditionals Hide create@1.5.5', () => { + beforeEach(() => { + visitPage('x8-conditionals-hide-create1-5-5'); + }); + + const formId = 'CF59f533d0a5e0b'; + const dropdown1 = 'fld_5216203'; + const number1 = 'fld_1705245'; + + const nextButton = 'fld_7100783'; + const prevButton = 'fld_5619974'; + + const dropdown2 = 'fld_313720'; + const number2 = 'fld_8846716'; + + function testInitialLoad() { + getCfField(dropdown1).contains('Hide Number' ); + + cfFieldDoesNotExist(number1); + cfFieldIsVisible(nextButton); + cfFieldIsNotVisible(prevButton); + cfFieldIsNotVisible(dropdown2); + cfFieldDoesNotExist(number2); + } + + + it( 'Updates conditionals across pages', () => { + testInitialLoad(); + cfFieldSelectValue(dropdown1, 'No'); + cfFieldIsVisible(number1); + cfFieldIsNotVisible(number2); + + cfFieldSetValue(number1,5); + cfFieldIsVisible(dropdown1); + + cfFieldSetValue(number1,6); + cfFieldDoesNotExist(dropdown1); + + cfFieldClickButton(nextButton); + cfFieldIsVisible(number2); + cfFieldIsNotVisible(number1); + cfFieldDoesNotExist(dropdown2); + + cfFieldClickButton(prevButton); + cfFieldDoesNotExist(dropdown1); + + cfFieldSetValue(number1,4); + cfFieldIsVisible(dropdown1); + + cfFieldClickButton(nextButton); + cfFieldIsVisible(number2); + cfFieldIsVisible(dropdown2); + + cfFieldSelectValue(dropdown2, 'Hide Number' ); + cfFieldDoesNotExist(number2); + + cfFieldSelectValue(dropdown2, 'No' ); + cfFieldIsVisible(number2); + + cfFieldSetValue(number2,10); + cfFieldDoesNotExist(dropdown2); + + }); + + it( 'Has the correct initial load', () => { + testInitialLoad(); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/conditionals-x9.test.js b/cypress/integration/conditionals-x9.test.js new file mode 100644 index 000000000..7b8956d3f --- /dev/null +++ b/cypress/integration/conditionals-x9.test.js @@ -0,0 +1,61 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, cfFieldClickButton, cfFieldIsNotVisible +} from '../support/util'; + + +describe('X9 CONDITIONALS SHOW CREATE@1.5.5', () => { + beforeEach(() => { + visitPage('x9-conditionals-show-create1-5-5'); + }); + + const formId = 'CF59f542781fc44'; + + const text1 = 'fld_2960467'; + const number1 = 'fld_7869772'; + const text2 = 'fld_1932889'; + const number2 = 'fld_8556025'; + + const showTextCheckbox = 'fld_5262727'; + const showNumbersRadio = 'fld_2047794'; + + const nextButton = 'fld_6983702'; + const prevButton = 'fld_5419649'; + + it( 'Hides and shows based on a radio across pages', () => { + cfFieldDoesNotExist(number1); + cfFieldDoesNotExist(number2); + + cfFieldClickButton(nextButton ); + cfFieldCheckValue(showNumbersRadio, 'Yes'); + cfFieldIsVisible(number2); + + cfFieldClickButton(prevButton); + cfFieldIsVisible(number1); + }); + + it( 'Hides and shows based on a checkbox across pages', () => { + cfFieldIsVisible(text1); + cfFieldIsNotVisible(text2); + + cfFieldUnCheckValue(showTextCheckbox, 'Yes'); + cfFieldDoesNotExist(text1); + + cfFieldClickButton(nextButton); + cfFieldDoesNotExist(text2); + + }); + +}); \ No newline at end of file diff --git a/cypress/integration/html-summary-2013.test.js b/cypress/integration/html-summary-2013.test.js new file mode 100644 index 000000000..7b5b12952 --- /dev/null +++ b/cypress/integration/html-summary-2013.test.js @@ -0,0 +1,57 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, getCfFieldSelector, + cfFieldSummaryContains, + cfFieldSummaryContainsValues +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('2013-html-summary-create1-5-2-1-dev1-5-7'); + }); + + const formId = 'CF59e13e034fc2d'; + const singleLine = 'fld_3068283'; + const dropdown = 'fld_4911252'; + const number1 = 'fld_7259588'; + const number2 = 'fld_7722492'; + + const summaryField = 'fld_5594906'; + + + it( 'Updates summary', () => { + const selector = `#html-content-${summaryField}_1`; + cfFieldSummaryContains(`#html-content-${summaryField}_1`, '2' ); + cfFieldSetValue(singleLine, 'Hi Roy' ); + cfFieldSummaryContainsValues(selector, ['2', 'Hi Roy' ]); + + cfFieldSelectValue(dropdown, 'One' ); + cfFieldSummaryContainsValues(selector, ['2', 'Hi Roy', 'One' ]); + + cfFieldSelectValue(dropdown, 'Two' ); + cfFieldSummaryContainsValues(selector, ['2', 'Hi Roy', 'Two' ]); + + cfFieldSetValue(number1, '55' ); + cfFieldSummaryContainsValues(selector, ['2', 'Hi Roy', 'Two', '55' ]); + + cfFieldSetValue(number2, '5' ); + cfFieldSummaryContainsValues(selector, ['5', 'Hi Roy', 'Two', '55' ]); + + + + }); + +}); \ No newline at end of file diff --git a/cypress/integration/html-summary-2014.test.js b/cypress/integration/html-summary-2014.test.js new file mode 100644 index 000000000..3323deec1 --- /dev/null +++ b/cypress/integration/html-summary-2014.test.js @@ -0,0 +1,78 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, cfFieldSummaryContains, cfFieldSummaryContainsValues +} from '../support/util'; + + +describe('Name of test', () => { + beforeEach(() => { + visitPage('2014-html-summary-create1-5-5-dev1-5-7'); + }); + + const formId = 'CF59e14e252a2c8'; + + const check1 = 'fld_17743'; + const check2 = 'fld_5391964'; + const check3 = 'fld_6022334'; + const summary = 'fld_5594906'; + + const summarySelector = '#html-content-fld_5594906_1'; + + + function testInitialLoad() { + cfFieldSummaryContains(summarySelector, 'Three'); + } + it('Has the correct initial load', () => { + testInitialLoad(); + }); + + it('Updates values', () => { + testInitialLoad(); + cfFieldCheckValue(check1, 'One' ); + cfFieldSummaryContainsValues(summarySelector, [ + 'Three', 'One' + ]); + + cfFieldCheckValue(check3, 'Four' ); + cfFieldSummaryContainsValues(summarySelector, [ + 'Three', 'One', 'Four' + ]); + + cfFieldCheckValue(check3, 'Five' ); + cfFieldSummaryContainsValues(summarySelector, [ + 'Three', 'One', 'Four, Five' + ]); + + cfFieldUnCheckValue(check3, 'Four' ); + cfFieldSummaryContainsValues(summarySelector, [ + 'Three', 'One', 'Five' + ]); + + cfFieldCheckValue(check1, 'Two' ); + cfFieldSummaryContainsValues(summarySelector, [ + 'Three', 'One, Two', 'Five' + ]); + + cfFieldCheckValue(check3, 'Four' ); + cfFieldSummaryContainsValues(summarySelector, [ + 'Three', 'One, Two', 'Four, Five' + ]); + + + }); + + + +}); \ No newline at end of file diff --git a/cypress/integration/html-summary-2049.test.js b/cypress/integration/html-summary-2049.test.js new file mode 100644 index 000000000..5dab48b52 --- /dev/null +++ b/cypress/integration/html-summary-2049.test.js @@ -0,0 +1,92 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, cfFieldSummaryContainsValues +} from '../support/util'; + + +describe('2049 HTML/SUMMARY CREATE@1.5.7 DEV@1.5.7', () => { + beforeEach(() => { + visitPage('2049-html-summary-create1-5-7-dev1-5-7'); + }); + + const formId = 'CF59fb854b2f05f'; + const dropdown1 = 'fld_30547'; + const dropdownSync = 'fld_7212795'; + const autocomplete = 'fld_9766093'; + const autoCompleteSync = 'fld_3490198'; + const summary = 'fld_6130370'; + + + const summaryContainsValues = (containsValues) => { + cfFieldSummaryContainsValues('#html-content-fld_6130370_1', containsValues ); + }; + + function testInitialLoad() { + cfFieldHasValue(dropdown1,'B'); + cfFieldHasValue(dropdownSync,'B'); + + cfFieldHasValue(autocomplete,'D'); + cfFieldHasValue(autoCompleteSync,'D'); + summaryContainsValues([ + 'B', 'B', 'D', 'D' + ]); + } + + it( 'Has the right initial load', () => { + testInitialLoad(); + }); + it.skip( 'Stays in sync from auto-complete field to text field', () => { + testInitialLoad(); + cfFieldSelectValue(dropdown1,'A'); + summaryContainsValues([ + 'A', 'A', 'D', 'D' + ]); + }); + it.skip( 'Breaks sync correctly from auto-complete field to text field', () => { + testInitialLoad(); + cfFieldSetValue(autocomplete,'C'); + cfFieldSetValue(autoCompleteSync, 'Boom' ); + summaryContainsValues([ + 'A', 'A', 'C', 'Boom' + ]); + cfFieldSelectValue(autocomplete,'D'); + cfFieldHasValue(autoCompleteSync, 'Boom' ); + summaryContainsValues([ + 'B', 'A', 'D', 'Boom' + ]); + }); + + it( 'Stays in sync from dropdown field to text field', () => { + testInitialLoad(); + cfFieldSelectValue(dropdown1,'A'); + summaryContainsValues([ + 'A', 'A', 'D', 'D' + ]); + }); + it( 'Breaks sync correctly from dropdown field to text field', () => { + testInitialLoad(); + cfFieldSelectValue(dropdown1,'A'); + cfFieldSetValue(dropdownSync, 'Boom' ); + summaryContainsValues([ + 'A', 'Boom', 'D', 'D' + ]); + cfFieldSelectValue(dropdown1,'B'); + cfFieldHasValue(dropdownSync, 'Boom' ); + summaryContainsValues([ + 'B', 'Boom', 'D', 'D' + ]); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/select-2090.test.js b/cypress/integration/select-2090.test.js new file mode 100644 index 000000000..7652e2467 --- /dev/null +++ b/cypress/integration/select-2090.test.js @@ -0,0 +1,42 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, cfFieldHasOptions +} from '../support/util'; + + +describe('2090 SELECT CREATED@1.5.7.1 DEV@1.5.8', () => { + beforeEach(() => { + visitPage('2090-select-created1-5-7-1-dev1-5-8'); + }); + + const formId = 'CF5a1163356fe7c'; + const select1 = 'fld_7960462'; + const select2 = 'fld_6647575'; + + + function testInitialLoad() { + //Define how it loads here + } + + it( 'Has the right number of options', () => { + cfFieldHasOptions(select1,3); + cfFieldHasOptions(select2,3); + }); + it( 'Has the right default values', () => { + cfFieldHasValue(select1,'0'); + cfFieldHasValue(select2,'1'); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/test-editor-basic.js b/cypress/integration/test-editor-basic.js new file mode 100644 index 000000000..1caa6ca52 --- /dev/null +++ b/cypress/integration/test-editor-basic.js @@ -0,0 +1,94 @@ +import { + visitPage, + getCfField, + clearCfField, + cfFieldIsVisible, + cfFieldDoesNotExist, + cfFieldHasValue, + cfFieldSelectValue, + cfFieldSetValue, + cfFieldCheckValue, + cfFieldIsDisabled, + cfFieldUnCheckValue, + cfFieldIsNotDisabled, + cfFieldCheckAllValues, + cfFieldCalcFieldValueIs, + visitPluginPage, login, visitFormEditor, cfEditorIsFieldPreviewVisible, cfEditorIsFieldPreviewNotVisible +} from '../support/util'; + +const formId = 'CF5bc64d633d2ea'; +const formName = 'Editor Basic Test'; + +const text1 = 'fld_6548786'; +const range2 = 'fld_8586141'; + + + +describe( 'Basic editing of form', () => { + before(() => login() ); + beforeEach(() => { + visitFormEditor( formId ) + }); + + it( 'Save button is primary, preview is not ', () => { + cy.get('.caldera-header-save-button').should( 'have.class', 'button-primary'); + cy.get('.caldera-header-preview-button').not( 'have.class', 'button-primary'); + }); + + it( 'Has the saved processor', () => { + //tab_processors + cy.get( '#tab_processors a' ).click(); + cy.get( '.active-processors-list').children().should('have.length', 1); + cy.get( '.active-processors-list').children().first().click(); + cy.get( '.processor-form_redirect' ).should('be.visible'); + }); + + it( 'Can add a processor', () => { + cy.get( '#tab_processors a' ).click(); + cy.get( '.new-processor-button' ).click(); + cy.get( '.active-processors-list').children().should('have.length', 2);s + }); + + it( 'Page nav', () => { + cy.get('button[data-name="Page 1"]').should( 'have.class', 'button-primary'); + cy.get('button[data-name="Page 2"]').not( 'have.class', 'button-primary'); + cfEditorIsFieldPreviewVisible(text1); + cfEditorIsFieldPreviewNotVisible(range2); + + cy.get('button[data-name="Page 2"]').click(); + cy.get('button[data-name="Page 2"]').should( 'have.class', 'button-primary'); + cy.get('button[data-name="Page 1"]').not( 'have.class', 'button-primary'); + cfEditorIsFieldPreviewVisible(range2); + cfEditorIsFieldPreviewNotVisible(text1); + }); + + it( 'Has the right name', () => { + cy.get('.caldera-element-type-label').contains(formName); + }); + + it( 'Has the variables still saved', () => { + cy.get( '#tab_variables a' ).click(); + cy.get('#variable_entry_list').children().should('have.length', 3); + }); + + it( 'can add a variables', () => { + cy.get( '#tab_variables a' ).click(); + cy.get( 'a.add-new-h2.caldera-panel-action.caldera-add-variable').click(); + cy.get('#variable_entry_list').children().should('have.length', 4); + + }); + + +}); + +describe('Form exists in admin', () => { + beforeEach(() => { + visitPluginPage( 'caldera-forms' ) + }); + + + it( 'Form is in list', () => { + cy.get( '#form_row_CF5bc64d633d2ea').contains(formName); + }); + +}); \ No newline at end of file diff --git a/cypress/integration/test.test.js b/cypress/integration/test.test.js new file mode 100644 index 000000000..ae16425c2 --- /dev/null +++ b/cypress/integration/test.test.js @@ -0,0 +1,67 @@ +import { + url, + user, + pass, + login, + activatePlugin, + visitPluginPage +} from '../support/util'; + +/** + * Before tests, login + * + * This is an anti-pattern + * @todo Use wp-cli or basic authentication headers + */ +before(() => { + login(); + activatePlugin('caldera-forms') +}); + +/** + * Tests for main Caldera Forms page + */ +describe('Caldera Forms admin main page', () => { + /** + * Before each test, go to main admin page + */ + beforeEach(() => { + visitPluginPage('caldera-forms'); + }); + + /** + * Create a contact form + */ + it('New form', () => { + cy.get('.cf-new-form-button').click(); + cy.wait(200); + cy.get('input[value="starter_contact_form"]').click({force: true}); + const name = 'My New Contact Form'; + cy.get('input.new-form-name').type(name); + cy.get('.cf-create-form-button').click(); + cy.url().should('include', 'edit') + cy.get('.caldera-element-type-label').contains(name); + }); +}); + +/** + * Test the block + */ +describe('Block', () => { + /** + * Before each test, go to new post page + */ + beforeEach(() => { + cy.visit(url + '/wp-admin/post-new.php'); + }); + + /** + * Can insert CF block + */ + it('Can insert CF Block', () => { + cy.wait(200); + cy.get('.edit-post-header-toolbar button.components-button.components-icon-button.editor-inserter__toggle').click({force: true}); + cy.get('button.editor-block-types-list__item.editor-block-list-item-calderaforms-cform').click({force: true}); + cy.get('.editor-block-list__layout').contains('Caldera Form'); + }); +}); \ No newline at end of file diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js new file mode 100644 index 000000000..51bec019b --- /dev/null +++ b/cypress/plugins/index.js @@ -0,0 +1,24 @@ +// *********************************************************** +// This example plugins/index.js can be used to load plugins +// +// You can change the location of this file or turn off loading +// the plugins file with the 'pluginsFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/plugins-guide +// *********************************************************** + +// This function is called when a project is opened or re-opened (e.g. due to +// the project's config changing) +const webpack = require('@cypress/webpack-preprocessor'); + +module.exports = (on, config) => { + const options = { + // send in the options from your webpack.config.js, so it works the same + // as your app's code + webpackOptions: require('../../webpack.config'), + watchOptions: {}, + } + + //on('file:preprocessor', webpack(options)) +}; diff --git a/cypress/support/commands.js b/cypress/support/commands.js new file mode 100644 index 000000000..c1f5a772e --- /dev/null +++ b/cypress/support/commands.js @@ -0,0 +1,25 @@ +// *********************************************** +// This example commands.js shows you how to +// create various custom commands and overwrite +// existing commands. +// +// For more comprehensive examples of custom +// commands please read more here: +// https://on.cypress.io/custom-commands +// *********************************************** +// +// +// -- This is a parent command -- +// Cypress.Commands.add("login", (email, password) => { ... }) +// +// +// -- This is a child command -- +// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) +// +// +// -- This is a dual command -- +// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) +// +// +// -- This is will overwrite an existing command -- +// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) diff --git a/cypress/support/index.js b/cypress/support/index.js new file mode 100644 index 000000000..e7aaa3bf8 --- /dev/null +++ b/cypress/support/index.js @@ -0,0 +1,22 @@ +// *********************************************************** +// This example support/index.js is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +import './commands' + + +/** Persist WordPress Cookies **/ +Cypress.Cookies.defaults({ + whitelist: /wordpress_.*/ +}); \ No newline at end of file diff --git a/cypress/support/util.js b/cypress/support/util.js new file mode 100644 index 000000000..1b0c374ad --- /dev/null +++ b/cypress/support/util.js @@ -0,0 +1,353 @@ +/** + * Get site details + * @type {any} + */ +export const site = Cypress.env('wp_site'); +export const {url, user, pass} = site; +export const login = () => { + cy.visit(url + '/wp-login.php'); + cy.wait(500); + cy.get('#user_login').type(user); + cy.get('#user_pass').type(pass); + cy.get('#wp-submit').click(); +}; + +/** + * Activate a plugin + * @param {string} pluginSlug + */ +export const activatePlugin = (pluginSlug) => { + cy.visit(url + '/wp-admin/plugins.php'); + const selector = 'tr[data-slug="' + pluginSlug + '"] .activate a'; + if (Cypress.$(selector).length > 0) { + cy.get(selector).click(); + }; +}; + +function pluginUrl(pluginSlug) { + return `${url}/wp-admin/admin.php?page=${pluginSlug}`; +} + +/** + * Go to a plugin page + * @param {string} pluginSlug + */ +export const visitPluginPage = (pluginSlug) => { + cy.visit(pluginUrl(pluginSlug)); +}; +export const visitFormEditor = (formId) => { + cy.visit(`${pluginUrl('caldera-forms')}&edit=${formId}` ); +} +export const visitPage = (pageSlug) => { + cy.visit(`${url}/${pageSlug}`); +}; + +/** + * Get a Caldera Forms field by ID + * + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const getCfField = (fieldId) => { + return cy.get(getCfFieldSelector(fieldId)); +}; + +/** + * Get the selector for a Caldera Forms field by ID + * + * @param {String} fieldId CF Field ID, not ID attribute + * @return {String} + */ +export const getCfFieldSelector = (fieldId) => { + return `[data-field="${fieldId}"]`; +}; + +/** + * Clear value of Caldera Forms field by ID + * + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const clearCfField = (fieldId) => { + return getCfField(fieldId).clear(); +}; + +/** + * Check if Caldera Forms field is visible by ID + * + * Use: Check if field was unhidden by conditional logic. + + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const cfFieldIsVisible = (fieldId) => { + return getCfField(fieldId).should('be.visible'); +}; + +/** + * Check if Caldera Forms field is NOT visible by ID + * + * Use: Check if field is on a different page AND not hidden by conditional logic + + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const cfFieldIsNotVisible = (fieldId) => { + return getCfField(fieldId).not('be.visible'); +}; + +/**v + * Check if Caldera Forms field does NOT exist on DOM by field ID + * + * Use: Check if field was hidden by conditional logic. + * + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const cfFieldDoesNotExist = (fieldId) => { + return getCfField(fieldId).should('not.exist'); +}; + +/** + * Check if a Caldera Forms field exists and has a value, by field ID + * @param {String} fieldId CF Field ID, not ID attribute + * @param {String|Number} value Value to assert. Evaluated as string (numbers will be cast to string) + * @return {Cypress.Chainable>} + */ +export const cfFieldHasValue = (fieldId, value) => { + if ('number' === typeof value) { + value = value.toString(10); + } + return getCfField(fieldId).should('have.value', value); +}; + +/** + * Select an option of a Caldera Forms select field, by field ID + * @param {String} fieldId CF Field ID, not ID attribute + * @param {String} newValue Value to set + * @return {Cypress.Chainable>} + */ +export const cfFieldSelectValue = (fieldId, newValue) => { + return getCfField(fieldId).select(newValue); +}; + + +export const cfFieldIsValueSelected = (fieldId,value) => { + return cfFieldOptionIsSelected(fieldId,value); +}; + + +/** + * Set new value for Caldera Forms text-like field, by field ID + * + * Note: clears field first + * + * @param {String} fieldId CF Field ID, not ID attribute + * @param {String} newValue Value to set + * @return {Cypress.Chainable>} + */ +export const cfFieldSetValue = (fieldId, newValue) => { + return clearCfField(fieldId).type(newValue); +}; + +/** + * Check value for Caldera Forms radio/checkbox, by field ID + ** + * @param {String} fieldId CF Field ID, not ID attribute + * @param {String} valueToCheck Value to set + * @return {Cypress.Chainable>} + */ +export const cfFieldCheckValue = (fieldId, valueToCheck) => { + return getCfField(fieldId).check(valueToCheck); +}; + +/** + * Check all values for Caldera Forms radio/checkbox, by field ID + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const cfFieldCheckAllValues = (fieldId) => { + return getCfField(fieldId).check(); +}; + +/** + * UnCheck value for Caldera Forms radio/checkbox, by field ID + * + * Note: clears field first + * + * @param {String} fieldId CF Field ID, not ID attribute + * @param {String} valueToCheck Value to set + * @return {Cypress.Chainable>} + */ +export const cfFieldUnCheckValue = (fieldId, valueToCheck) => { + return getCfField(fieldId).uncheck(valueToCheck); +}; + +/** + * Check if a Caldera Forms field is disabled, by field ID + * + * Use: Check if a field is disabled by conditional + * + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const cfFieldIsDisabled = (fieldId) => { + return getCfField(fieldId).should('be.disabled'); +}; + +/** + * Check if a Caldera Forms field is NOT disabled, by field ID + * + * Use: Check if a field is disabled by conditional + * + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const cfFieldIsNotDisabled = (fieldId) => { + return getCfField(fieldId).not('be.disabled'); +}; + +/** + * Get the field ID attribute for a Caldera Forms field by field ID + * + * @param {String} fieldId CF Field ID, not ID attribute + * @param {Number} formCount Optional. Form count, default is 1 + * @return {string} + */ +export const getCfFieldIdAttr = (fieldId, formCount = 1) => { + return `${fieldId}_${formCount}`; +}; + +/** + * Get the field ID attribute for a Caldera Form by form ID + * + * @param {String} formId CF Form ID, not ID attribute + * @param {Number} formCount Optional. Form count, default is 1 + * @return {string} + */ +export const getCfFormIdAttr = (formId, formCount = 1) => { + return `${formId}_${formCount}`; +}; + +/** + * + * @param {String} fieldId CF Field ID, not ID attribute + * @param value + */ +export const cfFieldIsChecked = (fieldId, value ) => { + expect(getCfField(fieldId)).not.to.be.checked +}; + +/** + * Get a checkbox option for a Caldera Forms checkbox field, by field Id and option value. + * @param {String} fieldId CF Field ID, not ID attribute + * @param optionValue + * @return {Cypress.Chainable>} + */ +export const getCfCheckboxOption =(fieldId, optionValue) => { + return cy.get(`input[data-field="${fieldId}"][value="${optionValue}"]`); +}; + +/** + * + * @param {String} fieldId CF Field ID, not ID attribute + * @param optionValue + * @return {Cypress.Chainable>} + */ +export const cfFieldOptionIsChecked = (fieldId, optionValue ) => { + return getCfCheckboxOption(fieldId,optionValue).should('be.checked'); +}; + +export const cfFieldOptionIsNotChecked = (fieldId, optionValue ) => { + return getCfCheckboxOption(fieldId,optionValue).not('be.checked'); +}; + +/** + * + * @param {String} fieldId CF Field ID, not ID attribute + * @param value + * @return {Cypress.Chainable>} + */ +export const cfFieldOptionIsSelected = (fieldId, value ) => { + + return getCfField(fieldId).should('have.value', value); +}; + +/** + * + * @param {String} fieldId CF Field ID, not ID attribute + * @param value + * @return {Cypress.Chainable>} + */ +export const cfFieldCalcFieldValueIs = (fieldId, value) => { + return cy.get( `[data-calc-field="${fieldId}`).should('have.value', value); +}; + +/** + * Check that a summary field contains a value + * + * @param {String} fieldSelector Selector for field + * @param {mixed} contains Value to check for + * @return {Cypress.Chainable>} + */ +export const cfFieldSummaryContains = (fieldSelector,contains) => { + return cy + .get( fieldSelector ) + .find( '.caldera-forms-summary-value' ) + .contains(contains); +}; + +/** + * Check that a summary field contains values + * + * @param {String} fieldSelector Selector for field + * @param {array} containsValues Values to check for + * @param fieldSelector + * @param containsValues + */ +export const cfFieldSummaryContainsValues = (fieldSelector,containsValues) => { + containsValues.forEach( value => { + cfFieldSummaryContains(fieldSelector,value); + }) +}; + +/** + * Click a button by field Id + * + * @param {String} fieldId CF Field ID, not ID attribute + * @return {Cypress.Chainable>} + */ +export const cfFieldClickButton = (fieldId) => { + return cy.get(`.btn${getCfFieldSelector(fieldId)}`).click(); +}; + +export const cfFieldGetWrapper = (fieldId ) => { + return cy.get(`div[data-field-wrapper="${fieldId}"]` ); +}; + +export const cfAlertHasText = (formId, text = 'Form has been successfully submitted. Thank you.' ) => { + return cy.get( `.caldera-grid[data-cf-form-id="${formId}"] .alert` ).contains(text ); +}; + +/** + * Test how many options a select field should have + * + * @param {String} fieldId CF Field ID, not ID attribute + * @param {number} number Number of options select field should have + * @return {Chai.Assertion} + */ +export const cfFieldHasOptions = (fieldId, number ) => { + return expect(Cypress.$(`${getCfFieldSelector(fieldId)}`).find( 'option' ).length ).equals(number); +}; + +export const cfEditorGetFieldPreview = (fieldId) => { + return cy.get( 'div[data-config="fld_8586141"]' ); +}; + +export const cfEditorIsFieldPreviewVisible = (fieldId ) => { + return cfEditorGetFieldPreview(fieldId).should('be.visible'); +}; + +export const cfEditorIsFieldPreviewNotVisible = (fieldId ) => { + return cfEditorGetFieldPreview(fieldId).not('be.visible'); +}; diff --git a/cypress/tests.json b/cypress/tests.json new file mode 100644 index 000000000..c200c2430 --- /dev/null +++ b/cypress/tests.json @@ -0,0 +1,129 @@ +{ + "forms": [ + { + "formId": "CF5bc25738c82c2", + "pageSlug": "conditional-hide-test" + }, + { + "formId": "CF5bc257d7eb85a", + "pageSlug": "hide-conditionals-select" + }, + { + "formId": "CF5bc235072e2a8", + "pageSlug": "conditional-hide-test" + }, + { + "formId": "CF5bc200019a22f", + "pageSlug": "conditional-show-test" + }, + { + "formId": "CF5bc21a0e818ab", + "pageSlug": "conditionals-disable-test" + }, + { + "formId": "CF5bc25cfa53898", + "pageSlug": "calculation-money" + }, + { + "formId": "CF5bc26604eaf3c", + "pageSlug": "calculations-checkbox" + }, + { + "formId": "CF5bc26a30e6032", + "pageSlug": "calculations-manual" + }, + { + "formId": "CF59d957b7acff7", + "pageSlug": "1962-calculations-created1-5-5-dev1-5-6-2", + "ghostId": "59d95f09c80d1948e5dc1938" + }, + { + "formId": "CF59d9652a86fff", + "pageSlug": "1993-calculations-created1-5-5-dev1-5-6-2", + "ghostId": "59dd5575f4151b3304ee4763" + }, + { + "formId": "CF59ce6f1747efb", + "pageSlug": "1979-calculations-created1-5-5-dev1-5-6-2", + "ghostId": "59d828c430e3b074c50ccf39" + }, + { + "formId": "CF59dd15667a03b", + "pageSlug": "x1-calculations-create1-5-5-dev1-5-6-2", + "ghostId": "59dd1c0018b8510dccc849ca" + }, + { + "formId": "CF59dd5d8e95ffb", + "pageSlug": "x2-calculations-create1-5-5-dev1-5-6-2", + "ghostId": "59dd6e5718b8510dccc866e7" + }, + { + "formId": "CF59dd60bbe7ab6", + "pageSlug": "x3-calculations-create1-5-5-dev1-5-6-2", + "ghostId": "59dd6d5af4151b3304ee4c69" + }, + { + "formId": "CF59e13e034fc2d", + "pageSlug": "2013-html-summary-create1-5-2-1-dev1-5-7", + "ghostId": "59f3d36238399239575d5e74" + }, + { + "formId": "CF59e14e252a2c8", + "pageSlug": "2014-html-summary-create1-5-5-dev1-5-7", + "ghostId": "59f3d09b38399239575d5e09" + }, + { + "formId": "CF59f533d0a5e0b", + "pageSlug": "x8-conditionals-hide-create1-5-5", + "ghostId": "59f541e9639a7d76ba202522" + }, + { + "formId": "CF59f542781fc44", + "pageSlug": "x9-conditionals-show-create1-5-5", + "ghostId": "59f54788639a7d76ba2025b3" + }, + { + "formId": "CF59f54cb2b84bb", + "pageSlug": "x10-conditionals-hide-single-page-create1-5-5", + "ghostId": "59f5525f639a7d76ba202728" + }, + { + "formId": "CF59f5446e46a71", + "pageSlug": "x11-conditionals-show-single-page-create1-5-5", + "ghostId": "59f541e9639a7d76ba202522" + }, + { + "formId": "CF59fb854b2f05f", + "pageSlug": "2049-html-summary-create1-5-7-dev1-5-7", + "ghostId": "59fb8f6a38399239575f13b0" + }, + { + "formId": "CF5a047196d398f", + "pageSlug": "2063-calculations-createx-dev1-5-7-1", + "ghostId": "5a0486d1d5628e428b3399f1" + }, + { + "formId": "CF5a0479e6025a2", + "pageSlug": "2063-1-conditionals-create1-6-2-2-dev1-5-7-1", + "ghostId": "5a0486d1d5628e428b3399f1" + }, + { + "formId": "CF5a303ca839615", + "pageSlug": "2021-adv-file-created1-5-7-1-dev1-5-8/", + "ghostId": "5a304bce8c944a6f3e1cc709" + }, + { + "formId": "CF5a3193046927c", + "pageSlug": "2021-adv-file-created1-5-7-1-dev1-5-8/", + "ghostId": "5a304bce8c944a6f3e1cc709" + }, + { + "formId": "CF5a1de64c110ae", + "pageSlug": "2107-credit-card-created-dev1-5-8", + "ghostId": "5a316b7e8c944a6f3e1d200b" + }, + { + "formId": "CF5bc64d633d2ea" + } + ] +} \ No newline at end of file diff --git a/db-error.php b/db-error.php deleted file mode 100644 index 1fe230f73..000000000 --- a/db-error.php +++ /dev/null @@ -1,7 +0,0 @@ -print_error(); -} diff --git a/docker-compose.yml b/docker-compose.yml old mode 100644 new mode 100755 index ec042be3f..89ac3caa4 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,29 +1,46 @@ -version: '2.2' +version: '3.1' services: + wordpress: + image: wordpress + ports: + - 8228:80 + environment: + WORDPRESS_DB_PASSWORD: example + ABSPATH: /usr/src/wordpress/ volumes: - - ./src:/wordpress/src - - ./tests:/wordpress/tests - - ./:/wordpress/src/wp-content/plugins/Caldera-Forms - - build: - context: . - args: - WORDPRESS_DB_PASSWORD: pass - PHP_IMAGE_TAG: $PHP_IMAGE_TAG - WORDPRESS_VERSION: $WORDPRESS_VERSION - depends_on: - mysql: - condition: service_healthy - + - wordpress:/var/www/html + - .:/var/www/html/wp-content/plugins/caldera-forms + - ./wp-content/plugins/gutenberg:/var/www/html/wp-content/plugins/gutenberg + cli: + image: wordpress:cli + volumes: + - wordpress:/var/www/html + - .:/var/www/html/wp-content/plugins/caldera-forms + - ./wp-content/plugins/gutenberg:/var/www/html/wp-content/plugins/gutenberg + environment: + WORDPRESS_DB_PASSWORD: example + ABSPATH: /usr/src/wordpress/ mysql: - image: mariadb:latest - restart: always - healthcheck: - test: "/usr/bin/mysql --user=root --password=pass --execute \"SHOW DATABASES;\"" - interval: 1s - timeout: .5s - retries: 10 + image: mysql:5.7 environment: - MYSQL_ROOT_PASSWORD: pass \ No newline at end of file + MYSQL_ROOT_PASSWORD: example + MYSQL_DATABASE: wordpress_test + + wordpress_phpunit: + image: chriszarate/wordpress-phpunit + environment: + PHPUNIT_DB_HOST: mysql + volumes: + - .:/app + - testsuite:/tmp + + composer: + image: composer + volumes: + - .:/app + +volumes: + testsuite: + wordpress: diff --git a/package-lock.json b/package-lock.json index 8b6ee930d..65868a251 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "caldera-forms", - "version": "1.7.3", + "version": "1.8.0-a.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -13,6 +13,324 @@ "@babel/highlight": "^7.0.0" } }, + "@babel/core": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.0.1.tgz", + "integrity": "sha512-7Yy2vRB6KYbhWeIrrwJmKv9UwDxokmlo43wi6AV84oNs4Gi71NTNGh3YxY/hK3+CxuSc6wcKSl25F2tQOhm1GQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.0.0", + "@babel/helpers": "^7.0.0", + "@babel/parser": "^7.0.0", + "@babel/template": "^7.0.0", + "@babel/traverse": "^7.0.0", + "@babel/types": "^7.0.0", + "convert-source-map": "^1.1.0", + "debug": "^3.1.0", + "json5": "^0.5.0", + "lodash": "^4.17.10", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + }, + "resolve": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.8.1.tgz", + "integrity": "sha512-AicPrAC7Qu1JxPCZ9ZgCZlY35QgFnNqc+0LtbRNxnVw4TXvjQ72wnuL9JQcEBgXkI9JM8MsT9kaQoHcpCRJOYA==", + "dev": true, + "requires": { + "path-parse": "^1.0.5" + } + } + } + }, + "@babel/generator": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.1.3.tgz", + "integrity": "sha512-ZoCZGcfIJFJuZBqxcY9OjC1KW2lWK64qrX1o4UYL3yshVhwKFYgzpWZ0vvtGMNJdTlvkw0W+HR1VnYN8q3QPFQ==", + "dev": true, + "requires": { + "@babel/types": "^7.1.3", + "jsesc": "^2.5.1", + "lodash": "^4.17.10", + "source-map": "^0.5.0", + "trim-right": "^1.0.1" + }, + "dependencies": { + "jsesc": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.1.tgz", + "integrity": "sha1-5CGiqOINawgZ3yiQj3glJrlt0f4=", + "dev": true + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + } + } + }, + "@babel/helper-annotate-as-pure": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz", + "integrity": "sha512-3UYcJUj9kvSLbLbUIfQTqzcy5VX7GRZ/CCDrnOaZorFFM01aXp1+GJwuFGV4NDDoAS+mOUyHcO6UD/RfqOks3Q==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-builder-binary-assignment-operator-visitor": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-builder-binary-assignment-operator-visitor/-/helper-builder-binary-assignment-operator-visitor-7.1.0.tgz", + "integrity": "sha512-qNSR4jrmJ8M1VMM9tibvyRAHXQs2PmaksQF7c1CGJNipfe3D8p+wgNwgso/P2A2r2mdgBWAXljNWR0QRZAMW8w==", + "dev": true, + "requires": { + "@babel/helper-explode-assignable-expression": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-builder-react-jsx": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-builder-react-jsx/-/helper-builder-react-jsx-7.0.0.tgz", + "integrity": "sha512-ebJ2JM6NAKW0fQEqN8hOLxK84RbRz9OkUhGS/Xd5u56ejMfVbayJ4+LykERZCOUM6faa6Fp3SZNX3fcT16MKHw==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0", + "esutils": "^2.0.0" + } + }, + "@babel/helper-call-delegate": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-call-delegate/-/helper-call-delegate-7.1.0.tgz", + "integrity": "sha512-YEtYZrw3GUK6emQHKthltKNZwszBcHK58Ygcis+gVUrF4/FmTVr5CCqQNSfmvg2y+YDEANyYoaLz/SHsnusCwQ==", + "dev": true, + "requires": { + "@babel/helper-hoist-variables": "^7.0.0", + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-define-map": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-define-map/-/helper-define-map-7.1.0.tgz", + "integrity": "sha512-yPPcW8dc3gZLN+U1mhYV91QU3n5uTbx7DUdf8NnPbjS0RMwBuHi9Xt2MUgppmNz7CJxTBWsGczTiEp1CSOTPRg==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.1.0", + "@babel/types": "^7.0.0", + "lodash": "^4.17.10" + }, + "dependencies": { + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + } + } + }, + "@babel/helper-explode-assignable-expression": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-explode-assignable-expression/-/helper-explode-assignable-expression-7.1.0.tgz", + "integrity": "sha512-NRQpfHrJ1msCHtKjbzs9YcMmJZOg6mQMmGRB+hbamEdG5PNpaSm95275VD92DvJKuyl0s2sFiDmMZ+EnnvufqA==", + "dev": true, + "requires": { + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-function-name": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.1.0.tgz", + "integrity": "sha512-A95XEoCpb3TO+KZzJ4S/5uW5fNe26DjBGqf1o9ucyLyCmi1dXq/B3c8iaWTfBk3VvetUxl16e8tIrd5teOCfGw==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.0.0", + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0.tgz", + "integrity": "sha512-r2DbJeg4svYvt3HOS74U4eWKsUAMRH01Z1ds1zx8KNTPtpTL5JAsdFv8BNyOpVqdFhHkkRDIg5B4AsxmkjAlmQ==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-hoist-variables": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.0.0.tgz", + "integrity": "sha512-Ggv5sldXUeSKsuzLkddtyhyHe2YantsxWKNi7A+7LeD12ExRDWTRk29JCXpaHPAbMaIPZSil7n+lq78WY2VY7w==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.0.0.tgz", + "integrity": "sha512-avo+lm/QmZlv27Zsi0xEor2fKcqWG56D5ae9dzklpIaY7cQMK5N8VSpaNVPPagiqmy7LrEjK1IWdGMOqPu5csg==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-module-imports": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.0.0.tgz", + "integrity": "sha512-aP/hlLq01DWNEiDg4Jn23i+CXxW/owM4WpDLFUbpjxe4NS3BhLVZQ5i7E0ZrxuQ/vwekIeciyamgB1UIYxxM6A==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-module-transforms": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.1.0.tgz", + "integrity": "sha512-0JZRd2yhawo79Rcm4w0LwSMILFmFXjugG3yqf+P/UsKsRS1mJCmMwwlHDlMg7Avr9LrvSpp4ZSULO9r8jpCzcw==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/helper-simple-access": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.0.0", + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0", + "lodash": "^4.17.10" + }, + "dependencies": { + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + } + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.0.0.tgz", + "integrity": "sha512-u8nd9NQePYNQV8iPWu/pLLYBqZBa4ZaY1YWRFMuxrid94wKI1QNt67NEZ7GAe5Kc/0LLScbim05xZFWkAdrj9g==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-plugin-utils": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.0.0.tgz", + "integrity": "sha512-CYAOUCARwExnEixLdB6sDm2dIJ/YgEAKDM1MOeMeZu9Ld/bDgVo8aiWrXwcY7OBh+1Ea2uUcVRcxKk0GJvW7QA==", + "dev": true + }, + "@babel/helper-regex": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-regex/-/helper-regex-7.0.0.tgz", + "integrity": "sha512-TR0/N0NDCcUIUEbqV6dCO+LptmmSQFQ7q70lfcEB4URsjD0E1HzicrwUH+ap6BAQ2jhCX9Q4UqZy4wilujWlkg==", + "dev": true, + "requires": { + "lodash": "^4.17.10" + }, + "dependencies": { + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + } + } + }, + "@babel/helper-remap-async-to-generator": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-remap-async-to-generator/-/helper-remap-async-to-generator-7.1.0.tgz", + "integrity": "sha512-3fOK0L+Fdlg8S5al8u/hWE6vhufGSn0bN09xm2LXMy//REAF8kDCrYoOBKYmA8m5Nom+sV9LyLCwrFynA8/slg==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.0.0", + "@babel/helper-wrap-function": "^7.1.0", + "@babel/template": "^7.1.0", + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-replace-supers": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.1.0.tgz", + "integrity": "sha512-BvcDWYZRWVuDeXTYZWxekQNO5D4kO55aArwZOTFXw6rlLQA8ZaDicJR1sO47h+HrnCiDFiww0fSPV0d713KBGQ==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.0.0", + "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-simple-access": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.1.0.tgz", + "integrity": "sha512-Vk+78hNjRbsiu49zAPALxTb+JUQCz1aolpd8osOF16BGnLtseD21nbHgLPGUwrXEurZgiCOUmvs3ExTu4F5x6w==", + "dev": true, + "requires": { + "@babel/template": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0.tgz", + "integrity": "sha512-MXkOJqva62dfC0w85mEf/LucPPS/1+04nmmRMPEBUB++hiiThQ2zPtX/mEWQ3mtzCEjIJvPY8nuwxXtQeQwUag==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@babel/helper-wrap-function": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.1.0.tgz", + "integrity": "sha512-R6HU3dete+rwsdAfrOzTlE9Mcpk4RjU3aX3gi9grtmugQY0u79X7eogUvfXA5sI81Mfq1cn6AgxihfN33STjJA==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.1.0", + "@babel/template": "^7.1.0", + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@babel/helpers": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.1.2.tgz", + "integrity": "sha512-Myc3pUE8eswD73aWcartxB16K6CGmHDv9KxOmD2CeOs/FaEAQodr3VYGmlvOmog60vNQ2w8QbatuahepZwrHiA==", + "dev": true, + "requires": { + "@babel/template": "^7.1.2", + "@babel/traverse": "^7.1.0", + "@babel/types": "^7.1.2" + } + }, "@babel/highlight": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0.tgz", @@ -30,73 +348,1327 @@ "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", "dev": true, "requires": { - "color-convert": "^1.9.0" + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, +<<<<<<< HEAD + "@babel/runtime": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.1.2.tgz", + "integrity": "sha512-Y3SCjmhSupzFB6wcv1KmmFucH6gDVnI30WjOcicV10ju0cZjak3Jcs67YLIXBrmZYw1xCrVeJPbycFwrqNyxpg==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.12.0" +======= + "@babel/parser": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.1.3.tgz", + "integrity": "sha512-gqmspPZOMW3MIRb9HlrnbZHXI1/KHTOroBwN1NcLL6pWxzqzEKGvRTq0W/PxS45OtQGbaFikSQpkS5zbnsQm2w==", + "dev": true + }, + "@babel/plugin-proposal-async-generator-functions": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.1.0.tgz", + "integrity": "sha512-Fq803F3Jcxo20MXUSDdmZZXrPe6BWyGcWBPPNB/M7WaUYESKDeKMOGIxEzQOjGSmW/NWb6UaPZrtTB2ekhB/ew==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-remap-async-to-generator": "^7.1.0", + "@babel/plugin-syntax-async-generators": "^7.0.0" + } + }, + "@babel/plugin-proposal-json-strings": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-json-strings/-/plugin-proposal-json-strings-7.0.0.tgz", + "integrity": "sha512-kfVdUkIAGJIVmHmtS/40i/fg/AGnw/rsZBCaapY5yjeO5RA9m165Xbw9KMOu2nqXP5dTFjEjHdfNdoVcHv133Q==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-json-strings": "^7.0.0" +>>>>>>> feature/2771 + } + }, + "@babel/plugin-proposal-object-rest-spread": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-object-rest-spread/-/plugin-proposal-object-rest-spread-7.0.0.tgz", + "integrity": "sha512-14fhfoPcNu7itSen7Py1iGN0gEm87hX/B+8nZPqkdmANyyYWYMY2pjA3r8WXbWVKMzfnSNS0xY8GVS0IjXi/iw==", + "dev": true, + "requires": { +<<<<<<< HEAD + "core-js": "^2.5.7", + "regenerator-runtime": "^0.12.0" +======= + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-object-rest-spread": "^7.0.0" + } + }, + "@babel/plugin-proposal-optional-catch-binding": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-catch-binding/-/plugin-proposal-optional-catch-binding-7.0.0.tgz", + "integrity": "sha512-JPqAvLG1s13B/AuoBjdBYvn38RqW6n1TzrQO839/sIpqLpbnXKacsAgpZHzLD83Sm8SDXMkkrAvEnJ25+0yIpw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-optional-catch-binding": "^7.0.0" + } + }, + "@babel/plugin-proposal-unicode-property-regex": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-proposal-unicode-property-regex/-/plugin-proposal-unicode-property-regex-7.0.0.tgz", + "integrity": "sha512-tM3icA6GhC3ch2SkmSxv7J/hCWKISzwycub6eGsDrFDgukD4dZ/I+x81XgW0YslS6mzNuQ1Cbzh5osjIMgepPQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-regex": "^7.0.0", + "regexpu-core": "^4.2.0" + }, + "dependencies": { + "regenerate": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", + "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==", + "dev": true + }, + "regexpu-core": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.2.0.tgz", + "integrity": "sha512-Z835VSnJJ46CNBttalHD/dB+Sj2ezmY6Xp38npwU87peK6mqOzOpV8eYktdkLTEkzzD+JsTcxd84ozd8I14+rw==", + "dev": true, + "requires": { + "regenerate": "^1.4.0", + "regenerate-unicode-properties": "^7.0.0", + "regjsgen": "^0.4.0", + "regjsparser": "^0.3.0", + "unicode-match-property-ecmascript": "^1.0.4", + "unicode-match-property-value-ecmascript": "^1.0.2" + } + }, + "regjsgen": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.4.0.tgz", + "integrity": "sha512-X51Lte1gCYUdlwhF28+2YMO0U6WeN0GLpgpA7LK7mbdDnkQYiwvEpmpe0F/cv5L14EbxgrdayAG3JETBv0dbXA==", + "dev": true + }, + "regjsparser": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.3.0.tgz", + "integrity": "sha512-zza72oZBBHzt64G7DxdqrOo/30bhHkwMUoT0WqfGu98XLd7N+1tsy5MJ96Bk4MD0y74n629RhmrGW6XlnLLwCA==", + "dev": true, + "requires": { + "jsesc": "~0.5.0" + } + } +>>>>>>> feature/2771 + } + }, + "@babel/plugin-syntax-async-generators": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.0.0.tgz", + "integrity": "sha512-im7ged00ddGKAjcZgewXmp1vxSZQQywuQXe2B1A7kajjZmDeY/ekMPmWr9zJgveSaQH0k7BcGrojQhcK06l0zA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-json-strings": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.0.0.tgz", + "integrity": "sha512-UlSfNydC+XLj4bw7ijpldc1uZ/HB84vw+U6BTuqMdIEmz/LDe63w/GHtpQMdXWdqQZFeAI9PjnHe/vDhwirhKA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-jsx": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.0.0.tgz", + "integrity": "sha512-PdmL2AoPsCLWxhIr3kG2+F9v4WH06Q3z+NoGVpQgnUNGcagXHq5sB3OXxkSahKq9TLdNMN/AJzFYSOo8UKDMHg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-object-rest-spread": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.0.0.tgz", + "integrity": "sha512-5A0n4p6bIiVe5OvQPxBnesezsgFJdHhSs3uFSvaPdMqtsovajLZ+G2vZyvNe10EzJBWWo3AcHGKhAFUxqwp2dw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-syntax-optional-catch-binding": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.0.0.tgz", + "integrity": "sha512-Wc+HVvwjcq5qBg1w5RG9o9RVzmCaAg/Vp0erHCKpAYV8La6I94o4GQAmFYNmkzoMO6gzoOSulpKeSSz6mPEoZw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-arrow-functions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-arrow-functions/-/plugin-transform-arrow-functions-7.0.0.tgz", + "integrity": "sha512-2EZDBl1WIO/q4DIkIp4s86sdp4ZifL51MoIviLY/gG/mLSuOIEg7J8o6mhbxOTvUJkaN50n+8u41FVsr5KLy/w==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-async-to-generator": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-async-to-generator/-/plugin-transform-async-to-generator-7.1.0.tgz", + "integrity": "sha512-rNmcmoQ78IrvNCIt/R9U+cixUHeYAzgusTFgIAv+wQb9HJU4szhpDD6e5GCACmj/JP5KxuCwM96bX3L9v4ZN/g==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-remap-async-to-generator": "^7.1.0" + } + }, + "@babel/plugin-transform-block-scoped-functions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoped-functions/-/plugin-transform-block-scoped-functions-7.0.0.tgz", + "integrity": "sha512-AOBiyUp7vYTqz2Jibe1UaAWL0Hl9JUXEgjFvvvcSc9MVDItv46ViXFw2F7SVt1B5k+KWjl44eeXOAk3UDEaJjQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-block-scoping": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.0.0.tgz", + "integrity": "sha512-GWEMCrmHQcYWISilUrk9GDqH4enf3UmhOEbNbNrlNAX1ssH3MsS1xLOS6rdjRVPgA7XXVPn87tRkdTEoA/dxEg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "lodash": "^4.17.10" + }, + "dependencies": { + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + } + } + }, + "@babel/plugin-transform-classes": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-classes/-/plugin-transform-classes-7.1.0.tgz", + "integrity": "sha512-rNaqoD+4OCBZjM7VaskladgqnZ1LO6o2UxuWSDzljzW21pN1KXkB7BstAVweZdxQkHAujps5QMNOTWesBciKFg==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.0.0", + "@babel/helper-define-map": "^7.1.0", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-optimise-call-expression": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-replace-supers": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.0.0", + "globals": "^11.1.0" + }, + "dependencies": { + "globals": { + "version": "11.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.8.0.tgz", + "integrity": "sha512-io6LkyPVuzCHBSQV9fmOwxZkUk6nIaGmxheLDgmuFv89j0fm2aqDbIXKAGfzCMHqz3HLF2Zf8WSG6VqMh2qFmA==", + "dev": true + } + } + }, + "@babel/plugin-transform-computed-properties": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-computed-properties/-/plugin-transform-computed-properties-7.0.0.tgz", + "integrity": "sha512-ubouZdChNAv4AAWAgU7QKbB93NU5sHwInEWfp+/OzJKA02E6Woh9RVoX4sZrbRwtybky/d7baTUqwFx+HgbvMA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-destructuring": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-destructuring/-/plugin-transform-destructuring-7.1.3.tgz", + "integrity": "sha512-Mb9M4DGIOspH1ExHOUnn2UUXFOyVTiX84fXCd+6B5iWrQg/QMeeRmSwpZ9lnjYLSXtZwiw80ytVMr3zue0ucYw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-dotall-regex": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-dotall-regex/-/plugin-transform-dotall-regex-7.0.0.tgz", + "integrity": "sha512-00THs8eJxOJUFVx1w8i1MBF4XH4PsAjKjQ1eqN/uCH3YKwP21GCKfrn6YZFZswbOk9+0cw1zGQPHVc1KBlSxig==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-regex": "^7.0.0", + "regexpu-core": "^4.1.3" + }, + "dependencies": { + "regenerate": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", + "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==", + "dev": true + }, + "regexpu-core": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.2.0.tgz", + "integrity": "sha512-Z835VSnJJ46CNBttalHD/dB+Sj2ezmY6Xp38npwU87peK6mqOzOpV8eYktdkLTEkzzD+JsTcxd84ozd8I14+rw==", + "dev": true, + "requires": { + "regenerate": "^1.4.0", + "regenerate-unicode-properties": "^7.0.0", + "regjsgen": "^0.4.0", + "regjsparser": "^0.3.0", + "unicode-match-property-ecmascript": "^1.0.4", + "unicode-match-property-value-ecmascript": "^1.0.2" + } + }, + "regjsgen": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.4.0.tgz", + "integrity": "sha512-X51Lte1gCYUdlwhF28+2YMO0U6WeN0GLpgpA7LK7mbdDnkQYiwvEpmpe0F/cv5L14EbxgrdayAG3JETBv0dbXA==", + "dev": true + }, + "regjsparser": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.3.0.tgz", + "integrity": "sha512-zza72oZBBHzt64G7DxdqrOo/30bhHkwMUoT0WqfGu98XLd7N+1tsy5MJ96Bk4MD0y74n629RhmrGW6XlnLLwCA==", + "dev": true, + "requires": { + "jsesc": "~0.5.0" + } + } + } + }, + "@babel/plugin-transform-duplicate-keys": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-duplicate-keys/-/plugin-transform-duplicate-keys-7.0.0.tgz", + "integrity": "sha512-w2vfPkMqRkdxx+C71ATLJG30PpwtTpW7DDdLqYt2acXU7YjztzeWW2Jk1T6hKqCLYCcEA5UQM/+xTAm+QCSnuQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-exponentiation-operator": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-exponentiation-operator/-/plugin-transform-exponentiation-operator-7.1.0.tgz", + "integrity": "sha512-uZt9kD1Pp/JubkukOGQml9tqAeI8NkE98oZnHZ2qHRElmeKCodbTZgOEUtujSCSLhHSBWbzNiFSDIMC4/RBTLQ==", + "dev": true, + "requires": { + "@babel/helper-builder-binary-assignment-operator-visitor": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-for-of": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.0.0.tgz", + "integrity": "sha512-TlxKecN20X2tt2UEr2LNE6aqA0oPeMT1Y3cgz8k4Dn1j5ObT8M3nl9aA37LLklx0PBZKETC9ZAf9n/6SujTuXA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-function-name": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-function-name/-/plugin-transform-function-name-7.1.0.tgz", + "integrity": "sha512-VxOa1TMlFMtqPW2IDYZQaHsFrq/dDoIjgN098NowhexhZcz3UGlvPgZXuE1jEvNygyWyxRacqDpCZt+par1FNg==", + "dev": true, + "requires": { + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-literals": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-literals/-/plugin-transform-literals-7.0.0.tgz", + "integrity": "sha512-1NTDBWkeNXgpUcyoVFxbr9hS57EpZYXpje92zv0SUzjdu3enaRwF/l3cmyRnXLtIdyJASyiS6PtybK+CgKf7jA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-modules-amd": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-amd/-/plugin-transform-modules-amd-7.1.0.tgz", + "integrity": "sha512-wt8P+xQ85rrnGNr2x1iV3DW32W8zrB6ctuBkYBbf5/ZzJY99Ob4MFgsZDFgczNU76iy9PWsy4EuxOliDjdKw6A==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-modules-commonjs": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-commonjs/-/plugin-transform-modules-commonjs-7.1.0.tgz", + "integrity": "sha512-wtNwtMjn1XGwM0AXPspQgvmE6msSJP15CX2RVfpTSTNPLhKhaOjaIfBaVfj4iUZ/VrFSodcFedwtPg/NxwQlPA==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-simple-access": "^7.1.0" + } + }, + "@babel/plugin-transform-modules-systemjs": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-systemjs/-/plugin-transform-modules-systemjs-7.1.3.tgz", + "integrity": "sha512-PvTxgjxQAq4pvVUZF3mD5gEtVDuId8NtWkJsZLEJZMZAW3TvgQl1pmydLLN1bM8huHFVVU43lf0uvjQj9FRkKw==", + "dev": true, + "requires": { + "@babel/helper-hoist-variables": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-modules-umd": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-modules-umd/-/plugin-transform-modules-umd-7.1.0.tgz", + "integrity": "sha512-enrRtn5TfRhMmbRwm7F8qOj0qEYByqUvTttPEGimcBH4CJHphjyK1Vg7sdU7JjeEmgSpM890IT/efS2nMHwYig==", + "dev": true, + "requires": { + "@babel/helper-module-transforms": "^7.1.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-new-target": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-new-target/-/plugin-transform-new-target-7.0.0.tgz", + "integrity": "sha512-yin069FYjah+LbqfGeTfzIBODex/e++Yfa0rH0fpfam9uTbuEeEOx5GLGr210ggOV77mVRNoeqSYqeuaqSzVSw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-object-super": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-object-super/-/plugin-transform-object-super-7.1.0.tgz", + "integrity": "sha512-/O02Je1CRTSk2SSJaq0xjwQ8hG4zhZGNjE8psTsSNPXyLRCODv7/PBozqT5AmQMzp7MI3ndvMhGdqp9c96tTEw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-replace-supers": "^7.1.0" + } + }, + "@babel/plugin-transform-parameters": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-parameters/-/plugin-transform-parameters-7.1.0.tgz", + "integrity": "sha512-vHV7oxkEJ8IHxTfRr3hNGzV446GAb+0hgbA7o/0Jd76s+YzccdWuTU296FOCOl/xweU4t/Ya4g41yWz80RFCRw==", + "dev": true, + "requires": { + "@babel/helper-call-delegate": "^7.1.0", + "@babel/helper-get-function-arity": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-react-display-name": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.0.0.tgz", + "integrity": "sha512-BX8xKuQTO0HzINxT6j/GiCwoJB0AOMs0HmLbEnAvcte8U8rSkNa/eSCAY+l1OA4JnCVq2jw2p6U8QQryy2fTPg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-react-jsx": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx/-/plugin-transform-react-jsx-7.0.0.tgz", + "integrity": "sha512-0TMP21hXsSUjIQJmu/r7RiVxeFrXRcMUigbKu0BLegJK9PkYodHstaszcig7zxXfaBji2LYUdtqIkHs+hgYkJQ==", + "dev": true, + "requires": { + "@babel/helper-builder-react-jsx": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-jsx": "^7.0.0" + } + }, + "@babel/plugin-transform-react-jsx-self": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-self/-/plugin-transform-react-jsx-self-7.0.0.tgz", + "integrity": "sha512-pymy+AK12WO4safW1HmBpwagUQRl9cevNX+82AIAtU1pIdugqcH+nuYP03Ja6B+N4gliAaKWAegIBL/ymALPHA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-jsx": "^7.0.0" + } + }, + "@babel/plugin-transform-react-jsx-source": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-jsx-source/-/plugin-transform-react-jsx-source-7.0.0.tgz", + "integrity": "sha512-OSeEpFJEH5dw/TtxTg4nijl4nHBbhqbKL94Xo/Y17WKIf2qJWeIk/QeXACF19lG1vMezkxqruwnTjVizaW7u7w==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-syntax-jsx": "^7.0.0" + } + }, + "@babel/plugin-transform-regenerator": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-regenerator/-/plugin-transform-regenerator-7.0.0.tgz", + "integrity": "sha512-sj2qzsEx8KDVv1QuJc/dEfilkg3RRPvPYx/VnKLtItVQRWt1Wqf5eVCOLZm29CiGFfYYsA3VPjfizTCV0S0Dlw==", + "dev": true, + "requires": { + "regenerator-transform": "^0.13.3" + }, + "dependencies": { + "regenerator-transform": { + "version": "0.13.3", + "resolved": "https://registry.npmjs.org/regenerator-transform/-/regenerator-transform-0.13.3.tgz", + "integrity": "sha512-5ipTrZFSq5vU2YoGoww4uaRVAK4wyYC4TSICibbfEPOruUu8FFP7ErV0BjmbIOEpn3O/k9na9UEdYR/3m7N6uA==", + "dev": true, + "requires": { + "private": "^0.1.6" + } + } + } + }, + "@babel/plugin-transform-shorthand-properties": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-shorthand-properties/-/plugin-transform-shorthand-properties-7.0.0.tgz", + "integrity": "sha512-g/99LI4vm5iOf5r1Gdxq5Xmu91zvjhEG5+yZDJW268AZELAu4J1EiFLnkSG3yuUsZyOipVOVUKoGPYwfsTymhw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-spread": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-spread/-/plugin-transform-spread-7.0.0.tgz", + "integrity": "sha512-L702YFy2EvirrR4shTj0g2xQp7aNwZoWNCkNu2mcoU0uyzMl0XRwDSwzB/xp6DSUFiBmEXuyAyEN16LsgVqGGQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-sticky-regex": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-sticky-regex/-/plugin-transform-sticky-regex-7.0.0.tgz", + "integrity": "sha512-LFUToxiyS/WD+XEWpkx/XJBrUXKewSZpzX68s+yEOtIbdnsRjpryDw9U06gYc6klYEij/+KQVRnD3nz3AoKmjw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-regex": "^7.0.0" + } + }, + "@babel/plugin-transform-template-literals": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-template-literals/-/plugin-transform-template-literals-7.0.0.tgz", + "integrity": "sha512-vA6rkTCabRZu7Nbl9DfLZE1imj4tzdWcg5vtdQGvj+OH9itNNB6hxuRMHuIY8SGnEt1T9g5foqs9LnrHzsqEFg==", + "dev": true, + "requires": { + "@babel/helper-annotate-as-pure": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-typeof-symbol": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typeof-symbol/-/plugin-transform-typeof-symbol-7.0.0.tgz", + "integrity": "sha512-1r1X5DO78WnaAIvs5uC48t41LLckxsYklJrZjNKcevyz83sF2l4RHbw29qrCPr/6ksFsdfRpT/ZgxNWHXRnffg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0" + } + }, + "@babel/plugin-transform-unicode-regex": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-unicode-regex/-/plugin-transform-unicode-regex-7.0.0.tgz", + "integrity": "sha512-uJBrJhBOEa3D033P95nPHu3nbFwFE9ZgXsfEitzoIXIwqAZWk7uXcg06yFKXz9FSxBH5ucgU/cYdX0IV8ldHKw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/helper-regex": "^7.0.0", + "regexpu-core": "^4.1.3" + }, + "dependencies": { + "regenerate": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", + "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==", + "dev": true + }, + "regexpu-core": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/regexpu-core/-/regexpu-core-4.2.0.tgz", + "integrity": "sha512-Z835VSnJJ46CNBttalHD/dB+Sj2ezmY6Xp38npwU87peK6mqOzOpV8eYktdkLTEkzzD+JsTcxd84ozd8I14+rw==", + "dev": true, + "requires": { + "regenerate": "^1.4.0", + "regenerate-unicode-properties": "^7.0.0", + "regjsgen": "^0.4.0", + "regjsparser": "^0.3.0", + "unicode-match-property-ecmascript": "^1.0.4", + "unicode-match-property-value-ecmascript": "^1.0.2" + } + }, + "regjsgen": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/regjsgen/-/regjsgen-0.4.0.tgz", + "integrity": "sha512-X51Lte1gCYUdlwhF28+2YMO0U6WeN0GLpgpA7LK7mbdDnkQYiwvEpmpe0F/cv5L14EbxgrdayAG3JETBv0dbXA==", + "dev": true + }, + "regjsparser": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/regjsparser/-/regjsparser-0.3.0.tgz", + "integrity": "sha512-zza72oZBBHzt64G7DxdqrOo/30bhHkwMUoT0WqfGu98XLd7N+1tsy5MJ96Bk4MD0y74n629RhmrGW6XlnLLwCA==", + "dev": true, + "requires": { + "jsesc": "~0.5.0" + } + } + } + }, + "@babel/preset-env": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.0.0.tgz", + "integrity": "sha512-Fnx1wWaWv2w2rl+VHxA9si//Da40941IQ29fKiRejVR7oN1FxSEL8+SyAX/2oKIye2gPvY/GBbJVEKQ/oi43zQ==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.0.0", + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-proposal-async-generator-functions": "^7.0.0", + "@babel/plugin-proposal-json-strings": "^7.0.0", + "@babel/plugin-proposal-object-rest-spread": "^7.0.0", + "@babel/plugin-proposal-optional-catch-binding": "^7.0.0", + "@babel/plugin-proposal-unicode-property-regex": "^7.0.0", + "@babel/plugin-syntax-async-generators": "^7.0.0", + "@babel/plugin-syntax-object-rest-spread": "^7.0.0", + "@babel/plugin-syntax-optional-catch-binding": "^7.0.0", + "@babel/plugin-transform-arrow-functions": "^7.0.0", + "@babel/plugin-transform-async-to-generator": "^7.0.0", + "@babel/plugin-transform-block-scoped-functions": "^7.0.0", + "@babel/plugin-transform-block-scoping": "^7.0.0", + "@babel/plugin-transform-classes": "^7.0.0", + "@babel/plugin-transform-computed-properties": "^7.0.0", + "@babel/plugin-transform-destructuring": "^7.0.0", + "@babel/plugin-transform-dotall-regex": "^7.0.0", + "@babel/plugin-transform-duplicate-keys": "^7.0.0", + "@babel/plugin-transform-exponentiation-operator": "^7.0.0", + "@babel/plugin-transform-for-of": "^7.0.0", + "@babel/plugin-transform-function-name": "^7.0.0", + "@babel/plugin-transform-literals": "^7.0.0", + "@babel/plugin-transform-modules-amd": "^7.0.0", + "@babel/plugin-transform-modules-commonjs": "^7.0.0", + "@babel/plugin-transform-modules-systemjs": "^7.0.0", + "@babel/plugin-transform-modules-umd": "^7.0.0", + "@babel/plugin-transform-new-target": "^7.0.0", + "@babel/plugin-transform-object-super": "^7.0.0", + "@babel/plugin-transform-parameters": "^7.0.0", + "@babel/plugin-transform-regenerator": "^7.0.0", + "@babel/plugin-transform-shorthand-properties": "^7.0.0", + "@babel/plugin-transform-spread": "^7.0.0", + "@babel/plugin-transform-sticky-regex": "^7.0.0", + "@babel/plugin-transform-template-literals": "^7.0.0", + "@babel/plugin-transform-typeof-symbol": "^7.0.0", + "@babel/plugin-transform-unicode-regex": "^7.0.0", + "browserslist": "^4.1.0", + "invariant": "^2.2.2", + "js-levenshtein": "^1.1.3", + "semver": "^5.3.0" + }, + "dependencies": { + "browserslist": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.2.1.tgz", + "integrity": "sha512-1oO0c7Zhejwd+LXihS89WqtKionSbz298rJZKJgfrHIZhrV8AC15gw553VcB0lcEugja7IhWD7iAlrsamfYVPA==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30000890", + "electron-to-chromium": "^1.3.79", + "node-releases": "^1.0.0-alpha.14" + } + }, + "caniuse-lite": { + "version": "1.0.30000893", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30000893.tgz", + "integrity": "sha512-kOddHcTEef+NgN/fs0zmX2brHTNATVOWMEIhlZHCuwQRtXobjSw9pAECc44Op4bTBcavRjkLaPrGomknH7+Jvg==", + "dev": true + }, + "electron-to-chromium": { + "version": "1.3.79", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.79.tgz", + "integrity": "sha512-LQdY3j4PxuUl6xfxiFruTSlCniTrTrzAd8/HfsLEMi0PUpaQ0Iy+Pr4N4VllDYjs0Hyu2lkTbvzqlG+PX9NsNw==", + "dev": true + } + } + }, + "@babel/preset-react": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.0.0.tgz", + "integrity": "sha512-oayxyPS4Zj+hF6Et11BwuBkmpgT/zMxyuZgFrMeZID6Hdh3dGlk4sHCAhdBCpuCKW2ppBfl2uCCetlrUIJRY3w==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@babel/plugin-transform-react-display-name": "^7.0.0", + "@babel/plugin-transform-react-jsx": "^7.0.0", + "@babel/plugin-transform-react-jsx-self": "^7.0.0", + "@babel/plugin-transform-react-jsx-source": "^7.0.0" + } + }, + "@babel/runtime": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.0.0.tgz", + "integrity": "sha512-7hGhzlcmg01CvH1EHdSPVXYX1aJ8KCEyz6I9xYIi/asDtzBPMyMhVibhM/K6g/5qnKBwjZtp10bNZIEFTRW1MA==", + "dev": true, + "requires": { + "regenerator-runtime": "^0.12.0" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", + "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==", + "dev": true + } + } + }, + "@babel/runtime-corejs2": { + "version": "7.0.0-beta.56", + "resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.0.0-beta.56.tgz", + "integrity": "sha512-LE2R7zTLAgaM54y/XdyAMzHERY1lv1cyQll3IvgN2VrTVxdlUBO7t/cHpc5iwqqHI85/VRNfGtQZdO2PecCIqg==", + "requires": { + "core-js": "^2.5.7", + "regenerator-runtime": "^0.12.0" + }, + "dependencies": { + "core-js": { + "version": "2.5.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.5.7.tgz", + "integrity": "sha512-RszJCAxg/PP6uzXVXL6BsxSXx/B05oJAQ2vkJRjyjrEcNVycaqOmNb5OTxZPE3xa5gwZduqza6L9JOCenh/Ecw==" + }, + "regenerator-runtime": { + "version": "0.12.1", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", + "integrity": "sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg==" + } + } + }, + "@babel/template": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.1.2.tgz", + "integrity": "sha512-SY1MmplssORfFiLDcOETrW7fCLl+PavlwMh92rrGcikQaRq4iWPVH0MpwPpY3etVMx6RnDjXtr6VZYr/IbP/Ag==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/parser": "^7.1.2", + "@babel/types": "^7.1.2" + } + }, + "@babel/traverse": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.1.4.tgz", + "integrity": "sha512-my9mdrAIGdDiSVBuMjpn/oXYpva0/EZwWL3sm3Wcy/AVWO2eXnsoZruOT9jOGNRXU8KbCIu5zsKnXcAJ6PcV6Q==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "@babel/generator": "^7.1.3", + "@babel/helper-function-name": "^7.1.0", + "@babel/helper-split-export-declaration": "^7.0.0", + "@babel/parser": "^7.1.3", + "@babel/types": "^7.1.3", + "debug": "^3.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.10" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "globals": { + "version": "11.8.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.8.0.tgz", + "integrity": "sha512-io6LkyPVuzCHBSQV9fmOwxZkUk6nIaGmxheLDgmuFv89j0fm2aqDbIXKAGfzCMHqz3HLF2Zf8WSG6VqMh2qFmA==", + "dev": true + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } + } + }, + "@babel/types": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.1.3.tgz", + "integrity": "sha512-RpPOVfK+yatXyn8n4PB1NW6k9qjinrXrRR8ugBN8fD6hCy5RXI6PSbVqpOJBO9oSaY7Nom4ohj35feb0UR9hSA==", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "lodash": "^4.17.10", + "to-fast-properties": "^2.0.0" + }, + "dependencies": { + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=", + "dev": true + } + } + }, + "@caldera-labs/api-client": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@caldera-labs/api-client/-/api-client-0.2.2.tgz", + "integrity": "sha512-Hu85LYz62m777Pq3jGiC1bbA71scFZ8SG1lS8i3kS90LwX9/Wy6mTDzvK9pmEejDKdOGXs6QOf/VfamFnJqBRQ==", + "dev": true + }, + "@caldera-labs/state": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/@caldera-labs/state/-/state-0.7.1.tgz", + "integrity": "sha512-Pqb88AGoAeBDsT6IEEdGfcNjsSO4SbSmU1sjKpWElbfzBPGOf1WRri9lkRSYyRJ55vBwYEqUanhGnkNL65yNpQ==", + "dev": true + }, + "@cypress/listr-verbose-renderer": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/@cypress/listr-verbose-renderer/-/listr-verbose-renderer-0.4.1.tgz", + "integrity": "sha1-p3SS9LEdzHxEajSz4ochr9M8ZCo=", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "cli-cursor": "^1.0.2", + "date-fns": "^1.27.2", + "figures": "^1.7.0" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "@cypress/webpack-preprocessor": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@cypress/webpack-preprocessor/-/webpack-preprocessor-3.0.0.tgz", + "integrity": "sha512-6AY5SnYwEgt/Ey7DB8TVo1czWxDLn6jyFEU/WUNAwBLOfRsXAiyWx8BuUT38lnwcpTW25beDnvRO8x6GlHd+dw==", + "dev": true, + "requires": { + "@babel/core": "7.0.1", + "@babel/preset-env": "7.0.0", + "@babel/preset-react": "7.0.0", + "babel-loader": "8.0.2", + "bluebird": "3.5.0", + "debug": "3.1.0", + "lodash.clonedeep": "4.5.0", + "webpack": "4.18.1" + }, + "dependencies": { + "acorn": { + "version": "5.7.3", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.7.3.tgz", + "integrity": "sha512-T/zvzYRfbVojPWahDsE5evJdHb3oJoQfFbsrKM7w5Zcs++Tr257tia3BmMP8XYVjp1S9RZXQMh7gao96BlqZOw==", + "dev": true + }, + "acorn-dynamic-import": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/acorn-dynamic-import/-/acorn-dynamic-import-3.0.0.tgz", + "integrity": "sha512-zVWV8Z8lislJoOKKqdNMOB+s6+XV5WERty8MnKBeFgwA+19XJjJHs2RP5dzM57FftIs+jQnRToLiWazKr6sSWg==", + "dev": true, + "requires": { + "acorn": "^5.0.0" + } + }, + "ajv": { + "version": "6.5.4", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.5.4.tgz", + "integrity": "sha512-4Wyjt8+t6YszqaXnLDfMmG/8AlO5Zbcsy3ATHncCzjW/NoPzAId8AK6749Ybjmdt+kUY1gP60fCu46oDxPv/mg==", + "dev": true, + "requires": { + "fast-deep-equal": "^2.0.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "babel-loader": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/babel-loader/-/babel-loader-8.0.2.tgz", + "integrity": "sha512-Law0PGtRV1JL8Y9Wpzc0d6EE0GD7LzXWCfaeWwboUMcBWNG6gvaWTK1/+BK7a4X5EmeJiGEuDDFxUsOa8RSWCw==", + "dev": true, + "requires": { + "find-cache-dir": "^1.0.0", + "loader-utils": "^1.0.2", + "mkdirp": "^0.5.1", + "util.promisify": "^1.0.0" + } + }, + "bluebird": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", + "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=", + "dev": true + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "enhanced-resolve": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz", + "integrity": "sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "memory-fs": "^0.4.0", + "tapable": "^1.0.0" } }, - "chalk": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", - "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "fast-deep-equal": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", + "integrity": "sha1-ewUhjd+WZ79/Nwv3/bLLFf3Qqkk=", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "schema-utils": { + "version": "0.4.7", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-0.4.7.tgz", + "integrity": "sha512-v/iwU6wvwGK8HbU9yi3/nhGzP0yGSuhQMzL6ySiec1FSrZZDkhm4noOSWzrNFo/jEc+SJY6jRTwuwbSXJPDUnQ==", "dev": true, "requires": { - "ansi-styles": "^3.2.1", - "escape-string-regexp": "^1.0.5", - "supports-color": "^5.3.0" + "ajv": "^6.1.0", + "ajv-keywords": "^3.1.0" } }, - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true }, - "js-tokens": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", - "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "tapable": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-1.1.0.tgz", + "integrity": "sha512-IlqtmLVaZA2qab8epUXbVWRn3aB1imbDMJtjB3nu4X0NqPkcY/JH9ZtCBWKHWPxs8Svi9tyo8w2dBoi07qZbBA==", "dev": true }, - "supports-color": { - "version": "5.5.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", - "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "webpack": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-4.18.1.tgz", + "integrity": "sha512-YAKkdiasBy+XJqdxmr00NvL69I6TImnap/3+6YNEkS4lRMAfRCLEmtGWCIB0hGhb+qWDTdTV3C+zTPmctOhJ7Q==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "@webassemblyjs/ast": "1.7.6", + "@webassemblyjs/helper-module-context": "1.7.6", + "@webassemblyjs/wasm-edit": "1.7.6", + "@webassemblyjs/wasm-parser": "1.7.6", + "acorn": "^5.6.2", + "acorn-dynamic-import": "^3.0.0", + "ajv": "^6.1.0", + "ajv-keywords": "^3.1.0", + "chrome-trace-event": "^1.0.0", + "enhanced-resolve": "^4.1.0", + "eslint-scope": "^4.0.0", + "json-parse-better-errors": "^1.0.2", + "loader-runner": "^2.3.0", + "loader-utils": "^1.1.0", + "memory-fs": "~0.4.1", + "micromatch": "^3.1.8", + "mkdirp": "~0.5.0", + "neo-async": "^2.5.0", + "node-libs-browser": "^2.0.0", + "schema-utils": "^0.4.4", + "tapable": "^1.1.0", + "uglifyjs-webpack-plugin": "^1.2.4", + "watchpack": "^1.5.0", + "webpack-sources": "^1.2.0" + } + }, + "webpack-sources": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.3.0.tgz", + "integrity": "sha512-OiVgSrbGu7NEnEvQJJgdSFPl2qWKkWq5lHMhgiToIiN9w34EBnjYzSYs+VbL5KoYiLNtFFa7BZIKxRED3I32pA==", + "dev": true, + "requires": { + "source-list-map": "^2.0.0", + "source-map": "~0.6.1" } } } }, - "@babel/runtime": { - "version": "7.1.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.1.2.tgz", - "integrity": "sha512-Y3SCjmhSupzFB6wcv1KmmFucH6gDVnI30WjOcicV10ju0cZjak3Jcs67YLIXBrmZYw1xCrVeJPbycFwrqNyxpg==", + "@cypress/xvfb": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/@cypress/xvfb/-/xvfb-1.2.3.tgz", + "integrity": "sha512-yYrK+/bgL3hwoRHMZG4r5fyLniCy1pXex5fimtewAY6vE/jsVs8Q37UsEO03tFlcmiLnQ3rBNMaZBYTi/+C1cw==", "dev": true, "requires": { - "regenerator-runtime": "^0.12.0" + "debug": "^3.1.0", + "lodash.once": "^4.1.1" + }, + "dependencies": { + "debug": { + "version": "3.2.6", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", + "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", + "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", + "dev": true + } } }, - "@babel/runtime-corejs2": { - "version": "7.0.0-beta.56", - "resolved": "https://registry.npmjs.org/@babel/runtime-corejs2/-/runtime-corejs2-7.0.0-beta.56.tgz", - "integrity": "sha512-LE2R7zTLAgaM54y/XdyAMzHERY1lv1cyQll3IvgN2VrTVxdlUBO7t/cHpc5iwqqHI85/VRNfGtQZdO2PecCIqg==", + "@types/blob-util": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/@types/blob-util/-/blob-util-1.3.3.tgz", + "integrity": "sha512-4ahcL/QDnpjWA2Qs16ZMQif7HjGP2cw3AGjHabybjw7Vm1EKu+cfQN1D78BaZbS1WJNa1opSMF5HNMztx7lR0w==", + "dev": true + }, + "@types/bluebird": { + "version": "3.5.18", + "resolved": "https://registry.npmjs.org/@types/bluebird/-/bluebird-3.5.18.tgz", + "integrity": "sha512-OTPWHmsyW18BhrnG5x8F7PzeZ2nFxmHGb42bZn79P9hl+GI5cMzyPgQTwNjbem0lJhoru/8vtjAFCUOu3+gE2w==", + "dev": true + }, + "@types/chai": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.0.8.tgz", + "integrity": "sha512-m812CONwdZn/dMzkIJEY0yAs4apyTkTORgfB2UsMOxgkUbC205AHnm4T8I0I5gPg9MHrFc1dJ35iS75c0CJkjg==", + "dev": true + }, + "@types/chai-jquery": { + "version": "1.1.35", + "resolved": "https://registry.npmjs.org/@types/chai-jquery/-/chai-jquery-1.1.35.tgz", + "integrity": "sha512-7aIt9QMRdxuagLLI48dPz96YJdhu64p6FCa6n4qkGN5DQLHnrIjZpD9bXCvV2G0NwgZ1FAmfP214dxc5zNCfgQ==", + "dev": true, "requires": { - "core-js": "^2.5.7", - "regenerator-runtime": "^0.12.0" + "@types/chai": "*", + "@types/jquery": "*" } }, - "@caldera-labs/api-client": { - "version": "0.2.2", - "resolved": "https://registry.npmjs.org/@caldera-labs/api-client/-/api-client-0.2.2.tgz", - "integrity": "sha512-Hu85LYz62m777Pq3jGiC1bbA71scFZ8SG1lS8i3kS90LwX9/Wy6mTDzvK9pmEejDKdOGXs6QOf/VfamFnJqBRQ==", + "@types/jquery": { + "version": "3.2.16", + "resolved": "https://registry.npmjs.org/@types/jquery/-/jquery-3.2.16.tgz", + "integrity": "sha512-q2WC02YxQoX2nY1HRKlYGHpGP1saPmD7GN0pwCDlTz35a4eOtJG+aHRlXyjCuXokUukSrR2aXyBhSW3j+jPc0A==", "dev": true }, - "@caldera-labs/state": { - "version": "0.7.1", - "resolved": "https://registry.npmjs.org/@caldera-labs/state/-/state-0.7.1.tgz", - "integrity": "sha512-Pqb88AGoAeBDsT6IEEdGfcNjsSO4SbSmU1sjKpWElbfzBPGOf1WRri9lkRSYyRJ55vBwYEqUanhGnkNL65yNpQ==", + "@types/lodash": { + "version": "4.14.87", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.87.tgz", + "integrity": "sha512-AqRC+aEF4N0LuNHtcjKtvF9OTfqZI0iaBoe3dA6m/W+/YZJBZjBmW/QIZ8fBeXC6cnytSY9tBoFBqZ9uSCeVsw==", + "dev": true + }, + "@types/minimatch": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz", + "integrity": "sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==", + "dev": true + }, + "@types/mocha": { + "version": "2.2.44", + "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-2.2.44.tgz", + "integrity": "sha512-k2tWTQU8G4+iSMvqKi0Q9IIsWAp/n8xzdZS4Q4YVIltApoMA00wFBFdlJnmoaK1/z7B0Cy0yPe6GgXteSmdUNw==", + "dev": true + }, + "@types/sinon": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@types/sinon/-/sinon-4.0.0.tgz", + "integrity": "sha512-cuK4xM8Lg2wd8cxshcQa8RG4IK/xfyB6TNE6tNVvkrShR4xdrYgsV04q6Dp6v1Lp6biEFdzD8k8zg/ujQeiw+A==", + "dev": true + }, + "@types/sinon-chai": { + "version": "2.7.29", + "resolved": "https://registry.npmjs.org/@types/sinon-chai/-/sinon-chai-2.7.29.tgz", + "integrity": "sha512-EkI/ZvJT4hglWo7Ipf9SX+J+R9htNOMjW8xiOhce7+0csqvgoF5IXqY5Ae1GqRgNtWCuaywR5HjVa1snkTqpOw==", + "dev": true, + "requires": { + "@types/chai": "*", + "@types/sinon": "*" + } + }, + "@webassemblyjs/ast": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.7.6.tgz", + "integrity": "sha512-8nkZS48EVsMUU0v6F1LCIOw4RYWLm2plMtbhFTjNgeXmsTNLuU3xTRtnljt9BFQB+iPbLRobkNrCWftWnNC7wQ==", + "dev": true, + "requires": { + "@webassemblyjs/helper-module-context": "1.7.6", + "@webassemblyjs/helper-wasm-bytecode": "1.7.6", + "@webassemblyjs/wast-parser": "1.7.6", + "mamacro": "^0.0.3" + } + }, + "@webassemblyjs/floating-point-hex-parser": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.7.6.tgz", + "integrity": "sha512-VBOZvaOyBSkPZdIt5VBMg3vPWxouuM13dPXGWI1cBh3oFLNcFJ8s9YA7S9l4mPI7+Q950QqOmqj06oa83hNWBA==", + "dev": true + }, + "@webassemblyjs/helper-api-error": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.7.6.tgz", + "integrity": "sha512-SCzhcQWHXfrfMSKcj8zHg1/kL9kb3aa5TN4plc/EREOs5Xop0ci5bdVBApbk2yfVi8aL+Ly4Qpp3/TRAUInjrg==", + "dev": true + }, + "@webassemblyjs/helper-buffer": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.7.6.tgz", + "integrity": "sha512-1/gW5NaGsEOZ02fjnFiU8/OEEXU1uVbv2um0pQ9YVL3IHSkyk6xOwokzyqqO1qDZQUAllb+V8irtClPWntbVqw==", "dev": true }, + "@webassemblyjs/helper-code-frame": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.7.6.tgz", + "integrity": "sha512-+suMJOkSn9+vEvDvgyWyrJo5vJsWSDXZmJAjtoUq4zS4eqHyXImpktvHOZwXp1XQjO5H+YQwsBgqTQEc0J/5zg==", + "dev": true, + "requires": { + "@webassemblyjs/wast-printer": "1.7.6" + } + }, + "@webassemblyjs/helper-fsm": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-fsm/-/helper-fsm-1.7.6.tgz", + "integrity": "sha512-HCS6KN3wgxUihGBW7WFzEC/o8Eyvk0d56uazusnxXthDPnkWiMv+kGi9xXswL2cvfYfeK5yiM17z2K5BVlwypw==", + "dev": true + }, + "@webassemblyjs/helper-module-context": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-module-context/-/helper-module-context-1.7.6.tgz", + "integrity": "sha512-e8/6GbY7OjLM+6OsN7f2krC2qYVNaSr0B0oe4lWdmq5sL++8dYDD1TFbD1TdAdWMRTYNr/Qq7ovXWzia2EbSjw==", + "dev": true, + "requires": { + "mamacro": "^0.0.3" + } + }, + "@webassemblyjs/helper-wasm-bytecode": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.7.6.tgz", + "integrity": "sha512-PzYFCb7RjjSdAOljyvLWVqd6adAOabJW+8yRT+NWhXuf1nNZWH+igFZCUK9k7Cx7CsBbzIfXjJc7u56zZgFj9Q==", + "dev": true + }, + "@webassemblyjs/helper-wasm-section": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.7.6.tgz", + "integrity": "sha512-3GS628ppDPSuwcYlQ7cDCGr4W2n9c4hLzvnRKeuz+lGsJSmc/ADVoYpm1ts2vlB1tGHkjtQMni+yu8mHoMlKlA==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.7.6", + "@webassemblyjs/helper-buffer": "1.7.6", + "@webassemblyjs/helper-wasm-bytecode": "1.7.6", + "@webassemblyjs/wasm-gen": "1.7.6" + } + }, + "@webassemblyjs/ieee754": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.7.6.tgz", + "integrity": "sha512-V4cIp0ruyw+hawUHwQLn6o2mFEw4t50tk530oKsYXQhEzKR+xNGDxs/SFFuyTO7X3NzEu4usA3w5jzhl2RYyzQ==", + "dev": true, + "requires": { + "@xtuc/ieee754": "^1.2.0" + } + }, + "@webassemblyjs/leb128": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.7.6.tgz", + "integrity": "sha512-ojdlG8WpM394lBow4ncTGJoIVZ4aAtNOWHhfAM7m7zprmkVcKK+2kK5YJ9Bmj6/ketTtOn7wGSHCtMt+LzqgYQ==", + "dev": true, + "requires": { + "@xtuc/long": "4.2.1" + } + }, + "@webassemblyjs/utf8": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.7.6.tgz", + "integrity": "sha512-oId+tLxQ+AeDC34ELRYNSqJRaScB0TClUU6KQfpB8rNT6oelYlz8axsPhf6yPTg7PBJ/Z5WcXmUYiHEWgbbHJw==", + "dev": true + }, + "@webassemblyjs/wasm-edit": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.7.6.tgz", + "integrity": "sha512-pTNjLO3o41v/Vz9VFLl+I3YLImpCSpodFW77pNoH4agn5I6GgSxXHXtvWDTvYJFty0jSeXZWLEmbaSIRUDlekg==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.7.6", + "@webassemblyjs/helper-buffer": "1.7.6", + "@webassemblyjs/helper-wasm-bytecode": "1.7.6", + "@webassemblyjs/helper-wasm-section": "1.7.6", + "@webassemblyjs/wasm-gen": "1.7.6", + "@webassemblyjs/wasm-opt": "1.7.6", + "@webassemblyjs/wasm-parser": "1.7.6", + "@webassemblyjs/wast-printer": "1.7.6" + } + }, + "@webassemblyjs/wasm-gen": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.7.6.tgz", + "integrity": "sha512-mQvFJVumtmRKEUXMohwn8nSrtjJJl6oXwF3FotC5t6e2hlKMh8sIaW03Sck2MDzw9xPogZD7tdP5kjPlbH9EcQ==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.7.6", + "@webassemblyjs/helper-wasm-bytecode": "1.7.6", + "@webassemblyjs/ieee754": "1.7.6", + "@webassemblyjs/leb128": "1.7.6", + "@webassemblyjs/utf8": "1.7.6" + } + }, + "@webassemblyjs/wasm-opt": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.7.6.tgz", + "integrity": "sha512-go44K90fSIsDwRgtHhX14VtbdDPdK2sZQtZqUcMRvTojdozj5tLI0VVJAzLCfz51NOkFXezPeVTAYFqrZ6rI8Q==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.7.6", + "@webassemblyjs/helper-buffer": "1.7.6", + "@webassemblyjs/wasm-gen": "1.7.6", + "@webassemblyjs/wasm-parser": "1.7.6" + } + }, + "@webassemblyjs/wasm-parser": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.7.6.tgz", + "integrity": "sha512-t1T6TfwNY85pDA/HWPA8kB9xA4sp9ajlRg5W7EKikqrynTyFo+/qDzIpvdkOkOGjlS6d4n4SX59SPuIayR22Yg==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.7.6", + "@webassemblyjs/helper-api-error": "1.7.6", + "@webassemblyjs/helper-wasm-bytecode": "1.7.6", + "@webassemblyjs/ieee754": "1.7.6", + "@webassemblyjs/leb128": "1.7.6", + "@webassemblyjs/utf8": "1.7.6" + } + }, + "@webassemblyjs/wast-parser": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-parser/-/wast-parser-1.7.6.tgz", + "integrity": "sha512-1MaWTErN0ziOsNUlLdvwS+NS1QWuI/kgJaAGAMHX8+fMJFgOJDmN/xsG4h/A1Gtf/tz5VyXQciaqHZqp2q0vfg==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.7.6", + "@webassemblyjs/floating-point-hex-parser": "1.7.6", + "@webassemblyjs/helper-api-error": "1.7.6", + "@webassemblyjs/helper-code-frame": "1.7.6", + "@webassemblyjs/helper-fsm": "1.7.6", + "@xtuc/long": "4.2.1", + "mamacro": "^0.0.3" + } + }, + "@webassemblyjs/wast-printer": { + "version": "1.7.6", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.7.6.tgz", + "integrity": "sha512-vHdHSK1tOetvDcl1IV1OdDeGNe/NDDQ+KzuZHMtqTVP1xO/tZ/IKNpj5BaGk1OYFdsDWQqb31PIwdEyPntOWRQ==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.7.6", + "@webassemblyjs/wast-parser": "1.7.6", + "@xtuc/long": "4.2.1" + } + }, "@wordpress/babel-preset-default": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@wordpress/babel-preset-default/-/babel-preset-default-1.3.0.tgz", @@ -220,6 +1792,18 @@ "@babel/runtime-corejs2": "7.0.0-beta.56" } }, + "@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", + "dev": true + }, + "@xtuc/long": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.1.tgz", + "integrity": "sha512-FZdkNBDqBRHKQ2MEbSC17xnPFOhZxeJ2YGSfr2BKf3sujG49Qe3bB+rGCwQfIaA7WHnGeGkSijX4FuBCdrzW/g==", + "dev": true + }, "abab": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.0.tgz", @@ -2096,6 +3680,15 @@ } } }, + "cachedir": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/cachedir/-/cachedir-1.3.0.tgz", + "integrity": "sha512-O1ji32oyON9laVPJL1IZ5bmwd2cB46VfpxkDequezH+15FDzzVddEyrGEeX4WusDSqKxdyFdDQDEG1yo1GoWkg==", + "dev": true, + "requires": { + "os-homedir": "^1.0.1" + } + }, "callsites": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-2.0.0.tgz", @@ -2187,6 +3780,12 @@ "supports-color": "^2.0.0" } }, + "check-more-types": { + "version": "2.24.0", + "resolved": "https://registry.npmjs.org/check-more-types/-/check-more-types-2.24.0.tgz", + "integrity": "sha1-FCD/sQ/URNz8ebQ4kbv//TKoRgA=", + "dev": true + }, "chokidar": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", @@ -2211,6 +3810,15 @@ "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==", "dev": true }, + "chrome-trace-event": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.0.tgz", + "integrity": "sha512-xDbVgyfDTT2piup/h8dK/y4QZfJRSa73bw1WZ8b4XM1o7fsFubUVGYcE+1ANtOzJJELGpYoG2961z0Z6OAld9A==", + "dev": true, + "requires": { + "tslib": "^1.9.0" + } + }, "ci-info": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.6.0.tgz", @@ -2299,6 +3907,31 @@ } } }, + "cli-cursor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-1.0.2.tgz", + "integrity": "sha1-ZNo/fValRBLll5S9Ytw1KV6PKYc=", + "dev": true, + "requires": { + "restore-cursor": "^1.0.1" + } + }, + "cli-spinners": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-0.1.2.tgz", + "integrity": "sha1-u3ZNiOGF+54eaiofGXcjGPYF4xw=", + "dev": true + }, + "cli-truncate": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/cli-truncate/-/cli-truncate-0.2.1.tgz", + "integrity": "sha1-nxXPuwcFAFNpIWxiasfQWrkN1XQ=", + "dev": true, + "requires": { + "slice-ansi": "0.0.4", + "string-width": "^1.0.1" + } + }, "cliui": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-2.1.0.tgz", @@ -2441,6 +4074,15 @@ "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==", "dev": true }, + "common-tags": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/common-tags/-/common-tags-1.4.0.tgz", + "integrity": "sha1-EYe+Tz1M8MBCfUP3Tu8fc1AWFMA=", + "dev": true, + "requires": { + "babel-runtime": "^6.18.0" + } + }, "commondir": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", @@ -2876,12 +4518,82 @@ "resolved": "https://registry.npmjs.org/autoprefixer/-/autoprefixer-6.7.7.tgz", "integrity": "sha1-Hb0cg1ZY41zj+ZhAmdsAWFx4IBQ=", "requires": { - "browserslist": "^1.7.6", - "caniuse-db": "^1.0.30000634", - "normalize-range": "^0.1.2", - "num2fraction": "^1.2.2", - "postcss": "^5.2.16", - "postcss-value-parser": "^3.2.3" + "browserslist": "^1.7.6", + "caniuse-db": "^1.0.30000634", + "normalize-range": "^0.1.2", + "num2fraction": "^1.2.2", + "postcss": "^5.2.16", + "postcss-value-parser": "^3.2.3" + } +<<<<<<< HEAD +======= + }, + "browserslist": { + "version": "1.7.7", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-1.7.7.tgz", + "integrity": "sha1-C9dnBCWL6CmyOYu1Dkti0aFmsLk=", + "requires": { + "caniuse-db": "^1.0.30000639", + "electron-to-chromium": "^1.2.7" + } + }, + "chalk": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + }, + "dependencies": { + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=" + } + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "has-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", + "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=" + }, + "postcss": { + "version": "5.2.18", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-5.2.18.tgz", + "integrity": "sha512-zrUjRRe1bpXKsX1qAJNJjqZViErVuyEkMTRrwu4ud4sbTtIBRmtaYDrHmcGgmrbsW3MHfmtIf+vJumgQn+PrXg==", + "requires": { + "chalk": "^1.1.3", + "js-base64": "^2.1.9", + "source-map": "^0.5.6", + "supports-color": "^3.2.3" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", + "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "requires": { + "has-flag": "^1.0.0" } } } @@ -2925,6 +4637,260 @@ "integrity": "sha1-GzN5LhHpFKL9bW7WRHRkRE5fpkA=", "dev": true }, + "cypress": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/cypress/-/cypress-3.1.0.tgz", + "integrity": "sha512-UqLbXgHvM8Y6Y+roHrepZMWcyMN5u4KcjpTbJTZi0d5O2Prvtqmnpoky7a4C65q4oRQXeSc6cBZUhxJkhU4pbQ==", + "dev": true, + "requires": { + "@cypress/listr-verbose-renderer": "0.4.1", + "@cypress/xvfb": "1.2.3", + "@types/blob-util": "1.3.3", + "@types/bluebird": "3.5.18", + "@types/chai": "4.0.8", + "@types/chai-jquery": "1.1.35", + "@types/jquery": "3.2.16", + "@types/lodash": "4.14.87", + "@types/minimatch": "3.0.3", + "@types/mocha": "2.2.44", + "@types/sinon": "4.0.0", + "@types/sinon-chai": "2.7.29", + "bluebird": "3.5.0", + "cachedir": "1.3.0", + "chalk": "2.4.1", + "check-more-types": "2.24.0", + "commander": "2.11.0", + "common-tags": "1.4.0", + "debug": "3.1.0", + "execa": "0.10.0", + "executable": "4.1.1", + "extract-zip": "1.6.6", + "fs-extra": "4.0.1", + "getos": "3.1.0", + "glob": "7.1.2", + "is-ci": "1.0.10", + "is-installed-globally": "0.1.0", + "lazy-ass": "1.6.0", + "listr": "0.12.0", + "lodash": "4.17.10", + "log-symbols": "2.2.0", + "minimist": "1.2.0", + "progress": "1.1.8", + "ramda": "0.24.1", + "request": "2.87.0", + "request-progress": "0.3.1", + "supports-color": "5.1.0", + "tmp": "0.0.31", + "url": "0.11.0", + "yauzl": "2.8.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "bluebird": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.0.tgz", + "integrity": "sha1-eRQg1/VR7qKJdFOop3ZT+WYG1nw=", + "dev": true + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "dependencies": { + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + }, + "cross-spawn": { + "version": "6.0.5", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz", + "integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==", + "dev": true, + "requires": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "execa": { + "version": "0.10.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.10.0.tgz", + "integrity": "sha512-7XOMnz8Ynx1gGo/3hyV9loYNPWM94jG3+3T3Y8tsfSstFmETmENCMU/A/zj8Lyaj1lkgEepKepvd6240tBRvlw==", + "dev": true, + "requires": { + "cross-spawn": "^6.0.0", + "get-stream": "^3.0.0", + "is-stream": "^1.1.0", + "npm-run-path": "^2.0.0", + "p-finally": "^1.0.0", + "signal-exit": "^3.0.0", + "strip-eof": "^1.0.0" + } + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "har-validator": { + "version": "5.0.3", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.0.3.tgz", + "integrity": "sha1-ukAsJmGU8VlW7xXg/PJCmT9qff0=", + "dev": true, + "requires": { + "ajv": "^5.1.0", + "har-schema": "^2.0.0" + } + }, + "is-ci": { + "version": "1.0.10", + "resolved": "http://registry.npmjs.org/is-ci/-/is-ci-1.0.10.tgz", + "integrity": "sha1-9zkzayYyNlBhqdSCcM1WrjNpMY4=", + "dev": true, + "requires": { + "ci-info": "^1.0.0" + } + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "oauth-sign": { + "version": "0.8.2", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.8.2.tgz", + "integrity": "sha1-Rqarfwrq2N6unsBWV4C31O/rnUM=", + "dev": true + }, + "request": { + "version": "2.87.0", + "resolved": "https://registry.npmjs.org/request/-/request-2.87.0.tgz", + "integrity": "sha512-fcogkm7Az5bsS6Sl0sibkbhcKsnyon/jV1kF3ajGmF0c8HrttdKTPRT9hieOaQHA5HEq6r8OyWOo/o781C1tNw==", + "dev": true, + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.6.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.5", + "extend": "~3.0.1", + "forever-agent": "~0.6.1", + "form-data": "~2.3.1", + "har-validator": "~5.0.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.17", + "oauth-sign": "~0.8.2", + "performance-now": "^2.1.0", + "qs": "~6.5.1", + "safe-buffer": "^5.1.1", + "tough-cookie": "~2.3.3", + "tunnel-agent": "^0.6.0", + "uuid": "^3.1.0" + } + }, + "supports-color": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.1.0.tgz", + "integrity": "sha512-Ry0AwkoKjDpVKK4sV4h6o3UJmNRbjYm2uXhwfj3J56lMVdvnUNqzQVRztOOMGQ++w1K/TjNDFvpJk0F/LoeBCQ==", + "dev": true, + "requires": { + "has-flag": "^2.0.0" + }, + "dependencies": { + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + } + } + }, + "tough-cookie": { + "version": "2.3.4", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.3.4.tgz", + "integrity": "sha512-TZ6TTfI5NtZnuyy/Kecv+CnoROnyXn2DN97LontgQpCwsX2XyLYCC0ENhYkehSOwAp8rTQKc/NUIF7BkQ5rKLA==", + "dev": true, + "requires": { + "punycode": "^1.4.1" + } + }, + "which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } +>>>>>>> feature/2771 + } + } + }, "d": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/d/-/d-1.0.0.tgz", @@ -2977,6 +4943,12 @@ } } }, + "date-fns": { + "version": "1.29.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-1.29.0.tgz", + "integrity": "sha512-lbTXWZ6M20cWH8N9S6afb0SBm6tMk+uUg6z3MqHPKE9atmsY3kJkTm8vKe93izJ2B2+q5MV990sM2CHgtAZaOw==", + "dev": true + }, "date-now": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/date-now/-/date-now-0.1.4.tgz", @@ -3273,6 +5245,12 @@ "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.3.79.tgz", "integrity": "sha512-LQdY3j4PxuUl6xfxiFruTSlCniTrTrzAd8/HfsLEMi0PUpaQ0Iy+Pr4N4VllDYjs0Hyu2lkTbvzqlG+PX9NsNw==" }, + "elegant-spinner": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/elegant-spinner/-/elegant-spinner-1.0.1.tgz", + "integrity": "sha1-2wQ1IcldfjA/2PNFvtwzSc+wcp4=", + "dev": true + }, "elliptic": { "version": "6.4.1", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-6.4.1.tgz", @@ -3517,6 +5495,16 @@ "estraverse": "^4.1.1" } }, + "eslint-scope": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz", + "integrity": "sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA==", + "dev": true, + "requires": { + "esrecurse": "^4.1.0", + "estraverse": "^4.1.1" + } + }, "esprima": { "version": "2.7.3", "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", @@ -3611,12 +5599,27 @@ } } }, + "executable": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/executable/-/executable-4.1.1.tgz", + "integrity": "sha512-8iA79xD3uAch729dUG8xaaBBFGaEa0wdD2VkYLFHwlqosEj/jT66AzcreRDSgV7ehnNLBW2WR5jIXwGKjVdTLg==", + "dev": true, + "requires": { + "pify": "^2.2.0" + } + }, "exit": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", "dev": true }, + "exit-hook": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-1.1.1.tgz", + "integrity": "sha1-8FyiM7SMBdVP/wd2XfhQfpXAL/g=", + "dev": true + }, "expand-brackets": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", @@ -3709,7 +5712,73 @@ "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", "dev": true, "requires": { +<<<<<<< HEAD "is-extglob": "^1.0.0" +======= + "array-unique": "^0.3.2", + "define-property": "^1.0.0", + "expand-brackets": "^2.1.4", + "extend-shallow": "^2.0.1", + "fragment-cache": "^0.2.1", + "regex-not": "^1.0.0", + "snapdragon": "^0.8.1", + "to-regex": "^3.0.1" + }, + "dependencies": { + "define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", + "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", + "dev": true, + "requires": { + "is-descriptor": "^1.0.0" + } + }, + "extend-shallow": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", + "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", + "dev": true, + "requires": { + "is-extendable": "^0.1.0" + } + }, + "is-accessor-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-data-descriptor": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", + "dev": true, + "requires": { + "kind-of": "^6.0.0" + } + }, + "is-descriptor": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", + "dev": true, + "requires": { + "is-accessor-descriptor": "^1.0.0", + "is-data-descriptor": "^1.0.0", + "kind-of": "^6.0.2" + } + }, + "kind-of": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", + "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", + "dev": true + } +>>>>>>> feature/2771 } }, "extract-text-webpack-plugin": { @@ -3722,6 +5791,120 @@ "loader-utils": "^1.1.0", "schema-utils": "^0.3.0", "webpack-sources": "^1.0.1" +<<<<<<< HEAD +======= + }, + "dependencies": { + "async": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.6.0.tgz", + "integrity": "sha512-xAfGg1/NTLBBKlHFmnd7PlmUW9KhVQIUuSrYem9xzFUZy13ScvtyGGejaae9iAVRiRq9+Cx7DPFaAAhCpyxyPw==", + "dev": true, + "requires": { + "lodash": "^4.14.0" + } + }, + "lodash": { + "version": "4.17.5", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.5.tgz", + "integrity": "sha512-svL3uiZf1RwhH+cWrfZn3A4+U58wbP0tGVTLQPbjplZxZ8ROD9VLuNgsRniTlLe7OlSqR79RUehXgpBW/s0IQw==", + "dev": true + } + } + }, + "extract-zip": { + "version": "1.6.6", + "resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-1.6.6.tgz", + "integrity": "sha1-EpDt6NINCHK0Kf0/NRyhKOxe+Fw=", + "dev": true, + "requires": { + "concat-stream": "1.6.0", + "debug": "2.6.9", + "mkdirp": "0.5.0", + "yauzl": "2.4.1" + }, + "dependencies": { + "concat-stream": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/concat-stream/-/concat-stream-1.6.0.tgz", + "integrity": "sha1-CqxmL9Ur54lk1VMvaUeE5wEQrPc=", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "readable-stream": "^2.2.2", + "typedarray": "^0.0.6" + } + }, + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "minimist": { + "version": "0.0.8", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.0", + "resolved": "http://registry.npmjs.org/mkdirp/-/mkdirp-0.5.0.tgz", + "integrity": "sha1-HXMHam35hs2TROFecfzAWkyavxI=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "readable-stream": { + "version": "2.3.6", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.3", + "isarray": "~1.0.0", + "process-nextick-args": "~2.0.0", + "safe-buffer": "~5.1.1", + "string_decoder": "~1.1.1", + "util-deprecate": "~1.0.1" + } + }, + "string_decoder": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + }, + "yauzl": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.4.1.tgz", + "integrity": "sha1-lSj0QtqxsihOWLQ3m7GU4i4MQAU=", + "dev": true, + "requires": { + "fd-slicer": "~1.0.1" + } + } +>>>>>>> feature/2771 } }, "extsprintf": { @@ -3771,6 +5954,39 @@ "bser": "^2.0.0" } }, +<<<<<<< HEAD +======= + "fbjs": { + "version": "0.8.16", + "resolved": "https://registry.npmjs.org/fbjs/-/fbjs-0.8.16.tgz", + "integrity": "sha1-XmdDL1UNxBtXK/VYR7ispk5TN9s=", + "requires": { + "core-js": "^1.0.0", + "isomorphic-fetch": "^2.1.1", + "loose-envify": "^1.0.0", + "object-assign": "^4.1.0", + "promise": "^7.1.1", + "setimmediate": "^1.0.5", + "ua-parser-js": "^0.7.9" + }, + "dependencies": { + "core-js": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-1.2.7.tgz", + "integrity": "sha1-ZSKUwUZR2yj6k70tX/KYOk8IxjY=" + } + } + }, + "fd-slicer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.0.1.tgz", + "integrity": "sha1-i1vL2ewyfFBBv5qwI/1nUPEXfmU=", + "dev": true, + "requires": { + "pend": "~1.2.0" + } + }, +>>>>>>> feature/2771 "figures": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/figures/-/figures-1.7.0.tgz", @@ -3994,6 +6210,17 @@ "readable-stream": "^2.0.0" } }, + "fs-extra": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-4.0.1.tgz", + "integrity": "sha1-f8DGyJV/mD9X8waiTlud3Y0N2IA=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "jsonfile": "^3.0.0", + "universalify": "^0.1.0" + } + }, "fs-readdir-recursive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", @@ -4641,6 +6868,32 @@ "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=", "dev": true }, + "getos": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/getos/-/getos-3.1.0.tgz", + "integrity": "sha512-i9vrxtDu5DlLVFcrbqUqGWYlZN/zZ4pGMICCAcZoYsX3JA54nYp8r5EThw5K+m2q3wszkx4Th746JstspB0H4Q==", + "dev": true, + "requires": { + "async": "2.4.0" + }, + "dependencies": { + "async": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/async/-/async-2.4.0.tgz", + "integrity": "sha1-SZAgDxjqW4N8LMT4wDGmmFw4VhE=", + "dev": true, + "requires": { + "lodash": "^4.14.0" + } + }, + "lodash": { + "version": "4.17.11", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", + "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "dev": true + } + } + }, "getpass": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", @@ -4693,6 +6946,15 @@ "is-glob": "^2.0.0" } }, + "global-dirs": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/global-dirs/-/global-dirs-0.1.1.tgz", + "integrity": "sha1-sxnA3UYH81PzvpzKTHL8FIxJ9EU=", + "dev": true, + "requires": { + "ini": "^1.3.4" + } + }, "globals": { "version": "9.18.0", "resolved": "https://registry.npmjs.org/globals/-/globals-9.18.0.tgz", @@ -5776,6 +8038,12 @@ "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", "dev": true }, + "ini": { + "version": "1.3.5", + "resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz", + "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==", + "dev": true + }, "inputmask": { "version": "3.3.11", "resolved": "https://registry.npmjs.org/inputmask/-/inputmask-3.3.11.tgz", @@ -5957,6 +8225,16 @@ "is-extglob": "^1.0.0" } }, + "is-installed-globally": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/is-installed-globally/-/is-installed-globally-0.1.0.tgz", + "integrity": "sha1-Df2Y9akRFxbdU13aZJL2e/PSWoA=", + "dev": true, + "requires": { + "global-dirs": "^0.1.0", + "is-path-inside": "^1.0.0" + } + }, "is-number": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", @@ -5966,6 +8244,35 @@ "kind-of": "^3.0.2" } }, +<<<<<<< HEAD +======= + "is-odd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-odd/-/is-odd-2.0.0.tgz", + "integrity": "sha512-OTiixgpZAT1M4NHgS5IguFp/Vz2VI3U7Goh4/HA1adtwyLtSBrxYlcSYkhpAE07s4fKEcjrFxyvtQBND4vFQyQ==", + "dev": true, + "requires": { + "is-number": "^4.0.0" + }, + "dependencies": { + "is-number": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-4.0.0.tgz", + "integrity": "sha512-rSklcAIlf1OmFdyAqbnWTLVelsQ58uvZ66S/ZyawjWqIviTWCjg2PzVGw8WUA+nNuPTqb4wgA+NszrJ+08LlgQ==", + "dev": true + } + } + }, + "is-path-inside": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-1.0.1.tgz", + "integrity": "sha1-jvW33lBDej/cprToZe96pVy0gDY=", + "dev": true, + "requires": { + "path-is-inside": "^1.0.1" + } + }, +>>>>>>> feature/2771 "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -6000,6 +8307,12 @@ "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", "dev": true }, + "is-promise": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.1.0.tgz", + "integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=", + "dev": true + }, "is-regex": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", @@ -7181,6 +9494,12 @@ "resolved": "https://registry.npmjs.org/js-base64/-/js-base64-2.4.9.tgz", "integrity": "sha512-xcinL3AuDJk7VSzsHgb9DvvIXayBbadtMZ4HFPx8rUszbW1MuNMlwYVC4zzCZ6e1sqZpnNS5ZFYOhXqA39T7LQ==" }, + "js-levenshtein": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.4.tgz", + "integrity": "sha512-PxfGzSs0ztShKrUYPIn5r0MtyAhYcCwmndozzpz8YObbPnD1jFxzlBGbRnX2mIu6Z13xN6+PTu05TQFnZFlzow==", + "dev": true + }, "js-tokens": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", @@ -7283,6 +9602,15 @@ "resolved": "http://registry.npmjs.org/json5/-/json5-0.5.1.tgz", "integrity": "sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE=" }, + "jsonfile": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-3.0.1.tgz", + "integrity": "sha1-pezG9l9T9mLEQVx2daAzHQmS7GY=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.6" + } + }, "jsprim": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.1.tgz", @@ -7316,6 +9644,12 @@ "integrity": "sha512-77XF9iTllATmG9lSlIv0qdQ2BQ/h9t0bJllHlbvsQ0zUWfU7Yi0S8L5JXzPZgkefIiajLmBJJ4BsMJmqcf7oxQ==", "dev": true }, + "lazy-ass": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/lazy-ass/-/lazy-ass-1.6.0.tgz", + "integrity": "sha1-eZllXoZGwX8In90YfRUNMyTVRRM=", + "dev": true + }, "lazy-cache": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/lazy-cache/-/lazy-cache-1.0.4.tgz", @@ -7328,66 +9662,301 @@ "integrity": "sha1-GyXWPHcqTCDwpe0KnXf0hLbhaSA=", "dev": true, "requires": { - "readable-stream": "~1.0.2" + "readable-stream": "~1.0.2" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "readable-stream": { + "version": "1.0.34", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", + "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "dev": true, + "requires": { + "core-util-is": "~1.0.0", + "inherits": "~2.0.1", + "isarray": "0.0.1", + "string_decoder": "~0.10.x" + } + }, + "string_decoder": { + "version": "0.10.31", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", + "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "dev": true + } + } + }, + "lcid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", + "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", + "dev": true, + "requires": { + "invert-kv": "^1.0.0" + } + }, + "left-pad": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz", + "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==", + "dev": true + }, + "leven": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", + "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", + "dev": true + }, + "levn": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", + "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "dev": true, + "requires": { + "prelude-ls": "~1.1.2", + "type-check": "~0.3.2" + } + }, + "listr": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/listr/-/listr-0.12.0.tgz", + "integrity": "sha1-a84sD1YD+klYDqF81qAMwOX6RRo=", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "cli-truncate": "^0.2.1", + "figures": "^1.7.0", + "indent-string": "^2.1.0", + "is-promise": "^2.1.0", + "is-stream": "^1.1.0", + "listr-silent-renderer": "^1.1.1", + "listr-update-renderer": "^0.2.0", + "listr-verbose-renderer": "^0.4.0", + "log-symbols": "^1.0.2", + "log-update": "^1.0.2", + "ora": "^0.2.3", + "p-map": "^1.1.1", + "rxjs": "^5.0.0-beta.11", + "stream-to-observable": "^0.1.0", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "log-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", + "dev": true, + "requires": { + "chalk": "^1.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "listr-silent-renderer": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz", + "integrity": "sha1-kktaN1cVN3C/Go4/v3S4u/P5JC4=", + "dev": true + }, + "listr-update-renderer": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/listr-update-renderer/-/listr-update-renderer-0.2.0.tgz", + "integrity": "sha1-yoDhd5tOcCZoB+ju0a1qvjmFUPk=", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "cli-truncate": "^0.2.1", + "elegant-spinner": "^1.0.1", + "figures": "^1.7.0", + "indent-string": "^3.0.0", + "log-symbols": "^1.0.2", + "log-update": "^1.0.2", + "strip-ansi": "^3.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "indent-string": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-3.2.0.tgz", + "integrity": "sha1-Sl/W0nzDMvN+VBmlBNu4NxBckok=", + "dev": true + }, + "log-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-1.0.2.tgz", + "integrity": "sha1-N2/3tY6jCGoPCfrMdGF+ylAeGhg=", + "dev": true, + "requires": { + "chalk": "^1.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, + "listr-verbose-renderer": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/listr-verbose-renderer/-/listr-verbose-renderer-0.4.1.tgz", + "integrity": "sha1-ggb0z21S3cWCfl/RSYng6WWTOjU=", + "dev": true, + "requires": { + "chalk": "^1.1.3", + "cli-cursor": "^1.0.2", + "date-fns": "^1.27.2", + "figures": "^1.7.0" }, "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", "dev": true }, - "readable-stream": { - "version": "1.0.34", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.0.34.tgz", - "integrity": "sha1-Elgg40vIQtLyqq+v5MKRbuMsFXw=", + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" } }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", "dev": true } } }, - "lcid": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lcid/-/lcid-1.0.0.tgz", - "integrity": "sha1-MIrMr6C8SDo4Z7S28rlQYlHRuDU=", - "dev": true, - "requires": { - "invert-kv": "^1.0.0" - } - }, - "left-pad": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz", - "integrity": "sha512-XI5MPzVNApjAyhQzphX8BkmKsKUxD4LdyK24iZeQGinBN9yTQT3bFlCBy/aVx2HrNcqQGsdot8ghrjyrvMCoEA==", - "dev": true - }, - "leven": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/leven/-/leven-2.1.0.tgz", - "integrity": "sha1-wuep93IJTe6dNCAq6KzORoeHVYA=", - "dev": true - }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", - "dev": true, - "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" - } - }, "livereload-js": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/livereload-js/-/livereload-js-2.3.0.tgz", @@ -7521,6 +10090,12 @@ "integrity": "sha512-eWw5r+PYICtEBgrBE5hhlT6aAa75f411bgDz/ZL2KZqYV03USvucsxcHUIlGTDTECs1eunpI7HOV7U+WLDvNdQ==", "dev": true }, + "lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha1-DdOXEhPHxW34gJd9UEyI+0cal6w=", + "dev": true + }, "lodash.remove": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.remove/-/lodash.remove-4.7.0.tgz", @@ -7543,6 +10118,64 @@ "resolved": "https://registry.npmjs.org/lodash.uniq/-/lodash.uniq-4.5.0.tgz", "integrity": "sha1-0CJTc662Uq3BvILklFM5qEJ1R3M=" }, + "log-symbols": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", + "integrity": "sha512-VeIAFslyIerEJLXHziedo2basKbMKtTw3vfn5IzG0XTjhAVEJyNHnL2p7vc+wBDSdQuUpNw3M2u6xb9QsAY5Eg==", + "dev": true, + "requires": { + "chalk": "^2.0.1" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.1.tgz", + "integrity": "sha512-ObN6h1v2fTJSmUXoS3nMQ92LbDK9be4TV+6G+omQlGJFdcUX5heKi1LZ1YnRMIgwTLEj3E24bT6tYni50rlCfQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "log-update": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/log-update/-/log-update-1.0.2.tgz", + "integrity": "sha1-GZKfZMQJPS0ucHWh2tivWcKWuNE=", + "dev": true, + "requires": { + "ansi-escapes": "^1.0.0", + "cli-cursor": "^1.0.2" + }, + "dependencies": { + "ansi-escapes": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-1.4.0.tgz", + "integrity": "sha1-06ioOzGapneTZisT52HHkRQiMG4=", + "dev": true + } + } + }, "longest": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/longest/-/longest-1.0.1.tgz", @@ -7601,6 +10234,12 @@ "tmpl": "1.0.x" } }, + "mamacro": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/mamacro/-/mamacro-0.0.3.tgz", + "integrity": "sha512-qMEwh+UujcQ+kbz3T6V+wAmO2U8veoq2w+3wY8MquqwVA3jChfwY+Tk52GZKDfACEPjuZ7r2oJLejwpt8jtwTA==", + "dev": true + }, "map-cache": { "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", @@ -8084,6 +10723,15 @@ "which": "^1.3.0" } }, + "node-releases": { + "version": "1.0.0-alpha.14", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.0.0-alpha.14.tgz", + "integrity": "sha512-G8nnF9cP9QPP/jUmYWw/uUUhumHmkm+X/EarCugYFjYm2uXRMFeOD6CVT3RLdoyCvDUNy51nirGfUItKWs/S1g==", + "dev": true, + "requires": { + "semver": "^5.3.0" + } + }, "node-sass": { "version": "4.9.4", "resolved": "https://registry.npmjs.org/node-sass/-/node-sass-4.9.4.tgz", @@ -8357,6 +11005,12 @@ "wrappy": "1" } }, + "onetime": { + "version": "1.1.0", + "resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz", + "integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k=", + "dev": true + }, "optimist": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", @@ -8389,6 +11043,69 @@ } } }, + "ora": { + "version": "0.2.3", + "resolved": "http://registry.npmjs.org/ora/-/ora-0.2.3.tgz", + "integrity": "sha1-N1J9Igrc1Tw5tzVx11QVbV22V6Q=", + "dev": true, + "requires": { + "chalk": "^1.1.1", + "cli-cursor": "^1.0.2", + "cli-spinners": "^0.1.2", + "object-assign": "^4.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-2.1.1.tgz", + "integrity": "sha1-w7M6te42DYbg5ijwRorn7yfWVN8=", + "dev": true + }, + "ansi-styles": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-2.2.1.tgz", + "integrity": "sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4=", + "dev": true + }, + "chalk": { + "version": "1.1.3", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", + "dev": true, + "requires": { + "ansi-styles": "^2.2.1", + "escape-string-regexp": "^1.0.2", + "has-ansi": "^2.0.0", + "strip-ansi": "^3.0.0", + "supports-color": "^2.0.0" + } + }, + "has-ansi": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz", + "integrity": "sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "strip-ansi": { + "version": "3.0.1", + "resolved": "http://registry.npmjs.org/strip-ansi/-/strip-ansi-3.0.1.tgz", + "integrity": "sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8=", + "dev": true, + "requires": { + "ansi-regex": "^2.0.0" + } + }, + "supports-color": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-2.0.0.tgz", + "integrity": "sha1-U10EXOa2Nj+kARcIRimZXp3zJMc=", + "dev": true + } + } + }, "os-browserify": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/os-browserify/-/os-browserify-0.3.0.tgz", @@ -8463,6 +11180,12 @@ "p-limit": "^1.1.0" } }, + "p-map": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz", + "integrity": "sha512-r6zKACMNhjPJMTl8KcFH4li//gkrXWfbD6feV8l6doRHlzljFWGJ2AP6iKaCJXyZmAUMOPtvbW7EXkbWO/pLEA==", + "dev": true + }, "p-try": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", @@ -8564,6 +11287,12 @@ "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", "dev": true }, + "path-is-inside": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/path-is-inside/-/path-is-inside-1.0.2.tgz", + "integrity": "sha1-NlQX3t5EQw0cEa9hAn+s8HS9/FM=", + "dev": true + }, "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", @@ -8598,6 +11327,12 @@ "sha.js": "^2.4.8" } }, + "pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA=", + "dev": true + }, "performance-now": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", @@ -9470,6 +12205,23 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, +<<<<<<< HEAD +======= + "progress": { + "version": "1.1.8", + "resolved": "http://registry.npmjs.org/progress/-/progress-1.1.8.tgz", + "integrity": "sha1-4mDHj2Fhzdmw5WzD4Khd4Xx6V74=", + "dev": true + }, + "promise": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", + "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", + "requires": { + "asap": "~2.0.3" + } + }, +>>>>>>> feature/2771 "promise-inflight": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/promise-inflight/-/promise-inflight-1.0.1.tgz", @@ -9602,6 +12354,12 @@ "integrity": "sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM=", "dev": true }, + "ramda": { + "version": "0.24.1", + "resolved": "https://registry.npmjs.org/ramda/-/ramda-0.24.1.tgz", + "integrity": "sha1-w7d1UZfzW43DUCIoJixMkd22uFc=", + "dev": true + }, "randomatic": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-3.1.0.tgz", @@ -10232,6 +12990,23 @@ "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==" }, + "regenerate-unicode-properties": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/regenerate-unicode-properties/-/regenerate-unicode-properties-7.0.0.tgz", + "integrity": "sha512-s5NGghCE4itSlUS+0WUj88G6cfMVMmH8boTPNvABf8od+2dhT9WDlWu8n01raQAJZMOK8Ch6jSexaRO7swd6aw==", + "dev": true, + "requires": { + "regenerate": "^1.4.0" + }, + "dependencies": { + "regenerate": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/regenerate/-/regenerate-1.4.0.tgz", + "integrity": "sha512-1G6jJVDWrt0rK99kBjvEtziZNCICAuvIPkSiUFIQxVP06RCVpq3dmDo2oi6ABpYaDYaTRr67BEhL8r1wgEZZKg==", + "dev": true + } + } + }, "regenerator-runtime": { "version": "0.12.1", "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz", @@ -10372,6 +13147,15 @@ } } }, + "request-progress": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-0.3.1.tgz", + "integrity": "sha1-ByHBBdipasayzossia4tXs/Pazo=", + "dev": true, + "requires": { + "throttleit": "~0.0.2" + } + }, "request-promise-core": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/request-promise-core/-/request-promise-core-1.1.1.tgz", @@ -10454,6 +13238,16 @@ "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", "dev": true }, + "restore-cursor": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-1.0.1.tgz", + "integrity": "sha1-NGYfRohjJ/7SmRR5FSJS35LapUE=", + "dev": true, + "requires": { + "exit-hook": "^1.0.0", + "onetime": "^1.0.0" + } + }, "ret": { "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", @@ -10503,6 +13297,23 @@ "aproba": "^1.1.1" } }, + "rxjs": { + "version": "5.5.12", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.12.tgz", + "integrity": "sha512-xx2itnL5sBbqeeiVgNPVuQQ1nC8Jp2WfNJhXWHmElW9YmrpS9UVnNzhP3EH3HFqexO5Tlp8GhYY+WEcqcVMvGw==", + "dev": true, + "requires": { + "symbol-observable": "1.0.1" + }, + "dependencies": { + "symbol-observable": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/symbol-observable/-/symbol-observable-1.0.1.tgz", + "integrity": "sha1-g0D8RwLDEi310iKI+IKD9RPT/dQ=", + "dev": true + } + } + }, "safe-buffer": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", @@ -11119,6 +13930,12 @@ "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", "dev": true }, + "slice-ansi": { + "version": "0.0.4", + "resolved": "http://registry.npmjs.org/slice-ansi/-/slice-ansi-0.0.4.tgz", + "integrity": "sha1-7b+JA/ZvfOL46v1s7tZeJkyDGzU=", + "dev": true + }, "snapdragon": { "version": "0.8.2", "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", @@ -11432,6 +14249,12 @@ "integrity": "sha1-1cdSgl5TZ+eG944Y5EXqIjoVWVI=", "dev": true }, + "stream-to-observable": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/stream-to-observable/-/stream-to-observable-0.1.0.tgz", + "integrity": "sha1-Rb8dny19wJvtgfHDB8Qw5ouEz/4=", + "dev": true + }, "strict-uri-encode": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz", @@ -11668,6 +14491,12 @@ "integrity": "sha1-iQN8vJLFarGJJua6TLsgDhVnKmo=", "dev": true }, + "throttleit": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/throttleit/-/throttleit-0.0.2.tgz", + "integrity": "sha1-z+34jmDADdlpe2H90qg0OptoDq8=", + "dev": true + }, "through2": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/through2/-/through2-2.0.3.tgz", @@ -11718,6 +14547,15 @@ } } }, + "tmp": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.31.tgz", + "integrity": "sha1-jzirlDjhcxXl29izZX6L+yd65Kc=", + "dev": true, + "requires": { + "os-tmpdir": "~1.0.1" + } + }, "tmpl": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.4.tgz", @@ -11832,6 +14670,12 @@ "glob": "^7.1.2" } }, + "tslib": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", + "integrity": "sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ==", + "dev": true + }, "tty-browserify": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/tty-browserify/-/tty-browserify-0.0.0.tgz", @@ -11981,6 +14825,34 @@ "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=", "dev": true }, + "unicode-canonical-property-names-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", + "integrity": "sha512-jDrNnXWHd4oHiTZnx/ZG7gtUTVp+gCcTTKr8L0HjlwphROEW3+Him+IpvC+xcJEFegapiMZyZe02CyuOnRmbnQ==", + "dev": true + }, + "unicode-match-property-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-match-property-ecmascript/-/unicode-match-property-ecmascript-1.0.4.tgz", + "integrity": "sha512-L4Qoh15vTfntsn4P1zqnHulG0LdXgjSO035fEpdtp6YxXhMT51Q6vgM5lYdG/5X3MjS+k/Y9Xw4SFCY9IkR0rg==", + "dev": true, + "requires": { + "unicode-canonical-property-names-ecmascript": "^1.0.4", + "unicode-property-aliases-ecmascript": "^1.0.4" + } + }, + "unicode-match-property-value-ecmascript": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/unicode-match-property-value-ecmascript/-/unicode-match-property-value-ecmascript-1.0.2.tgz", + "integrity": "sha512-Rx7yODZC1L/T8XKo/2kNzVAQaRE88AaMvI1EF/Xnj3GW2wzN6fop9DDWuFAKUVFH7vozkz26DzP0qyWLKLIVPQ==", + "dev": true + }, + "unicode-property-aliases-ecmascript": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/unicode-property-aliases-ecmascript/-/unicode-property-aliases-ecmascript-1.0.4.tgz", + "integrity": "sha512-2WSLa6OdYd2ng8oqiGIWnJqyFArvhn+5vgx5GTxMbUYjCYKUcuKS62YLFF0R/BDGlB1yzXjQOLtPAfHsgirEpg==", + "dev": true + }, "union-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", @@ -12044,6 +14916,12 @@ "imurmurhash": "^0.1.4" } }, + "universalify": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", + "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", + "dev": true + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -13263,6 +16141,16 @@ } } }, + "yauzl": { + "version": "2.8.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-2.8.0.tgz", + "integrity": "sha1-eUUK/yKyqcWkHvVOAtuQfM+/nuI=", + "dev": true, + "requires": { + "buffer-crc32": "~0.2.3", + "fd-slicer": "~1.0.1" + } + }, "zip-stream": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/zip-stream/-/zip-stream-0.5.2.tgz", diff --git a/package.json b/package.json index 5206ef0fa..dc17b98cb 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "package": "npm run build && grunt make", "test": "npm run test:watch", "test:watch": "jest --watch", - "test:once": "jest" + "test:once": "jest", + "test:e2e": "cypress open" }, "browserslist": [ "last 2 versions", @@ -55,6 +56,7 @@ "devDependencies": { "@caldera-labs/api-client": "^0.2.2", "@caldera-labs/state": "^0.7.1", + "@cypress/webpack-preprocessor": "^3.0.0", "@wordpress/babel-preset-default": "^1.3.0", "@wordpress/browserslist-config": "^2.2.2", "@wordpress/data": "^1.2.1", @@ -71,6 +73,7 @@ "classnames": "^2.2.6", "copy-webpack-plugin": "^4.5.2", "cross-env": "^5.2.0", + "cypress": "^3.1.0", "extract-text-webpack-plugin": "^3.0.2", "file-loader": "^0.9.0", "friendly-errors-webpack-plugin": "^1.1.2", diff --git a/phpunit-integration.xml.dist b/phpunit-integration.xml.dist new file mode 100755 index 000000000..fe1f3000b --- /dev/null +++ b/phpunit-integration.xml.dist @@ -0,0 +1,14 @@ + + + + ./tests/ + + + \ No newline at end of file diff --git a/phpunit-unit.xml.dist b/phpunit-unit.xml.dist new file mode 100755 index 000000000..dc5992afc --- /dev/null +++ b/phpunit-unit.xml.dist @@ -0,0 +1,15 @@ + + + + ./tests/Unit + + + + diff --git a/tests/Unit/SampleTest.php b/tests/Unit/SampleTest.php new file mode 100644 index 000000000..589a02f51 --- /dev/null +++ b/tests/Unit/SampleTest.php @@ -0,0 +1,25 @@ +assertNotEquals($excepted, $actual); + } + +} \ No newline at end of file diff --git a/tests/Unit/TestCase.php b/tests/Unit/TestCase.php new file mode 100644 index 000000000..9ea85893c --- /dev/null +++ b/tests/Unit/TestCase.php @@ -0,0 +1,56 @@ +setup_common_wp_stubs(); + } + + /** + * Cleans up the test environment after each test. + */ + protected function tearDown() + { + Monkey\tearDown(); + parent::tearDown(); + } + + //phpcs:disable + /** + * Set up the stubs for the common WordPress escaping and internationalization functions. + */ + protected function setup_common_wp_stubs() + { + // Common internationalization functions. + Monkey\Functions\stubs(array( + '__', + 'esc_html__', + 'esc_html_x', + 'esc_attr_x', + )); + } + //phpcs:enable +} diff --git a/tests/Util/CreatePages.php b/tests/Util/CreatePages.php new file mode 100644 index 000000000..3dd16a1cb --- /dev/null +++ b/tests/Util/CreatePages.php @@ -0,0 +1,78 @@ +filePath = $filePath; + } + + + /** + * Create pages for test forms + * + * @return int + */ + public function import() + { + + $data = json_decode(file_get_contents($this->filePath), true); + $testForms = $data['forms']; + + $created = []; + $contentPattern = '[caldera_form id="%s"]'; + + foreach ($testForms as $testForm) { + $formId = $testForm['formId']; + $pageSlug = $testForm['pageSlug']; + $page = get_page_by_path($pageSlug, OBJECT); + if( isset( $page ) ){ + continue; + } + $form = \Caldera_Forms_Forms::get_form($formId); + if( isset( $form[ 'name' ]) ){ + + if ( ! isset($page) ){ + $created_page = wp_insert_post( + [ + 'post_name' => $pageSlug, + 'post_type' => 'page', + 'post_title' => $form[ 'name' ], + 'post_content' => sprintf($contentPattern,$formId), + 'post_status' => 'publish' + ] + + ); + if( ! is_wp_error( $page ) ){ + $created[] = $created_page; + } + } + } + + } + + return count($created); + + } + + +} \ No newline at end of file diff --git a/tests/Util/ImportForms.php b/tests/Util/ImportForms.php new file mode 100644 index 000000000..9350fd000 --- /dev/null +++ b/tests/Util/ImportForms.php @@ -0,0 +1,59 @@ +dirPath = $dirPath; + } + + /** + * Import test forms + * + * @return int + */ + public function import() + { + $formFiles = scandir($this->dirPath); + $imported = []; + $existingForms = \Caldera_Forms_Forms::get_forms(false, false); + if (!empty($existingForms)) { + $existingForms = array_keys($existingForms); + } + if( ! is_array( $existingForms ) ){ + $existingForms = []; + } + foreach ($formFiles as $file) { + $fullPath = $this->dirPath . '/' . $file; + $info = pathinfo($fullPath); + if ('json' === $info['extension']) { + $importFormId = str_replace('.json', '', $file); + if (!in_array($importFormId, $existingForms)) { + $imported[] = \Caldera_Forms_Forms::import_form( + json_decode(file_get_contents($fullPath), true), + true + ); + } + } + } + + return count($imported); + + } + + +} \ No newline at end of file diff --git a/tests/Util/Traits/SharedFactories.php b/tests/Util/Traits/SharedFactories.php new file mode 100644 index 000000000..71917989f --- /dev/null +++ b/tests/Util/Traits/SharedFactories.php @@ -0,0 +1,10 @@ +import() ) ); + } + WP_CLI::add_command( 'cf import-test-forms', 'calderaFormsImportTestFormsCommand' ); + + /** + * Create pages command + * + * @param $args + */ + function calderaFormsCreatePagesCommand( $args ) { + $filePath = file_exists($args[0]) ? $args[0]: dirname(__FILE__, 2) . '/cypress/tests.json'; + $importer = new \calderawp\calderaforms\Tests\Util\CreatePages($filePath); + WP_CLI::success( sprintf( 'Pages added: %d', $importer->import() ) ); + } + WP_CLI::add_command( 'cf create-test-pages', 'calderaFormsCreatePagesCommand' ); +} diff --git a/vendor/antecedent/patchwork/LICENSE b/vendor/antecedent/patchwork/LICENSE new file mode 100644 index 000000000..d1ccb7a56 --- /dev/null +++ b/vendor/antecedent/patchwork/LICENSE @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2010-2018 Ignas Rudaitis + +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/antecedent/patchwork/Patchwork.php b/vendor/antecedent/patchwork/Patchwork.php new file mode 100644 index 000000000..163ab903d --- /dev/null +++ b/vendor/antecedent/patchwork/Patchwork.php @@ -0,0 +1,149 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork; + +if (function_exists('Patchwork\replace')) { + return; +} + +require_once __DIR__ . '/src/Exceptions.php'; +require_once __DIR__ . '/src/CallRerouting.php'; +require_once __DIR__ . '/src/CodeManipulation.php'; +require_once __DIR__ . '/src/Utils.php'; +require_once __DIR__ . '/src/Stack.php'; +require_once __DIR__ . '/src/Config.php'; + +function redefine($subject, callable $content) +{ + $handle = null; + foreach (array_slice(func_get_args(), 1) as $content) { + $handle = CallRerouting\connect($subject, $content, $handle); + } + $handle->silence(); + return $handle; +} + +function relay(array $args = null) +{ + return CallRerouting\relay($args); +} + +function fallBack() +{ + throw new Exceptions\NoResult; +} + +function restore(CallRerouting\Handle $handle) +{ + $handle->expire(); +} + +function restoreAll() +{ + CallRerouting\disconnectAll(); +} + +function silence(CallRerouting\Handle $handle) +{ + $handle->silence(); +} + +function assertEventuallyDefined(CallRerouting\Handle $handle) +{ + $handle->unsilence(); +} + +function getClass() +{ + return Stack\top('class'); +} + +function getCalledClass() +{ + return Stack\topCalledClass(); +} + +function getFunction() +{ + return Stack\top('function'); +} + +function getMethod() +{ + return getClass() . '::' . getFunction(); +} + +function configure() +{ + Config\locate(); +} + +function hasMissed($callable) +{ + return Utils\callableWasMissed($callable); +} + +function always($value) +{ + return function() use ($value) { + return $value; + }; +} + +Utils\alias('Patchwork', [ + 'redefine' => ['replace', 'replaceLater'], + 'relay' => 'callOriginal', + 'fallBack' => 'pass', + 'restore' => 'undo', + 'restoreAll' => 'undoAll', +]); + +configure(); + +Utils\markMissedCallables(); + +if (Utils\runningOnHHVM()) { + # no preprocessor needed on HHVM; + # just let Patchwork become a wrapper for fb_intercept() + spl_autoload_register('Patchwork\CallRerouting\deployQueue'); + return; +} + +CodeManipulation\Stream::wrap(); + +CodeManipulation\register([ + CodeManipulation\Actions\CodeManipulation\propagateThroughEval(), + CodeManipulation\Actions\CallRerouting\injectCallInterceptionCode(), + CodeManipulation\Actions\CallRerouting\injectQueueDeploymentCode(), + CodeManipulation\Actions\RedefinitionOfInternals\spliceNamedFunctionCalls(), + CodeManipulation\Actions\RedefinitionOfInternals\spliceDynamicCalls(), + CodeManipulation\Actions\RedefinitionOfNew\spliceAllInstantiations, + CodeManipulation\Actions\RedefinitionOfNew\publicizeConstructors, + CodeManipulation\Actions\ConflictPrevention\preventImportingOtherCopiesOfPatchwork(), +]); + +CodeManipulation\onImport([ + CodeManipulation\Actions\CallRerouting\markPreprocessedFiles(), +]); + +Utils\clearOpcodeCaches(); + +register_shutdown_function('Patchwork\Utils\clearOpcodeCaches'); + +CallRerouting\createStubsForInternals(); +CallRerouting\connectDefaultInternals(); + +require __DIR__ . '/src/Redefinitions/LanguageConstructs.php'; + +CodeManipulation\register([ + CodeManipulation\Actions\RedefinitionOfLanguageConstructs\spliceAllConfiguredLanguageConstructs(), +]); + +if (Utils\wasRunAsConsoleApp()) { + require __DIR__ . '/src/Console.php'; +} diff --git a/vendor/antecedent/patchwork/composer.json b/vendor/antecedent/patchwork/composer.json new file mode 100644 index 000000000..702eae85c --- /dev/null +++ b/vendor/antecedent/patchwork/composer.json @@ -0,0 +1,17 @@ +{ + "name": "antecedent/patchwork", + "homepage": "http://patchwork2.org/", + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "keywords": ["testing", "redefinition", "runkit", "monkeypatching", "interception", "aop", "aspect"], + "license": "MIT", + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "minimum-stability": "stable", + "require": { + "php": ">=5.4.0" + } +} diff --git a/vendor/antecedent/patchwork/src/CallRerouting.php b/vendor/antecedent/patchwork/src/CallRerouting.php new file mode 100644 index 000000000..ae5bad309 --- /dev/null +++ b/vendor/antecedent/patchwork/src/CallRerouting.php @@ -0,0 +1,605 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CallRerouting; + +require __DIR__ . '/CallRerouting/Handle.php'; +require __DIR__ . '/CallRerouting/Decorator.php'; + +use Patchwork\Utils; +use Patchwork\Stack; +use Patchwork\Config; +use Patchwork\Exceptions; +use Patchwork\CodeManipulation; +use Patchwork\CodeManipulation\Actions\RedefinitionOfLanguageConstructs; +use Patchwork\CodeManipulation\Actions\RedefinitionOfNew; + +const INTERNAL_REDEFINITION_NAMESPACE = 'Patchwork\Redefinitions'; +const EVALUATED_CODE_FILE_NAME_SUFFIX = '/\(\d+\) : eval\(\)\'d code$/'; +const INSTANTIATOR_NAMESPACE = 'Patchwork\Instantiators'; +const INSTANTIATOR_DEFAULT_ARGUMENT = 'Patchwork\CallRerouting\INSTANTIATOR_DEFAULT_ARGUMENT'; + +const INTERNAL_STUB_CODE = ' + namespace @ns_for_redefinitions; + function @name(@signature) { + $__pwArgs = \array_slice(\debug_backtrace()[0]["args"], 1); + if (!empty($__pwNamespace) && \function_exists($__pwNamespace . "\\\\@name")) { + return \call_user_func_array($__pwNamespace . "\\\\@name", $__pwArgs); + } + @interceptor; + return \call_user_func_array("@name", $__pwArgs); + } +'; + +const INSTANTIATOR_CODE = ' + namespace @namespace; + class @instantiator { + function instantiate(@parameters) { + $__pwArgs = \debug_backtrace()[0]["args"]; + foreach ($__pwArgs as $__pwOffset => $__pwValue) { + if ($__pwValue === \Patchwork\CallRerouting\INSTANTIATOR_DEFAULT_ARGUMENT) { + unset($__pwArgs[$__pwOffset]); + } + } + switch (count($__pwArgs)) { + case 0: + return new \@class; + case 1: + return new \@class($__pwArgs[0]); + case 2: + return new \@class($__pwArgs[0], $__pwArgs[1]); + case 3: + return new \@class($__pwArgs[0], $__pwArgs[1], $__pwArgs[2]); + case 4: + return new \@class($__pwArgs[0], $__pwArgs[1], $__pwArgs[2], $__pwArgs[3]); + case 5: + return new \@class($__pwArgs[0], $__pwArgs[1], $__pwArgs[2], $__pwArgs[3], $__pwArgs[4]); + default: + $__pwReflector = new \ReflectionClass(\'@class\'); + return $__pwReflector->newInstanceArgs($__pwArgs); + } + } + } +'; + +function connect($source, callable $target, Handle $handle = null, $partOfWildcard = false) +{ + $source = translateIfLanguageConstruct($source); + $handle = $handle ?: new Handle; + list($class, $method) = Utils\interpretCallable($source); + if (constitutesWildcard($source)) { + return applyWildcard($source, $target, $handle); + } + if (Utils\isOwnName($class) || Utils\isOwnName($method)) { + return $handle; + } + validate($source, $partOfWildcard); + if (empty($class)) { + if (Utils\callableDefined($source) && (new \ReflectionFunction($method))->isInternal()) { + $stub = INTERNAL_REDEFINITION_NAMESPACE . '\\' . $source; + return connect($stub, $target, $handle, $partOfWildcard); + } + $handle = connectFunction($method, $target, $handle); + } else { + if (Utils\callableDefined($source)) { + if ($method === 'new') { + $handle = connectInstantiation($class, $target, $handle); + } elseif ((new \ReflectionMethod($class, $method))->isUserDefined()) { + $handle = connectMethod($source, $target, $handle); + } else { + throw new InternalMethodsNotSupported($source); + } + } else { + $handle = queueConnection($source, $target, $handle); + if (Utils\runningOnHHVM()) { + connectOnHHVM("$class::$method", $handle); + } + } + } + attachExistenceAssertion($handle, $source); + return $handle; +} + +function constitutesWildcard($source) +{ + $source = Utils\interpretCallable($source); + $source = Utils\callableToString($source); + return strcspn($source, '*{,}') != strlen($source); +} + +function applyWildcard($wildcard, callable $target, Handle $handle = null) +{ + $handle = $handle ?: new Handle; + list($class, $method, $instance) = Utils\interpretCallable($wildcard); + if (!empty($instance)) { + foreach (Utils\matchWildcard($method, get_class_methods($instance)) as $item) { + if (!$handle->hasTag($item)) { + connect([$instance, $item], $target, $handle); + $handle->tag($item); + } + } + return $handle; + } + + $callables = Utils\matchWildcard($wildcard, Utils\getRedefinableCallables()); + foreach ($callables as $callable) { + if (!inPreprocessedFile($callable) || $handle->hasTag($callable)) { + continue; + } + if (function_exists($callable)) { + # Restore lower/upper case distinction + $callable = (new \ReflectionFunction($callable))->getName(); + } + connect($callable, $target, $handle, true); + $handle->tag($callable); + } + if (!class_exists($class, false)) { + queueConnection($wildcard, $target, $handle); + } + return $handle; +} + +function attachExistenceAssertion(Handle $handle, $function) +{ + $handle->addExpirationHandler(function() use ($function) { + if (!Utils\callableDefined($function)) { + # Not using exceptions because this might happen during PHP shutdown + $message = '%s() was never defined during the lifetime of its redefinition'; + trigger_error(sprintf($message, Utils\callableToString($function)), E_USER_WARNING); + } + }); +} + +function validate($function, $partOfWildcard = false) +{ + list($class, $method) = Utils\interpretCallable($function); + if (!Utils\callableDefined($function) || $method === 'new') { + return; + } + $reflection = Utils\reflectCallable($function); + $name = Utils\callableToString($function); + if ($reflection->isInternal() && !in_array($name, Config\getRedefinableInternals())) { + throw new Exceptions\NotUserDefined($function); + } + if (Utils\runningOnHHVM()) { + if ($reflection->isInternal()) { + throw new Exceptions\InternalsNotSupportedOnHHVM($function); + } + return; + } + if (!$reflection->isInternal() && !inPreprocessedFile($function) && !$partOfWildcard) { + throw new Exceptions\DefinedTooEarly($function); + } +} + +function inPreprocessedFile($callable) +{ + if (Utils\runningOnHHVM()) { + return true; + } + if (Utils\isOwnName(Utils\callableToString($callable))) { + return false; + } + $file = Utils\reflectCallable($callable)->getFileName(); + $evaluated = preg_match(EVALUATED_CODE_FILE_NAME_SUFFIX, $file); + return $evaluated || !empty(State::$preprocessedFiles[$file]); +} + +function connectFunction($function, callable $target, Handle $handle = null) +{ + $handle = $handle ?: new Handle; + $routes = &State::$routes[null][$function]; + $offset = Utils\append($routes, [$target, $handle]); + $handle->addReference($routes[$offset]); + if (Utils\runningOnHHVM()) { + connectOnHHVM($function, $handle); + } + return $handle; +} + +function queueConnection($source, callable $target, Handle $handle = null) +{ + $handle = $handle ?: new Handle; + $offset = Utils\append(State::$queue, [$source, $target, $handle]); + $handle->addReference(State::$queue[$offset]); + return $handle; +} + +function deployQueue() +{ + foreach (State::$queue as $offset => $item) { + if (empty($item)) { + unset(State::$queue[$offset]); + continue; + } + list($source, $target, $handle) = $item; + if (Utils\callableDefined($source) || constitutesWildcard($source)) { + connect($source, $target, $handle); + unset(State::$queue[$offset]); + } + } +} + +function connectMethod($function, callable $target, Handle $handle = null) +{ + $handle = $handle ?: new Handle; + list($class, $method, $instance) = Utils\interpretCallable($function); + $target = new Decorator($target); + $target->superclass = $class; + $target->method = $method; + $target->instance = $instance; + $reflection = Utils\reflectCallable($function); + $declaringClass = $reflection->getDeclaringClass(); + $class = $declaringClass->getName(); + if (!Utils\runningOnHHVM()) { + $aliases = $declaringClass->getTraitAliases(); + if (isset($aliases[$method])) { + list($trait, $method) = explode('::', $aliases[$method]); + } + } + $routes = &State::$routes[$class][$method]; + $offset = Utils\append($routes, [$target, $handle]); + $handle->addReference($routes[$offset]); + if (Utils\runningOnHHVM()) { + connectOnHHVM("$class::$method", $handle); + } + return $handle; +} + +function connectInstantiation($class, callable $target, Handle $handle = null) +{ + if (!Config\isNewKeywordRedefinable()) { + throw new Exceptions\NewKeywordNotRedefinable; + } + $handle = $handle ?: new Handle; + $class = strtr($class, ['\\' => '__']); + $routes = &State::$routes["Patchwork\\Instantiators\\$class"]['instantiate']; + $offset = Utils\append($routes, [$target, $handle]); + $handle->addReference($routes[$offset]); + return $handle; +} + +function disconnectAll() +{ + foreach (State::$routes as $class => $routesByClass) { + foreach ($routesByClass as $method => $routes) { + foreach ($routes as $route) { + list($callback, $handle) = $route; + if ($handle !== null) { + $handle->expire(); + } + } + } + } + State::$routes = []; + connectDefaultInternals(); +} + +function dispatchTo(callable $target) +{ + return call_user_func_array($target, Stack\top('args')); +} + +function dispatch($class, $calledClass, $method, $frame, &$result, array $args = null) +{ + $isInternalStub = strpos($method, INTERNAL_REDEFINITION_NAMESPACE) === 0; + $isLanguageConstructStub = strpos($method, RedefinitionOfLanguageConstructs\LANGUAGE_CONSTRUCT_PREFIX) === 0; + $isInstantiator = strpos($method, INSTANTIATOR_NAMESPACE) === 0; + if ($isInternalStub && !$isLanguageConstructStub && $args === null) { + # Mind the namespace-of-origin argument + $trace = debug_backtrace(); + $args = array_reverse($trace)[$frame - 1]['args']; + array_shift($args); + } + if ($isInstantiator) { + $trace = debug_backtrace(); + $args = $args ?: array_reverse($trace)[$frame - 1]['args']; + foreach ($args as $offset => $value) { + if ($value === INSTANTIATOR_DEFAULT_ARGUMENT) { + unset($args[$offset]); + } + } + } + $success = false; + Stack\pushFor($frame, $calledClass, function() use ($class, $method, &$result, &$success) { + foreach (getRoutesFor($class, $method) as $offset => $route) { + if (empty($route)) { + unset(State::$routes[$class][$method][$offset]); + continue; + } + State::$routeStack[] = [$class, $method, $offset]; + try { + $result = dispatchTo(reset($route)); + $success = true; + } catch (Exceptions\NoResult $e) { + array_pop(State::$routeStack); + continue; + } + array_pop(State::$routeStack); + if ($success) { + break; + } + } + }, $args); + return $success; +} + +function relay(array $args = null) +{ + list($class, $method, $offset) = end(State::$routeStack); + $route = &State::$routes[$class][$method][$offset]; + $backup = $route; + $route = ['Patchwork\fallBack', new Handle]; + $top = Stack\top(); + if ($args === null) { + $args = $top['args']; + } + $isInternalStub = strpos($method, INTERNAL_REDEFINITION_NAMESPACE) === 0; + $isLanguageConstructStub = strpos($method, RedefinitionOfLanguageConstructs\LANGUAGE_CONSTRUCT_PREFIX) === 0; + if ($isInternalStub && !$isLanguageConstructStub) { + array_unshift($args, ''); + } + try { + if (isset($top['class'])) { + $reflection = new \ReflectionMethod(Stack\topCalledClass(), $top['function']); + $reflection->setAccessible(true); + $result = $reflection->invokeArgs(Stack\top('object'), $args); + } else { + $result = call_user_func_array($top['function'], $args); + } + } catch (\Exception $e) { + $exception = $e; + } + $route = $backup; + if (isset($exception)) { + throw $exception; + } + return $result; +} + +function connectOnHHVM($function, Handle $handle) +{ + fb_intercept($function, function($name, $obj, $args, $data, &$done) { + deployQueue(); + list($class, $method) = Utils\interpretCallable($name); + $calledClass = null; + if (is_string($obj)) { + $calledClass = $obj; + } elseif (is_object($obj)) { + $calledClass = get_class($obj); + } + $frame = count(debug_backtrace(false)) - 1; + $result = null; + $done = dispatch($class, $calledClass, $method, $frame, $result, $args); + return $result; + }); + $handle->addExpirationHandler(getHHVMExpirationHandler($function)); +} + +function getHHVMExpirationHandler($function) +{ + return function() use ($function) { + list($class, $method) = Utils\interpretCallable($function); + $empty = true; + foreach (getRoutesFor($class, $method) as $offset => $route) { + if (!empty($route)) { + $empty = false; + break; + } else { + unset(State::$routes[$class][$method][$offset]); + } + } + if ($empty) { + fb_intercept($function, null); + } + }; +} + +function getRoutesFor($class, $method) +{ + if (!isset(State::$routes[$class][$method])) { + return []; + } + return array_reverse(State::$routes[$class][$method], true); +} + +function dispatchDynamic($callable, array $arguments) +{ + list($class, $method) = Utils\interpretCallable($callable); + $translation = INTERNAL_REDEFINITION_NAMESPACE . '\\' . $method; + if ($class === null && function_exists($translation)) { + $callable = $translation; + # Mind the namespace-of-origin argument + array_unshift($arguments, ''); + } + return call_user_func_array($callable, $arguments); +} + +function createStubsForInternals() +{ + $namespace = INTERNAL_REDEFINITION_NAMESPACE; + foreach (Config\getRedefinableInternals() as $name) { + if (function_exists($namespace . '\\' . $name)) { + continue; + } + $signature = ['$__pwNamespace']; + foreach ((new \ReflectionFunction($name))->getParameters() as $offset => $argument) { + $formal = ''; + if ($argument->isPassedByReference()) { + $formal .= '&'; + } + $formal .= '$' . $argument->getName(); + $isVariadic = is_callable([$argument, 'isVariadic']) ? $argument->isVariadic() : false; + if ($argument->isOptional() || $isVariadic || ($name === 'define' && $offset === 2)) { + continue; + } + $signature[] = $formal; + } + eval(strtr(INTERNAL_STUB_CODE, [ + '@name' => $name, + '@signature' => join(', ', $signature), + '@interceptor' => \Patchwork\CodeManipulation\Actions\CallRerouting\CALL_INTERCEPTION_CODE, + '@ns_for_redefinitions' => INTERNAL_REDEFINITION_NAMESPACE, + ])); + } +} + +/** + * This is needed, for instance, to intercept the time() call in call_user_func('time'). + * + * For that to happen, we require that if at least one internal function is redefinable, then + * call_user_func, preg_replace_callback and other callback-taking internal functions also be + * redefinable: see Patchwork\Config. + * + * Here, we go through the callback-taking internals and add argument-inspecting patches + * (redefinitions) to them. + * + * The patches are then expected to find the "nested" internal calls, such as the 'time' argument + * in call_user_func('time'), and invoke their respective redefinitions, if any. + */ +function connectDefaultInternals() +{ + # call_user_func() etc. are not a problem if no other internal functions are redefined + if (Config\getRedefinableInternals() === []) { + return; + } + foreach (Config\getDefaultRedefinableInternals() as $function) { + # Which arguments are callbacks? Store their offsets in the following array. + $offsets = []; + foreach ((new \ReflectionFunction($function))->getParameters() as $offset => $argument) { + $name = $argument->getName(); + if (strpos($name, 'call') !== false || strpos($name, 'func') !== false) { + $offsets[] = $offset; + } + } + connect($function, function() use ($offsets) { + # This is the argument-inspecting patch. + $args = Stack\top('args'); + $caller = Stack\all()[1]; + foreach ($offsets as $offset) { + # Callback absent + if (!isset($args[$offset])) { + continue; + } + $callable = $args[$offset]; + # Callback is a closure => definitely not internal + if ($callable instanceof \Closure) { + continue; + } + list($class, $method, $instance) = Utils\interpretCallable($callable); + if (empty($class)) { + # Callback is global function, which might be internal too. + $args[$offset] = function() use ($callable) { + return dispatchDynamic($callable, func_get_args()); + }; + } + # Callback involves a class => not internal either, since the only internals that + # Patchwork can handle as of 2.0 are global functions. + # However, we must handle all kinds of opaque access here too, such as self:: and + # private methods, because we're actually patching a stub (see INTERNAL_STUB_CODE) + # and not directly call_user_func itself (or usort, or any other of those). + # We must compensate for scope that is lost, and that callback-taking functions + # can make use of. + if (!empty($class)) { + if ($class === 'self' || $class === 'static' || $class === 'parent') { + # We do not discriminate between early and late static binding here: FIXME. + $actualClass = $caller['class']; + if ($class === 'parent') { + $actualClass = get_parent_class($actualClass); + } + $class = $actualClass; + } + # When calling a parent constructor, the reference to the object being + # constructed needs to be extracted from the stack info + if (is_null($instance) && $method === '__construct') { + $instance = $caller['object']; + } + try { + $reflection = new \ReflectionMethod($class, $method); + $reflection->setAccessible(true); + $args[$offset] = function() use ($reflection, $instance) { + return $reflection->invokeArgs($instance, func_get_args()); + }; + } catch (\ReflectionException $e) { + # If it's an invalid callable, then just prevent the unexpected propagation + # of ReflectionExceptions. + } + } + } + # Give the inspected arguments back to the callback-taking function + return relay($args); + }); + } +} + +/** + * @since 2.0.5 + * + * As of version 2.0.5, this is used to accommodate language constructs + * (echo, eval, exit and others) within the concept of callable. + */ +function translateIfLanguageConstruct($callable) +{ + if (!is_string($callable)) { + return $callable; + } + if (in_array($callable, Config\getRedefinableLanguageConstructs())) { + return RedefinitionOfLanguageConstructs\LANGUAGE_CONSTRUCT_PREFIX . $callable; + } elseif (in_array($callable, Config\getSupportedLanguageConstructs())) { + throw new Exceptions\NotUserDefined($callable); + } else { + return $callable; + } +} + +function resolveClassToInstantiate($class, $calledClass) +{ + $pieces = explode('\\', $class); + $last = array_pop($pieces); + if (in_array($last, ['self', 'static', 'parent'])) { + $frame = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2]; + if ($last == 'self') { + $class = $frame['class']; + } elseif ($last == 'parent') { + $class = get_parent_class($frame['class']); + } elseif ($last == 'static') { + $class = $calledClass; + } + } + return ltrim($class, '\\'); +} + +function getInstantiator($class, $calledClass) +{ + $namespace = INSTANTIATOR_NAMESPACE; + $class = resolveClassToInstantiate($class, $calledClass); + $adaptedName = strtr($class, ['\\' => '__']); + if (!class_exists("$namespace\\$adaptedName")) { + $constructor = (new \ReflectionClass($class))->getConstructor(); + list($parameters, $arguments) = Utils\getParameterAndArgumentLists($constructor); + $code = strtr(INSTANTIATOR_CODE, [ + '@namespace' => INSTANTIATOR_NAMESPACE, + '@instantiator' => $adaptedName, + '@class' => $class, + '@parameters' => $parameters, + ]); + RedefinitionOfNew\suspendFor(function() use ($code) { + eval(CodeManipulation\transformForEval($code)); + }); + } + $instantiator = "$namespace\\$adaptedName"; + return new $instantiator; +} + +class State +{ + static $routes = []; + static $queue = []; + static $preprocessedFiles = []; + static $routeStack = []; +} diff --git a/vendor/antecedent/patchwork/src/CallRerouting/Decorator.php b/vendor/antecedent/patchwork/src/CallRerouting/Decorator.php new file mode 100644 index 000000000..1a641df0e --- /dev/null +++ b/vendor/antecedent/patchwork/src/CallRerouting/Decorator.php @@ -0,0 +1,62 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CallRerouting; + +use Patchwork; +use Patchwork\Stack; + +class Decorator +{ + public $superclass; + public $instance; + public $method; + + private $patch; + + public function __construct($patch) + { + $this->patch = $patch; + } + + public function __invoke() + { + $top = Stack\top(); + $superclassMatches = $this->superclassMatches(); + $instanceMatches = $this->instanceMatches($top); + $methodMatches = $this->methodMatches($top); + if ($superclassMatches && $instanceMatches && $methodMatches) { + $patch = $this->patch; + if (isset($top["object"]) && $patch instanceof \Closure) { + $patch = $patch->bindTo($top["object"], $this->superclass); + } + return dispatchTo($patch); + } + Patchwork\fallBack(); + } + + private function superclassMatches() + { + return $this->superclass === null || + Stack\topCalledClass() === $this->superclass || + is_subclass_of(Stack\topCalledClass(), $this->superclass); + } + + private function instanceMatches(array $top) + { + return $this->instance === null || + (isset($top["object"]) && $top["object"] === $this->instance); + } + + private function methodMatches(array $top) + { + return $this->method === null || + $this->method === 'new' || + $top["function"] === $this->method; + } +} diff --git a/vendor/antecedent/patchwork/src/CallRerouting/Handle.php b/vendor/antecedent/patchwork/src/CallRerouting/Handle.php new file mode 100644 index 000000000..2c0d96d39 --- /dev/null +++ b/vendor/antecedent/patchwork/src/CallRerouting/Handle.php @@ -0,0 +1,65 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CallRerouting; + +class Handle +{ + private $references = []; + private $expirationHandlers = []; + private $silenced = false; + private $tags = []; + + public function __destruct() + { + $this->expire(); + } + + public function tag($tag) + { + $this->tags[] = $tag; + } + + public function hasTag($tag) + { + return in_array($tag, $this->tags); + } + + public function addReference(&$reference) + { + $this->references[] = &$reference; + } + + public function expire() + { + foreach ($this->references as &$reference) { + $reference = null; + } + if (!$this->silenced) { + foreach ($this->expirationHandlers as $expirationHandler) { + $expirationHandler(); + } + } + $this->expirationHandlers = []; + } + + public function addExpirationHandler(callable $expirationHandler) + { + $this->expirationHandlers[] = $expirationHandler; + } + + public function silence() + { + $this->silenced = true; + } + + public function unsilence() + { + $this->silenced = false; + } +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation.php b/vendor/antecedent/patchwork/src/CodeManipulation.php new file mode 100644 index 000000000..f36043ce2 --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation.php @@ -0,0 +1,160 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation; + +require __DIR__ . '/CodeManipulation/Source.php'; +require __DIR__ . '/CodeManipulation/Stream.php'; +require __DIR__ . '/CodeManipulation/Actions/Generic.php'; +require __DIR__ . '/CodeManipulation/Actions/CallRerouting.php'; +require __DIR__ . '/CodeManipulation/Actions/CodeManipulation.php'; +require __DIR__ . '/CodeManipulation/Actions/Namespaces.php'; +require __DIR__ . '/CodeManipulation/Actions/RedefinitionOfInternals.php'; +require __DIR__ . '/CodeManipulation/Actions/RedefinitionOfLanguageConstructs.php'; +require __DIR__ . '/CodeManipulation/Actions/ConflictPrevention.php'; +require __DIR__ . '/CodeManipulation/Actions/RedefinitionOfNew.php'; + +use Patchwork\Exceptions; +use Patchwork\Utils; +use Patchwork\Config; + +const OUTPUT_DESTINATION = 'php://memory'; +const OUTPUT_ACCESS_MODE = 'rb+'; + +function transform(Source $s) +{ + foreach (State::$actions as $action) { + $action($s); + } +} + +function transformString($code) +{ + $source = new Source($code); + transform($source); + return (string) $source; +} + +function transformForEval($code) +{ + $prefix = "file), $source); +} + +function availableCached($file) +{ + if (!cacheEnabled()) { + return false; + } + $cached = getCachedPath($file); + return file_exists($cached) && + filemtime($file) <= filemtime($cached) && + Config\getTimestamp() <= filemtime($cached); +} + +function internalToCache($file) +{ + if (!cacheEnabled()) { + return false; + } + return strpos($file, Config\getCachePath() . '/') === 0 + || strpos($file, Config\getCachePath() . DIRECTORY_SEPARATOR) === 0; +} + +function transformAndOpen($file) +{ + foreach (State::$importListeners as $listener) { + $listener($file); + } + if (!internalToCache($file) && availableCached($file)) { + return fopen(getCachedPath($file), 'r'); + } + $resource = fopen(OUTPUT_DESTINATION, OUTPUT_ACCESS_MODE); + $code = file_get_contents($file, true); + $source = new Source($code); + $source->file = $file; + transform($source); + if (!internalToCache($file) && cacheEnabled()) { + storeInCache($source); + return transformAndOpen($file); + } + fwrite($resource, $source); + rewind($resource); + return $resource; +} + +function prime($file) +{ + fclose(transformAndOpen($file)); +} + +function shouldTransform($file) +{ + return !Config\isBlacklisted($file) || Config\isWhitelisted($file); +} + +function register($actions) +{ + State::$actions = array_merge(State::$actions, (array) $actions); +} + +function onImport($listeners) +{ + State::$importListeners = array_merge(State::$importListeners, (array) $listeners); +} + +class State +{ + static $actions = []; + static $importListeners = []; + static $cacheIndex = []; + static $cacheIndexFile; +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Actions/CallRerouting.php b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/CallRerouting.php new file mode 100644 index 000000000..8600fb67d --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/CallRerouting.php @@ -0,0 +1,46 @@ + + * @link http://patchwork2.org/ + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation\Actions\CallRerouting; + +use Patchwork\CodeManipulation\Actions\Generic; +use Patchwork\CallRerouting; +use Patchwork\Utils; + +const CALL_INTERCEPTION_CODE = ' + $__pwClosureName = __NAMESPACE__ ? __NAMESPACE__ . "\\\\{closure}" : "\\\\{closure}"; + $__pwClass = (__CLASS__ && __FUNCTION__ !== $__pwClosureName) ? __CLASS__ : null; + if (!empty(\Patchwork\CallRerouting\State::$routes[$__pwClass][__FUNCTION__])) { + $__pwCalledClass = $__pwClass ? \get_called_class() : null; + $__pwFrame = \count(\debug_backtrace(false)); + if (\Patchwork\CallRerouting\dispatch($__pwClass, $__pwCalledClass, __FUNCTION__, $__pwFrame, $__pwResult)) { + return $__pwResult; + } + } + unset($__pwClass, $__pwCalledClass, $__pwResult, $__pwClosureName, $__pwFrame); +'; + +const QUEUE_DEPLOYMENT_CODE = '\Patchwork\CallRerouting\deployQueue()'; + +function markPreprocessedFiles() +{ + return Generic\markPreprocessedFiles(CallRerouting\State::$preprocessedFiles); +} + +function injectCallInterceptionCode() +{ + return Generic\prependCodeToFunctions(Utils\condense(CALL_INTERCEPTION_CODE)); +} + +function injectQueueDeploymentCode() +{ + return Generic\chain(array( + Generic\injectFalseExpressionAtBeginnings(QUEUE_DEPLOYMENT_CODE), + Generic\injectCodeAfterClassDefinitions(QUEUE_DEPLOYMENT_CODE . ';'), + )); +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Actions/CodeManipulation.php b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/CodeManipulation.php new file mode 100644 index 000000000..cbf96973a --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/CodeManipulation.php @@ -0,0 +1,26 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation\Actions\CodeManipulation; + +use Patchwork\CodeManipulation\Actions\Generic; +use Patchwork\CodeManipulation\Source; + +const EVAL_ARGUMENT_WRAPPER = '\Patchwork\CodeManipulation\transformForEval'; + +function propagateThroughEval() +{ + return Generic\wrapUnaryConstructArguments(T_EVAL, EVAL_ARGUMENT_WRAPPER); +} + +function flush() +{ + return function(Source $s) { + $s->flush(); + }; +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Actions/ConflictPrevention.php b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/ConflictPrevention.php new file mode 100644 index 000000000..634296b7d --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/ConflictPrevention.php @@ -0,0 +1,33 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation\Actions\ConflictPrevention; + +use Patchwork\CodeManipulation\Source; + +/** + * @since 2.0.1 + * + * Serves to avoid "Cannot redeclare Patchwork\redefine()" errors. + */ +function preventImportingOtherCopiesOfPatchwork() +{ + return function(Source $s) { + $namespaceKeyword = $s->next(T_NAMESPACE, -1); + if ($namespaceKeyword === INF || $namespaceKeyword < 2) { + return; + } + if ($s->read($namespaceKeyword, 4) == 'namespace Patchwork;') { + $pattern = '/@copyright\s+2010(-\d+)? Ignas Rudaitis/'; + if (preg_match($pattern, $s->read($namespaceKeyword - 2))) { + # Clear the file completely (in memory) + $s->splice('', 0, count($s->tokens)); + } + } + }; +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Actions/Generic.php b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/Generic.php new file mode 100644 index 000000000..a28fa32d0 --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/Generic.php @@ -0,0 +1,142 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation\Actions\Generic; + +use Patchwork\CodeManipulation\Source; +use Patchwork\Utils; + +const LEFT_ROUND = '('; +const RIGHT_ROUND = ')'; +const LEFT_CURLY = '{'; +const RIGHT_CURLY = '}'; +const LEFT_SQUARE = '['; +const RIGHT_SQUARE = ']'; +const SEMICOLON = ';'; + +function markPreprocessedFiles(&$target) +{ + return function($file) use (&$target) { + $target[$file] = true; + }; +} + +function prependCodeToFunctions($code, $skipVoidTyped = true) +{ + return function(Source $s) use ($code, $skipVoidTyped) { + foreach ($s->all(T_FUNCTION) as $function) { + # Skip "use function" + $previous = $s->skipBack(Source::junk(), $function); + if ($s->is(T_USE, $previous)) { + continue; + } + if ($skipVoidTyped && isVoidTyped($s, $function)) { + continue; + } + $bracket = $s->next(LEFT_CURLY, $function); + if (Utils\generatorsSupported()) { + # Skip generators + $yield = $s->next(T_YIELD, $bracket); + if ($yield < $s->match($bracket)) { + continue; + } + } + $semicolon = $s->next(SEMICOLON, $function); + if ($bracket < $semicolon) { + $s->splice($code, $bracket + 1); + } + } + }; +} + +function isVoidTyped(Source $s, $function) +{ + $parenthesis = $s->next(LEFT_ROUND, $function); + $next = $s->skip(Source::junk(), $s->match($parenthesis)); + if ($s->is(T_USE, $next)) { + $next = $s->skip(Source::junk(), $s->match($s->next(LEFT_ROUND, $next))); + } + if ($s->is(':', $next)) { + return $s->read($s->skip(Source::junk(), $next), 1) === 'void'; + } + return false; +} + +function wrapUnaryConstructArguments($construct, $wrapper) +{ + return function(Source $s) use ($construct, $wrapper) { + foreach ($s->all($construct) as $match) { + $pos = $s->next(LEFT_ROUND, $match); + $s->splice($wrapper . LEFT_ROUND, $pos + 1); + $s->splice(RIGHT_ROUND, $s->match($pos)); + } + }; +} + +function injectFalseExpressionAtBeginnings($expression) +{ + return function(Source $s) use ($expression) { + $openingTags = $s->all(T_OPEN_TAG); + $openingTagsWithEcho = $s->all(T_OPEN_TAG_WITH_ECHO); + if (empty($openingTags) && empty($openingTagsWithEcho)) { + return; + } + if (!empty($openingTags) && + (empty($openingTagsWithEcho) || reset($openingTags) < reset($openingTagsWithEcho))) { + $pos = reset($openingTags); + # Skip initial declare() statements + while ($s->read($s->skip(Source::junk(), $pos)) === 'declare') { + $pos = $s->next(SEMICOLON, $pos); + } + # Enter first namespace + $namespaceKeyword = $s->next(T_NAMESPACE, $pos); + if ($namespaceKeyword !== INF) { + $semicolon = $s->next(SEMICOLON, $namespaceKeyword); + $leftBracket = $s->next(LEFT_CURLY, $namespaceKeyword); + $pos = min($semicolon, $leftBracket); + } + $s->splice(' ' . $expression . ';', $pos + 1); + } else { + $openingTag = reset($openingTagsWithEcho); + $closingTag = $s->next(T_CLOSE_TAG, $openingTag); + $semicolon = $s->next(SEMICOLON, $openingTag); + $s->splice(' (' . $expression . ') ?: (', $openingTag + 1); + $s->splice(') ', min($closingTag, $semicolon)); + } + }; +} + +function injectCodeAfterClassDefinitions($code) +{ + return function(Source $s) use ($code) { + foreach ($s->all(T_CLASS) as $match) { + if ($s->is([T_DOUBLE_COLON, T_NEW], $s->skipBack(Source::junk(), $match))) { + # Not a proper class definition: either ::class syntax or anonymous class + continue; + } + $leftBracket = $s->next(LEFT_CURLY, $match); + if ($leftBracket === INF) { + continue; + } + $rightBracket = $s->match($leftBracket); + if ($rightBracket === INF) { + continue; + } + $s->splice($code, $rightBracket + 1); + } + }; +} + +function chain(array $callbacks) +{ + return function(Source $s) use ($callbacks) { + foreach ($callbacks as $callback) { + $callback($s); + } + }; +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Actions/Namespaces.php b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/Namespaces.php new file mode 100644 index 000000000..f3324a0a4 --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/Namespaces.php @@ -0,0 +1,177 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation\Actions\Namespaces; + +use Patchwork\CodeManipulation\Source; +use Patchwork\CodeManipulation\Actions\Generic; + +/** + * @since 2.1.0 + */ +function resolveName(Source $s, $pos, $type = 'class') +{ + $name = scanQualifiedName($s, $pos); + $pieces = explode('\\', $name); + if ($pieces[0] === '') { + return $name; + } + $uses = collectUseDeclarations($s, $pos); + if (isset($uses[$type][$name])) { + return '\\' . ltrim($uses[$type][$name], ' \\'); + } + if (isset($uses['class'][$pieces[0]])) { + $name = '\\' . ltrim($uses['class'][$pieces[0]] . '\\' . join('\\', array_slice($pieces, 1)), '\\'); + } else { + $name = '\\' . ltrim(getNamespaceAt($s, $pos) . '\\' . $name, '\\'); + } + return $name; +} + +/** + * @since 2.1.0 + */ +function getNamespaceAt(Source $s, $pos) +{ + foreach (collectNamespaceBoundaries($s) as $namespace => $boundaryPairs) { + foreach ($boundaryPairs as $boundaries) { + list($begin, $end) = $boundaries; + if ($begin <= $pos && $pos <= $end) { + return $namespace; + } + } + } + return ''; +} + +function collectNamespaceBoundaries(Source $s) +{ + return $s->cache([], function() { + if (!$this->has(T_NAMESPACE)) { + return ['' => [[0, INF]]]; + } + $result = []; + foreach ($this->all(T_NAMESPACE) as $keyword) { + if ($this->next(';', $keyword) < $this->next(Generic\LEFT_CURLY, $keyword)) { + return [scanQualifiedName($this, $keyword + 1) => [[0, INF]]]; + } + $begin = $this->next(Generic\LEFT_CURLY, $keyword) + 1; + $end = $this->match($begin - 1) - 1; + $name = scanQualifiedName($this, $keyword + 1); + if (!isset($result[$name])) { + $result[$name] = []; + } + $result[$name][] = [$begin, $end]; + } + return $result; + }); +} + +function collectUseDeclarations(Source $s, $begin) +{ + foreach (collectNamespaceBoundaries($s) as $boundaryPairs) { + foreach ($boundaryPairs as $boundaries) { + list($leftBoundary, $rightBoundary) = $boundaries; + if ($leftBoundary <= $begin && $begin <= $rightBoundary) { + $begin = $leftBoundary; + break; + } + } + } + return $s->cache([$begin], function($begin) { + $result = ['class' => [], 'function' => [], 'const' => []]; + # only tokens that are siblings bracket-wise are considered, + # so trait-use instances are not an issue + foreach ($this->siblings(T_USE, $begin) as $keyword) { + # skip if closure-use + $next = $this->skip(Source::junk(), $keyword); + if ($this->is(Generic\LEFT_ROUND, $next)) { + continue; + } + parseUseDeclaration($this, $next, $result); + } + return $result; + }); +} + +function parseUseDeclaration(Source $s, $pos, array &$aliases, $prefix = '', $type = 'class') +{ + $lastPart = null; + $whole = $prefix; + while (true) { + switch ($s->tokens[$pos][Source::TYPE_OFFSET]) { + case T_FUNCTION: + $type = 'function'; + break; + case T_CONST: + $type = 'const'; + break; + case T_NS_SEPARATOR: + if (!empty($whole)) { + $whole .= '\\'; + } + break; + case T_STRING: + $lastPart = $s->tokens[$pos][Source::STRING_OFFSET]; + $whole .= $lastPart; + break; + case T_AS: + $pos = $s->skip(Source::junk(), $pos); + $aliases[$type][$s->tokens[$pos][Source::STRING_OFFSET]] = $whole; + $lastPart = null; + $whole = $prefix; + break; + case ',': + if ($lastPart !== null) { + $aliases[$type][$lastPart] = $whole; + } + $lastPart = null; + $whole = $prefix; + $type = 'class'; + break; + case Generic\LEFT_CURLY: + parseUseDeclaration($s, $pos + 1, $aliases, $prefix . '\\', $type); + break; + case T_WHITESPACE: + case T_COMMENT: + case T_DOC_COMMENT: + break; + default: + if ($lastPart !== null) { + $aliases[$type][$lastPart] = $whole; + } + return; + } + $pos++; + } +} + +function scanQualifiedName(Source $s, $begin) +{ + $result = ''; + while (true) { + switch ($s->tokens[$begin][Source::TYPE_OFFSET]) { + case T_NS_SEPARATOR: + if (!empty($result)) { + $result .= '\\'; + } + # fall through + case T_STRING: + case T_STATIC: + $result .= $s->tokens[$begin][Source::STRING_OFFSET]; + break; + case T_WHITESPACE: + case T_COMMENT: + case T_DOC_COMMENT: + break; + default: + return str_replace('\\\\', '\\', $result); + } + $begin++; + } +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfInternals.php b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfInternals.php new file mode 100644 index 000000000..8d420b351 --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfInternals.php @@ -0,0 +1,137 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation\Actions\RedefinitionOfInternals; + +use Patchwork\Config; +use Patchwork\CallRerouting; +use Patchwork\CodeManipulation\Source; +use Patchwork\CodeManipulation\Actions\Generic; +use Patchwork\CodeManipulation\Actions\Namespaces; + +const DYNAMIC_CALL_REPLACEMENT = '\Patchwork\CallRerouting\dispatchDynamic(%s, \Patchwork\Utils\args(%s))'; + +function spliceNamedFunctionCalls() +{ + if (Config\getRedefinableInternals() === []) { + return function() {}; + } + $names = []; + foreach (Config\getRedefinableInternals() as $name) { + $names[strtolower($name)] = true; + } + return function(Source $s) use ($names) { + foreach (Namespaces\collectNamespaceBoundaries($s) as $namespace => $boundaryList) { + foreach ($boundaryList as $boundaries) { + list($begin, $end) = $boundaries; + $aliases = Namespaces\collectUseDeclarations($s, $begin)['function']; + # Receive all aliases, leave only those for redefinable internals + foreach ($aliases as $alias => $qualified) { + if (!isset($names[$qualified])) { + unset($aliases[$alias]); + } else { + $aliases[strtolower($alias)] = strtolower($qualified); + } + } + spliceNamedCallsWithin($s, $begin, $end, $names, $aliases); + } + } + }; +} + +function spliceNamedCallsWithin(Source $s, $begin, $end, array $names, array $aliases) +{ + foreach ($s->within(T_STRING, $begin, $end) as $string) { + $original = strtolower($s->read($string)); + if (isset($names[$original]) || isset($aliases[$original])) { + $previous = $s->skipBack(Source::junk(), $string); + $hadBackslash = false; + if ($s->is(T_NS_SEPARATOR, $previous)) { + if (!isset($names[$original])) { + # use-aliased name cannot have a leading backslash + continue; + } + $s->splice('', $previous, 1); + $previous = $s->skipBack(Source::junk(), $previous); + $hadBackslash = true; + } + if ($s->is([T_FUNCTION, T_OBJECT_OPERATOR, T_DOUBLE_COLON, T_STRING, T_NEW], $previous)) { + continue; + } + $next = $s->skip(Source::junk(), $string); + if (!$s->is(Generic\LEFT_ROUND, $next)) { + continue; + } + if (isset($aliases[$original])) { + $original = $aliases[$original]; + } + $secondNext = $s->skip(Source::junk(), $next); + $splice = '\\' . CallRerouting\INTERNAL_REDEFINITION_NAMESPACE . '\\'; + $splice .= $original . Generic\LEFT_ROUND; + # prepend a namespace-of-origin argument to handle cases like Acme\time() vs time() + $splice .= !$hadBackslash ? '__NAMESPACE__' : '""'; + if (!$s->is(Generic\RIGHT_ROUND, $secondNext)) { + # right parenthesis doesn't follow immediately => there are arguments + $splice .= ', '; + } + $s->splice($splice, $string, $secondNext - $string); + } + } +} + +function spliceDynamicCalls() +{ + if (Config\getRedefinableInternals() === []) { + return function() {}; + } + return function(Source $s) { + spliceDynamicCallsWithin($s, 0, count($s->tokens) - 1); + }; +} + +function spliceDynamicCallsWithin(Source $s, $first, $last) +{ + $pos = $first; + $anchor = INF; + $suppress = false; + while ($pos <= $last) { + switch ($s->tokens[$pos][Source::TYPE_OFFSET]) { + case '$': + case T_VARIABLE: + $anchor = min($pos, $anchor); + break; + case Generic\LEFT_ROUND: + if ($anchor !== INF && !$suppress) { + $callable = $s->read($anchor, $pos - $anchor); + $arguments = $s->read($pos + 1, $s->match($pos) - $pos - 1); + $pos = $s->match($pos); + $replacement = sprintf(DYNAMIC_CALL_REPLACEMENT, $callable, $arguments); + $s->splice($replacement, $anchor, $pos - $anchor + 1); + } + break; + case Generic\LEFT_SQUARE: + case Generic\LEFT_CURLY: + spliceDynamicCallsWithin($s, $pos + 1, $s->match($pos) - 1); + $pos = $s->match($pos); + break; + case T_WHITESPACE: + case T_COMMENT: + case T_DOC_COMMENT: + break; + case T_OBJECT_OPERATOR: + case T_DOUBLE_COLON: + case T_NEW: + $suppress = true; + break; + default: + $suppress = false; + $anchor = INF; + } + $pos++; + } +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfLanguageConstructs.php b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfLanguageConstructs.php new file mode 100644 index 000000000..b61590aef --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfLanguageConstructs.php @@ -0,0 +1,124 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation\Actions\RedefinitionOfLanguageConstructs; + +use Patchwork\CodeManipulation\Source; +use Patchwork\CodeManipulation\Actions\Generic; +use Patchwork\Exceptions; +use Patchwork\Config; + +const LANGUAGE_CONSTRUCT_PREFIX = 'Patchwork\Redefinitions\LanguageConstructs\_'; + +/** + * @since 2.0.5 + */ +function spliceAllConfiguredLanguageConstructs() +{ + $mapping = getMappingOfConstructs(); + $used = []; + $actions = []; + foreach (Config\getRedefinableLanguageConstructs() as $construct) { + if (isset($used[$mapping[$construct]])) { + continue; + } + $used[$mapping[$construct]] = true; + $actions[] = spliceLanguageConstruct($mapping[$construct]); + } + return Generic\chain($actions); +} + +function getMappingOfConstructs() +{ + return [ + 'echo' => T_ECHO, + 'print' => T_PRINT, + 'eval' => T_EVAL, + 'die' => T_EXIT, + 'exit' => T_EXIT, + 'isset' => T_ISSET, + 'unset' => T_UNSET, + 'empty' => T_EMPTY, + 'require' => T_REQUIRE, + 'require_once' => T_REQUIRE_ONCE, + 'include' => T_INCLUDE, + 'include_once' => T_INCLUDE_ONCE, + 'clone' => T_CLONE, + ]; +} + +function getInnerTokens() +{ + return [ + '$', + ',', + T_OBJECT_OPERATOR, + T_DOUBLE_COLON, + T_NS_SEPARATOR, + T_STRING, + T_LNUMBER, + T_DNUMBER, + T_WHITESPACE, + T_CONSTANT_ENCAPSED_STRING, + T_COMMENT, + T_DOC_COMMENT, + T_VARIABLE, + T_ENCAPSED_AND_WHITESPACE, + ]; +} + +function getBracketTokens() +{ + return [ + Generic\LEFT_ROUND, + Generic\LEFT_SQUARE, + Generic\LEFT_CURLY, + T_CURLY_OPEN, + T_DOLLAR_OPEN_CURLY_BRACES, + ]; +} + +function spliceLanguageConstruct($token) +{ + return function(Source $s) use ($token) { + foreach ($s->all($token) as $pos) { + $s->splice('\\' . LANGUAGE_CONSTRUCT_PREFIX, $pos, 0, Source::PREPEND); + if (lacksParentheses($s, $pos)) { + addParentheses($s, $pos); + } + } + }; +} + +function lacksParentheses(Source $s, $pos) +{ + if ($s->is(T_ECHO, $pos)) { + return true; + } + $next = $s->skip(Source::junk(), $pos); + return !$s->is(Generic\LEFT_ROUND, $next); +} + +function addParentheses(Source $s, $pos) +{ + $pos = $s->skip(Source::junk(), $pos); + $s->splice(Generic\LEFT_ROUND, $pos, 0, Source::PREPEND); + while ($pos < count($s->tokens)) { + if ($s->is(getInnerTokens(), $pos)) { + $pos++; + } elseif ($s->is(getBracketTokens(), $pos)) { + $pos = $s->match($pos) + 1; + } else { + break; + } + } + if ($s->is(Source::junk(), $pos)) { + $pos = $s->skipBack(Source::junk(), $pos); + } + $s->splice(Generic\RIGHT_ROUND, $pos, 0, Source::APPEND); +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfNew.php b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfNew.php new file mode 100644 index 000000000..3413e152b --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Actions/RedefinitionOfNew.php @@ -0,0 +1,191 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation\Actions\RedefinitionOfNew; + +use Patchwork\CodeManipulation\Source; +use Patchwork\CodeManipulation\Actions\Generic; +use Patchwork\CodeManipulation\Actions\Namespaces; +use Patchwork\Config; + +const STATIC_INSTANTIATION_REPLACEMENT = '\Patchwork\CallRerouting\getInstantiator(\'%s\', %s)->instantiate(%s)'; +const DYNAMIC_INSTANTIATION_REPLACEMENT = '\Patchwork\CallRerouting\getInstantiator(%s, %s)->instantiate(%s)'; +const CALLED_CLASS = '((__CLASS__ && __FUNCTION__ !== (__NAMESPACE__ ? __NAMESPACE__ . "\\\\{closure}" : "\\\\{closure}")) ? \get_called_class() : null)'; + +const spliceAllInstantiations = 'Patchwork\CodeManipulation\Actions\RedefinitionOfNew\spliceAllInstantiations'; +const publicizeConstructors = 'Patchwork\CodeManipulation\Actions\RedefinitionOfNew\publicizeConstructors'; + +/** + * @since 2.1.0 + */ +function spliceAllInstantiations(Source $s) +{ + if (!State::$enabled || !Config\isNewKeywordRedefinable()) { + return; + } + foreach ($s->all(T_NEW) as $new) { + $begin = $s->skip(Source::junk(), $new); + if ($s->is(T_CLASS, $begin)) { + # Anonymous class + continue; + } + $end = scanInnerTokens($s, $begin, $dynamic); + $afterEnd = $s->skip(Source::junk(), $end); + list($argsOpen, $argsClose) = [null, null]; + if ($s->is(Generic\LEFT_ROUND, $afterEnd)) { + list($argsOpen, $argsClose) = [$afterEnd, $s->match($afterEnd)]; + } + spliceInstantiation($s, $new, $begin, $end, $argsOpen, $argsClose, $dynamic); + if (hasExtraParentheses($s, $new)) { + removeExtraParentheses($s, $new); + } + } +} + +function publicizeConstructors(Source $s) +{ + if (!Config\isNewKeywordRedefinable()) { + return; + } + foreach ($s->all([T_PRIVATE, T_PROTECTED]) as $first) { + $second = $s->skip(Source::junk(), $first); + $third = $s->skip(Source::junk(), $second); + if ($s->is(T_FUNCTION, $second) && $s->read($third, 1) === '__construct') { + $s->splice('public', $first, 1); + } + } +} + +function spliceInstantiation(Source $s, $new, $begin, $end, $argsOpen, $argsClose, $dynamic) +{ + $class = $s->read($begin, $end - $begin + 1); + $args = ''; + $length = $end - $new + 1; + if ($argsOpen !== null) { + $args = $s->read($argsOpen + 1, $argsClose - $argsOpen - 1); + $length = $argsClose - $new + 1; + } + $replacement = DYNAMIC_INSTANTIATION_REPLACEMENT; + if (!$dynamic) { + $class = Namespaces\resolveName($s, $begin); + $replacement = STATIC_INSTANTIATION_REPLACEMENT; + } + $s->splice(sprintf($replacement, $class, CALLED_CLASS, $args), $new, $length); +} + +function getInnerTokens() +{ + return [ + '$', + T_OBJECT_OPERATOR, + T_DOUBLE_COLON, + T_NS_SEPARATOR, + T_STRING, + T_LNUMBER, + T_DNUMBER, + T_WHITESPACE, + T_CONSTANT_ENCAPSED_STRING, + T_COMMENT, + T_DOC_COMMENT, + T_VARIABLE, + T_ENCAPSED_AND_WHITESPACE, + T_STATIC, + ]; +} + +function getBracketTokens() +{ + return [ + Generic\LEFT_SQUARE, + Generic\LEFT_CURLY, + T_CURLY_OPEN, + T_DOLLAR_OPEN_CURLY_BRACES, + ]; +} + +function getDynamicTokens() +{ + return [ + '$', + T_OBJECT_OPERATOR, + T_DOUBLE_COLON, + T_LNUMBER, + T_DNUMBER, + T_CONSTANT_ENCAPSED_STRING, + T_VARIABLE, + T_ENCAPSED_AND_WHITESPACE, + ]; +} + +function scanInnerTokens(Source $s, $begin, &$dynamic = null) +{ + $dynamic = false; + $pos = $begin; + while ($s->is(getInnerTokens(), $pos) || $s->is(getBracketTokens(), $pos)) { + if ($s->is(getBracketTokens(), $pos)) { + $dynamic = true; + $pos = $s->match($pos) + 1; + } else { + if ($s->is(getDynamicTokens(), $pos)) { + $dynamic = true; + } + $pos++; + } + } + return $pos - 1; +} + +function hasExtraParentheses(Source $s, $new) +{ + $doNotRemoveAfter = [ + T_STRING, + T_STATIC, + T_VARIABLE, + T_FOREACH, + T_FOR, + T_IF, + T_ELSEIF, + T_WHILE, + T_ARRAY, + T_PRINT, + T_ECHO + ]; + $left = $s->skipBack(Source::junk(), $new); + if (!$s->is(Generic\LEFT_ROUND, $left)) { + return false; + } + $beforeLeft = $s->skipBack(Source::junk(), $left); + return !$s->is($doNotRemoveAfter, $beforeLeft); +} + +function removeExtraParentheses(Source $s, $new) +{ + $left = $s->skipBack(Source::junk(), $new); + $s->splice('', $left, 1); + $s->splice('', $s->match($left), 1); +} + +function suspendFor(callable $function) +{ + State::$enabled = false; + $exception = null; + try { + $function(); + } catch (\Exception $e) { + $exception = $e; + } + State::$enabled = true; + if ($exception) { + throw $exception; + } +} + +class State +{ + static $enabled = true; +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Source.php b/vendor/antecedent/patchwork/src/CodeManipulation/Source.php new file mode 100644 index 000000000..0ead73bab --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Source.php @@ -0,0 +1,314 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation; + +use Patchwork\Utils; + +class Source +{ + const TYPE_OFFSET = 0; + const STRING_OFFSET = 1; + + const PREPEND = 'PREPEND'; + const APPEND = 'APPEND'; + const OVERWRITE = 'OVERWRITE'; + + const ANY = null; + + public $tokens; + public $tokensByType; + public $splices; + public $spliceLengths; + public $code; + public $file; + public $matchingBrackets; + public $levels; + public $levelBeginnings; + public $levelEndings; + public $tokensByLevel; + public $tokensByLevelAndType; + public $cache; + + function __construct($string) + { + $this->code = $string; + $this->initialize(); + } + + function initialize() + { + $this->tokens = token_get_all($this->code); + $this->tokens[] = [T_WHITESPACE, ""]; + $this->indexTokensByType(); + $this->collectBracketMatchings(); + $this->collectLevelInfo(); + $this->splices = []; + $this->spliceLengths = []; + $this->cache = []; + } + + function indexTokensByType() + { + $this->tokensByType = []; + foreach ($this->tokens as $offset => $token) { + $this->tokensByType[$token[self::TYPE_OFFSET]][] = $offset; + } + } + + function collectBracketMatchings() + { + $this->matchingBrackets = []; + $stack = []; + foreach ($this->tokens as $offset => $token) { + $type = $token[self::TYPE_OFFSET]; + switch ($type) { + case '(': + case '[': + case '{': + case T_CURLY_OPEN: + case T_DOLLAR_OPEN_CURLY_BRACES: + $stack[] = $offset; + break; + case ')': + case ']': + case '}': + $top = array_pop($stack); + $this->matchingBrackets[$top] = $offset; + $this->matchingBrackets[$offset] = $top; + break; + } + } + } + + function collectLevelInfo() + { + $level = 0; + $this->levels = []; + $this->tokensByLevel = []; + $this->levelBeginnings = []; + $this->levelEndings = []; + $this->tokensByLevelAndType = []; + foreach ($this->tokens as $offset => $token) { + $type = $token[self::TYPE_OFFSET]; + switch ($type) { + case '(': + case '[': + case '{': + case T_CURLY_OPEN: + case T_DOLLAR_OPEN_CURLY_BRACES: + $level++; + Utils\appendUnder($this->levelBeginnings, $level, $offset); + break; + case ')': + case ']': + case '}': + Utils\appendUnder($this->levelEndings, $level, $offset); + $level--; + } + $this->levels[$offset] = $level; + Utils\appendUnder($this->tokensByLevel, $level, $offset); + Utils\appendUnder($this->tokensByLevelAndType, [$level, $type], $offset); + } + Utils\appendUnder($this->levelBeginnings, 0, 0); + Utils\appendUnder($this->levelEndings, 0, count($this->tokens) - 1); + } + + function has($types) + { + foreach ((array) $types as $type) { + if ($this->all($type) !== []) { + return true; + } + } + return false; + } + + function is($types, $offset) + { + foreach ((array) $types as $type) { + if ($this->tokens[$offset][self::TYPE_OFFSET] === $type) { + return true; + } + } + return false; + } + + function skip($types, $offset, $direction = 1) + { + $offset += $direction; + $types = (array) $types; + while ($offset < count($this->tokens) && $offset >= 0) { + if (!in_array($this->tokens[$offset][self::TYPE_OFFSET], $types)) { + return $offset; + } + $offset += $direction; + } + return ($direction > 0) ? INF : -1; + } + + function skipBack($types, $offset) + { + return $this->skip($types, $offset, -1); + } + + function within($types, $low, $high) + { + $result = []; + foreach ((array) $types as $type) { + $candidates = isset($this->tokensByType[$type]) ? $this->tokensByType[$type] : []; + $result = array_merge(Utils\allWithinRange($candidates, $low, $high), $result); + } + return $result; + } + + function read($offset, $count = 1) + { + $result = ''; + $pos = $offset; + while ($pos < $offset + $count) { + if (isset($this->tokens[$pos][self::STRING_OFFSET])) { + $result .= $this->tokens[$pos][self::STRING_OFFSET]; + } else { + $result .= $this->tokens[$pos]; + } + $pos++; + } + return $result; + } + + function siblings($types, $offset) + { + $level = $this->levels[$offset]; + $begin = Utils\lastNotGreaterThan(Utils\access($this->levelBeginnings, $level, []), $offset); + $end = Utils\firstGreaterThan(Utils\access($this->levelEndings, $level, []), $offset); + if ($types === self::ANY) { + return Utils\allWithinRange($this->tokensByLevel[$level], $begin, $end); + } else { + $result = []; + foreach ((array) $types as $type) { + $candidates = Utils\access($this->tokensByLevelAndType, [$level, $type], []); + $result = array_merge(Utils\allWithinRange($candidates, $begin, $end), $result); + } + return $result; + } + } + + function next($types, $offset) + { + if (!is_array($types)) { + $candidates = Utils\access($this->tokensByType, $types, []); + return Utils\firstGreaterThan($candidates, $offset); + } + $result = INF; + foreach ($types as $type) { + $result = min($this->next($type, $offset), $result); + } + return $result; + } + + function all($types) + { + if (!is_array($types)) { + return Utils\access($this->tokensByType, $types, []); + } + $result = []; + foreach ($types as $type) { + $result = array_merge($result, $this->all($type)); + } + sort($result); + return $result; + } + + function match($offset) + { + return isset($this->matchingBrackets[$offset]) ? $this->matchingBrackets[$offset] : INF; + } + + function splice($splice, $offset, $length = 0, $policy = self::OVERWRITE) + { + if ($policy === self::OVERWRITE) { + $this->splices[$offset] = $splice; + } elseif ($policy === self::PREPEND || $policy === self::APPEND) { + if (!isset($this->splices[$offset])) { + $this->splices[$offset] = ''; + } + if ($policy === self::PREPEND) { + $this->splices[$offset] = $splice . $this->splices[$offset]; + } elseif ($policy === self::APPEND) { + $this->splices[$offset] .= $splice; + } + } + if (!isset($this->spliceLengths[$offset])) { + $this->spliceLengths[$offset] = 0; + } + $this->spliceLengths[$offset] = max($length, $this->spliceLengths[$offset]); + $this->code = null; + } + + function createCodeFromTokens() + { + $splices = $this->splices; + $code = ""; + $count = count($this->tokens); + for ($offset = 0; $offset < $count; $offset++) { + if (isset($splices[$offset])) { + $code .= $splices[$offset]; + unset($splices[$offset]); + $offset += $this->spliceLengths[$offset] - 1; + } else { + $t = $this->tokens[$offset]; + $code .= isset($t[self::STRING_OFFSET]) ? $t[self::STRING_OFFSET] : $t; + } + } + $this->code = $code; + } + + static function junk() + { + return [T_WHITESPACE, T_COMMENT, T_DOC_COMMENT]; + } + + function __toString() + { + if ($this->code === null) { + $this->createCodeFromTokens(); + } + return (string) $this->code; + } + + function flush() + { + $this->initialize(token_get_all($this)); + } + + /** + * @since 2.1.0 + */ + function cache(array $args, \Closure $function) + { + $found = true; + $trace = debug_backtrace()[1]; + $location = $trace['file'] . ':' . $trace['line']; + $result = &$this->cache; + foreach (array_merge([$location], $args) as $step) { + if (!is_scalar($step)) { + throw new \LogicException; + } + if (!isset($result[$step])) { + $result[$step] = []; + $found = false; + } + $result = &$result[$step]; + } + if (!$found) { + $result = call_user_func_array($function->bindTo($this), $args); + } + return $result; + } +} diff --git a/vendor/antecedent/patchwork/src/CodeManipulation/Stream.php b/vendor/antecedent/patchwork/src/CodeManipulation/Stream.php new file mode 100644 index 000000000..115c26328 --- /dev/null +++ b/vendor/antecedent/patchwork/src/CodeManipulation/Stream.php @@ -0,0 +1,257 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\CodeManipulation; + +use Patchwork\Utils; + +class Stream +{ + const STREAM_OPEN_FOR_INCLUDE = 128; + const STAT_MTIME_NUMERIC_OFFSET = 9; + const STAT_MTIME_ASSOC_OFFSET = 'mtime'; + + protected static $protocols = ['file', 'phar']; + + public $context; + public $resource; + + public static function wrap() + { + foreach (static::$protocols as $protocol) { + stream_wrapper_unregister($protocol); + stream_wrapper_register($protocol, get_called_class()); + } + } + + public static function unwrap() + { + foreach (static::$protocols as $protocol) { + set_error_handler(function() {}); + stream_wrapper_restore($protocol); + restore_error_handler(); + } + } + + public function stream_open($path, $mode, $options, &$openedPath) + { + $this->unwrap(); + $including = (bool) ($options & self::STREAM_OPEN_FOR_INCLUDE); + if ($including && shouldTransform($path)) { + $this->resource = transformAndOpen($path); + $this->wrap(); + return true; + } + if (isset($this->context)) { + $this->resource = fopen($path, $mode, $options, $this->context); + } else { + $this->resource = fopen($path, $mode, $options); + } + $this->wrap(); + return $this->resource !== false; + } + + public function stream_close() + { + return fclose($this->resource); + } + + public function stream_eof() + { + return feof($this->resource); + } + + public function stream_flush() + { + return fflush($this->resource); + } + + public function stream_read($count) + { + return fread($this->resource, $count); + } + + public function stream_seek($offset, $whence = SEEK_SET) + { + return fseek($this->resource, $offset, $whence) === 0; + } + + public function stream_stat() + { + $result = fstat($this->resource); + if ($result) { + $result[self::STAT_MTIME_ASSOC_OFFSET]++; + $result[self::STAT_MTIME_NUMERIC_OFFSET]++; + } + return $result; + } + + public function stream_tell() + { + return ftell($this->resource); + } + + public function url_stat($path, $flags) + { + $this->unwrap(); + set_error_handler(function() {}); + try { + $result = stat($path); + } catch (\Exception $e) { + $result = null; + } + restore_error_handler(); + $this->wrap(); + if ($result) { + $result[self::STAT_MTIME_ASSOC_OFFSET]++; + $result[self::STAT_MTIME_NUMERIC_OFFSET]++; + } + return $result; + } + + public function dir_closedir() + { + closedir($this->resource); + return true; + } + + public function dir_opendir($path, $options) + { + $this->unwrap(); + if (isset($this->context)) { + $this->resource = opendir($path, $this->context); + } else { + $this->resource = opendir($path); + } + $this->wrap(); + return $this->resource !== false; + } + + public function dir_readdir() + { + return readdir($this->resource); + } + + public function dir_rewinddir() + { + rewinddir($this->resource); + return true; + } + + public function mkdir($path, $mode, $options) + { + $this->unwrap(); + if (isset($this->context)) { + $result = mkdir($path, $mode, $options, $this->context); + } else { + $result = mkdir($path, $mode, $options); + } + $this->wrap(); + return $result; + } + + public function rename($path_from, $path_to) + { + $this->unwrap(); + if (isset($this->context)) { + $result = rename($path_from, $path_to, $this->context); + } else { + $result = rename($path_from, $path_to); + } + $this->wrap(); + return $result; + } + + public function rmdir($path, $options) + { + $this->unwrap(); + if (isset($this->context)) { + $result = rmdir($path, $this->context); + } else { + $result = rmdir($path); + } + $this->wrap(); + return $result; + } + + public function stream_cast($cast_as) + { + return $this->resource; + } + + public function stream_lock($operation) + { + if ($operation === '0' || $operation === 0) { + $operation = LOCK_EX; + } + return flock($this->resource, $operation); + } + + public function stream_set_option($option, $arg1, $arg2) + { + switch ($option) { + case STREAM_OPTION_BLOCKING: + return stream_set_blocking($this->resource, $arg1); + case STREAM_OPTION_READ_TIMEOUT: + return stream_set_timeout($this->resource, $arg1, $arg2); + case STREAM_OPTION_WRITE_BUFFER: + return stream_set_write_buffer($this->resource, $arg1); + case STREAM_OPTION_READ_BUFFER: + return stream_set_read_buffer($this->resource, $arg1); + } + } + + public function stream_write($data) + { + return fwrite($this->resource, $data); + } + + public function unlink($path) + { + $this->unwrap(); + if (isset($this->context)) { + $result = unlink($path, $this->context); + } else { + $result = unlink($path); + } + $this->wrap(); + return $result; + } + + public function stream_metadata($path, $option, $value) + { + $this->unwrap(); + switch ($option) { + case STREAM_META_TOUCH: + if (empty($value)) { + $result = touch($path); + } else { + $result = touch($path, $value[0], $value[1]); + } + break; + case STREAM_META_OWNER_NAME: + case STREAM_META_OWNER: + $result = chown($path, $value); + break; + case STREAM_META_GROUP_NAME: + case STREAM_META_GROUP: + $result = chgrp($path, $value); + break; + case STREAM_META_ACCESS: + $result = chmod($path, $value); + break; + } + $this->wrap(); + return $result; + } + + public function stream_truncate($new_size) + { + return ftruncate($this->resource, $new_size); + } +} diff --git a/vendor/antecedent/patchwork/src/Config.php b/vendor/antecedent/patchwork/src/Config.php new file mode 100644 index 000000000..7c374f60a --- /dev/null +++ b/vendor/antecedent/patchwork/src/Config.php @@ -0,0 +1,230 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\Config; + +use Patchwork\Utils; +use Patchwork\Exceptions; +use Patchwork\CodeManipulation\Actions\RedefinitionOfLanguageConstructs; + +const FILE_NAME = 'patchwork.json'; + +function locate() +{ + $alreadyRead = []; + $paths = array_map('dirname', get_included_files()); + $paths[] = dirname($_SERVER['PHP_SELF']); + $paths[] = getcwd(); + foreach ($paths as $path) { + while (dirname($path) !== $path) { + $file = $path . DIRECTORY_SEPARATOR . FILE_NAME; + if (is_file($file) && !isset($alreadyRead[$file])) { + read($file); + State::$timestamp = max(filemtime($file), State::$timestamp); + $alreadyRead[$file] = true; + } + $path = dirname($path); + } + } +} + +function read($file) +{ + $data = json_decode(file_get_contents($file), true); + if (json_last_error() !== JSON_ERROR_NONE) { + $message = json_last_error_msg(); + throw new Exceptions\ConfigMalformed($file, $message); + } + set($data, $file); +} + +function set(array $data, $file) +{ + $keys = array_keys($data); + $list = ['blacklist', 'whitelist', 'cache-path', 'redefinable-internals', 'new-keyword-redefinable']; + $unknown = array_diff($keys, $list); + if ($unknown != []) { + throw new Exceptions\ConfigKeyNotRecognized(reset($unknown), $list, $file); + } + $root = dirname($file); + setBlacklist(get($data, 'blacklist'), $root); + setWhitelist(get($data, 'whitelist'), $root); + setCachePath(get($data, 'cache-path'), $root); + setRedefinableInternals(get($data, 'redefinable-internals'), $root); + setNewKeywordRedefinability(get($data, 'new-keyword-redefinable'), $root); +} + +function get(array $data, $key) +{ + return isset($data[$key]) ? $data[$key] : null; +} + +function setBlacklist($data, $root) +{ + merge(State::$blacklist, resolvePaths($data, $root)); +} + +function isListed($path, array $list) +{ + $path = rtrim($path, '\\/'); + foreach ($list as $item) { + if (strpos($path, $item) === 0) { + return true; + } + } + return false; +} + +function isBlacklisted($path) +{ + return isListed($path, State::$blacklist); +} + +function setWhitelist($data, $root) +{ + merge(State::$whitelist, resolvePaths($data, $root)); +} + +function isWhitelisted($path) +{ + return isListed($path, State::$whitelist); +} + +function setCachePath($data, $root) +{ + if ($data === null) { + return; + } + $path = resolvePath($data, $root); + if (State::$cachePath !== null && State::$cachePath !== $path) { + throw new Exceptions\CachePathConflict(State::$cachePath, $path); + } + State::$cachePath = $path; +} + +function getDefaultRedefinableInternals() +{ + return [ + 'preg_replace_callback', + 'spl_autoload_register', + 'iterator_apply', + 'header_register_callback', + 'call_user_func', + 'call_user_func_array', + 'forward_static_call', + 'forward_static_call_array', + 'register_shutdown_function', + 'register_tick_function', + 'unregister_tick_function', + 'ob_start', + 'usort', + 'uasort', + 'uksort', + 'array_reduce', + 'array_intersect_ukey', + 'array_uintersect', + 'array_uintersect_assoc', + 'array_intersect_uassoc', + 'array_uintersect_uassoc', + 'array_uintersect_uassoc', + 'array_diff_ukey', + 'array_udiff', + 'array_udiff_assoc', + 'array_diff_uassoc', + 'array_udiff_uassoc', + 'array_udiff_uassoc', + 'array_filter', + 'array_map', + 'libxml_set_external_entity_loader', + ]; +} + +function getRedefinableInternals() +{ + if (!empty(State::$redefinableInternals)) { + return array_merge(State::$redefinableInternals, getDefaultRedefinableInternals()); + } + return []; +} + +function setRedefinableInternals($names) +{ + merge(State::$redefinableInternals, $names); + $constructs = array_intersect(State::$redefinableInternals, getSupportedLanguageConstructs()); + State::$redefinableLanguageConstructs = array_merge(State::$redefinableLanguageConstructs, $constructs); + State::$redefinableInternals = array_diff(State::$redefinableInternals, $constructs); +} + +function setNewKeywordRedefinability($value) +{ + State::$newKeywordRedefinable = State::$newKeywordRedefinable || $value; +} + +function getRedefinableLanguageConstructs() +{ + return State::$redefinableLanguageConstructs; +} + +function getSupportedLanguageConstructs() +{ + return array_keys(RedefinitionOfLanguageConstructs\getMappingOfConstructs()); +} + +function isNewKeywordRedefinable() +{ + return State::$newKeywordRedefinable; +} + +function getCachePath() +{ + return State::$cachePath; +} + +function resolvePath($path, $root) +{ + if ($path === null) { + return null; + } + if (file_exists($path) && realpath($path) === $path) { + return $path; + } + return realpath($root . '/' . $path); +} + +function resolvePaths($paths, $root) +{ + if ($paths === null) { + return []; + } + $result = []; + foreach ((array) $paths as $path) { + $result[] = resolvePath($path, $root); + } + return $result; +} + +function merge(array &$target, $source) +{ + $target = array_merge($target, (array) $source); +} + +function getTimestamp() +{ + return State::$timestamp; +} + +class State +{ + static $blacklist = []; + static $whitelist = []; + static $cachePath; + static $redefinableInternals = []; + static $redefinableLanguageConstructs = []; + static $newKeywordRedefinable = false; + static $timestamp = 0; +} diff --git a/vendor/antecedent/patchwork/src/Console.php b/vendor/antecedent/patchwork/src/Console.php new file mode 100644 index 000000000..466130d12 --- /dev/null +++ b/vendor/antecedent/patchwork/src/Console.php @@ -0,0 +1,57 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\Console; + +use Patchwork\CodeManipulation as CM; + +error_reporting(E_ALL | E_STRICT); + +$argc > 2 && $argv[1] == 'prime' + or exit("\nUsage: php patchwork.phar prime DIR1 DIR2 ... DIRn\n" . + " (to recursively prime all PHP files under given directories)\n\n"); + +try { + CM\cacheEnabled() + or exit("\nError: no cache location set.\n\n"); +} catch (Patchwork\Exceptions\CachePathUnavailable $e) { + exit("\nError: " . $e->getMessage() . "\n\n"); +} + +echo "\nCounting files...\n"; + +$files = []; + +foreach (array_slice($argv, 2) as $path) { + $path = realpath($path); + foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path)) as $file) { + if (substr($file, -4) == '.php' && !CM\internalToCache($file) && !CM\availableCached($file)) { + $files[] = $file; + } + } +} + +$count = count($files); + +$count > 0 or exit("\nNothing to do.\n\n"); + +echo "\nPriming ($count files total):\n"; + +const CONSOLE_WIDTH = 80; + +$progress = 0; + +for ($i = 0; $i < $count; $i++) { + CM\prime($files[$i]->getRealPath()); + while ((int) (($i + 1) / $count * CONSOLE_WIDTH) > $progress) { + echo '.'; + $progress++; + } +} + +echo "\n\n"; diff --git a/vendor/antecedent/patchwork/src/Exceptions.php b/vendor/antecedent/patchwork/src/Exceptions.php new file mode 100644 index 000000000..00c637a4c --- /dev/null +++ b/vendor/antecedent/patchwork/src/Exceptions.php @@ -0,0 +1,116 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\Exceptions; + +use Patchwork\Utils; + +abstract class Exception extends \Exception +{ +} + +class NoResult extends Exception +{ +} + +class StackEmpty extends Exception +{ + protected $message = "There are no calls in the dispatch stack"; +} + +abstract class CallbackException extends Exception +{ + function __construct($callback) + { + parent::__construct(sprintf($this->message, Utils\callableToString($callback))); + } +} + +class NotUserDefined extends CallbackException +{ + protected $message = 'Please include {"redefinable-internals": ["%s"]} in your patchwork.json.'; +} + +class DefinedTooEarly extends CallbackException +{ + + function __construct($callback) + { + $this->message = "The file that defines %s() was included earlier than Patchwork. " . + "This is likely a result of an improper setup; see readme for details."; + parent::__construct($callback); + } +} + +class InternalMethodsNotSupported extends CallbackException +{ + protected $message = "Methods of internal classes (such as %s) are not yet redefinable in Patchwork 2.1."; +} + +class InternalsNotSupportedOnHHVM extends CallbackException +{ + protected $message = "As of version 2.1, Patchwork cannot redefine internal functions and methods (such as %s) on HHVM."; +} + +class CachePathUnavailable extends Exception +{ + function __construct($location) + { + parent::__construct(sprintf( + "The specified cache path is inexistent or read-only: %s", + $location + )); + } +} + +class ConfigException extends Exception +{ +} + +class ConfigMalformed extends ConfigException +{ + function __construct($file, $message) + { + parent::__construct(sprintf( + 'The configuration file %s is malformed: %s', + $file, + $message + )); + } +} + +class ConfigKeyNotRecognized extends ConfigException +{ + function __construct($key, $list, $file) + { + parent::__construct(sprintf( + "The key '%s' in the configuration file %s was not recognized. " . + "You might have meant one of these: %s", + $key, + $file, + join(', ', $list) + )); + } +} + +class CachePathConflict extends ConfigException +{ + function __construct($first, $second) + { + parent::__construct(sprintf( + "Detected configuration files provide conflicting cache paths: %s and %s", + $first, + $second + )); + } +} + +class NewKeywordNotRedefinable extends ConfigException +{ + protected $message = 'Please set {"new-keyword-redefinable": true} to redefine instantiations'; +} diff --git a/vendor/antecedent/patchwork/src/Redefinitions/LanguageConstructs.php b/vendor/antecedent/patchwork/src/Redefinitions/LanguageConstructs.php new file mode 100644 index 000000000..661726612 --- /dev/null +++ b/vendor/antecedent/patchwork/src/Redefinitions/LanguageConstructs.php @@ -0,0 +1,76 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\Redefinitions\LanguageConstructs; + +function _echo($string) +{ + foreach (func_get_args() as $argument) { + echo $argument; + } +} + +function _print($string) +{ + return print($string); +} + +function _eval($code) +{ + return eval($code); +} + +function _die($message = null) +{ + die($message); +} + +function _exit($message = null) +{ + exit($message); +} + +function _isset(&$lvalue) +{ + return isset($lvalue); +} + +function _unset(&$lvalue) +{ + unset($lvalue); +} + +function _empty(&$lvalue) +{ + return empty($lvalue); +} + +function _require($path) +{ + return require($path); +} + +function _require_once($path) +{ + return require_once($path); +} + +function _include($path) +{ + return include($path); +} + +function _include_once($path) +{ + return include_once($path); +} + +function _clone($object) +{ + return clone $object; +} diff --git a/vendor/antecedent/patchwork/src/Stack.php b/vendor/antecedent/patchwork/src/Stack.php new file mode 100644 index 000000000..aab8f040d --- /dev/null +++ b/vendor/antecedent/patchwork/src/Stack.php @@ -0,0 +1,95 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\Stack; + +use Patchwork\Exceptions; + +function push($offset, $calledClass, array $argsOverride = null) +{ + State::$items[] = [$offset, $calledClass, $argsOverride]; +} + +function pop() +{ + array_pop(State::$items); +} + +function pushFor($offset, $calledClass, $callback, array $argsOverride = null) +{ + push($offset, $calledClass, $argsOverride); + try { + $callback(); + } catch (\Exception $e) { + $exception = $e; + } + pop(); + if (isset($exception)) { + throw $exception; + } +} + +function top($property = null) +{ + $all = all(); + $frame = reset($all); + $argsOverride = topArgsOverride(); + if ($argsOverride !== null) { + $frame["args"] = $argsOverride; + } + if ($property) { + return isset($frame[$property]) ? $frame[$property] : null; + } + return $frame; +} + +function topOffset() +{ + if (empty(State::$items)) { + throw new Exceptions\StackEmpty; + } + list($offset, $calledClass) = end(State::$items); + return $offset; +} + +function topCalledClass() +{ + if (empty(State::$items)) { + throw new Exceptions\StackEmpty; + } + list($offset, $calledClass) = end(State::$items); + return $calledClass; +} + +function topArgsOverride() +{ + if (empty(State::$items)) { + throw new Exceptions\StackEmpty; + } + list($offset, $calledClass, $argsOverride) = end(State::$items); + return $argsOverride; +} + +function all() +{ + $backtrace = debug_backtrace(); + return array_slice($backtrace, count($backtrace) - topOffset()); +} + +function allCalledClasses() +{ + return array_map(function($item) { + list($offset, $calledClass) = $item; + return $calledClass; + }, State::$items); +} + +class State +{ + static $items = []; +} diff --git a/vendor/antecedent/patchwork/src/Utils.php b/vendor/antecedent/patchwork/src/Utils.php new file mode 100644 index 000000000..a6c8e21c4 --- /dev/null +++ b/vendor/antecedent/patchwork/src/Utils.php @@ -0,0 +1,384 @@ + + * @copyright 2010-2018 Ignas Rudaitis + * @license http://www.opensource.org/licenses/mit-license.html + */ +namespace Patchwork\Utils; + +use Patchwork\Config; +use Patchwork\CallRerouting; +use Patchwork\CodeManipulation; + +const ALIASING_CODE = ' + namespace %s; + function %s() { + return call_user_func_array("%s", func_get_args()); + } +'; + +function clearOpcodeCaches() +{ + if (function_exists('opcache_reset')) { + opcache_reset(); + } + if (ini_get('wincache.ocenabled')) { + wincache_refresh_if_changed(); + } + if (ini_get('apc.enabled') && function_exists('apc_clear_cache')) { + apc_clear_cache(); + } +} + +function generatorsSupported() +{ + return version_compare(PHP_VERSION, "5.5", ">="); +} + +function runningOnHHVM() +{ + return defined("HHVM_VERSION"); +} + +function condense($string) +{ + return preg_replace('/\s*/', '', $string); +} + +function indexOfFirstGreaterThan(array $array, $value) +{ + $low = 0; + $high = count($array) - 1; + if (empty($array) || $array[$high] <= $value) { + return -1; + } + while ($low < $high) { + $mid = (int)(($low + $high) / 2); + if ($array[$mid] <= $value) { + $low = $mid + 1; + } else { + $high = $mid; + } + } + return $low; +} + +function indexOfLastNotGreaterThan(array $array, $value) +{ + if (empty($array)) { + return -1; + } + $result = indexOfFirstGreaterThan($array, $value); + if ($result === -1) { + $result = count($array) - 1; + } + while ($array[$result] > $value) { + $result--; + } + return $result; +} + +function firstGreaterThan(array $array, $value, $default = INF) +{ + $index = indexOfFirstGreaterThan($array, $value); + return ($index !== -1) ? $array[$index] : $default; +} + +function lastNotGreaterThan(array $array, $value, $default = INF) +{ + $index = indexOfLastNotGreaterThan($array, $value); + return ($index !== -1) ? $array[$index] : $default; +} + +function allWithinRange(array $array, $low, $high) +{ + $low--; + $high++; + $index = indexOfFirstGreaterThan($array, $low); + if ($index === -1) { + return []; + } + $result = []; + while ($index < count($array) && $array[$index] < $high) { + $result[] = $array[$index]; + $index++; + } + return $result; +} + +function interpretCallable($callback) +{ + if (is_object($callback)) { + return interpretCallable([$callback, "__invoke"]); + } + if (is_array($callback)) { + list($class, $method) = $callback; + $instance = null; + if (is_object($class)) { + $instance = $class; + $class = get_class($class); + } + $class = ltrim($class, "\\"); + return [$class, $method, $instance]; + } + if (substr($callback, 0, 4) === 'new ') { + return [ltrim(substr($callback, 4)), 'new', null]; + } + $callback = ltrim($callback, "\\"); + if (strpos($callback, "::")) { + list($class, $method) = explode("::", $callback); + return [$class, $method, null]; + } + return [null, $callback, null]; +} + +function callableDefined($callable, $shouldAutoload = false) +{ + list($class, $method, $instance) = interpretCallable($callable); + if ($instance !== null) { + return true; + } + if (isset($class)) { + return classOrTraitExists($class, $shouldAutoload) && + (method_exists($class, $method) || $method === 'new'); + } + return function_exists($method); +} + +function classOrTraitExists($classOrTrait, $shouldAutoload = true) +{ + return class_exists($classOrTrait, $shouldAutoload) + || trait_exists($classOrTrait, $shouldAutoload); +} + +function append(&$array, $value) +{ + $array[] = $value; + end($array); + return key($array); +} + +function appendUnder(&$array, $path, $value) +{ + foreach ((array) $path as $key) { + if (!isset($array[$key])) { + $array[$key] = []; + } + $array = &$array[$key]; + } + return append($array, $value); +} + +function access($array, $path, $default = null) +{ + foreach ((array) $path as $key) { + if (!isset($array[$key])) { + return $default; + } + $array = $array[$key]; + } + return $array; +} + +function normalizePath($path) +{ + return rtrim(strtr($path, "\\", "/"), "/"); +} + +function reflectCallable($callback) +{ + if ($callback instanceof \Closure) { + return new \ReflectionFunction($callback); + } + list($class, $method) = interpretCallable($callback); + if (isset($class)) { + return new \ReflectionMethod($class, $method); + } + return new \ReflectionFunction($method); +} + +function callableToString($callback) +{ + list($class, $method) = interpretCallable($callback); + if (isset($class)) { + return $class . "::" . $method; + } + return $method; +} + +function alias($namespace, array $mapping) +{ + foreach ($mapping as $original => $aliases) { + $original = ltrim(str_replace('\\', '\\\\', $namespace) . '\\\\' . $original, '\\'); + foreach ((array) $aliases as $alias) { + eval(sprintf(ALIASING_CODE, $namespace, $alias, $original)); + } + } +} + +function getUserDefinedCallables() +{ + return array_merge(get_defined_functions()['user'], getUserDefinedMethods()); +} + +function getRedefinableCallables() +{ + return array_merge(getUserDefinedCallables(), Config\getRedefinableInternals()); +} + +function getUserDefinedMethods() +{ + static $result = []; + static $classCount = 0; + static $traitCount = 0; + $classes = getUserDefinedClasses(); + $traits = getUserDefinedTraits(); + if (runningOnHHVM()) { + # cannot rely on the order of get_declared_classes() + static $previousClasses = []; + static $previousTraits = []; + $newClasses = array_diff($classes, $previousClasses); + $newTraits = array_diff($traits, $previousTraits); + $previousClasses = $classes; + $previousTraits = $traits; + } else { + $newClasses = array_slice($classes, $classCount); + $newTraits = array_slice($traits, $traitCount); + } + foreach (array_merge($newClasses, $newTraits) as $newClass) { + foreach (get_class_methods($newClass) as $method) { + $result[] = $newClass . '::' . $method; + } + } + $classCount = count($classes); + $traitCount = count($traits); + return $result; +} + +function getUserDefinedClasses() +{ + static $classCutoff; + $classes = get_declared_classes(); + if (!isset($classCutoff)) { + $classCutoff = count($classes); + for ($i = 0; $i < count($classes); $i++) { + if ((new \ReflectionClass($classes[$i]))->isUserDefined()) { + $classCutoff = $i; + break; + } + } + } + return array_slice($classes, $classCutoff); +} + +function getUserDefinedTraits() +{ + static $traitCutoff; + $traits = get_declared_traits(); + if (!isset($traitCutoff)) { + $traitCutoff = count($traits); + for ($i = 0; $i < count($traits); $i++) { + $methods = get_class_methods($traits[$i]); + if (empty($methods)) { + continue; + } + list($first) = $methods; + if ((new \ReflectionMethod($traits[$i], $first))->isUserDefined()) { + $traitCutoff = $i; + break; + } + } + } + return array_slice($traits, $traitCutoff); +} + +function matchWildcard($wildcard, array $subjects) +{ + $table = ['*' => '.*', '{' => '(', '}' => ')', ' ' => '', '\\' => '\\\\']; + $pattern = '/' . strtr($wildcard, $table) . '/i'; + return preg_grep($pattern, $subjects); +} + +function wildcardMatches($wildcard, $subject) +{ + return matchWildcard($wildcard, [$subject]) == [$subject]; +} + +function isOwnName($name) +{ + return stripos((string) $name, 'Patchwork\\') === 0 + && stripos((string) $name, CallRerouting\INTERNAL_REDEFINITION_NAMESPACE . '\\') !== 0; +} + +function isForeignName($name) +{ + return !isOwnName($name); +} + +function markMissedCallables() +{ + State::$missedCallables = array_map('strtolower', getUserDefinedCallables()); +} + +function getMissedCallables() +{ + return State::$missedCallables; +} + +function callableWasMissed($name) +{ + return in_array(strtolower($name), getMissedCallables()); +} + +function endsWith($haystack, $needle) +{ + if (strlen($haystack) === strlen($needle)) { + return $haystack === $needle; + } + if (strlen($haystack) < strlen($needle)) { + return false; + } + return substr($haystack, -strlen($needle)) === $needle; +} + +function wasRunAsConsoleApp() +{ + global $argv; + return isset($argv) && ( + endsWith($argv[0], 'patchwork.phar') || endsWith($argv[0], 'Patchwork.php') + ); +} + +function getParameterAndArgumentLists(\ReflectionMethod $reflection = null) +{ + $parameters = []; + $arguments = []; + if ($reflection) { + foreach ($reflection->getParameters() as $p) { + $parameter = '$' . $p->name; + if ($p->isOptional()) { + try { + $value = var_export($p->getDefaultValue(), true); + } catch (\ReflectionException $e) { + $value = var_export(CallRerouting\INSTANTIATOR_DEFAULT_ARGUMENT, true); + } + $parameter .= ' = ' . $value; + } + $parameters[] = $parameter; + $arguments[] = '$' . $p->name; + } + } + return [join(', ' , $parameters), join(', ', $arguments)]; +} + +function args() +{ + return func_get_args(); +} + +class State +{ + static $missedCallables = []; +} diff --git a/vendor/brain/monkey/.gitattributes b/vendor/brain/monkey/.gitattributes new file mode 100644 index 000000000..07eb7762c --- /dev/null +++ b/vendor/brain/monkey/.gitattributes @@ -0,0 +1,5 @@ +# Auto detect text files and perform LF normalization +text eol=lf + +tests/ export-ignore +.travis.yml export-ignore diff --git a/vendor/brain/monkey/.gitignore b/vendor/brain/monkey/.gitignore new file mode 100644 index 000000000..f706e713a --- /dev/null +++ b/vendor/brain/monkey/.gitignore @@ -0,0 +1,6 @@ +vendor/ +/composer.lock +/phpunit.xml +website/ +couscous-theme/ +couscous.* \ No newline at end of file diff --git a/vendor/brain/monkey/LICENSE b/vendor/brain/monkey/LICENSE new file mode 100644 index 000000000..48ba0d9d6 --- /dev/null +++ b/vendor/brain/monkey/LICENSE @@ -0,0 +1,19 @@ +The MIT License (MIT) + +Copyright (c) 2017 Giuseppe Mazzapica + +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. \ No newline at end of file diff --git a/vendor/brain/monkey/README.md b/vendor/brain/monkey/README.md new file mode 100644 index 000000000..944a1494a --- /dev/null +++ b/vendor/brain/monkey/README.md @@ -0,0 +1,46 @@ + + +# Brain Monkey + +[![Travis CI status](https://travis-ci.org/Brain-WP/BrainMonkey.svg?branch=master)](https://travis-ci.org/Brain-WP/BrainMonkey) + +Brain Monkey is a tests utility for PHP. + +It provides **two set of helpers**: + + - the first are framework-agnostic tools that allow to mock (or *monkey patch*) and to test behavior of any **PHP function** + - the second are **specific to WordPress** and make unit testing of WordPress extensions a no-brainer. + +# Requirements + + - PHP 5.6+ + - [Composer](https://getcomposer.org/) to install + +Via Composer following packages are required: + + - [mockery/mockery](https://packagist.org/packages/mockery/mockery) version 1 (BSD-3-Clause) + - [antecedent/patchwork](https://packagist.org/packages/antecedent/patchwork) version 2 (MIT) + +When installed for development, following packages are also required: + + - [phpunit/phpunit](https://packagist.org/packages/phpunit/phpunit) version 5.7 (BSD-3-Clause) + + +# License + +Brain Monkey is open source and released under MIT license. See LICENSE file for more info. + + +# Question? Issues? + +Brain Monkey is hosted on GitHub. Feel free to open issues there for suggestions, questions and real issues. + + +# Who's Behind + +I'm Giuseppe, I deal with PHP since 2005. For questions, rants or chat ping me on Twitter ([@gmazzap](https://twitter.com/gmazzap)) +or on ["The Loop"](http://chat.stackexchange.com/rooms/6/the-loop) (Stack Exchange) chat. + +Well, it's possible I'll ignore rants. \ No newline at end of file diff --git a/vendor/brain/monkey/composer.json b/vendor/brain/monkey/composer.json new file mode 100644 index 000000000..146a43cb2 --- /dev/null +++ b/vendor/brain/monkey/composer.json @@ -0,0 +1,65 @@ +{ + "name": "brain/monkey", + "description": "Mocking utility for PHP functions and WordPress plugin API", + "keywords": [ + "testing", + "test", + "mockery", + "patchwork", + "mock", + "mock functions", + "runkit", + "redefinition", + "monkey patching", + "interception" + ], + "authors": [ + { + "name": "Giuseppe Mazzapica", + "email": "giuseppe.mazzapica@gmail.com", + "homepage": "https://gmazzap.me", + "role": "Developer" + } + ], + "support": { + "issues": "https://github.com/Brain-WP/BrainMonkey/issues", + "source": "https://github.com/Brain-WP/BrainMonkey" + }, + "license": "MIT", + "require": { + "php": ">=5.6.0", + "mockery/mockery": ">=0.9 <2", + "antecedent/patchwork": "^2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.9" + }, + "autoload": { + "psr-4": { + "Brain\\Monkey\\": "src/" + }, + "files": [ + "inc/api.php" + ] + }, + "autoload-dev": { + "psr-4": { + "Brain\\Monkey\\Tests\\": "tests/src/" + }, + "files": [ + "inc/wp-helper-functions.php", + "inc/wp-hook-functions.php" + ] + }, + "minimum-stability": "dev", + "prefer-stable": true, + "config": { + "optimize-autoloader": true + }, + "extra": { + "branch-alias": { + "dev-version/1": "1.x-dev", + "dev-master": "2.0.x-dev" + } + } +} diff --git a/vendor/brain/monkey/docs/functions-expect.md b/vendor/brain/monkey/docs/functions-expect.md new file mode 100644 index 000000000..0f3a41e1a --- /dev/null +++ b/vendor/brain/monkey/docs/functions-expect.md @@ -0,0 +1,145 @@ + +# Testing functions with expect() + +Often, in tests, what we need is not only to enforce a function returned value (what `Functions\when()` allows to do), but to test function behavior based on **expectations**. + +Mockery has a very powerful, and human readable Domain Specific Language (DSL) that allows to set expectations on how object methods should behave, e.g. validate arguments they should receive, how many times they are called, and so on. + +Brain Monkey brings that power to function testing. The entry-point is the `Functions\expect()` function. + +It receives a function name and returns a Mockery expectation object with all its power. + +Below there are just several examples, for the full story about Mockery expectations see its [documentation](http://docs.mockery.io/en/latest/reference/index.html). + +Only note that in functions testing the `shouldReceive` Mockery method makes **no sense**, so don't use it (an exception will be thrown if you do that). + + + + +## Expectations on times a function is called + +```php +Functions\expect('paganini')->once(); + +Functions\expect('tween')->twice(); + +Functions\expect('who_knows')->zeroOrMoreTimes(); + +Functions\expect('i_should_run')->atLeast()->once(); + +Functions\expect('i_have_a_max')->atMost()->twice(); + +Functions\expect('poor_me')->never(); + +Functions\expect('pretty_precise')->times(3); + +Functions\expect('i_have_max_and_min')->between(2, 4); +``` + +There is no need to explain how it works: Mockery DSL reads like plain English. + +Of course, expectation on the times a function should run can be combined with arguments expectation. + + + +## Expectations on received arguments + +Below a few examples, for the full story see [Mockery docs](http://docs.mockery.io/en/latest/reference/argument_validation.html). + +```php +// allow anything +Functions\expect('function_name') + ->once() + ->withAnyArgs(); + +// allow nothing +Functions\expect('function_name') + ->once() + ->withNoArgs(); + +// validate specific arguments +Functions\expect('function_name') + ->once() + ->with('arg_1', 'arg2'); + +// validate specific argument types +Functions\expect('function_name') + ->times(3) + ->with(Mockery::type('resource'), Mockery::type('int')); + +// validate anything in specific places +Functions\expect('function_name') + ->zeroOrMoreTimes() + ->with(Mockery::any()); + +// validate a set of given arguments +Functions::expect('function_name') + ->once() + ->with(Mockery::anyOf('a', 'b', 'c')); + +// regex validation +Functions\expect('function_name') + ->once() + ->with('/^foo/'); + +// excluding specific values +Functions\expect('function_name') + ->once() + ->with(Mockery::not(2, 3)); + +// dealing with array arguments +Functions\expect('function_name') + ->once() + ->with(Mockery::hasKey('foo'), Mockery::contains('bar', 'baz')); +``` + + + +## Forcing behavior + +Excluding `shouldReceive`, all the Mockery expectation methods can be used with Brain Monkey, including +`andReturn` or `andReturnUsing` used to enforce a function to return specific values during tests. + +In fact, `Functions\when()` do same thing for simple cases when no expectations are required. + +Again, just a few examples: + +```php +// return a specific value +Functions\expect('function_name') + ->once() + ->with('foo', 'bar') + ->andReturn('Baz!'); + +// return values in order +Functions\expect('function_name') + ->twice() + ->andReturn('First time I run', 'Second time I run'); + +// return values in order, alternative +Functions\expect('function_name') + ->twice() + ->andReturnValues(['First time I run', 'Second time I run']); + +// return noting +Functions::expect('function_name') + ->twice() + ->andReturnNull(); + +// use a callback for returning a value +Functions\expect('function_name') + ->atLeast() + ->once() + ->andReturnUsing(function() { + return 'I am an alias!'; + }); + +// makes function throws an Exception (e.g. to test try statements) +Functions\expect('function_name') + ->once() + ->andThrow('RuntimeException'); // Both exception names and object are supported +``` \ No newline at end of file diff --git a/vendor/brain/monkey/docs/functions-setup.md b/vendor/brain/monkey/docs/functions-setup.md new file mode 100644 index 000000000..90439d0c1 --- /dev/null +++ b/vendor/brain/monkey/docs/functions-setup.md @@ -0,0 +1,96 @@ + +# Testing PHP Functions: Setup Brain Monkey + + + +## Testing framework agnostic + +Brain Monkey can be used with any testing framework. + +Examples in this page will use PHPUnit, but the concepts are applicable at any testing framework. + + + +## Warning + +Brain Monkey uses [Patchwork](http://antecedent.github.io/patchwork/) to redefine functions. + +Brain Monkey 2.* requires Patchwork 2 which allows to re-define both userland and core functions, +with some [limitations](http://patchwork2.org/limitations/). + +The main limitations that affects Brain Monkey are (from Patchwork website): + +- _Patchwork will fail on every attempt to redefine an internal function that is missing from the redefinable-internals array of your `patchwork.json`._ +- _Make sure that Patchwork is imported as early as possible, since any files imported earlier, including the one from which the importing takes place, will be missed by Patchwork's code preprocessor._ + + + + +## Setup tests + +After Brain Monkey is part of the project (see *Getting Started / Installation*), to be able to use its features +two simple steps are needed before being able to use Brain Monkey in tests: + +1. be sure to require Composer autoload file _before_ running tests (e.g. PHPUnit users will probably require it in their bootstrap file). +2. call the function `Brain\Monkey\tearDown()` after any test + + + + +### PHPUnit example + +Let's take PHPUnit as example, the average test case class that uses Brain Monkey would be something like: + +```php +use PHPUnit_Framework_TestCase; +use Brain\Monkey; + +class MyTestCase extends PHPUnit_Framework_TestCase +{ + + protected function tearDown() + { + Monkey\tearDown(); + parent::tearDown(); + } +} +``` + +After that for all test classes can extend this class instead of directly extending `PHPUnit_Framework_TestCase`. + +That's all. Again, I used PHPUnit for the example, but any testing framework can be used. + +For function mocking and testing there are two entry-point functions: + +- **`Functions\when()`** +- **`Functions\expect()`** + +See dedicated documentation pages. + + + +## Namespaced functions + +All the code examples in this documentation make use of functions in global namespace. + +However, note that namespaced functions are supported as well, just be sure to pass the fully qualified name of the functions: + +```php +Functions\expect('a_global_function'); + +Functions\expect('My\\App\\awesome_function'); +``` + + + +## Note for WordPressers + +Anything said in this page is fine for WordPress functions too, they are PHP functions, after all. + +However, Brain Monkey has specific features for WordPress, and there is a way to setup tests for **all** Brain Monkey features (WordPress-specific and not). + +**If you want to use Brain Monkey to test code wrote for WordPress, it is preferable to use the setup explained in the *"WordPress / Setup"* section that *includes* the setup needed to use Brain Monkey tools for functions.** \ No newline at end of file diff --git a/vendor/brain/monkey/docs/functions-stubs.md b/vendor/brain/monkey/docs/functions-stubs.md new file mode 100644 index 000000000..f35968740 --- /dev/null +++ b/vendor/brain/monkey/docs/functions-stubs.md @@ -0,0 +1,135 @@ + +# Bulk patching with stubs() + +`when()` and its related functions are quite simple and straightforward. + +However, it can be quite verbose when multiple functions needed to be patched. + +When one uses `when()` they are not interested in adding expectations but usually are +interested in ensuring the target function is defined, and maybe its return value. + +For this reason, version 2.1 introduced a new API function to define multiple functions in bulk: `stubs()` + +## `stubs()` + +`Functions\stubs()` accepts an array of functions to be defined. + +The function names can be passed as array item _keys_ or as array item _values_ and no key. + +When the function name is the item key, the item value can be either: + +- a `callable`, in which case the function will be aliased to it +- anything else, in which case a stub returning a given value will be created for the function + +Example: + +```php +Functions\stubs([ + 'is_user_logged_in' => true, + 'current_user_can' => true, + 'wp_get_current_user' => function() { + return \Mockery::mock('\WP_User'); + } +]); +``` + +When the function name is the array item value, and no item key is used, the behavior will change +based on the second argument passed to `stubs()`: + +- when the second argument is `null` (default), the created stub will return the first parameter it would receive +- when the second argument is anything else, the created stub will use it as its return value + + +Example: + +```php +// Given functions will return `true` +Functions\stubs( + [ + 'is_user_logged_in', + 'current_user_can', + ], + true +); + +// Given functions will return the first argument they would receive, +// just like `when( $function_name )->justReturnArg()` was used for all of them. +Functions\stubs( + [ + 'esc_attr', + 'esc_html', + 'esc_textarea', + '__', + '_x', + 'esc_html__', + 'esc_html_x', + 'esc_attr_x', + ] +); +``` + +### Gotcha + +When passing a function name as an array item key and a `callable` as the value, the function +will be aliased to that callable. That means it is **not** possible to create a stub +for a function that returns a callback, by doing something like: + +```php +Functions\stubs( + [ + 'function_that_returns_a_callback' => 'the_expected_returned_callback' + ] +); +``` + +But this will work: + +```php +Functions\stubs( + [ + 'function_that_returns_a_callback' => function() { + return 'the_expected_returned_callback'; + } + ] +); +``` + +Moreover, when doing something like this: + +```php +Functions\stubs( + [ 'function_that_returns_null' => null ] +); +``` + +or like this: + +```php +Functions\stubs( + [ 'function_that_returns_null' ], + null +); +``` + + +the return value of the stub will **not** be `null`, because when return value is set to `null` +Brain Monkey will make the function stub return the first received value. + +The only way to use `stubs()` for creating a stub that returns `null` is: + +```php +Functions\stubs( + [ 'function_that_returns_null' => function() { return null; } ] +); +``` + +or the equivalent but more concise: + +```php +// __return_null is defined by Brain Monkey since version 2 +Functions\stubs( [ 'function_that_returns_null' => '__return_null' ] ); +``` diff --git a/vendor/brain/monkey/docs/functions-when.md b/vendor/brain/monkey/docs/functions-when.md new file mode 100644 index 000000000..943d4bc84 --- /dev/null +++ b/vendor/brain/monkey/docs/functions-when.md @@ -0,0 +1,115 @@ + +# Patching functions with when() + +The first way Brain Monkey offers to monkey patch a function is `Functions\when()`. + +This function has to be used to **set a behavior** for functions. + +`when()` and 5 related methods are used to define functions (if not defined yet) and: + + - make them return a specific value + - make them return one of the received arguments + - make them echo a specific value + - make them echo one of the received arguments + - make them behave just like another callback + + +For the sake of readability, in all the code samples below I'll assume that an `use` statement is in place: + +```php +use Brain\Monkey\Functions; +``` + +Don't forget to add it in your code as well, or use the fully qualified class name. + +Also be sure to read the *PHP Functions / Setup* section that explain how setup Brain Monkey for usage in tests. + + + + +## `justReturn()` + +By using `when()` in combination with `justReturn()` you can make a (maybe) undefined function *just return* a given value: + + +```php +Functions\when('a_undefined_function')->justReturn('Cool!'); + +echo a_undefined_function(); // echoes "Cool!" +``` + +Without passing a value to `justReturn()` the target function will return nothing (`null`). + + + + +## `returnArg()` + +This other `when`-related method is used to make the target function return one of the received arguments, by default the first. + +```php +Functions\when('give_me_the_first')->returnArg(); // is the same of ->returnArg(1) +Functions\when('i_want_the_second')->returnArg(2); +Functions\when('and_the_third_for_me')->returnArg(3); + +echo give_me_the_first('A', 'B', 'C'); // echoes "A" +echo i_want_the_second('A', 'B', 'C'); // echoes "B" +echo and_the_third_for_me('A', 'B', 'C'); // echoes "C" +``` + +Note that if the target function does not receive the desired argument, `returnArg()` throws an exception: + +```php +Functions\when('needs_the_third')->returnArg(3); + +// throws an exception because required 3rd argument, but received 2 +echo needs_the_third('A', 'B'); +``` + + + +## `justEcho()` + +Similar to `justReturn()`, it makes the mocked function echo some value instead of returning it. + +```php +Functions\when('a_undefined_function')->justEcho('Cool!'); + +a_undefined_function(); // echoes "Cool!" +``` + + + +## `echoArg()` + +Similar to `returnArg()`, it makes the mocked function echo some received argument instead of returning it. + +```php +Functions\when('echo_the_first')->echoArg(); // is the same of ->echoArg(1) +Functions\when('echo_the_second')->echoArg(2); + +echo_the_first('A', 'B', 'C'); // echoes "A" +echo_the_second('A', 'B', 'C'); // echoes "B" +``` + + + +## `alias()` + +The last of the when-related methods allows to make a function behave just like another callback. +The replacing function can be anything that can be run: a core function or a custom one, a class method, a closure... + +```php +Functions\when('duplicate')->alias(function($value) { + "Was ".$value.", now is ".($value * 2); +}); + +Functions\when('bigger')->alias('strtoupper'); + +echo duplicate(1); // echoes "Was 1, now is 2" +echo bigger('was lower'); // echoes "WAS LOWER" +``` \ No newline at end of file diff --git a/vendor/brain/monkey/docs/installation.md b/vendor/brain/monkey/docs/installation.md new file mode 100644 index 000000000..e7063b42c --- /dev/null +++ b/vendor/brain/monkey/docs/installation.md @@ -0,0 +1,50 @@ + +# Installation + +To install Brain Monkey you need: + + - PHP 5.6+ + - [Composer](https://getcomposer.org) + +Brain Monkey is available on Packagist, so the only thing you need to do is to add it as a dependency for your project. + +That can be done by running following command in your project folder: + +```shell +composer require brain/monkey:2.* --dev +``` + +As alternative you can directly edit your `composer.json` by adding: + +```json +{ + "require-dev": { + "brain/monkey": "~2.0.0" + } +} +``` + +I've used `require-dev` because, being a testing tool, Brain Monkey should **not** be included in production. + +Brain Monkey can work with any testing framework, so it doesn't require any of them. + +To run your tests you'll probably need to require a testing framework too, e.g. [PHPUnit](https://phpunit.de/) or [phpspec](http://www.phpspec.net/en/latest/). + + + +## Dependencies + +Brain Monkey needs 2 libraries to work: + + - [Mockery](http://docs.mockery.io/en/latest/) (BSD-3-Clause) + - [Patchwork](http://antecedent.github.io/patchwork/) (MIT) + +They will be installed for you by Composer. + +When installed in development mode (to test itself), Brain Monkey also requires: + + - [PHPUnit](https://phpunit.de/) (MIT) \ No newline at end of file diff --git a/vendor/brain/monkey/docs/migrating-from-v1.md b/vendor/brain/monkey/docs/migrating-from-v1.md new file mode 100644 index 000000000..dd94cc3ee --- /dev/null +++ b/vendor/brain/monkey/docs/migrating-from-v1.md @@ -0,0 +1,473 @@ + +# Migrating From v1 To v2 + + + +## [Updated] Patchwork Version + +Patchwork has been updated to version 2. This new version allows to redefine PHP core functions and +not only custom defined functions. (There are limitations, see http://patchwork2.org/limitations/). + +This new Patchwork version seems to also fix an annoying issue with undesired Patchwork cache. + +--- + + + +## [Changed] Setup Functions - BREAKING! + +On version 1 of Brain Monkey there where 4 static methods dedicated to setup: + +- `Brain\Monkey::setUp()` -> before each test that use only functions redefinition (no WP features) +- `Brain\Monkey::tearDown()` -> after each test that use only functions redefinition (no WP features) +- `Brain\Monkey::setUpWp()` -> before each test that use functions redefinition and WP features +- `Brain\Monkey::tearDownWp()` -> after each test that use functions redefinition and WP features + + +This has been simplified, in fact, **only two setup functions exists in Brain Monkey v2**: + +- `Brain\Monkey\setUp()` -> before each test that use functions redefinition and WP features +- `Brain\Monkey\tearDown()` -> after each test, no matter if for functions redefinition or for also + WP features + + +Which means that for function redefinitions, only `Brain\Monkey\tearDown()` have to be called after +each test, and nothing _before_ each test. + +To also use WP features, `Brain\Monkey\setUp()` have also to called before each test. + +--- + + + +## [Changed] New API - BREAKING! + +Big part of Brain Monkey is acting as a "bridge" between Mockery an Patchwork, that is, make Mockery +DSL for expectations available for functions and WordPress hooks. + +To access the Mockery API, Brain Monkey v1 provided two different methods: + +1. using static methods on the `Brain\Monkey` class +2. using static methods on one of the three feature-specific classes `Brain\Monkey\Functions`, + `Brain\Monkey\WP\Actions` or `Brain\Monkey\WP\Filters` + +For example: + +```php +// Brain Monkey v1 method one +Brain\Monkey::functions::expect('some_function'); +Brain\Monkey::actions()->expectAdded('init'); +Brain\Monkey::filters()->expectApplied('the_title'); + +// Brain Monkey v1 method two +Brain\Monkey\Functions::expect('some_function'); +Brain\Monkey\WP\Actions::expectAdded('init'); +Brain\Monkey\WP\Filters::expectApplied('the_title'); +``` + +In Brain Monkey v2 there's only one method, that makes use of **functions**: + +```php +// Brain Monkey v2 +Brain\Monkey\Functions\expect('some_function'); +Brain\Monkey\Actions\expectAdded('init'); +Brain\Monkey\Filters\expectApplied('the_title'); +``` + + + +#### Renamed method for done actions + +For WordPress filters, there were in Brain Monkey v1 two methods: + +- `Filters::expectAdded()` +- `Filters::expectApplied()` + +named after the WordPress functions `add_filter()` / `apply_filters()` + +But for actions there were: + +- `Actions::expectAdded()` +- `Actions::expectFired()` + +`expectAdded()` pairs with `add_action()`, but `expectFired()` does not really pair with +`do_action()`: this is why in Brain Monkey v2 **the method `expectFired()` has been replaced by the +function `expectDone()`**. + +So, in version 2 there are total of 5 entry-point **functions** to Mockery API: + +- `Brain\Monkey\Functions\expect()` +- `Brain\Monkey\Actions\expectAdded()` +- `Brain\Monkey\Actions\expectDone()` +- `Brain\Monkey\Filters\expectAdded()` +- `Brain\Monkey\Filters\expectApplied()` + +--- + + + +## [Changed] Default Expectations Behavior - BREAKING! + +In Brain Monkey v1, expectation on the "times" an expected event happen was required. + +```php +class MyClass { + + public function doSomething() { + return true; + } +} + + +class MyClassTest extends MyTestCase { + + // this test passes in Brain Monkey v1 + public function testSomething() { + \Brain\Monkey\WP\Actions::expectAdded('init'); // this has pretty much no effect + $class = new MyClass(); + self::assertTrue($class->doSomething()); + } +} +``` + +This **test passed in Brain Monkey v1**, because even if `Actions::expectAdded()` was used, the test +does not fail unless something like `Actions::expectAdded('init')->once()` was used, which made the +test pass only if `add_action( 'init' )` was called once. + +The reason is that Mockery default behavior is to add a `->zeroOrMoreTimes()` as expectation on number +of times a method is called, so when the expectation is called *zero times*, that's a valid outcome. + +This was somehow confusing (because reading `expectAdded` one could *expect* the test to fail if that +thing did not happened), and also made tests unnecessarily verbose. + +**Brain Monkey v2, set Mockery expectation default to `->atLeast()->once()`** so, for example, +the test above fails in Brain Monkey v2 if `MyClass::doSomething()` does not call `add_action('init')` +at least once. + +--- + + + +## [Changed] Closure String Representation - BREAKING! + +Brain Monkey allows to do some basic tests using `has_action()` / `has_filter()`, functions, to test +if some portion of code have added some hooks. + +A "special" syntax, was already added in Brain Monkey v1 to permit the checking for hooks added using +object instances as part of the hook callback, without having any reference to those objects. + +For example, assuming a function like: + +```php +namespace A\Name\Space; + +function test() { + + add_action('example_one', [new SomeClass(), 'aMethod']); + + add_action('example_two', function(array $foo) { /* ... */ }); +} +``` + +could be tested with in Brain Monkey v1 with: + +```php +// Brain Monkey v1: +test(); +self::assertTrue(has_action('example_one', 'A\Name\Space\SomeClass->aMethod()')); // pass +self::assertTrue(has_action('example_two', 'function()')); // pass +``` + +The syntax for string representation of callbacks including objects is unchanged in Brain Monkey v2, +however, **the syntax for closures string representation has been changed to allow more fine grained +control**. + +In fact, in Brain Monkey v1 *all* the closures were represented as the string `"function()"`, +in Brain Monkey v2 closure string representations also contain the parameters used in the closure +signature: + +```php +// Brain Monkey v2: +test(); +self::assertTrue(has_action('example_one', 'A\Name\Space\SomeClass->aMethod()')); // pass +self::assertTrue(has_action('example_two', 'function()')); // fail! +self::assertTrue(has_action('example_two', 'function(array $foo)')); // pass! +``` + +The closure string representation *does* take into account: + +- name of the parameters +- parameters type hints (works with PHP 7+ scalar type hints) +- variadic arguments +- `static` closures VS normal closures + +*does not* take into account: + +- PHP 7 return type declaration +- parameters defaults +- content of the closure + +For example: + +```php +namespace A\Name\Space; + +$closure_1 = static function( array $foo, SomeClass $bar, int ...$ids ) : bool { /* */ } + +$closure_2 = function( array $foo, SomeClass $bar, array $ids = [] ) : bool { /* */ } + +// $closure_1 is represented as: +"static function ( array $foo, A\Name\Space\SomeClass $bar, int ...$ids )"; + +// $closure_2 is represented as: +"function ( array $foo, A\Name\Space\SomeClass $bar, array $ids )"; +``` + +Note how type-hints using classes always have fully qualified names in string representation. + +--- + + + +## [Changed] Relaxed `callable` check + +In Brain Monkey v1 methods and functions that accept a `callable` like, for example, second argument +to `add_action()` / `add_filter()`, checked the received argument to be an actual callable PHP +entity, using `is_callable`: + +```php +// this fail in Brain Monkey v1 if `SomeClass` was not available +// or if SomeClass::aMethod would not be a valid method +add_action( 'foo', [ SomeClass::class, 'aMethod' ] ); + +// this fail in Brain Monkey v1 if `Some\Name\Space\aFunction` is not available +add_action( 'bar', 'Some\Name\Space\aFunction' ); +``` + +For these reasons, it was often required to create a mock for unavailable classes or functions just +to don't make Brain Monkey throw an exception, even if the mock was not used and not relevant for the +test. + +Brain Monkey v2 is less strict on checking for `callable` and it accepts anything that _looks like_ +a callable. + +Something like `[SomeClass::class, 'aMethod']` would be accepted even if `SomeClass` is not loaded +at all, because *it looks like* a callable. Same goes for `'Some\Name\Space\aFunction'`. + +However, something like `[SomeClass::class, 'a-Method']` or `[SomeClass::class, 'aMethod', 1]` +or even `Some\Name\Space\a Function` will throw an exception because method and function names can't +contain hyphens or spaces and when a callback is made of an array, it must have exactly two arguments. + +This more "relaxed" check allows to save creation of mocks that are not necessary for the logic of +the test. + +It worth noting that when doing something like `[SomeClass::class, 'aMethod']` **if** the class +`SomeClass` is available, Brain Monkey checks it to have an accessible method named `aMethod`, and +raise an exception if not, but will not do any check if the class is not available. + +The same applies when object instances are used for callbacks, for example, using as callback argument +`[$someObject, 'aMethod']`, the instance of `$someObject` is checked to have an accessible method +named `aMethod`. + +--- + + + +## [Fixed] `apply_filters` Default Behavior + +The WordPress function `apply_filters()` is defined by Brain Monkey and it returns the first argument +passed to it, just like WordPress: + +```php +self::assertSame('Foo', apply_filters('a_filter', 'Foo', 'Bar')); // pass! +``` + +In Brain Monkey v1 this was true *unless* some expectation was added to the applied filter: + +```php +Brain\Monkey\WP\Filters::expectApplied('a_filter'); + +self::assertSame('Foo', apply_filters('a_filter', 'Foo', 'Bar')); // fails in v1 +``` + +**The test above fails in Brain Monkey v1**. The reason is that even if the expectation in first line +is validated, it breaks the default `apply_filters` behavior, requiring the return value to be added +to expectation to make the test pass again. + +For example, the following test used to pass in Brain Monkey v1: + +```php +Brain\Monkey\WP\Filters::expectApplied('a_filter')->andReturn('Foo'); + +self::assertSame('Foo', apply_filters('a_filter', 'Foo', 'Bar')); // pass +``` + +**In Brain Monkey v2 this is not necessary anymore.** + +Calling `expectApplied` on applied filters does **not** break the default behavior of `apply_filters` +behavior, if no return expectations are added. + +The following test **passes in Brain Monkey v2**: + +```php +Brain\Monkey\Filters\expectApplied('a_filter')->once()->with('Foo', 'Bar'); + +self::assertSame('Foo', apply_filters('a_filter', 'Foo', 'Bar')); // pass in v2! +``` + +Please note that if any return expectation is added for a filter, return expectations must be added +for all the set of arguments the filter might receive. + +For example: + +```php +Brain\Monkey\Filters\expectApplied('a_filter')->once()->with('Foo')->andReturn('Foo!'); +Brain\Monkey\Filters\expectApplied('a_filter')->once()->with('Bar'); + +self::assertSame('Foo!', apply_filters('a_filter', 'Foo')); // pass +self::assertSame('Bar', apply_filters('a_filter', 'Bar')); // fail! +``` + +The second assertion fails because since we added a return expectation for the filter "'a_filter'" +we need to add return expectation for _all_ the possible arguments. + +This task is easier in Brain Monkey v2 thanks to the introduction of `andReturnFirstArg()` expectation +method (more on this below). + +For example: + +```php +Brain\Monkey\Filters\expectApplied('a_filter')->once()->with('Foo')->andReturn('Foo!'); +Brain\Monkey\Filters\expectApplied('a_filter')->zeroOrMoreTimes()->withAnyArgs()->andReturnFirstArg(); + +self::assertSame('Foo', apply_filters('a_filter', 'Foo', 'Bar')); // pass +self::assertSame('Bar', apply_filters('a_filter', 'Bar')); // pass! +``` + +`andReturnFirstArg()` used in combination with Mockery methods `zeroOrMoreTimes()->withAnyArgs()` +allows to create a "catch all" behavior for filters when a return expectation has been added, without +having to create specific expectations for each of the possible arguments a filter might receive. + +Of course, adding specific expectations for each of the possible arguments a filter might receive is +still possible. + +--- + + + +## [Added] Utility Functions Stubs + +There are WordPress functions that are often used in WordPress plugins or themes that are pretty much +*logicless*, but still they need to be mocked in tests if WordPress is not available. + +Brain Monkey v2 now ships stubs for those functions, so it is not necessary to mock them anymore, +they are: + +- `__return_true` +- `__return_false` +- `__return_null` +- `__return_empty_array` +- `__return_empty_string` +- `__return_zero` +- `trailingslashit` +- `untrailingslashit` + +Those functions do exactly what they are expected to do, even if WordPress is not loaded: some +functions mocking is now saved. + +Of course, their behavior can still be mocked, e.g. to make a test fail on purpose. + +--- + + + +## [Added] Support for `doing_action()` and `doing_filter()` + +When adding expectation on returning value of filters, or when using `whenHappen` to respond to +actions, inside the expectation callback, the function `current_filter()` in Brain Monkey v1 used to +correctly resolve to the action / filter being executed. + +The functions `doing_action()` and `doing_filter()` didn't work: they were not provided at all with +Brain Monkey v1 and required to be mocked "manually" . + +In Brain Monkey v2 those two functions are provided as well, and correctly return true or false when +used inside the callbacks used to respond to hooks. + +--- + + + +## [Added] Method `andReturnFirstArg()` + +When adding expectations on returning value of applied filters or functions, it is now possible to +use `andReturnFirstArg()` to make the Mockery expectations return first argument received. + +```php +// Brain\Monkey v2: +Brain\Monkey\Functions\expect('foo')->andReturnFirstArg(); +Brain\Monkey\Filters\expectApplied('the_title')->andReturnFirstArg(); + + +// Brain\Monkey v1: +Brain\Monkey\Functions\expect('foo')->andReturnUsing(function($arg) { + return $arg; +}); + +Brain\Monkey\Filters\expectApplied('the_title')->andReturnUsing(function($arg) { + return $arg; +}); +``` + +--- + + + +## [Added] Method `andAlsoExpectIt()` + +In Mockery, when creating expectations for multiple methods of same class, the method `getMock()` +allows to do it without leaving "fluent interface chain", for example: + +```php +Mockery\mock(SomeClass::class) + ->shouldReceive('exclamation')->with('Foo')->once()->andReturn('Foo!') + ->getMock() + ->shouldReceive('question')->with('Bar')->once()->andReturn('Bar?') + ->getMock() + ->shouldReceive('invert')->with('Baz')->once()->andReturn('zaB') +``` + +The method `getMock()` is **not** available for Brain Monkey expectations. + +For this reason has been introduced `andAlsoExpectIt()`: + +```php +Brain\Monkey\Filters\expectApplied('some_filter') + ->once()->with('Hello')->andReturn('Hello!') + ->andAlsoExpectIt() + ->atLeast()->twice()->with('Hi')->andReturn('Hi!') + ->andAlsoExpectIt() + ->zeroOrMoreTimes()->withAnyArgs()->andReturnFirstArg(); +``` + +Of course, it also works in other kind of expectations, like for functions or for actions added or +done. + +--- + + + +## [Added] New Exceptions Classes + +In Brain Monkey v1, when exceptions were thrown, PHP core exception classes were used, like +`\RuntimeException` or `\InvalidArgumentException`, and so on. + +In Brain Monkey v2, different custom exceptions classes have been added, to make very easy to catch +any error thrown by Brain Monkey. + +Now, in fact, every exception thrown by Brain Monkey is of a custom type, and there's a hierarchy of +exceptions classes for a total of 16 exception classes, all inheriting (one or more levels deep) +the "base" exception class that is `Brain\Monkey\Exception`. \ No newline at end of file diff --git a/vendor/brain/monkey/docs/what-and-why.md b/vendor/brain/monkey/docs/what-and-why.md new file mode 100644 index 000000000..2ec75c3cb --- /dev/null +++ b/vendor/brain/monkey/docs/what-and-why.md @@ -0,0 +1,60 @@ + +# What's Brain Monkey + +Brain Monkey is a unit test utility for PHP. + +It comes with 2 group of features: + + - the first allow **mocking and testing any PHP function**. This part is a general tool and two times framework agnostic: can be used to test code that uses any frameworks (or no framework) and in combination with any testing framework. + - the second group of features can be used with any testing framework as well, but is **specific to test WordPress code**. + Who is interested in the first part can use only it, just like this second group of features does not exists. + + + + +# Why Brain Monkey + +When unit tests are done in the right way, the SUT (System Under Test) must be tested in **isolation**. + +Long story short, it means that any *external* code used in the SUT must be assumed as perfectly working. + +This is a key concept in unit tests. + +In PHP, to create "mock" and "stubs" for objects is a pretty easy task, framework like [PHPUnit](https://phpunit.de/manual/current/en/test-doubles.html) or [phpspec](http://www.phpspec.net/en/latest/manual/prophet-objects.html) have embedded features to do that, and libraries like [Mockery](https://github.com/padraic/mockery) make it even easier. + +But when *external* code make use of **functions** things become harder, because PHP testing framework can't mock or monkey patch functions. + +This is where Brain Monkey comes into play: its aim is to bring that easiness to function testing. + +This involves: + + - define functions if not defined + - allow to enforce function behavior + - allow to set expectations on function execution + +Moreover, I have to admit that I coded Brain Monkey to test WordPress code (that makes a large use of global functions). + +This is the reason why Brain Monkey comes with a set of WordPress-specific tools, but the ability to monkey patch and test functions is independent from WordPress-specific tools and can be used to test any PHP code. + + + +## Under the hood + +Brain Monkey gets all its power from two great libraries: [**Mockery**](http://docs.mockery.io/) and [**Patchwork**](http://antecedent.github.io/patchwork/). + +What actually Brain Monkey does is to connect the *function redefinition* feature of Patchwork with the powerful testing mechanism and DSL provided by Mockery, and thanks to that Brain Monkey has: + + - PHPUnit, PHPSpec or any other testing framework compatibility + - powerful and succinct API with human readable syntax + +All the rest is joy. + + + +## PHP versions compatibility + +Currently, Brain Monkey supports PHP 5.6+. \ No newline at end of file diff --git a/vendor/brain/monkey/docs/wordpress-hooks-added.md b/vendor/brain/monkey/docs/wordpress-hooks-added.md new file mode 100644 index 000000000..ba7038636 --- /dev/null +++ b/vendor/brain/monkey/docs/wordpress-hooks-added.md @@ -0,0 +1,294 @@ + + + + +# Testing Added Hooks + +With Brain Monkey there are two ways to test some hook have been added, and with which arguments. + +First method (easier) makes use of WordPress functions, the second (more powerful) makes use of Brain Monkey (Mockery) expectation DSL. + + + +## Testing framework agnostic + +Brain Monkey can be used with any testing framework. +Examples in this page will use PHPUnit, but the concepts are applicable to any testing framework. + +Also note that test classes in this page extends the class `MyTestCase` that is assumed very similar to the one coded in the *WordPress / Setup* docs section. + + + +## Testing with WordPress functions: `has_action()` and `has_filter()` + +When Brain Monkey is loaded for tests it registers all the functions of WordPress plugin API (see *WordPress / WordPress Testing Tools*). +Among them there are `has_action()` and `has_filter()` that, just like *real* WordPress functions can be used to test if some hook (action or filter) has been added, and also verify the arguments. + +Let's assume the code to be tested is: + +```php +namespace Some\Name\Space; + +class MyClass { + + public function addHooks() { + + add_action('init', [__CLASS__, 'init'], 20); + add_filter('the_title', [__CLASS__, 'the_title'], 99); + } +} +``` + +in Brain Monkey, just like in real WordPress code, you can test hooks are added using WordPress functions: + +```php +use Some\Name\Space\MyClass; + +class MyClassTest extends MyTestCase { + + public function testAddHooksActuallyAddsHooks() { + + ( new MyClass() )->addHooks(); + self::assertTrue( has_action('init', [ MyClass::class, 'init' ]) ); + self::assertTrue( has_filter('the_title', [ MyClass::class, 'the_title' ] ) ); + } +} +``` + +Nice thing of this approach is that you don't need to remember Brain Monkey classes and methods names, you can just use functions you, as a WordPress developer, are already used to use. + +There's more. + +A problem of WordPress hooks is that when dynamic object methods or anonymous functions are used, identify them is not easy. It's pretty hard, to be honest. + +But Brain Monkey is not WordPress, and it makes these sort of things very easy. Let's assume the code to test is: + +```php +namespace Some\Name\Space; + +class MyClass { + + public function addHooks() { + /* ... */ + } + + public function addHooks() { + add_action('init', [ $this, 'init' ], 20); + } +} +``` + +Using real WordPress functions, to check hooks added like in code above is pretty hard, because we don't have access to `$this` outside of the class. + +But Brain Monkey version of `has_action` and `has_filter` allow to check this cases with a very intuitive syntax: + +```php +class MyClassTest extends MyTestCase +{ + public function testAddHooksActuallyAddsHooks() + { + $class = new \Some\Name\Space\MyClass\MyClass(); + $class->addHooks(); + + self::assertTrue( has_action('init', 'Some\Name\Space\MyClass->init()', 20) ); + } +} +``` + +So we have identified a dynamic method by using the class name, followed by `->` and the method name followed by parenthesis. + +Moreover + - a static method can be identified by the class name followed by `::` and the method name followed by parenthesis, e.g. `'Some\Name\Space\MyClass::init()'` + - an invokable object (a class with a `__invoke()` method) can be identified by the class name followed by parenthesis, e.g. `'Some\Name\Space\MyClass()'` + + +Note that fully qualified names of classes are used and namespace. + + + +### Identify Closures + +One tricky thing when working with hooks and closures in WordPress is that they are hard to identify, for example to remove or even to check via `has_action()` / `has_filter()` if a specific closure has been added to an hook. + +Brain Monkey makes this a bit easier thanks to a sort of "serialization" of closures: a closure can be identified by a string very similar to the PHP code used to define the closure. Hopefully, an example will make it more clear. + +Assuming a code like: + +```php +namespace Some\Name\Space; + +class MyClass { + + public function addHooks() { + + add_filter('the_title', function($title) { + return $title; + }, 99); + } +} +``` + +It could be tested with: + +```php +class MyClassTest extends MyTestCase +{ + public function testAddHooksActuallyAddsHooks() + { + $class = new \Some\Name\Space\MyClass(); + $class->addHooks(); + + self::assertTrue( has_filter('the_title', 'function ($title)' ) ); + } +} +``` + +It also works with type-hints and variadic arguments. E.g. a closure like: + +```php +namespace Foo\Bar; + +function( array $foo, Baz $baz, Bar ...$bar) { + // .... +} +``` + +could be identified like this: + +```php +'function ( array $foo, Foo\Bar\Baz $baz, Foo\Bar\Bar ...$bar )'; +``` + +Just note how classes used in type-hints were using _relative_ namespace on declaration, always need the fully qualified name in the closure string representation. + +PHP 7+ scalar type hints are perfectly supported. + +The serialization also recognizes `static `closures. Following closure: + +```php +static function( int $foo, Bar ...$bar ) { + // .... +} +``` + +could be identified like this: + +```php +'static function ( int $foo, Bar ...$bar )'; +``` + +Things that are **not** took into account during serialization: + +- default values for arguments +- PHP 7+ return type declarations + +For example **all** following closures: + +```php +function( array $foo, $bar ) { + // .... +} + +function( array $foo = [], $bar = null ) { + // .... +} + +function( array $foo, $bar ) : array { + // .... +} + +function( array $foo, $bar = null ) : array { + // .... +} +``` + +are serialized into : + +```php +'function ( array $foo, $bar )'; +``` + + + +## Testing with expectations + +Even if the doing tests using WordPress native functions is pretty easy, there are cases in which is not enough powerful, or the expectation methods are just more convenient. + +Moreover, Brain Monkey functions always try to mimic WordPress real functions behavior and so a call to `remove_action` or `remove_filter` can make impossible to test some code using `has_action` and `has_filter`, because hooks are actually removed. + +The solution is to use expectations, provided in Brain Monkey by Mockery. + +Assuming the class to test is: + +```php +namespace Some\Name\Space; + +class MyClass { + + public function addHooks() { + + add_action('init', [$this, 'init']); + + add_filter('the_title', function($title) { + return $title; + }, 99); + } +} +``` + +it can be tested like so: + + +```php +use Brain\Monkey\Actions; +use Brain\Monkey\Filters; + +class MyClassTest extends MyTestCase +{ + function testAddHooksActuallyAddsHooks() + { + Actions\expectAdded('init'); + + Filters\expectAdded('the_title')->with(\Mockery\type('Closure')); + + // let's use the code that have to satisfy our expectations + ( new \Some\Name\Space\MyClass() )->addHooks(); + } +} +``` + +This is just an example, but Mockery expectations are a very powerful testing mechanism. + +To know more, read [Mockery documentation](http://docs.mockery.io/en/latest/), and have a look to *PHP Functions* doc section +to see how it is used seamlessly in Brain Monkey. + + + +## Just a couple of things... + + - expectations must be set *before* the code to be tested runs: they are called "expectations" for a reason; + - argument validation done using `with()`, validates hook arguments, not function arguments, it means what is passed to `add_action()` or `add_filter()` **excluding** hook name itself. + + + + +## Don't set expectations on return values for added hooks + +Maybe you already know that `add_action()` and `add_filter()` always return `true`. + +As already said, Brain Monkey always tries to make WordPress functions behave how they do in real WordPress code, for this reason Brain Monkey version of those functions returns `true` as well. + +But if you read *PHP Functions* doc section or Mockery documentation you probably noticed a `andReturn` method that allows to force an expectation to return a given value. + +Once `expectAdded()` method works with Mockery expectations, you may be tempted to use it... if you do that **an exception will be thrown**. + +```php +// this expectation will thrown an error! +Filters\expectAdded('the_title')->once()->andReturn(false); +``` + +Reason is that if Brain Monkey had allowed a *mocked* returning value for `add_action` and `add_filter` that had been in contrast with real WordPress code, with disastrous effects on tests. \ No newline at end of file diff --git a/vendor/brain/monkey/docs/wordpress-hooks-done.md b/vendor/brain/monkey/docs/wordpress-hooks-done.md new file mode 100644 index 000000000..76a4922a8 --- /dev/null +++ b/vendor/brain/monkey/docs/wordpress-hooks-done.md @@ -0,0 +1,329 @@ + + +# Testing Fired Hooks + + + +## Testing framework agnostic + +Brain Monkey can be used with any testing framework. +Examples in this page will use PHPUnit, but the concepts are applicable to any testing framework. + +Also note that test classes in this page extends the class `MyTestCase` that is assumed very similar to the one coded in the *WordPress / Setup* docs section. + + + +## Simple tests with `did_action()` and `Filters\applied()` + +To check hooks have been fired, the only available WordPress function is `did_action()`, it doesn't exist any `did_filter()` or `applied_filter()`. + +To overcome the missing counter part of `did_action()` for filters, Brain Monkey has a method accessible via `Brain\Monkey\Filters\applied()` that does what you might expect. + +Assuming a class like the following: + +```php +class MyClass { + + function fireHooks() { + + do_action('my_action', $this); + + return apply_filters('my_filter', 'Filter applied', $this); + } +} +``` + +It can be tested using: + +```php +use Brain\Monkey\Filters; + +class MyClassTest extends MyTestCase +{ + function testFireHooksActuallyFiresHooks() + { + ( new MyClass() )->fireHooks(); + + $this->assertSame( 1, did_action('my_action') ); + $this->assertTrue( Filters\applied('my_filter') > 0 ); + } +} +``` + +As you can guess from test code above, `did_action()` and `Filters\applied()` return the number of times an action or a filter has been triggered, just like `did_action()` does in WordPress, but there's no way to use them to check which arguments were passed to the fired hook. + +So, `did_action()` and `Filters\applied()` are fine for simple tests, mostly because using them you don't need to recall Brain Monkey methods, but they are not very powerful: arguments checking and, above all, the ability to respond to fired hooks are pivotal tasks to proper test WordPress code. + +In Brain Monkey those tasks can be done testing fired hooks with expectations. + + + + +## Test fired hooks with expectations + +A powerful testing mechanism for fired hooks is provided by Brain Monkey thanks to Mockery expectations. + +The entry points to use it are the `Actions\expectDone()` and `Filters\expectApplied()` functions. + +As usual, below there a just a couple of examples, for the full story see [Mockery docs](http://docs.mockery.io/en/latest/reference/expectations.html). + +Assuming the `MyClass` above in this page, it can be tested with: + + +```php +use Brain\Monkey\Actions; +use Brain\Monkey\Filters; + +class MyClassTest extends MyTestCase +{ + function testFireHooksActuallyFiresHooks() + { + Actions\expectDone('my_action') + ->once() + ->with(Mockery::type(MyClass::class)); + + Filters\expectApplied('my_filter') + ->once() + ->with('Filter applied', Mockery::type(MyClass::class)); + + ( new MyClass() )->fireHooks(); + } +} +``` + + + +## Just a couple of things... + + - expectations must be set *before* the code to be tested runs: they are called "expectations" for a reason + - argument validation done using `with()`, validates hook arguments, not function arguments, it means what is passed to `do_action` or `apply_filters` **excluding** hook name itself + + + + +## Respond to filters + +Yet again, Brain Monkey, when possible, tries to make WordPress functions it redefines behave in the same way of *real* WordPress functions. + +Brain Monkey `apply_filters` by default returns the first argument passed to it, just like WordPress function does when no callback is added to the filter. + +However, sometimes in tests is required that a filter returns something different. + +Luckily, Mockery provides `andReturn()` and `andReturnUsing()` expectation methods that can be used to make a filter return anything. + +```php +use Brain\Monkey\Filters; + +class MyClassTest extends MyTestCase { + + function testFireHooksReturnValue() { + + Filters\expectApplied('my_filter') + ->once() + ->with('Filter applied', Mockery::type(MyClass::class)) + ->andReturn('Brain Monkey rocks!'); + + $class = new MyClass(); + + $this->assertSame('Brain Monkey rocks!', $class->fireHooks()); + } +} +``` + +See [Mockery docs](http://docs.mockery.io/en/latest/reference/expectations.html) for more information. + +Brain Monkey also provides the helper `andReturnFirstArg()` that can be used to make a filter expectation behave like WordPress does: return first argument received: + +```php +Filters\expectApplied('my_filter')->once()->andReturnFirstArg(); + +self::assertSame( 'foo', apply_filters( 'my_filter', 'foo', 'bar' ) ); +``` + +Note that in the example right above, the expectation would not be necessary; in fact, the assertion verify either way because it is the default behavior of WordPress and Brain Monkey. + +But this is very helpful what we want to set expectations and returned values for filters based on some received arguments, for example: + +```php +Filters\expectApplied('my_filter')->once()->with('foo')->andReturnFirstArg(); +Filters\expectApplied('my_filter')->once()->with('bar')->andReturn('This time bar!'); + +self::assertSame( 'Foo', apply_filters( 'my_filter', 'Foo' ) ); +self::assertSame( 'This time bar!', apply_filters( 'my_filter', 'Bar' ) ); +``` + +Finally note that when setting different expectations for same filter, but for different received arguments, an expectation is required to be set for **all** the arguments that the filter is going to receive. For example this will fail: + +```php +Filters\expectApplied('my_filter')->once()->with('foo')->andReturnFirstArg(); +Filters\expectApplied('my_filter')->once()->with('bar')->andReturn('This time bar!'); + +self::assertSame( 'Foo', apply_filters( 'my_filter', 'Foo' ) ); +self::assertSame( 'This time bar!', apply_filters( 'my_filter', 'Bar' ) ); +self::assertSame( 'Meh!', apply_filters( 'my_filter', 'Meh!' ) ); +``` + +The reason for failing is that there's no expectation set when the filter receives `"Meh!"`. + +In such case, `andReturnFirstArg()` comes useful again, to set a "catch all" expectation: + +```php +Filters\expectApplied('my_filter')->once()->with('bar')->andReturn('This time bar!'); +// Catch all the other cases with the default: +Filters\expectApplied('my_filter')->once()->withAnyargs()->andReturnFirstArg(); + +// All the following passes! +self::assertSame( 'Foo', apply_filters( 'my_filter', 'Foo' ) ); +self::assertSame( 'This time bar!', apply_filters( 'my_filter', 'Bar' ) ); +self::assertSame( 'Meh!', apply_filters( 'my_filter', 'Meh!' ) ); +``` + + + +## Respond to actions + +To return a value from a filter is routine, not so for actions. + +In fact, `do_action()` always returns `null` so, if Brain Monkey would allow a *mocked* returning value for `do_action()` expectations, it would be in contrast with real WordPress code, with disastrous effects on tests. + +So, don't try to use neither `andReturn()` or `andReturnUsing()` with `Actions\expectDone()` because it will throw an exception. + +However, sometimes one may be in the need do *something* when code calls `do_action()`, like WordPress actually does. + +This is the reason Brain Monkey introduces `whenHappen()` method for action expectations. The method takes a callback to be ran when an action is fired. + +Let's assume a class like the following: + +```php +class MyClass { + + public $post; + + function setPost() { + + global $post; + $this->post = $post; + + do_action('my_class_set_post', $this); + + return $post; + } +} +``` + +It is possible write a test like this: + +```php +use Brain\Monkey\Actions; + +class MyClassTest extends MyTestCase { + + function testFireHooksReturnValue() { + + Action\expectDone('my_class_set_post') + ->with(Mockery::type(MyClass::class)) + ->whenHappen(function($my_class) { + $my_class->post = (object) ['post_title' => 'Mocked!']; + }); + + ( new MyClass() )->setPost(); + + $this->assertSame( 'Mocked!', $class->post->post_title ); + } +} +``` + + + + +## Resolving `current_filter()`, `doing_action` and `doing_filter()` + +When WordPress is not performing an hook, `current_filter()` returns `false`. + +And so does the Brain Monkey version of that function. + +Now I want to surprise you: `current_filter()` correctly resolves to the correct hook during the execution of any callback added to respond to hooks. + +Let's assume a class like the following: + +```php +class MyClass { + + function getValues() { + + $title = apply_filters('my_class_title', ''); + $content = apply_filters('my_class_content', ''); + + return [$title, $content]; + } +} +``` + +It is possible write a test like this: + +```php +use Brain\Monkey\Filters; + +class MyClassTest extends MyTestCase +{ + function testGetValues() + { + $callback = function() { + return current_filter() === 'my_class_title' ? 'Title' : 'Content'; + }; + + Filters\expectApplied('my_class_title')->once()->andReturnUsing($callback); + Filters\expectApplied('my_class_content')->once()->andReturnUsing($callback); + + $class = new MyClass(); + + $this->assertSame(['Title', 'Content'], $class->getValues()); + } +} +``` + +Like magic, inside our callback, `current_filter()` returns the right hook just like it does in WordPress. Note this will also work with any callback passed to `whenHappen()`. + +Surprised? There's more: inside callbacks used to respond to actions and filters, `doing_action()` and `doing_filter()` works as well! + +Assuming a class like the following: + +```php +class MyClass { + + function doStuff() { + do_action( 'trigger_an_hook' ); + } +} +``` + +It is possible to write a test like this: + +```php +use Brain\Monkey\Actions; + +class MyClassTest extends MyTestCase { + + function testDoStuff() { + + // 'an_hook' action is done below in the "whenHappen" callback + Actions\expectDone( 'an_hook' )->once()->whenHappen(function() { + + self::assertTrue( doing_action('an_hook') ); + + // doing_action() also resolves the "parent" hook like it was WordPress! + self::assertTrue( doing_action('trigger_an_hook') ); + }); + + Actions\expectDone('trigger_an_hook')->once()->whenHappen(function() { + if( current_filter() === 'trigger_an_hook' ) { + do_action('an_hook'); + } + }); + } +} +``` \ No newline at end of file diff --git a/vendor/brain/monkey/docs/wordpress-setup.md b/vendor/brain/monkey/docs/wordpress-setup.md new file mode 100644 index 000000000..39cc9c20f --- /dev/null +++ b/vendor/brain/monkey/docs/wordpress-setup.md @@ -0,0 +1,59 @@ + + +# Setup Brain Monkey for WordPress Tests + + + +## Testing framework agnostic + +Brain Monkey can be used with any testing framework. +Examples in this page will use PHPUnit, but the concepts are applicable to any testing framework. + + + +## Warning + +The procedure below **includes** the setup needed for testing PHP functions, so there is **no** need to +apply what said here and *additionally* what said in the section *PHP Functions / Setup*: steps below are enough to use all Brain Monkey features, including functions utilities. + + + +## Setup tests + +After Brain Monkey is part of the project (see *Getting Started / Installation*), to be able to use its features +you need to **require vendor autoload file** before running tests (e.g. PHPUnit users will probably require it in their bootstrap file). + +After that, you need to call a function *before* any test, and another *after* any test. + +These two functions are: + + - `Brain\Monkey\setUp()` has to be run before any test + - `Brain\Monkey\tearDown()` has to be run after any test + +PHPUnit users will probably want to add these methods to a custom test case class: + +```php +use PHPUnit_Framework_TestCase; +use Brain\Monkey; + +class MyTestCase extends PHPUnit_Framework_TestCase { + + protected function setUp() { + parent::setUp(); + Monkey\setUp(); + } + + protected function tearDown() { + Monkey\tearDown(); + parent::tearDown(); + } +} +``` + +and then extend various test classes from it instead of directly extend `PHPUnit_Framework_TestCase`. + +That's all. You are ready to use all Brain Monkey features. \ No newline at end of file diff --git a/vendor/brain/monkey/docs/wordpress-tools.md b/vendor/brain/monkey/docs/wordpress-tools.md new file mode 100644 index 000000000..147a63273 --- /dev/null +++ b/vendor/brain/monkey/docs/wordpress-tools.md @@ -0,0 +1,85 @@ + +# WordPress Testing Tools + +The sole ability to mocking functions is a great help on testing WordPress code. + +All WordPress functions can be mocked and tested using the techniques described in the *PHP Functions* section, they are PHP functions, after all. + +However, to test WordPress code in isolation, without a bunch of bootstrap code for every test, a more fine grained control of plugin API functions is required. + +This is exactly what Brain Monkey offers. + + + +## Defined functions + +Following functions are defined by Brain Monkey when it is loaded for tests: + + + +**Hook-related functions:** + + - `add_action()` + - `remove_action()` + - `do_action()` + - `do_action_ref_array()` + - `did_action()` + - `doing_action()` + - `has_action()` + - `add_filter()` + - `remove_filter()` + - `apply_filters()` + - `apply_filters_ref_array()` + - `has_filter()` + - `current_filter()` + +**Generic functions:** + + - `__return_true()` + - `__return_false()` + - `__return_null()` + - `__return_empty_array()` + - `__return_empty_string()` + - `trailingslashit()` + - `untrailingslashit()` + + + +If your code uses any of these functions, and very likely it does, you don't need to define (or mock) them +to avoid fatal errors during tests. + +Note that the returning value of those functions (most of the times) will work out of the box as you might expect. + +For example, if your code contains: + +```php +do_action('my_custom_action'); + +// something in the middle +$did = did_action('my_custom_action'); +``` +the value of `$did` will be correctly `1` (`did_action()` in WordPress returns the number an action was *done*). + +Or if your code contains: + +```php +$post = [ 'post_title' => 'My Title' ]; + +$title = apply_filters('the_title', $post['post_title']); +``` +the value of `$title` will be `'My Title'`, without the need of any intervention. + +But, of course, that's not enough. To proper test WordPress code you will probably desire to: + + - test if an action or a filter has been added, how many times that happen and with which arguments + - test if an action or a filter has been fired, how many times that happen and with which arguments + - perform some callback when an action is fired, being able to access passed arguments + - perform some callback when an filter is applied, being able to access passed arguments and to return specific values + +Guess what, Brain Monkey allows to do all of this and even more. + +And it does that using its straightforward and human readable syntax. \ No newline at end of file diff --git a/vendor/brain/monkey/docs/wordpress-why-bother.md b/vendor/brain/monkey/docs/wordpress-why-bother.md new file mode 100644 index 000000000..44036779f --- /dev/null +++ b/vendor/brain/monkey/docs/wordpress-why-bother.md @@ -0,0 +1,41 @@ + + +# Brain Monkey for WordPress: Why Bother + +Just to be clear, Brain Monkey is useful for testing code wrote *for* WordPress (plugin, themes) +not WordPress core. + +More specifically, it is useful to run **unit tests**. + +Integration tests or end-to-end tests are a thing: you need to be sure that your code works good *with* WordPress. + +But **unit** tests are meant to be run **without loading WordPress environment**. + +Every component that is unit tested, should be tested in isolation: when you test a class, you only have to test that specific class, assuming all other code (e.g. WordPress code) is working perfectly. + +This is not only because doing that tests will run much faster, but also because the key concept in unit testing is that every piece of code should work *per se*, in this way if a test fails there is only one possible culprit. + +By assuming all the external code is working perfectly, it is possible to test the behavior of the SUT (System Under Test), without any *interference*. + +To deepen these concepts, read [this answer](http://wordpress.stackexchange.com/a/164138/35541) I wrote for WordPress Development (StackExchange) site, that also contains some tips to write better *testable* WordPress code. + + + +## If WordPress is not loaded... + +WordPress functions are not available, and trying to run tests in that situation, tests fail with fatal errors. + +Unless you use Brain Monkey. + +It allows to mock WordPress function (just like any PHP function), and to check how they are called inside your code. + +See the *PHP Function* documentation section for a deep explanation on how it works. + +Moreover, among others, WordPress [Plugin API functions](https://codex.wordpress.org/Plugin_API) are particularly +important and a very fine grained control on how they are used in code is pivotal to proper test WordPress extensions. + +This is why Brain Monkey comes with a set of features specifically designed for that. \ No newline at end of file diff --git a/vendor/brain/monkey/inc/api.php b/vendor/brain/monkey/inc/api.php new file mode 100644 index 000000000..7e90e5e56 --- /dev/null +++ b/vendor/brain/monkey/inc/api.php @@ -0,0 +1,298 @@ +reset(); + \Mockery::close(); + \Patchwork\restoreAll(); + } +} + +namespace Brain\Monkey\Functions { + + use Brain\Monkey\Container; + use Brain\Monkey\Expectation\FunctionStubFactory; + use Brain\Monkey\Name\FunctionName; + + /** + * API entrypoint for plain functions stub. + * + * Factory method: receives the name of the function to mock and returns an instance of + * FunctionStub. + * + * @param string $function_name the name of the function to mock + * @return \Brain\Monkey\Expectation\FunctionStub + */ + function when($function_name) + { + return Container::instance() + ->functionStubFactory() + ->create(new FunctionName($function_name), FunctionStubFactory::SCOPE_STUB); + } + + /** + * API method to fast & simple create multiple functions stubs. + * + * It does not allow to add expectations. + * + * The function name to create stub for can be passed as array key or as array value (with no key). + * + * When the function name is in the key, the value can be: + * - a callable, in which case the function will be aliased to it + * - anything else, in which case a stub returning given value will be created for the function + * + * When the function name is in the value, and no key is set, the behavior will change based on + * the second param: + * - when 2nd param is `null` (default) the created stub will return the 1st param it will receive + * - when 2nd param is anything else the created stub will return it + * + * + * @param array $functions + * @param mixed|null $default_return + */ + function stubs(array $functions, $default_return = null) + { + foreach ($functions as $key => $value) { + + list($function_name, $return_value) = is_numeric($key) + ? [$value, $default_return] + : [$key, $value]; + + if (is_callable($return_value)) { + when($function_name)->alias($return_value); + continue; + } + + $return_value === null + ? when($function_name)->returnArg() + : when($function_name)->justReturn($return_value); + } + } + + /** + * API entrypoint for plain functions expectations. + * + * Returns a Mockery Expectation object, where is possible to set all the expectations, using + * Mockery methods. + * + * @param string $function_name + * @return \Brain\Monkey\Expectation\Expectation + */ + function expect($function_name) + { + $name = new FunctionName($function_name); + $expectation = Container::instance() + ->expectationFactory() + ->forFunctionExecuted($function_name); + + $factory = Container::instance()->functionStubFactory(); + if ( ! $factory->has($name)) { + $factory->create($name, FunctionStubFactory::SCOPE_EXPECTATION) + ->redefineUsingExpectation($expectation); + + } + + return $expectation; + } +} + +namespace Brain\Monkey\Actions { + + use Brain\Monkey\Container; + use Brain\Monkey\Hook; + + /** + * API entrypoint for added action expectations. + * + * Takes the action name and returns a Mockery Expectation object, where is possible to set all + * the expectations, using Mockery methods. + * + * @param string $action + * @return \Brain\Monkey\Expectation\Expectation + */ + function expectAdded($action) + { + return Container::instance() + ->expectationFactory() + ->forActionAdded($action); + } + + /** + * API entrypoint for fired action expectations. + * + * Takes the action name and returns a Mockery Expectation object, where is possible to set all + * the expectations, using Mockery methods. + * + * @param string $action + * @return \Brain\Monkey\Expectation\Expectation + */ + function expectDone($action) + { + return Container::instance() + ->expectationFactory() + ->forActionDone($action); + } + + /** + * Utility method to check if any or specific callback has been added to given action. + * + * Brain Monkey version of `has_action` will alias here. + * + * @param string $action + * @param null $callback + * @return bool + */ + function has($action, $callback = null) + { + return Container::instance() + ->hookStorage() + ->isHookAdded(Hook\HookStorage::ACTIONS, $action, $callback); + } + + /** + * Utility method to check if given action has been done. + * + * Brain Monkey version of `did_action` will alias here. + * + * @param string $action + * @return int + */ + function did($action) + { + return Container::instance() + ->hookStorage() + ->isHookDone(Hook\HookStorage::ACTIONS, $action); + } + + /** + * Utility method to check if given action is currently being done. + * + * Brain Monkey version of `doing_action` will alias here. + * + * @param string $action + * @return bool + */ + function doing($action) + { + return Container::instance() + ->hookRunningStack() + ->has($action); + } +} + +namespace Brain\Monkey\Filters { + + use Brain\Monkey\Container; + use Brain\Monkey\Hook; + + /** + * API entrypoint for added filter expectations. + * + * Takes the filter name and returns a Mockery Expectation object, where is possible to set all + * the expectations, using Mockery methods. + * + * @param string $filter + * @return \Brain\Monkey\Expectation\Expectation + */ + function expectAdded($filter) + { + return Container::instance() + ->expectationFactory() + ->forFilterAdded($filter); + } + + /** + * API entrypoint for applied filter expectations. + * + * Takes the filter name and returns a Mockery Expectation object, where is possible to set all + * the expectations, using Mockery methods. + * + * @param string $filter + * @return \Brain\Monkey\Expectation\Expectation + */ + function expectApplied($filter) + { + return Container::instance() + ->expectationFactory() + ->forFilterApplied($filter); + } + + /** + * Utility method to check if any or specific callback has been added to given filter. + * + * Brain Monkey version of `has_filter` will alias here. + * + * @param string $filter + * @param null $callback + * @return bool + */ + function has($filter, $callback = null) + { + return Container::instance() + ->hookStorage() + ->isHookAdded(Hook\HookStorage::FILTERS, $filter, $callback); + } + + /** + * Utility method to check if given filter as been applied. + * + * There's no WordPress function counter part for it. + * + * @param string $filter + * @return int + */ + function applied($filter) + { + return Container::instance() + ->hookStorage() + ->isHookDone(Hook\HookStorage::FILTERS, $filter); + } + + /** + * Utility method to check if given filter is currently being done. + * + * Brain Monkey version of `doing_filter` will alias here. + * + * @param string $filter + * @return bool + */ + function doing($filter) + { + return Container::instance() + ->hookRunningStack() + ->has($filter); + } +} + diff --git a/vendor/brain/monkey/inc/patchwork-loader.php b/vendor/brain/monkey/inc/patchwork-loader.php new file mode 100644 index 000000000..22562bfdc --- /dev/null +++ b/vendor/brain/monkey/inc/patchwork-loader.php @@ -0,0 +1,31 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @author Giuseppe Mazzapica + * @license http://opensource.org/licenses/MIT MIT + * @package BrainMonkey + */ + +if (function_exists('Patchwork\redefine')) { + return; +} + +if (file_exists(dirname(dirname(dirname(__DIR__)))."/antecedent/patchwork/Patchwork.php")) { + /** @noinspection PhpIncludeInspection */ + @require_once dirname(dirname(dirname(__DIR__)))."/antecedent/patchwork/Patchwork.php"; +} elseif (file_exists(dirname(__DIR__)."/vendor/antecedent/patchwork/Patchwork.php")) { + /** @noinspection PhpIncludeInspection */ + @require_once dirname(__DIR__)."/vendor/antecedent/patchwork/Patchwork.php"; +} + +if ( ! function_exists('Patchwork\redefine')) { + throw new \Brain\Monkey\Exception( + 'Brain Monkey was unable to load Patchwork. Please require Patchwork.php by yourself before running tests.' + ); +} diff --git a/vendor/brain/monkey/inc/wp-helper-functions.php b/vendor/brain/monkey/inc/wp-helper-functions.php new file mode 100644 index 000000000..d5383da3d --- /dev/null +++ b/vendor/brain/monkey/inc/wp-helper-functions.php @@ -0,0 +1,69 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @author Giuseppe Mazzapica + * @license http://opensource.org/licenses/MIT MIT + * @package BrainMonkey + */ + +if ( ! function_exists('__return_true')) { + function __return_true() + { + return true; + } +} + +if ( ! function_exists('__return_false')) { + function __return_false() + { + return false; + } +} + +if ( ! function_exists('__return_null')) { + function __return_null() + { + return null; + } +} + +if ( ! function_exists('__return_zero')) { + function __return_zero() + { + return 0; + } +} + +if ( ! function_exists('__return_empty_array')) { + function __return_empty_array() + { + return []; + } +} + +if ( ! function_exists('__return_empty_string')) { + function __return_empty_string() + { + return ''; + } +} + +if ( ! function_exists('untrailingslashit')) { + function untrailingslashit($string) + { + return rtrim($string, '/\\'); + } +} + +if ( ! function_exists('trailingslashit')) { + function trailingslashit($string) + { + return rtrim($string, '/\\').'/'; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/inc/wp-hook-functions.php b/vendor/brain/monkey/inc/wp-hook-functions.php new file mode 100644 index 000000000..ecf33790c --- /dev/null +++ b/vendor/brain/monkey/inc/wp-hook-functions.php @@ -0,0 +1,135 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + * + * @author Giuseppe Mazzapica + * @license http://opensource.org/licenses/MIT MIT + * @package BrainMonkey + */ + +use Brain\Monkey; + +if ( ! function_exists('add_action')) { + function add_action($action, ...$args) + { + $container = Monkey\Container::instance(); + $container->hookStorage()->pushToAdded(Monkey\Hook\HookStorage::ACTIONS, $action, $args); + $container->hookExpectationExecutor()->executeAddAction($action, $args); + + return true; + } +} + +if ( ! function_exists('add_filter')) { + function add_filter($filter, ...$args) + { + $container = Monkey\Container::instance(); + $container->hookStorage()->pushToAdded(Monkey\Hook\HookStorage::FILTERS, $filter, $args); + $container->hookExpectationExecutor()->executeAddFilter($filter, $args); + + return true; + } +} + +if ( ! function_exists('do_action')) { + function do_action($action, ...$args) + { + $container = Monkey\Container::instance(); + $container->hookStorage()->pushToDone(Monkey\Hook\HookStorage::ACTIONS, $action, $args); + $container->hookExpectationExecutor()->executeDoAction($action, $args); + } +} + +if ( ! function_exists('do_action_ref_array')) { + function do_action_ref_array($action, array $args) + { + $container = Monkey\Container::instance(); + $container->hookStorage()->pushToDone(Monkey\Hook\HookStorage::ACTIONS, $action, $args); + $container->hookExpectationExecutor()->executeDoAction($action, $args); + } +} + +if ( ! function_exists('apply_filters')) { + function apply_filters($filter, ...$args) + { + $container = Monkey\Container::instance(); + $container->hookStorage()->pushToDone(Monkey\Hook\HookStorage::FILTERS, $filter, $args); + + return $container->hookExpectationExecutor()->executeApplyFilters($filter, $args); + } +} + +if ( ! function_exists('apply_filters_ref_array')) { + function apply_filters_ref_array($filter, array $args) + { + $container = Monkey\Container::instance(); + $container->hookStorage()->pushToDone(Monkey\Hook\HookStorage::FILTERS, $filter, $args); + + return $container->hookExpectationExecutor()->executeApplyFilters($filter, $args); + } +} + +if ( ! function_exists('has_action')) { + function has_action($action, $callback = null) + { + return Monkey\Actions\has($action, $callback); + } +} + +if ( ! function_exists('has_filter')) { + function has_filter($filter, $callback = null) + { + return Monkey\Filters\has($filter, $callback); + } +} + +if ( ! function_exists('did_action')) { + function did_action($action) + { + return Monkey\Actions\did($action); + } +} + +if ( ! function_exists('remove_action')) { + function remove_action($action, ...$args) + { + return Monkey\Container::instance() + ->hookStorage() + ->removeFromAdded(Monkey\Hook\HookStorage::ACTIONS, $action, $args); + } +} + +if ( ! function_exists('remove_filter')) { + function remove_filter($filter, ...$args) + { + return Monkey\Container::instance() + ->hookStorage() + ->removeFromAdded(Monkey\Hook\HookStorage::FILTERS, $filter, $args); + } +} + +if ( ! function_exists('doing_action')) { + function doing_action($action) + { + return Monkey\Actions\doing($action); + } +} + +if ( ! function_exists('doing_filter')) { + function doing_filter($filter) + { + return Monkey\Filters\doing($filter); + } +} + +if ( ! function_exists('current_filter')) { + function current_filter() + { + return Monkey\Container::instance()->hookRunningStack()->last() ? : false; + } +} diff --git a/vendor/brain/monkey/phpunit.xml.dist b/vendor/brain/monkey/phpunit.xml.dist new file mode 100644 index 000000000..0a6fdd641 --- /dev/null +++ b/vendor/brain/monkey/phpunit.xml.dist @@ -0,0 +1,28 @@ + + + + src + + + + + tests/src/Api + + + tests/src/Expectation + + + tests/src/Name + + + tests/src/Hook + + + diff --git a/vendor/brain/monkey/src/Container.php b/vendor/brain/monkey/src/Container.php new file mode 100644 index 000000000..246fbe2ab --- /dev/null +++ b/vendor/brain/monkey/src/Container.php @@ -0,0 +1,113 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class Container +{ + + /** + * @var Container + */ + private static $instance; + + /** + * @var array + */ + private $services = []; + + /** + * Static instance lookup. + * + * @return static + */ + public static function instance() + { + if (!self::$instance) { + require_once dirname(__DIR__).'/inc/patchwork-loader.php'; + self::$instance = new static(); + } + + return self::$instance; + } + + /** + * @return \Brain\Monkey\Expectation\ExpectationFactory + */ + public function expectationFactory() + { + return $this->service(__FUNCTION__, new Expectation\ExpectationFactory()); + } + + /** + * @return \Brain\Monkey\Hook\HookRunningStack + */ + public function hookRunningStack() + { + return $this->service(__FUNCTION__, new Hook\HookRunningStack()); + } + + /** + * @return \Brain\Monkey\Hook\HookStorage + */ + public function hookStorage() + { + return $this->service(__FUNCTION__, new Hook\HookStorage()); + } + + /** + * @return \Brain\Monkey\Hook\HookExpectationExecutor + */ + public function hookExpectationExecutor() + { + return $this->service(__FUNCTION__, new Hook\HookExpectationExecutor( + $this->hookRunningStack(), + $this->expectationFactory() + )); + } + + /** + * @return \Brain\Monkey\Expectation\FunctionStubFactory + */ + public function functionStubFactory() + { + return $this->service(__FUNCTION__, new Expectation\FunctionStubFactory()); + } + + /** + * @return void + */ + public function reset() + { + $this->expectationFactory()->reset(); + $this->hookRunningStack()->reset(); + $this->hookStorage()->reset(); + $this->functionStubFactory()->reset(); + } + + /** + * @param string $id + * @param mixed $service + * @return mixed + */ + private function service($id, $service) + { + if ( ! array_key_exists($id, $this->services)) { + $this->services[$id] = $service; + } + + return $this->services[$id]; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Exception.php b/vendor/brain/monkey/src/Exception.php new file mode 100644 index 000000000..877d9aae1 --- /dev/null +++ b/vendor/brain/monkey/src/Exception.php @@ -0,0 +1,21 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class Exception extends \Exception +{ + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/Exception/Exception.php b/vendor/brain/monkey/src/Expectation/Exception/Exception.php new file mode 100644 index 000000000..046472d6a --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/Exception/Exception.php @@ -0,0 +1,37 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class Exception extends BaseException +{ + + /** + * + * @param \Exception $exception + * @return static + */ + public static function becauseOf(\Exception $exception) + { + return new static( + $exception->getMessage(), + $exception->getCode(), + $exception + ); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/Exception/ExpectationArgsRequired.php b/vendor/brain/monkey/src/Expectation/Exception/ExpectationArgsRequired.php new file mode 100644 index 000000000..0b0ebab4c --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/Exception/ExpectationArgsRequired.php @@ -0,0 +1,51 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class ExpectationArgsRequired extends Exception +{ + + /** + * @param \Brain\Monkey\Expectation\ExpectationTarget $target + * @return static + */ + public static function forExpectationType(ExpectationTarget $target) + { + $type = 'given'; + + switch ($target->type()) { + case ExpectationTarget::TYPE_ACTION_ADDED: + $type = "added action"; + break; + case ExpectationTarget::TYPE_ACTION_DONE: + $type = "done action"; + break; + case ExpectationTarget::TYPE_FILTER_ADDED: + $type = "added filter"; + break; + case ExpectationTarget::TYPE_FILTER_APPLIED: + $type = "applied filter"; + break; + } + + return new static( + "Can't use `withNoArgs()` for {$type} expectations: they require at least one argument." + ); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/Exception/InvalidArgumentForStub.php b/vendor/brain/monkey/src/Expectation/Exception/InvalidArgumentForStub.php new file mode 100644 index 000000000..e53a86fec --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/Exception/InvalidArgumentForStub.php @@ -0,0 +1,21 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class InvalidArgumentForStub extends Exception +{ + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/Exception/InvalidExpectationName.php b/vendor/brain/monkey/src/Expectation/Exception/InvalidExpectationName.php new file mode 100644 index 000000000..194d8a583 --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/Exception/InvalidExpectationName.php @@ -0,0 +1,39 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class InvalidExpectationName extends Exception +{ + + /** + * @param mixed $name + * @param string $type + * @return static + */ + public static function forNameAndType($name, $type) + { + return new static( + sprintf( + '%s name to set expectation for must be in a string, got %s.', + $type === ExpectationTarget::TYPE_FUNCTION ? 'Function' : 'Hook', + is_object($name) ? 'instance of '.get_class($name) : gettype($name) + ) + ); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/Exception/InvalidExpectationType.php b/vendor/brain/monkey/src/Expectation/Exception/InvalidExpectationType.php new file mode 100644 index 000000000..e277ed0f1 --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/Exception/InvalidExpectationType.php @@ -0,0 +1,35 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class InvalidExpectationType extends Exception +{ + + /** + * @param string $type + * @return static + */ + public static function forType($type) + { + return new static( + sprintf( + '%s method is not allowed for Brain Monkey expectation.', + $type + ) + ); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/Exception/MissedPatchworkReplace.php b/vendor/brain/monkey/src/Expectation/Exception/MissedPatchworkReplace.php new file mode 100644 index 000000000..4eaebf7c0 --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/Exception/MissedPatchworkReplace.php @@ -0,0 +1,32 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class MissedPatchworkReplace extends Exception +{ + + /** + * @param string $function_name + * @return static + */ + public static function forFunction($function_name) + { + return new static( + "Patchwork was not able to replace '{$function_name}', try to load Patchwork earlier." + ); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/Exception/NotAllowedMethod.php b/vendor/brain/monkey/src/Expectation/Exception/NotAllowedMethod.php new file mode 100644 index 000000000..2cf01c5af --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/Exception/NotAllowedMethod.php @@ -0,0 +1,76 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class NotAllowedMethod extends Exception +{ + + const CODE_METHOD = 1; + const CODE_RETURNING_METHOD = 2; + const CODE_WHEN_HAPPEN = 3; + + /** + * @param string $method_name + * @return static + */ + public static function forMethod($method_name) + { + return new static( + sprintf( + '%s method is not allowed for Brain Monkey expectation.', + $method_name + ), + self::CODE_METHOD + ); + } + + /** + * @param string $method_name + * @return static + */ + public static function forReturningMethod($method_name) + { + return new static( + sprintf( + 'Bad usage of "%s" method: returning expectation can only be used for functions or applied filters expectations.', + $method_name + ), + self::CODE_RETURNING_METHOD + ); + } + + public static function forWhenHappen(ExpectationTarget $target) + { + $type = ''; + + switch ($target->type()) { + case ExpectationTarget::TYPE_FUNCTION: + $type = "function"; + break; + case ExpectationTarget::TYPE_FILTER_APPLIED: + $type = "applied filter"; + break; + } + + return new static( + "Can't use `whenHappen()` for {$type} expectations: use `andReturnUsing()` instead.", + self::CODE_WHEN_HAPPEN + ); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/Expectation.php b/vendor/brain/monkey/src/Expectation/Expectation.php new file mode 100644 index 000000000..9bb4cde84 --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/Expectation.php @@ -0,0 +1,247 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Brain\Monkey\Expectation; + +use Mockery\ExpectationInterface; + +/** + * A wrap around Mockery expectation. + * + * Acts as "man in the middle" between Monkey API and Mockery expectation, preventing calls to + * some methods and do some checks before calling other methods. + * finally, some additional methods are added like `andAlsoExpect` to overcome the not allowed + * `getMock()` and `andReturnFirstArg()` to facilitate the creation of expectation for applied + * filter hooks. + * + * @author Giuseppe Mazzapica + * @license http://opensource.org/licenses/MIT MIT + * @package BrainMonkey + * + * @method Expectation once() + * @method Expectation twice() + * @method Expectation atLeast() + * @method Expectation atMost() + * @method Expectation times(int $times) + * @method Expectation never() + * @method Expectation ordered() + * @method Expectation between(int $min, int $max) + * @method Expectation zeroOrMoreTimes() + * @method Expectation with(...$args) + * @method Expectation withAnyArgs() + * @method Expectation andReturn(...$args) + * @method Expectation andReturnNull() + * @method Expectation andReturnValues(...$args) + * @method Expectation andReturnUsing(callable ...$args) + * @method Expectation andThrow(\Throwable $throwable) + */ +class Expectation +{ + + const RETURNING_EXPECTATION_TYPES = [ + ExpectationTarget::TYPE_FILTER_APPLIED, + ExpectationTarget::TYPE_FUNCTION + ]; + + const NO_ARGS_EXPECTATION_TYPES = [ + ExpectationTarget::TYPE_ACTION_DONE, + ExpectationTarget::TYPE_FUNCTION + ]; + + const NOT_ALLOWED_METHODS = [ + 'shouldReceive', + 'andSet', + 'set', + 'shouldExpect', + 'mock', + 'getMock', + 'byDefault' + ]; + + /** + * @var \Mockery\Expectation|\Mockery\ExpectationInterface + */ + private $expectation; + + /** + * @var \Brain\Monkey\Expectation\ExpectationTarget + */ + private $target; + + /** + * @var bool + */ + private $default = true; + + /** + * @var \ArrayAccess + */ + private $return_expectations; + + /** + * @param \Mockery\ExpectationInterface $expectation + * @param \Brain\Monkey\Expectation\ExpectationTarget $target + * @param \ArrayAccess $return_expectations + */ + public function __construct( + ExpectationInterface $expectation, + ExpectationTarget $target, + \ArrayAccess $return_expectations = null + ) { + $this->expectation = $expectation; + $this->target = $target; + $this->return_expectations = $return_expectations ?: new \ArrayObject(); + } + + /** + * Ensure full cloning. + * + * @codeCoverageIgnore + */ + public function __clone() + { + $this->expectation = clone $this->expectation; + $this->target = clone $this->target; + } + + /** + * Delegate method to wrapped expectation, after some checks. + * + * @param string $name + * @param array $arguments + * @return static + * @throws \Brain\Monkey\Expectation\Exception\NotAllowedMethod + */ + public function __call($name, array $arguments = []) + { + if (in_array($name, self::NOT_ALLOWED_METHODS, true)) { + throw Exception\NotAllowedMethod::forMethod($name); + } + + $has_return = stristr($name, 'return'); + + if ( + $has_return + && ! in_array($this->target->type(), self::RETURNING_EXPECTATION_TYPES, true) + ) { + throw Exception\NotAllowedMethod::forReturningMethod($name); + } + + if ($this->default) { + $this->default = false; + $this->andAlsoExpectIt(); + } + + $callback = [$this->expectation, $name]; + + $this->expectation = $callback(...$arguments); + + if ($has_return) { + $id = $this->target->identifier(); + $this->return_expectations->offsetExists($id) or $this->return_expectations[$id] = 1; + } + + return $this; + } + + /** + * @return \Mockery\Expectation|\Mockery\CompositeExpectation + */ + public function mockeryExpectation() + { + return $this->expectation; + } + + /** + * Mockery expectation allow chaining different expectations with by chaining `getMock()` + * method. + * Since `getMock()` is disabled for Brain Monkey expectation this methods provides a way to + * chain expectations. + * + * @return static + */ + public function andAlsoExpectIt() + { + $method = $this->target->mockMethodName(); + /** @noinspection PhpMethodParametersCountMismatchInspection */ + $this->expectation = $this->expectation->getMock()->shouldReceive($method); + + return $this; + } + + /** + * WordPress action and filters addition and filters applying requires at least one argument, + * and setting an expectation of no arguments for those triggers an error in Brain Monkey. + * + * @return static + * @throws \Brain\Monkey\Expectation\Exception\ExpectationArgsRequired + */ + public function withNoArgs() + { + if ( ! in_array($this->target->type(), self::NO_ARGS_EXPECTATION_TYPES, true)) { + throw Exception\ExpectationArgsRequired::forExpectationType($this->target); + } + + $this->expectation = $this->expectation->withNoArgs(); + + return $this; + } + + /** + * Brain Monkey doesn't allow return expectation for actions (added/done) nor for added + * filters. + * However, it is desirable to do something when the expected callback is used, this is the + * reason to be of this method. + * + * ``` + * Actions::expectDone('some_action')->once()->whenHappen(function($some_arg) { + * echo "{$some_arg} was passed to " . current_filter(); + * }); + * ``` + * + * Snippet above will not change the return of `do_action('some_action', $some_arg)` + * like a normal return expectation would do, but allows to catch expected events with a + * callback. + * + * For expectation types that allows return expectation (functions, applied filters) this method + * becomes just an alias for Mockery `andReturnUsing()`. + * + * @param callable $callback + * @return static + * @throws \Brain\Monkey\Expectation\Exception\NotAllowedMethod + */ + public function whenHappen(callable $callback) + { + if (in_array($this->target->type(), self::RETURNING_EXPECTATION_TYPES, true)) { + throw Exception\NotAllowedMethod::forWhenHappen($this->target); + } + + $this->expectation->andReturnUsing($callback); + + return $this; + } + + /** + * @return static + * @throws \Brain\Monkey\Expectation\Exception\NotAllowedMethod + */ + public function andReturnFirstArg() + { + if ( ! in_array($this->target->type(), self::RETURNING_EXPECTATION_TYPES, true)) { + throw Exception\NotAllowedMethod::forReturningMethod('andReturnFirstParam'); + } + + $this->expectation->andReturnUsing(function ($arg = null) { + return $arg; + }); + + return $this; + } +} diff --git a/vendor/brain/monkey/src/Expectation/ExpectationFactory.php b/vendor/brain/monkey/src/Expectation/ExpectationFactory.php new file mode 100644 index 000000000..9575f8850 --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/ExpectationFactory.php @@ -0,0 +1,165 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class ExpectationFactory +{ + + /** + * @var \Brain\Monkey\Expectation\Expectation[] + */ + private $expectations = []; + + /** + * @var \ArrayObject + */ + private $return_expectations; + + public function __construct() + { + $this->return_expectations = new \ArrayObject(); + } + + /** + * @param string $function + * @return \Brain\Monkey\Expectation\Expectation; + */ + public function forFunctionExecuted($function) + { + return $this->create( + new ExpectationTarget(ExpectationTarget::TYPE_FUNCTION, $function) + ); + } + + /** + * @param string $action + * @return \Brain\Monkey\Expectation\Expectation; + */ + public function forActionAdded($action) + { + return $this->create( + new ExpectationTarget(ExpectationTarget::TYPE_ACTION_ADDED, $action) + ); + } + + /** + * @param string $action + * @return \Brain\Monkey\Expectation\Expectation; + */ + public function forActionDone($action) + { + return $this->create( + new ExpectationTarget(ExpectationTarget::TYPE_ACTION_DONE, $action) + ); + } + + /** + * @param string $filter + * @return \Brain\Monkey\Expectation\Expectation; + */ + public function forFilterAdded($filter) + { + return $this->create( + new ExpectationTarget(ExpectationTarget::TYPE_FILTER_ADDED, $filter) + ); + } + + /** + * @param string $filter + * @return \Brain\Monkey\Expectation\Expectation; + */ + public function forFilterApplied($filter) + { + return $this->create( + new ExpectationTarget(ExpectationTarget::TYPE_FILTER_APPLIED, $filter) + ); + } + + /** + * @param \Brain\Monkey\Expectation\ExpectationTarget $target + * @return \Mockery\MockInterface|mixed + */ + public function hasMockFor(ExpectationTarget $target) + { + return array_key_exists($target->identifier(), $this->expectations); + } + + /** + * @param \Brain\Monkey\Expectation\ExpectationTarget $target + * @return \Mockery\MockInterface|mixed + */ + public function hasReturnExpectationFor(ExpectationTarget $target) + { + if ( ! $this->hasMockFor($target)) { + return false; + } + + return $this->return_expectations->offsetExists($target->identifier()); + } + + /** + * @param \Brain\Monkey\Expectation\ExpectationTarget $target + * @return \Mockery\MockInterface|mixed + */ + public function mockFor(ExpectationTarget $target) + { + return $this->hasMockFor($target) + ? $this->expectations[$target->identifier()]->mockeryExpectation()->getMock() + : \Mockery::mock(); + } + + public function reset() + { + $this->expectations = []; + $this->return_expectations = new \ArrayObject(); + } + + /** + * @param \Brain\Monkey\Expectation\ExpectationTarget $target + * @return \Brain\Monkey\Expectation\Expectation + */ + private function create(ExpectationTarget $target) + { + $id = $target->identifier(); + + /** @noinspection PhpMethodParametersCountMismatchInspection */ + $expectation = $this->mockFor($target) + ->shouldReceive($target->mockMethodName()) + ->atLeast() + ->once(); + + if ($target->type() === ExpectationTarget::TYPE_FILTER_APPLIED) { + $expectation = $expectation->andReturnUsing(function ($arg) { + return $arg; + }); + } + + $expectation = $expectation->byDefault(); + + $this->expectations[$id] = new Expectation( + $expectation, + $target, + $this->return_expectations + ); + + return $this->expectations[$id]; + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/ExpectationTarget.php b/vendor/brain/monkey/src/Expectation/ExpectationTarget.php new file mode 100644 index 000000000..13a7c9020 --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/ExpectationTarget.php @@ -0,0 +1,191 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class ExpectationTarget +{ + + const TYPE_ACTION_ADDED = 'add_action'; + const TYPE_ACTION_DONE = 'do_action'; + const TYPE_FILTER_ADDED = 'add_filter'; + const TYPE_FILTER_APPLIED = 'apply_filters'; + const TYPE_FUNCTION = 'function'; + const TYPE_NULL = ''; + + const TYPES = [ + self::TYPE_FUNCTION, + self::TYPE_ACTION_ADDED, + self::TYPE_ACTION_DONE, + self::TYPE_FILTER_ADDED, + self::TYPE_FILTER_APPLIED, + ]; + + const HOOK_SANITIZE_MAP = [ + '-' => '_hyphen_', + ' ' => '_space_', + '/' => '_slash_', + '\\' => '_backslash_', + '.' => '_dot_', + '!' => '_exclamation_', + '"' => '_double_quote_', + '\'' => '_quote_', + '£' => '_pound_', + '$' => '_dollar_', + '%' => '_percent_', + '=' => '_equal_', + '?' => '_question_', + '*' => '_asterisk_', + '@' => '_slug_', + '#' => '_sharp_', + '+' => '_plus_', + '|' => '_pipe_', + '<' => '_lt_', + '>' => '_gt_', + ',' => '_comma_', + ';' => '_semicolon_', + ':' => '_colon_', + '~' => '_tilde_', + '(' => '_bracket_open_', + ')' => '_bracket_close_', + '[' => '_square_bracket_open_', + ']' => '_square_bracket_close_', + '{' => '_curly_bracket_open_', + '}' => '_curly_bracket_close_', + ]; + + /** + * @var string + */ + private $type; + + /** + * @var callable|string + */ + private $name; + + /** + * @var string + */ + private $original_name; + + /** + * @param string $type + * @param string $name + * @throws \Brain\Monkey\Expectation\Exception\InvalidExpectationName + * @throws \Brain\Monkey\Expectation\Exception\InvalidExpectationType + */ + public function __construct($type, $name) + { + if ( ! in_array($type, self::TYPES, true)) { + throw Exception\InvalidExpectationType::forType($name); + } + + if ( ! is_string($name)) { + throw Exception\InvalidExpectationName::forNameAndType($name, $type); + } + + $this->type = $type; + + if ($type === self::TYPE_FUNCTION) { + $nameObject = new FunctionName($name); + $namespace = str_replace('\\', '_', ltrim($nameObject->getNamespace(), '\\')); + $this->original_name = $nameObject->fullyQualifiedName(); + $this->name = $namespace + ? "{$namespace}_".$nameObject->shortName() + : $nameObject->shortName(); + + return; + } + + $this->original_name = $name; + $replaced = strtr($name, self::HOOK_SANITIZE_MAP); + $this->name = preg_replace('/[^a-zA-Z0-9_]/', '__', $replaced); + + } + + /** + * @return string + */ + public function identifier() + { + return md5($this->original_name.$this->type); + } + + /** + * @return string + */ + public function name() + { + return $this->name; + } + + /** + * @return string + */ + public function mockMethodName() + { + $name = $this->name(); + + switch ($this->type()) { + case ExpectationTarget::TYPE_FUNCTION: + break; + case ExpectationTarget::TYPE_ACTION_ADDED: + $name = "add_action_{$name}"; + break; + case ExpectationTarget::TYPE_ACTION_DONE: + $name = "do_action_{$name}"; + break; + case ExpectationTarget::TYPE_FILTER_ADDED: + $name = "add_filter_{$name}"; + break; + case ExpectationTarget::TYPE_FILTER_APPLIED: + $name = "apply_filters_{$name}"; + break; + default : + throw new \UnexpectedValueException(sprintf('Unexpected %s type.', __CLASS__)); + } + + return $name; + } + + /** + * @return string + */ + public function type() + { + return $this->type; + } + + /** + * @param \Brain\Monkey\Expectation\ExpectationTarget $target + * @return bool + */ + public function equals(ExpectationTarget $target) + { + return + $this->original_name === $target->original_name + && $this->type === $target->type; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/FunctionStub.php b/vendor/brain/monkey/src/Expectation/FunctionStub.php new file mode 100644 index 000000000..3d8b5b06f --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/FunctionStub.php @@ -0,0 +1,243 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class FunctionStub +{ + + /** + * @var \Brain\Monkey\Name\FunctionName + */ + private $function_name; + + /** + * @param FunctionName $function_name + */ + public function __construct(FunctionName $function_name) + { + $this->function_name = $function_name; + $name = $this->function_name->shortName(); + $namespace = $this->function_name->getNamespace(); + + if (function_exists($function_name->fullyQualifiedName())) { + return; + } + + $function = <<function_name->fullyQualifiedName(); + } + + /** + * Redefine target function replacing it on the fly with a given callable. + * + * @param callable $callback + */ + public function alias(callable $callback) + { + $fqn = $this->function_name->fullyQualifiedName(); + \Patchwork\redefine($fqn, $callback); + $this->assertRedefined($fqn); + } + + /** + * Redefine target function replacing it with a function that execute Brain Monkey expectation + * target method on the mock associated with given Brain Monkey expectation. + * + * @param \Brain\Monkey\Expectation\Expectation $expectation + * @return void + */ + public function redefineUsingExpectation(Expectation $expectation) + { + $fqn = $this->function_name->fullyQualifiedName(); + + $this->alias(function (...$args) use ($expectation, $fqn) { + + $mock = $expectation->mockeryExpectation()->getMock(); + $target = new ExpectationTarget(ExpectationTarget::TYPE_FUNCTION, $fqn); + + return $mock->{$target->mockMethodName()}(...$args); + }); + } + + /** + * Redefine target function making it return an arbitrary value. + * + * @param mixed $return + */ + public function justReturn($return = null) + { + $fqn = ltrim($this->function_name->fullyQualifiedName(), '\\'); + + \Patchwork\redefine($fqn, function () use ($return) { + return $return; + }); + + $this->assertRedefined($fqn); + } + + /** + * Redefine target function making it echo an arbitrary value. + * + * @param mixed $value + * @throws \Brain\Monkey\Expectation\Exception\InvalidArgumentForStub + */ + public function justEcho($value = null) + { + is_null($value) and $value = ''; + $fqn = ltrim($this->function_name->fullyQualifiedName(), '\\'); + + $this->assertPrintable($value, 'provided to justEcho'); + + \Patchwork\redefine($fqn, function () use ($value) { + echo $value; + }); + + $this->assertRedefined($fqn); + } + + /** + * Redefine target function making it return one of the received arguments, the first by + * default. Redefined function will throw an exception if the function does not receive desired + * argument. + * + * @param int $arg_num The position (1-based) of the argument to return + */ + public function returnArg($arg_num = 1) + { + $arg_num = $this->assertValidArgNum($arg_num); + + $fqn = $this->function_name->fullyQualifiedName(); + + \Patchwork\redefine($fqn, function (...$args) use ($fqn, $arg_num) { + if ( ! array_key_exists($arg_num - 1, $args)) { + $count = count($args); + throw new Exception\InvalidArgumentForStub( + "{$fqn} was called with {$count} params, can't return argument \"{$arg_num}\"." + ); + } + + return $args[$arg_num - 1]; + }); + $this->assertRedefined($fqn); + } + + /** + * Redefine target function making it echo one of the received arguments, the first by default. + * Redefined function will throw an exception if the function does not receive desired argument. + * + * @param int $arg_num The position (1-based) of the argument to echo + * @throws \Brain\Monkey\Expectation\Exception\InvalidArgumentForStub + */ + public function echoArg($arg_num = 1) + { + $arg_num = $this->assertValidArgNum($arg_num); + + $fqn = $this->function_name->fullyQualifiedName(); + + \Patchwork\redefine($fqn, function (...$args) use ($fqn, $arg_num) { + + if ( ! array_key_exists($arg_num - 1, $args)) { + $count = count($args); + throw new \RuntimeException( + "{$fqn} was called with {$count} params, can't return argument \"{$arg_num}\"." + ); + } + + $arg = $args[$arg_num - 1]; + + $this->assertPrintable($arg, "passed as argument {$arg_num} to {$fqn}"); + + echo (string) $arg; + }); + + $this->assertRedefined($fqn); + } + + /** + * @param int $arg_num + * @return bool + * @throws \Brain\Monkey\Expectation\Exception\InvalidArgumentForStub + */ + private function assertValidArgNum($arg_num) + { + if ( ! is_int($arg_num) || $arg_num <= 0) { + throw new Exception\InvalidArgumentForStub( + sprintf('`%s::returnArg()` first parameter must be a positiver integer.', __CLASS__) + ); + } + + return $arg_num; + } + + /** + * @param string $function_name + * @throws \Brain\Monkey\Expectation\Exception\MissedPatchworkReplace + */ + private function assertRedefined($function_name) + { + if (\Patchwork\hasMissed($function_name)) { + throw Exception\MissedPatchworkReplace::forFunction($function_name); + } + } + + /** + * @param $value + * @param string $coming + * @throws \Brain\Monkey\Expectation\Exception\InvalidArgumentForStub + */ + private function assertPrintable($value, $coming = '') + { + if (is_scalar($value)) { + return; + } + + $printable = + is_object($value) + && method_exists($value, '__toString') + && is_callable([$value, '__toString']); + + if ( ! $printable) { + throw new Exception\InvalidArgumentForStub( + sprintf( + "%s, %s, is not printable.", + is_object($value) ? 'Instance of '.get_class($value) : gettype($value), + $coming + ) + ); + } + + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Expectation/FunctionStubFactory.php b/vendor/brain/monkey/src/Expectation/FunctionStubFactory.php new file mode 100644 index 000000000..8bc074720 --- /dev/null +++ b/vendor/brain/monkey/src/Expectation/FunctionStubFactory.php @@ -0,0 +1,96 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class FunctionStubFactory +{ + + const SCOPE_STUB = 'a stub'; + const SCOPE_EXPECTATION = 'an expectation'; + + /** + * @var array + */ + private $storage = []; + + /** + * @param \Brain\Monkey\Name\FunctionName $name + * @param string $scope + * @return \Brain\Monkey\Expectation\FunctionStub + * @throws \Brain\Monkey\Expectation\Exception\Exception + */ + public function create(FunctionName $name, $scope) + { + $stored_type = $this->storedType($name); + + if ( ! $stored_type) { + + $stub = new FunctionStub($name); + $this->storage[$name->fullyQualifiedName()] = [$stub, $scope]; + + return $stub; + } + + if ($scope !== $stored_type) { + throw new Exception\Exception( + sprintf( + 'It was not possible to create %s for function "%s" because %s for it already exists.', + $scope, + $name->fullyQualifiedName(), + $stored_type + ) + ); + } + + list($stub) = $this->storage[$name->fullyQualifiedName()]; + + return $stub; + } + + /** + * @param \Brain\Monkey\Name\FunctionName $name + * @return bool + */ + public function has(FunctionName $name) + { + return array_key_exists($name->fullyQualifiedName(), $this->storage); + } + + /** + * @return void + */ + public function reset() + { + $this->storage = []; + } + + /** + * @param \Brain\Monkey\Name\FunctionName $name + * @return string + */ + private function storedType(FunctionName $name) + { + if ( ! $this->has($name)) { + return ''; + } + + list(, $stored_type) = $this->storage[$name->fullyQualifiedName()]; + + return $stored_type; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Hook/Exception/Exception.php b/vendor/brain/monkey/src/Hook/Exception/Exception.php new file mode 100644 index 000000000..7cbe74a3c --- /dev/null +++ b/vendor/brain/monkey/src/Hook/Exception/Exception.php @@ -0,0 +1,24 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class Exception extends BaseException +{ + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Hook/Exception/InvalidAddedHookArgument.php b/vendor/brain/monkey/src/Hook/Exception/InvalidAddedHookArgument.php new file mode 100644 index 000000000..858481fb4 --- /dev/null +++ b/vendor/brain/monkey/src/Hook/Exception/InvalidAddedHookArgument.php @@ -0,0 +1,87 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class InvalidAddedHookArgument extends InvalidHookArgument +{ + + const CODE_WRONG_ARGS_COUNT = 1; + const CODE_MISSING_CALLBACK = 2; + const CODE_INVALID_PRIORITY = 3; + const CODE_INVALID_ACCEPTED_ARGS = 4; + + /** + * @param string $type + * @return static + */ + public static function forWrongArgumentsCount($type) + { + return new static( + sprintf( + '"%s" must be called at with hook name and at maximum three other arguments: callback, priority, and accepted args num.', + $type === HookStorage::ACTIONS ? "add_action" : "add_filter" + ), + self::CODE_WRONG_ARGS_COUNT + ); + } + + /** + * @param string $type + * @return static + */ + public static function forMissingCallback($type) + { + return new static( + sprintf( + 'A callback parameter is required for "%s".', + $type === HookStorage::ACTIONS ? "add_action" : "add_filter" + ), + self::CODE_MISSING_CALLBACK + ); + } + + /** + * @param string $type + * @return static + */ + public static function forInvalidPriority($type) + { + return new static( + sprintf( + 'Priority parameter passed to "%s" must be an integer.', + $type === HookStorage::ACTIONS ? "add_action" : "add_filter" + ), + self::CODE_INVALID_PRIORITY + ); + } + + /** + * @param string $type + * @return static + */ + public static function forInvalidAcceptedArgs($type) + { + return new static( + sprintf( + 'Accepted args number parameter passed to "%s" must be an integer.', + $type === HookStorage::ACTIONS ? "add_action" : "add_filter" + ), + self::CODE_INVALID_ACCEPTED_ARGS + ); + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Hook/Exception/InvalidHookArgument.php b/vendor/brain/monkey/src/Hook/Exception/InvalidHookArgument.php new file mode 100644 index 000000000..fb7058cec --- /dev/null +++ b/vendor/brain/monkey/src/Hook/Exception/InvalidHookArgument.php @@ -0,0 +1,79 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class InvalidHookArgument extends Exception +{ + + /** + * @param mixed $type + * @return static + */ + public static function forInvalidType($type) + { + return new static( + sprintf( + 'HookStorage hook type must either HookStorage::ACTIONS or HookStorage::FILTERS, got %s.', + is_object($type) ? ' instance of '.get_class($type) : gettype($type) + ) + ); + } + + /** + * @param mixed $type + * @return static + */ + public static function forInvalidHook($type) + { + return new static( + sprintf( + 'Hook name must be in a string, got %s.', + is_object($type) ? ' instance of '.get_class($type) : gettype($type) + ) + ); + } + + /** + * @param string $key + * @param string $type + * @return static + */ + public static function forEmptyArguments($key, $type) + { + $function = $missing = ''; + + switch ($type) { + case HookStorage::ACTIONS: + $missing = 'callback'; + $function = $key === HookStorage::ADDED ? "'add_action'" : "'do_action'"; + break; + case HookStorage::FILTERS: + $missing = $key === HookStorage::ADDED ? 'callback' : 'first'; + $function = $key === HookStorage::ADDED ? "'add_filter'" : "'apply_filters'"; + break; + } + + return new static( + sprintf( + 'Missing %s required argument for %s.', + $missing, + $function + ) + ); + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Hook/HookExpectationExecutor.php b/vendor/brain/monkey/src/Hook/HookExpectationExecutor.php new file mode 100644 index 000000000..2f7b13cef --- /dev/null +++ b/vendor/brain/monkey/src/Hook/HookExpectationExecutor.php @@ -0,0 +1,119 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class HookExpectationExecutor +{ + + /** + * @var \Brain\Monkey\Hook\HookRunningStack + */ + private $stack; + + /** + * @var \Brain\Monkey\Expectation\ExpectationFactory + */ + private $factory; + + /** + * @param \Brain\Monkey\Hook\HookRunningStack $stack + * @param \Brain\Monkey\Expectation\ExpectationFactory $factory + */ + public function __construct(HookRunningStack $stack, ExpectationFactory $factory) + { + $this->stack = $stack; + $this->factory = $factory; + } + + /** + * @param string $action + * @param array $args + */ + public function executeAddAction($action, array $args) + { + $this->execute(ExpectationTarget::TYPE_ACTION_ADDED, $action, $args); + } + + /** + * @param string $action + * @param array $args + */ + public function executeAddFilter($action, array $args) + { + $this->execute(ExpectationTarget::TYPE_FILTER_ADDED, $action, $args); + } + + /** + * @param string $action + * @param array $args + */ + public function executeDoAction($action, array $args = []) + { + $is_running = $this->stack->has(); + $this->stack->push($action); + $this->execute(ExpectationTarget::TYPE_ACTION_DONE, $action, $args); + $is_running or $this->stack->reset(); + } + + /** + * @param string $filter + * @param array $args + * @return mixed|null + */ + public function executeApplyFilters($filter, array $args) + { + + $is_running = $this->stack->has(); + $this->stack->push($filter); + $return = $this->execute(ExpectationTarget::TYPE_FILTER_APPLIED, $filter, $args); + $is_running or $this->stack->reset(); + + return $return; + } + + /** + * @param string $type + * @param string $hook + * @param array $args + * @return mixed + */ + private function execute($type, $hook, array $args) + { + $target = new ExpectationTarget($type, $hook); + if ($this->factory->hasMockFor($target)) { + $method = $target->mockMethodName(); + + $return = $this->factory->mockFor($target)->{$method}(...$args); + $this->factory->hasReturnExpectationFor($target) or $return = reset($args); + + return $return; + } + + if ($type === ExpectationTarget::TYPE_FILTER_APPLIED) { + return reset($args); + } + + return null; + + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Hook/HookRunningStack.php b/vendor/brain/monkey/src/Hook/HookRunningStack.php new file mode 100644 index 000000000..572870f94 --- /dev/null +++ b/vendor/brain/monkey/src/Hook/HookRunningStack.php @@ -0,0 +1,76 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class HookRunningStack +{ + + /** + * @var array + */ + private $stack = []; + + /** + * @param string $hook_name + * @return static + */ + public function push($hook_name) + { + $this->stack[] = $hook_name; + + return $this; + } + + /** + * @return string + */ + public function last() + { + if ( ! $this->stack) { + return ''; + } + + return end($this->stack); + } + + /** + * @param string $hook_name + * @return bool + */ + public function has($hook_name = null) + { + if ( ! $this->stack) { + return false; + } + + return $hook_name === null ? true : in_array($hook_name, $this->stack, true); + } + + /** + * @return static + */ + public function reset() + { + $this->stack = []; + + return $this; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Hook/HookStorage.php b/vendor/brain/monkey/src/Hook/HookStorage.php new file mode 100644 index 000000000..bbb188f7c --- /dev/null +++ b/vendor/brain/monkey/src/Hook/HookStorage.php @@ -0,0 +1,239 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class HookStorage +{ + + const ACTIONS = 'actions'; + const FILTERS = 'filters'; + const ADDED = 'added'; + const DONE = 'done'; + + private $storage = [ + self::ADDED => [], + self::DONE => [] + ]; + + /** + * @return void + */ + public function reset() + { + $this->storage = [ + self::ADDED => [], + self::DONE => [] + ]; + } + + /** + * @param string $type + * @param string $hook + * @param array $args + * @return static + */ + public function pushToAdded($type, $hook, array $args) + { + return $this->pushToStorage(self::ADDED, $type, $hook, $args); + } + + /** + * @param string $type + * @param string $hook + * @param array $args + * @return bool + */ + public function removeFromAdded($type, $hook, array $args) + { + if ( ! $this->isHookAdded($type, $hook)) { + return false; + } + + if ( ! $args) { + unset($this->storage[self::ADDED][$type][$hook]); + + return true; + } + + $args = $this->parseArgsToAdd($args, self::ADDED, $type); + + $all = $this->storage[self::ADDED][$type][$hook]; + $removed = 0; + + /** + * @var CallbackStringForm $callback + */ + foreach ($all as $key => list($callback, $priority)) { + if ($callback->equals($args[0]) && $priority === $args[1]) { + unset($all[$key]); + $removed++; + } + } + + $removed and $this->storage[self::ADDED][$type][$hook] = array_values($all); + if ( ! $this->storage[self::ADDED][$type][$hook]) { + unset($this->storage[self::ADDED][$type][$hook]); + } + + return $removed > 0; + } + + /** + * @param string $type + * @param string $hook + * @param array $args + * @return static + */ + public function pushToDone($type, $hook, array $args) + { + return $this->pushToStorage(self::DONE, $type, $hook, $args); + } + + /** + * @param string $type + * @param string $hook + * @param callable|null $function + * @return bool + */ + public function isHookAdded($type, $hook, $function = null) + { + return $this->isInStorage(self::ADDED, $type, $hook, $function); + } + + /** + * @param $type + * @param $hook + * @return int + */ + public function isHookDone($type, $hook) + { + return $this->isInStorage(self::DONE, $type, $hook); + } + + /** + * @param string $key + * @param string $type + * @param string $hook + * @param array $args + * @return static + * @throws \Brain\Monkey\Hook\Exception\InvalidHookArgument + */ + private function pushToStorage($key, $type, $hook, array $args) + { + if ($type !== self::ACTIONS && $type !== self::FILTERS) { + throw Exception\InvalidHookArgument::forInvalidType($type); + } + + if ( ! is_string($hook)) { + throw Exception\InvalidHookArgument::forInvalidHook($hook); + } + + // do_action() is the only of target functions that can be called without additional arguments + if ( ! $args && ($key !== self::DONE || $type !== self::ACTIONS)) { + throw Exception\InvalidHookArgument::forEmptyArguments($key, $type); + } + + $storage = &$this->storage[$key]; + + array_key_exists($type, $storage) or $storage[$type] = []; + array_key_exists($hook, $storage[$type]) or $storage[$type][$hook] = []; + + if ($key === self::ADDED) { + $args = $this->parseArgsToAdd($args, $key, $type); + } + + $storage[$type][$hook][] = $args; + + return $this; + } + + /** + * @param string $key + * @param string $type + * @param string $hook + * @param callable|null $function + * @return int|bool + * @throws \Brain\Monkey\Hook\Exception\InvalidHookArgument + */ + private function isInStorage($key, $type, $hook, $function = null) + { + $storage = $this->storage[$key]; + + if ( ! in_array($type, [self::ACTIONS, self::FILTERS], true)) { + throw Exception\InvalidHookArgument::forInvalidType($type); + } + + if ( ! array_key_exists($type, $storage) || ! array_key_exists($hook, $storage[$type])) { + return $key === self::ADDED ? false : 0; + } + + if ($function === null) { + return $key === self::ADDED ? true : count($storage[$type][$hook]); + } + + $filter = function (array $args) use ($function) { + return $args[0]->equals(new CallbackStringForm($function)); + }; + + $matching = array_filter($storage[$type][$hook], $filter); + + return $key === self::ADDED ? (bool)$matching : count($matching); + } + + /** + * @param array $args + * @param string $key + * @param string $type + * @return array + * @throws \Brain\Monkey\Hook\Exception\InvalidHookArgument + */ + private function parseArgsToAdd(array $args, $key, $type) + { + if ( ! $args) { + throw Exception\InvalidHookArgument::forEmptyArguments($key, $type); + } + + if ( ! count($args) > 3) { + throw Exception\InvalidAddedHookArgument::forWrongArgumentsCount($type); + } + + $args = array_replace([null, 10, 1], array_values($args)); + + if ( ! $args[0]) { + throw Exception\InvalidAddedHookArgument::forMissingCallback($type); + } + + $args[0] = new CallbackStringForm($args[0]); + + if ( ! is_int($args[1])) { + throw Exception\InvalidAddedHookArgument::forInvalidPriority($type); + } + + if ( ! is_int($args[2])) { + throw Exception\InvalidAddedHookArgument::forInvalidAcceptedArgs($type); + } + + return $args; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/CallbackStringForm.php b/vendor/brain/monkey/src/Name/CallbackStringForm.php new file mode 100644 index 000000000..6431b5739 --- /dev/null +++ b/vendor/brain/monkey/src/Name/CallbackStringForm.php @@ -0,0 +1,181 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class CallbackStringForm +{ + + /** + * @var string + */ + private $parsed; + + /** + * @param callable $callback + */ + public function __construct($callback) + { + $this->parsed = $this->parseCallback($callback); + } + + /** + * @param \Brain\Monkey\Name\CallbackStringForm $callback + * @return bool + */ + public function equals(CallbackStringForm $callback) + { + return (string)$this === (string)$callback; + } + + /** + * @return string + * @throws \Brain\Monkey\Name\Exception\NotInvokableObjectAsCallback + */ + public function __toString() + { + return $this->parsed; + } + + /** + * @param $callback + * @return string + * @throws \Brain\Monkey\Name\Exception\InvalidCallable + * @throws \Brain\Monkey\Name\Exception\NotInvokableObjectAsCallback + */ + private function parseCallback($callback) + { + if ( ! is_callable($callback, true)) { + throw Exception\InvalidCallable::forCallable($callback); + } + + if (is_string($callback)) { + return $this->parseString($callback); + } + + $is_object = is_object($callback); + + if ($is_object && ! is_callable($callback)) { + throw new Exception\NotInvokableObjectAsCallback(); + } + + if ($is_object) { + return $callback instanceof \Closure + ? (string)new ClosureStringForm($callback) + : get_class($callback).'()'; + } + + list($object, $method) = $callback; + + $method_name = (new MethodName($method))->name(); + + if (is_string($object)) { + $class_name = (new ClassName($object))->fullyQualifiedName(); + + $this->assertMethodCallable($class_name, $method_name, $callback); + + return "{$class_name}::{$method_name}()"; + } + + if ( ! is_callable([$object, $method_name])) { + throw new Exception\NotInvokableObjectAsCallback(); + } + + $class_name = (new ClassName(get_class($object)))->fullyQualifiedName(); + + return ltrim("{$class_name}->{$method_name}()", '\\'); + } + + /** + * @param string $callback + * @return bool|string + * @throws \Brain\Monkey\Name\Exception\InvalidCallable + * @throws \Brain\Monkey\Name\Exception\NotInvokableObjectAsCallback + */ + private function parseString($callback) + { + $callback = trim($callback); + + if ( + (strpos($callback, 'function') === 0 || strpos($callback, 'static') === 0) + && substr($callback, -1) === ')' + ) { + try { + return ClosureStringForm::normalizeString($callback); + } catch (Exception\Exception $exception) { + throw Exception\InvalidCallable::forCallable($callback); + } + } + + // If this is not a string in normalized form, we just check is a valid function name + if (substr($callback, -2) !== '()') { + return (new FunctionName($callback))->fullyQualifiedName(); + } + + // remove parenthesis + $callback = substr($callback, 0, -2); + + $is_dynamic_method = substr_count($callback, '->') === 1; + $is_static_method = substr_count($callback, '::') === 1; + + // If this is a normalized form of a static or dynamic method let's check that both class + // and method names are fine + if ($is_dynamic_method || $is_static_method) { + $separator = $is_dynamic_method ? '->' : '::'; + list($class, $method) = explode($separator, $callback); + $class_name = (new ClassName($class))->fullyQualifiedName(); + $method_name = (new MethodName($method))->name(); + $this->assertMethodCallable($class_name, $method, "{$callback}()"); + + return ltrim("{$class_name}{$separator}{$method_name}()", '\\'); + } + + // Last chance is that the string is fully qualified name of an invokable object. + $class_name = (new ClassName($callback))->fullyQualifiedName(); + // Check `__invoke` method existence only if class is available + if (class_exists($class_name) && ! method_exists($class_name, '__invoke')) { + throw new Exception\NotInvokableObjectAsCallback(); + } + + return ltrim("{$class_name}()", '\\'); + } + + /** + * Ensure method existence only if class is available. + * + * @param string $class_name + * @param string $method + * @param string|array $callable + * @throws \Brain\Monkey\Name\Exception\InvalidCallable + * @throws \Brain\Monkey\Name\Exception\NotInvokableObjectAsCallback + */ + private function assertMethodCallable($class_name, $method, $callable) + { + if ( + class_exists($class_name) + && ! (method_exists($class_name, $method) || is_callable([$class_name, $method])) + ) { + throw Exception\InvalidCallable::forCallable($callable); + } + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/ClassName.php b/vendor/brain/monkey/src/Name/ClassName.php new file mode 100644 index 000000000..22653d9e0 --- /dev/null +++ b/vendor/brain/monkey/src/Name/ClassName.php @@ -0,0 +1,72 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class ClassName +{ + + /** + * @var \Brain\Monkey\Name\FunctionName + */ + private $function_name; + + /** + * @param string $class_name + * @throws \Brain\Monkey\Name\Exception\InvalidName + */ + public function __construct($class_name) + { + try { + $this->function_name = new FunctionName($class_name); + } catch (Exception\InvalidName $e) { + throw Exception\InvalidName::forClass($class_name); + } + } + + /** + * @return string + */ + public function fullyQualifiedName() + { + return $this->function_name->fullyQualifiedName(); + } + + /** + * @return string + */ + public function shortName() + { + return $this->function_name->shortName(); + } + + /** + * @return string + */ + public function getNamespace() + { + return $this->function_name->getNamespace(); + } + + /** + * @param \Brain\Monkey\Name\ClassName $name + * @return bool + */ + public function equals(ClassName $name) + { + return $this->fullyQualifiedName() === $name->fullyQualifiedName(); + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/ClosureParamStringForm.php b/vendor/brain/monkey/src/Name/ClosureParamStringForm.php new file mode 100644 index 000000000..3ab23e063 --- /dev/null +++ b/vendor/brain/monkey/src/Name/ClosureParamStringForm.php @@ -0,0 +1,131 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class ClosureParamStringForm +{ + + const VALID_PARAM_PATTERN = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/'; + + private $param_name; + /** + * @var string + */ + private $type_name; + /** + * @var bool + */ + private $variadic; + + /** + * @param string $param + * @return static + * @throws \Brain\Monkey\Name\Exception\InvalidClosureParam + */ + public static function fromString($param) + { + $param = trim($param); + + $variadic = substr_count($param, '...') === 1; + $variadic and $param = str_replace('.', '', $param); + $parts = array_filter(explode(' ', $param)); + $count = count($parts); + + if ($count !== 2 && $count !== 1) { + throw InvalidClosureParam::forInvalidName($param); + } + + $name = array_pop($parts); + $type = $parts ? ltrim(array_pop($parts), '\\') : ''; + + strpos($name, '$') === 0 and $name = substr($name, 1); + + if ($name && ! preg_match(self::VALID_PARAM_PATTERN, $name)) { + throw InvalidClosureParam::forInvalidName($name); + } + + if ($type && ! preg_match(self::VALID_PARAM_PATTERN, $type)) { + throw InvalidClosureParam::forInvalidType($type, $name); + } + + return new static($name, $type, $variadic); + } + + /** + * @param \ReflectionParameter $parameter + * @return static + */ + public static function fromReflectionParameter(\ReflectionParameter $parameter) + { + $type = ''; + if (PHP_MAJOR_VERSION >= 7) { + $type = $parameter->hasType() ? ltrim($parameter->getType(), '\\') : ''; + } + + return new static($parameter->getName(), $type, $parameter->isVariadic()); + } + + /** + * @param string $param_name + * @param string $type_name + * @param bool $variadic + * @throws \Brain\Monkey\Name\Exception\InvalidClosureParam + */ + private function __construct($param_name, $type_name = '', $variadic = false) + { + if ( ! is_string($param_name) || ! $param_name) { + throw InvalidClosureParam::forInvalidName($param_name); + } + + (PHP_MAJOR_VERSION < 7) and $type_name = ''; + + $this->param_name = $param_name; + $this->type_name = $type_name; + $this->variadic = $variadic; + } + + /** + * @param \Brain\Monkey\Name\ClosureParamStringForm $param + * @return bool + */ + public function equals(ClosureParamStringForm $param) + { + return $this->__toString() === (string)$param; + } + + /** + * @return string + */ + public function __toString() + { + $string = $this->type_name ? "{$this->type_name} " : ''; + $this->variadic and $string .= '...'; + $string .= '$'.$this->param_name; + + return $string; + } + + /** + * @return bool + */ + public function isVariadic() + { + return $this->variadic; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/ClosureStringForm.php b/vendor/brain/monkey/src/Name/ClosureStringForm.php new file mode 100644 index 000000000..0db51d2c8 --- /dev/null +++ b/vendor/brain/monkey/src/Name/ClosureStringForm.php @@ -0,0 +1,128 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class ClosureStringForm +{ + + const CLOSURE_PATTERN = '/^(static\s+)?function\s*\((.*?)\)$/'; + + /** + * @var string + */ + private $name; + + /** + * @param string $closure_string + * @return string + * @throws \Brain\Monkey\Name\Exception\InvalidCallable + * @throws \Brain\Monkey\Name\Exception\NotInvokableObjectAsCallback + */ + public static function normalizeString($closure_string) + { + if ( + ! is_string($closure_string) + || ! preg_match(self::CLOSURE_PATTERN, trim($closure_string), $matches) + ) { + throw InvalidCallable::forCallable($closure_string); + } + + $raw_params = trim($matches[2]); + $static = trim($matches[1]); + + $normalized = $static ? 'static function (' : 'function ('; + + if ( ! $raw_params) { + return "{$normalized})"; + } + + $variadic = false; + $params = explode(',', $raw_params); + + $normalized = array_reduce($params, function ($normalized, $param_name) use (&$variadic) { + + $param = ClosureParamStringForm::fromString($param_name); + + $is_variadic = $param->isVariadic(); + if ($variadic && $is_variadic) { + throw InvalidClosureParam::forMultipleVariadic($param_name); + } + + $is_variadic and $variadic = true; + + return $normalized.(string)$param.', '; + + }, $normalized); + + return rtrim($normalized, ', ').')'; + } + + /** + * @param \Closure $closure + */ + public function __construct(\Closure $closure) + { + $this->name = $this->buildName($closure); + } + + /** + * @return string + */ + public function __toString() + { + return $this->name; + } + + /** + * @param \Brain\Monkey\Name\ClosureStringForm $name + * @return bool + */ + public function equals(ClosureStringForm $name) + { + return $this->__toString() === (string)$name; + } + + /** + * Checks the name of a function and throw an exception if is not valid. + * When name is valid returns an array of the name itself and its namespace parts. + * + * @param \Closure $closure + * @return string + */ + private function buildName(\Closure $closure) + { + $reflection = new \ReflectionFunction($closure); + + // Quite hackish, but it seems there's no better way to get if a closure is static + $bind = @\Closure::bind($closure, new \stdClass); + $static = + $bind === null + || (new \ReflectionFunction($bind))->getClosureThis() === null; + + $arguments = array_map('strval', array_map( + [ClosureParamStringForm::class, 'fromReflectionParameter'], + $reflection->getParameters() + )); + + $name = $static ? 'static function (' : 'function ('; + + return $name.implode($arguments, ', ').')'; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/Exception/Exception.php b/vendor/brain/monkey/src/Name/Exception/Exception.php new file mode 100644 index 000000000..0a4385d54 --- /dev/null +++ b/vendor/brain/monkey/src/Name/Exception/Exception.php @@ -0,0 +1,24 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class Exception extends BaseException +{ + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/Exception/InvalidCallable.php b/vendor/brain/monkey/src/Name/Exception/InvalidCallable.php new file mode 100644 index 000000000..84e789963 --- /dev/null +++ b/vendor/brain/monkey/src/Name/Exception/InvalidCallable.php @@ -0,0 +1,41 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class InvalidCallable extends Exception +{ + + /** + * @param $callback + * @return \Brain\Monkey\Name\Exception\InvalidCallable|\Brain\Monkey\Name\Exception\NotInvokableObjectAsCallback + */ + public static function forCallable($callback) + { + if (is_object($callback)) { + return new NotInvokableObjectAsCallback(); + } + + return new static( + sprintf( + 'Given %s "%s" is not a valid PHP callable.', + gettype($callback), + is_string($callback) ? "{$callback}" : var_export($callback, true) + ) + ); + + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/Exception/InvalidClosureParam.php b/vendor/brain/monkey/src/Name/Exception/InvalidClosureParam.php new file mode 100644 index 000000000..75662fda4 --- /dev/null +++ b/vendor/brain/monkey/src/Name/Exception/InvalidClosureParam.php @@ -0,0 +1,66 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class InvalidClosureParam extends Exception +{ + + const CODE_INVALID_NAME = 1; + const CODE_INVALID_TYPE = 2; + const CODE_MULTIPLE_VARIADIC = 3; + + /** + * @param $name + * @return static + */ + public static function forInvalidName($name) + { + return new static( + sprintf('%s is not a valid function argument name.', $name), + self::CODE_INVALID_NAME + ); + } + + /** + * @param $type + * @param $name + * @return static + */ + public static function forInvalidType($type, $name) + { + return new static( + sprintf('%s is not a valid function argument type for argument %s.', $type, $name), + self::CODE_INVALID_NAME + ); + } + + /** + * @param $name + * @return static + */ + public static function forMultipleVariadic($name) + { + return new static( + sprintf( + '%s is a variadic argument for a function that already has a variadic argument.', + $name + ), + self::CODE_INVALID_NAME + ); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/Exception/InvalidName.php b/vendor/brain/monkey/src/Name/Exception/InvalidName.php new file mode 100644 index 000000000..923681ef5 --- /dev/null +++ b/vendor/brain/monkey/src/Name/Exception/InvalidName.php @@ -0,0 +1,83 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class InvalidName extends Exception +{ + + const CODE_FOR_FUNCTION = 1; + const CODE_FOR_CLASS = 2; + const CODE_FOR_METHOD = 3; + + /** + * @param string $function + * @return \Brain\Monkey\Name\Exception\InvalidName + */ + public static function forFunction($function) + { + return self::createFor($function, self::CODE_FOR_FUNCTION); + } + + /** + * @param $class + * @return \Brain\Monkey\Name\Exception\InvalidName + */ + public static function forClass($class) + { + return self::createFor($class, self::CODE_FOR_CLASS); + } + + /** + * @param $function + * @return \Brain\Monkey\Name\Exception\InvalidName + */ + public static function forMethod($function) + { + return self::createFor($function, self::CODE_FOR_METHOD); + } + + /** + * @param string $thing + * @param int $code + * @return static + */ + private static function createFor($thing, $code) + { + switch ($code) { + case self::CODE_FOR_CLASS: + $type = 'class'; + break; + case self::CODE_FOR_METHOD: + $type = 'class method'; + break; + case self::CODE_FOR_FUNCTION: + default: + $type = 'function'; + break; + } + + $name = "'{$thing}'"; + if ( ! is_string($thing)) { + $name = is_object($thing) + ? 'An instance of '.get_class($thing) + : 'A variable of type '.gettype($thing); + } + + return new static(sprintf('%s is not a valid %s name.', $name, $type), $code); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/Exception/NotInvokableObjectAsCallback.php b/vendor/brain/monkey/src/Name/Exception/NotInvokableObjectAsCallback.php new file mode 100644 index 000000000..2738a5192 --- /dev/null +++ b/vendor/brain/monkey/src/Name/Exception/NotInvokableObjectAsCallback.php @@ -0,0 +1,29 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +class NotInvokableObjectAsCallback extends Exception +{ + + public function __construct() + { + parent::__construct( + 'Only closures and invokable objects can be used as callbacks for hooks.' + ); + } + +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/FunctionName.php b/vendor/brain/monkey/src/Name/FunctionName.php new file mode 100644 index 000000000..71fe6489a --- /dev/null +++ b/vendor/brain/monkey/src/Name/FunctionName.php @@ -0,0 +1,98 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class FunctionName +{ + + const VALID_NAME_PATTERN = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/'; + + /** + * @var string + */ + private $function_name = ''; + + /** + * @var string + */ + private $namespace = ''; + + /** + * @param string $function_name + */ + public function __construct($function_name) + { + list($this->function_name, $this->namespace) = $this->parseName($function_name); + } + + /** + * @return string + */ + public function fullyQualifiedName() + { + return ltrim("{$this->namespace}\\{$this->function_name}", '\\'); + } + + /** + * @return string + */ + public function shortName() + { + return $this->function_name; + } + + /** + * @return string + */ + public function getNamespace() + { + return $this->namespace; + } + + /** + * @param \Brain\Monkey\Name\FunctionName $name + * @return bool + */ + public function equals(FunctionName $name) + { + return $this->fullyQualifiedName() === $name->fullyQualifiedName(); + } + + /** + * Checks the name of a function and throw an exception if is not valid. + * When name is valid returns an array of the name itself and its namespace parts. + * + * @param string $function_name + * @return \string[] + * @throws \Brain\Monkey\Name\Exception\InvalidName + */ + private function parseName($function_name) + { + $chunks = is_string($function_name) ? explode('\\', ltrim($function_name, '\\')) : null; + $valid = $chunks ? preg_filter(self::VALID_NAME_PATTERN, '$0', $chunks) : null; + + if ( ! $valid || $valid !== $chunks) { + $name = is_string($function_name) + ? "'{$function_name}'" + : 'Variable of type '.gettype($function_name); + + throw Exception\InvalidName::forFunction($name); + } + + return [array_pop($chunks), implode('\\', $chunks)]; + } +} \ No newline at end of file diff --git a/vendor/brain/monkey/src/Name/MethodName.php b/vendor/brain/monkey/src/Name/MethodName.php new file mode 100644 index 000000000..abe9bdbaa --- /dev/null +++ b/vendor/brain/monkey/src/Name/MethodName.php @@ -0,0 +1,62 @@ + + * @package BrainMonkey + * @license http://opensource.org/licenses/MIT MIT + */ +final class MethodName +{ + + /** + * @var string + */ + private $name; + + /** + * @param string $method_name + * @throws \Brain\Monkey\Name\Exception\InvalidName + */ + public function __construct($method_name) + { + try { + $function_name = new FunctionName($method_name); + } catch (Exception\InvalidName $e) { + throw Exception\InvalidName::forMethod($method_name); + } + + if ($function_name->getNamespace()) { + throw Exception\InvalidName::forMethod($method_name); + } + + $this->name = $function_name->shortName(); + } + + /** + * @return string + */ + public function name() + { + return $this->name; + } + + /** + * @param \Brain\Monkey\Name\MethodName $name + * @return bool + */ + public function equals(MethodName $name) + { + return $this->name() === $name->name(); + } +} \ No newline at end of file diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index dc02dfb11..95f7e0978 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -377,7 +377,7 @@ private function findFileWithExtension($class, $ext) $subPath = $class; while (false !== $lastPos = strrpos($subPath, '\\')) { $subPath = substr($subPath, 0, $lastPos); - $search = $subPath.'\\'; + $search = $subPath . '\\'; if (isset($this->prefixDirsPsr4[$search])) { $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); foreach ($this->prefixDirsPsr4[$search] as $dir) { diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index a0c3a809a..8330bd042 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -9,6 +9,74 @@ 'File_Iterator' => $vendorDir . '/phpunit/php-file-iterator/src/Iterator.php', 'File_Iterator_Facade' => $vendorDir . '/phpunit/php-file-iterator/src/Facade.php', 'File_Iterator_Factory' => $vendorDir . '/phpunit/php-file-iterator/src/Factory.php', + 'Hamcrest\\Arrays\\IsArray' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArray.php', + 'Hamcrest\\Arrays\\IsArrayContaining' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContaining.php', + 'Hamcrest\\Arrays\\IsArrayContainingInAnyOrder' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php', + 'Hamcrest\\Arrays\\IsArrayContainingInOrder' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInOrder.php', + 'Hamcrest\\Arrays\\IsArrayContainingKey' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php', + 'Hamcrest\\Arrays\\IsArrayContainingKeyValuePair' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php', + 'Hamcrest\\Arrays\\IsArrayWithSize' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayWithSize.php', + 'Hamcrest\\Arrays\\MatchingOnce' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/MatchingOnce.php', + 'Hamcrest\\Arrays\\SeriesMatchingOnce' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/SeriesMatchingOnce.php', + 'Hamcrest\\AssertionError' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/AssertionError.php', + 'Hamcrest\\BaseDescription' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/BaseDescription.php', + 'Hamcrest\\BaseMatcher' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/BaseMatcher.php', + 'Hamcrest\\Collection\\IsEmptyTraversable' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php', + 'Hamcrest\\Collection\\IsTraversableWithSize' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsTraversableWithSize.php', + 'Hamcrest\\Core\\AllOf' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/AllOf.php', + 'Hamcrest\\Core\\AnyOf' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/AnyOf.php', + 'Hamcrest\\Core\\CombinableMatcher' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/CombinableMatcher.php', + 'Hamcrest\\Core\\DescribedAs' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/DescribedAs.php', + 'Hamcrest\\Core\\Every' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Every.php', + 'Hamcrest\\Core\\HasToString' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/HasToString.php', + 'Hamcrest\\Core\\Is' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Is.php', + 'Hamcrest\\Core\\IsAnything' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsAnything.php', + 'Hamcrest\\Core\\IsCollectionContaining' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsCollectionContaining.php', + 'Hamcrest\\Core\\IsEqual' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsEqual.php', + 'Hamcrest\\Core\\IsIdentical' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsIdentical.php', + 'Hamcrest\\Core\\IsInstanceOf' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsInstanceOf.php', + 'Hamcrest\\Core\\IsNot' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNot.php', + 'Hamcrest\\Core\\IsNull' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNull.php', + 'Hamcrest\\Core\\IsSame' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsSame.php', + 'Hamcrest\\Core\\IsTypeOf' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsTypeOf.php', + 'Hamcrest\\Core\\Set' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Set.php', + 'Hamcrest\\Core\\ShortcutCombination' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/ShortcutCombination.php', + 'Hamcrest\\Description' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Description.php', + 'Hamcrest\\DiagnosingMatcher' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/DiagnosingMatcher.php', + 'Hamcrest\\FeatureMatcher' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/FeatureMatcher.php', + 'Hamcrest\\Internal\\SelfDescribingValue' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Internal/SelfDescribingValue.php', + 'Hamcrest\\Matcher' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matcher.php', + 'Hamcrest\\MatcherAssert' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/MatcherAssert.php', + 'Hamcrest\\Matchers' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matchers.php', + 'Hamcrest\\NullDescription' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/NullDescription.php', + 'Hamcrest\\Number\\IsCloseTo' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Number/IsCloseTo.php', + 'Hamcrest\\Number\\OrderingComparison' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Number/OrderingComparison.php', + 'Hamcrest\\SelfDescribing' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/SelfDescribing.php', + 'Hamcrest\\StringDescription' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/StringDescription.php', + 'Hamcrest\\Text\\IsEmptyString' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEmptyString.php', + 'Hamcrest\\Text\\IsEqualIgnoringCase' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php', + 'Hamcrest\\Text\\IsEqualIgnoringWhiteSpace' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php', + 'Hamcrest\\Text\\MatchesPattern' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/MatchesPattern.php', + 'Hamcrest\\Text\\StringContains' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContains.php', + 'Hamcrest\\Text\\StringContainsIgnoringCase' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsIgnoringCase.php', + 'Hamcrest\\Text\\StringContainsInOrder' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsInOrder.php', + 'Hamcrest\\Text\\StringEndsWith' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringEndsWith.php', + 'Hamcrest\\Text\\StringStartsWith' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringStartsWith.php', + 'Hamcrest\\Text\\SubstringMatcher' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/SubstringMatcher.php', + 'Hamcrest\\TypeSafeDiagnosingMatcher' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/TypeSafeDiagnosingMatcher.php', + 'Hamcrest\\TypeSafeMatcher' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/TypeSafeMatcher.php', + 'Hamcrest\\Type\\IsArray' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsArray.php', + 'Hamcrest\\Type\\IsBoolean' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsBoolean.php', + 'Hamcrest\\Type\\IsCallable' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsCallable.php', + 'Hamcrest\\Type\\IsDouble' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsDouble.php', + 'Hamcrest\\Type\\IsInteger' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsInteger.php', + 'Hamcrest\\Type\\IsNumeric' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsNumeric.php', + 'Hamcrest\\Type\\IsObject' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsObject.php', + 'Hamcrest\\Type\\IsResource' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsResource.php', + 'Hamcrest\\Type\\IsScalar' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsScalar.php', + 'Hamcrest\\Type\\IsString' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsString.php', + 'Hamcrest\\Util' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Util.php', + 'Hamcrest\\Xml\\HasXPath' => $vendorDir . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Xml/HasXPath.php', 'PHPUnit\\Framework\\TestCase' => $vendorDir . '/phpunit/phpunit/src/ForwardCompatibility/TestCase.php', 'PHPUnit_Exception' => $vendorDir . '/phpunit/phpunit/src/Exception.php', 'PHPUnit_Extensions_GroupTestSuite' => $vendorDir . '/phpunit/phpunit/src/Extensions/GroupTestSuite.php', diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index 3a42d23e7..bf19cde4b 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -7,7 +7,9 @@ return array( '320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', + '051bafe20e2674435a162870efa2d2a7' => $vendorDir . '/brain/monkey/inc/api.php', '6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php', '653f15cae3415bbad33eff25628b45a8' => $vendorDir . '/calderawp/caldera-forms-query/src/CalderaFormsQueries.php', '5e73ffc188f5a63fbd263c4490731358' => $vendorDir . '/inpsyde/wonolog/inc/bootstrap.php', + 'e3b369f785b64e46a24dc3ca6f0257a1' => $baseDir . '/tests/testing-cli.php', ); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 17cb44990..46bee6fcf 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -6,6 +6,8 @@ $baseDir = dirname($vendorDir); return array( + 'johnpbloch\\Composer\\' => array($vendorDir . '/johnpbloch/wordpress-core-installer/src'), 'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src'), 'Pimple' => array($vendorDir . '/pimple/pimple/src'), + 'Mockery' => array($vendorDir . '/mockery/mockery/library'), ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index ffe8e0c0d..dc7eaedc9 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -8,6 +8,9 @@ return array( 'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'), 'calderawp\\calderaforms\\pro\\' => array($baseDir . '/includes/cf-pro-client/classes'), + 'calderawp\\calderaforms\\Tests\\Util\\Traits\\' => array($baseDir . '/tests/Util/Traits'), + 'calderawp\\calderaforms\\Tests\\Util\\' => array($baseDir . '/tests/Util'), + 'calderawp\\calderaforms\\Tests\\Unit\\' => array($baseDir . '/tests/Unit'), 'calderawp\\CalderaFormsQuery\\' => array($vendorDir . '/calderawp/caldera-forms-query/src'), 'calderawp\\CalderaContainers\\' => array($vendorDir . '/calderawp/caldera-containers/src'), 'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'), @@ -21,4 +24,6 @@ 'Inpsyde\\Wonolog\\' => array($vendorDir . '/inpsyde/wonolog/src'), 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'), 'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'), + 'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src/Composer/Installers'), + 'Brain\\Monkey\\' => array($vendorDir . '/brain/monkey/src'), ); diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index c2f580ee1..900996f0e 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -8,9 +8,11 @@ class ComposerStaticInit734406fe75b0a330f41f48930525b165 { public static $files = array ( '320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', + '051bafe20e2674435a162870efa2d2a7' => __DIR__ . '/..' . '/brain/monkey/inc/api.php', '6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php', '653f15cae3415bbad33eff25628b45a8' => __DIR__ . '/..' . '/calderawp/caldera-forms-query/src/CalderaFormsQueries.php', '5e73ffc188f5a63fbd263c4490731358' => __DIR__ . '/..' . '/inpsyde/wonolog/inc/bootstrap.php', + 'e3b369f785b64e46a24dc3ca6f0257a1' => __DIR__ . '/../..' . '/tests/testing-cli.php', ); public static $prefixLengthsPsr4 = array ( @@ -21,6 +23,9 @@ class ComposerStaticInit734406fe75b0a330f41f48930525b165 'c' => array ( 'calderawp\\calderaforms\\pro\\' => 27, + 'calderawp\\calderaforms\\Tests\\Util\\Traits\\' => 41, + 'calderawp\\calderaforms\\Tests\\Util\\' => 34, + 'calderawp\\calderaforms\\Tests\\Unit\\' => 34, 'calderawp\\CalderaFormsQuery\\' => 28, 'calderawp\\CalderaContainers\\' => 28, ), @@ -56,6 +61,14 @@ class ComposerStaticInit734406fe75b0a330f41f48930525b165 'Doctrine\\Instantiator\\' => 22, 'DeepCopy\\' => 9, ), + 'C' => + array ( + 'Composer\\Installers\\' => 20, + ), + 'B' => + array ( + 'Brain\\Monkey\\' => 13, + ), ); public static $prefixDirsPsr4 = array ( @@ -69,6 +82,18 @@ class ComposerStaticInit734406fe75b0a330f41f48930525b165 array ( 0 => __DIR__ . '/../..' . '/includes/cf-pro-client/classes', ), + 'calderawp\\calderaforms\\Tests\\Util\\Traits\\' => + array ( + 0 => __DIR__ . '/../..' . '/tests/Util/Traits', + ), + 'calderawp\\calderaforms\\Tests\\Util\\' => + array ( + 0 => __DIR__ . '/../..' . '/tests/Util', + ), + 'calderawp\\calderaforms\\Tests\\Unit\\' => + array ( + 0 => __DIR__ . '/../..' . '/tests/Unit', + ), 'calderawp\\CalderaFormsQuery\\' => array ( 0 => __DIR__ . '/..' . '/calderawp/caldera-forms-query/src', @@ -121,9 +146,24 @@ class ComposerStaticInit734406fe75b0a330f41f48930525b165 array ( 0 => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy', ), + 'Composer\\Installers\\' => + array ( + 0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers', + ), + 'Brain\\Monkey\\' => + array ( + 0 => __DIR__ . '/..' . '/brain/monkey/src', + ), ); public static $prefixesPsr0 = array ( + 'j' => + array ( + 'johnpbloch\\Composer\\' => + array ( + 0 => __DIR__ . '/..' . '/johnpbloch/wordpress-core-installer/src', + ), + ), 'P' => array ( 'Prophecy\\' => @@ -135,12 +175,87 @@ class ComposerStaticInit734406fe75b0a330f41f48930525b165 0 => __DIR__ . '/..' . '/pimple/pimple/src', ), ), + 'M' => + array ( + 'Mockery' => + array ( + 0 => __DIR__ . '/..' . '/mockery/mockery/library', + ), + ), ); public static $classMap = array ( 'File_Iterator' => __DIR__ . '/..' . '/phpunit/php-file-iterator/src/Iterator.php', 'File_Iterator_Facade' => __DIR__ . '/..' . '/phpunit/php-file-iterator/src/Facade.php', 'File_Iterator_Factory' => __DIR__ . '/..' . '/phpunit/php-file-iterator/src/Factory.php', + 'Hamcrest\\Arrays\\IsArray' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArray.php', + 'Hamcrest\\Arrays\\IsArrayContaining' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContaining.php', + 'Hamcrest\\Arrays\\IsArrayContainingInAnyOrder' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php', + 'Hamcrest\\Arrays\\IsArrayContainingInOrder' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInOrder.php', + 'Hamcrest\\Arrays\\IsArrayContainingKey' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php', + 'Hamcrest\\Arrays\\IsArrayContainingKeyValuePair' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php', + 'Hamcrest\\Arrays\\IsArrayWithSize' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayWithSize.php', + 'Hamcrest\\Arrays\\MatchingOnce' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/MatchingOnce.php', + 'Hamcrest\\Arrays\\SeriesMatchingOnce' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/SeriesMatchingOnce.php', + 'Hamcrest\\AssertionError' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/AssertionError.php', + 'Hamcrest\\BaseDescription' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/BaseDescription.php', + 'Hamcrest\\BaseMatcher' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/BaseMatcher.php', + 'Hamcrest\\Collection\\IsEmptyTraversable' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php', + 'Hamcrest\\Collection\\IsTraversableWithSize' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsTraversableWithSize.php', + 'Hamcrest\\Core\\AllOf' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/AllOf.php', + 'Hamcrest\\Core\\AnyOf' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/AnyOf.php', + 'Hamcrest\\Core\\CombinableMatcher' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/CombinableMatcher.php', + 'Hamcrest\\Core\\DescribedAs' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/DescribedAs.php', + 'Hamcrest\\Core\\Every' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Every.php', + 'Hamcrest\\Core\\HasToString' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/HasToString.php', + 'Hamcrest\\Core\\Is' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Is.php', + 'Hamcrest\\Core\\IsAnything' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsAnything.php', + 'Hamcrest\\Core\\IsCollectionContaining' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsCollectionContaining.php', + 'Hamcrest\\Core\\IsEqual' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsEqual.php', + 'Hamcrest\\Core\\IsIdentical' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsIdentical.php', + 'Hamcrest\\Core\\IsInstanceOf' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsInstanceOf.php', + 'Hamcrest\\Core\\IsNot' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNot.php', + 'Hamcrest\\Core\\IsNull' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNull.php', + 'Hamcrest\\Core\\IsSame' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsSame.php', + 'Hamcrest\\Core\\IsTypeOf' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsTypeOf.php', + 'Hamcrest\\Core\\Set' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Set.php', + 'Hamcrest\\Core\\ShortcutCombination' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/ShortcutCombination.php', + 'Hamcrest\\Description' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Description.php', + 'Hamcrest\\DiagnosingMatcher' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/DiagnosingMatcher.php', + 'Hamcrest\\FeatureMatcher' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/FeatureMatcher.php', + 'Hamcrest\\Internal\\SelfDescribingValue' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Internal/SelfDescribingValue.php', + 'Hamcrest\\Matcher' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matcher.php', + 'Hamcrest\\MatcherAssert' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/MatcherAssert.php', + 'Hamcrest\\Matchers' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matchers.php', + 'Hamcrest\\NullDescription' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/NullDescription.php', + 'Hamcrest\\Number\\IsCloseTo' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Number/IsCloseTo.php', + 'Hamcrest\\Number\\OrderingComparison' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Number/OrderingComparison.php', + 'Hamcrest\\SelfDescribing' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/SelfDescribing.php', + 'Hamcrest\\StringDescription' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/StringDescription.php', + 'Hamcrest\\Text\\IsEmptyString' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEmptyString.php', + 'Hamcrest\\Text\\IsEqualIgnoringCase' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php', + 'Hamcrest\\Text\\IsEqualIgnoringWhiteSpace' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php', + 'Hamcrest\\Text\\MatchesPattern' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/MatchesPattern.php', + 'Hamcrest\\Text\\StringContains' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContains.php', + 'Hamcrest\\Text\\StringContainsIgnoringCase' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsIgnoringCase.php', + 'Hamcrest\\Text\\StringContainsInOrder' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsInOrder.php', + 'Hamcrest\\Text\\StringEndsWith' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringEndsWith.php', + 'Hamcrest\\Text\\StringStartsWith' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringStartsWith.php', + 'Hamcrest\\Text\\SubstringMatcher' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/SubstringMatcher.php', + 'Hamcrest\\TypeSafeDiagnosingMatcher' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/TypeSafeDiagnosingMatcher.php', + 'Hamcrest\\TypeSafeMatcher' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/TypeSafeMatcher.php', + 'Hamcrest\\Type\\IsArray' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsArray.php', + 'Hamcrest\\Type\\IsBoolean' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsBoolean.php', + 'Hamcrest\\Type\\IsCallable' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsCallable.php', + 'Hamcrest\\Type\\IsDouble' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsDouble.php', + 'Hamcrest\\Type\\IsInteger' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsInteger.php', + 'Hamcrest\\Type\\IsNumeric' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsNumeric.php', + 'Hamcrest\\Type\\IsObject' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsObject.php', + 'Hamcrest\\Type\\IsResource' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsResource.php', + 'Hamcrest\\Type\\IsScalar' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsScalar.php', + 'Hamcrest\\Type\\IsString' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsString.php', + 'Hamcrest\\Util' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Util.php', + 'Hamcrest\\Xml\\HasXPath' => __DIR__ . '/..' . '/hamcrest/hamcrest-php/hamcrest/Hamcrest/Xml/HasXPath.php', 'PHPUnit\\Framework\\TestCase' => __DIR__ . '/..' . '/phpunit/phpunit/src/ForwardCompatibility/TestCase.php', 'PHPUnit_Exception' => __DIR__ . '/..' . '/phpunit/phpunit/src/Exception.php', 'PHPUnit_Extensions_GroupTestSuite' => __DIR__ . '/..' . '/phpunit/phpunit/src/Extensions/GroupTestSuite.php', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 8b6e0a0dc..58c9df672 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1,4 +1,113 @@ [ + { + "name": "antecedent/patchwork", + "version": "2.1.8", + "version_normalized": "2.1.8.0", + "source": { + "type": "git", + "url": "https://github.com/antecedent/patchwork.git", + "reference": "3bb81ace3914c220aa273d1c0603d5e1b454c0d7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/antecedent/patchwork/zipball/3bb81ace3914c220aa273d1c0603d5e1b454c0d7", + "reference": "3bb81ace3914c220aa273d1c0603d5e1b454c0d7", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "time": "2018-02-19T18:52:50+00:00", + "type": "library", + "installation-source": "dist", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ignas Rudaitis", + "email": "ignas.rudaitis@gmail.com" + } + ], + "description": "Method redefinition (monkey-patching) functionality for PHP.", + "homepage": "http://patchwork2.org/", + "keywords": [ + "aop", + "aspect", + "interception", + "monkeypatching", + "redefinition", + "runkit", + "testing" + ] + }, + { + "name": "brain/monkey", + "version": "2.2.0", + "version_normalized": "2.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/Brain-WP/BrainMonkey.git", + "reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Brain-WP/BrainMonkey/zipball/ed9e0698bc1292f33698719da8ca1aa2e18acc51", + "reference": "ed9e0698bc1292f33698719da8ca1aa2e18acc51", + "shasum": "" + }, + "require": { + "antecedent/patchwork": "^2.0", + "mockery/mockery": ">=0.9 <2", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.9" + }, + "time": "2017-12-01T16:32:09+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-version/1": "1.x-dev", + "dev-master": "2.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Brain\\Monkey\\": "src/" + }, + "files": [ + "inc/api.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Giuseppe Mazzapica", + "email": "giuseppe.mazzapica@gmail.com", + "homepage": "https://gmazzap.me", + "role": "Developer" + } + ], + "description": "Mocking utility for PHP functions and WordPress plugin API", + "keywords": [ + "Monkey Patching", + "interception", + "mock", + "mock functions", + "mockery", + "patchwork", + "redefinition", + "runkit", + "test", + "testing" + ] + }, { "name": "calderawp/caldera-containers", "version": "0.2.0", @@ -101,6 +210,128 @@ ], "description": "Caldera Forms Query Library" }, + { + "name": "composer/installers", + "version": "v1.6.0", + "version_normalized": "1.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/composer/installers.git", + "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/composer/installers/zipball/cfcca6b1b60bc4974324efb5783c13dca6932b5b", + "reference": "cfcca6b1b60bc4974324efb5783c13dca6932b5b", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "replace": { + "roundcube/plugin-installer": "*", + "shama/baton": "*" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "^4.8.36" + }, + "time": "2018-08-27T06:10:37+00:00", + "type": "composer-plugin", + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Composer\\Installers\\": "src/Composer/Installers" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "description": "A multi-framework Composer library installer", + "homepage": "https://composer.github.io/installers/", + "keywords": [ + "Craft", + "Dolibarr", + "Eliasis", + "Hurad", + "ImageCMS", + "Kanboard", + "Lan Management System", + "MODX Evo", + "Mautic", + "Maya", + "OXID", + "Plentymarkets", + "Porto", + "RadPHP", + "SMF", + "Thelia", + "WolfCMS", + "agl", + "aimeos", + "annotatecms", + "attogram", + "bitrix", + "cakephp", + "chef", + "cockpit", + "codeigniter", + "concrete5", + "croogo", + "dokuwiki", + "drupal", + "eZ Platform", + "elgg", + "expressionengine", + "fuelphp", + "grav", + "installer", + "itop", + "joomla", + "kohana", + "laravel", + "lavalite", + "lithium", + "magento", + "majima", + "mako", + "mediawiki", + "modulework", + "modx", + "moodle", + "osclass", + "phpbb", + "piwik", + "ppi", + "puppet", + "pxcms", + "reindex", + "roundcube", + "shopware", + "silverstripe", + "sydes", + "symfony", + "typo3", + "wordpress", + "yawik", + "zend", + "zikula" + ] + }, { "name": "doctrine/instantiator", "version": "1.1.0", @@ -157,6 +388,56 @@ "instantiate" ] }, + { + "name": "hamcrest/hamcrest-php", + "version": "v2.0.0", + "version_normalized": "2.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/hamcrest/hamcrest-php.git", + "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/776503d3a8e85d4f9a1148614f95b7a608b046ad", + "reference": "776503d3a8e85d4f9a1148614f95b7a608b046ad", + "shasum": "" + }, + "require": { + "php": "^5.3|^7.0" + }, + "replace": { + "cordoval/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "kodova/hamcrest-php": "*" + }, + "require-dev": { + "phpunit/php-file-iterator": "1.3.3", + "phpunit/phpunit": "~4.0", + "satooshi/php-coveralls": "^1.0" + }, + "time": "2016-01-20T08:20:44+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + }, + "installation-source": "dist", + "autoload": { + "classmap": [ + "hamcrest" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD" + ], + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": [ + "test" + ] + }, { "name": "inpsyde/wonolog", "version": "1.0.2", @@ -226,6 +507,207 @@ "wordpress" ] }, + { + "name": "johnpbloch/wordpress", + "version": "4.9.8", + "version_normalized": "4.9.8.0", + "source": { + "type": "git", + "url": "https://github.com/johnpbloch/wordpress.git", + "reference": "de02cd79a41e06f36558040724414197cb7f6246" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/johnpbloch/wordpress/zipball/de02cd79a41e06f36558040724414197cb7f6246", + "reference": "de02cd79a41e06f36558040724414197cb7f6246", + "shasum": "" + }, + "require": { + "johnpbloch/wordpress-core": "4.9.8", + "johnpbloch/wordpress-core-installer": "^1.0", + "php": ">=5.3.2" + }, + "time": "2018-08-02T21:48:39+00:00", + "type": "package", + "installation-source": "dist", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "WordPress Community", + "homepage": "http://wordpress.org/about/" + } + ], + "description": "WordPress is web software you can use to create a beautiful website or blog.", + "homepage": "http://wordpress.org/", + "keywords": [ + "blog", + "cms", + "wordpress" + ] + }, + { + "name": "johnpbloch/wordpress-core", + "version": "4.9.8", + "version_normalized": "4.9.8.0", + "source": { + "type": "git", + "url": "https://github.com/johnpbloch/wordpress-core.git", + "reference": "50323f9b91d7689d615b4af02caf9d80584b1cfc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/johnpbloch/wordpress-core/zipball/50323f9b91d7689d615b4af02caf9d80584b1cfc", + "reference": "50323f9b91d7689d615b4af02caf9d80584b1cfc", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "provide": { + "wordpress/core-implementation": "4.9.8" + }, + "time": "2018-08-02T21:48:32+00:00", + "type": "wordpress-core", + "installation-source": "dist", + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0-or-later" + ], + "authors": [ + { + "name": "WordPress Community", + "homepage": "http://wordpress.org/about/" + } + ], + "description": "WordPress is web software you can use to create a beautiful website or blog.", + "homepage": "http://wordpress.org/", + "keywords": [ + "blog", + "cms", + "wordpress" + ] + }, + { + "name": "johnpbloch/wordpress-core-installer", + "version": "1.0.0.2", + "version_normalized": "1.0.0.2", + "source": { + "type": "git", + "url": "https://github.com/johnpbloch/wordpress-core-installer.git", + "reference": "7941acd71725710a789daabe0557429da63e7ac6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/johnpbloch/wordpress-core-installer/zipball/7941acd71725710a789daabe0557429da63e7ac6", + "reference": "7941acd71725710a789daabe0557429da63e7ac6", + "shasum": "" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "conflict": { + "composer/installers": "<1.0.6" + }, + "require-dev": { + "composer/composer": "^1.0", + "phpunit/phpunit": ">=4.8.35" + }, + "time": "2018-01-29T14:49:29+00:00", + "type": "composer-plugin", + "extra": { + "class": "johnpbloch\\Composer\\WordPressCorePlugin" + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "johnpbloch\\Composer\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "GPL-2.0+" + ], + "authors": [ + { + "name": "John P. Bloch", + "email": "me@johnpbloch.com" + } + ], + "description": "A custom installer to handle deploying WordPress with composer", + "keywords": [ + "wordpress" + ] + }, + { + "name": "mockery/mockery", + "version": "1.2.0", + "version_normalized": "1.2.0.0", + "source": { + "type": "git", + "url": "https://github.com/mockery/mockery.git", + "reference": "100633629bf76d57430b86b7098cd6beb996a35a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/mockery/mockery/zipball/100633629bf76d57430b86b7098cd6beb996a35a", + "reference": "100633629bf76d57430b86b7098cd6beb996a35a", + "shasum": "" + }, + "require": { + "hamcrest/hamcrest-php": "~2.0", + "lib-pcre": ">=7.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.10|~6.5|~7.0" + }, + "time": "2018-10-02T21:52:37+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "description": "Mockery is a simple yet flexible PHP mock object framework", + "homepage": "https://github.com/mockery/mockery", + "keywords": [ + "BDD", + "TDD", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "test", + "test double", + "testing" + ] + }, { "name": "monolog/monolog", "version": "1.23.0", @@ -1964,5 +2446,27 @@ "check", "validate" ] + }, + { + "name": "wpackagist-plugin/gutenberg", + "version": "4.0.0", + "version_normalized": "4.0.0.0", + "source": { + "type": "svn", + "url": "https://plugins.svn.wordpress.org/gutenberg/", + "reference": "tags/4.0.0" + }, + "dist": { + "type": "zip", + "url": "https://downloads.wordpress.org/plugin/gutenberg.4.0.0.zip", + "reference": null, + "shasum": null + }, + "require": { + "composer/installers": "~1.0" + }, + "type": "wordpress-plugin", + "installation-source": "dist", + "homepage": "https://wordpress.org/plugins/gutenberg/" } ] diff --git a/vendor/composer/installers/LICENSE b/vendor/composer/installers/LICENSE new file mode 100644 index 000000000..85f97fc79 --- /dev/null +++ b/vendor/composer/installers/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2012 Kyle Robinson Young + +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. \ No newline at end of file diff --git a/vendor/composer/installers/composer.json b/vendor/composer/installers/composer.json new file mode 100644 index 000000000..6de40853c --- /dev/null +++ b/vendor/composer/installers/composer.json @@ -0,0 +1,105 @@ +{ + "name": "composer/installers", + "type": "composer-plugin", + "license": "MIT", + "description": "A multi-framework Composer library installer", + "keywords": [ + "installer", + "Aimeos", + "AGL", + "AnnotateCms", + "Attogram", + "Bitrix", + "CakePHP", + "Chef", + "Cockpit", + "CodeIgniter", + "concrete5", + "Craft", + "Croogo", + "DokuWiki", + "Dolibarr", + "Drupal", + "Elgg", + "Eliasis", + "ExpressionEngine", + "eZ Platform", + "FuelPHP", + "Grav", + "Hurad", + "ImageCMS", + "iTop", + "Joomla", + "Kanboard", + "Kohana", + "Lan Management System", + "Laravel", + "Lavalite", + "Lithium", + "Magento", + "majima", + "Mako", + "Mautic", + "Maya", + "MODX", + "MODX Evo", + "MediaWiki", + "OXID", + "osclass", + "MODULEWork", + "Moodle", + "Piwik", + "pxcms", + "phpBB", + "Plentymarkets", + "PPI", + "Puppet", + "Porto", + "RadPHP", + "ReIndex", + "Roundcube", + "shopware", + "SilverStripe", + "SMF", + "SyDES", + "symfony", + "Thelia", + "TYPO3", + "WolfCMS", + "WordPress", + "YAWIK", + "Zend", + "Zikula" + ], + "homepage": "https://composer.github.io/installers/", + "authors": [ + { + "name": "Kyle Robinson Young", + "email": "kyle@dontkry.com", + "homepage": "https://github.com/shama" + } + ], + "autoload": { + "psr-4": { "Composer\\Installers\\": "src/Composer/Installers" } + }, + "extra": { + "class": "Composer\\Installers\\Plugin", + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "replace": { + "shama/baton": "*", + "roundcube/plugin-installer": "*" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "require-dev": { + "composer/composer": "1.0.*@dev", + "phpunit/phpunit": "^4.8.36" + }, + "scripts": { + "test": "phpunit" + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/AglInstaller.php b/vendor/composer/installers/src/Composer/Installers/AglInstaller.php new file mode 100644 index 000000000..01b8a4165 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/AglInstaller.php @@ -0,0 +1,21 @@ + 'More/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = preg_replace_callback('/(?:^|_|-)(.?)/', function ($matches) { + return strtoupper($matches[1]); + }, $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php b/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php new file mode 100644 index 000000000..79a0e958f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php @@ -0,0 +1,9 @@ + 'ext/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php b/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php new file mode 100644 index 000000000..89d7ad905 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/AnnotateCmsInstaller.php @@ -0,0 +1,11 @@ + 'addons/modules/{$name}/', + 'component' => 'addons/components/{$name}/', + 'service' => 'addons/services/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php b/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php new file mode 100644 index 000000000..22dad1b9a --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/AsgardInstaller.php @@ -0,0 +1,49 @@ + 'Modules/{$name}/', + 'theme' => 'Themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type asgard-module, cut off a trailing '-plugin' if present. + * + * For package type asgard-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'asgard-module') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'asgard-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php b/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php new file mode 100644 index 000000000..d62fd8fd1 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/AttogramInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php b/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php new file mode 100644 index 000000000..7082bf2cb --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/BaseInstaller.php @@ -0,0 +1,136 @@ +composer = $composer; + $this->package = $package; + $this->io = $io; + } + + /** + * Return the install path based on package type. + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + $type = $this->package->getType(); + + $prettyName = $this->package->getPrettyName(); + if (strpos($prettyName, '/') !== false) { + list($vendor, $name) = explode('/', $prettyName); + } else { + $vendor = ''; + $name = $prettyName; + } + + $availableVars = $this->inflectPackageVars(compact('name', 'vendor', 'type')); + + $extra = $package->getExtra(); + if (!empty($extra['installer-name'])) { + $availableVars['name'] = $extra['installer-name']; + } + + if ($this->composer->getPackage()) { + $extra = $this->composer->getPackage()->getExtra(); + if (!empty($extra['installer-paths'])) { + $customPath = $this->mapCustomInstallPaths($extra['installer-paths'], $prettyName, $type, $vendor); + if ($customPath !== false) { + return $this->templatePath($customPath, $availableVars); + } + } + } + + $packageType = substr($type, strlen($frameworkType) + 1); + $locations = $this->getLocations(); + if (!isset($locations[$packageType])) { + throw new \InvalidArgumentException(sprintf('Package type "%s" is not supported', $type)); + } + + return $this->templatePath($locations[$packageType], $availableVars); + } + + /** + * For an installer to override to modify the vars per installer. + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + return $vars; + } + + /** + * Gets the installer's locations + * + * @return array + */ + public function getLocations() + { + return $this->locations; + } + + /** + * Replace vars in a path + * + * @param string $path + * @param array $vars + * @return string + */ + protected function templatePath($path, array $vars = array()) + { + if (strpos($path, '{') !== false) { + extract($vars); + preg_match_all('@\{\$([A-Za-z0-9_]*)\}@i', $path, $matches); + if (!empty($matches[1])) { + foreach ($matches[1] as $var) { + $path = str_replace('{$' . $var . '}', $$var, $path); + } + } + } + + return $path; + } + + /** + * Search through a passed paths array for a custom install path. + * + * @param array $paths + * @param string $name + * @param string $type + * @param string $vendor = NULL + * @return string + */ + protected function mapCustomInstallPaths(array $paths, $name, $type, $vendor = NULL) + { + foreach ($paths as $path => $names) { + if (in_array($name, $names) || in_array('type:' . $type, $names) || in_array('vendor:' . $vendor, $names)) { + return $path; + } + } + + return false; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php b/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php new file mode 100644 index 000000000..e80cd1e10 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/BitrixInstaller.php @@ -0,0 +1,126 @@ +.`. + * - `bitrix-d7-component` — copy the component to directory `bitrix/components//`. + * - `bitrix-d7-template` — copy the template to directory `bitrix/templates/_`. + * + * You can set custom path to directory with Bitrix kernel in `composer.json`: + * + * ```json + * { + * "extra": { + * "bitrix-dir": "s1/bitrix" + * } + * } + * ``` + * + * @author Nik Samokhvalov + * @author Denis Kulichkin + */ +class BitrixInstaller extends BaseInstaller +{ + protected $locations = array( + 'module' => '{$bitrix_dir}/modules/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) + 'component' => '{$bitrix_dir}/components/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) + 'theme' => '{$bitrix_dir}/templates/{$name}/', // deprecated, remove on the major release (Backward compatibility will be broken) + 'd7-module' => '{$bitrix_dir}/modules/{$vendor}.{$name}/', + 'd7-component' => '{$bitrix_dir}/components/{$vendor}/{$name}/', + 'd7-template' => '{$bitrix_dir}/templates/{$vendor}_{$name}/', + ); + + /** + * @var array Storage for informations about duplicates at all the time of installation packages. + */ + private static $checkedDuplicates = array(); + + /** + * {@inheritdoc} + */ + public function inflectPackageVars($vars) + { + if ($this->composer->getPackage()) { + $extra = $this->composer->getPackage()->getExtra(); + + if (isset($extra['bitrix-dir'])) { + $vars['bitrix_dir'] = $extra['bitrix-dir']; + } + } + + if (!isset($vars['bitrix_dir'])) { + $vars['bitrix_dir'] = 'bitrix'; + } + + return parent::inflectPackageVars($vars); + } + + /** + * {@inheritdoc} + */ + protected function templatePath($path, array $vars = array()) + { + $templatePath = parent::templatePath($path, $vars); + $this->checkDuplicates($templatePath, $vars); + + return $templatePath; + } + + /** + * Duplicates search packages. + * + * @param string $path + * @param array $vars + */ + protected function checkDuplicates($path, array $vars = array()) + { + $packageType = substr($vars['type'], strlen('bitrix') + 1); + $localDir = explode('/', $vars['bitrix_dir']); + array_pop($localDir); + $localDir[] = 'local'; + $localDir = implode('/', $localDir); + + $oldPath = str_replace( + array('{$bitrix_dir}', '{$name}'), + array($localDir, $vars['name']), + $this->locations[$packageType] + ); + + if (in_array($oldPath, static::$checkedDuplicates)) { + return; + } + + if ($oldPath !== $path && file_exists($oldPath) && $this->io && $this->io->isInteractive()) { + + $this->io->writeError(' Duplication of packages:'); + $this->io->writeError(' Package ' . $oldPath . ' will be called instead package ' . $path . ''); + + while (true) { + switch ($this->io->ask(' Delete ' . $oldPath . ' [y,n,?]? ', '?')) { + case 'y': + $fs = new Filesystem(); + $fs->removeDirectory($oldPath); + break 2; + + case 'n': + break 2; + + case '?': + default: + $this->io->writeError(array( + ' y - delete package ' . $oldPath . ' and to continue with the installation', + ' n - don\'t delete and to continue with the installation', + )); + $this->io->writeError(' ? - print help'); + break; + } + } + } + + static::$checkedDuplicates[] = $oldPath; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php b/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php new file mode 100644 index 000000000..da3aad2a3 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/BonefishInstaller.php @@ -0,0 +1,9 @@ + 'Packages/{$vendor}/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php b/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php new file mode 100644 index 000000000..6352beb11 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php @@ -0,0 +1,82 @@ + 'Plugin/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + if ($this->matchesCakeVersion('>=', '3.0.0')) { + return $vars; + } + + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + + return $vars; + } + + /** + * Change the default plugin location when cakephp >= 3.0 + */ + public function getLocations() + { + if ($this->matchesCakeVersion('>=', '3.0.0')) { + $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; + } + return $this->locations; + } + + /** + * Check if CakePHP version matches against a version + * + * @param string $matcher + * @param string $version + * @return bool + */ + protected function matchesCakeVersion($matcher, $version) + { + if (class_exists('Composer\Semver\Constraint\MultiConstraint')) { + $multiClass = 'Composer\Semver\Constraint\MultiConstraint'; + $constraintClass = 'Composer\Semver\Constraint\Constraint'; + } else { + $multiClass = 'Composer\Package\LinkConstraint\MultiConstraint'; + $constraintClass = 'Composer\Package\LinkConstraint\VersionConstraint'; + } + + $repositoryManager = $this->composer->getRepositoryManager(); + if ($repositoryManager) { + $repos = $repositoryManager->getLocalRepository(); + if (!$repos) { + return false; + } + $cake3 = new $multiClass(array( + new $constraintClass($matcher, $version), + new $constraintClass('!=', '9999999-dev'), + )); + $pool = new Pool('dev'); + $pool->addRepository($repos); + $packages = $pool->whatProvides('cakephp/cakephp'); + foreach ($packages as $package) { + $installed = new $constraintClass('=', $package->getVersion()); + if ($cake3->matches($installed)) { + return true; + } + } + } + return false; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php b/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php new file mode 100644 index 000000000..ab2f9aad8 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ChefInstaller.php @@ -0,0 +1,11 @@ + 'Chef/{$vendor}/{$name}/', + 'role' => 'Chef/roles/{$name}/', + ); +} + diff --git a/vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php b/vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php new file mode 100644 index 000000000..6673aea94 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CiviCrmInstaller.php @@ -0,0 +1,9 @@ + 'ext/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php b/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php new file mode 100644 index 000000000..c887815c9 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php @@ -0,0 +1,10 @@ + 'CCF/orbit/{$name}/', + 'theme' => 'CCF/app/themes/{$name}/', + ); +} \ No newline at end of file diff --git a/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php b/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php new file mode 100644 index 000000000..c7816dfce --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CockpitInstaller.php @@ -0,0 +1,34 @@ + 'cockpit/modules/addons/{$name}/', + ); + + /** + * Format module name. + * + * Strip `module-` prefix from package name. + * + * @param array @vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] == 'cockpit-module') { + return $this->inflectModuleVars($vars); + } + + return $vars; + } + + public function inflectModuleVars($vars) + { + $vars['name'] = ucfirst(preg_replace('/cockpit-/i', '', $vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php b/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php new file mode 100644 index 000000000..3b4a4ece1 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CodeIgniterInstaller.php @@ -0,0 +1,11 @@ + 'application/libraries/{$name}/', + 'third-party' => 'application/third_party/{$name}/', + 'module' => 'application/modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php b/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php new file mode 100644 index 000000000..5c01bafd7 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/Concrete5Installer.php @@ -0,0 +1,13 @@ + 'concrete/', + 'block' => 'application/blocks/{$name}/', + 'package' => 'packages/{$name}/', + 'theme' => 'application/themes/{$name}/', + 'update' => 'updates/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php b/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php new file mode 100644 index 000000000..d37a77ae2 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CraftInstaller.php @@ -0,0 +1,35 @@ + 'craft/plugins/{$name}/', + ); + + /** + * Strip `craft-` prefix and/or `-plugin` suffix from package names + * + * @param array $vars + * + * @return array + */ + final public function inflectPackageVars($vars) + { + return $this->inflectPluginVars($vars); + } + + private function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-' . self::NAME_SUFFIX . '$/i', '', $vars['name']); + $vars['name'] = preg_replace('/^' . self::NAME_PREFIX . '-/i', '', $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php b/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php new file mode 100644 index 000000000..d94219d3a --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/CroogoInstaller.php @@ -0,0 +1,21 @@ + 'Plugin/{$name}/', + 'theme' => 'View/Themed/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(str_replace(array('-', '_'), ' ', $vars['name'])); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php b/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php new file mode 100644 index 000000000..f4837a6c1 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/DecibelInstaller.php @@ -0,0 +1,10 @@ + 'app/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php b/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php new file mode 100644 index 000000000..cfd638d5f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/DokuWikiInstaller.php @@ -0,0 +1,50 @@ + 'lib/plugins/{$name}/', + 'template' => 'lib/tpl/{$name}/', + ); + + /** + * Format package name. + * + * For package type dokuwiki-plugin, cut off a trailing '-plugin', + * or leading dokuwiki_ if present. + * + * For package type dokuwiki-template, cut off a trailing '-template' if present. + * + */ + public function inflectPackageVars($vars) + { + + if ($vars['type'] === 'dokuwiki-plugin') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'dokuwiki-template') { + return $this->inflectTemplateVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-plugin$/', '', $vars['name']); + $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); + + return $vars; + } + + protected function inflectTemplateVars($vars) + { + $vars['name'] = preg_replace('/-template$/', '', $vars['name']); + $vars['name'] = preg_replace('/^dokuwiki_?-?/', '', $vars['name']); + + return $vars; + } + +} diff --git a/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php b/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php new file mode 100644 index 000000000..21f7e8e80 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/DolibarrInstaller.php @@ -0,0 +1,16 @@ + + */ +class DolibarrInstaller extends BaseInstaller +{ + //TODO: Add support for scripts and themes + protected $locations = array( + 'module' => 'htdocs/custom/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php b/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php new file mode 100644 index 000000000..fef7c525d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php @@ -0,0 +1,16 @@ + 'core/', + 'module' => 'modules/{$name}/', + 'theme' => 'themes/{$name}/', + 'library' => 'libraries/{$name}/', + 'profile' => 'profiles/{$name}/', + 'drush' => 'drush/{$name}/', + 'custom-theme' => 'themes/custom/{$name}/', + 'custom-module' => 'modules/custom/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php b/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php new file mode 100644 index 000000000..c0bb609f4 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ElggInstaller.php @@ -0,0 +1,9 @@ + 'mod/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php b/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php new file mode 100644 index 000000000..6f3dc97b1 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/EliasisInstaller.php @@ -0,0 +1,12 @@ + 'components/{$name}/', + 'module' => 'modules/{$name}/', + 'plugin' => 'plugins/{$name}/', + 'template' => 'templates/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php b/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php new file mode 100644 index 000000000..d5321a8ca --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ExpressionEngineInstaller.php @@ -0,0 +1,29 @@ + 'system/expressionengine/third_party/{$name}/', + 'theme' => 'themes/third_party/{$name}/', + ); + + private $ee3Locations = array( + 'addon' => 'system/user/addons/{$name}/', + 'theme' => 'themes/user/{$name}/', + ); + + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + + $version = "{$frameworkType}Locations"; + $this->locations = $this->$version; + + return parent::getInstallPath($package, $frameworkType); + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php b/vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php new file mode 100644 index 000000000..f30ebcc77 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/EzPlatformInstaller.php @@ -0,0 +1,10 @@ + 'web/assets/ezplatform/', + 'assets' => 'web/assets/ezplatform/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php b/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php new file mode 100644 index 000000000..6eba2e34f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/FuelInstaller.php @@ -0,0 +1,11 @@ + 'fuel/app/modules/{$name}/', + 'package' => 'fuel/packages/{$name}/', + 'theme' => 'fuel/app/themes/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php b/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php new file mode 100644 index 000000000..29d980b30 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/FuelphpInstaller.php @@ -0,0 +1,9 @@ + 'components/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/GravInstaller.php b/vendor/composer/installers/src/Composer/Installers/GravInstaller.php new file mode 100644 index 000000000..dbe63e07e --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/GravInstaller.php @@ -0,0 +1,30 @@ + 'user/plugins/{$name}/', + 'theme' => 'user/themes/{$name}/', + ); + + /** + * Format package name + * + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $restrictedWords = implode('|', array_keys($this->locations)); + + $vars['name'] = strtolower($vars['name']); + $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui', + '$1', + $vars['name'] + ); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php b/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php new file mode 100644 index 000000000..8fe017f0f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/HuradInstaller.php @@ -0,0 +1,25 @@ + 'plugins/{$name}/', + 'theme' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php b/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php new file mode 100644 index 000000000..5e2142ea5 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ImageCMSInstaller.php @@ -0,0 +1,11 @@ + 'templates/{$name}/', + 'module' => 'application/modules/{$name}/', + 'library' => 'application/libraries/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/Installer.php b/vendor/composer/installers/src/Composer/Installers/Installer.php new file mode 100644 index 000000000..352cb7fae --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/Installer.php @@ -0,0 +1,274 @@ + 'AimeosInstaller', + 'asgard' => 'AsgardInstaller', + 'attogram' => 'AttogramInstaller', + 'agl' => 'AglInstaller', + 'annotatecms' => 'AnnotateCmsInstaller', + 'bitrix' => 'BitrixInstaller', + 'bonefish' => 'BonefishInstaller', + 'cakephp' => 'CakePHPInstaller', + 'chef' => 'ChefInstaller', + 'civicrm' => 'CiviCrmInstaller', + 'ccframework' => 'ClanCatsFrameworkInstaller', + 'cockpit' => 'CockpitInstaller', + 'codeigniter' => 'CodeIgniterInstaller', + 'concrete5' => 'Concrete5Installer', + 'craft' => 'CraftInstaller', + 'croogo' => 'CroogoInstaller', + 'dokuwiki' => 'DokuWikiInstaller', + 'dolibarr' => 'DolibarrInstaller', + 'decibel' => 'DecibelInstaller', + 'drupal' => 'DrupalInstaller', + 'elgg' => 'ElggInstaller', + 'eliasis' => 'EliasisInstaller', + 'ee3' => 'ExpressionEngineInstaller', + 'ee2' => 'ExpressionEngineInstaller', + 'ezplatform' => 'EzPlatformInstaller', + 'fuel' => 'FuelInstaller', + 'fuelphp' => 'FuelphpInstaller', + 'grav' => 'GravInstaller', + 'hurad' => 'HuradInstaller', + 'imagecms' => 'ImageCMSInstaller', + 'itop' => 'ItopInstaller', + 'joomla' => 'JoomlaInstaller', + 'kanboard' => 'KanboardInstaller', + 'kirby' => 'KirbyInstaller', + 'kodicms' => 'KodiCMSInstaller', + 'kohana' => 'KohanaInstaller', + 'lms' => 'LanManagementSystemInstaller', + 'laravel' => 'LaravelInstaller', + 'lavalite' => 'LavaLiteInstaller', + 'lithium' => 'LithiumInstaller', + 'magento' => 'MagentoInstaller', + 'majima' => 'MajimaInstaller', + 'mako' => 'MakoInstaller', + 'maya' => 'MayaInstaller', + 'mautic' => 'MauticInstaller', + 'mediawiki' => 'MediaWikiInstaller', + 'microweber' => 'MicroweberInstaller', + 'modulework' => 'MODULEWorkInstaller', + 'modx' => 'ModxInstaller', + 'modxevo' => 'MODXEvoInstaller', + 'moodle' => 'MoodleInstaller', + 'october' => 'OctoberInstaller', + 'ontowiki' => 'OntoWikiInstaller', + 'oxid' => 'OxidInstaller', + 'osclass' => 'OsclassInstaller', + 'pxcms' => 'PxcmsInstaller', + 'phpbb' => 'PhpBBInstaller', + 'pimcore' => 'PimcoreInstaller', + 'piwik' => 'PiwikInstaller', + 'plentymarkets'=> 'PlentymarketsInstaller', + 'ppi' => 'PPIInstaller', + 'puppet' => 'PuppetInstaller', + 'radphp' => 'RadPHPInstaller', + 'phifty' => 'PhiftyInstaller', + 'porto' => 'PortoInstaller', + 'redaxo' => 'RedaxoInstaller', + 'reindex' => 'ReIndexInstaller', + 'roundcube' => 'RoundcubeInstaller', + 'shopware' => 'ShopwareInstaller', + 'sitedirect' => 'SiteDirectInstaller', + 'silverstripe' => 'SilverStripeInstaller', + 'smf' => 'SMFInstaller', + 'sydes' => 'SyDESInstaller', + 'symfony1' => 'Symfony1Installer', + 'thelia' => 'TheliaInstaller', + 'tusk' => 'TuskInstaller', + 'typo3-cms' => 'TYPO3CmsInstaller', + 'typo3-flow' => 'TYPO3FlowInstaller', + 'userfrosting' => 'UserFrostingInstaller', + 'vanilla' => 'VanillaInstaller', + 'whmcs' => 'WHMCSInstaller', + 'wolfcms' => 'WolfCMSInstaller', + 'wordpress' => 'WordPressInstaller', + 'yawik' => 'YawikInstaller', + 'zend' => 'ZendInstaller', + 'zikula' => 'ZikulaInstaller', + 'prestashop' => 'PrestashopInstaller' + ); + + /** + * Installer constructor. + * + * Disables installers specified in main composer extra installer-disable + * list + * + * @param IOInterface $io + * @param Composer $composer + * @param string $type + * @param Filesystem|null $filesystem + * @param BinaryInstaller|null $binaryInstaller + */ + public function __construct( + IOInterface $io, + Composer $composer, + $type = 'library', + Filesystem $filesystem = null, + BinaryInstaller $binaryInstaller = null + ) { + parent::__construct($io, $composer, $type, $filesystem, + $binaryInstaller); + $this->removeDisabledInstallers(); + } + + /** + * {@inheritDoc} + */ + public function getInstallPath(PackageInterface $package) + { + $type = $package->getType(); + $frameworkType = $this->findFrameworkType($type); + + if ($frameworkType === false) { + throw new \InvalidArgumentException( + 'Sorry the package type of this package is not yet supported.' + ); + } + + $class = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; + $installer = new $class($package, $this->composer, $this->getIO()); + + return $installer->getInstallPath($package, $frameworkType); + } + + public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) + { + parent::uninstall($repo, $package); + $installPath = $this->getPackageBasePath($package); + $this->io->write(sprintf('Deleting %s - %s', $installPath, !file_exists($installPath) ? 'deleted' : 'not deleted')); + } + + /** + * {@inheritDoc} + */ + public function supports($packageType) + { + $frameworkType = $this->findFrameworkType($packageType); + + if ($frameworkType === false) { + return false; + } + + $locationPattern = $this->getLocationPattern($frameworkType); + + return preg_match('#' . $frameworkType . '-' . $locationPattern . '#', $packageType, $matches) === 1; + } + + /** + * Finds a supported framework type if it exists and returns it + * + * @param string $type + * @return string + */ + protected function findFrameworkType($type) + { + $frameworkType = false; + + krsort($this->supportedTypes); + + foreach ($this->supportedTypes as $key => $val) { + if ($key === substr($type, 0, strlen($key))) { + $frameworkType = substr($type, 0, strlen($key)); + break; + } + } + + return $frameworkType; + } + + /** + * Get the second part of the regular expression to check for support of a + * package type + * + * @param string $frameworkType + * @return string + */ + protected function getLocationPattern($frameworkType) + { + $pattern = false; + if (!empty($this->supportedTypes[$frameworkType])) { + $frameworkClass = 'Composer\\Installers\\' . $this->supportedTypes[$frameworkType]; + /** @var BaseInstaller $framework */ + $framework = new $frameworkClass(null, $this->composer, $this->getIO()); + $locations = array_keys($framework->getLocations()); + $pattern = $locations ? '(' . implode('|', $locations) . ')' : false; + } + + return $pattern ? : '(\w+)'; + } + + /** + * Get I/O object + * + * @return IOInterface + */ + private function getIO() + { + return $this->io; + } + + /** + * Look for installers set to be disabled in composer's extra config and + * remove them from the list of supported installers. + * + * Globals: + * - true, "all", and "*" - disable all installers. + * - false - enable all installers (useful with + * wikimedia/composer-merge-plugin or similar) + * + * @return void + */ + protected function removeDisabledInstallers() + { + $extra = $this->composer->getPackage()->getExtra(); + + if (!isset($extra['installer-disable']) || $extra['installer-disable'] === false) { + // No installers are disabled + return; + } + + // Get installers to disable + $disable = $extra['installer-disable']; + + // Ensure $disabled is an array + if (!is_array($disable)) { + $disable = array($disable); + } + + // Check which installers should be disabled + $all = array(true, "all", "*"); + $intersect = array_intersect($all, $disable); + if (!empty($intersect)) { + // Disable all installers + $this->supportedTypes = array(); + } else { + // Disable specified installers + foreach ($disable as $key => $installer) { + if (is_string($installer) && key_exists($installer, $this->supportedTypes)) { + unset($this->supportedTypes[$installer]); + } + } + } + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php b/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php new file mode 100644 index 000000000..c6c1b3374 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ItopInstaller.php @@ -0,0 +1,9 @@ + 'extensions/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php b/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php new file mode 100644 index 000000000..9ee775965 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/JoomlaInstaller.php @@ -0,0 +1,15 @@ + 'components/{$name}/', + 'module' => 'modules/{$name}/', + 'template' => 'templates/{$name}/', + 'plugin' => 'plugins/{$name}/', + 'library' => 'libraries/{$name}/', + ); + + // TODO: Add inflector for mod_ and com_ names +} diff --git a/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php b/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php new file mode 100644 index 000000000..9cb7b8cdb --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/KanboardInstaller.php @@ -0,0 +1,18 @@ + 'plugins/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php b/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php new file mode 100644 index 000000000..36b2f84a7 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/KirbyInstaller.php @@ -0,0 +1,11 @@ + 'site/plugins/{$name}/', + 'field' => 'site/fields/{$name}/', + 'tag' => 'site/tags/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php b/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php new file mode 100644 index 000000000..7143e232b --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/KodiCMSInstaller.php @@ -0,0 +1,10 @@ + 'cms/plugins/{$name}/', + 'media' => 'cms/media/vendor/{$name}/' + ); +} \ No newline at end of file diff --git a/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php b/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php new file mode 100644 index 000000000..dcd6d2632 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/KohanaInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php b/vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php new file mode 100644 index 000000000..903143a55 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/LanManagementSystemInstaller.php @@ -0,0 +1,27 @@ + 'plugins/{$name}/', + 'template' => 'templates/{$name}/', + 'document-template' => 'documents/templates/{$name}/', + 'userpanel-module' => 'userpanel/modules/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + +} diff --git a/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php b/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php new file mode 100644 index 000000000..be4d53a7b --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/LaravelInstaller.php @@ -0,0 +1,9 @@ + 'libraries/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php b/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php new file mode 100644 index 000000000..412c0b5c0 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/LavaLiteInstaller.php @@ -0,0 +1,10 @@ + 'packages/{$vendor}/{$name}/', + 'theme' => 'public/themes/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php b/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php new file mode 100644 index 000000000..47bbd4cab --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/LithiumInstaller.php @@ -0,0 +1,10 @@ + 'libraries/{$name}/', + 'source' => 'libraries/_source/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php b/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php new file mode 100644 index 000000000..9c2e9fb40 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MODULEWorkInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php b/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php new file mode 100644 index 000000000..5a664608d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MODXEvoInstaller.php @@ -0,0 +1,16 @@ + 'assets/snippets/{$name}/', + 'plugin' => 'assets/plugins/{$name}/', + 'module' => 'assets/modules/{$name}/', + 'template' => 'assets/templates/{$name}/', + 'lib' => 'assets/lib/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php b/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php new file mode 100644 index 000000000..cf18e9478 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MagentoInstaller.php @@ -0,0 +1,11 @@ + 'app/design/frontend/{$name}/', + 'skin' => 'skin/frontend/default/{$name}/', + 'library' => 'lib/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php b/vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php new file mode 100644 index 000000000..e463756fa --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MajimaInstaller.php @@ -0,0 +1,37 @@ + 'plugins/{$name}/', + ); + + /** + * Transforms the names + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + return $this->correctPluginName($vars); + } + + /** + * Change hyphenated names to camelcase + * @param array $vars + * @return array + */ + private function correctPluginName($vars) + { + $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + $vars['name'] = ucfirst($camelCasedName); + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php b/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php new file mode 100644 index 000000000..ca3cfacb4 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MakoInstaller.php @@ -0,0 +1,9 @@ + 'app/packages/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php b/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php new file mode 100644 index 000000000..3e1ce2b2d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MauticInstaller.php @@ -0,0 +1,25 @@ + 'plugins/{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Format package name of mautic-plugins to CamelCase + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] == 'mautic-plugin') { + $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, ucfirst($vars['name'])); + } + + return $vars; + } + +} diff --git a/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php b/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php new file mode 100644 index 000000000..30a91676d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MayaInstaller.php @@ -0,0 +1,33 @@ + 'modules/{$name}/', + ); + + /** + * Format package name. + * + * For package type maya-module, cut off a trailing '-module' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'maya-module') { + return $this->inflectModuleVars($vars); + } + + return $vars; + } + + protected function inflectModuleVars($vars) + { + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php b/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php new file mode 100644 index 000000000..f5a8957ef --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MediaWikiInstaller.php @@ -0,0 +1,51 @@ + 'core/', + 'extension' => 'extensions/{$name}/', + 'skin' => 'skins/{$name}/', + ); + + /** + * Format package name. + * + * For package type mediawiki-extension, cut off a trailing '-extension' if present and transform + * to CamelCase keeping existing uppercase chars. + * + * For package type mediawiki-skin, cut off a trailing '-skin' if present. + * + */ + public function inflectPackageVars($vars) + { + + if ($vars['type'] === 'mediawiki-extension') { + return $this->inflectExtensionVars($vars); + } + + if ($vars['type'] === 'mediawiki-skin') { + return $this->inflectSkinVars($vars); + } + + return $vars; + } + + protected function inflectExtensionVars($vars) + { + $vars['name'] = preg_replace('/-extension$/', '', $vars['name']); + $vars['name'] = str_replace('-', ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectSkinVars($vars) + { + $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); + + return $vars; + } + +} diff --git a/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php b/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php new file mode 100644 index 000000000..4bbbec8c0 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MicroweberInstaller.php @@ -0,0 +1,111 @@ + 'userfiles/modules/{$name}/', + 'module-skin' => 'userfiles/modules/{$name}/templates/', + 'template' => 'userfiles/templates/{$name}/', + 'element' => 'userfiles/elements/{$name}/', + 'vendor' => 'vendor/{$name}/', + 'components' => 'components/{$name}/' + ); + + /** + * Format package name. + * + * For package type microweber-module, cut off a trailing '-module' if present + * + * For package type microweber-template, cut off a trailing '-template' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'microweber-template') { + return $this->inflectTemplateVars($vars); + } + if ($vars['type'] === 'microweber-templates') { + return $this->inflectTemplatesVars($vars); + } + if ($vars['type'] === 'microweber-core') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-adapter') { + return $this->inflectCoreVars($vars); + } + if ($vars['type'] === 'microweber-module') { + return $this->inflectModuleVars($vars); + } + if ($vars['type'] === 'microweber-modules') { + return $this->inflectModulesVars($vars); + } + if ($vars['type'] === 'microweber-skin') { + return $this->inflectSkinVars($vars); + } + if ($vars['type'] === 'microweber-element' or $vars['type'] === 'microweber-elements') { + return $this->inflectElementVars($vars); + } + + return $vars; + } + + protected function inflectTemplateVars($vars) + { + $vars['name'] = preg_replace('/-template$/', '', $vars['name']); + $vars['name'] = preg_replace('/template-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectTemplatesVars($vars) + { + $vars['name'] = preg_replace('/-templates$/', '', $vars['name']); + $vars['name'] = preg_replace('/templates-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectCoreVars($vars) + { + $vars['name'] = preg_replace('/-providers$/', '', $vars['name']); + $vars['name'] = preg_replace('/-provider$/', '', $vars['name']); + $vars['name'] = preg_replace('/-adapter$/', '', $vars['name']); + + return $vars; + } + + protected function inflectModuleVars($vars) + { + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); + $vars['name'] = preg_replace('/module-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectModulesVars($vars) + { + $vars['name'] = preg_replace('/-modules$/', '', $vars['name']); + $vars['name'] = preg_replace('/modules-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectSkinVars($vars) + { + $vars['name'] = preg_replace('/-skin$/', '', $vars['name']); + $vars['name'] = preg_replace('/skin-$/', '', $vars['name']); + + return $vars; + } + + protected function inflectElementVars($vars) + { + $vars['name'] = preg_replace('/-elements$/', '', $vars['name']); + $vars['name'] = preg_replace('/elements-$/', '', $vars['name']); + $vars['name'] = preg_replace('/-element$/', '', $vars['name']); + $vars['name'] = preg_replace('/element-$/', '', $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/ModxInstaller.php b/vendor/composer/installers/src/Composer/Installers/ModxInstaller.php new file mode 100644 index 000000000..0ee140abf --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ModxInstaller.php @@ -0,0 +1,12 @@ + 'core/packages/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php b/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php new file mode 100644 index 000000000..a89c82f73 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/MoodleInstaller.php @@ -0,0 +1,57 @@ + 'mod/{$name}/', + 'admin_report' => 'admin/report/{$name}/', + 'atto' => 'lib/editor/atto/plugins/{$name}/', + 'tool' => 'admin/tool/{$name}/', + 'assignment' => 'mod/assignment/type/{$name}/', + 'assignsubmission' => 'mod/assign/submission/{$name}/', + 'assignfeedback' => 'mod/assign/feedback/{$name}/', + 'auth' => 'auth/{$name}/', + 'availability' => 'availability/condition/{$name}/', + 'block' => 'blocks/{$name}/', + 'booktool' => 'mod/book/tool/{$name}/', + 'cachestore' => 'cache/stores/{$name}/', + 'cachelock' => 'cache/locks/{$name}/', + 'calendartype' => 'calendar/type/{$name}/', + 'format' => 'course/format/{$name}/', + 'coursereport' => 'course/report/{$name}/', + 'datafield' => 'mod/data/field/{$name}/', + 'datapreset' => 'mod/data/preset/{$name}/', + 'editor' => 'lib/editor/{$name}/', + 'enrol' => 'enrol/{$name}/', + 'filter' => 'filter/{$name}/', + 'gradeexport' => 'grade/export/{$name}/', + 'gradeimport' => 'grade/import/{$name}/', + 'gradereport' => 'grade/report/{$name}/', + 'gradingform' => 'grade/grading/form/{$name}/', + 'local' => 'local/{$name}/', + 'logstore' => 'admin/tool/log/store/{$name}/', + 'ltisource' => 'mod/lti/source/{$name}/', + 'ltiservice' => 'mod/lti/service/{$name}/', + 'message' => 'message/output/{$name}/', + 'mnetservice' => 'mnet/service/{$name}/', + 'plagiarism' => 'plagiarism/{$name}/', + 'portfolio' => 'portfolio/{$name}/', + 'qbehaviour' => 'question/behaviour/{$name}/', + 'qformat' => 'question/format/{$name}/', + 'qtype' => 'question/type/{$name}/', + 'quizaccess' => 'mod/quiz/accessrule/{$name}/', + 'quiz' => 'mod/quiz/report/{$name}/', + 'report' => 'report/{$name}/', + 'repository' => 'repository/{$name}/', + 'scormreport' => 'mod/scorm/report/{$name}/', + 'search' => 'search/engine/{$name}/', + 'theme' => 'theme/{$name}/', + 'tinymce' => 'lib/editor/tinymce/plugins/{$name}/', + 'profilefield' => 'user/profile/field/{$name}/', + 'webservice' => 'webservice/{$name}/', + 'workshopallocation' => 'mod/workshop/allocation/{$name}/', + 'workshopeval' => 'mod/workshop/eval/{$name}/', + 'workshopform' => 'mod/workshop/form/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php b/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php new file mode 100644 index 000000000..08d5dc4e7 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/OctoberInstaller.php @@ -0,0 +1,47 @@ + 'modules/{$name}/', + 'plugin' => 'plugins/{$vendor}/{$name}/', + 'theme' => 'themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type october-plugin, cut off a trailing '-plugin' if present. + * + * For package type october-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'october-plugin') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'october-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/^oc-|-plugin$/', '', $vars['name']); + $vars['vendor'] = preg_replace('/[^a-z0-9_]/i', '', $vars['vendor']); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/^oc-|-theme$/', '', $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php b/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php new file mode 100644 index 000000000..5dd3438d9 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/OntoWikiInstaller.php @@ -0,0 +1,24 @@ + 'extensions/{$name}/', + 'theme' => 'extensions/themes/{$name}/', + 'translation' => 'extensions/translations/{$name}/', + ); + + /** + * Format package name to lower case and remove ".ontowiki" suffix + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower($vars['name']); + $vars['name'] = preg_replace('/.ontowiki$/', '', $vars['name']); + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); + $vars['name'] = preg_replace('/-translation$/', '', $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php b/vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php new file mode 100644 index 000000000..3ca7954c9 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/OsclassInstaller.php @@ -0,0 +1,14 @@ + 'oc-content/plugins/{$name}/', + 'theme' => 'oc-content/themes/{$name}/', + 'language' => 'oc-content/languages/{$name}/', + ); + +} diff --git a/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php b/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php new file mode 100644 index 000000000..49940ff6d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/OxidInstaller.php @@ -0,0 +1,59 @@ +.+)\/.+/'; + + protected $locations = array( + 'module' => 'modules/{$name}/', + 'theme' => 'application/views/{$name}/', + 'out' => 'out/{$name}/', + ); + + /** + * getInstallPath + * + * @param PackageInterface $package + * @param string $frameworkType + * @return void + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + $installPath = parent::getInstallPath($package, $frameworkType); + $type = $this->package->getType(); + if ($type === 'oxid-module') { + $this->prepareVendorDirectory($installPath); + } + return $installPath; + } + + /** + * prepareVendorDirectory + * + * Makes sure there is a vendormetadata.php file inside + * the vendor folder if there is a vendor folder. + * + * @param string $installPath + * @return void + */ + protected function prepareVendorDirectory($installPath) + { + $matches = ''; + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); + if (!$hasVendorDirectory) { + return; + } + + $vendorDirectory = $matches['vendor']; + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; + if (!file_exists($vendorPath)) { + mkdir($vendorPath, 0755, true); + } + + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; + touch($vendorMetaDataPath); + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php b/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php new file mode 100644 index 000000000..170136f98 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PPIInstaller.php @@ -0,0 +1,9 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php b/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php new file mode 100644 index 000000000..4e59a8a74 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PhiftyInstaller.php @@ -0,0 +1,11 @@ + 'bundles/{$name}/', + 'library' => 'libraries/{$name}/', + 'framework' => 'frameworks/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php b/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php new file mode 100644 index 000000000..deb2b77a6 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PhpBBInstaller.php @@ -0,0 +1,11 @@ + 'ext/{$vendor}/{$name}/', + 'language' => 'language/{$name}/', + 'style' => 'styles/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php b/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php new file mode 100644 index 000000000..4781fa6d1 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PimcoreInstaller.php @@ -0,0 +1,21 @@ + 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php b/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php new file mode 100644 index 000000000..c17f4572b --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PiwikInstaller.php @@ -0,0 +1,32 @@ + 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php b/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php new file mode 100644 index 000000000..903e55f62 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PlentymarketsInstaller.php @@ -0,0 +1,29 @@ + '{$name}/' + ); + + /** + * Remove hyphen, "plugin" and format to camelcase + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = explode("-", $vars['name']); + foreach ($vars['name'] as $key => $name) { + $vars['name'][$key] = ucfirst($vars['name'][$key]); + if (strcasecmp($name, "Plugin") == 0) { + unset($vars['name'][$key]); + } + } + $vars['name'] = implode("",$vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/Plugin.php b/vendor/composer/installers/src/Composer/Installers/Plugin.php new file mode 100644 index 000000000..5eb04af17 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/Plugin.php @@ -0,0 +1,17 @@ +getInstallationManager()->addInstaller($installer); + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php b/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php new file mode 100644 index 000000000..dbf85e635 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PortoInstaller.php @@ -0,0 +1,9 @@ + 'app/Containers/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php b/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php new file mode 100644 index 000000000..4c8421e36 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php @@ -0,0 +1,10 @@ + 'modules/{$name}/', + 'theme' => 'themes/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php b/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php new file mode 100644 index 000000000..77cc3dd87 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PuppetInstaller.php @@ -0,0 +1,11 @@ + 'modules/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php b/vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php new file mode 100644 index 000000000..65510580e --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/PxcmsInstaller.php @@ -0,0 +1,63 @@ + 'app/Modules/{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Format package name. + * + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'pxcms-module') { + return $this->inflectModuleVars($vars); + } + + if ($vars['type'] === 'pxcms-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + /** + * For package type pxcms-module, cut off a trailing '-plugin' if present. + * + * return string + */ + protected function inflectModuleVars($vars) + { + $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy) + $vars['name'] = str_replace('module-', '', $vars['name']); // strip out module- + $vars['name'] = preg_replace('/-module$/', '', $vars['name']); // strip out -module + $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s + $vars['name'] = ucwords($vars['name']); // make module name camelcased + + return $vars; + } + + + /** + * For package type pxcms-module, cut off a trailing '-plugin' if present. + * + * return string + */ + protected function inflectThemeVars($vars) + { + $vars['name'] = str_replace('pxcms-', '', $vars['name']); // strip out pxcms- just incase (legacy) + $vars['name'] = str_replace('theme-', '', $vars['name']); // strip out theme- + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); // strip out -theme + $vars['name'] = str_replace('-', '_', $vars['name']); // make -'s be _'s + $vars['name'] = ucwords($vars['name']); // make module name camelcased + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php b/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php new file mode 100644 index 000000000..0f78b5ca6 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/RadPHPInstaller.php @@ -0,0 +1,24 @@ + 'src/{$name}/' + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $nameParts = explode('/', $vars['name']); + foreach ($nameParts as &$value) { + $value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value)); + $value = str_replace(array('-', '_'), ' ', $value); + $value = str_replace(' ', '', ucwords($value)); + } + $vars['name'] = implode('/', $nameParts); + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php b/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php new file mode 100644 index 000000000..252c7339f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ReIndexInstaller.php @@ -0,0 +1,10 @@ + 'themes/{$name}/', + 'plugin' => 'plugins/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php b/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php new file mode 100644 index 000000000..09544576b --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/RedaxoInstaller.php @@ -0,0 +1,10 @@ + 'redaxo/include/addons/{$name}/', + 'bestyle-plugin' => 'redaxo/include/addons/be_style/plugins/{$name}/' + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php b/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php new file mode 100644 index 000000000..d8d795be0 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/RoundcubeInstaller.php @@ -0,0 +1,22 @@ + 'plugins/{$name}/', + ); + + /** + * Lowercase name and changes the name to a underscores + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(str_replace('-', '_', $vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php b/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php new file mode 100644 index 000000000..1acd3b14c --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/SMFInstaller.php @@ -0,0 +1,10 @@ + 'Sources/{$name}/', + 'theme' => 'Themes/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php b/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php new file mode 100644 index 000000000..7d20d27a2 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ShopwareInstaller.php @@ -0,0 +1,60 @@ + 'engine/Shopware/Plugins/Local/Backend/{$name}/', + 'core-plugin' => 'engine/Shopware/Plugins/Local/Core/{$name}/', + 'frontend-plugin' => 'engine/Shopware/Plugins/Local/Frontend/{$name}/', + 'theme' => 'templates/{$name}/', + 'plugin' => 'custom/plugins/{$name}/', + 'frontend-theme' => 'themes/Frontend/{$name}/', + ); + + /** + * Transforms the names + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'shopware-theme') { + return $this->correctThemeName($vars); + } + + return $this->correctPluginName($vars); + } + + /** + * Changes the name to a camelcased combination of vendor and name + * @param array $vars + * @return array + */ + private function correctPluginName($vars) + { + $camelCasedName = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + + $vars['name'] = ucfirst($vars['vendor']) . ucfirst($camelCasedName); + + return $vars; + } + + /** + * Changes the name to a underscore separated name + * @param array $vars + * @return array + */ + private function correctThemeName($vars) + { + $vars['name'] = str_replace('-', '_', $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php b/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php new file mode 100644 index 000000000..81910e9f1 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/SilverStripeInstaller.php @@ -0,0 +1,35 @@ + '{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Return the install path based on package type. + * + * Relies on built-in BaseInstaller behaviour with one exception: silverstripe/framework + * must be installed to 'sapphire' and not 'framework' if the version is <3.0.0 + * + * @param PackageInterface $package + * @param string $frameworkType + * @return string + */ + public function getInstallPath(PackageInterface $package, $frameworkType = '') + { + if ( + $package->getName() == 'silverstripe/framework' + && preg_match('/^\d+\.\d+\.\d+/', $package->getVersion()) + && version_compare($package->getVersion(), '2.999.999') < 0 + ) { + return $this->templatePath($this->locations['module'], array('name' => 'sapphire')); + } + + return parent::getInstallPath($package, $frameworkType); + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php b/vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php new file mode 100644 index 000000000..762d94c68 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/SiteDirectInstaller.php @@ -0,0 +1,25 @@ + 'modules/{$vendor}/{$name}/', + 'plugin' => 'plugins/{$vendor}/{$name}/' + ); + + public function inflectPackageVars($vars) + { + return $this->parseVars($vars); + } + + protected function parseVars($vars) + { + $vars['vendor'] = strtolower($vars['vendor']) == 'sitedirect' ? 'SiteDirect' : $vars['vendor']; + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php b/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php new file mode 100644 index 000000000..83ef9d091 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/SyDESInstaller.php @@ -0,0 +1,49 @@ + 'app/modules/{$name}/', + 'theme' => 'themes/{$name}/', + ); + + /** + * Format module name. + * + * Strip `sydes-` prefix and a trailing '-theme' or '-module' from package name if present. + * + * @param array @vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] == 'sydes-module') { + return $this->inflectModuleVars($vars); + } + + if ($vars['type'] === 'sydes-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + public function inflectModuleVars($vars) + { + $vars['name'] = preg_replace('/(^sydes-|-module$)/i', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/(^sydes-|-theme$)/', '', $vars['name']); + $vars['name'] = strtolower($vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php b/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php new file mode 100644 index 000000000..1675c4f21 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/Symfony1Installer.php @@ -0,0 +1,26 @@ + + */ +class Symfony1Installer extends BaseInstaller +{ + protected $locations = array( + 'plugin' => 'plugins/{$name}/', + ); + + /** + * Format package name to CamelCase + */ + public function inflectPackageVars($vars) + { + $vars['name'] = preg_replace_callback('/(-[a-z])/', function ($matches) { + return strtoupper($matches[0][1]); + }, $vars['name']); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php b/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php new file mode 100644 index 000000000..b1663e843 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/TYPO3CmsInstaller.php @@ -0,0 +1,16 @@ + + */ +class TYPO3CmsInstaller extends BaseInstaller +{ + protected $locations = array( + 'extension' => 'typo3conf/ext/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php b/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php new file mode 100644 index 000000000..42572f44f --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/TYPO3FlowInstaller.php @@ -0,0 +1,38 @@ + 'Packages/Application/{$name}/', + 'framework' => 'Packages/Framework/{$name}/', + 'plugin' => 'Packages/Plugins/{$name}/', + 'site' => 'Packages/Sites/{$name}/', + 'boilerplate' => 'Packages/Boilerplates/{$name}/', + 'build' => 'Build/{$name}/', + ); + + /** + * Modify the package name to be a TYPO3 Flow style key. + * + * @param array $vars + * @return array + */ + public function inflectPackageVars($vars) + { + $autoload = $this->package->getAutoload(); + if (isset($autoload['psr-0']) && is_array($autoload['psr-0'])) { + $namespace = key($autoload['psr-0']); + $vars['name'] = str_replace('\\', '.', $namespace); + } + if (isset($autoload['psr-4']) && is_array($autoload['psr-4'])) { + $namespace = key($autoload['psr-4']); + $vars['name'] = rtrim(str_replace('\\', '.', $namespace), '.'); + } + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php b/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php new file mode 100644 index 000000000..158af5261 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/TheliaInstaller.php @@ -0,0 +1,12 @@ + 'local/modules/{$name}/', + 'frontoffice-template' => 'templates/frontOffice/{$name}/', + 'backoffice-template' => 'templates/backOffice/{$name}/', + 'email-template' => 'templates/email/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php b/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php new file mode 100644 index 000000000..7c0113b85 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/TuskInstaller.php @@ -0,0 +1,14 @@ + + */ + class TuskInstaller extends BaseInstaller + { + protected $locations = array( + 'task' => '.tusk/tasks/{$name}/', + 'command' => '.tusk/commands/{$name}/', + 'asset' => 'assets/tusk/{$name}/', + ); + } diff --git a/vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php b/vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php new file mode 100644 index 000000000..fcb414ab7 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/UserFrostingInstaller.php @@ -0,0 +1,9 @@ + 'app/sprinkles/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php b/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php new file mode 100644 index 000000000..24ca64512 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/VanillaInstaller.php @@ -0,0 +1,10 @@ + 'plugins/{$name}/', + 'theme' => 'themes/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php b/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php new file mode 100644 index 000000000..7d90c5e6e --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/VgmcpInstaller.php @@ -0,0 +1,49 @@ + 'src/{$vendor}/{$name}/', + 'theme' => 'themes/{$name}/' + ); + + /** + * Format package name. + * + * For package type vgmcp-bundle, cut off a trailing '-bundle' if present. + * + * For package type vgmcp-theme, cut off a trailing '-theme' if present. + * + */ + public function inflectPackageVars($vars) + { + if ($vars['type'] === 'vgmcp-bundle') { + return $this->inflectPluginVars($vars); + } + + if ($vars['type'] === 'vgmcp-theme') { + return $this->inflectThemeVars($vars); + } + + return $vars; + } + + protected function inflectPluginVars($vars) + { + $vars['name'] = preg_replace('/-bundle$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } + + protected function inflectThemeVars($vars) + { + $vars['name'] = preg_replace('/-theme$/', '', $vars['name']); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} diff --git a/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php b/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php new file mode 100644 index 000000000..2cbb4a463 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/WHMCSInstaller.php @@ -0,0 +1,10 @@ + 'modules/gateways/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php b/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php new file mode 100644 index 000000000..cb387881d --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/WolfCMSInstaller.php @@ -0,0 +1,9 @@ + 'wolf/plugins/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php b/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php new file mode 100644 index 000000000..91c46ad99 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/WordPressInstaller.php @@ -0,0 +1,12 @@ + 'wp-content/plugins/{$name}/', + 'theme' => 'wp-content/themes/{$name}/', + 'muplugin' => 'wp-content/mu-plugins/{$name}/', + 'dropin' => 'wp-content/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php b/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php new file mode 100644 index 000000000..27f429ff2 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/YawikInstaller.php @@ -0,0 +1,32 @@ + 'module/{$name}/', + ); + + /** + * Format package name to CamelCase + * @param array $vars + * + * @return array + */ + public function inflectPackageVars($vars) + { + $vars['name'] = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $vars['name'])); + $vars['name'] = str_replace(array('-', '_'), ' ', $vars['name']); + $vars['name'] = str_replace(' ', '', ucwords($vars['name'])); + + return $vars; + } +} \ No newline at end of file diff --git a/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php b/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php new file mode 100644 index 000000000..bde9bc8c8 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ZendInstaller.php @@ -0,0 +1,11 @@ + 'library/{$name}/', + 'extra' => 'extras/library/{$name}/', + 'module' => 'module/{$name}/', + ); +} diff --git a/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php b/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php new file mode 100644 index 000000000..56cdf5da7 --- /dev/null +++ b/vendor/composer/installers/src/Composer/Installers/ZikulaInstaller.php @@ -0,0 +1,10 @@ + 'modules/{$vendor}-{$name}/', + 'theme' => 'themes/{$vendor}-{$name}/' + ); +} diff --git a/vendor/composer/installers/src/bootstrap.php b/vendor/composer/installers/src/bootstrap.php new file mode 100644 index 000000000..0de276ee2 --- /dev/null +++ b/vendor/composer/installers/src/bootstrap.php @@ -0,0 +1,13 @@ +ignoringCase()); + +* Fixed Hamcrest_Core_IsInstanceOf to return false for native types. + +* Moved string-based matchers to Hamcrest_Text package. + StringContains, StringEndsWith, StringStartsWith, and SubstringMatcher + +* Hamcrest.php and Hamcrest_Matchers.php are now built from @factory doctags. + Added @factory doctag to every static factory method. + +* Hamcrest_Matchers and Hamcrest.php now import each matcher as-needed + and Hamcrest.php calls the matchers directly instead of Hamcrest_Matchers. + + +== Version 0.3.0: Released Jul 26 2010 == + +* Added running count to Hamcrest_MatcherAssert with methods to get and reset it. + This can be used by unit testing frameworks for reporting. + +* Added Hamcrest_Core_HasToString to assert return value of toString() or __toString(). + + assertThat($anObject, hasToString('foo')); + +* Added Hamcrest_Type_IsScalar to assert is_scalar(). + Matches values of type bool, int, float, double, and string. + + assertThat($count, scalarValue()); + assertThat('foo', scalarValue()); + +* Added Hamcrest_Collection package. + + - IsEmptyTraversable + - IsTraversableWithSize + + assertThat($iterator, emptyTraversable()); + assertThat($iterator, traversableWithSize(5)); + +* Added Hamcrest_Xml_HasXPath to assert XPath expressions or the content of nodes in an XML/HTML DOM. + + assertThat($dom, hasXPath('books/book/title')); + assertThat($dom, hasXPath('books/book[contains(title, "Alice")]', 3)); + assertThat($dom, hasXPath('books/book/title', 'Alice in Wonderland')); + assertThat($dom, hasXPath('count(books/book)', greaterThan(10))); + +* Added aliases to match the Java API. + + hasEntry() -> hasKeyValuePair() + hasValue() -> hasItemInArray() + contains() -> arrayContaining() + containsInAnyOrder() -> arrayContainingInAnyOrder() + +* Added optional subtype to Hamcrest_TypeSafeMatcher to enforce object class or resource type. + +* Hamcrest_TypeSafeDiagnosingMatcher now extends Hamcrest_TypeSafeMatcher. + + +== Version 0.2.0: Released Jul 14 2010 == + +Issues Fixed: 109, 111, 114, 115 + +* Description::appendValues() and appendValueList() accept Iterator and IteratorAggregate. [111] + BaseDescription::appendValue() handles IteratorAggregate. + +* assertThat() accepts a single boolean parameter and + wraps any non-Matcher third parameter with equalTo(). + +* Removed null return value from assertThat(). [114] + +* Fixed wrong variable name in contains(). [109] + +* Added Hamcrest_Core_IsSet to assert isset(). + + assertThat(array('foo' => 'bar'), set('foo')); + assertThat(array('foo' => 'bar'), notSet('bar')); + +* Added Hamcrest_Core_IsTypeOf to assert built-in types with gettype(). [115] + Types: array, boolean, double, integer, null, object, resource, and string. + Note that gettype() returns "double" for float values. + + assertThat($count, typeOf('integer')); + assertThat(3.14159, typeOf('double')); + assertThat(array('foo', 'bar'), typeOf('array')); + assertThat(new stdClass(), typeOf('object')); + +* Added type-specific matchers in new Hamcrest_Type package. + + - IsArray + - IsBoolean + - IsDouble (includes float values) + - IsInteger + - IsObject + - IsResource + - IsString + + assertThat($count, integerValue()); + assertThat(3.14159, floatValue()); + assertThat('foo', stringValue()); + +* Added Hamcrest_Type_IsNumeric to assert is_numeric(). + Matches values of type int and float/double or strings that are formatted as numbers. + + assertThat(5, numericValue()); + assertThat('-5e+3', numericValue()); + +* Added Hamcrest_Type_IsCallable to assert is_callable(). + + assertThat('preg_match', callable()); + assertThat(array('SomeClass', 'SomeMethod'), callable()); + assertThat(array($object, 'SomeMethod'), callable()); + assertThat($object, callable()); + assertThat(function ($x, $y) { return $x + $y; }, callable()); + +* Added Hamcrest_Text_MatchesPattern for regex matching with preg_match(). + + assertThat('foobar', matchesPattern('/o+b/')); + +* Added aliases: + - atLeast() for greaterThanOrEqualTo() + - atMost() for lessThanOrEqualTo() + + +== Version 0.1.0: Released Jul 7 2010 == + +* Created PEAR package + +* Core matchers + diff --git a/vendor/hamcrest/hamcrest-php/LICENSE.txt b/vendor/hamcrest/hamcrest-php/LICENSE.txt new file mode 100644 index 000000000..91cd329a4 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/LICENSE.txt @@ -0,0 +1,27 @@ +BSD License + +Copyright (c) 2000-2014, www.hamcrest.org +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +Redistributions of source code must retain the above copyright notice, this list of +conditions and the following disclaimer. Redistributions in binary form must reproduce +the above copyright notice, this list of conditions and the following disclaimer in +the documentation and/or other materials provided with the distribution. + +Neither the name of Hamcrest nor the names of its contributors may be used to endorse +or promote products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT +SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY +WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. diff --git a/vendor/hamcrest/hamcrest-php/README.md b/vendor/hamcrest/hamcrest-php/README.md new file mode 100644 index 000000000..0b07c71ef --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/README.md @@ -0,0 +1,53 @@ +This is the PHP port of Hamcrest Matchers +========================================= + +[![Build Status](https://travis-ci.org/hamcrest/hamcrest-php.png?branch=master)](https://travis-ci.org/hamcrest/hamcrest-php) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/hamcrest/hamcrest-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/hamcrest/hamcrest-php/?branch=master) +[![Code Coverage](https://scrutinizer-ci.com/g/hamcrest/hamcrest-php/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/hamcrest/hamcrest-php/?branch=master) + +Hamcrest is a matching library originally written for Java, but +subsequently ported to many other languages. hamcrest-php is the +official PHP port of Hamcrest and essentially follows a literal +translation of the original Java API for Hamcrest, with a few +Exceptions, mostly down to PHP language barriers: + + 1. `instanceOf($theClass)` is actually `anInstanceOf($theClass)` + + 2. `both(containsString('a'))->and(containsString('b'))` + is actually `both(containsString('a'))->andAlso(containsString('b'))` + + 3. `either(containsString('a'))->or(containsString('b'))` + is actually `either(containsString('a'))->orElse(containsString('b'))` + + 4. Unless it would be non-semantic for a matcher to do so, hamcrest-php + allows dynamic typing for it's input, in "the PHP way". Exception are + where semantics surrounding the type itself would suggest otherwise, + such as stringContains() and greaterThan(). + + 5. Several official matchers have not been ported because they don't + make sense or don't apply in PHP: + + - `typeCompatibleWith($theClass)` + - `eventFrom($source)` + - `hasProperty($name)` ** + - `samePropertyValuesAs($obj)` ** + + 6. When most of the collections matchers are finally ported, PHP-specific + aliases will probably be created due to a difference in naming + conventions between Java's Arrays, Collections, Sets and Maps compared + with PHP's Arrays. + +--- +** [Unless we consider POPO's (Plain Old PHP Objects) akin to JavaBeans] + - The POPO thing is a joke. Java devs coin the term POJO's (Plain Old + Java Objects). + + +Usage +----- + +Hamcrest matchers are easy to use as: + +```php +Hamcrest_MatcherAssert::assertThat('a', Hamcrest_Matchers::equalToIgnoringCase('A')); +``` diff --git a/vendor/hamcrest/hamcrest-php/TODO.txt b/vendor/hamcrest/hamcrest-php/TODO.txt new file mode 100644 index 000000000..92e1190d8 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/TODO.txt @@ -0,0 +1,22 @@ +Still TODO Before Complete for PHP +---------------------------------- + +Port: + + - Hamcrest_Collection_* + - IsCollectionWithSize + - IsEmptyCollection + - IsIn + - IsTraversableContainingInAnyOrder + - IsTraversableContainingInOrder + - IsMapContaining (aliases) + +Aliasing/Deprecation (questionable): + + - Find and fix any factory methods that start with "is". + +Namespaces: + + - Investigate adding PHP 5.3+ namespace support in a way that still permits + use in PHP 5.2. + - Other than a parallel codebase, I don't see how this could be possible. diff --git a/vendor/hamcrest/hamcrest-php/composer.json b/vendor/hamcrest/hamcrest-php/composer.json new file mode 100644 index 000000000..5349f5fda --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/composer.json @@ -0,0 +1,38 @@ +{ + "name": "hamcrest/hamcrest-php", + "type": "library", + "description": "This is the PHP port of Hamcrest Matchers", + "keywords": ["test"], + "license": "BSD", + "authors": [ + ], + + "autoload": { + "classmap": ["hamcrest"] + }, + "autoload-dev": { + "classmap": ["tests", "generator"] + }, + + "require": { + "php": "^5.3|^7.0" + }, + + "require-dev": { + "satooshi/php-coveralls": "^1.0", + "phpunit/php-file-iterator": "1.3.3", + "phpunit/phpunit": "~4.0" + }, + + "replace": { + "kodova/hamcrest-php": "*", + "davedevelopment/hamcrest-php": "*", + "cordoval/hamcrest-php": "*" + }, + + "extra": { + "branch-alias": { + "dev-master": "2.0-dev" + } + } +} diff --git a/vendor/hamcrest/hamcrest-php/composer.lock b/vendor/hamcrest/hamcrest-php/composer.lock new file mode 100644 index 000000000..0581a4ed0 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/composer.lock @@ -0,0 +1,1493 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "52d9e3c2e238bdc2aab7f6e1d322e31d", + "content-hash": "ed113672807f01f40b4d9809b102dc31", + "packages": [], + "packages-dev": [ + { + "name": "doctrine/instantiator", + "version": "1.0.5", + "source": { + "type": "git", + "url": "https://github.com/doctrine/instantiator.git", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", + "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", + "shasum": "" + }, + "require": { + "php": ">=5.3,<8.0-DEV" + }, + "require-dev": { + "athletic/athletic": "~0.1.8", + "ext-pdo": "*", + "ext-phar": "*", + "phpunit/phpunit": "~4.0", + "squizlabs/php_codesniffer": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Marco Pivetta", + "email": "ocramius@gmail.com", + "homepage": "http://ocramius.github.com/" + } + ], + "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", + "homepage": "https://github.com/doctrine/instantiator", + "keywords": [ + "constructor", + "instantiate" + ], + "time": "2015-06-14 21:17:01" + }, + { + "name": "guzzle/guzzle", + "version": "v3.9.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle3.git", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle3/zipball/0645b70d953bc1c067bbc8d5bc53194706b628d9", + "reference": "0645b70d953bc1c067bbc8d5bc53194706b628d9", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "php": ">=5.3.3", + "symfony/event-dispatcher": "~2.1" + }, + "replace": { + "guzzle/batch": "self.version", + "guzzle/cache": "self.version", + "guzzle/common": "self.version", + "guzzle/http": "self.version", + "guzzle/inflection": "self.version", + "guzzle/iterator": "self.version", + "guzzle/log": "self.version", + "guzzle/parser": "self.version", + "guzzle/plugin": "self.version", + "guzzle/plugin-async": "self.version", + "guzzle/plugin-backoff": "self.version", + "guzzle/plugin-cache": "self.version", + "guzzle/plugin-cookie": "self.version", + "guzzle/plugin-curlauth": "self.version", + "guzzle/plugin-error-response": "self.version", + "guzzle/plugin-history": "self.version", + "guzzle/plugin-log": "self.version", + "guzzle/plugin-md5": "self.version", + "guzzle/plugin-mock": "self.version", + "guzzle/plugin-oauth": "self.version", + "guzzle/service": "self.version", + "guzzle/stream": "self.version" + }, + "require-dev": { + "doctrine/cache": "~1.3", + "monolog/monolog": "~1.0", + "phpunit/phpunit": "3.7.*", + "psr/log": "~1.0", + "symfony/class-loader": "~2.1", + "zendframework/zend-cache": "2.*,<2.3", + "zendframework/zend-log": "2.*,<2.3" + }, + "suggest": { + "guzzlehttp/guzzle": "Guzzle 5 has moved to a new package name. The package you have installed, Guzzle 3, is deprecated." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.9-dev" + } + }, + "autoload": { + "psr-0": { + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + }, + { + "name": "Guzzle Community", + "homepage": "https://github.com/guzzle/guzzle/contributors" + } + ], + "description": "PHP HTTP client. This library is deprecated in favor of https://packagist.org/packages/guzzlehttp/guzzle", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-03-18 18:23:50" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", + "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "suggest": { + "dflydev/markdown": "~1.0", + "erusev/parsedown": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-0": { + "phpDocumentor": [ + "src/" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "mike.vanriel@naenius.com" + } + ], + "time": "2015-02-03 12:10:50" + }, + { + "name": "phpspec/prophecy", + "version": "v1.5.0", + "source": { + "type": "git", + "url": "https://github.com/phpspec/prophecy.git", + "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7", + "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "phpdocumentor/reflection-docblock": "~2.0", + "sebastian/comparator": "~1.1" + }, + "require-dev": { + "phpspec/phpspec": "~2.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4.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": "2015-08-13 10:07:40" + }, + { + "name": "phpunit/php-code-coverage", + "version": "2.2.4", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-code-coverage.git", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "phpunit/php-file-iterator": "~1.3", + "phpunit/php-text-template": "~1.2", + "phpunit/php-token-stream": "~1.3", + "sebastian/environment": "^1.3.2", + "sebastian/version": "~1.0" + }, + "require-dev": { + "ext-xdebug": ">=2.1.4", + "phpunit/phpunit": "~4" + }, + "suggest": { + "ext-dom": "*", + "ext-xdebug": ">=2.2.1", + "ext-xmlwriter": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", + "homepage": "https://github.com/sebastianbergmann/php-code-coverage", + "keywords": [ + "coverage", + "testing", + "xunit" + ], + "time": "2015-10-06 15:47:00" + }, + { + "name": "phpunit/php-file-iterator", + "version": "1.3.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-file-iterator.git", + "reference": "16a78140ed2fc01b945cfa539665fadc6a038029" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/16a78140ed2fc01b945cfa539665fadc6a038029", + "reference": "16a78140ed2fc01b945cfa539665fadc6a038029", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "File/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "include-path": [ + "" + ], + "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": "http://www.phpunit.de/", + "keywords": [ + "filesystem", + "iterator" + ], + "time": "2012-10-11 11:44:38" + }, + { + "name": "phpunit/php-text-template", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-text-template.git", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Simple template engine.", + "homepage": "https://github.com/sebastianbergmann/php-text-template/", + "keywords": [ + "template" + ], + "time": "2015-06-21 13:50:34" + }, + { + "name": "phpunit/php-timer", + "version": "1.0.7", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-timer.git", + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Utility class for timing", + "homepage": "https://github.com/sebastianbergmann/php-timer/", + "keywords": [ + "timer" + ], + "time": "2015-06-21 08:01:12" + }, + { + "name": "phpunit/php-token-stream", + "version": "1.4.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/php-token-stream.git", + "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", + "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", + "shasum": "" + }, + "require": { + "ext-tokenizer": "*", + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Wrapper around PHP's tokenizer extension.", + "homepage": "https://github.com/sebastianbergmann/php-token-stream/", + "keywords": [ + "tokenizer" + ], + "time": "2015-09-15 10:49:45" + }, + { + "name": "phpunit/phpunit", + "version": "4.5.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit.git", + "reference": "d6429b0995b24a2d9dfe5587ee3a7071c1161af4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d6429b0995b24a2d9dfe5587ee3a7071c1161af4", + "reference": "d6429b0995b24a2d9dfe5587ee3a7071c1161af4", + "shasum": "" + }, + "require": { + "ext-dom": "*", + "ext-json": "*", + "ext-pcre": "*", + "ext-reflection": "*", + "ext-spl": "*", + "php": ">=5.3.3", + "phpspec/prophecy": "~1.3,>=1.3.1", + "phpunit/php-code-coverage": "~2.0,>=2.0.11", + "phpunit/php-file-iterator": "~1.3.2", + "phpunit/php-text-template": "~1.2", + "phpunit/php-timer": "~1.0.2", + "phpunit/phpunit-mock-objects": "~2.3", + "sebastian/comparator": "~1.1", + "sebastian/diff": "~1.1", + "sebastian/environment": "~1.2", + "sebastian/exporter": "~1.2", + "sebastian/global-state": "~1.0", + "sebastian/version": "~1.0", + "symfony/yaml": "~2.0" + }, + "suggest": { + "phpunit/php-invoker": "~1.1" + }, + "bin": [ + "phpunit" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "4.5.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": "2015-03-29 09:24:05" + }, + { + "name": "phpunit/phpunit-mock-objects", + "version": "2.3.8", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", + "shasum": "" + }, + "require": { + "doctrine/instantiator": "^1.0.2", + "php": ">=5.3.3", + "phpunit/php-text-template": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "suggest": { + "ext-soap": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sb@sebastian-bergmann.de", + "role": "lead" + } + ], + "description": "Mock Object library for PHPUnit", + "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", + "keywords": [ + "mock", + "xunit" + ], + "time": "2015-10-02 06:51:40" + }, + { + "name": "psr/log", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b", + "reference": "fe0936ee26643249e916849d48e3a51d5f5e278b", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-0": { + "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", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "time": "2012-12-21 11:40:51" + }, + { + "name": "satooshi/php-coveralls", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/satooshi/php-coveralls.git", + "reference": "3edbdbdb4f4cfab5cb9ce83655ff81432f2221a6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/3edbdbdb4f4cfab5cb9ce83655ff81432f2221a6", + "reference": "3edbdbdb4f4cfab5cb9ce83655ff81432f2221a6", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-simplexml": "*", + "guzzle/guzzle": "^2.8|^3.0", + "php": ">=5.3.3", + "psr/log": "^1.0", + "symfony/config": "^2.4|^3.0", + "symfony/console": "^2.1|^3.0", + "symfony/stopwatch": "^2.2|^3.0", + "symfony/yaml": "^2.1|^3.0" + }, + "suggest": { + "symfony/http-kernel": "Allows Symfony integration" + }, + "bin": [ + "bin/coveralls" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.8-dev" + } + }, + "autoload": { + "psr-4": { + "Satooshi\\": "src/Satooshi/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kitamura Satoshi", + "email": "with.no.parachute@gmail.com", + "homepage": "https://www.facebook.com/satooshi.jp" + } + ], + "description": "PHP client library for Coveralls API", + "homepage": "https://github.com/satooshi/php-coveralls", + "keywords": [ + "ci", + "coverage", + "github", + "test" + ], + "time": "2015-12-28 09:07:32" + }, + { + "name": "sebastian/comparator", + "version": "1.2.0", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/comparator.git", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", + "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/diff": "~1.2", + "sebastian/exporter": "~1.2" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides the functionality to compare PHP values for equality", + "homepage": "http://www.github.com/sebastianbergmann/comparator", + "keywords": [ + "comparator", + "compare", + "equality" + ], + "time": "2015-07-26 15:48:44" + }, + { + "name": "sebastian/diff", + "version": "1.4.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/diff.git", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", + "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.8" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.4-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Kore Nordmann", + "email": "mail@kore-nordmann.de" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Diff implementation", + "homepage": "https://github.com/sebastianbergmann/diff", + "keywords": [ + "diff" + ], + "time": "2015-12-08 07:14:41" + }, + { + "name": "sebastian/environment", + "version": "1.3.3", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/environment.git", + "reference": "6e7133793a8e5a5714a551a8324337374be209df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e7133793a8e5a5714a551a8324337374be209df", + "reference": "6e7133793a8e5a5714a551a8324337374be209df", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Provides functionality to handle HHVM/PHP environments", + "homepage": "http://www.github.com/sebastianbergmann/environment", + "keywords": [ + "Xdebug", + "environment", + "hhvm" + ], + "time": "2015-12-02 08:37:27" + }, + { + "name": "sebastian/exporter", + "version": "1.2.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/exporter.git", + "reference": "7ae5513327cb536431847bcc0c10edba2701064e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", + "reference": "7ae5513327cb536431847bcc0c10edba2701064e", + "shasum": "" + }, + "require": { + "php": ">=5.3.3", + "sebastian/recursion-context": "~1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.2.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Volker Dusch", + "email": "github@wallbash.com" + }, + { + "name": "Bernhard Schussek", + "email": "bschussek@2bepublished.at" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides the functionality to export PHP variables for visualization", + "homepage": "http://www.github.com/sebastianbergmann/exporter", + "keywords": [ + "export", + "exporter" + ], + "time": "2015-06-21 07:55:53" + }, + { + "name": "sebastian/global-state", + "version": "1.1.1", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/global-state.git", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", + "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.2" + }, + "suggest": { + "ext-uopz": "*" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + } + ], + "description": "Snapshotting of global state", + "homepage": "http://www.github.com/sebastianbergmann/global-state", + "keywords": [ + "global state" + ], + "time": "2015-10-12 03:26:01" + }, + { + "name": "sebastian/recursion-context", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/recursion-context.git", + "reference": "913401df809e99e4f47b27cdd781f4a258d58791" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", + "reference": "913401df809e99e4f47b27cdd781f4a258d58791", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "require-dev": { + "phpunit/phpunit": "~4.4" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Jeff Welch", + "email": "whatthejeff@gmail.com" + }, + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de" + }, + { + "name": "Adam Harvey", + "email": "aharvey@php.net" + } + ], + "description": "Provides functionality to recursively process PHP variables", + "homepage": "http://www.github.com/sebastianbergmann/recursion-context", + "time": "2015-11-11 19:50:13" + }, + { + "name": "sebastian/version", + "version": "1.0.6", + "source": { + "type": "git", + "url": "https://github.com/sebastianbergmann/version.git", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", + "shasum": "" + }, + "type": "library", + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause" + ], + "authors": [ + { + "name": "Sebastian Bergmann", + "email": "sebastian@phpunit.de", + "role": "lead" + } + ], + "description": "Library that helps with managing the version number of Git-hosted PHP projects", + "homepage": "https://github.com/sebastianbergmann/version", + "time": "2015-06-21 13:59:46" + }, + { + "name": "symfony/config", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/config.git", + "reference": "17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/config/zipball/17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2", + "reference": "17d4b2e64ce1c6ba7caa040f14469b3c44d7f7d2", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/filesystem": "~2.3|~3.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Config\\": "" + }, + "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 Config Component", + "homepage": "https://symfony.com", + "time": "2015-12-26 13:37:56" + }, + { + "name": "symfony/console", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/console.git", + "reference": "2e06a5ccb19dcf9b89f1c6a677a39a8df773635a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/console/zipball/2e06a5ccb19dcf9b89f1c6a677a39a8df773635a", + "reference": "2e06a5ccb19dcf9b89f1c6a677a39a8df773635a", + "shasum": "" + }, + "require": { + "php": ">=5.3.9", + "symfony/polyfill-mbstring": "~1.0" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/event-dispatcher": "~2.1|~3.0.0", + "symfony/process": "~2.1|~3.0.0" + }, + "suggest": { + "psr/log": "For using the console logger", + "symfony/event-dispatcher": "", + "symfony/process": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-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": "2015-12-22 10:25:57" + }, + { + "name": "symfony/event-dispatcher", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/event-dispatcher.git", + "reference": "a5eb815363c0388e83247e7e9853e5dbc14999cc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a5eb815363c0388e83247e7e9853e5dbc14999cc", + "reference": "a5eb815363c0388e83247e7e9853e5dbc14999cc", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "require-dev": { + "psr/log": "~1.0", + "symfony/config": "~2.0,>=2.0.5|~3.0.0", + "symfony/dependency-injection": "~2.6|~3.0.0", + "symfony/expression-language": "~2.6|~3.0.0", + "symfony/stopwatch": "~2.3|~3.0.0" + }, + "suggest": { + "symfony/dependency-injection": "", + "symfony/http-kernel": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\EventDispatcher\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony EventDispatcher Component", + "homepage": "https://symfony.com", + "time": "2015-10-30 20:15:42" + }, + { + "name": "symfony/filesystem", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/filesystem.git", + "reference": "a7ad724530a764d70c168d321ac226ba3d2f10fc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/a7ad724530a764d70c168d321ac226ba3d2f10fc", + "reference": "a7ad724530a764d70c168d321ac226ba3d2f10fc", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Filesystem\\": "" + }, + "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 Filesystem Component", + "homepage": "https://symfony.com", + "time": "2015-12-22 10:25:57" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.0.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "49ff736bd5d41f45240cec77b44967d76e0c3d25" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/49ff736bd5d41f45240cec77b44967d76e0c3d25", + "reference": "49ff736bd5d41f45240cec77b44967d76e0c3d25", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + }, + "files": [ + "bootstrap.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "time": "2015-11-20 09:19:13" + }, + { + "name": "symfony/stopwatch", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/stopwatch.git", + "reference": "5f1e2ebd1044da542d2b9510527836e8be92b1cb" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/stopwatch/zipball/5f1e2ebd1044da542d2b9510527836e8be92b1cb", + "reference": "5f1e2ebd1044da542d2b9510527836e8be92b1cb", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Stopwatch\\": "" + }, + "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 Stopwatch Component", + "homepage": "https://symfony.com", + "time": "2015-10-30 20:15:42" + }, + { + "name": "symfony/yaml", + "version": "v2.8.1", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966", + "reference": "ac84cbb98b68a6abbc9f5149eb96ccc7b07b8966", + "shasum": "" + }, + "require": { + "php": ">=5.3.9" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.8-dev" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony Yaml Component", + "homepage": "https://symfony.com", + "time": "2015-12-26 13:37:56" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": ">=5.3.2" + }, + "platform-dev": [] +} diff --git a/vendor/hamcrest/hamcrest-php/generator/FactoryCall.php b/vendor/hamcrest/hamcrest-php/generator/FactoryCall.php new file mode 100644 index 000000000..83965b2ae --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/FactoryCall.php @@ -0,0 +1,41 @@ +method = $method; + $this->name = $name; + } + + public function getMethod() + { + return $this->method; + } + + public function getName() + { + return $this->name; + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/FactoryClass.php b/vendor/hamcrest/hamcrest-php/generator/FactoryClass.php new file mode 100644 index 000000000..0c6bf78d7 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/FactoryClass.php @@ -0,0 +1,72 @@ +file = $file; + $this->reflector = $class; + $this->extractFactoryMethods(); + } + + public function extractFactoryMethods() + { + $this->methods = array(); + foreach ($this->getPublicStaticMethods() as $method) { + if ($method->isFactory()) { +// echo $this->getName() . '::' . $method->getName() . ' : ' . count($method->getCalls()) . PHP_EOL; + $this->methods[] = $method; + } + } + } + + public function getPublicStaticMethods() + { + $methods = array(); + foreach ($this->reflector->getMethods(ReflectionMethod::IS_STATIC) as $method) { + if ($method->isPublic() && $method->getDeclaringClass() == $this->reflector) { + $methods[] = new FactoryMethod($this, $method); + } + } + return $methods; + } + + public function getFile() + { + return $this->file; + } + + public function getName() + { + return $this->reflector->name; + } + + public function isFactory() + { + return !empty($this->methods); + } + + public function getMethods() + { + return $this->methods; + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/FactoryFile.php b/vendor/hamcrest/hamcrest-php/generator/FactoryFile.php new file mode 100644 index 000000000..ac3d6c7d3 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/FactoryFile.php @@ -0,0 +1,122 @@ +file = $file; + $this->indent = $indent; + } + + abstract public function addCall(FactoryCall $call); + + abstract public function build(); + + public function addFileHeader() + { + $this->code = ''; + $this->addPart('file_header'); + } + + public function addPart($name) + { + $this->addCode($this->readPart($name)); + } + + public function addCode($code) + { + $this->code .= $code; + } + + public function readPart($name) + { + return file_get_contents(__DIR__ . "/parts/$name.txt"); + } + + public function generateFactoryCall(FactoryCall $call) + { + $method = $call->getMethod(); + $code = $method->getComment($this->indent) . PHP_EOL; + $code .= $this->generateDeclaration($call->getName(), $method); + // $code .= $this->generateImport($method); + $code .= $this->generateCall($method); + $code .= $this->generateClosing(); + return $code; + } + + public function generateDeclaration($name, FactoryMethod $method) + { + $code = $this->indent . $this->getDeclarationModifiers() + . 'function ' . $name . '(' + . $this->generateDeclarationArguments($method) + . ')' . PHP_EOL . $this->indent . '{' . PHP_EOL; + return $code; + } + + public function getDeclarationModifiers() + { + return ''; + } + + public function generateDeclarationArguments(FactoryMethod $method) + { + if ($method->acceptsVariableArguments()) { + return '/* args... */'; + } else { + return $method->getParameterDeclarations(); + } + } + + public function generateImport(FactoryMethod $method) + { + return $this->indent . self::INDENT . "require_once '" . $method->getClass()->getFile() . "';" . PHP_EOL; + } + + public function generateCall(FactoryMethod $method) + { + $code = ''; + if ($method->acceptsVariableArguments()) { + $code .= $this->indent . self::INDENT . '$args = func_get_args();' . PHP_EOL; + } + + $code .= $this->indent . self::INDENT . 'return '; + if ($method->acceptsVariableArguments()) { + $code .= 'call_user_func_array(array(\'' + . '\\' . $method->getClassName() . '\', \'' + . $method->getName() . '\'), $args);' . PHP_EOL; + } else { + $code .= '\\' . $method->getClassName() . '::' + . $method->getName() . '(' + . $method->getParameterInvocations() . ');' . PHP_EOL; + } + + return $code; + } + + public function generateClosing() + { + return $this->indent . '}' . PHP_EOL; + } + + public function write() + { + file_put_contents($this->file, $this->code); + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/FactoryGenerator.php b/vendor/hamcrest/hamcrest-php/generator/FactoryGenerator.php new file mode 100644 index 000000000..37f80b6e9 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/FactoryGenerator.php @@ -0,0 +1,115 @@ +path = $path; + $this->factoryFiles = array(); + } + + public function addFactoryFile(FactoryFile $factoryFile) + { + $this->factoryFiles[] = $factoryFile; + } + + public function generate() + { + $classes = $this->getClassesWithFactoryMethods(); + foreach ($classes as $class) { + foreach ($class->getMethods() as $method) { + foreach ($method->getCalls() as $call) { + foreach ($this->factoryFiles as $file) { + $file->addCall($call); + } + } + } + } + } + + public function write() + { + foreach ($this->factoryFiles as $file) { + $file->build(); + $file->write(); + } + } + + public function getClassesWithFactoryMethods() + { + $classes = array(); + $files = $this->getSortedFiles(); + foreach ($files as $file) { + $class = $this->getFactoryClass($file); + if ($class !== null) { + $classes[] = $class; + } + } + + return $classes; + } + + public function getSortedFiles() + { + $iter = \File_Iterator_Factory::getFileIterator($this->path, '.php'); + $files = array(); + foreach ($iter as $file) { + $files[] = $file; + } + sort($files, SORT_STRING); + + return $files; + } + + public function getFactoryClass($file) + { + $name = $this->getFactoryClassName($file); + if ($name !== null) { + require_once $file; + + if (class_exists($name)) { + $class = new FactoryClass(substr($file, strpos($file, 'Hamcrest/')), new ReflectionClass($name)); + if ($class->isFactory()) { + return $class; + } + } + } + + return null; + } + + public function getFactoryClassName($file) + { + $content = file_get_contents($file); + if (preg_match('/namespace\s+(.+);/', $content, $namespace) + && preg_match('/\n\s*class\s+(\w+)\s+extends\b/', $content, $className) + && preg_match('/@factory\b/', $content) + ) { + return $namespace[1] . '\\' . $className[1]; + } + + return null; + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/FactoryMethod.php b/vendor/hamcrest/hamcrest-php/generator/FactoryMethod.php new file mode 100644 index 000000000..44f8dc510 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/FactoryMethod.php @@ -0,0 +1,231 @@ +class = $class; + $this->reflector = $reflector; + $this->extractCommentWithoutLeadingShashesAndStars(); + $this->extractFactoryNamesFromComment(); + $this->extractParameters(); + } + + public function extractCommentWithoutLeadingShashesAndStars() + { + $this->comment = explode("\n", $this->reflector->getDocComment()); + foreach ($this->comment as &$line) { + $line = preg_replace('#^\s*(/\\*+|\\*+/|\\*)\s?#', '', $line); + } + $this->trimLeadingBlankLinesFromComment(); + $this->trimTrailingBlankLinesFromComment(); + } + + public function trimLeadingBlankLinesFromComment() + { + while (count($this->comment) > 0) { + $line = array_shift($this->comment); + if (trim($line) != '') { + array_unshift($this->comment, $line); + break; + } + } + } + + public function trimTrailingBlankLinesFromComment() + { + while (count($this->comment) > 0) { + $line = array_pop($this->comment); + if (trim($line) != '') { + array_push($this->comment, $line); + break; + } + } + } + + public function extractFactoryNamesFromComment() + { + $this->calls = array(); + for ($i = 0; $i < count($this->comment); $i++) { + if ($this->extractFactoryNamesFromLine($this->comment[$i])) { + unset($this->comment[$i]); + } + } + $this->trimTrailingBlankLinesFromComment(); + } + + public function extractFactoryNamesFromLine($line) + { + if (preg_match('/^\s*@factory(\s+(.+))?$/', $line, $match)) { + $this->createCalls( + $this->extractFactoryNamesFromAnnotation( + isset($match[2]) ? trim($match[2]) : null + ) + ); + return true; + } + return false; + } + + public function extractFactoryNamesFromAnnotation($value) + { + $primaryName = $this->reflector->getName(); + if (empty($value)) { + return array($primaryName); + } + preg_match_all('/(\.{3}|-|[a-zA-Z_][a-zA-Z_0-9]*)/', $value, $match); + $names = $match[0]; + if (in_array('...', $names)) { + $this->isVarArgs = true; + } + if (!in_array('-', $names) && !in_array($primaryName, $names)) { + array_unshift($names, $primaryName); + } + return $names; + } + + public function createCalls(array $names) + { + $names = array_unique($names); + foreach ($names as $name) { + if ($name != '-' && $name != '...') { + $this->calls[] = new FactoryCall($this, $name); + } + } + } + + public function extractParameters() + { + $this->parameters = array(); + if (!$this->isVarArgs) { + foreach ($this->reflector->getParameters() as $parameter) { + $this->parameters[] = new FactoryParameter($this, $parameter); + } + } + } + + public function getParameterDeclarations() + { + if ($this->isVarArgs || !$this->hasParameters()) { + return ''; + } + $params = array(); + foreach ($this->parameters as /** @var $parameter FactoryParameter */ + $parameter) { + $params[] = $parameter->getDeclaration(); + } + return implode(', ', $params); + } + + public function getParameterInvocations() + { + if ($this->isVarArgs) { + return ''; + } + $params = array(); + foreach ($this->parameters as $parameter) { + $params[] = $parameter->getInvocation(); + } + return implode(', ', $params); + } + + + public function getClass() + { + return $this->class; + } + + public function getClassName() + { + return $this->class->getName(); + } + + public function getName() + { + return $this->reflector->name; + } + + public function isFactory() + { + return count($this->calls) > 0; + } + + public function getCalls() + { + return $this->calls; + } + + public function acceptsVariableArguments() + { + return $this->isVarArgs; + } + + public function hasParameters() + { + return !empty($this->parameters); + } + + public function getParameters() + { + return $this->parameters; + } + + public function getFullName() + { + return $this->getClassName() . '::' . $this->getName(); + } + + public function getCommentText() + { + return implode(PHP_EOL, $this->comment); + } + + public function getComment($indent = '') + { + $comment = $indent . '/**'; + foreach ($this->comment as $line) { + $comment .= PHP_EOL . rtrim($indent . ' * ' . $line); + } + $comment .= PHP_EOL . $indent . ' */'; + return $comment; + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/FactoryParameter.php b/vendor/hamcrest/hamcrest-php/generator/FactoryParameter.php new file mode 100644 index 000000000..93a76b38d --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/FactoryParameter.php @@ -0,0 +1,69 @@ +method = $method; + $this->reflector = $reflector; + } + + public function getDeclaration() + { + if ($this->reflector->isArray()) { + $code = 'array '; + } else { + $class = $this->reflector->getClass(); + if ($class !== null) { + $code = '\\' . $class->name . ' '; + } else { + $code = ''; + } + } + $code .= '$' . $this->reflector->name; + if ($this->reflector->isOptional()) { + $default = $this->reflector->getDefaultValue(); + if (is_null($default)) { + $default = 'null'; + } elseif (is_bool($default)) { + $default = $default ? 'true' : 'false'; + } elseif (is_string($default)) { + $default = "'" . $default . "'"; + } elseif (is_numeric($default)) { + $default = strval($default); + } elseif (is_array($default)) { + $default = 'array()'; + } else { + echo 'Warning: unknown default type for ' . $this->getMethod()->getFullName() . PHP_EOL; + var_dump($default); + $default = 'null'; + } + $code .= ' = ' . $default; + } + return $code; + } + + public function getInvocation() + { + return '$' . $this->reflector->name; + } + + public function getMethod() + { + return $this->method; + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/GlobalFunctionFile.php b/vendor/hamcrest/hamcrest-php/generator/GlobalFunctionFile.php new file mode 100644 index 000000000..5ee1b69f0 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/GlobalFunctionFile.php @@ -0,0 +1,42 @@ +functions = ''; + } + + public function addCall(FactoryCall $call) + { + $this->functions .= PHP_EOL . $this->generateFactoryCall($call); + } + + public function build() + { + $this->addFileHeader(); + $this->addPart('functions_imports'); + $this->addPart('functions_header'); + $this->addCode($this->functions); + $this->addPart('functions_footer'); + } + + public function generateFactoryCall(FactoryCall $call) + { + $code = "if (!function_exists('{$call->getName()}')) {"; + $code.= parent::generateFactoryCall($call); + $code.= "}\n"; + + return $code; + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/StaticMethodFile.php b/vendor/hamcrest/hamcrest-php/generator/StaticMethodFile.php new file mode 100644 index 000000000..44cec02f0 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/StaticMethodFile.php @@ -0,0 +1,38 @@ +methods = ''; + } + + public function addCall(FactoryCall $call) + { + $this->methods .= PHP_EOL . $this->generateFactoryCall($call); + } + + public function getDeclarationModifiers() + { + return 'public static '; + } + + public function build() + { + $this->addFileHeader(); + $this->addPart('matchers_imports'); + $this->addPart('matchers_header'); + $this->addCode($this->methods); + $this->addPart('matchers_footer'); + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/parts/file_header.txt b/vendor/hamcrest/hamcrest-php/generator/parts/file_header.txt new file mode 100644 index 000000000..7b352e447 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/parts/file_header.txt @@ -0,0 +1,7 @@ + + * //With an identifier + * assertThat("assertion identifier", $apple->flavour(), equalTo("tasty")); + * //Without an identifier + * assertThat($apple->flavour(), equalTo("tasty")); + * //Evaluating a boolean expression + * assertThat("some error", $a > $b); + * + */ + function assertThat() + { + $args = func_get_args(); + call_user_func_array( + array('Hamcrest\MatcherAssert', 'assertThat'), + $args + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/generator/parts/functions_imports.txt b/vendor/hamcrest/hamcrest-php/generator/parts/functions_imports.txt new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/hamcrest/hamcrest-php/generator/parts/matchers_footer.txt b/vendor/hamcrest/hamcrest-php/generator/parts/matchers_footer.txt new file mode 100644 index 000000000..5c34318c2 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/parts/matchers_footer.txt @@ -0,0 +1 @@ +} diff --git a/vendor/hamcrest/hamcrest-php/generator/parts/matchers_header.txt b/vendor/hamcrest/hamcrest-php/generator/parts/matchers_header.txt new file mode 100644 index 000000000..4f8bb2b7b --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/parts/matchers_header.txt @@ -0,0 +1,7 @@ + + +/** + * A series of static factories for all hamcrest matchers. + */ +class Matchers +{ diff --git a/vendor/hamcrest/hamcrest-php/generator/parts/matchers_imports.txt b/vendor/hamcrest/hamcrest-php/generator/parts/matchers_imports.txt new file mode 100644 index 000000000..7dd684953 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/parts/matchers_imports.txt @@ -0,0 +1,2 @@ + +namespace Hamcrest; \ No newline at end of file diff --git a/vendor/hamcrest/hamcrest-php/generator/run.php b/vendor/hamcrest/hamcrest-php/generator/run.php new file mode 100644 index 000000000..924d752ff --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/generator/run.php @@ -0,0 +1,37 @@ +addFactoryFile(new StaticMethodFile(STATIC_MATCHERS_FILE)); +$generator->addFactoryFile(new GlobalFunctionFile(GLOBAL_FUNCTIONS_FILE)); +$generator->generate(); +$generator->write(); diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php new file mode 100644 index 000000000..8a719eb3a --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php @@ -0,0 +1,805 @@ + + * //With an identifier + * assertThat("assertion identifier", $apple->flavour(), equalTo("tasty")); + * //Without an identifier + * assertThat($apple->flavour(), equalTo("tasty")); + * //Evaluating a boolean expression + * assertThat("some error", $a > $b); + * + */ + function assertThat() + { + $args = func_get_args(); + call_user_func_array( + array('Hamcrest\MatcherAssert', 'assertThat'), + $args + ); + } +} + +if (!function_exists('anArray')) { /** + * Evaluates to true only if each $matcher[$i] is satisfied by $array[$i]. + */ + function anArray(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Arrays\IsArray', 'anArray'), $args); + } +} + +if (!function_exists('hasItemInArray')) { /** + * Evaluates to true if any item in an array satisfies the given matcher. + * + * @param mixed $item as a {@link Hamcrest\Matcher} or a value. + * + * @return \Hamcrest\Arrays\IsArrayContaining + */ + function hasItemInArray($item) + { + return \Hamcrest\Arrays\IsArrayContaining::hasItemInArray($item); + } +} + +if (!function_exists('hasValue')) { /** + * Evaluates to true if any item in an array satisfies the given matcher. + * + * @param mixed $item as a {@link Hamcrest\Matcher} or a value. + * + * @return \Hamcrest\Arrays\IsArrayContaining + */ + function hasValue($item) + { + return \Hamcrest\Arrays\IsArrayContaining::hasItemInArray($item); + } +} + +if (!function_exists('arrayContainingInAnyOrder')) { /** + * An array with elements that match the given matchers. + */ + function arrayContainingInAnyOrder(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Arrays\IsArrayContainingInAnyOrder', 'arrayContainingInAnyOrder'), $args); + } +} + +if (!function_exists('containsInAnyOrder')) { /** + * An array with elements that match the given matchers. + */ + function containsInAnyOrder(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Arrays\IsArrayContainingInAnyOrder', 'arrayContainingInAnyOrder'), $args); + } +} + +if (!function_exists('arrayContaining')) { /** + * An array with elements that match the given matchers in the same order. + */ + function arrayContaining(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Arrays\IsArrayContainingInOrder', 'arrayContaining'), $args); + } +} + +if (!function_exists('contains')) { /** + * An array with elements that match the given matchers in the same order. + */ + function contains(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Arrays\IsArrayContainingInOrder', 'arrayContaining'), $args); + } +} + +if (!function_exists('hasKeyInArray')) { /** + * Evaluates to true if any key in an array matches the given matcher. + * + * @param mixed $key as a {@link Hamcrest\Matcher} or a value. + * + * @return \Hamcrest\Arrays\IsArrayContainingKey + */ + function hasKeyInArray($key) + { + return \Hamcrest\Arrays\IsArrayContainingKey::hasKeyInArray($key); + } +} + +if (!function_exists('hasKey')) { /** + * Evaluates to true if any key in an array matches the given matcher. + * + * @param mixed $key as a {@link Hamcrest\Matcher} or a value. + * + * @return \Hamcrest\Arrays\IsArrayContainingKey + */ + function hasKey($key) + { + return \Hamcrest\Arrays\IsArrayContainingKey::hasKeyInArray($key); + } +} + +if (!function_exists('hasKeyValuePair')) { /** + * Test if an array has both an key and value in parity with each other. + */ + function hasKeyValuePair($key, $value) + { + return \Hamcrest\Arrays\IsArrayContainingKeyValuePair::hasKeyValuePair($key, $value); + } +} + +if (!function_exists('hasEntry')) { /** + * Test if an array has both an key and value in parity with each other. + */ + function hasEntry($key, $value) + { + return \Hamcrest\Arrays\IsArrayContainingKeyValuePair::hasKeyValuePair($key, $value); + } +} + +if (!function_exists('arrayWithSize')) { /** + * Does array size satisfy a given matcher? + * + * @param \Hamcrest\Matcher|int $size as a {@link Hamcrest\Matcher} or a value. + * + * @return \Hamcrest\Arrays\IsArrayWithSize + */ + function arrayWithSize($size) + { + return \Hamcrest\Arrays\IsArrayWithSize::arrayWithSize($size); + } +} + +if (!function_exists('emptyArray')) { /** + * Matches an empty array. + */ + function emptyArray() + { + return \Hamcrest\Arrays\IsArrayWithSize::emptyArray(); + } +} + +if (!function_exists('nonEmptyArray')) { /** + * Matches an empty array. + */ + function nonEmptyArray() + { + return \Hamcrest\Arrays\IsArrayWithSize::nonEmptyArray(); + } +} + +if (!function_exists('emptyTraversable')) { /** + * Returns true if traversable is empty. + */ + function emptyTraversable() + { + return \Hamcrest\Collection\IsEmptyTraversable::emptyTraversable(); + } +} + +if (!function_exists('nonEmptyTraversable')) { /** + * Returns true if traversable is not empty. + */ + function nonEmptyTraversable() + { + return \Hamcrest\Collection\IsEmptyTraversable::nonEmptyTraversable(); + } +} + +if (!function_exists('traversableWithSize')) { /** + * Does traversable size satisfy a given matcher? + */ + function traversableWithSize($size) + { + return \Hamcrest\Collection\IsTraversableWithSize::traversableWithSize($size); + } +} + +if (!function_exists('allOf')) { /** + * Evaluates to true only if ALL of the passed in matchers evaluate to true. + */ + function allOf(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\AllOf', 'allOf'), $args); + } +} + +if (!function_exists('anyOf')) { /** + * Evaluates to true if ANY of the passed in matchers evaluate to true. + */ + function anyOf(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\AnyOf', 'anyOf'), $args); + } +} + +if (!function_exists('noneOf')) { /** + * Evaluates to false if ANY of the passed in matchers evaluate to true. + */ + function noneOf(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\AnyOf', 'noneOf'), $args); + } +} + +if (!function_exists('both')) { /** + * This is useful for fluently combining matchers that must both pass. + * For example: + *
+     *   assertThat($string, both(containsString("a"))->andAlso(containsString("b")));
+     * 
+ */ + function both(\Hamcrest\Matcher $matcher) + { + return \Hamcrest\Core\CombinableMatcher::both($matcher); + } +} + +if (!function_exists('either')) { /** + * This is useful for fluently combining matchers where either may pass, + * for example: + *
+     *   assertThat($string, either(containsString("a"))->orElse(containsString("b")));
+     * 
+ */ + function either(\Hamcrest\Matcher $matcher) + { + return \Hamcrest\Core\CombinableMatcher::either($matcher); + } +} + +if (!function_exists('describedAs')) { /** + * Wraps an existing matcher and overrides the description when it fails. + */ + function describedAs(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\DescribedAs', 'describedAs'), $args); + } +} + +if (!function_exists('everyItem')) { /** + * @param Matcher $itemMatcher + * A matcher to apply to every element in an array. + * + * @return \Hamcrest\Core\Every + * Evaluates to TRUE for a collection in which every item matches $itemMatcher + */ + function everyItem(\Hamcrest\Matcher $itemMatcher) + { + return \Hamcrest\Core\Every::everyItem($itemMatcher); + } +} + +if (!function_exists('hasToString')) { /** + * Does array size satisfy a given matcher? + */ + function hasToString($matcher) + { + return \Hamcrest\Core\HasToString::hasToString($matcher); + } +} + +if (!function_exists('is')) { /** + * Decorates another Matcher, retaining the behavior but allowing tests + * to be slightly more expressive. + * + * For example: assertThat($cheese, equalTo($smelly)) + * vs. assertThat($cheese, is(equalTo($smelly))) + */ + function is($value) + { + return \Hamcrest\Core\Is::is($value); + } +} + +if (!function_exists('anything')) { /** + * This matcher always evaluates to true. + * + * @param string $description A meaningful string used when describing itself. + * + * @return \Hamcrest\Core\IsAnything + */ + function anything($description = 'ANYTHING') + { + return \Hamcrest\Core\IsAnything::anything($description); + } +} + +if (!function_exists('hasItem')) { /** + * Test if the value is an array containing this matcher. + * + * Example: + *
+     * assertThat(array('a', 'b'), hasItem(equalTo('b')));
+     * //Convenience defaults to equalTo()
+     * assertThat(array('a', 'b'), hasItem('b'));
+     * 
+ */ + function hasItem(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\IsCollectionContaining', 'hasItem'), $args); + } +} + +if (!function_exists('hasItems')) { /** + * Test if the value is an array containing elements that match all of these + * matchers. + * + * Example: + *
+     * assertThat(array('a', 'b', 'c'), hasItems(equalTo('a'), equalTo('b')));
+     * 
+ */ + function hasItems(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\IsCollectionContaining', 'hasItems'), $args); + } +} + +if (!function_exists('equalTo')) { /** + * Is the value equal to another value, as tested by the use of the "==" + * comparison operator? + */ + function equalTo($item) + { + return \Hamcrest\Core\IsEqual::equalTo($item); + } +} + +if (!function_exists('identicalTo')) { /** + * Tests of the value is identical to $value as tested by the "===" operator. + */ + function identicalTo($value) + { + return \Hamcrest\Core\IsIdentical::identicalTo($value); + } +} + +if (!function_exists('anInstanceOf')) { /** + * Is the value an instance of a particular type? + * This version assumes no relationship between the required type and + * the signature of the method that sets it up, for example in + * assertThat($anObject, anInstanceOf('Thing')); + */ + function anInstanceOf($theClass) + { + return \Hamcrest\Core\IsInstanceOf::anInstanceOf($theClass); + } +} + +if (!function_exists('any')) { /** + * Is the value an instance of a particular type? + * This version assumes no relationship between the required type and + * the signature of the method that sets it up, for example in + * assertThat($anObject, anInstanceOf('Thing')); + */ + function any($theClass) + { + return \Hamcrest\Core\IsInstanceOf::anInstanceOf($theClass); + } +} + +if (!function_exists('not')) { /** + * Matches if value does not match $value. + */ + function not($value) + { + return \Hamcrest\Core\IsNot::not($value); + } +} + +if (!function_exists('nullValue')) { /** + * Matches if value is null. + */ + function nullValue() + { + return \Hamcrest\Core\IsNull::nullValue(); + } +} + +if (!function_exists('notNullValue')) { /** + * Matches if value is not null. + */ + function notNullValue() + { + return \Hamcrest\Core\IsNull::notNullValue(); + } +} + +if (!function_exists('sameInstance')) { /** + * Creates a new instance of IsSame. + * + * @param mixed $object + * The predicate evaluates to true only when the argument is + * this object. + * + * @return \Hamcrest\Core\IsSame + */ + function sameInstance($object) + { + return \Hamcrest\Core\IsSame::sameInstance($object); + } +} + +if (!function_exists('typeOf')) { /** + * Is the value a particular built-in type? + */ + function typeOf($theType) + { + return \Hamcrest\Core\IsTypeOf::typeOf($theType); + } +} + +if (!function_exists('set')) { /** + * Matches if value (class, object, or array) has named $property. + */ + function set($property) + { + return \Hamcrest\Core\Set::set($property); + } +} + +if (!function_exists('notSet')) { /** + * Matches if value (class, object, or array) does not have named $property. + */ + function notSet($property) + { + return \Hamcrest\Core\Set::notSet($property); + } +} + +if (!function_exists('closeTo')) { /** + * Matches if value is a number equal to $value within some range of + * acceptable error $delta. + */ + function closeTo($value, $delta) + { + return \Hamcrest\Number\IsCloseTo::closeTo($value, $delta); + } +} + +if (!function_exists('comparesEqualTo')) { /** + * The value is not > $value, nor < $value. + */ + function comparesEqualTo($value) + { + return \Hamcrest\Number\OrderingComparison::comparesEqualTo($value); + } +} + +if (!function_exists('greaterThan')) { /** + * The value is > $value. + */ + function greaterThan($value) + { + return \Hamcrest\Number\OrderingComparison::greaterThan($value); + } +} + +if (!function_exists('greaterThanOrEqualTo')) { /** + * The value is >= $value. + */ + function greaterThanOrEqualTo($value) + { + return \Hamcrest\Number\OrderingComparison::greaterThanOrEqualTo($value); + } +} + +if (!function_exists('atLeast')) { /** + * The value is >= $value. + */ + function atLeast($value) + { + return \Hamcrest\Number\OrderingComparison::greaterThanOrEqualTo($value); + } +} + +if (!function_exists('lessThan')) { /** + * The value is < $value. + */ + function lessThan($value) + { + return \Hamcrest\Number\OrderingComparison::lessThan($value); + } +} + +if (!function_exists('lessThanOrEqualTo')) { /** + * The value is <= $value. + */ + function lessThanOrEqualTo($value) + { + return \Hamcrest\Number\OrderingComparison::lessThanOrEqualTo($value); + } +} + +if (!function_exists('atMost')) { /** + * The value is <= $value. + */ + function atMost($value) + { + return \Hamcrest\Number\OrderingComparison::lessThanOrEqualTo($value); + } +} + +if (!function_exists('isEmptyString')) { /** + * Matches if value is a zero-length string. + */ + function isEmptyString() + { + return \Hamcrest\Text\IsEmptyString::isEmptyString(); + } +} + +if (!function_exists('emptyString')) { /** + * Matches if value is a zero-length string. + */ + function emptyString() + { + return \Hamcrest\Text\IsEmptyString::isEmptyString(); + } +} + +if (!function_exists('isEmptyOrNullString')) { /** + * Matches if value is null or a zero-length string. + */ + function isEmptyOrNullString() + { + return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString(); + } +} + +if (!function_exists('nullOrEmptyString')) { /** + * Matches if value is null or a zero-length string. + */ + function nullOrEmptyString() + { + return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString(); + } +} + +if (!function_exists('isNonEmptyString')) { /** + * Matches if value is a non-zero-length string. + */ + function isNonEmptyString() + { + return \Hamcrest\Text\IsEmptyString::isNonEmptyString(); + } +} + +if (!function_exists('nonEmptyString')) { /** + * Matches if value is a non-zero-length string. + */ + function nonEmptyString() + { + return \Hamcrest\Text\IsEmptyString::isNonEmptyString(); + } +} + +if (!function_exists('equalToIgnoringCase')) { /** + * Matches if value is a string equal to $string, regardless of the case. + */ + function equalToIgnoringCase($string) + { + return \Hamcrest\Text\IsEqualIgnoringCase::equalToIgnoringCase($string); + } +} + +if (!function_exists('equalToIgnoringWhiteSpace')) { /** + * Matches if value is a string equal to $string, regardless of whitespace. + */ + function equalToIgnoringWhiteSpace($string) + { + return \Hamcrest\Text\IsEqualIgnoringWhiteSpace::equalToIgnoringWhiteSpace($string); + } +} + +if (!function_exists('matchesPattern')) { /** + * Matches if value is a string that matches regular expression $pattern. + */ + function matchesPattern($pattern) + { + return \Hamcrest\Text\MatchesPattern::matchesPattern($pattern); + } +} + +if (!function_exists('containsString')) { /** + * Matches if value is a string that contains $substring. + */ + function containsString($substring) + { + return \Hamcrest\Text\StringContains::containsString($substring); + } +} + +if (!function_exists('containsStringIgnoringCase')) { /** + * Matches if value is a string that contains $substring regardless of the case. + */ + function containsStringIgnoringCase($substring) + { + return \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase($substring); + } +} + +if (!function_exists('stringContainsInOrder')) { /** + * Matches if value contains $substrings in a constrained order. + */ + function stringContainsInOrder(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Text\StringContainsInOrder', 'stringContainsInOrder'), $args); + } +} + +if (!function_exists('endsWith')) { /** + * Matches if value is a string that ends with $substring. + */ + function endsWith($substring) + { + return \Hamcrest\Text\StringEndsWith::endsWith($substring); + } +} + +if (!function_exists('startsWith')) { /** + * Matches if value is a string that starts with $substring. + */ + function startsWith($substring) + { + return \Hamcrest\Text\StringStartsWith::startsWith($substring); + } +} + +if (!function_exists('arrayValue')) { /** + * Is the value an array? + */ + function arrayValue() + { + return \Hamcrest\Type\IsArray::arrayValue(); + } +} + +if (!function_exists('booleanValue')) { /** + * Is the value a boolean? + */ + function booleanValue() + { + return \Hamcrest\Type\IsBoolean::booleanValue(); + } +} + +if (!function_exists('boolValue')) { /** + * Is the value a boolean? + */ + function boolValue() + { + return \Hamcrest\Type\IsBoolean::booleanValue(); + } +} + +if (!function_exists('callableValue')) { /** + * Is the value callable? + */ + function callableValue() + { + return \Hamcrest\Type\IsCallable::callableValue(); + } +} + +if (!function_exists('doubleValue')) { /** + * Is the value a float/double? + */ + function doubleValue() + { + return \Hamcrest\Type\IsDouble::doubleValue(); + } +} + +if (!function_exists('floatValue')) { /** + * Is the value a float/double? + */ + function floatValue() + { + return \Hamcrest\Type\IsDouble::doubleValue(); + } +} + +if (!function_exists('integerValue')) { /** + * Is the value an integer? + */ + function integerValue() + { + return \Hamcrest\Type\IsInteger::integerValue(); + } +} + +if (!function_exists('intValue')) { /** + * Is the value an integer? + */ + function intValue() + { + return \Hamcrest\Type\IsInteger::integerValue(); + } +} + +if (!function_exists('numericValue')) { /** + * Is the value a numeric? + */ + function numericValue() + { + return \Hamcrest\Type\IsNumeric::numericValue(); + } +} + +if (!function_exists('objectValue')) { /** + * Is the value an object? + */ + function objectValue() + { + return \Hamcrest\Type\IsObject::objectValue(); + } +} + +if (!function_exists('anObject')) { /** + * Is the value an object? + */ + function anObject() + { + return \Hamcrest\Type\IsObject::objectValue(); + } +} + +if (!function_exists('resourceValue')) { /** + * Is the value a resource? + */ + function resourceValue() + { + return \Hamcrest\Type\IsResource::resourceValue(); + } +} + +if (!function_exists('scalarValue')) { /** + * Is the value a scalar (boolean, integer, double, or string)? + */ + function scalarValue() + { + return \Hamcrest\Type\IsScalar::scalarValue(); + } +} + +if (!function_exists('stringValue')) { /** + * Is the value a string? + */ + function stringValue() + { + return \Hamcrest\Type\IsString::stringValue(); + } +} + +if (!function_exists('hasXPath')) { /** + * Wraps $matcher with {@link Hamcrest\Core\IsEqual) + * if it's not a matcher and the XPath in count() + * if it's an integer. + */ + function hasXPath($xpath, $matcher = null) + { + return \Hamcrest\Xml\HasXPath::hasXPath($xpath, $matcher); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArray.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArray.php new file mode 100644 index 000000000..9ea569703 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArray.php @@ -0,0 +1,118 @@ +_elementMatchers = $elementMatchers; + } + + protected function matchesSafely($array) + { + if (array_keys($array) != array_keys($this->_elementMatchers)) { + return false; + } + + /** @var $matcher \Hamcrest\Matcher */ + foreach ($this->_elementMatchers as $k => $matcher) { + if (!$matcher->matches($array[$k])) { + return false; + } + } + + return true; + } + + protected function describeMismatchSafely($actual, Description $mismatchDescription) + { + if (count($actual) != count($this->_elementMatchers)) { + $mismatchDescription->appendText('array length was ' . count($actual)); + + return; + } elseif (array_keys($actual) != array_keys($this->_elementMatchers)) { + $mismatchDescription->appendText('array keys were ') + ->appendValueList( + $this->descriptionStart(), + $this->descriptionSeparator(), + $this->descriptionEnd(), + array_keys($actual) + ) + ; + + return; + } + + /** @var $matcher \Hamcrest\Matcher */ + foreach ($this->_elementMatchers as $k => $matcher) { + if (!$matcher->matches($actual[$k])) { + $mismatchDescription->appendText('element ')->appendValue($k) + ->appendText(' was ')->appendValue($actual[$k]); + + return; + } + } + } + + public function describeTo(Description $description) + { + $description->appendList( + $this->descriptionStart(), + $this->descriptionSeparator(), + $this->descriptionEnd(), + $this->_elementMatchers + ); + } + + /** + * Evaluates to true only if each $matcher[$i] is satisfied by $array[$i]. + * + * @factory ... + */ + public static function anArray(/* args... */) + { + $args = func_get_args(); + + return new self(Util::createMatcherArray($args)); + } + + // -- Protected Methods + + protected function descriptionStart() + { + return '['; + } + + protected function descriptionSeparator() + { + return ', '; + } + + protected function descriptionEnd() + { + return ']'; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContaining.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContaining.php new file mode 100644 index 000000000..0e4a1eda9 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContaining.php @@ -0,0 +1,63 @@ +_elementMatcher = $elementMatcher; + } + + protected function matchesSafely($array) + { + foreach ($array as $element) { + if ($this->_elementMatcher->matches($element)) { + return true; + } + } + + return false; + } + + protected function describeMismatchSafely($array, Description $mismatchDescription) + { + $mismatchDescription->appendText('was ')->appendValue($array); + } + + public function describeTo(Description $description) + { + $description + ->appendText('an array containing ') + ->appendDescriptionOf($this->_elementMatcher) + ; + } + + /** + * Evaluates to true if any item in an array satisfies the given matcher. + * + * @param mixed $item as a {@link Hamcrest\Matcher} or a value. + * + * @return \Hamcrest\Arrays\IsArrayContaining + * @factory hasValue + */ + public static function hasItemInArray($item) + { + return new self(Util::wrapValueWithIsEqual($item)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php new file mode 100644 index 000000000..9009026b8 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInAnyOrder.php @@ -0,0 +1,59 @@ +_elementMatchers = $elementMatchers; + } + + protected function matchesSafelyWithDiagnosticDescription($array, Description $mismatchDescription) + { + $matching = new MatchingOnce($this->_elementMatchers, $mismatchDescription); + + foreach ($array as $element) { + if (!$matching->matches($element)) { + return false; + } + } + + return $matching->isFinished($array); + } + + public function describeTo(Description $description) + { + $description->appendList('[', ', ', ']', $this->_elementMatchers) + ->appendText(' in any order') + ; + } + + /** + * An array with elements that match the given matchers. + * + * @factory containsInAnyOrder ... + */ + public static function arrayContainingInAnyOrder(/* args... */) + { + $args = func_get_args(); + + return new self(Util::createMatcherArray($args)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInOrder.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInOrder.php new file mode 100644 index 000000000..611574045 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingInOrder.php @@ -0,0 +1,57 @@ +_elementMatchers = $elementMatchers; + } + + protected function matchesSafelyWithDiagnosticDescription($array, Description $mismatchDescription) + { + $series = new SeriesMatchingOnce($this->_elementMatchers, $mismatchDescription); + + foreach ($array as $element) { + if (!$series->matches($element)) { + return false; + } + } + + return $series->isFinished(); + } + + public function describeTo(Description $description) + { + $description->appendList('[', ', ', ']', $this->_elementMatchers); + } + + /** + * An array with elements that match the given matchers in the same order. + * + * @factory contains ... + */ + public static function arrayContaining(/* args... */) + { + $args = func_get_args(); + + return new self(Util::createMatcherArray($args)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php new file mode 100644 index 000000000..523477e7b --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKey.php @@ -0,0 +1,75 @@ +_keyMatcher = $keyMatcher; + } + + protected function matchesSafely($array) + { + foreach ($array as $key => $element) { + if ($this->_keyMatcher->matches($key)) { + return true; + } + } + + return false; + } + + protected function describeMismatchSafely($array, Description $mismatchDescription) + { + //Not using appendValueList() so that keys can be shown + $mismatchDescription->appendText('array was ') + ->appendText('[') + ; + $loop = false; + foreach ($array as $key => $value) { + if ($loop) { + $mismatchDescription->appendText(', '); + } + $mismatchDescription->appendValue($key)->appendText(' => ')->appendValue($value); + $loop = true; + } + $mismatchDescription->appendText(']'); + } + + public function describeTo(Description $description) + { + $description + ->appendText('array with key ') + ->appendDescriptionOf($this->_keyMatcher) + ; + } + + /** + * Evaluates to true if any key in an array matches the given matcher. + * + * @param mixed $key as a {@link Hamcrest\Matcher} or a value. + * + * @return \Hamcrest\Arrays\IsArrayContainingKey + * @factory hasKey + */ + public static function hasKeyInArray($key) + { + return new self(Util::wrapValueWithIsEqual($key)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php new file mode 100644 index 000000000..9ac3eba80 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayContainingKeyValuePair.php @@ -0,0 +1,80 @@ +_keyMatcher = $keyMatcher; + $this->_valueMatcher = $valueMatcher; + } + + protected function matchesSafely($array) + { + foreach ($array as $key => $value) { + if ($this->_keyMatcher->matches($key) && $this->_valueMatcher->matches($value)) { + return true; + } + } + + return false; + } + + protected function describeMismatchSafely($array, Description $mismatchDescription) + { + //Not using appendValueList() so that keys can be shown + $mismatchDescription->appendText('array was ') + ->appendText('[') + ; + $loop = false; + foreach ($array as $key => $value) { + if ($loop) { + $mismatchDescription->appendText(', '); + } + $mismatchDescription->appendValue($key)->appendText(' => ')->appendValue($value); + $loop = true; + } + $mismatchDescription->appendText(']'); + } + + public function describeTo(Description $description) + { + $description->appendText('array containing [') + ->appendDescriptionOf($this->_keyMatcher) + ->appendText(' => ') + ->appendDescriptionOf($this->_valueMatcher) + ->appendText(']') + ; + } + + /** + * Test if an array has both an key and value in parity with each other. + * + * @factory hasEntry + */ + public static function hasKeyValuePair($key, $value) + { + return new self( + Util::wrapValueWithIsEqual($key), + Util::wrapValueWithIsEqual($value) + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayWithSize.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayWithSize.php new file mode 100644 index 000000000..074375ce1 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/IsArrayWithSize.php @@ -0,0 +1,73 @@ +_elementMatchers = $elementMatchers; + $this->_mismatchDescription = $mismatchDescription; + } + + public function matches($item) + { + return $this->_isNotSurplus($item) && $this->_isMatched($item); + } + + public function isFinished($items) + { + if (empty($this->_elementMatchers)) { + return true; + } + + $this->_mismatchDescription + ->appendText('No item matches: ')->appendList('', ', ', '', $this->_elementMatchers) + ->appendText(' in ')->appendValueList('[', ', ', ']', $items) + ; + + return false; + } + + // -- Private Methods + + private function _isNotSurplus($item) + { + if (empty($this->_elementMatchers)) { + $this->_mismatchDescription->appendText('Not matched: ')->appendValue($item); + + return false; + } + + return true; + } + + private function _isMatched($item) + { + /** @var $matcher \Hamcrest\Matcher */ + foreach ($this->_elementMatchers as $i => $matcher) { + if ($matcher->matches($item)) { + unset($this->_elementMatchers[$i]); + + return true; + } + } + + $this->_mismatchDescription->appendText('Not matched: ')->appendValue($item); + + return false; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/SeriesMatchingOnce.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/SeriesMatchingOnce.php new file mode 100644 index 000000000..12a912d86 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Arrays/SeriesMatchingOnce.php @@ -0,0 +1,75 @@ +_elementMatchers = $elementMatchers; + $this->_keys = array_keys($elementMatchers); + $this->_mismatchDescription = $mismatchDescription; + } + + public function matches($item) + { + return $this->_isNotSurplus($item) && $this->_isMatched($item); + } + + public function isFinished() + { + if (!empty($this->_elementMatchers)) { + $nextMatcher = current($this->_elementMatchers); + $this->_mismatchDescription->appendText('No item matched: ')->appendDescriptionOf($nextMatcher); + + return false; + } + + return true; + } + + // -- Private Methods + + private function _isNotSurplus($item) + { + if (empty($this->_elementMatchers)) { + $this->_mismatchDescription->appendText('Not matched: ')->appendValue($item); + + return false; + } + + return true; + } + + private function _isMatched($item) + { + $this->_nextMatchKey = array_shift($this->_keys); + $nextMatcher = array_shift($this->_elementMatchers); + + if (!$nextMatcher->matches($item)) { + $this->_describeMismatch($nextMatcher, $item); + + return false; + } + + return true; + } + + private function _describeMismatch(Matcher $matcher, $item) + { + $this->_mismatchDescription->appendText('item with key ' . $this->_nextMatchKey . ': '); + $matcher->describeMismatch($item, $this->_mismatchDescription); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/AssertionError.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/AssertionError.php new file mode 100644 index 000000000..3a2a0e7c2 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/AssertionError.php @@ -0,0 +1,10 @@ +append($text); + + return $this; + } + + public function appendDescriptionOf(SelfDescribing $value) + { + $value->describeTo($this); + + return $this; + } + + public function appendValue($value) + { + if (is_null($value)) { + $this->append('null'); + } elseif (is_string($value)) { + $this->_toPhpSyntax($value); + } elseif (is_float($value)) { + $this->append('<'); + $this->append($value); + $this->append('F>'); + } elseif (is_bool($value)) { + $this->append('<'); + $this->append($value ? 'true' : 'false'); + $this->append('>'); + } elseif (is_array($value) || $value instanceof \Iterator || $value instanceof \IteratorAggregate) { + $this->appendValueList('[', ', ', ']', $value); + } elseif (is_object($value) && !method_exists($value, '__toString')) { + $this->append('<'); + $this->append(get_class($value)); + $this->append('>'); + } else { + $this->append('<'); + $this->append($value); + $this->append('>'); + } + + return $this; + } + + public function appendValueList($start, $separator, $end, $values) + { + $list = array(); + foreach ($values as $v) { + $list[] = new SelfDescribingValue($v); + } + + $this->appendList($start, $separator, $end, $list); + + return $this; + } + + public function appendList($start, $separator, $end, $values) + { + $this->append($start); + + $separate = false; + + foreach ($values as $value) { + /*if (!($value instanceof Hamcrest\SelfDescribing)) { + $value = new Hamcrest\Internal\SelfDescribingValue($value); + }*/ + + if ($separate) { + $this->append($separator); + } + + $this->appendDescriptionOf($value); + + $separate = true; + } + + $this->append($end); + + return $this; + } + + // -- Protected Methods + + /** + * Append the String $str to the description. + */ + abstract protected function append($str); + + // -- Private Methods + + private function _toPhpSyntax($value) + { + $str = '"'; + for ($i = 0, $len = strlen($value); $i < $len; ++$i) { + switch ($value[$i]) { + case '"': + $str .= '\\"'; + break; + + case "\t": + $str .= '\\t'; + break; + + case "\r": + $str .= '\\r'; + break; + + case "\n": + $str .= '\\n'; + break; + + default: + $str .= $value[$i]; + } + } + $str .= '"'; + $this->append($str); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/BaseMatcher.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/BaseMatcher.php new file mode 100644 index 000000000..286db3e17 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/BaseMatcher.php @@ -0,0 +1,25 @@ +appendText('was ')->appendValue($item); + } + + public function __toString() + { + return StringDescription::toString($this); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php new file mode 100644 index 000000000..8ab58ea5a --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsEmptyTraversable.php @@ -0,0 +1,71 @@ +_empty = $empty; + } + + public function matches($item) + { + if (!$item instanceof \Traversable) { + return false; + } + + foreach ($item as $value) { + return !$this->_empty; + } + + return $this->_empty; + } + + public function describeTo(Description $description) + { + $description->appendText($this->_empty ? 'an empty traversable' : 'a non-empty traversable'); + } + + /** + * Returns true if traversable is empty. + * + * @factory + */ + public static function emptyTraversable() + { + if (!self::$_INSTANCE) { + self::$_INSTANCE = new self; + } + + return self::$_INSTANCE; + } + + /** + * Returns true if traversable is not empty. + * + * @factory + */ + public static function nonEmptyTraversable() + { + if (!self::$_NOT_INSTANCE) { + self::$_NOT_INSTANCE = new self(false); + } + + return self::$_NOT_INSTANCE; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsTraversableWithSize.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsTraversableWithSize.php new file mode 100644 index 000000000..c95edc5c3 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Collection/IsTraversableWithSize.php @@ -0,0 +1,47 @@ +false. + */ +class AllOf extends DiagnosingMatcher +{ + + private $_matchers; + + public function __construct(array $matchers) + { + Util::checkAllAreMatchers($matchers); + + $this->_matchers = $matchers; + } + + public function matchesWithDiagnosticDescription($item, Description $mismatchDescription) + { + /** @var $matcher \Hamcrest\Matcher */ + foreach ($this->_matchers as $matcher) { + if (!$matcher->matches($item)) { + $mismatchDescription->appendDescriptionOf($matcher)->appendText(' '); + $matcher->describeMismatch($item, $mismatchDescription); + + return false; + } + } + + return true; + } + + public function describeTo(Description $description) + { + $description->appendList('(', ' and ', ')', $this->_matchers); + } + + /** + * Evaluates to true only if ALL of the passed in matchers evaluate to true. + * + * @factory ... + */ + public static function allOf(/* args... */) + { + $args = func_get_args(); + + return new self(Util::createMatcherArray($args)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/AnyOf.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/AnyOf.php new file mode 100644 index 000000000..4504279f3 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/AnyOf.php @@ -0,0 +1,58 @@ +true. + */ +class AnyOf extends ShortcutCombination +{ + + public function __construct(array $matchers) + { + parent::__construct($matchers); + } + + public function matches($item) + { + return $this->matchesWithShortcut($item, true); + } + + public function describeTo(Description $description) + { + $this->describeToWithOperator($description, 'or'); + } + + /** + * Evaluates to true if ANY of the passed in matchers evaluate to true. + * + * @factory ... + */ + public static function anyOf(/* args... */) + { + $args = func_get_args(); + + return new self(Util::createMatcherArray($args)); + } + + /** + * Evaluates to false if ANY of the passed in matchers evaluate to true. + * + * @factory ... + */ + public static function noneOf(/* args... */) + { + $args = func_get_args(); + + return IsNot::not( + new self(Util::createMatcherArray($args)) + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/CombinableMatcher.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/CombinableMatcher.php new file mode 100644 index 000000000..e3b4aa782 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/CombinableMatcher.php @@ -0,0 +1,78 @@ +_matcher = $matcher; + } + + public function matches($item) + { + return $this->_matcher->matches($item); + } + + public function describeTo(Description $description) + { + $description->appendDescriptionOf($this->_matcher); + } + + /** Diversion from Hamcrest-Java... Logical "and" not permitted */ + public function andAlso(Matcher $other) + { + return new self(new AllOf($this->_templatedListWith($other))); + } + + /** Diversion from Hamcrest-Java... Logical "or" not permitted */ + public function orElse(Matcher $other) + { + return new self(new AnyOf($this->_templatedListWith($other))); + } + + /** + * This is useful for fluently combining matchers that must both pass. + * For example: + *
+     *   assertThat($string, both(containsString("a"))->andAlso(containsString("b")));
+     * 
+ * + * @factory + */ + public static function both(Matcher $matcher) + { + return new self($matcher); + } + + /** + * This is useful for fluently combining matchers where either may pass, + * for example: + *
+     *   assertThat($string, either(containsString("a"))->orElse(containsString("b")));
+     * 
+ * + * @factory + */ + public static function either(Matcher $matcher) + { + return new self($matcher); + } + + // -- Private Methods + + private function _templatedListWith(Matcher $other) + { + return array($this->_matcher, $other); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/DescribedAs.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/DescribedAs.php new file mode 100644 index 000000000..5b2583fa7 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/DescribedAs.php @@ -0,0 +1,68 @@ +_descriptionTemplate = $descriptionTemplate; + $this->_matcher = $matcher; + $this->_values = $values; + } + + public function matches($item) + { + return $this->_matcher->matches($item); + } + + public function describeTo(Description $description) + { + $textStart = 0; + while (preg_match(self::ARG_PATTERN, $this->_descriptionTemplate, $matches, PREG_OFFSET_CAPTURE, $textStart)) { + $text = $matches[0][0]; + $index = $matches[1][0]; + $offset = $matches[0][1]; + + $description->appendText(substr($this->_descriptionTemplate, $textStart, $offset - $textStart)); + $description->appendValue($this->_values[$index]); + + $textStart = $offset + strlen($text); + } + + if ($textStart < strlen($this->_descriptionTemplate)) { + $description->appendText(substr($this->_descriptionTemplate, $textStart)); + } + } + + /** + * Wraps an existing matcher and overrides the description when it fails. + * + * @factory ... + */ + public static function describedAs(/* $description, Hamcrest\Matcher $matcher, $values... */) + { + $args = func_get_args(); + $description = array_shift($args); + $matcher = array_shift($args); + $values = $args; + + return new self($description, $matcher, $values); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Every.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Every.php new file mode 100644 index 000000000..d686f8dac --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Every.php @@ -0,0 +1,56 @@ +_matcher = $matcher; + } + + protected function matchesSafelyWithDiagnosticDescription($items, Description $mismatchDescription) + { + foreach ($items as $item) { + if (!$this->_matcher->matches($item)) { + $mismatchDescription->appendText('an item '); + $this->_matcher->describeMismatch($item, $mismatchDescription); + + return false; + } + } + + return true; + } + + public function describeTo(Description $description) + { + $description->appendText('every item is ')->appendDescriptionOf($this->_matcher); + } + + /** + * @param Matcher $itemMatcher + * A matcher to apply to every element in an array. + * + * @return \Hamcrest\Core\Every + * Evaluates to TRUE for a collection in which every item matches $itemMatcher + * + * @factory + */ + public static function everyItem(Matcher $itemMatcher) + { + return new self($itemMatcher); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/HasToString.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/HasToString.php new file mode 100644 index 000000000..45bd9102e --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/HasToString.php @@ -0,0 +1,56 @@ +toString(); + } + + return (string) $actual; + } + + /** + * Does array size satisfy a given matcher? + * + * @factory + */ + public static function hasToString($matcher) + { + return new self(Util::wrapValueWithIsEqual($matcher)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Is.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Is.php new file mode 100644 index 000000000..41266dc1f --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Is.php @@ -0,0 +1,57 @@ +_matcher = $matcher; + } + + public function matches($arg) + { + return $this->_matcher->matches($arg); + } + + public function describeTo(Description $description) + { + $description->appendText('is ')->appendDescriptionOf($this->_matcher); + } + + public function describeMismatch($item, Description $mismatchDescription) + { + $this->_matcher->describeMismatch($item, $mismatchDescription); + } + + /** + * Decorates another Matcher, retaining the behavior but allowing tests + * to be slightly more expressive. + * + * For example: assertThat($cheese, equalTo($smelly)) + * vs. assertThat($cheese, is(equalTo($smelly))) + * + * @factory + */ + public static function is($value) + { + return new self(Util::wrapValueWithIsEqual($value)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsAnything.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsAnything.php new file mode 100644 index 000000000..f20e6c0dc --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsAnything.php @@ -0,0 +1,45 @@ +true. + */ +class IsAnything extends BaseMatcher +{ + + private $_message; + + public function __construct($message = 'ANYTHING') + { + $this->_message = $message; + } + + public function matches($item) + { + return true; + } + + public function describeTo(Description $description) + { + $description->appendText($this->_message); + } + + /** + * This matcher always evaluates to true. + * + * @param string $description A meaningful string used when describing itself. + * + * @return \Hamcrest\Core\IsAnything + * @factory + */ + public static function anything($description = 'ANYTHING') + { + return new self($description); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsCollectionContaining.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsCollectionContaining.php new file mode 100644 index 000000000..5e60426d1 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsCollectionContaining.php @@ -0,0 +1,93 @@ +_elementMatcher = $elementMatcher; + } + + protected function matchesSafely($items) + { + foreach ($items as $item) { + if ($this->_elementMatcher->matches($item)) { + return true; + } + } + + return false; + } + + protected function describeMismatchSafely($items, Description $mismatchDescription) + { + $mismatchDescription->appendText('was ')->appendValue($items); + } + + public function describeTo(Description $description) + { + $description + ->appendText('a collection containing ') + ->appendDescriptionOf($this->_elementMatcher) + ; + } + + /** + * Test if the value is an array containing this matcher. + * + * Example: + *
+     * assertThat(array('a', 'b'), hasItem(equalTo('b')));
+     * //Convenience defaults to equalTo()
+     * assertThat(array('a', 'b'), hasItem('b'));
+     * 
+ * + * @factory ... + */ + public static function hasItem() + { + $args = func_get_args(); + $firstArg = array_shift($args); + + return new self(Util::wrapValueWithIsEqual($firstArg)); + } + + /** + * Test if the value is an array containing elements that match all of these + * matchers. + * + * Example: + *
+     * assertThat(array('a', 'b', 'c'), hasItems(equalTo('a'), equalTo('b')));
+     * 
+ * + * @factory ... + */ + public static function hasItems(/* args... */) + { + $args = func_get_args(); + $matchers = array(); + + foreach ($args as $arg) { + $matchers[] = self::hasItem($arg); + } + + return AllOf::allOf($matchers); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsEqual.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsEqual.php new file mode 100644 index 000000000..523fba0b1 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsEqual.php @@ -0,0 +1,44 @@ +_item = $item; + } + + public function matches($arg) + { + return (($arg == $this->_item) && ($this->_item == $arg)); + } + + public function describeTo(Description $description) + { + $description->appendValue($this->_item); + } + + /** + * Is the value equal to another value, as tested by the use of the "==" + * comparison operator? + * + * @factory + */ + public static function equalTo($item) + { + return new self($item); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsIdentical.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsIdentical.php new file mode 100644 index 000000000..28f7b36ea --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsIdentical.php @@ -0,0 +1,38 @@ +_value = $value; + } + + public function describeTo(Description $description) + { + $description->appendValue($this->_value); + } + + /** + * Tests of the value is identical to $value as tested by the "===" operator. + * + * @factory + */ + public static function identicalTo($value) + { + return new self($value); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsInstanceOf.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsInstanceOf.php new file mode 100644 index 000000000..7a5c92a6b --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsInstanceOf.php @@ -0,0 +1,67 @@ +_theClass = $theClass; + } + + protected function matchesWithDiagnosticDescription($item, Description $mismatchDescription) + { + if (!is_object($item)) { + $mismatchDescription->appendText('was ')->appendValue($item); + + return false; + } + + if (!($item instanceof $this->_theClass)) { + $mismatchDescription->appendText('[' . get_class($item) . '] ') + ->appendValue($item); + + return false; + } + + return true; + } + + public function describeTo(Description $description) + { + $description->appendText('an instance of ') + ->appendText($this->_theClass) + ; + } + + /** + * Is the value an instance of a particular type? + * This version assumes no relationship between the required type and + * the signature of the method that sets it up, for example in + * assertThat($anObject, anInstanceOf('Thing')); + * + * @factory any + */ + public static function anInstanceOf($theClass) + { + return new self($theClass); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNot.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNot.php new file mode 100644 index 000000000..167f0d063 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNot.php @@ -0,0 +1,44 @@ +_matcher = $matcher; + } + + public function matches($arg) + { + return !$this->_matcher->matches($arg); + } + + public function describeTo(Description $description) + { + $description->appendText('not ')->appendDescriptionOf($this->_matcher); + } + + /** + * Matches if value does not match $value. + * + * @factory + */ + public static function not($value) + { + return new self(Util::wrapValueWithIsEqual($value)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNull.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNull.php new file mode 100644 index 000000000..91a454c17 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsNull.php @@ -0,0 +1,56 @@ +appendText('null'); + } + + /** + * Matches if value is null. + * + * @factory + */ + public static function nullValue() + { + if (!self::$_INSTANCE) { + self::$_INSTANCE = new self(); + } + + return self::$_INSTANCE; + } + + /** + * Matches if value is not null. + * + * @factory + */ + public static function notNullValue() + { + if (!self::$_NOT_INSTANCE) { + self::$_NOT_INSTANCE = IsNot::not(self::nullValue()); + } + + return self::$_NOT_INSTANCE; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsSame.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsSame.php new file mode 100644 index 000000000..810787050 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsSame.php @@ -0,0 +1,51 @@ +_object = $object; + } + + public function matches($object) + { + return ($object === $this->_object) && ($this->_object === $object); + } + + public function describeTo(Description $description) + { + $description->appendText('sameInstance(') + ->appendValue($this->_object) + ->appendText(')') + ; + } + + /** + * Creates a new instance of IsSame. + * + * @param mixed $object + * The predicate evaluates to true only when the argument is + * this object. + * + * @return \Hamcrest\Core\IsSame + * @factory + */ + public static function sameInstance($object) + { + return new self($object); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsTypeOf.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsTypeOf.php new file mode 100644 index 000000000..d24f0f94c --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/IsTypeOf.php @@ -0,0 +1,71 @@ +_theType = strtolower($theType); + } + + public function matches($item) + { + return strtolower(gettype($item)) == $this->_theType; + } + + public function describeTo(Description $description) + { + $description->appendText(self::getTypeDescription($this->_theType)); + } + + public function describeMismatch($item, Description $description) + { + if ($item === null) { + $description->appendText('was null'); + } else { + $description->appendText('was ') + ->appendText(self::getTypeDescription(strtolower(gettype($item)))) + ->appendText(' ') + ->appendValue($item) + ; + } + } + + public static function getTypeDescription($type) + { + if ($type == 'null') { + return 'null'; + } + + return (strpos('aeiou', substr($type, 0, 1)) === false ? 'a ' : 'an ') + . $type; + } + + /** + * Is the value a particular built-in type? + * + * @factory + */ + public static function typeOf($theType) + { + return new self($theType); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Set.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Set.php new file mode 100644 index 000000000..cdc45d538 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/Set.php @@ -0,0 +1,95 @@ + + * assertThat(array('a', 'b'), set('b')); + * assertThat($foo, set('bar')); + * assertThat('Server', notSet('defaultPort')); + * + * + * @todo Replace $property with a matcher and iterate all property names. + */ +class Set extends BaseMatcher +{ + + private $_property; + private $_not; + + public function __construct($property, $not = false) + { + $this->_property = $property; + $this->_not = $not; + } + + public function matches($item) + { + if ($item === null) { + return false; + } + $property = $this->_property; + if (is_array($item)) { + $result = isset($item[$property]); + } elseif (is_object($item)) { + $result = isset($item->$property); + } elseif (is_string($item)) { + $result = isset($item::$$property); + } else { + throw new \InvalidArgumentException('Must pass an object, array, or class name'); + } + + return $this->_not ? !$result : $result; + } + + public function describeTo(Description $description) + { + $description->appendText($this->_not ? 'unset property ' : 'set property ')->appendText($this->_property); + } + + public function describeMismatch($item, Description $description) + { + $value = ''; + if (!$this->_not) { + $description->appendText('was not set'); + } else { + $property = $this->_property; + if (is_array($item)) { + $value = $item[$property]; + } elseif (is_object($item)) { + $value = $item->$property; + } elseif (is_string($item)) { + $value = $item::$$property; + } + parent::describeMismatch($value, $description); + } + } + + /** + * Matches if value (class, object, or array) has named $property. + * + * @factory + */ + public static function set($property) + { + return new self($property); + } + + /** + * Matches if value (class, object, or array) does not have named $property. + * + * @factory + */ + public static function notSet($property) + { + return new self($property, true); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/ShortcutCombination.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/ShortcutCombination.php new file mode 100644 index 000000000..d93db74ff --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Core/ShortcutCombination.php @@ -0,0 +1,43 @@ + + */ + private $_matchers; + + public function __construct(array $matchers) + { + Util::checkAllAreMatchers($matchers); + + $this->_matchers = $matchers; + } + + protected function matchesWithShortcut($item, $shortcut) + { + /** @var $matcher \Hamcrest\Matcher */ + foreach ($this->_matchers as $matcher) { + if ($matcher->matches($item) == $shortcut) { + return $shortcut; + } + } + + return !$shortcut; + } + + public function describeToWithOperator(Description $description, $operator) + { + $description->appendList('(', ' ' . $operator . ' ', ')', $this->_matchers); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Description.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Description.php new file mode 100644 index 000000000..9a482dbfc --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Description.php @@ -0,0 +1,70 @@ +matchesWithDiagnosticDescription($item, new NullDescription()); + } + + public function describeMismatch($item, Description $mismatchDescription) + { + $this->matchesWithDiagnosticDescription($item, $mismatchDescription); + } + + abstract protected function matchesWithDiagnosticDescription($item, Description $mismatchDescription); +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/FeatureMatcher.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/FeatureMatcher.php new file mode 100644 index 000000000..59f6cc734 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/FeatureMatcher.php @@ -0,0 +1,67 @@ +featureValueOf() in a subclass to pull out the feature to be + * matched against. + */ +abstract class FeatureMatcher extends TypeSafeDiagnosingMatcher +{ + + private $_subMatcher; + private $_featureDescription; + private $_featureName; + + /** + * Constructor. + * + * @param string $type + * @param string $subtype + * @param \Hamcrest\Matcher $subMatcher The matcher to apply to the feature + * @param string $featureDescription Descriptive text to use in describeTo + * @param string $featureName Identifying text for mismatch message + */ + public function __construct($type, $subtype, Matcher $subMatcher, $featureDescription, $featureName) + { + parent::__construct($type, $subtype); + + $this->_subMatcher = $subMatcher; + $this->_featureDescription = $featureDescription; + $this->_featureName = $featureName; + } + + /** + * Implement this to extract the interesting feature. + * + * @param mixed $actual the target object + * + * @return mixed the feature to be matched + */ + abstract protected function featureValueOf($actual); + + public function matchesSafelyWithDiagnosticDescription($actual, Description $mismatchDescription) + { + $featureValue = $this->featureValueOf($actual); + + if (!$this->_subMatcher->matches($featureValue)) { + $mismatchDescription->appendText($this->_featureName) + ->appendText(' was ')->appendValue($featureValue); + + return false; + } + + return true; + } + + final public function describeTo(Description $description) + { + $description->appendText($this->_featureDescription)->appendText(' ') + ->appendDescriptionOf($this->_subMatcher) + ; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Internal/SelfDescribingValue.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Internal/SelfDescribingValue.php new file mode 100644 index 000000000..995da71de --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Internal/SelfDescribingValue.php @@ -0,0 +1,27 @@ +_value = $value; + } + + public function describeTo(Description $description) + { + $description->appendValue($this->_value); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matcher.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matcher.php new file mode 100644 index 000000000..e5dcf0939 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matcher.php @@ -0,0 +1,50 @@ + + * Matcher implementations should NOT directly implement this interface. + * Instead, extend the {@link Hamcrest\BaseMatcher} abstract class, + * which will ensure that the Matcher API can grow to support + * new features and remain compatible with all Matcher implementations. + *

+ * For easy access to common Matcher implementations, use the static factory + * methods in {@link Hamcrest\CoreMatchers}. + * + * @see Hamcrest\CoreMatchers + * @see Hamcrest\BaseMatcher + */ +interface Matcher extends SelfDescribing +{ + + /** + * Evaluates the matcher for argument $item. + * + * @param mixed $item the object against which the matcher is evaluated. + * + * @return boolean true if $item matches, + * otherwise false. + * + * @see Hamcrest\BaseMatcher + */ + public function matches($item); + + /** + * Generate a description of why the matcher has not accepted the item. + * The description will be part of a larger description of why a matching + * failed, so it should be concise. + * This method assumes that matches($item) is false, but + * will not check this. + * + * @param mixed $item The item that the Matcher has rejected. + * @param Description $description + * @return + */ + public function describeMismatch($item, Description $description); +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/MatcherAssert.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/MatcherAssert.php new file mode 100644 index 000000000..d546dbee6 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/MatcherAssert.php @@ -0,0 +1,118 @@ + + * // With an identifier + * assertThat("apple flavour", $apple->flavour(), equalTo("tasty")); + * // Without an identifier + * assertThat($apple->flavour(), equalTo("tasty")); + * // Evaluating a boolean expression + * assertThat("some error", $a > $b); + * assertThat($a > $b); + * + */ + public static function assertThat(/* $args ... */) + { + $args = func_get_args(); + switch (count($args)) { + case 1: + self::$_count++; + if (!$args[0]) { + throw new AssertionError(); + } + break; + + case 2: + self::$_count++; + if ($args[1] instanceof Matcher) { + self::doAssert('', $args[0], $args[1]); + } elseif (!$args[1]) { + throw new AssertionError($args[0]); + } + break; + + case 3: + self::$_count++; + self::doAssert( + $args[0], + $args[1], + Util::wrapValueWithIsEqual($args[2]) + ); + break; + + default: + throw new \InvalidArgumentException('assertThat() requires one to three arguments'); + } + } + + /** + * Returns the number of assertions performed. + * + * @return int + */ + public static function getCount() + { + return self::$_count; + } + + /** + * Resets the number of assertions performed to zero. + */ + public static function resetCount() + { + self::$_count = 0; + } + + /** + * Performs the actual assertion logic. + * + * If $matcher doesn't match $actual, + * throws a {@link Hamcrest\AssertionError} with a description + * of the failure along with the optional $identifier. + * + * @param string $identifier added to the message upon failure + * @param mixed $actual value to compare against $matcher + * @param \Hamcrest\Matcher $matcher applied to $actual + * @throws AssertionError + */ + private static function doAssert($identifier, $actual, Matcher $matcher) + { + if (!$matcher->matches($actual)) { + $description = new StringDescription(); + if (!empty($identifier)) { + $description->appendText($identifier . PHP_EOL); + } + $description->appendText('Expected: ') + ->appendDescriptionOf($matcher) + ->appendText(PHP_EOL . ' but: '); + + $matcher->describeMismatch($actual, $description); + + throw new AssertionError((string) $description); + } + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matchers.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matchers.php new file mode 100644 index 000000000..23232e450 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Matchers.php @@ -0,0 +1,713 @@ + + * assertThat($string, both(containsString("a"))->andAlso(containsString("b"))); + * + */ + public static function both(\Hamcrest\Matcher $matcher) + { + return \Hamcrest\Core\CombinableMatcher::both($matcher); + } + + /** + * This is useful for fluently combining matchers where either may pass, + * for example: + *

+     *   assertThat($string, either(containsString("a"))->orElse(containsString("b")));
+     * 
+ */ + public static function either(\Hamcrest\Matcher $matcher) + { + return \Hamcrest\Core\CombinableMatcher::either($matcher); + } + + /** + * Wraps an existing matcher and overrides the description when it fails. + */ + public static function describedAs(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\DescribedAs', 'describedAs'), $args); + } + + /** + * @param Matcher $itemMatcher + * A matcher to apply to every element in an array. + * + * @return \Hamcrest\Core\Every + * Evaluates to TRUE for a collection in which every item matches $itemMatcher + */ + public static function everyItem(\Hamcrest\Matcher $itemMatcher) + { + return \Hamcrest\Core\Every::everyItem($itemMatcher); + } + + /** + * Does array size satisfy a given matcher? + */ + public static function hasToString($matcher) + { + return \Hamcrest\Core\HasToString::hasToString($matcher); + } + + /** + * Decorates another Matcher, retaining the behavior but allowing tests + * to be slightly more expressive. + * + * For example: assertThat($cheese, equalTo($smelly)) + * vs. assertThat($cheese, is(equalTo($smelly))) + */ + public static function is($value) + { + return \Hamcrest\Core\Is::is($value); + } + + /** + * This matcher always evaluates to true. + * + * @param string $description A meaningful string used when describing itself. + * + * @return \Hamcrest\Core\IsAnything + */ + public static function anything($description = 'ANYTHING') + { + return \Hamcrest\Core\IsAnything::anything($description); + } + + /** + * Test if the value is an array containing this matcher. + * + * Example: + *
+     * assertThat(array('a', 'b'), hasItem(equalTo('b')));
+     * //Convenience defaults to equalTo()
+     * assertThat(array('a', 'b'), hasItem('b'));
+     * 
+ */ + public static function hasItem(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\IsCollectionContaining', 'hasItem'), $args); + } + + /** + * Test if the value is an array containing elements that match all of these + * matchers. + * + * Example: + *
+     * assertThat(array('a', 'b', 'c'), hasItems(equalTo('a'), equalTo('b')));
+     * 
+ */ + public static function hasItems(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Core\IsCollectionContaining', 'hasItems'), $args); + } + + /** + * Is the value equal to another value, as tested by the use of the "==" + * comparison operator? + */ + public static function equalTo($item) + { + return \Hamcrest\Core\IsEqual::equalTo($item); + } + + /** + * Tests of the value is identical to $value as tested by the "===" operator. + */ + public static function identicalTo($value) + { + return \Hamcrest\Core\IsIdentical::identicalTo($value); + } + + /** + * Is the value an instance of a particular type? + * This version assumes no relationship between the required type and + * the signature of the method that sets it up, for example in + * assertThat($anObject, anInstanceOf('Thing')); + */ + public static function anInstanceOf($theClass) + { + return \Hamcrest\Core\IsInstanceOf::anInstanceOf($theClass); + } + + /** + * Is the value an instance of a particular type? + * This version assumes no relationship between the required type and + * the signature of the method that sets it up, for example in + * assertThat($anObject, anInstanceOf('Thing')); + */ + public static function any($theClass) + { + return \Hamcrest\Core\IsInstanceOf::anInstanceOf($theClass); + } + + /** + * Matches if value does not match $value. + */ + public static function not($value) + { + return \Hamcrest\Core\IsNot::not($value); + } + + /** + * Matches if value is null. + */ + public static function nullValue() + { + return \Hamcrest\Core\IsNull::nullValue(); + } + + /** + * Matches if value is not null. + */ + public static function notNullValue() + { + return \Hamcrest\Core\IsNull::notNullValue(); + } + + /** + * Creates a new instance of IsSame. + * + * @param mixed $object + * The predicate evaluates to true only when the argument is + * this object. + * + * @return \Hamcrest\Core\IsSame + */ + public static function sameInstance($object) + { + return \Hamcrest\Core\IsSame::sameInstance($object); + } + + /** + * Is the value a particular built-in type? + */ + public static function typeOf($theType) + { + return \Hamcrest\Core\IsTypeOf::typeOf($theType); + } + + /** + * Matches if value (class, object, or array) has named $property. + */ + public static function set($property) + { + return \Hamcrest\Core\Set::set($property); + } + + /** + * Matches if value (class, object, or array) does not have named $property. + */ + public static function notSet($property) + { + return \Hamcrest\Core\Set::notSet($property); + } + + /** + * Matches if value is a number equal to $value within some range of + * acceptable error $delta. + */ + public static function closeTo($value, $delta) + { + return \Hamcrest\Number\IsCloseTo::closeTo($value, $delta); + } + + /** + * The value is not > $value, nor < $value. + */ + public static function comparesEqualTo($value) + { + return \Hamcrest\Number\OrderingComparison::comparesEqualTo($value); + } + + /** + * The value is > $value. + */ + public static function greaterThan($value) + { + return \Hamcrest\Number\OrderingComparison::greaterThan($value); + } + + /** + * The value is >= $value. + */ + public static function greaterThanOrEqualTo($value) + { + return \Hamcrest\Number\OrderingComparison::greaterThanOrEqualTo($value); + } + + /** + * The value is >= $value. + */ + public static function atLeast($value) + { + return \Hamcrest\Number\OrderingComparison::greaterThanOrEqualTo($value); + } + + /** + * The value is < $value. + */ + public static function lessThan($value) + { + return \Hamcrest\Number\OrderingComparison::lessThan($value); + } + + /** + * The value is <= $value. + */ + public static function lessThanOrEqualTo($value) + { + return \Hamcrest\Number\OrderingComparison::lessThanOrEqualTo($value); + } + + /** + * The value is <= $value. + */ + public static function atMost($value) + { + return \Hamcrest\Number\OrderingComparison::lessThanOrEqualTo($value); + } + + /** + * Matches if value is a zero-length string. + */ + public static function isEmptyString() + { + return \Hamcrest\Text\IsEmptyString::isEmptyString(); + } + + /** + * Matches if value is a zero-length string. + */ + public static function emptyString() + { + return \Hamcrest\Text\IsEmptyString::isEmptyString(); + } + + /** + * Matches if value is null or a zero-length string. + */ + public static function isEmptyOrNullString() + { + return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString(); + } + + /** + * Matches if value is null or a zero-length string. + */ + public static function nullOrEmptyString() + { + return \Hamcrest\Text\IsEmptyString::isEmptyOrNullString(); + } + + /** + * Matches if value is a non-zero-length string. + */ + public static function isNonEmptyString() + { + return \Hamcrest\Text\IsEmptyString::isNonEmptyString(); + } + + /** + * Matches if value is a non-zero-length string. + */ + public static function nonEmptyString() + { + return \Hamcrest\Text\IsEmptyString::isNonEmptyString(); + } + + /** + * Matches if value is a string equal to $string, regardless of the case. + */ + public static function equalToIgnoringCase($string) + { + return \Hamcrest\Text\IsEqualIgnoringCase::equalToIgnoringCase($string); + } + + /** + * Matches if value is a string equal to $string, regardless of whitespace. + */ + public static function equalToIgnoringWhiteSpace($string) + { + return \Hamcrest\Text\IsEqualIgnoringWhiteSpace::equalToIgnoringWhiteSpace($string); + } + + /** + * Matches if value is a string that matches regular expression $pattern. + */ + public static function matchesPattern($pattern) + { + return \Hamcrest\Text\MatchesPattern::matchesPattern($pattern); + } + + /** + * Matches if value is a string that contains $substring. + */ + public static function containsString($substring) + { + return \Hamcrest\Text\StringContains::containsString($substring); + } + + /** + * Matches if value is a string that contains $substring regardless of the case. + */ + public static function containsStringIgnoringCase($substring) + { + return \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase($substring); + } + + /** + * Matches if value contains $substrings in a constrained order. + */ + public static function stringContainsInOrder(/* args... */) + { + $args = func_get_args(); + return call_user_func_array(array('\Hamcrest\Text\StringContainsInOrder', 'stringContainsInOrder'), $args); + } + + /** + * Matches if value is a string that ends with $substring. + */ + public static function endsWith($substring) + { + return \Hamcrest\Text\StringEndsWith::endsWith($substring); + } + + /** + * Matches if value is a string that starts with $substring. + */ + public static function startsWith($substring) + { + return \Hamcrest\Text\StringStartsWith::startsWith($substring); + } + + /** + * Is the value an array? + */ + public static function arrayValue() + { + return \Hamcrest\Type\IsArray::arrayValue(); + } + + /** + * Is the value a boolean? + */ + public static function booleanValue() + { + return \Hamcrest\Type\IsBoolean::booleanValue(); + } + + /** + * Is the value a boolean? + */ + public static function boolValue() + { + return \Hamcrest\Type\IsBoolean::booleanValue(); + } + + /** + * Is the value callable? + */ + public static function callableValue() + { + return \Hamcrest\Type\IsCallable::callableValue(); + } + + /** + * Is the value a float/double? + */ + public static function doubleValue() + { + return \Hamcrest\Type\IsDouble::doubleValue(); + } + + /** + * Is the value a float/double? + */ + public static function floatValue() + { + return \Hamcrest\Type\IsDouble::doubleValue(); + } + + /** + * Is the value an integer? + */ + public static function integerValue() + { + return \Hamcrest\Type\IsInteger::integerValue(); + } + + /** + * Is the value an integer? + */ + public static function intValue() + { + return \Hamcrest\Type\IsInteger::integerValue(); + } + + /** + * Is the value a numeric? + */ + public static function numericValue() + { + return \Hamcrest\Type\IsNumeric::numericValue(); + } + + /** + * Is the value an object? + */ + public static function objectValue() + { + return \Hamcrest\Type\IsObject::objectValue(); + } + + /** + * Is the value an object? + */ + public static function anObject() + { + return \Hamcrest\Type\IsObject::objectValue(); + } + + /** + * Is the value a resource? + */ + public static function resourceValue() + { + return \Hamcrest\Type\IsResource::resourceValue(); + } + + /** + * Is the value a scalar (boolean, integer, double, or string)? + */ + public static function scalarValue() + { + return \Hamcrest\Type\IsScalar::scalarValue(); + } + + /** + * Is the value a string? + */ + public static function stringValue() + { + return \Hamcrest\Type\IsString::stringValue(); + } + + /** + * Wraps $matcher with {@link Hamcrest\Core\IsEqual) + * if it's not a matcher and the XPath in count() + * if it's an integer. + */ + public static function hasXPath($xpath, $matcher = null) + { + return \Hamcrest\Xml\HasXPath::hasXPath($xpath, $matcher); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/NullDescription.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/NullDescription.php new file mode 100644 index 000000000..aae8e4616 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/NullDescription.php @@ -0,0 +1,43 @@ +_value = $value; + $this->_delta = $delta; + } + + protected function matchesSafely($item) + { + return $this->_actualDelta($item) <= 0.0; + } + + protected function describeMismatchSafely($item, Description $mismatchDescription) + { + $mismatchDescription->appendValue($item) + ->appendText(' differed by ') + ->appendValue($this->_actualDelta($item)) + ; + } + + public function describeTo(Description $description) + { + $description->appendText('a numeric value within ') + ->appendValue($this->_delta) + ->appendText(' of ') + ->appendValue($this->_value) + ; + } + + /** + * Matches if value is a number equal to $value within some range of + * acceptable error $delta. + * + * @factory + */ + public static function closeTo($value, $delta) + { + return new self($value, $delta); + } + + // -- Private Methods + + private function _actualDelta($item) + { + return (abs(($item - $this->_value)) - $this->_delta); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Number/OrderingComparison.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Number/OrderingComparison.php new file mode 100644 index 000000000..369d0cfa5 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Number/OrderingComparison.php @@ -0,0 +1,132 @@ +_value = $value; + $this->_minCompare = $minCompare; + $this->_maxCompare = $maxCompare; + } + + protected function matchesSafely($other) + { + $compare = $this->_compare($this->_value, $other); + + return ($this->_minCompare <= $compare) && ($compare <= $this->_maxCompare); + } + + protected function describeMismatchSafely($item, Description $mismatchDescription) + { + $mismatchDescription + ->appendValue($item)->appendText(' was ') + ->appendText($this->_comparison($this->_compare($this->_value, $item))) + ->appendText(' ')->appendValue($this->_value) + ; + } + + public function describeTo(Description $description) + { + $description->appendText('a value ') + ->appendText($this->_comparison($this->_minCompare)) + ; + if ($this->_minCompare != $this->_maxCompare) { + $description->appendText(' or ') + ->appendText($this->_comparison($this->_maxCompare)) + ; + } + $description->appendText(' ')->appendValue($this->_value); + } + + /** + * The value is not > $value, nor < $value. + * + * @factory + */ + public static function comparesEqualTo($value) + { + return new self($value, 0, 0); + } + + /** + * The value is > $value. + * + * @factory + */ + public static function greaterThan($value) + { + return new self($value, -1, -1); + } + + /** + * The value is >= $value. + * + * @factory atLeast + */ + public static function greaterThanOrEqualTo($value) + { + return new self($value, -1, 0); + } + + /** + * The value is < $value. + * + * @factory + */ + public static function lessThan($value) + { + return new self($value, 1, 1); + } + + /** + * The value is <= $value. + * + * @factory atMost + */ + public static function lessThanOrEqualTo($value) + { + return new self($value, 0, 1); + } + + // -- Private Methods + + private function _compare($left, $right) + { + $a = $left; + $b = $right; + + if ($a < $b) { + return -1; + } elseif ($a == $b) { + return 0; + } else { + return 1; + } + } + + private function _comparison($compare) + { + if ($compare > 0) { + return 'less than'; + } elseif ($compare == 0) { + return 'equal to'; + } else { + return 'greater than'; + } + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/SelfDescribing.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/SelfDescribing.php new file mode 100644 index 000000000..872fdf9c5 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/SelfDescribing.php @@ -0,0 +1,23 @@ +_out = (string) $out; + } + + public function __toString() + { + return $this->_out; + } + + /** + * Return the description of a {@link Hamcrest\SelfDescribing} object as a + * String. + * + * @param \Hamcrest\SelfDescribing $selfDescribing + * The object to be described. + * + * @return string + * The description of the object. + */ + public static function toString(SelfDescribing $selfDescribing) + { + $self = new self(); + + return (string) $self->appendDescriptionOf($selfDescribing); + } + + /** + * Alias for {@link toString()}. + */ + public static function asString(SelfDescribing $selfDescribing) + { + return self::toString($selfDescribing); + } + + // -- Protected Methods + + protected function append($str) + { + $this->_out .= $str; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEmptyString.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEmptyString.php new file mode 100644 index 000000000..2ae61b96c --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEmptyString.php @@ -0,0 +1,85 @@ +_empty = $empty; + } + + public function matches($item) + { + return $this->_empty + ? ($item === '') + : is_string($item) && $item !== ''; + } + + public function describeTo(Description $description) + { + $description->appendText($this->_empty ? 'an empty string' : 'a non-empty string'); + } + + /** + * Matches if value is a zero-length string. + * + * @factory emptyString + */ + public static function isEmptyString() + { + if (!self::$_INSTANCE) { + self::$_INSTANCE = new self(true); + } + + return self::$_INSTANCE; + } + + /** + * Matches if value is null or a zero-length string. + * + * @factory nullOrEmptyString + */ + public static function isEmptyOrNullString() + { + if (!self::$_NULL_OR_EMPTY_INSTANCE) { + self::$_NULL_OR_EMPTY_INSTANCE = AnyOf::anyOf( + IsNull::nullvalue(), + self::isEmptyString() + ); + } + + return self::$_NULL_OR_EMPTY_INSTANCE; + } + + /** + * Matches if value is a non-zero-length string. + * + * @factory nonEmptyString + */ + public static function isNonEmptyString() + { + if (!self::$_NOT_INSTANCE) { + self::$_NOT_INSTANCE = new self(false); + } + + return self::$_NOT_INSTANCE; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php new file mode 100644 index 000000000..3836a8c37 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringCase.php @@ -0,0 +1,52 @@ +_string = $string; + } + + protected function matchesSafely($item) + { + return strtolower($this->_string) === strtolower($item); + } + + protected function describeMismatchSafely($item, Description $mismatchDescription) + { + $mismatchDescription->appendText('was ')->appendText($item); + } + + public function describeTo(Description $description) + { + $description->appendText('equalToIgnoringCase(') + ->appendValue($this->_string) + ->appendText(')') + ; + } + + /** + * Matches if value is a string equal to $string, regardless of the case. + * + * @factory + */ + public static function equalToIgnoringCase($string) + { + return new self($string); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php new file mode 100644 index 000000000..853692b03 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/IsEqualIgnoringWhiteSpace.php @@ -0,0 +1,66 @@ +_string = $string; + } + + protected function matchesSafely($item) + { + return (strtolower($this->_stripSpace($item)) + === strtolower($this->_stripSpace($this->_string))); + } + + protected function describeMismatchSafely($item, Description $mismatchDescription) + { + $mismatchDescription->appendText('was ')->appendText($item); + } + + public function describeTo(Description $description) + { + $description->appendText('equalToIgnoringWhiteSpace(') + ->appendValue($this->_string) + ->appendText(')') + ; + } + + /** + * Matches if value is a string equal to $string, regardless of whitespace. + * + * @factory + */ + public static function equalToIgnoringWhiteSpace($string) + { + return new self($string); + } + + // -- Private Methods + + private function _stripSpace($string) + { + $parts = preg_split("/[\r\n\t ]+/", $string); + foreach ($parts as $i => $part) { + $parts[$i] = trim($part, " \r\n\t"); + } + + return trim(implode(' ', $parts), " \r\n\t"); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/MatchesPattern.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/MatchesPattern.php new file mode 100644 index 000000000..fa0d68eea --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/MatchesPattern.php @@ -0,0 +1,40 @@ +_substring, (string) $item) >= 1; + } + + protected function relationship() + { + return 'matching'; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContains.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContains.php new file mode 100644 index 000000000..b92786b60 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContains.php @@ -0,0 +1,45 @@ +_substring); + } + + /** + * Matches if value is a string that contains $substring. + * + * @factory + */ + public static function containsString($substring) + { + return new self($substring); + } + + // -- Protected Methods + + protected function evalSubstringOf($item) + { + return (false !== strpos((string) $item, $this->_substring)); + } + + protected function relationship() + { + return 'containing'; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsIgnoringCase.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsIgnoringCase.php new file mode 100644 index 000000000..69f37c258 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsIgnoringCase.php @@ -0,0 +1,40 @@ +_substring)); + } + + protected function relationship() + { + return 'containing in any case'; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsInOrder.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsInOrder.php new file mode 100644 index 000000000..e75de65d2 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringContainsInOrder.php @@ -0,0 +1,66 @@ +_substrings = $substrings; + } + + protected function matchesSafely($item) + { + $fromIndex = 0; + + foreach ($this->_substrings as $substring) { + if (false === $fromIndex = strpos($item, $substring, $fromIndex)) { + return false; + } + } + + return true; + } + + protected function describeMismatchSafely($item, Description $mismatchDescription) + { + $mismatchDescription->appendText('was ')->appendText($item); + } + + public function describeTo(Description $description) + { + $description->appendText('a string containing ') + ->appendValueList('', ', ', '', $this->_substrings) + ->appendText(' in order') + ; + } + + /** + * Matches if value contains $substrings in a constrained order. + * + * @factory ... + */ + public static function stringContainsInOrder(/* args... */) + { + $args = func_get_args(); + + if (isset($args[0]) && is_array($args[0])) { + $args = $args[0]; + } + + return new self($args); + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringEndsWith.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringEndsWith.php new file mode 100644 index 000000000..f802ee4d1 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringEndsWith.php @@ -0,0 +1,40 @@ +_substring))) === $this->_substring); + } + + protected function relationship() + { + return 'ending with'; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringStartsWith.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringStartsWith.php new file mode 100644 index 000000000..79c95656a --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/StringStartsWith.php @@ -0,0 +1,40 @@ +_substring)) === $this->_substring); + } + + protected function relationship() + { + return 'starting with'; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/SubstringMatcher.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/SubstringMatcher.php new file mode 100644 index 000000000..e560ad627 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Text/SubstringMatcher.php @@ -0,0 +1,45 @@ +_substring = $substring; + } + + protected function matchesSafely($item) + { + return $this->evalSubstringOf($item); + } + + protected function describeMismatchSafely($item, Description $mismatchDescription) + { + $mismatchDescription->appendText('was "')->appendText($item)->appendText('"'); + } + + public function describeTo(Description $description) + { + $description->appendText('a string ') + ->appendText($this->relationship()) + ->appendText(' ') + ->appendValue($this->_substring) + ; + } + + abstract protected function evalSubstringOf($string); + + abstract protected function relationship(); +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsArray.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsArray.php new file mode 100644 index 000000000..9179102ff --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsArray.php @@ -0,0 +1,32 @@ +isHexadecimal($item)) { + return true; + } + + return is_numeric($item); + } + + /** + * Return if the string passed is a valid hexadecimal number. + * This check is necessary because PHP 7 doesn't recognize hexadecimal string as numeric anymore. + * + * @param mixed $item + * @return boolean + */ + private function isHexadecimal($item) + { + if (is_string($item) && preg_match('/^0x(.*)$/', $item, $matches)) { + return ctype_xdigit($matches[1]); + } + + return false; + } + + /** + * Is the value a numeric? + * + * @factory + */ + public static function numericValue() + { + return new self; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsObject.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsObject.php new file mode 100644 index 000000000..65918fcf3 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Type/IsObject.php @@ -0,0 +1,32 @@ +matchesSafelyWithDiagnosticDescription($item, new NullDescription()); + } + + final public function describeMismatchSafely($item, Description $mismatchDescription) + { + $this->matchesSafelyWithDiagnosticDescription($item, $mismatchDescription); + } + + // -- Protected Methods + + /** + * Subclasses should implement these. The item will already have been checked for + * the specific type. + */ + abstract protected function matchesSafelyWithDiagnosticDescription($item, Description $mismatchDescription); +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/TypeSafeMatcher.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/TypeSafeMatcher.php new file mode 100644 index 000000000..56e299a9a --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/TypeSafeMatcher.php @@ -0,0 +1,107 @@ +_expectedType = $expectedType; + $this->_expectedSubtype = $expectedSubtype; + } + + final public function matches($item) + { + return $this->_isSafeType($item) && $this->matchesSafely($item); + } + + final public function describeMismatch($item, Description $mismatchDescription) + { + if (!$this->_isSafeType($item)) { + parent::describeMismatch($item, $mismatchDescription); + } else { + $this->describeMismatchSafely($item, $mismatchDescription); + } + } + + // -- Protected Methods + + /** + * The item will already have been checked for the specific type and subtype. + */ + abstract protected function matchesSafely($item); + + /** + * The item will already have been checked for the specific type and subtype. + */ + abstract protected function describeMismatchSafely($item, Description $mismatchDescription); + + // -- Private Methods + + private function _isSafeType($value) + { + switch ($this->_expectedType) { + + case self::TYPE_ANY: + return true; + + case self::TYPE_STRING: + return is_string($value) || is_numeric($value); + + case self::TYPE_NUMERIC: + return is_numeric($value) || is_string($value); + + case self::TYPE_ARRAY: + return is_array($value); + + case self::TYPE_OBJECT: + return is_object($value) + && ($this->_expectedSubtype === null + || $value instanceof $this->_expectedSubtype); + + case self::TYPE_RESOURCE: + return is_resource($value) + && ($this->_expectedSubtype === null + || get_resource_type($value) == $this->_expectedSubtype); + + case self::TYPE_BOOLEAN: + return true; + + default: + return true; + + } + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Util.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Util.php new file mode 100644 index 000000000..169b03663 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Util.php @@ -0,0 +1,76 @@ + all items are + */ + public static function createMatcherArray(array $items) + { + //Extract single array item + if (count($items) == 1 && is_array($items[0])) { + $items = $items[0]; + } + + //Replace non-matchers + foreach ($items as &$item) { + if (!($item instanceof Matcher)) { + $item = Core\IsEqual::equalTo($item); + } + } + + return $items; + } +} diff --git a/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Xml/HasXPath.php b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Xml/HasXPath.php new file mode 100644 index 000000000..d9764e45f --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Xml/HasXPath.php @@ -0,0 +1,195 @@ +_xpath = $xpath; + $this->_matcher = $matcher; + } + + /** + * Matches if the XPath matches against the DOM node and the matcher. + * + * @param string|\DOMNode $actual + * @param Description $mismatchDescription + * @return bool + */ + protected function matchesWithDiagnosticDescription($actual, Description $mismatchDescription) + { + if (is_string($actual)) { + $actual = $this->createDocument($actual); + } elseif (!$actual instanceof \DOMNode) { + $mismatchDescription->appendText('was ')->appendValue($actual); + + return false; + } + $result = $this->evaluate($actual); + if ($result instanceof \DOMNodeList) { + return $this->matchesContent($result, $mismatchDescription); + } else { + return $this->matchesExpression($result, $mismatchDescription); + } + } + + /** + * Creates and returns a DOMDocument from the given + * XML or HTML string. + * + * @param string $text + * @return \DOMDocument built from $text + * @throws \InvalidArgumentException if the document is not valid + */ + protected function createDocument($text) + { + $document = new \DOMDocument(); + if (preg_match('/^\s*<\?xml/', $text)) { + if (!@$document->loadXML($text)) { + throw new \InvalidArgumentException('Must pass a valid XML document'); + } + } else { + if (!@$document->loadHTML($text)) { + throw new \InvalidArgumentException('Must pass a valid HTML or XHTML document'); + } + } + + return $document; + } + + /** + * Applies the configured XPath to the DOM node and returns either + * the result if it's an expression or the node list if it's a query. + * + * @param \DOMNode $node context from which to issue query + * @return mixed result of expression or DOMNodeList from query + */ + protected function evaluate(\DOMNode $node) + { + if ($node instanceof \DOMDocument) { + $xpathDocument = new \DOMXPath($node); + + return $xpathDocument->evaluate($this->_xpath); + } else { + $xpathDocument = new \DOMXPath($node->ownerDocument); + + return $xpathDocument->evaluate($this->_xpath, $node); + } + } + + /** + * Matches if the list of nodes is not empty and the content of at least + * one node matches the configured matcher, if supplied. + * + * @param \DOMNodeList $nodes selected by the XPath query + * @param Description $mismatchDescription + * @return bool + */ + protected function matchesContent(\DOMNodeList $nodes, Description $mismatchDescription) + { + if ($nodes->length == 0) { + $mismatchDescription->appendText('XPath returned no results'); + } elseif ($this->_matcher === null) { + return true; + } else { + foreach ($nodes as $node) { + if ($this->_matcher->matches($node->textContent)) { + return true; + } + } + $content = array(); + foreach ($nodes as $node) { + $content[] = $node->textContent; + } + $mismatchDescription->appendText('XPath returned ') + ->appendValue($content); + } + + return false; + } + + /** + * Matches if the result of the XPath expression matches the configured + * matcher or evaluates to true if there is none. + * + * @param mixed $result result of the XPath expression + * @param Description $mismatchDescription + * @return bool + */ + protected function matchesExpression($result, Description $mismatchDescription) + { + if ($this->_matcher === null) { + if ($result) { + return true; + } + $mismatchDescription->appendText('XPath expression result was ') + ->appendValue($result); + } else { + if ($this->_matcher->matches($result)) { + return true; + } + $mismatchDescription->appendText('XPath expression result '); + $this->_matcher->describeMismatch($result, $mismatchDescription); + } + + return false; + } + + public function describeTo(Description $description) + { + $description->appendText('XML or HTML document with XPath "') + ->appendText($this->_xpath) + ->appendText('"'); + if ($this->_matcher !== null) { + $description->appendText(' '); + $this->_matcher->describeTo($description); + } + } + + /** + * Wraps $matcher with {@link Hamcrest\Core\IsEqual) + * if it's not a matcher and the XPath in count() + * if it's an integer. + * + * @factory + */ + public static function hasXPath($xpath, $matcher = null) + { + if ($matcher === null || $matcher instanceof Matcher) { + return new self($xpath, $matcher); + } elseif (is_int($matcher) && strpos($xpath, 'count(') !== 0) { + $xpath = 'count(' . $xpath . ')'; + } + + return new self($xpath, IsEqual::equalTo($matcher)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/AbstractMatcherTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/AbstractMatcherTest.php new file mode 100644 index 000000000..6c52c0e5d --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/AbstractMatcherTest.php @@ -0,0 +1,66 @@ +assertTrue($matcher->matches($arg), $message); + } + + public function assertDoesNotMatch(\Hamcrest\Matcher $matcher, $arg, $message) + { + $this->assertFalse($matcher->matches($arg), $message); + } + + public function assertDescription($expected, \Hamcrest\Matcher $matcher) + { + $description = new \Hamcrest\StringDescription(); + $description->appendDescriptionOf($matcher); + $this->assertEquals($expected, (string) $description, 'Expected description'); + } + + public function assertMismatchDescription($expected, \Hamcrest\Matcher $matcher, $arg) + { + $description = new \Hamcrest\StringDescription(); + $this->assertFalse( + $matcher->matches($arg), + 'Precondtion: Matcher should not match item' + ); + $matcher->describeMismatch($arg, $description); + $this->assertEquals( + $expected, + (string) $description, + 'Expected mismatch description' + ); + } + + public function testIsNullSafe() + { + //Should not generate any notices + $this->createMatcher()->matches(null); + $this->createMatcher()->describeMismatch( + null, + new \Hamcrest\NullDescription() + ); + } + + public function testCopesWithUnknownTypes() + { + //Should not generate any notices + $this->createMatcher()->matches(new UnknownType()); + $this->createMatcher()->describeMismatch( + new UnknownType(), + new NullDescription() + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInAnyOrderTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInAnyOrderTest.php new file mode 100644 index 000000000..45d9f138a --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInAnyOrderTest.php @@ -0,0 +1,54 @@ +assertDescription('[<1>, <2>] in any order', containsInAnyOrder(array(1, 2))); + } + + public function testMatchesItemsInAnyOrder() + { + $this->assertMatches(containsInAnyOrder(array(1, 2, 3)), array(1, 2, 3), 'in order'); + $this->assertMatches(containsInAnyOrder(array(1, 2, 3)), array(3, 2, 1), 'out of order'); + $this->assertMatches(containsInAnyOrder(array(1)), array(1), 'single'); + } + + public function testAppliesMatchersInAnyOrder() + { + $this->assertMatches( + containsInAnyOrder(array(1, 2, 3)), + array(1, 2, 3), + 'in order' + ); + $this->assertMatches( + containsInAnyOrder(array(1, 2, 3)), + array(3, 2, 1), + 'out of order' + ); + $this->assertMatches( + containsInAnyOrder(array(1)), + array(1), + 'single' + ); + } + + public function testMismatchesItemsInAnyOrder() + { + $matcher = containsInAnyOrder(array(1, 2, 3)); + + $this->assertMismatchDescription('was null', $matcher, null); + $this->assertMismatchDescription('No item matches: <1>, <2>, <3> in []', $matcher, array()); + $this->assertMismatchDescription('No item matches: <2>, <3> in [<1>]', $matcher, array(1)); + $this->assertMismatchDescription('Not matched: <4>', $matcher, array(4, 3, 2, 1)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInOrderTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInOrderTest.php new file mode 100644 index 000000000..1868343fa --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingInOrderTest.php @@ -0,0 +1,44 @@ +assertDescription('[<1>, <2>]', arrayContaining(array(1, 2))); + } + + public function testMatchesItemsInOrder() + { + $this->assertMatches(arrayContaining(array(1, 2, 3)), array(1, 2, 3), 'in order'); + $this->assertMatches(arrayContaining(array(1)), array(1), 'single'); + } + + public function testAppliesMatchersInOrder() + { + $this->assertMatches( + arrayContaining(array(1, 2, 3)), + array(1, 2, 3), + 'in order' + ); + $this->assertMatches(arrayContaining(array(1)), array(1), 'single'); + } + + public function testMismatchesItemsInAnyOrder() + { + $matcher = arrayContaining(array(1, 2, 3)); + $this->assertMismatchDescription('was null', $matcher, null); + $this->assertMismatchDescription('No item matched: <1>', $matcher, array()); + $this->assertMismatchDescription('No item matched: <2>', $matcher, array(1)); + $this->assertMismatchDescription('item with key 0: was <4>', $matcher, array(4, 3, 2, 1)); + $this->assertMismatchDescription('item with key 2: was <4>', $matcher, array(1, 2, 4)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyTest.php new file mode 100644 index 000000000..31770d8dd --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyTest.php @@ -0,0 +1,62 @@ +1); + + $this->assertMatches(hasKey('a'), $array, 'Matches single key'); + } + + public function testMatchesArrayContainingKey() + { + $array = array('a'=>1, 'b'=>2, 'c'=>3); + + $this->assertMatches(hasKey('a'), $array, 'Matches a'); + $this->assertMatches(hasKey('c'), $array, 'Matches c'); + } + + public function testMatchesArrayContainingKeyWithIntegerKeys() + { + $array = array(1=>'A', 2=>'B'); + + assertThat($array, hasKey(1)); + } + + public function testMatchesArrayContainingKeyWithNumberKeys() + { + $array = array(1=>'A', 2=>'B'); + + assertThat($array, hasKey(1)); + + // very ugly version! + assertThat($array, IsArrayContainingKey::hasKeyInArray(2)); + } + + public function testHasReadableDescription() + { + $this->assertDescription('array with key "a"', hasKey('a')); + } + + public function testDoesNotMatchEmptyArray() + { + $this->assertMismatchDescription('array was []', hasKey('Foo'), array()); + } + + public function testDoesNotMatchArrayMissingKey() + { + $array = array('a'=>1, 'b'=>2, 'c'=>3); + + $this->assertMismatchDescription('array was ["a" => <1>, "b" => <2>, "c" => <3>]', hasKey('d'), $array); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php new file mode 100644 index 000000000..a415f9f7a --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingKeyValuePairTest.php @@ -0,0 +1,36 @@ +1, 'b'=>2); + + $this->assertMatches(hasKeyValuePair(equalTo('a'), equalTo(1)), $array, 'matcherA'); + $this->assertMatches(hasKeyValuePair(equalTo('b'), equalTo(2)), $array, 'matcherB'); + $this->assertMismatchDescription( + 'array was ["a" => <1>, "b" => <2>]', + hasKeyValuePair(equalTo('c'), equalTo(3)), + $array + ); + } + + public function testDoesNotMatchNull() + { + $this->assertMismatchDescription('was null', hasKeyValuePair(anything(), anything()), null); + } + + public function testHasReadableDescription() + { + $this->assertDescription('array containing ["a" => <2>]', hasKeyValuePair(equalTo('a'), equalTo(2))); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingTest.php new file mode 100644 index 000000000..8d5bd8109 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayContainingTest.php @@ -0,0 +1,50 @@ +assertMatches( + hasItemInArray('a'), + array('a', 'b', 'c'), + "should matches array that contains 'a'" + ); + } + + public function testDoesNotMatchAnArrayThatDoesntContainAnElementMatchingTheGivenMatcher() + { + $this->assertDoesNotMatch( + hasItemInArray('a'), + array('b', 'c'), + "should not matches array that doesn't contain 'a'" + ); + $this->assertDoesNotMatch( + hasItemInArray('a'), + array(), + 'should not match empty array' + ); + } + + public function testDoesNotMatchNull() + { + $this->assertDoesNotMatch( + hasItemInArray('a'), + null, + 'should not match null' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription('an array containing "a"', hasItemInArray('a')); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayTest.php new file mode 100644 index 000000000..e4db53e79 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayTest.php @@ -0,0 +1,89 @@ +assertMatches( + anArray(array(equalTo('a'), equalTo('b'), equalTo('c'))), + array('a', 'b', 'c'), + 'should match array with matching elements' + ); + } + + public function testDoesNotMatchAnArrayWhenElementsDoNotMatch() + { + $this->assertDoesNotMatch( + anArray(array(equalTo('a'), equalTo('b'))), + array('b', 'c'), + 'should not match array with different elements' + ); + } + + public function testDoesNotMatchAnArrayOfDifferentSize() + { + $this->assertDoesNotMatch( + anArray(array(equalTo('a'), equalTo('b'))), + array('a', 'b', 'c'), + 'should not match larger array' + ); + $this->assertDoesNotMatch( + anArray(array(equalTo('a'), equalTo('b'))), + array('a'), + 'should not match smaller array' + ); + } + + public function testDoesNotMatchNull() + { + $this->assertDoesNotMatch( + anArray(array(equalTo('a'))), + null, + 'should not match null' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription( + '["a", "b"]', + anArray(array(equalTo('a'), equalTo('b'))) + ); + } + + public function testHasAReadableMismatchDescriptionWhenKeysDontMatch() + { + $this->assertMismatchDescription( + 'array keys were [<1>, <2>]', + anArray(array(equalTo('a'), equalTo('b'))), + array(1 => 'a', 2 => 'b') + ); + } + + public function testSupportsMatchesAssociativeArrays() + { + $this->assertMatches( + anArray(array('x'=>equalTo('a'), 'y'=>equalTo('b'), 'z'=>equalTo('c'))), + array('x'=>'a', 'y'=>'b', 'z'=>'c'), + 'should match associative array with matching elements' + ); + } + + public function testDoesNotMatchAnAssociativeArrayWhenKeysDoNotMatch() + { + $this->assertDoesNotMatch( + anArray(array('x'=>equalTo('a'), 'y'=>equalTo('b'))), + array('x'=>'b', 'z'=>'c'), + 'should not match array with different keys' + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayWithSizeTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayWithSizeTest.php new file mode 100644 index 000000000..8413c896d --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Array/IsArrayWithSizeTest.php @@ -0,0 +1,37 @@ +assertMatches(arrayWithSize(equalTo(3)), array(1, 2, 3), 'correct size'); + $this->assertDoesNotMatch(arrayWithSize(equalTo(2)), array(1, 2, 3), 'incorrect size'); + } + + public function testProvidesConvenientShortcutForArrayWithSizeEqualTo() + { + $this->assertMatches(arrayWithSize(3), array(1, 2, 3), 'correct size'); + $this->assertDoesNotMatch(arrayWithSize(2), array(1, 2, 3), 'incorrect size'); + } + + public function testEmptyArray() + { + $this->assertMatches(emptyArray(), array(), 'correct size'); + $this->assertDoesNotMatch(emptyArray(), array(1), 'incorrect size'); + } + + public function testHasAReadableDescription() + { + $this->assertDescription('an array with size <3>', arrayWithSize(equalTo(3))); + $this->assertDescription('an empty array', emptyArray()); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/BaseMatcherTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/BaseMatcherTest.php new file mode 100644 index 000000000..833e2c3ec --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/BaseMatcherTest.php @@ -0,0 +1,23 @@ +appendText('SOME DESCRIPTION'); + } + + public function testDescribesItselfWithToStringMethod() + { + $someMatcher = new \Hamcrest\SomeMatcher(); + $this->assertEquals('SOME DESCRIPTION', (string) $someMatcher); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Collection/IsEmptyTraversableTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Collection/IsEmptyTraversableTest.php new file mode 100644 index 000000000..2f15fb499 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Collection/IsEmptyTraversableTest.php @@ -0,0 +1,77 @@ +assertMatches( + emptyTraversable(), + new \ArrayObject(array()), + 'an empty traversable' + ); + } + + public function testEmptyMatcherDoesNotMatchWhenNotEmpty() + { + $this->assertDoesNotMatch( + emptyTraversable(), + new \ArrayObject(array(1, 2, 3)), + 'a non-empty traversable' + ); + } + + public function testEmptyMatcherDoesNotMatchNull() + { + $this->assertDoesNotMatch( + emptyTraversable(), + null, + 'should not match null' + ); + } + + public function testEmptyMatcherHasAReadableDescription() + { + $this->assertDescription('an empty traversable', emptyTraversable()); + } + + public function testNonEmptyDoesNotMatchNull() + { + $this->assertDoesNotMatch( + nonEmptyTraversable(), + null, + 'should not match null' + ); + } + + public function testNonEmptyDoesNotMatchWhenEmpty() + { + $this->assertDoesNotMatch( + nonEmptyTraversable(), + new \ArrayObject(array()), + 'an empty traversable' + ); + } + + public function testNonEmptyMatchesWhenNotEmpty() + { + $this->assertMatches( + nonEmptyTraversable(), + new \ArrayObject(array(1, 2, 3)), + 'a non-empty traversable' + ); + } + + public function testNonEmptyNonEmptyMatcherHasAReadableDescription() + { + $this->assertDescription('a non-empty traversable', nonEmptyTraversable()); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Collection/IsTraversableWithSizeTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Collection/IsTraversableWithSizeTest.php new file mode 100644 index 000000000..c1c67a7a4 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Collection/IsTraversableWithSizeTest.php @@ -0,0 +1,57 @@ +assertMatches( + traversableWithSize(equalTo(3)), + new \ArrayObject(array(1, 2, 3)), + 'correct size' + ); + } + + public function testDoesNotMatchWhenSizeIsIncorrect() + { + $this->assertDoesNotMatch( + traversableWithSize(equalTo(2)), + new \ArrayObject(array(1, 2, 3)), + 'incorrect size' + ); + } + + public function testDoesNotMatchNull() + { + $this->assertDoesNotMatch( + traversableWithSize(3), + null, + 'should not match null' + ); + } + + public function testProvidesConvenientShortcutForTraversableWithSizeEqualTo() + { + $this->assertMatches( + traversableWithSize(3), + new \ArrayObject(array(1, 2, 3)), + 'correct size' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription( + 'a traversable with size <3>', + traversableWithSize(equalTo(3)) + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/AllOfTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/AllOfTest.php new file mode 100644 index 000000000..86b8c277f --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/AllOfTest.php @@ -0,0 +1,56 @@ +assertDescription( + '("good" and "bad" and "ugly")', + allOf('good', 'bad', 'ugly') + ); + } + + public function testMismatchDescriptionDescribesFirstFailingMatch() + { + $this->assertMismatchDescription( + '"good" was "bad"', + allOf('bad', 'good'), + 'bad' + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/AnyOfTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/AnyOfTest.php new file mode 100644 index 000000000..3d62b9350 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/AnyOfTest.php @@ -0,0 +1,79 @@ +assertDescription( + '("good" or "bad" or "ugly")', + anyOf('good', 'bad', 'ugly') + ); + } + + public function testNoneOfEvaluatesToTheLogicalDisjunctionOfTwoOtherMatchers() + { + assertThat('good', not(noneOf('bad', 'good'))); + assertThat('good', not(noneOf('good', 'good'))); + assertThat('good', not(noneOf('good', 'bad'))); + + assertThat('good', noneOf('bad', startsWith('b'))); + } + + public function testNoneOfEvaluatesToTheLogicalDisjunctionOfManyOtherMatchers() + { + assertThat('good', not(noneOf('bad', 'good', 'bad', 'bad', 'bad'))); + assertThat('good', noneOf('bad', 'bad', 'bad', 'bad', 'bad')); + } + + public function testNoneOfSupportsMixedTypes() + { + $combined = noneOf( + equalTo(new \Hamcrest\Core\SampleBaseClass('good')), + equalTo(new \Hamcrest\Core\SampleBaseClass('ugly')), + equalTo(new \Hamcrest\Core\SampleSubClass('good')) + ); + + assertThat(new \Hamcrest\Core\SampleSubClass('bad'), $combined); + } + + public function testNoneOfHasAReadableDescription() + { + $this->assertDescription( + 'not ("good" or "bad" or "ugly")', + noneOf('good', 'bad', 'ugly') + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/CombinableMatcherTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/CombinableMatcherTest.php new file mode 100644 index 000000000..4c2261499 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/CombinableMatcherTest.php @@ -0,0 +1,59 @@ +_either_3_or_4 = \Hamcrest\Core\CombinableMatcher::either(equalTo(3))->orElse(equalTo(4)); + $this->_not_3_and_not_4 = \Hamcrest\Core\CombinableMatcher::both(not(equalTo(3)))->andAlso(not(equalTo(4))); + } + + protected function createMatcher() + { + return \Hamcrest\Core\CombinableMatcher::either(equalTo('irrelevant'))->orElse(equalTo('ignored')); + } + + public function testBothAcceptsAndRejects() + { + assertThat(2, $this->_not_3_and_not_4); + assertThat(3, not($this->_not_3_and_not_4)); + } + + public function testAcceptsAndRejectsThreeAnds() + { + $tripleAnd = $this->_not_3_and_not_4->andAlso(equalTo(2)); + assertThat(2, $tripleAnd); + assertThat(3, not($tripleAnd)); + } + + public function testBothDescribesItself() + { + $this->assertEquals('(not <3> and not <4>)', (string) $this->_not_3_and_not_4); + $this->assertMismatchDescription('was <3>', $this->_not_3_and_not_4, 3); + } + + public function testEitherAcceptsAndRejects() + { + assertThat(3, $this->_either_3_or_4); + assertThat(6, not($this->_either_3_or_4)); + } + + public function testAcceptsAndRejectsThreeOrs() + { + $orTriple = $this->_either_3_or_4->orElse(greaterThan(10)); + + assertThat(11, $orTriple); + assertThat(9, not($orTriple)); + } + + public function testEitherDescribesItself() + { + $this->assertEquals('(<3> or <4>)', (string) $this->_either_3_or_4); + $this->assertMismatchDescription('was <6>', $this->_either_3_or_4, 6); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/DescribedAsTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/DescribedAsTest.php new file mode 100644 index 000000000..673ab41e1 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/DescribedAsTest.php @@ -0,0 +1,36 @@ +assertDescription('m1 description', $m1); + $this->assertDescription('m2 description', $m2); + } + + public function testAppendsValuesToDescription() + { + $m = describedAs('value 1 = %0, value 2 = %1', anything(), 33, 97); + + $this->assertDescription('value 1 = <33>, value 2 = <97>', $m); + } + + public function testDelegatesMatchingToAnotherMatcher() + { + $m1 = describedAs('irrelevant', anything()); + $m2 = describedAs('irrelevant', not(anything())); + + $this->assertTrue($m1->matches(new \stdClass())); + $this->assertFalse($m2->matches('hi')); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/EveryTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/EveryTest.php new file mode 100644 index 000000000..5eb153c5e --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/EveryTest.php @@ -0,0 +1,30 @@ +assertEquals('every item is a string containing "a"', (string) $each); + + $this->assertMismatchDescription('an item was "BbB"', $each, array('BbB')); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/HasToStringTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/HasToStringTest.php new file mode 100644 index 000000000..e2e136dcd --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/HasToStringTest.php @@ -0,0 +1,108 @@ +assertMatches( + hasToString(equalTo('php')), + new \Hamcrest\Core\PhpForm(), + 'correct __toString' + ); + $this->assertMatches( + hasToString(equalTo('java')), + new \Hamcrest\Core\JavaForm(), + 'correct toString' + ); + } + + public function testPicksJavaOverPhpToString() + { + $this->assertMatches( + hasToString(equalTo('java')), + new \Hamcrest\Core\BothForms(), + 'correct toString' + ); + } + + public function testDoesNotMatchWhenToStringDoesNotMatch() + { + $this->assertDoesNotMatch( + hasToString(equalTo('mismatch')), + new \Hamcrest\Core\PhpForm(), + 'incorrect __toString' + ); + $this->assertDoesNotMatch( + hasToString(equalTo('mismatch')), + new \Hamcrest\Core\JavaForm(), + 'incorrect toString' + ); + $this->assertDoesNotMatch( + hasToString(equalTo('mismatch')), + new \Hamcrest\Core\BothForms(), + 'incorrect __toString' + ); + } + + public function testDoesNotMatchNull() + { + $this->assertDoesNotMatch( + hasToString(equalTo('a')), + null, + 'should not match null' + ); + } + + public function testProvidesConvenientShortcutForTraversableWithSizeEqualTo() + { + $this->assertMatches( + hasToString(equalTo('php')), + new \Hamcrest\Core\PhpForm(), + 'correct __toString' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription( + 'an object with toString() "php"', + hasToString(equalTo('php')) + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsAnythingTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsAnythingTest.php new file mode 100644 index 000000000..f68032e53 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsAnythingTest.php @@ -0,0 +1,29 @@ +assertDescription('ANYTHING', anything()); + } + + public function testCanOverrideDescription() + { + $description = 'description'; + $this->assertDescription($description, anything($description)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsCollectionContainingTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsCollectionContainingTest.php new file mode 100644 index 000000000..a3929b543 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsCollectionContainingTest.php @@ -0,0 +1,91 @@ +assertMatches( + $itemMatcher, + array('a', 'b', 'c'), + "should match list that contains 'a'" + ); + } + + public function testDoesNotMatchCollectionThatDoesntContainAnElementMatchingTheGivenMatcher() + { + $matcher1 = hasItem(equalTo('a')); + $this->assertDoesNotMatch( + $matcher1, + array('b', 'c'), + "should not match list that doesn't contain 'a'" + ); + + $matcher2 = hasItem(equalTo('a')); + $this->assertDoesNotMatch( + $matcher2, + array(), + 'should not match the empty list' + ); + } + + public function testDoesNotMatchNull() + { + $this->assertDoesNotMatch( + hasItem(equalTo('a')), + null, + 'should not match null' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription('a collection containing "a"', hasItem(equalTo('a'))); + } + + public function testMatchesAllItemsInCollection() + { + $matcher1 = hasItems(equalTo('a'), equalTo('b'), equalTo('c')); + $this->assertMatches( + $matcher1, + array('a', 'b', 'c'), + 'should match list containing all items' + ); + + $matcher2 = hasItems('a', 'b', 'c'); + $this->assertMatches( + $matcher2, + array('a', 'b', 'c'), + 'should match list containing all items (without matchers)' + ); + + $matcher3 = hasItems(equalTo('a'), equalTo('b'), equalTo('c')); + $this->assertMatches( + $matcher3, + array('c', 'b', 'a'), + 'should match list containing all items in any order' + ); + + $matcher4 = hasItems(equalTo('a'), equalTo('b'), equalTo('c')); + $this->assertMatches( + $matcher4, + array('e', 'c', 'b', 'a', 'd'), + 'should match list containing all items plus others' + ); + + $matcher5 = hasItems(equalTo('a'), equalTo('b'), equalTo('c')); + $this->assertDoesNotMatch( + $matcher5, + array('e', 'c', 'b', 'd'), // 'a' missing + 'should not match list unless it contains all items' + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsEqualTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsEqualTest.php new file mode 100644 index 000000000..73e3ff07e --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsEqualTest.php @@ -0,0 +1,102 @@ +_arg = $arg; + } + + public function __toString() + { + return $this->_arg; + } +} + +class IsEqualTest extends \Hamcrest\AbstractMatcherTest +{ + + protected function createMatcher() + { + return \Hamcrest\Core\IsEqual::equalTo('irrelevant'); + } + + public function testComparesObjectsUsingEqualityOperator() + { + assertThat("hi", equalTo("hi")); + assertThat("bye", not(equalTo("hi"))); + + assertThat(1, equalTo(1)); + assertThat(1, not(equalTo(2))); + + assertThat("2", equalTo(2)); + } + + public function testCanCompareNullValues() + { + assertThat(null, equalTo(null)); + + assertThat(null, not(equalTo('hi'))); + assertThat('hi', not(equalTo(null))); + } + + public function testComparesTheElementsOfAnArray() + { + $s1 = array('a', 'b'); + $s2 = array('a', 'b'); + $s3 = array('c', 'd'); + $s4 = array('a', 'b', 'c', 'd'); + + assertThat($s1, equalTo($s1)); + assertThat($s2, equalTo($s1)); + assertThat($s3, not(equalTo($s1))); + assertThat($s4, not(equalTo($s1))); + } + + public function testComparesTheElementsOfAnArrayOfPrimitiveTypes() + { + $i1 = array(1, 2); + $i2 = array(1, 2); + $i3 = array(3, 4); + $i4 = array(1, 2, 3, 4); + + assertThat($i1, equalTo($i1)); + assertThat($i2, equalTo($i1)); + assertThat($i3, not(equalTo($i1))); + assertThat($i4, not(equalTo($i1))); + } + + public function testRecursivelyTestsElementsOfArrays() + { + $i1 = array(array(1, 2), array(3, 4)); + $i2 = array(array(1, 2), array(3, 4)); + $i3 = array(array(5, 6), array(7, 8)); + $i4 = array(array(1, 2, 3, 4), array(3, 4)); + + assertThat($i1, equalTo($i1)); + assertThat($i2, equalTo($i1)); + assertThat($i3, not(equalTo($i1))); + assertThat($i4, not(equalTo($i1))); + } + + public function testIncludesTheResultOfCallingToStringOnItsArgumentInTheDescription() + { + $argumentDescription = 'ARGUMENT DESCRIPTION'; + $argument = new \Hamcrest\Core\DummyToStringClass($argumentDescription); + $this->assertDescription('<' . $argumentDescription . '>', equalTo($argument)); + } + + public function testReturnsAnObviousDescriptionIfCreatedWithANestedMatcherByMistake() + { + $innerMatcher = equalTo('NestedMatcher'); + $this->assertDescription('<' . (string) $innerMatcher . '>', equalTo($innerMatcher)); + } + + public function testReturnsGoodDescriptionIfCreatedWithNullReference() + { + $this->assertDescription('null', equalTo(null)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsIdenticalTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsIdenticalTest.php new file mode 100644 index 000000000..9cc27946c --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsIdenticalTest.php @@ -0,0 +1,30 @@ +assertDescription('"ARG"', identicalTo('ARG')); + } + + public function testReturnsReadableDescriptionFromToStringWhenInitialisedWithNull() + { + $this->assertDescription('null', identicalTo(null)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsInstanceOfTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsInstanceOfTest.php new file mode 100644 index 000000000..7a5f095a2 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsInstanceOfTest.php @@ -0,0 +1,51 @@ +_baseClassInstance = new \Hamcrest\Core\SampleBaseClass('good'); + $this->_subClassInstance = new \Hamcrest\Core\SampleSubClass('good'); + } + + protected function createMatcher() + { + return \Hamcrest\Core\IsInstanceOf::anInstanceOf('stdClass'); + } + + public function testEvaluatesToTrueIfArgumentIsInstanceOfASpecificClass() + { + assertThat($this->_baseClassInstance, anInstanceOf('Hamcrest\Core\SampleBaseClass')); + assertThat($this->_subClassInstance, anInstanceOf('Hamcrest\Core\SampleSubClass')); + assertThat(null, not(anInstanceOf('Hamcrest\Core\SampleBaseClass'))); + assertThat(new \stdClass(), not(anInstanceOf('Hamcrest\Core\SampleBaseClass'))); + } + + public function testEvaluatesToFalseIfArgumentIsNotAnObject() + { + assertThat(null, not(anInstanceOf('Hamcrest\Core\SampleBaseClass'))); + assertThat(false, not(anInstanceOf('Hamcrest\Core\SampleBaseClass'))); + assertThat(5, not(anInstanceOf('Hamcrest\Core\SampleBaseClass'))); + assertThat('foo', not(anInstanceOf('Hamcrest\Core\SampleBaseClass'))); + assertThat(array(1, 2, 3), not(anInstanceOf('Hamcrest\Core\SampleBaseClass'))); + } + + public function testHasAReadableDescription() + { + $this->assertDescription('an instance of stdClass', anInstanceOf('stdClass')); + } + + public function testDecribesActualClassInMismatchMessage() + { + $this->assertMismatchDescription( + '[Hamcrest\Core\SampleBaseClass] ', + anInstanceOf('Hamcrest\Core\SampleSubClass'), + $this->_baseClassInstance + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsNotTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsNotTest.php new file mode 100644 index 000000000..09d4a652a --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsNotTest.php @@ -0,0 +1,31 @@ +assertMatches(not(equalTo('A')), 'B', 'should match'); + $this->assertDoesNotMatch(not(equalTo('B')), 'B', 'should not match'); + } + + public function testProvidesConvenientShortcutForNotEqualTo() + { + $this->assertMatches(not('A'), 'B', 'should match'); + $this->assertMatches(not('B'), 'A', 'should match'); + $this->assertDoesNotMatch(not('A'), 'A', 'should not match'); + $this->assertDoesNotMatch(not('B'), 'B', 'should not match'); + } + + public function testUsesDescriptionOfNegatedMatcherWithPrefix() + { + $this->assertDescription('not a value greater than <2>', not(greaterThan(2))); + $this->assertDescription('not "A"', not('A')); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsNullTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsNullTest.php new file mode 100644 index 000000000..bfa42554d --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsNullTest.php @@ -0,0 +1,20 @@ +assertDescription('sameInstance("ARG")', sameInstance('ARG')); + } + + public function testReturnsReadableDescriptionFromToStringWhenInitialisedWithNull() + { + $this->assertDescription('sameInstance(null)', sameInstance(null)); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsTest.php new file mode 100644 index 000000000..bbd848b9f --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsTest.php @@ -0,0 +1,33 @@ +assertMatches(is(equalTo(true)), true, 'should match'); + $this->assertMatches(is(equalTo(false)), false, 'should match'); + $this->assertDoesNotMatch(is(equalTo(true)), false, 'should not match'); + $this->assertDoesNotMatch(is(equalTo(false)), true, 'should not match'); + } + + public function testGeneratesIsPrefixInDescription() + { + $this->assertDescription('is ', is(equalTo(true))); + } + + public function testProvidesConvenientShortcutForIsEqualTo() + { + $this->assertMatches(is('A'), 'A', 'should match'); + $this->assertMatches(is('B'), 'B', 'should match'); + $this->assertDoesNotMatch(is('A'), 'B', 'should not match'); + $this->assertDoesNotMatch(is('B'), 'A', 'should not match'); + $this->assertDescription('is "A"', is('A')); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsTypeOfTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsTypeOfTest.php new file mode 100644 index 000000000..3f48dea70 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/IsTypeOfTest.php @@ -0,0 +1,45 @@ +assertDescription('a double', typeOf('double')); + $this->assertDescription('an integer', typeOf('integer')); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', typeOf('boolean'), null); + $this->assertMismatchDescription('was an integer <5>', typeOf('float'), 5); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/SampleBaseClass.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/SampleBaseClass.php new file mode 100644 index 000000000..c953e7cd7 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/SampleBaseClass.php @@ -0,0 +1,18 @@ +_arg = $arg; + } + + public function __toString() + { + return $this->_arg; + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/SampleSubClass.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/SampleSubClass.php new file mode 100644 index 000000000..822f1b641 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Core/SampleSubClass.php @@ -0,0 +1,6 @@ +_instanceProperty); + } + + protected function createMatcher() + { + return \Hamcrest\Core\Set::set('property_name'); + } + + public function testEvaluatesToTrueIfArrayPropertyIsSet() + { + assertThat(array('foo' => 'bar'), set('foo')); + } + + public function testNegatedEvaluatesToFalseIfArrayPropertyIsSet() + { + assertThat(array('foo' => 'bar'), not(notSet('foo'))); + } + + public function testEvaluatesToTrueIfClassPropertyIsSet() + { + self::$_classProperty = 'bar'; + assertThat('Hamcrest\Core\SetTest', set('_classProperty')); + } + + public function testNegatedEvaluatesToFalseIfClassPropertyIsSet() + { + self::$_classProperty = 'bar'; + assertThat('Hamcrest\Core\SetTest', not(notSet('_classProperty'))); + } + + public function testEvaluatesToTrueIfObjectPropertyIsSet() + { + $this->_instanceProperty = 'bar'; + assertThat($this, set('_instanceProperty')); + } + + public function testNegatedEvaluatesToFalseIfObjectPropertyIsSet() + { + $this->_instanceProperty = 'bar'; + assertThat($this, not(notSet('_instanceProperty'))); + } + + public function testEvaluatesToFalseIfArrayPropertyIsNotSet() + { + assertThat(array('foo' => 'bar'), not(set('baz'))); + } + + public function testNegatedEvaluatesToTrueIfArrayPropertyIsNotSet() + { + assertThat(array('foo' => 'bar'), notSet('baz')); + } + + public function testEvaluatesToFalseIfClassPropertyIsNotSet() + { + assertThat('Hamcrest\Core\SetTest', not(set('_classProperty'))); + } + + public function testNegatedEvaluatesToTrueIfClassPropertyIsNotSet() + { + assertThat('Hamcrest\Core\SetTest', notSet('_classProperty')); + } + + public function testEvaluatesToFalseIfObjectPropertyIsNotSet() + { + assertThat($this, not(set('_instanceProperty'))); + } + + public function testNegatedEvaluatesToTrueIfObjectPropertyIsNotSet() + { + assertThat($this, notSet('_instanceProperty')); + } + + public function testHasAReadableDescription() + { + $this->assertDescription('set property foo', set('foo')); + $this->assertDescription('unset property bar', notSet('bar')); + } + + public function testDecribesPropertySettingInMismatchMessage() + { + $this->assertMismatchDescription( + 'was not set', + set('bar'), + array('foo' => 'bar') + ); + $this->assertMismatchDescription( + 'was "bar"', + notSet('foo'), + array('foo' => 'bar') + ); + self::$_classProperty = 'bar'; + $this->assertMismatchDescription( + 'was "bar"', + notSet('_classProperty'), + 'Hamcrest\Core\SetTest' + ); + $this->_instanceProperty = 'bar'; + $this->assertMismatchDescription( + 'was "bar"', + notSet('_instanceProperty'), + $this + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/FeatureMatcherTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/FeatureMatcherTest.php new file mode 100644 index 000000000..7543294ae --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/FeatureMatcherTest.php @@ -0,0 +1,73 @@ +_result = $result; + } + public function getResult() + { + return $this->_result; + } +} + +/* Test-specific subclass only */ +class ResultMatcher extends \Hamcrest\FeatureMatcher +{ + public function __construct() + { + parent::__construct(self::TYPE_ANY, null, equalTo('bar'), 'Thingy with result', 'result'); + } + public function featureValueOf($actual) + { + if ($actual instanceof \Hamcrest\Thingy) { + return $actual->getResult(); + } + } +} + +class FeatureMatcherTest extends \Hamcrest\AbstractMatcherTest +{ + + private $_resultMatcher; + + public function setUp() + { + $this->_resultMatcher = $this->_resultMatcher(); + } + + protected function createMatcher() + { + return $this->_resultMatcher(); + } + + public function testMatchesPartOfAnObject() + { + $this->assertMatches($this->_resultMatcher, new \Hamcrest\Thingy('bar'), 'feature'); + $this->assertDescription('Thingy with result "bar"', $this->_resultMatcher); + } + + public function testMismatchesPartOfAnObject() + { + $this->assertMismatchDescription( + 'result was "foo"', + $this->_resultMatcher, + new \Hamcrest\Thingy('foo') + ); + } + + public function testDoesNotGenerateNoticesForNull() + { + $this->assertMismatchDescription('result was null', $this->_resultMatcher, null); + } + + // -- Creation Methods + + private function _resultMatcher() + { + return new \Hamcrest\ResultMatcher(); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/MatcherAssertTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/MatcherAssertTest.php new file mode 100644 index 000000000..218371211 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/MatcherAssertTest.php @@ -0,0 +1,190 @@ +getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat(null); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat(''); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat(0); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat(0.0); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat(array()); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('', $ex->getMessage()); + } + self::assertEquals(6, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + + public function testAssertThatWithIdentifierAndTrueArgPasses() + { + \Hamcrest\MatcherAssert::assertThat('identifier', true); + \Hamcrest\MatcherAssert::assertThat('identifier', 'non-empty'); + \Hamcrest\MatcherAssert::assertThat('identifier', 1); + \Hamcrest\MatcherAssert::assertThat('identifier', 3.14159); + \Hamcrest\MatcherAssert::assertThat('identifier', array(true)); + self::assertEquals(5, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + + public function testAssertThatWithIdentifierAndFalseArgFails() + { + try { + \Hamcrest\MatcherAssert::assertThat('identifier', false); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('identifier', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat('identifier', null); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('identifier', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat('identifier', ''); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('identifier', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat('identifier', 0); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('identifier', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat('identifier', 0.0); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('identifier', $ex->getMessage()); + } + try { + \Hamcrest\MatcherAssert::assertThat('identifier', array()); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals('identifier', $ex->getMessage()); + } + self::assertEquals(6, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + + public function testAssertThatWithActualValueAndMatcherArgsThatMatchPasses() + { + \Hamcrest\MatcherAssert::assertThat(true, is(true)); + self::assertEquals(1, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + + public function testAssertThatWithActualValueAndMatcherArgsThatDontMatchFails() + { + $expected = 'expected'; + $actual = 'actual'; + + $expectedMessage = + 'Expected: "expected"' . PHP_EOL . + ' but: was "actual"'; + + try { + \Hamcrest\MatcherAssert::assertThat($actual, equalTo($expected)); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals($expectedMessage, $ex->getMessage()); + self::assertEquals(1, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + } + + public function testAssertThatWithIdentifierAndActualValueAndMatcherArgsThatMatchPasses() + { + \Hamcrest\MatcherAssert::assertThat('identifier', true, is(true)); + self::assertEquals(1, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + + public function testAssertThatWithIdentifierAndActualValueAndMatcherArgsThatDontMatchFails() + { + $expected = 'expected'; + $actual = 'actual'; + + $expectedMessage = + 'identifier' . PHP_EOL . + 'Expected: "expected"' . PHP_EOL . + ' but: was "actual"'; + + try { + \Hamcrest\MatcherAssert::assertThat('identifier', $actual, equalTo($expected)); + self::fail('expected assertion failure'); + } catch (\Hamcrest\AssertionError $ex) { + self::assertEquals($expectedMessage, $ex->getMessage()); + self::assertEquals(1, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + } + + public function testAssertThatWithNoArgsThrowsErrorAndDoesntIncrementCount() + { + try { + \Hamcrest\MatcherAssert::assertThat(); + self::fail('expected invalid argument exception'); + } catch (\InvalidArgumentException $ex) { + self::assertEquals(0, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + } + + public function testAssertThatWithFourArgsThrowsErrorAndDoesntIncrementCount() + { + try { + \Hamcrest\MatcherAssert::assertThat(1, 2, 3, 4); + self::fail('expected invalid argument exception'); + } catch (\InvalidArgumentException $ex) { + self::assertEquals(0, \Hamcrest\MatcherAssert::getCount(), 'assertion count'); + } + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Number/IsCloseToTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Number/IsCloseToTest.php new file mode 100644 index 000000000..987d55267 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Number/IsCloseToTest.php @@ -0,0 +1,27 @@ +assertTrue($p->matches(1.0)); + $this->assertTrue($p->matches(0.5)); + $this->assertTrue($p->matches(1.5)); + + $this->assertDoesNotMatch($p, 2.0, 'too large'); + $this->assertMismatchDescription('<2F> differed by <0.5F>', $p, 2.0); + $this->assertDoesNotMatch($p, 0.0, 'number too small'); + $this->assertMismatchDescription('<0F> differed by <0.5F>', $p, 0.0); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Number/OrderingComparisonTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Number/OrderingComparisonTest.php new file mode 100644 index 000000000..a4c94d373 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Number/OrderingComparisonTest.php @@ -0,0 +1,41 @@ +_text = $text; + } + + public function describeTo(\Hamcrest\Description $description) + { + $description->appendText($this->_text); + } +} + +class StringDescriptionTest extends \PhpUnit_Framework_TestCase +{ + + private $_description; + + public function setUp() + { + $this->_description = new \Hamcrest\StringDescription(); + } + + public function testAppendTextAppendsTextInformation() + { + $this->_description->appendText('foo')->appendText('bar'); + $this->assertEquals('foobar', (string) $this->_description); + } + + public function testAppendValueCanAppendTextTypes() + { + $this->_description->appendValue('foo'); + $this->assertEquals('"foo"', (string) $this->_description); + } + + public function testSpecialCharactersAreEscapedForStringTypes() + { + $this->_description->appendValue("foo\\bar\"zip\r\n"); + $this->assertEquals('"foo\\bar\\"zip\r\n"', (string) $this->_description); + } + + public function testIntegerValuesCanBeAppended() + { + $this->_description->appendValue(42); + $this->assertEquals('<42>', (string) $this->_description); + } + + public function testFloatValuesCanBeAppended() + { + $this->_description->appendValue(42.78); + $this->assertEquals('<42.78F>', (string) $this->_description); + } + + public function testNullValuesCanBeAppended() + { + $this->_description->appendValue(null); + $this->assertEquals('null', (string) $this->_description); + } + + public function testArraysCanBeAppended() + { + $this->_description->appendValue(array('foo', 42.78)); + $this->assertEquals('["foo", <42.78F>]', (string) $this->_description); + } + + public function testObjectsCanBeAppended() + { + $this->_description->appendValue(new \stdClass()); + $this->assertEquals('', (string) $this->_description); + } + + public function testBooleanValuesCanBeAppended() + { + $this->_description->appendValue(false); + $this->assertEquals('', (string) $this->_description); + } + + public function testListsOfvaluesCanBeAppended() + { + $this->_description->appendValue(array('foo', 42.78)); + $this->assertEquals('["foo", <42.78F>]', (string) $this->_description); + } + + public function testIterableOfvaluesCanBeAppended() + { + $items = new \ArrayObject(array('foo', 42.78)); + $this->_description->appendValue($items); + $this->assertEquals('["foo", <42.78F>]', (string) $this->_description); + } + + public function testIteratorOfvaluesCanBeAppended() + { + $items = new \ArrayObject(array('foo', 42.78)); + $this->_description->appendValue($items->getIterator()); + $this->assertEquals('["foo", <42.78F>]', (string) $this->_description); + } + + public function testListsOfvaluesCanBeAppendedManually() + { + $this->_description->appendValueList('@start@', '@sep@ ', '@end@', array('foo', 42.78)); + $this->assertEquals('@start@"foo"@sep@ <42.78F>@end@', (string) $this->_description); + } + + public function testIterableOfvaluesCanBeAppendedManually() + { + $items = new \ArrayObject(array('foo', 42.78)); + $this->_description->appendValueList('@start@', '@sep@ ', '@end@', $items); + $this->assertEquals('@start@"foo"@sep@ <42.78F>@end@', (string) $this->_description); + } + + public function testIteratorOfvaluesCanBeAppendedManually() + { + $items = new \ArrayObject(array('foo', 42.78)); + $this->_description->appendValueList('@start@', '@sep@ ', '@end@', $items->getIterator()); + $this->assertEquals('@start@"foo"@sep@ <42.78F>@end@', (string) $this->_description); + } + + public function testSelfDescribingObjectsCanBeAppended() + { + $this->_description + ->appendDescriptionOf(new \Hamcrest\SampleSelfDescriber('foo')) + ->appendDescriptionOf(new \Hamcrest\SampleSelfDescriber('bar')) + ; + $this->assertEquals('foobar', (string) $this->_description); + } + + public function testSelfDescribingObjectsCanBeAppendedAsLists() + { + $this->_description->appendList('@start@', '@sep@ ', '@end@', array( + new \Hamcrest\SampleSelfDescriber('foo'), + new \Hamcrest\SampleSelfDescriber('bar') + )); + $this->assertEquals('@start@foo@sep@ bar@end@', (string) $this->_description); + } + + public function testSelfDescribingObjectsCanBeAppendedAsIteratedLists() + { + $items = new \ArrayObject(array( + new \Hamcrest\SampleSelfDescriber('foo'), + new \Hamcrest\SampleSelfDescriber('bar') + )); + $this->_description->appendList('@start@', '@sep@ ', '@end@', $items); + $this->assertEquals('@start@foo@sep@ bar@end@', (string) $this->_description); + } + + public function testSelfDescribingObjectsCanBeAppendedAsIterators() + { + $items = new \ArrayObject(array( + new \Hamcrest\SampleSelfDescriber('foo'), + new \Hamcrest\SampleSelfDescriber('bar') + )); + $this->_description->appendList('@start@', '@sep@ ', '@end@', $items->getIterator()); + $this->assertEquals('@start@foo@sep@ bar@end@', (string) $this->_description); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEmptyStringTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEmptyStringTest.php new file mode 100644 index 000000000..8d5c56be1 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEmptyStringTest.php @@ -0,0 +1,86 @@ +assertDoesNotMatch(emptyString(), null, 'null'); + } + + public function testEmptyDoesNotMatchZero() + { + $this->assertDoesNotMatch(emptyString(), 0, 'zero'); + } + + public function testEmptyDoesNotMatchFalse() + { + $this->assertDoesNotMatch(emptyString(), false, 'false'); + } + + public function testEmptyDoesNotMatchEmptyArray() + { + $this->assertDoesNotMatch(emptyString(), array(), 'empty array'); + } + + public function testEmptyMatchesEmptyString() + { + $this->assertMatches(emptyString(), '', 'empty string'); + } + + public function testEmptyDoesNotMatchNonEmptyString() + { + $this->assertDoesNotMatch(emptyString(), 'foo', 'non-empty string'); + } + + public function testEmptyHasAReadableDescription() + { + $this->assertDescription('an empty string', emptyString()); + } + + public function testEmptyOrNullMatchesNull() + { + $this->assertMatches(nullOrEmptyString(), null, 'null'); + } + + public function testEmptyOrNullMatchesEmptyString() + { + $this->assertMatches(nullOrEmptyString(), '', 'empty string'); + } + + public function testEmptyOrNullDoesNotMatchNonEmptyString() + { + $this->assertDoesNotMatch(nullOrEmptyString(), 'foo', 'non-empty string'); + } + + public function testEmptyOrNullHasAReadableDescription() + { + $this->assertDescription('(null or an empty string)', nullOrEmptyString()); + } + + public function testNonEmptyDoesNotMatchNull() + { + $this->assertDoesNotMatch(nonEmptyString(), null, 'null'); + } + + public function testNonEmptyDoesNotMatchEmptyString() + { + $this->assertDoesNotMatch(nonEmptyString(), '', 'empty string'); + } + + public function testNonEmptyMatchesNonEmptyString() + { + $this->assertMatches(nonEmptyString(), 'foo', 'non-empty string'); + } + + public function testNonEmptyHasAReadableDescription() + { + $this->assertDescription('a non-empty string', nonEmptyString()); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringCaseTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringCaseTest.php new file mode 100644 index 000000000..0539fd5cb --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringCaseTest.php @@ -0,0 +1,40 @@ +assertDescription( + 'equalToIgnoringCase("heLLo")', + equalToIgnoringCase('heLLo') + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php new file mode 100644 index 000000000..6c2304f43 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/IsEqualIgnoringWhiteSpaceTest.php @@ -0,0 +1,51 @@ +_matcher = \Hamcrest\Text\IsEqualIgnoringWhiteSpace::equalToIgnoringWhiteSpace( + "Hello World how\n are we? " + ); + } + + protected function createMatcher() + { + return $this->_matcher; + } + + public function testPassesIfWordsAreSameButWhitespaceDiffers() + { + assertThat('Hello World how are we?', $this->_matcher); + assertThat(" Hello \rWorld \t how are\nwe?", $this->_matcher); + } + + public function testFailsIfTextOtherThanWhitespaceDiffers() + { + assertThat('Hello PLANET how are we?', not($this->_matcher)); + assertThat('Hello World how are we', not($this->_matcher)); + } + + public function testFailsIfWhitespaceIsAddedOrRemovedInMidWord() + { + assertThat('HelloWorld how are we?', not($this->_matcher)); + assertThat('Hello Wo rld how are we?', not($this->_matcher)); + } + + public function testFailsIfMatchingAgainstNull() + { + assertThat(null, not($this->_matcher)); + } + + public function testHasAReadableDescription() + { + $this->assertDescription( + "equalToIgnoringWhiteSpace(\"Hello World how\\n are we? \")", + $this->_matcher + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/MatchesPatternTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/MatchesPatternTest.php new file mode 100644 index 000000000..4891598f6 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/MatchesPatternTest.php @@ -0,0 +1,30 @@ +assertDescription('a string matching "pattern"', matchesPattern('pattern')); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php new file mode 100644 index 000000000..3b5b08e3b --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsIgnoringCaseTest.php @@ -0,0 +1,80 @@ +_stringContains = \Hamcrest\Text\StringContainsIgnoringCase::containsStringIgnoringCase( + strtolower(self::EXCERPT) + ); + } + + protected function createMatcher() + { + return $this->_stringContains; + } + + public function testEvaluatesToTrueIfArgumentContainsSpecifiedSubstring() + { + $this->assertTrue( + $this->_stringContains->matches(self::EXCERPT . 'END'), + 'should be true if excerpt at beginning' + ); + $this->assertTrue( + $this->_stringContains->matches('START' . self::EXCERPT), + 'should be true if excerpt at end' + ); + $this->assertTrue( + $this->_stringContains->matches('START' . self::EXCERPT . 'END'), + 'should be true if excerpt in middle' + ); + $this->assertTrue( + $this->_stringContains->matches(self::EXCERPT . self::EXCERPT), + 'should be true if excerpt is repeated' + ); + + $this->assertFalse( + $this->_stringContains->matches('Something else'), + 'should not be true if excerpt is not in string' + ); + $this->assertFalse( + $this->_stringContains->matches(substr(self::EXCERPT, 1)), + 'should not be true if part of excerpt is in string' + ); + } + + public function testEvaluatesToTrueIfArgumentIsEqualToSubstring() + { + $this->assertTrue( + $this->_stringContains->matches(self::EXCERPT), + 'should be true if excerpt is entire string' + ); + } + + public function testEvaluatesToTrueIfArgumentContainsExactSubstring() + { + $this->assertTrue( + $this->_stringContains->matches(strtolower(self::EXCERPT)), + 'should be false if excerpt is entire string ignoring case' + ); + $this->assertTrue( + $this->_stringContains->matches('START' . strtolower(self::EXCERPT) . 'END'), + 'should be false if excerpt is contained in string ignoring case' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription( + 'a string containing in any case "' + . strtolower(self::EXCERPT) . '"', + $this->_stringContains + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsInOrderTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsInOrderTest.php new file mode 100644 index 000000000..0be70629f --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsInOrderTest.php @@ -0,0 +1,42 @@ +_m = \Hamcrest\Text\StringContainsInOrder::stringContainsInOrder(array('a', 'b', 'c')); + } + + protected function createMatcher() + { + return $this->_m; + } + + public function testMatchesOnlyIfStringContainsGivenSubstringsInTheSameOrder() + { + $this->assertMatches($this->_m, 'abc', 'substrings in order'); + $this->assertMatches($this->_m, '1a2b3c4', 'substrings separated'); + + $this->assertDoesNotMatch($this->_m, 'cab', 'substrings out of order'); + $this->assertDoesNotMatch($this->_m, 'xyz', 'no substrings in string'); + $this->assertDoesNotMatch($this->_m, 'ac', 'substring missing'); + $this->assertDoesNotMatch($this->_m, '', 'empty string'); + } + + public function testAcceptsVariableArguments() + { + $this->assertMatches(stringContainsInOrder('a', 'b', 'c'), 'abc', 'substrings as variable arguments'); + } + + public function testHasAReadableDescription() + { + $this->assertDescription( + 'a string containing "a", "b", "c" in order', + $this->_m + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsTest.php new file mode 100644 index 000000000..203fd918d --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringContainsTest.php @@ -0,0 +1,86 @@ +_stringContains = \Hamcrest\Text\StringContains::containsString(self::EXCERPT); + } + + protected function createMatcher() + { + return $this->_stringContains; + } + + public function testEvaluatesToTrueIfArgumentContainsSubstring() + { + $this->assertTrue( + $this->_stringContains->matches(self::EXCERPT . 'END'), + 'should be true if excerpt at beginning' + ); + $this->assertTrue( + $this->_stringContains->matches('START' . self::EXCERPT), + 'should be true if excerpt at end' + ); + $this->assertTrue( + $this->_stringContains->matches('START' . self::EXCERPT . 'END'), + 'should be true if excerpt in middle' + ); + $this->assertTrue( + $this->_stringContains->matches(self::EXCERPT . self::EXCERPT), + 'should be true if excerpt is repeated' + ); + + $this->assertFalse( + $this->_stringContains->matches('Something else'), + 'should not be true if excerpt is not in string' + ); + $this->assertFalse( + $this->_stringContains->matches(substr(self::EXCERPT, 1)), + 'should not be true if part of excerpt is in string' + ); + } + + public function testEvaluatesToTrueIfArgumentIsEqualToSubstring() + { + $this->assertTrue( + $this->_stringContains->matches(self::EXCERPT), + 'should be true if excerpt is entire string' + ); + } + + public function testEvaluatesToFalseIfArgumentContainsSubstringIgnoringCase() + { + $this->assertFalse( + $this->_stringContains->matches(strtolower(self::EXCERPT)), + 'should be false if excerpt is entire string ignoring case' + ); + $this->assertFalse( + $this->_stringContains->matches('START' . strtolower(self::EXCERPT) . 'END'), + 'should be false if excerpt is contained in string ignoring case' + ); + } + + public function testIgnoringCaseReturnsCorrectMatcher() + { + $this->assertTrue( + $this->_stringContains->ignoringCase()->matches('EXceRpT'), + 'should be true if excerpt is entire string ignoring case' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription( + 'a string containing "' + . self::EXCERPT . '"', + $this->_stringContains + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringEndsWithTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringEndsWithTest.php new file mode 100644 index 000000000..fffa3c9cd --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringEndsWithTest.php @@ -0,0 +1,62 @@ +_stringEndsWith = \Hamcrest\Text\StringEndsWith::endsWith(self::EXCERPT); + } + + protected function createMatcher() + { + return $this->_stringEndsWith; + } + + public function testEvaluatesToTrueIfArgumentContainsSpecifiedSubstring() + { + $this->assertFalse( + $this->_stringEndsWith->matches(self::EXCERPT . 'END'), + 'should be false if excerpt at beginning' + ); + $this->assertTrue( + $this->_stringEndsWith->matches('START' . self::EXCERPT), + 'should be true if excerpt at end' + ); + $this->assertFalse( + $this->_stringEndsWith->matches('START' . self::EXCERPT . 'END'), + 'should be false if excerpt in middle' + ); + $this->assertTrue( + $this->_stringEndsWith->matches(self::EXCERPT . self::EXCERPT), + 'should be true if excerpt is at end and repeated' + ); + + $this->assertFalse( + $this->_stringEndsWith->matches('Something else'), + 'should be false if excerpt is not in string' + ); + $this->assertFalse( + $this->_stringEndsWith->matches(substr(self::EXCERPT, 0, strlen(self::EXCERPT) - 2)), + 'should be false if part of excerpt is at end of string' + ); + } + + public function testEvaluatesToTrueIfArgumentIsEqualToSubstring() + { + $this->assertTrue( + $this->_stringEndsWith->matches(self::EXCERPT), + 'should be true if excerpt is entire string' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription('a string ending with "EXCERPT"', $this->_stringEndsWith); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringStartsWithTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringStartsWithTest.php new file mode 100644 index 000000000..fc3761bde --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Text/StringStartsWithTest.php @@ -0,0 +1,62 @@ +_stringStartsWith = \Hamcrest\Text\StringStartsWith::startsWith(self::EXCERPT); + } + + protected function createMatcher() + { + return $this->_stringStartsWith; + } + + public function testEvaluatesToTrueIfArgumentContainsSpecifiedSubstring() + { + $this->assertTrue( + $this->_stringStartsWith->matches(self::EXCERPT . 'END'), + 'should be true if excerpt at beginning' + ); + $this->assertFalse( + $this->_stringStartsWith->matches('START' . self::EXCERPT), + 'should be false if excerpt at end' + ); + $this->assertFalse( + $this->_stringStartsWith->matches('START' . self::EXCERPT . 'END'), + 'should be false if excerpt in middle' + ); + $this->assertTrue( + $this->_stringStartsWith->matches(self::EXCERPT . self::EXCERPT), + 'should be true if excerpt is at beginning and repeated' + ); + + $this->assertFalse( + $this->_stringStartsWith->matches('Something else'), + 'should be false if excerpt is not in string' + ); + $this->assertFalse( + $this->_stringStartsWith->matches(substr(self::EXCERPT, 1)), + 'should be false if part of excerpt is at start of string' + ); + } + + public function testEvaluatesToTrueIfArgumentIsEqualToSubstring() + { + $this->assertTrue( + $this->_stringStartsWith->matches(self::EXCERPT), + 'should be true if excerpt is entire string' + ); + } + + public function testHasAReadableDescription() + { + $this->assertDescription('a string starting with "EXCERPT"', $this->_stringStartsWith); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsArrayTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsArrayTest.php new file mode 100644 index 000000000..d13c24d2c --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsArrayTest.php @@ -0,0 +1,35 @@ +assertDescription('an array', arrayValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', arrayValue(), null); + $this->assertMismatchDescription('was a string "foo"', arrayValue(), 'foo'); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsBooleanTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsBooleanTest.php new file mode 100644 index 000000000..24309fc09 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsBooleanTest.php @@ -0,0 +1,35 @@ +assertDescription('a boolean', booleanValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', booleanValue(), null); + $this->assertMismatchDescription('was a string "foo"', booleanValue(), 'foo'); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsCallableTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsCallableTest.php new file mode 100644 index 000000000..5098e21ba --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsCallableTest.php @@ -0,0 +1,103 @@ +=')) { + $this->markTestSkipped('Closures require php 5.3'); + } + eval('assertThat(function () {}, callableValue());'); + } + + public function testEvaluatesToTrueIfArgumentImplementsInvoke() + { + if (!version_compare(PHP_VERSION, '5.3', '>=')) { + $this->markTestSkipped('Magic method __invoke() requires php 5.3'); + } + assertThat($this, callableValue()); + } + + public function testEvaluatesToFalseIfArgumentIsInvalidFunctionName() + { + if (function_exists('not_a_Hamcrest_function')) { + $this->markTestSkipped('Function "not_a_Hamcrest_function" must not exist'); + } + + assertThat('not_a_Hamcrest_function', not(callableValue())); + } + + public function testEvaluatesToFalseIfArgumentIsInvalidStaticMethodCallback() + { + assertThat( + array('Hamcrest\Type\IsCallableTest', 'noMethod'), + not(callableValue()) + ); + } + + public function testEvaluatesToFalseIfArgumentIsInvalidInstanceMethodCallback() + { + assertThat(array($this, 'noMethod'), not(callableValue())); + } + + public function testEvaluatesToFalseIfArgumentDoesntImplementInvoke() + { + assertThat(new \stdClass(), not(callableValue())); + } + + public function testEvaluatesToFalseIfArgumentDoesntMatchType() + { + assertThat(false, not(callableValue())); + assertThat(5.2, not(callableValue())); + } + + public function testHasAReadableDescription() + { + $this->assertDescription('a callable', callableValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription( + 'was a string "invalid-function"', + callableValue(), + 'invalid-function' + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsDoubleTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsDoubleTest.php new file mode 100644 index 000000000..85c2a963c --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsDoubleTest.php @@ -0,0 +1,35 @@ +assertDescription('a double', doubleValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', doubleValue(), null); + $this->assertMismatchDescription('was a string "foo"', doubleValue(), 'foo'); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsIntegerTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsIntegerTest.php new file mode 100644 index 000000000..ce5a51a9f --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsIntegerTest.php @@ -0,0 +1,36 @@ +assertDescription('an integer', integerValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', integerValue(), null); + $this->assertMismatchDescription('was a string "foo"', integerValue(), 'foo'); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsNumericTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsNumericTest.php new file mode 100644 index 000000000..1fd83efe5 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsNumericTest.php @@ -0,0 +1,53 @@ +assertDescription('a number', numericValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', numericValue(), null); + $this->assertMismatchDescription('was a string "foo"', numericValue(), 'foo'); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsObjectTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsObjectTest.php new file mode 100644 index 000000000..a3b617c20 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsObjectTest.php @@ -0,0 +1,34 @@ +assertDescription('an object', objectValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', objectValue(), null); + $this->assertMismatchDescription('was a string "foo"', objectValue(), 'foo'); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsResourceTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsResourceTest.php new file mode 100644 index 000000000..d6ea53484 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsResourceTest.php @@ -0,0 +1,34 @@ +assertDescription('a resource', resourceValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', resourceValue(), null); + $this->assertMismatchDescription('was a string "foo"', resourceValue(), 'foo'); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsScalarTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsScalarTest.php new file mode 100644 index 000000000..72a188d67 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsScalarTest.php @@ -0,0 +1,39 @@ +assertDescription('a scalar', scalarValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', scalarValue(), null); + $this->assertMismatchDescription('was an array ["foo"]', scalarValue(), array('foo')); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsStringTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsStringTest.php new file mode 100644 index 000000000..557d5913a --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Type/IsStringTest.php @@ -0,0 +1,35 @@ +assertDescription('a string', stringValue()); + } + + public function testDecribesActualTypeInMismatchMessage() + { + $this->assertMismatchDescription('was null', stringValue(), null); + $this->assertMismatchDescription('was a double <5.2F>', stringValue(), 5.2); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/UtilTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/UtilTest.php new file mode 100644 index 000000000..0c2cd0433 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/UtilTest.php @@ -0,0 +1,80 @@ +assertSame($matcher, $newMatcher); + } + + public function testWrapValueWithIsEqualWrapsPrimitive() + { + $matcher = \Hamcrest\Util::wrapValueWithIsEqual('foo'); + $this->assertInstanceOf('Hamcrest\Core\IsEqual', $matcher); + $this->assertTrue($matcher->matches('foo')); + } + + public function testCheckAllAreMatchersAcceptsMatchers() + { + \Hamcrest\Util::checkAllAreMatchers(array( + new \Hamcrest\Text\MatchesPattern('/fo+/'), + new \Hamcrest\Core\IsEqual('foo'), + )); + } + + /** + * @expectedException InvalidArgumentException + */ + public function testCheckAllAreMatchersFailsForPrimitive() + { + \Hamcrest\Util::checkAllAreMatchers(array( + new \Hamcrest\Text\MatchesPattern('/fo+/'), + 'foo', + )); + } + + private function callAndAssertCreateMatcherArray($items) + { + $matchers = \Hamcrest\Util::createMatcherArray($items); + $this->assertInternalType('array', $matchers); + $this->assertSameSize($items, $matchers); + foreach ($matchers as $matcher) { + $this->assertInstanceOf('\Hamcrest\Matcher', $matcher); + } + + return $matchers; + } + + public function testCreateMatcherArrayLeavesMatchersUntouched() + { + $matcher = new \Hamcrest\Text\MatchesPattern('/fo+/'); + $items = array($matcher); + $matchers = $this->callAndAssertCreateMatcherArray($items); + $this->assertSame($matcher, $matchers[0]); + } + + public function testCreateMatcherArrayWrapsPrimitiveWithIsEqualMatcher() + { + $matchers = $this->callAndAssertCreateMatcherArray(array('foo')); + $this->assertInstanceOf('Hamcrest\Core\IsEqual', $matchers[0]); + $this->assertTrue($matchers[0]->matches('foo')); + } + + public function testCreateMatcherArrayDoesntModifyOriginalArray() + { + $items = array('foo'); + $this->callAndAssertCreateMatcherArray($items); + $this->assertSame('foo', $items[0]); + } + + public function testCreateMatcherArrayUnwrapsSingleArrayElement() + { + $matchers = $this->callAndAssertCreateMatcherArray(array(array('foo'))); + $this->assertInstanceOf('Hamcrest\Core\IsEqual', $matchers[0]); + $this->assertTrue($matchers[0]->matches('foo')); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Xml/HasXPathTest.php b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Xml/HasXPathTest.php new file mode 100644 index 000000000..677488716 --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/Hamcrest/Xml/HasXPathTest.php @@ -0,0 +1,198 @@ + + + + alice + Alice Frankel + admin + + + bob + Bob Frankel + user + + + charlie + Charlie Chan + user + + +XML; + self::$doc = new \DOMDocument(); + self::$doc->loadXML(self::$xml); + + self::$html = << + + Home Page + + +

Heading

+

Some text

+ + +HTML; + } + + protected function createMatcher() + { + return \Hamcrest\Xml\HasXPath::hasXPath('/users/user'); + } + + public function testMatchesWhenXPathIsFound() + { + assertThat('one match', self::$doc, hasXPath('user[id = "bob"]')); + assertThat('two matches', self::$doc, hasXPath('user[role = "user"]')); + } + + public function testDoesNotMatchWhenXPathIsNotFound() + { + assertThat( + 'no match', + self::$doc, + not(hasXPath('user[contains(id, "frank")]')) + ); + } + + public function testMatchesWhenExpressionWithoutMatcherEvaluatesToTrue() + { + assertThat( + 'one match', + self::$doc, + hasXPath('count(user[id = "bob"])') + ); + } + + public function testDoesNotMatchWhenExpressionWithoutMatcherEvaluatesToFalse() + { + assertThat( + 'no matches', + self::$doc, + not(hasXPath('count(user[id = "frank"])')) + ); + } + + public function testMatchesWhenExpressionIsEqual() + { + assertThat( + 'one match', + self::$doc, + hasXPath('count(user[id = "bob"])', 1) + ); + assertThat( + 'two matches', + self::$doc, + hasXPath('count(user[role = "user"])', 2) + ); + } + + public function testDoesNotMatchWhenExpressionIsNotEqual() + { + assertThat( + 'no match', + self::$doc, + not(hasXPath('count(user[id = "frank"])', 2)) + ); + assertThat( + 'one match', + self::$doc, + not(hasXPath('count(user[role = "admin"])', 2)) + ); + } + + public function testMatchesWhenContentMatches() + { + assertThat( + 'one match', + self::$doc, + hasXPath('user/name', containsString('ice')) + ); + assertThat( + 'two matches', + self::$doc, + hasXPath('user/role', equalTo('user')) + ); + } + + public function testDoesNotMatchWhenContentDoesNotMatch() + { + assertThat( + 'no match', + self::$doc, + not(hasXPath('user/name', containsString('Bobby'))) + ); + assertThat( + 'no matches', + self::$doc, + not(hasXPath('user/role', equalTo('owner'))) + ); + } + + public function testProvidesConvenientShortcutForHasXPathEqualTo() + { + assertThat('matches', self::$doc, hasXPath('count(user)', 3)); + assertThat('matches', self::$doc, hasXPath('user[2]/id', 'bob')); + } + + public function testProvidesConvenientShortcutForHasXPathCountEqualTo() + { + assertThat('matches', self::$doc, hasXPath('user[id = "charlie"]', 1)); + } + + public function testMatchesAcceptsXmlString() + { + assertThat('accepts XML string', self::$xml, hasXPath('user')); + } + + public function testMatchesAcceptsHtmlString() + { + assertThat('accepts HTML string', self::$html, hasXPath('body/h1', 'Heading')); + } + + public function testHasAReadableDescription() + { + $this->assertDescription( + 'XML or HTML document with XPath "/users/user"', + hasXPath('/users/user') + ); + $this->assertDescription( + 'XML or HTML document with XPath "count(/users/user)" <2>', + hasXPath('/users/user', 2) + ); + $this->assertDescription( + 'XML or HTML document with XPath "/users/user/name"' + . ' a string starting with "Alice"', + hasXPath('/users/user/name', startsWith('Alice')) + ); + } + + public function testHasAReadableMismatchDescription() + { + $this->assertMismatchDescription( + 'XPath returned no results', + hasXPath('/users/name'), + self::$doc + ); + $this->assertMismatchDescription( + 'XPath expression result was <3F>', + hasXPath('/users/user', 2), + self::$doc + ); + $this->assertMismatchDescription( + 'XPath returned ["alice", "bob", "charlie"]', + hasXPath('/users/user/id', 'Frank'), + self::$doc + ); + } +} diff --git a/vendor/hamcrest/hamcrest-php/tests/bootstrap.php b/vendor/hamcrest/hamcrest-php/tests/bootstrap.php new file mode 100644 index 000000000..bc4958d1f --- /dev/null +++ b/vendor/hamcrest/hamcrest-php/tests/bootstrap.php @@ -0,0 +1,11 @@ + + + + . + + + + + + ../hamcrest + + + diff --git a/vendor/johnpbloch/wordpress-core-installer/LICENSE.md b/vendor/johnpbloch/wordpress-core-installer/LICENSE.md new file mode 100644 index 000000000..23cb79033 --- /dev/null +++ b/vendor/johnpbloch/wordpress-core-installer/LICENSE.md @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + {description} + Copyright (C) {year} {fullname} + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + {signature of Ty Coon}, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/vendor/johnpbloch/wordpress-core-installer/composer.json b/vendor/johnpbloch/wordpress-core-installer/composer.json new file mode 100644 index 000000000..2d147a204 --- /dev/null +++ b/vendor/johnpbloch/wordpress-core-installer/composer.json @@ -0,0 +1,46 @@ +{ + "name": "johnpbloch/wordpress-core-installer", + "description": "A custom installer to handle deploying WordPress with composer", + "keywords": [ + "wordpress" + ], + "type": "composer-plugin", + "license": "GPL-2.0+", + "minimum-stability": "dev", + "prefer-stable": true, + "authors": [ + { + "name": "John P. Bloch", + "email": "me@johnpbloch.com" + } + ], + "autoload": { + "psr-0": { + "johnpbloch\\Composer\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Tests\\JohnPBloch\\Composer\\": "tests/" + } + }, + "extra": { + "class": "johnpbloch\\Composer\\WordPressCorePlugin" + }, + "require": { + "composer-plugin-api": "^1.0" + }, + "require-dev": { + "composer/composer": "^1.0", + "phpunit/phpunit": ">=4.8.35" + }, + "conflict": { + "composer/installers": "<1.0.6" + }, + "scripts": { + "test:phpunit": "phpunit", + "test": [ + "@test:phpunit" + ] + } +} diff --git a/vendor/johnpbloch/wordpress-core-installer/src/johnpbloch/Composer/WordPressCoreInstaller.php b/vendor/johnpbloch/wordpress-core-installer/src/johnpbloch/Composer/WordPressCoreInstaller.php new file mode 100644 index 000000000..bfbfe5546 --- /dev/null +++ b/vendor/johnpbloch/wordpress-core-installer/src/johnpbloch/Composer/WordPressCoreInstaller.php @@ -0,0 +1,111 @@ +getPrettyName(); + if ( $this->composer->getPackage() ) { + $topExtra = $this->composer->getPackage()->getExtra(); + if ( ! empty( $topExtra['wordpress-install-dir'] ) ) { + $installationDir = $topExtra['wordpress-install-dir']; + if ( is_array( $installationDir ) ) { + $installationDir = empty( $installationDir[ $prettyName ] ) ? false : $installationDir[ $prettyName ]; + } + } + } + $extra = $package->getExtra(); + if ( ! $installationDir && ! empty( $extra['wordpress-install-dir'] ) ) { + $installationDir = $extra['wordpress-install-dir']; + } + if ( ! $installationDir ) { + $installationDir = 'wordpress'; + } + $vendorDir = $this->composer->getConfig()->get( 'vendor-dir', Config::RELATIVE_PATHS ) ?: 'vendor'; + if ( + in_array( $installationDir, $this->sensitiveDirectories ) || + ( $installationDir === $vendorDir ) + ) { + throw new \InvalidArgumentException( $this->getSensitiveDirectoryMessage( $installationDir, $prettyName ) ); + } + if ( + ! empty( self::$_installedPaths[ $installationDir ] ) && + $prettyName !== self::$_installedPaths[ $installationDir ] + ) { + $conflict_message = $this->getConflictMessage( $prettyName, self::$_installedPaths[ $installationDir ] ); + throw new \InvalidArgumentException( $conflict_message ); + } + self::$_installedPaths[ $installationDir ] = $prettyName; + + return $installationDir; + } + + /** + * {@inheritDoc} + */ + public function supports( $packageType ) { + return self::TYPE === $packageType; + } + + /** + * Get the exception message with conflicting packages + * + * @param string $attempted + * @param string $alreadyExists + * + * @return string + */ + private function getConflictMessage( $attempted, $alreadyExists ) { + return sprintf( self::MESSAGE_CONFLICT, $attempted, $alreadyExists ); + } + + /** + * Get the exception message for attempted sensitive directories + * + * @param string $attempted + * @param string $packageName + * + * @return string + */ + private function getSensitiveDirectoryMessage( $attempted, $packageName ) { + return sprintf( self::MESSAGE_SENSITIVE, $attempted, $packageName ); + } + +} diff --git a/vendor/johnpbloch/wordpress-core-installer/src/johnpbloch/Composer/WordPressCorePlugin.php b/vendor/johnpbloch/wordpress-core-installer/src/johnpbloch/Composer/WordPressCorePlugin.php new file mode 100644 index 000000000..13d8c2f93 --- /dev/null +++ b/vendor/johnpbloch/wordpress-core-installer/src/johnpbloch/Composer/WordPressCorePlugin.php @@ -0,0 +1,41 @@ +getInstallationManager()->addInstaller( $installer ); + } + +} diff --git a/vendor/johnpbloch/wordpress/README.md b/vendor/johnpbloch/wordpress/README.md new file mode 100644 index 000000000..b6cc2bc6d --- /dev/null +++ b/vendor/johnpbloch/wordpress/README.md @@ -0,0 +1,6 @@ +# WordPress Composer Fork + +If you're looking for more information on using composer and WordPress together, go check out http://composer.rarst.net + +If you're looking for WordPress core, the core package is now at https://github.com/johnpbloch/wordpress-core + diff --git a/vendor/johnpbloch/wordpress/composer.json b/vendor/johnpbloch/wordpress/composer.json new file mode 100644 index 000000000..60ea6528b --- /dev/null +++ b/vendor/johnpbloch/wordpress/composer.json @@ -0,0 +1,30 @@ +{ + "name": "johnpbloch/wordpress", + "description": "WordPress is web software you can use to create a beautiful website or blog.", + "keywords": [ + "wordpress", + "blog", + "cms" + ], + "type": "package", + "homepage": "http://wordpress.org/", + "license": "GPL-2.0+", + "authors": [ + { + "name": "WordPress Community", + "homepage": "http://wordpress.org/about/" + } + ], + "support": { + "issues": "http://core.trac.wordpress.org/", + "forum": "http://wordpress.org/support/", + "wiki": "http://codex.wordpress.org/", + "irc": "irc://irc.freenode.net/wordpress", + "source": "http://core.trac.wordpress.org/browser" + }, + "require": { + "php": ">=5.3.2", + "johnpbloch/wordpress-core-installer": "^1.0", + "johnpbloch/wordpress-core": "4.9.8" + } +} diff --git a/vendor/mockery/mockery/.gitignore b/vendor/mockery/mockery/.gitignore new file mode 100644 index 000000000..062facccd --- /dev/null +++ b/vendor/mockery/mockery/.gitignore @@ -0,0 +1,15 @@ +*~ +pearfarm.spec +*.sublime-project +library/Hamcrest/* +composer.lock +vendor/ +composer.phar +test.php +build/ +phpunit.xml +*.DS_store +.idea/* +.php_cs.cache +docs/api +phpDocumentor.phar* diff --git a/vendor/mockery/mockery/.php_cs b/vendor/mockery/mockery/.php_cs new file mode 100644 index 000000000..be098ba38 --- /dev/null +++ b/vendor/mockery/mockery/.php_cs @@ -0,0 +1,30 @@ +in([ + 'library', + 'tests', + ]); + + return PhpCsFixer\Config::create() + ->setRules(array( + '@PSR2' => true, + )) + ->setUsingCache(true) + ->setFinder($finder) + ; +} + +$finder = DefaultFinder::create()->in( + [ + 'library', + 'tests', + ]); + +return Config::create() + ->level('psr2') + ->setUsingCache(true) + ->finder($finder); diff --git a/vendor/mockery/mockery/.phpstorm.meta.php b/vendor/mockery/mockery/.phpstorm.meta.php new file mode 100644 index 000000000..6c53f80cd --- /dev/null +++ b/vendor/mockery/mockery/.phpstorm.meta.php @@ -0,0 +1,11 @@ +> ~/.phpenv/versions/"$(phpenv version-name)"/etc/conf.d/travis.ini + fi + +script: +- | + if [[ $TRAVIS_PHP_VERSION = 5.* ]]; then + ./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite PHP56"; + else + ./vendor/bin/phpunit --coverage-text --coverage-clover="build/logs/clover.xml" --testsuite="Mockery Test Suite"; + fi + +after_success: + - composer require satooshi/php-coveralls + - vendor/bin/coveralls -v + - wget https://scrutinizer-ci.com/ocular.phar + - php ocular.phar code-coverage:upload --format=php-clover "build/logs/clover.xml" + - make apidocs + +notifications: + email: + - padraic.brady@gmail.com + - dave@atstsolutions.co.uk + + irc: irc.freenode.org#mockery +deploy: + overwrite: true + provider: pages + file_glob: true + file: docs/api/* + local_dir: docs/api + skip_cleanup: true + github_token: $GITHUB_TOKEN + on: + branch: master + php: '7.1' + condition: $DEPS = latest diff --git a/vendor/mockery/mockery/CHANGELOG.md b/vendor/mockery/mockery/CHANGELOG.md new file mode 100644 index 000000000..ba8a3e67a --- /dev/null +++ b/vendor/mockery/mockery/CHANGELOG.md @@ -0,0 +1,106 @@ +# Change Log + +## x.y.z (unreleased) + +## 1.2.0 (2018-10-02) + +* Starts counting default expectations towards count (#910) +* Adds workaround for some HHVM return types (#909) +* Adds PhpStorm metadata support for autocomplete etc (#904) +* Further attempts to support multiple PHPUnit versions (#903) +* Allows setting constructor expectations on instance mocks (#900) +* Adds workaround for HHVM memoization decorator (#893) +* Adds experimental support for callable spys (#712) + +## 1.1.0 (2018-05-08) + +* Allows use of string method names in allows and expects (#794) +* Finalises allows and expects syntax in API (#799) +* Search for handlers in a case instensitive way (#801) +* Deprecate allowMockingMethodsUnnecessarily (#808) +* Fix risky tests (#769) +* Fix namespace in TestListener (#812) +* Fixed conflicting mock names (#813) +* Clean elses (#819) +* Updated protected method mocking exception message (#826) +* Map of constants to mock (#829) +* Simplify foreach with `in_array` function (#830) +* Typehinted return value on Expectation#verify. (#832) +* Fix shouldNotHaveReceived with HigherOrderMessage (#842) +* Deprecates shouldDeferMissing (#839) +* Adds support for return type hints in Demeter chains (#848) +* Adds shouldNotReceive to composite expectation (#847) +* Fix internal error when using --static-backup (#845) +* Adds `andAnyOtherArgs` as an optional argument matcher (#860) +* Fixes namespace qualifying with namespaced named mocks (#872) +* Added possibility to add Constructor-Expections on hard dependencies, read: Mockery::mock('overload:...') (#781) + +## 1.0.0 (2017-09-06) + +* Destructors (`__destruct`) are stubbed out where it makes sense +* Allow passing a closure argument to `withArgs()` to validate multiple arguments at once. +* `Mockery\Adapter\Phpunit\TestListener` has been rewritten because it + incorrectly marked some tests as risky. It will no longer verify mock + expectations but instead check that tests do that themselves. PHPUnit 6 is + required if you want to use this fail safe. +* Removes SPL Class Loader +* Removed object recorder feature +* Bumped minimum PHP version to 5.6 +* `andThrow` will now throw anything `\Throwable` +* Adds `allows` and `expects` syntax +* Adds optional global helpers for `mock`, `namedMock` and `spy` +* Adds ability to create objects using traits +* `Mockery\Matcher\MustBe` was deprecated +* Marked `Mockery\MockInterface` as internal +* Subset matcher matches recursively +* BC BREAK - Spies return `null` by default from ignored (non-mocked) methods with nullable return type +* Removed extracting getter methods of object instances +* BC BREAK - Remove implicit regex matching when trying to match string arguments, introduce `\Mockery::pattern()` when regex matching is needed +* Fix Mockery not getting closed in cases of failing test cases +* Fix Mockery not setting properties on overloaded instance mocks +* BC BREAK - Fix Mockery not trying default expectations if there is any concrete expectation +* BC BREAK - Mockery's PHPUnit integration will mark a test as risky if it + thinks one it's exceptions has been swallowed in PHPUnit > 5.7.6. Use `$e->dismiss()` to dismiss. + +## 0.9.4 (XXXX-XX-XX) + +* `shouldIgnoreMissing` will respect global `allowMockingNonExistentMethods` + config +* Some support for variadic parameters +* Hamcrest is now a required dependency +* Instance mocks now respect `shouldIgnoreMissing` call on control instance +* This will be the *last version to support PHP 5.3* +* Added `Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration` trait +* Added `makePartial` to `Mockery\MockInterface` as it was missing + +## 0.9.3 (2014-12-22) + +* Added a basic spy implementation +* Added `Mockery\Adapter\Phpunit\MockeryTestCase` for more reliable PHPUnit + integration + +## 0.9.2 (2014-09-03) + +* Some workarounds for the serialisation problems created by changes to PHP in 5.5.13, 5.4.29, + 5.6. +* Demeter chains attempt to reuse doubles as they see fit, so for foo->bar and + foo->baz, we'll attempt to use the same foo + +## 0.9.1 (2014-05-02) + +* Allow specifying consecutive exceptions to be thrown with `andThrowExceptions` +* Allow specifying methods which can be mocked when using + `Mockery\Configuration::allowMockingNonExistentMethods(false)` with + `Mockery\MockInterface::shouldAllowMockingMethod($methodName)` +* Added andReturnSelf method: `$mock->shouldReceive("foo")->andReturnSelf()` +* `shouldIgnoreMissing` now takes an optional value that will be return instead + of null, e.g. `$mock->shouldIgnoreMissing($mock)` + +## 0.9.0 (2014-02-05) + +* Allow mocking classes with final __wakeup() method +* Quick definitions are now always `byDefault` +* Allow mocking of protected methods with `shouldAllowMockingProtectedMethods` +* Support official Hamcrest package +* Generator completely rewritten +* Easily create named mocks with namedMock diff --git a/vendor/mockery/mockery/CONTRIBUTING.md b/vendor/mockery/mockery/CONTRIBUTING.md new file mode 100644 index 000000000..b714f3f44 --- /dev/null +++ b/vendor/mockery/mockery/CONTRIBUTING.md @@ -0,0 +1,88 @@ +# Contributing + + +We'd love you to help out with mockery and no contribution is too small. + + +## Reporting Bugs + +Issues can be reported on the [issue +tracker](https://github.com/padraic/mockery/issues). Please try and report any +bugs with a minimal reproducible example, it will make things easier for other +contributors and your problems will hopefully be resolved quickly. + + +## Requesting Features + +We're always interested to hear about your ideas and you can request features by +creating a ticket in the [issue +tracker](https://github.com/padraic/mockery/issues). We can't always guarantee +someone will jump on it straight away, but putting it out there to see if anyone +else is interested is a good idea. + +Likewise, if a feature you would like is already listed in +the issue tracker, add a :+1: so that other contributors know it's a feature +that would help others. + + +## Contributing code and documentation + +We loosely follow the +[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) coding standards, +but we'll probably merge any code that looks close enough. + +* Fork the [repository](https://github.com/padraic/mockery) on GitHub +* Add the code for your feature or bug +* Add some tests for your feature or bug +* Optionally, but preferably, write some documentation +* Optionally, update the CHANGELOG.md file with your feature or + [BC](http://en.wikipedia.org/wiki/Backward_compatibility) break +* Send a [Pull + Request](https://help.github.com/articles/creating-a-pull-request) to the + correct target branch (see below) + +If you have a big change or would like to discuss something, create an issue in +the [issue tracker](https://github.com/padraic/mockery/issues) or jump in to +\#mockery on freenode + + +Any code you contribute must be licensed under the [BSD 3-Clause +License](http://opensource.org/licenses/BSD-3-Clause). + + +## Target Branch + +Mockery may have several active branches at any one time and roughly follows a +[Git Branching Model](https://igor.io/2013/10/21/git-branching-model.html). +Generally, if you're developing a new feature, you want to be targeting the +master branch, if it's a bug fix, you want to be targeting a release branch, +e.g. 0.8. + + +## Testing Mockery + +To run the unit tests for Mockery, clone the git repository, download Composer using +the instructions at [http://getcomposer.org/download/](http://getcomposer.org/download/), +then install the dependencies with `php /path/to/composer.phar install`. + +This will install the required PHPUnit and Hamcrest dev dependencies and create the +autoload files required by the unit tests. You may run the `vendor/bin/phpunit` command +to run the unit tests. If everything goes to plan, there will be no failed tests! + + +## Debugging Mockery + +Mockery and its code generation can be difficult to debug. A good start is to +use the `RequireLoader`, which will dump the code generated by mockery to a file +before requiring it, rather than using eval. This will help with stack traces, +and you will be able to open the mock class in your editor. + +``` php + +// tests/bootstrap.php + +Mockery::setLoader(new Mockery\Loader\RequireLoader(sys_get_temp_dir())); + +``` diff --git a/vendor/mockery/mockery/LICENSE b/vendor/mockery/mockery/LICENSE new file mode 100644 index 000000000..2e127a651 --- /dev/null +++ b/vendor/mockery/mockery/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2010, Pádraic Brady +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * The name of Pádraic Brady may not be used to endorse or promote + products derived from this software without specific prior written + permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/mockery/mockery/Makefile b/vendor/mockery/mockery/Makefile new file mode 100644 index 000000000..c312f705e --- /dev/null +++ b/vendor/mockery/mockery/Makefile @@ -0,0 +1,52 @@ +vendor/composer/installed.json: composer.json + composer install + +.PHONY: deps +deps: vendor/composer/installed.json + +.PHONY: test +test: deps + php vendor/bin/phpunit + +.PHONY: apidocs +apidocs: docs/api/index.html + +phpDocumentor.phar: + wget https://github.com/phpDocumentor/phpDocumentor2/releases/download/v3.0.0-alpha.2-nightly-gdff5545/phpDocumentor.phar + wget https://github.com/phpDocumentor/phpDocumentor2/releases/download/v3.0.0-alpha.2-nightly-gdff5545/phpDocumentor.phar.pubkey + +library_files=$(shell find library -name '*.php') +docs/api/index.html: vendor/composer/installed.json $(library_files) phpDocumentor.phar + php phpDocumentor.phar run -d library -t docs/api + +.PHONY: test-all +test-all: test-72 test-71 test-70 test-56 + +.PHONY: test-all-7 +test-all-7: test-72 test-71 test-70 + +.PHONY: test-72 +test-72: deps + docker run -it --rm -v "$$PWD":/opt/mockery -w /opt/mockery php:7.2-cli php vendor/bin/phpunit + +.PHONY: test-71 +test-71: deps + docker run -it --rm -v "$$PWD":/opt/mockery -w /opt/mockery php:7.1-cli php vendor/bin/phpunit + +.PHONY: test-70 +test-70: deps + docker run -it --rm -v "$$PWD":/opt/mockery -w /opt/mockery php:7.0-cli php vendor/bin/phpunit + +.PHONY: test-56 +test-56: build56 + docker run -it --rm \ + -v "$$PWD/library":/opt/mockery/library \ + -v "$$PWD/tests":/opt/mockery/tests \ + -v "$$PWD/phpunit.xml.dist":/opt/mockery/phpunit.xml \ + -w /opt/mockery \ + mockery_php56 \ + php vendor/bin/phpunit + +.PHONY: build56 +build56: + docker build -t mockery_php56 -f "$$PWD/docker/php56/Dockerfile" . diff --git a/vendor/mockery/mockery/README.md b/vendor/mockery/mockery/README.md new file mode 100644 index 000000000..b346f4b0c --- /dev/null +++ b/vendor/mockery/mockery/README.md @@ -0,0 +1,299 @@ +Mockery +======= + +[![Build Status](https://travis-ci.org/mockery/mockery.svg?branch=master)](https://travis-ci.org/mockery/mockery) +[![Latest Stable Version](https://poser.pugx.org/mockery/mockery/v/stable.svg)](https://packagist.org/packages/mockery/mockery) +[![Coverage Status](https://coveralls.io/repos/github/mockery/mockery/badge.svg)](https://coveralls.io/github/mockery/mockery) +[![Total Downloads](https://poser.pugx.org/mockery/mockery/downloads.svg)](https://packagist.org/packages/mockery/mockery) + +Mockery is a simple yet flexible PHP mock object framework for use in unit testing +with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a +test double framework with a succinct API capable of clearly defining all possible +object operations and interactions using a human readable Domain Specific Language +(DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, +Mockery is easy to integrate with PHPUnit and can operate alongside +phpunit-mock-objects without the World ending. + +Mockery is released under a New BSD License. + +## Installation + +To install Mockery, run the command below and you will get the latest +version + +```sh +composer require --dev mockery/mockery +``` + +## Documentation + +In older versions, this README file was the documentation for Mockery. Over time +we have improved this, and have created an extensive documentation for you. Please +use this README file as a starting point for Mockery, but do read the documentation +to learn how to use Mockery. + +The current version can be seen at [docs.mockery.io](http://docs.mockery.io). + +## Test Doubles + +Test doubles (often called mocks) simulate the behaviour of real objects. They are +commonly utilised to offer test isolation, to stand in for objects which do not +yet exist, or to allow for the exploratory design of class APIs without +requiring actual implementation up front. + +The benefits of a test double framework are to allow for the flexible generation +and configuration of test doubles. They allow the setting of expected method calls +and/or return values using a flexible API which is capable of capturing every +possible real object behaviour in way that is stated as close as possible to a +natural language description. Use the `Mockery::mock` method to create a test +double. + +``` php +$double = Mockery::mock(); +``` + +If you need Mockery to create a test double to satisfy a particular type hint, +you can pass the type to the `mock` method. + +``` php +class Book {} + +interface BookRepository { + function find($id): Book; + function findAll(): array; + function add(Book $book): void; +} + +$double = Mockery::mock(BookRepository::class); +``` + +A detailed explanation of creating and working with test doubles is given in the +documentation, [Creating test doubles](http://docs.mockery.io/en/latest/reference/creating_test_doubles.html) +section. + +## Method Stubs 🎫 + +A method stub is a mechanism for having your test double return canned responses +to certain method calls. With stubs, you don't care how many times, if at all, +the method is called. Stubs are used to provide indirect input to the system +under test. + +``` php +$double->allows()->find(123)->andReturns(new Book()); + +$book = $double->find(123); +``` + +If you have used Mockery before, you might see something new in the example +above — we created a method stub using `allows`, instead of the "old" +`shouldReceive` syntax. This is a new feature of Mockery v1, but fear not, +the trusty ol' `shouldReceive` is still here. + +For new users of Mockery, the above example can also be written as: + +``` php +$double->shouldReceive('find')->with(123)->andReturn(new Book()); +$book = $double->find(123); +``` + +If your stub doesn't require specific arguments, you can also use this shortcut +for setting up multiple calls at once: + +``` php +$double->allows([ + "findAll" => [new Book(), new Book()], +]); +``` + +or + +``` php +$double->shouldReceive('findAll') + ->andReturn([new Book(), new Book()]); +``` + +You can also use this shortcut, which creates a double and sets up some stubs in +one call: + +``` php +$double = Mockery::mock(BookRepository::class, [ + "findAll" => [new Book(), new Book()], +]); +``` + +## Method Call Expectations 📲 + +A Method call expectation is a mechanism to allow you to verify that a +particular method has been called. You can specify the parameters and you can +also specify how many times you expect it to be called. Method call expectations +are used to verify indirect output of the system under test. + +``` php +$book = new Book(); + +$double = Mockery::mock(BookRepository::class); +$double->expects()->add($book); +``` + +During the test, Mockery accept calls to the `add` method as prescribed. +After you have finished exercising the system under test, you need to +tell Mockery to check that the method was called as expected, using the +`Mockery::close` method. One way to do that is to add it to your `tearDown` +method in PHPUnit. + +``` php + +public function tearDown() +{ + Mockery::close(); +} +``` + +The `expects()` method automatically sets up an expectation that the method call +(and matching parameters) is called **once and once only**. You can choose to change +this if you are expecting more calls. + +``` php +$double->expects()->add($book)->twice(); +``` + +If you have used Mockery before, you might see something new in the example +above — we created a method expectation using `expects`, instead of the "old" +`shouldReceive` syntax. This is a new feature of Mockery v1, but same as with +`accepts` in the previous section, it can be written in the "old" style. + +For new users of Mockery, the above example can also be written as: + +``` php +$double->shouldReceive('find') + ->with(123) + ->once() + ->andReturn(new Book()); +$book = $double->find(123); +``` + +A detailed explanation of declaring expectations on method calls, please +read the documentation, the [Expectation declarations](http://docs.mockery.io/en/latest/reference/expectations.html) +section. After that, you can also learn about the new `allows` and `expects` methods +in the [Alternative shouldReceive syntax](http://docs.mockery.io/en/latest/reference/alternative_should_receive_syntax.html) +section. + +It is worth mentioning that one way of setting up expectations is no better or worse +than the other. Under the hood, `allows` and `expects` are doing the same thing as +`shouldReceive`, at times in "less words", and as such it comes to a personal preference +of the programmer which way to use. + +## Test Spies 🕵️ + +By default, all test doubles created with the `Mockery::mock` method will only +accept calls that they have been configured to `allow` or `expect` (or in other words, +calls that they `shouldReceive`). Sometimes we don't necessarily care about all of the +calls that are going to be made to an object. To facilitate this, we can tell Mockery +to ignore any calls it has not been told to expect or allow. To do so, we can tell a +test double `shouldIgnoreMissing`, or we can create the double using the `Mocker::spy` +shortcut. + +``` php +// $double = Mockery::mock()->shouldIgnoreMissing(); +$double = Mockery::spy(); + +$double->foo(); // null +$double->bar(); // null +``` + +Further to this, sometimes we want to have the object accept any call during the test execution +and then verify the calls afterwards. For these purposes, we need our test +double to act as a Spy. All mockery test doubles record the calls that are made +to them for verification afterwards by default: + +``` php +$double->baz(123); + +$double->shouldHaveReceived()->baz(123); // null +$double->shouldHaveReceived()->baz(12345); // Uncaught Exception Mockery\Exception\InvalidCountException... +``` + +Please refer to the [Spies](http://docs.mockery.io/en/latest/reference/spies.html) section +of the documentation to learn more about the spies. + +## Utilities 🔌 + +### Global Helpers + +Mockery ships with a handful of global helper methods, you just need to ask +Mockery to declare them. + +``` php +Mockery::globalHelpers(); + +$mock = mock(Some::class); +$spy = spy(Some::class); + +$spy->shouldHaveReceived() + ->foo(anyArgs()); +``` + +All of the global helpers are wrapped in a `!function_exists` call to avoid +conflicts. So if you already have a global function called `spy`, Mockery will +silently skip the declaring its own `spy` function. + +### Testing Traits + +As Mockery ships with code generation capabilities, it was trivial to add +functionality allowing users to create objects on the fly that use particular +traits. Any abstract methods defined by the trait will be created and can have +expectations or stubs configured like normal Test Doubles. + +``` php +trait Foo { + function foo() { + return $this->doFoo(); + } + + abstract function doFoo(); +} + +$double = Mockery::mock(Foo::class); +$double->allows()->doFoo()->andReturns(123); +$double->foo(); // int(123) +``` + +### Testing the constructor arguments of hard Dependencies + +See [Mocking hard dependencies](http://docs.mockery.io/en/latest/cookbook/mocking_hard_dependencies.html) + +``` php +$implementationMock = Mockery::mock('overload:\Some\Implementation'); + +$implementationMock->shouldReceive('__construct') + ->once() + ->with(['host' => 'localhost]); +// add other expectations as usual + +$implementation = new \Some\Implementation(['host' => 'localhost']); +``` + +## Versioning + +The Mockery team attempts to adhere to [Semantic Versioning](http://semver.org), +however, some of Mockery's internals are considered private and will be open to +change at any time. Just because a class isn't final, or a method isn't marked +private, does not mean it constitutes part of the API we guarantee under the +versioning scheme. + +### Alternative Runtimes + +Mockery will attempt to continue support HHVM, but will not make any guarantees. + +## A new home for Mockery + +⚠️️ Update your remotes! Mockery has transferred to a new location. While it was once +at `padraic/mockery`, it is now at `mockery/mockery`. While your +existing repositories will redirect transparently for any operations, take some +time to transition to the new URL. +```sh +$ git remote set-url upstream https://github.com/mockery/mockery.git +``` +Replace `upstream` with the name of the remote you use locally; `upstream` is commonly +used but you may be using something else. Run `git remote -v` to see what you're actually +using. diff --git a/vendor/mockery/mockery/composer.json b/vendor/mockery/mockery/composer.json new file mode 100644 index 000000000..4d7c96c29 --- /dev/null +++ b/vendor/mockery/mockery/composer.json @@ -0,0 +1,56 @@ +{ + "name": "mockery/mockery", + "description": "Mockery is a simple yet flexible PHP mock object framework", + "scripts": { + "docs": "phpdoc -d library -t docs/api" + }, + "keywords": [ + "bdd", + "library", + "mock", + "mock objects", + "mockery", + "stub", + "tdd", + "test", + "test double", + "testing" + ], + "homepage": "https://github.com/mockery/mockery", + "license": "BSD-3-Clause", + "authors": [ + { + "name": "Pádraic Brady", + "email": "padraic.brady@gmail.com", + "homepage": "http://blog.astrumfutura.com" + }, + { + "name": "Dave Marshall", + "email": "dave.marshall@atstsolutions.co.uk", + "homepage": "http://davedevelopment.co.uk" + } + ], + "require": { + "php": ">=5.6.0", + "lib-pcre": ">=7.0", + "hamcrest/hamcrest-php": "~2.0" + }, + "require-dev": { + "phpunit/phpunit": "~5.7.10|~6.5|~7.0" + }, + "autoload": { + "psr-0": { + "Mockery": "library/" + } + }, + "autoload-dev": { + "psr-4": { + "test\\": "tests/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/vendor/mockery/mockery/docker/php56/Dockerfile b/vendor/mockery/mockery/docker/php56/Dockerfile new file mode 100644 index 000000000..264c5c036 --- /dev/null +++ b/vendor/mockery/mockery/docker/php56/Dockerfile @@ -0,0 +1,14 @@ +FROM php:5.6-cli + +RUN apt-get update && \ + apt-get install -y git zip unzip && \ + apt-get -y autoremove && \ + apt-get clean && \ + curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +WORKDIR /opt/mockery + +COPY composer.json ./ + +RUN composer install diff --git a/vendor/mockery/mockery/docs/.gitignore b/vendor/mockery/mockery/docs/.gitignore new file mode 100644 index 000000000..e35d8850c --- /dev/null +++ b/vendor/mockery/mockery/docs/.gitignore @@ -0,0 +1 @@ +_build diff --git a/vendor/mockery/mockery/docs/Makefile b/vendor/mockery/mockery/docs/Makefile new file mode 100644 index 000000000..9a8c94087 --- /dev/null +++ b/vendor/mockery/mockery/docs/Makefile @@ -0,0 +1,177 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = _build + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/MockeryDocs.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/MockeryDocs.qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/MockeryDocs" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/MockeryDocs" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." diff --git a/vendor/mockery/mockery/docs/README.md b/vendor/mockery/mockery/docs/README.md new file mode 100644 index 000000000..63ca69db7 --- /dev/null +++ b/vendor/mockery/mockery/docs/README.md @@ -0,0 +1,4 @@ +mockery-docs +============ + +Document for the PHP Mockery framework on readthedocs.org \ No newline at end of file diff --git a/vendor/mockery/mockery/docs/conf.py b/vendor/mockery/mockery/docs/conf.py new file mode 100644 index 000000000..901f04056 --- /dev/null +++ b/vendor/mockery/mockery/docs/conf.py @@ -0,0 +1,267 @@ +# -*- coding: utf-8 -*- +# +# Mockery Docs documentation build configuration file, created by +# sphinx-quickstart on Mon Mar 3 14:04:26 2014. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import os + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +#sys.path.insert(0, os.path.abspath('.')) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.todo', +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +#source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = u'Mockery Docs' +copyright = u'Pádraic Brady, Dave Marshall and contributors' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '1.0' +# The full version, including alpha/beta/rc tags. +release = '1.0-alpha' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +#language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ['_build'] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + +# A list of ignored prefixes for module index sorting. +#modindex_common_prefix = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'default' + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +#html_theme_options = {} + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = [] + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +#html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +#html_domain_indices = True + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, links to the reST sources are added to the pages. +#html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +#html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +#html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = None + +# Output file base name for HTML help builder. +htmlhelp_basename = 'MockeryDocsdoc' + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { +# The paper size ('letterpaper' or 'a4paper'). +#'papersize': 'letterpaper', + +# The font size ('10pt', '11pt' or '12pt'). +#'pointsize': '10pt', + +# Additional stuff for the LaTeX preamble. +#'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ('index', 'MockeryDocs.tex', u'Mockery Docs Documentation', + u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell', 'manual'), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +#latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = False + +# If true, show page references after internal links. +#latex_show_pagerefs = False + +# If true, show URL addresses after external links. +#latex_show_urls = False + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +#latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [ + ('index', 'mockerydocs', u'Mockery Docs Documentation', + [u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell'], 1) +] + +# If true, show URL addresses after external links. +#man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ('index', 'MockeryDocs', u'Mockery Docs Documentation', + u'Pádraic Brady, Dave Marshall, Wouter, Graham Campbell', 'MockeryDocs', 'One line description of project.', + 'Miscellaneous'), +] + +# Documents to append as an appendix to all manuals. +#texinfo_appendices = [] + +# If false, no module index is generated. +#texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +#texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +#texinfo_no_detailmenu = False + + +#on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org +on_rtd = os.environ.get('READTHEDOCS', None) == 'True' + +if not on_rtd: # only import and set the theme if we're building docs locally + import sphinx_rtd_theme + html_theme = 'sphinx_rtd_theme' + html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] + print sphinx_rtd_theme.get_html_theme_path() + +# load PhpLexer +from sphinx.highlighting import lexers +from pygments.lexers.web import PhpLexer + +# enable highlighting for PHP code not between by default +lexers['php'] = PhpLexer(startinline=True) +lexers['php-annotations'] = PhpLexer(startinline=True) diff --git a/vendor/mockery/mockery/docs/cookbook/big_parent_class.rst b/vendor/mockery/mockery/docs/cookbook/big_parent_class.rst new file mode 100644 index 000000000..a27d5327c --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/big_parent_class.rst @@ -0,0 +1,52 @@ +.. index:: + single: Cookbook; Big Parent Class + +Big Parent Class +================ + +In some application code, especially older legacy code, we can come across some +classes that extend a "big parent class" - a parent class that knows and does +too much: + +.. code-block:: php + + class BigParentClass + { + public function doesEverything() + { + // sets up database connections + // writes to log files + } + } + + class ChildClass extends BigParentClass + { + public function doesOneThing() + { + // but calls on BigParentClass methods + $result = $this->doesEverything(); + // does something with $result + return $result; + } + } + +We want to test our ``ChildClass`` and its ``doesOneThing`` method, but the +problem is that it calls on ``BigParentClass::doesEverything()``. One way to +handle this would be to mock out **all** of the dependencies ``BigParentClass`` +has and needs, and then finally actually test our ``doesOneThing`` method. It's +an awful lot of work to do that. + +What we can do, is to do something... unconventional. We can create a runtime +partial test double of the ``ChildClass`` itself and mock only the parent's +``doesEverything()`` method: + +.. code-block:: php + + $childClass = \Mockery::mock('ChildClass')->makePartial(); + $childClass->shouldReceive('doesEverything') + ->andReturn('some result from parent'); + + $childClass->doesOneThing(); // string("some result from parent"); + +With this approach we mock out only the ``doesEverything()`` method, and all the +unmocked methods are called on the actual ``ChildClass`` instance. diff --git a/vendor/mockery/mockery/docs/cookbook/class_constants.rst b/vendor/mockery/mockery/docs/cookbook/class_constants.rst new file mode 100644 index 000000000..0d13dd207 --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/class_constants.rst @@ -0,0 +1,183 @@ +.. index:: + single: Cookbook; Class Constants + +Class Constants +=============== + +When creating a test double for a class, Mockery does not create stubs out of +any class constants defined in the class we are mocking. Sometimes though, the +non-existence of these class constants, setup of the test, and the application +code itself, it can lead to undesired behavior, and even a PHP error: +``PHP Fatal error: Uncaught Error: Undefined class constant 'FOO' in ...``` + +While supporting class constants in Mockery would be possible, it does require +an awful lot of work, for a small number of use cases. + +Named Mocks +----------- + +We can, however, deal with these constants in a way supported by Mockery - by +using :ref:`creating-test-doubles-named-mocks`. + +A named mock is a test double that has a name of the class we want to mock, but +under it is a stubbed out class that mimics the real class with canned responses. + +Lets look at the following made up, but not impossible scenario: + +.. code-block:: php + + class Fetcher + { + const SUCCESS = 0; + const FAILURE = 1; + + public static function fetch() + { + // Fetcher gets something for us from somewhere... + return self::SUCCESS; + } + } + + class MyClass + { + public function doFetching() + { + $response = Fetcher::fetch(); + + if ($response == Fetcher::SUCCESS) { + echo "Thanks!" . PHP_EOL; + } else { + echo "Try again!" . PHP_EOL; + } + } + } + +Our ``MyClass`` calls a ``Fetcher`` that fetches some resource from somewhere - +maybe it downloads a file from a remote web service. Our ``MyClass`` prints out +a response message depending on the response from the ``Fetcher::fetch()`` call. + +When testing ``MyClass`` we don't really want ``Fetcher`` to go and download +random stuff from the internet every time we run our test suite. So we mock it +out: + +.. code-block:: php + + // Using alias: because fetch is called statically! + \Mockery::mock('alias:Fetcher') + ->shouldReceive('fetch') + ->andReturn(0); + + $myClass = new MyClass(); + $myClass->doFetching(); + +If we run this, our test will error out with a nasty +``PHP Fatal error: Uncaught Error: Undefined class constant 'SUCCESS' in ..``. + +Here's how a ``namedMock()`` can help us in a situation like this. + +We create a stub for the ``Fetcher`` class, stubbing out the class constants, +and then use ``namedMock()`` to create a mock named ``Fetcher`` based on our +stub: + +.. code-block:: php + + class FetcherStub + { + const SUCCESS = 0; + const FAILURE = 1; + } + + \Mockery::mock('Fetcher', 'FetcherStub') + ->shouldReceive('fetch') + ->andReturn(0); + + $myClass = new MyClass(); + $myClass->doFetching(); + +This works because under the hood, Mockery creates a class called ``Fetcher`` +that extends ``FetcherStub``. + +The same approach will work even if ``Fetcher::fetch()`` is not a static +dependency: + +.. code-block:: php + + class Fetcher + { + const SUCCESS = 0; + const FAILURE = 1; + + public function fetch() + { + // Fetcher gets something for us from somewhere... + return self::SUCCESS; + } + } + + class MyClass + { + public function doFetching($fetcher) + { + $response = $fetcher->fetch(); + + if ($response == Fetcher::SUCCESS) { + echo "Thanks!" . PHP_EOL; + } else { + echo "Try again!" . PHP_EOL; + } + } + } + +And the test will have something like this: + +.. code-block:: php + + class FetcherStub + { + const SUCCESS = 0; + const FAILURE = 1; + } + + $mock = \Mockery::mock('Fetcher', 'FetcherStub') + $mock->shouldReceive('fetch') + ->andReturn(0); + + $myClass = new MyClass(); + $myClass->doFetching($mock); + + +Constants Map +------------- + +Another way of mocking class constants can be with the use of the constants map configuration. + +Given a class with constants: + +.. code-block:: php + + class Fetcher + { + const SUCCESS = 0; + const FAILURE = 1; + + public function fetch() + { + // Fetcher gets something for us from somewhere... + return self::SUCCESS; + } + } + +It can be mocked with: + +.. code-block:: php + + \Mockery::getConfiguration()->setConstantsMap([ + 'Fetcher' => [ + 'SUCCESS' => 'success', + 'FAILURE' => 'fail', + ] + ]); + + $mock = \Mockery::mock('Fetcher'); + var_dump($mock::SUCCESS); // (string) 'success' + var_dump($mock::FAILURE); // (string) 'fail' diff --git a/vendor/mockery/mockery/docs/cookbook/default_expectations.rst b/vendor/mockery/mockery/docs/cookbook/default_expectations.rst new file mode 100644 index 000000000..2c6fcae23 --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/default_expectations.rst @@ -0,0 +1,17 @@ +.. index:: + single: Cookbook; Default Mock Expectations + +Default Mock Expectations +========================= + +Often in unit testing, we end up with sets of tests which use the same object +dependency over and over again. Rather than mocking this class/object within +every single unit test (requiring a mountain of duplicate code), we can +instead define reusable default mocks within the test case's ``setup()`` +method. This even works where unit tests use varying expectations on the same +or similar mock object. + +How this works, is that you can define mocks with default expectations. Then, +in a later unit test, you can add or fine-tune expectations for that specific +test. Any expectation can be set as a default using the ``byDefault()`` +declaration. diff --git a/vendor/mockery/mockery/docs/cookbook/detecting_mock_objects.rst b/vendor/mockery/mockery/docs/cookbook/detecting_mock_objects.rst new file mode 100644 index 000000000..0210c692b --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/detecting_mock_objects.rst @@ -0,0 +1,13 @@ +.. index:: + single: Cookbook; Detecting Mock Objects + +Detecting Mock Objects +====================== + +Users may find it useful to check whether a given object is a real object or a +simulated Mock Object. All Mockery mocks implement the +``\Mockery\MockInterface`` interface which can be used in a type check. + +.. code-block:: php + + assert($mightBeMocked instanceof \Mockery\MockInterface); diff --git a/vendor/mockery/mockery/docs/cookbook/index.rst b/vendor/mockery/mockery/docs/cookbook/index.rst new file mode 100644 index 000000000..48acbab07 --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/index.rst @@ -0,0 +1,15 @@ +Cookbook +======== + +.. toctree:: + :hidden: + + default_expectations + detecting_mock_objects + not_calling_the_constructor + mocking_hard_dependencies + class_constants + big_parent_class + mockery_on + +.. include:: map.rst.inc diff --git a/vendor/mockery/mockery/docs/cookbook/map.rst.inc b/vendor/mockery/mockery/docs/cookbook/map.rst.inc new file mode 100644 index 000000000..c9dd99efe --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/map.rst.inc @@ -0,0 +1,7 @@ +* :doc:`/cookbook/default_expectations` +* :doc:`/cookbook/detecting_mock_objects` +* :doc:`/cookbook/not_calling_the_constructor` +* :doc:`/cookbook/mocking_hard_dependencies` +* :doc:`/cookbook/class_constants` +* :doc:`/cookbook/big_parent_class` +* :doc:`/cookbook/mockery_on` diff --git a/vendor/mockery/mockery/docs/cookbook/mockery_on.rst b/vendor/mockery/mockery/docs/cookbook/mockery_on.rst new file mode 100644 index 000000000..631f1241c --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/mockery_on.rst @@ -0,0 +1,85 @@ +.. index:: + single: Cookbook; Complex Argument Matching With Mockery::on + +Complex Argument Matching With Mockery::on +========================================== + +When we need to do a more complex argument matching for an expected method call, +the ``\Mockery::on()`` matcher comes in really handy. It accepts a closure as an +argument and that closure in turn receives the argument passed in to the method, +when called. If the closure returns ``true``, Mockery will consider that the +argument has passed the expectation. If the closure returns ``false``, or a +"falsey" value, the expectation will not pass. + +The ``\Mockery::on()`` matcher can be used in various scenarios — validating +an array argument based on multiple keys and values, complex string matching... + +Say, for example, we have the following code. It doesn't do much; publishes a +post by setting the ``published`` flag in the database to ``1`` and sets the +``published_at`` to the current date and time: + +.. code-block:: php + + model = $model; + } + + public function publishPost($id) + { + $saveData = [ + 'post_id' => $id, + 'published' => 1, + 'published_at' => gmdate('Y-m-d H:i:s'), + ]; + $this->model->save($saveData); + } + } + +In a test we would mock the model and set some expectations on the call of the +``save()`` method: + +.. code-block:: php + + shouldReceive('save') + ->once() + ->with(\Mockery::on(function ($argument) use ($postId) { + $postIdIsSet = isset($argument['post_id']) && $argument['post_id'] === $postId; + $publishedFlagIsSet = isset($argument['published']) && $argument['published'] === 1; + $publishedAtIsSet = isset($argument['published_at']); + + return $postIdIsSet && $publishedFlagIsSet && $publishedAtIsSet; + })); + + $service = new \Service\Post($modelMock); + $service->publishPost($postId); + + \Mockery::close(); + +The important part of the example is inside the closure we pass to the +``\Mockery::on()`` matcher. The ``$argument`` is actually the ``$saveData`` argument +the ``save()`` method gets when it is called. We check for a couple of things in +this argument: + +* the post ID is set, and is same as the post ID we passed in to the + ``publishPost()`` method, +* the ``published`` flag is set, and is ``1``, and +* the ``published_at`` key is present. + +If any of these requirements is not satisfied, the closure will return ``false``, +the method call expectation will not be met, and Mockery will throw a +``NoMatchingExpectationException``. + +.. note:: + + This cookbook entry is an adaption of the blog post titled + `"Complex argument matching in Mockery" `_, + published by Robert Basic on his blog. diff --git a/vendor/mockery/mockery/docs/cookbook/mocking_hard_dependencies.rst b/vendor/mockery/mockery/docs/cookbook/mocking_hard_dependencies.rst new file mode 100644 index 000000000..b9381fdf3 --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/mocking_hard_dependencies.rst @@ -0,0 +1,99 @@ +.. index:: + single: Cookbook; Mocking Hard Dependencies + +Mocking Hard Dependencies (new Keyword) +======================================= + +One prerequisite to mock hard dependencies is that the code we are trying to test uses autoloading. + +Let's take the following code for an example: + +.. code-block:: php + + sendSomething($param); + return $externalService->getSomething(); + } + } + +The way we can test this without doing any changes to the code itself is by creating :doc:`instance mocks ` by using the ``overload`` prefix. + +.. code-block:: php + + shouldReceive('sendSomething') + ->once() + ->with($param); + $externalMock->shouldReceive('getSomething') + ->once() + ->andReturn('Tested!'); + + $service = new \App\Service(); + + $result = $service->callExternalService($param); + + $this->assertSame('Tested!', $result); + } + } + +If we run this test now, it should pass. Mockery does its job and our ``App\Service`` will use the mocked external service instead of the real one. + +The problem with this is when we want to, for example, test the ``App\Service\External`` itself, or if we use that class somewhere else in our tests. + +When Mockery overloads a class, because of how PHP works with files, that overloaded class file must not be included otherwise Mockery will throw a "class already exists" exception. This is where autoloading kicks in and makes our job a lot easier. + +To make this possible, we'll tell PHPUnit to run the tests that have overloaded classes in separate processes and to not preserve global state. That way we'll avoid having the overloaded class included more than once. Of course this has its downsides as these tests will run slower. + +Our test example from above now becomes: + +.. code-block:: php + + shouldReceive('sendSomething') + ->once() + ->with($param); + $externalMock->shouldReceive('getSomething') + ->once() + ->andReturn('Tested!'); + + $service = new \App\Service(); + + $result = $service->callExternalService($param); + + $this->assertSame('Tested!', $result); + } + } + +.. note:: + + This cookbook entry is an adaption of the blog post titled + `"Mocking hard dependencies with Mockery" `_, + published by Robert Basic on his blog. diff --git a/vendor/mockery/mockery/docs/cookbook/not_calling_the_constructor.rst b/vendor/mockery/mockery/docs/cookbook/not_calling_the_constructor.rst new file mode 100644 index 000000000..b8157ae3c --- /dev/null +++ b/vendor/mockery/mockery/docs/cookbook/not_calling_the_constructor.rst @@ -0,0 +1,63 @@ +.. index:: + single: Cookbook; Not Calling the Original Constructor + +Not Calling the Original Constructor +==================================== + +When creating generated partial test doubles, Mockery mocks out only the method +which we specifically told it to. This means that the original constructor of +the class we are mocking will be called. + +In some cases this is not a desired behavior, as the constructor might issue +calls to other methods, or other object collaborators, and as such, can create +undesired side-effects in the application's environment when running the tests. + +If this happens, we need to use runtime partial test doubles, as they don't +call the original constructor. + +.. code-block:: php + + class MyClass + { + public function __construct() + { + echo "Original constructor called." . PHP_EOL; + // Other side-effects can happen... + } + } + + // This will print "Original constructor called." + $mock = \Mockery::mock('MyClass[foo]'); + +A better approach is to use runtime partial doubles: + +.. code-block:: php + + class MyClass + { + public function __construct() + { + echo "Original constructor called." . PHP_EOL; + // Other side-effects can happen... + } + } + + // This will not print anything + $mock = \Mockery::mock('MyClass')->makePartial(); + $mock->shouldReceive('foo'); + +This is one of the reason why we don't recommend using generated partial test +doubles, but if possible, always use the runtime partials. + +Read more about :ref:`creating-test-doubles-partial-test-doubles`. + +.. note:: + + The way generated partial test doubles work, is a BC break. If you use a + really old version of Mockery, it might behave in a way that the constructor + is not being called for these generated partials. In the case if you upgrade + to a more recent version of Mockery, you'll probably have to change your + tests to use runtime partials, instead of generated ones. + + This change was introduced in early 2013, so it is highly unlikely that you + are using a Mockery from before that, so this should not be an issue. diff --git a/vendor/mockery/mockery/docs/getting_started/index.rst b/vendor/mockery/mockery/docs/getting_started/index.rst new file mode 100644 index 000000000..434755c86 --- /dev/null +++ b/vendor/mockery/mockery/docs/getting_started/index.rst @@ -0,0 +1,12 @@ +Getting Started +=============== + +.. toctree:: + :hidden: + + installation + upgrading + simple_example + quick_reference + +.. include:: map.rst.inc diff --git a/vendor/mockery/mockery/docs/getting_started/installation.rst b/vendor/mockery/mockery/docs/getting_started/installation.rst new file mode 100644 index 000000000..8019567f4 --- /dev/null +++ b/vendor/mockery/mockery/docs/getting_started/installation.rst @@ -0,0 +1,43 @@ +.. index:: + single: Installation + +Installation +============ + +Mockery can be installed using Composer or by cloning it from its GitHub +repository. These two options are outlined below. + +Composer +-------- + +You can read more about Composer on `getcomposer.org `_. +To install Mockery using Composer, first install Composer for your project +using the instructions on the `Composer download page `_. +You can then define your development dependency on Mockery using the suggested +parameters below. While every effort is made to keep the master branch stable, +you may prefer to use the current stable version tag instead (use the +``@stable`` tag). + +.. code-block:: json + + { + "require-dev": { + "mockery/mockery": "dev-master" + } + } + +To install, you then may call: + +.. code-block:: bash + + php composer.phar update + +This will install Mockery as a development dependency, meaning it won't be +installed when using ``php composer.phar update --no-dev`` in production. + +Git +--- + +The Git repository hosts the development version in its master branch. You can +install this using Composer by referencing ``dev-master`` as your preferred +version in your project's ``composer.json`` file as the earlier example shows. diff --git a/vendor/mockery/mockery/docs/getting_started/map.rst.inc b/vendor/mockery/mockery/docs/getting_started/map.rst.inc new file mode 100644 index 000000000..1055945ba --- /dev/null +++ b/vendor/mockery/mockery/docs/getting_started/map.rst.inc @@ -0,0 +1,4 @@ +* :doc:`/getting_started/installation` +* :doc:`/getting_started/upgrading` +* :doc:`/getting_started/simple_example` +* :doc:`/getting_started/quick_reference` diff --git a/vendor/mockery/mockery/docs/getting_started/quick_reference.rst b/vendor/mockery/mockery/docs/getting_started/quick_reference.rst new file mode 100644 index 000000000..e729a850f --- /dev/null +++ b/vendor/mockery/mockery/docs/getting_started/quick_reference.rst @@ -0,0 +1,200 @@ +.. index:: + single: Quick Reference + +Quick Reference +=============== + +The purpose of this page is to give a quick and short overview of some of the +most common Mockery features. + +Do read the :doc:`../reference/index` to learn about all the Mockery features. + +Integrate Mockery with PHPUnit, either by extending the ``MockeryTestCase``: + +.. code-block:: php + + use \Mockery\Adapter\Phpunit\MockeryTestCase; + + class MyTest extends MockeryTestCase + { + } + +or by using the ``MockeryPHPUnitIntegration`` trait: + +.. code-block:: php + + use \PHPUnit\Framework\TestCase; + use \Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; + + class MyTest extends TestCase + { + use MockeryPHPUnitIntegration; + } + +Creating a test double: + +.. code-block:: php + + $testDouble = \Mockery::mock('MyClass'); + +Creating a test double that implements a certain interface: + +.. code-block:: php + + $testDouble = \Mockery::mock('MyClass, MyInterface'); + +Expecting a method to be called on a test double: + +.. code-block:: php + + $testDouble = \Mockery::mock('MyClass'); + $testDouble->shouldReceive('foo'); + +Expecting a method to **not** be called on a test double: + +.. code-block:: php + + $testDouble = \Mockery::mock('MyClass'); + $testDouble->shouldNotReceive('foo'); + +Expecting a method to be called on a test double, once, with a certain argument, +and to return a value: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->once() + ->with($arg) + ->andReturn($returnValue); + +Expecting a method to be called on a test double and to return a different value +for each successive call: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->andReturn(1, 2, 3); + + $mock->foo(); // int(1); + $mock->foo(); // int(2); + $mock->foo(); // int(3); + $mock->foo(); // int(3); + +Creating a runtime partial test double: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass')->makePartial(); + +Creating a spy: + +.. code-block:: php + + $spy = \Mockery::spy('MyClass'); + +Expecting that a spy should have received a method call: + +.. code-block:: php + + $spy = \Mockery::spy('MyClass'); + + $spy->foo(); + + $spy->shouldHaveReceived()->foo(); + +Not so simple examples +^^^^^^^^^^^^^^^^^^^^^^ + +Creating a mock object to return a sequence of values from a set of method +calls: + +.. code-block:: php + + use \Mockery\Adapter\Phpunit\MockeryTestCase; + + class SimpleTest extends MockeryTestCase + { + public function testSimpleMock() + { + $mock = \Mockery::mock(array('pi' => 3.1416, 'e' => 2.71)); + $this->assertEquals(3.1416, $mock->pi()); + $this->assertEquals(2.71, $mock->e()); + } + } + +Creating a mock object which returns a self-chaining Undefined object for a +method call: + +.. code-block:: php + + use \Mockery\Adapter\Phpunit\MockeryTestCase; + + class UndefinedTest extends MockeryTestCase + { + public function testUndefinedValues() + { + $mock = \Mockery::mock('mymock'); + $mock->shouldReceive('divideBy')->with(0)->andReturnUndefined(); + $this->assertTrue($mock->divideBy(0) instanceof \Mockery\Undefined); + } + } + +Creating a mock object with multiple query calls and a single update call: + +.. code-block:: php + + use \Mockery\Adapter\Phpunit\MockeryTestCase; + + class DbTest extends MockeryTestCase + { + public function testDbAdapter() + { + $mock = \Mockery::mock('db'); + $mock->shouldReceive('query')->andReturn(1, 2, 3); + $mock->shouldReceive('update')->with(5)->andReturn(NULL)->once(); + + // ... test code here using the mock + } + } + +Expecting all queries to be executed before any updates: + +.. code-block:: php + + use \Mockery\Adapter\Phpunit\MockeryTestCase; + + class DbTest extends MockeryTestCase + { + public function testQueryAndUpdateOrder() + { + $mock = \Mockery::mock('db'); + $mock->shouldReceive('query')->andReturn(1, 2, 3)->ordered(); + $mock->shouldReceive('update')->andReturn(NULL)->once()->ordered(); + + // ... test code here using the mock + } + } + +Creating a mock object where all queries occur after startup, but before finish, +and where queries are expected with several different params: + +.. code-block:: php + + use \Mockery\Adapter\Phpunit\MockeryTestCase; + + class DbTest extends MockeryTestCase + { + public function testOrderedQueries() + { + $db = \Mockery::mock('db'); + $db->shouldReceive('startup')->once()->ordered(); + $db->shouldReceive('query')->with('CPWR')->andReturn(12.3)->once()->ordered('queries'); + $db->shouldReceive('query')->with('MSFT')->andReturn(10.0)->once()->ordered('queries'); + $db->shouldReceive('query')->with(\Mockery::pattern("/^....$/"))->andReturn(3.3)->atLeast()->once()->ordered('queries'); + $db->shouldReceive('finish')->once()->ordered(); + + // ... test code here using the mock + } + } diff --git a/vendor/mockery/mockery/docs/getting_started/simple_example.rst b/vendor/mockery/mockery/docs/getting_started/simple_example.rst new file mode 100644 index 000000000..1fb252e4f --- /dev/null +++ b/vendor/mockery/mockery/docs/getting_started/simple_example.rst @@ -0,0 +1,70 @@ +.. index:: + single: Getting Started; Simple Example + +Simple Example +============== + +Imagine we have a ``Temperature`` class which samples the temperature of a +locale before reporting an average temperature. The data could come from a web +service or any other data source, but we do not have such a class at present. +We can, however, assume some basic interactions with such a class based on its +interaction with the ``Temperature`` class: + +.. code-block:: php + + class Temperature + { + private $service; + + public function __construct($service) + { + $this->service = $service; + } + + public function average() + { + $total = 0; + for ($i=0; $i<3; $i++) { + $total += $this->service->readTemp(); + } + return $total/3; + } + } + +Even without an actual service class, we can see how we expect it to operate. +When writing a test for the ``Temperature`` class, we can now substitute a +mock object for the real service which allows us to test the behaviour of the +``Temperature`` class without actually needing a concrete service instance. + +.. code-block:: php + + use \Mockery; + + class TemperatureTest extends PHPUnit_Framework_TestCase + { + public function tearDown() + { + Mockery::close(); + } + + public function testGetsAverageTemperatureFromThreeServiceReadings() + { + $service = Mockery::mock('service'); + $service->shouldReceive('readTemp') + ->times(3) + ->andReturn(10, 12, 14); + + $temperature = new Temperature($service); + + $this->assertEquals(12, $temperature->average()); + } + } + +We create a mock object which our ``Temperature`` class will use and set some +expectations for that mock — that it should receive three calls to the ``readTemp`` +method, and these calls will return 10, 12, and 14 as results. + +.. note:: + + PHPUnit integration can remove the need for a ``tearDown()`` method. See + ":doc:`/reference/phpunit_integration`" for more information. diff --git a/vendor/mockery/mockery/docs/getting_started/upgrading.rst b/vendor/mockery/mockery/docs/getting_started/upgrading.rst new file mode 100644 index 000000000..7201e5973 --- /dev/null +++ b/vendor/mockery/mockery/docs/getting_started/upgrading.rst @@ -0,0 +1,82 @@ +.. index:: + single: Upgrading + +Upgrading +========= + +Upgrading to 1.0.0 +------------------ + +Minimum PHP version ++++++++++++++++++++ + +As of Mockery 1.0.0 the minimum PHP version required is 5.6. + +Using Mockery with PHPUnit +++++++++++++++++++++++++++ + +In the "old days", 0.9.x and older, the way Mockery was integrated with PHPUnit was +through a PHPUnit listener. That listener would in turn call the ``\Mockery::close()`` +method for us. + +As of 1.0.0, PHPUnit test cases where we want to use Mockery, should either use the +``\Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration`` trait, or extend the +``\Mockery\Adapter\Phpunit\MockeryTestCase`` test case. This will in turn call the +``\Mockery::close()`` method for us. + +Read the documentation for a detailed overview of ":doc:`/reference/phpunit_integration`". + +``\Mockery\Matcher\MustBe`` is deprecated ++++++++++++++++++++++++++++++++++++++++++ + +As of 1.0.0 the ``\Mockery\Matcher\MustBe`` matcher is deprecated and will be removed in +Mockery 2.0.0. We recommend instead to use the PHPUnit or Hamcrest equivalents of the +MustBe matcher. + +``allows`` and ``expects`` +++++++++++++++++++++++++++ + +As of 1.0.0, Mockery has two new methods to set up expectations: ``allows`` and ``expects``. +This means that these methods names are now "reserved" for Mockery, or in other words +classes you want to mock with Mockery, can't have methods called ``allows`` or ``expects``. + +Read more in the documentation about this ":doc:`/reference/alternative_should_receive_syntax`". + +No more implicit regex matching for string arguments +++++++++++++++++++++++++++++++++++++++++++++++++++++ + +When setting up string arguments in method expectations, Mockery 0.9.x and older, would try +to match arguments using a regular expression in a "last attempt" scenario. + +As of 1.0.0, Mockery will no longer attempt to do this regex matching, but will only try +first the identical operator ``===``, and failing that, the equals operator ``==``. + +If you want to match an argument using regular expressions, please use the new +``\Mockery\Matcher\Pattern`` matcher. Read more in the documentation about this +pattern matcher in the ":doc:`/reference/argument_validation`" section. + +``andThrow`` ``\Throwable`` ++++++++++++++++++++++++++++ + +As of 1.0.0, the ``andThrow`` can now throw any ``\Throwable``. + +Upgrading to 0.9 +---------------- + +The generator was completely rewritten, so any code with a deep integration to +mockery will need evaluating. + +Upgrading to 0.8 +---------------- + +Since the release of 0.8.0 the following behaviours were altered: + +1. The ``shouldIgnoreMissing()`` behaviour optionally applied to mock objects + returned an instance of ``\Mockery\Undefined`` when methods called did not + match a known expectation. Since 0.8.0, this behaviour was switched to + returning ``null`` instead. You can restore the 0.7.2 behaviour by using the + following: + + .. code-block:: php + + $mock = \Mockery::mock('stdClass')->shouldIgnoreMissing()->asUndefined(); diff --git a/vendor/mockery/mockery/docs/index.rst b/vendor/mockery/mockery/docs/index.rst new file mode 100644 index 000000000..f8cbbd32a --- /dev/null +++ b/vendor/mockery/mockery/docs/index.rst @@ -0,0 +1,76 @@ +Mockery +======= + +Mockery is a simple yet flexible PHP mock object framework for use in unit +testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is +to offer a test double framework with a succinct API capable of clearly +defining all possible object operations and interactions using a human +readable Domain Specific Language (DSL). Designed as a drop in alternative to +PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with +PHPUnit and can operate alongside phpunit-mock-objects without the World +ending. + +Mock Objects +------------ + +In unit tests, mock objects simulate the behaviour of real objects. They are +commonly utilised to offer test isolation, to stand in for objects which do +not yet exist, or to allow for the exploratory design of class APIs without +requiring actual implementation up front. + +The benefits of a mock object framework are to allow for the flexible +generation of such mock objects (and stubs). They allow the setting of +expected method calls and return values using a flexible API which is capable +of capturing every possible real object behaviour in way that is stated as +close as possible to a natural language description. + +Getting Started +--------------- + +Ready to dive into the Mockery framework? Then you can get started by reading +the "Getting Started" section! + +.. toctree:: + :hidden: + + getting_started/index + +.. include:: getting_started/map.rst.inc + +Reference +--------- + +The reference contains a complete overview of all features of the Mockery +framework. + +.. toctree:: + :hidden: + + reference/index + +.. include:: reference/map.rst.inc + +Mockery +------- + +Learn about Mockery's configuration, reserved method names, exceptions... + +.. toctree:: + :hidden: + + mockery/index + +.. include:: mockery/map.rst.inc + +Cookbook +-------- + +Want to learn some easy tips and tricks? Take a look at the cookbook articles! + +.. toctree:: + :hidden: + + cookbook/index + +.. include:: cookbook/map.rst.inc + diff --git a/vendor/mockery/mockery/docs/mockery/configuration.rst b/vendor/mockery/mockery/docs/mockery/configuration.rst new file mode 100644 index 000000000..3a89579cf --- /dev/null +++ b/vendor/mockery/mockery/docs/mockery/configuration.rst @@ -0,0 +1,77 @@ +.. index:: + single: Mockery; Configuration + +Mockery Global Configuration +============================ + +To allow for a degree of fine-tuning, Mockery utilises a singleton +configuration object to store a small subset of core behaviours. The two +currently present include: + +* Option to allow/disallow the mocking of methods which do not actually exist + fulfilled (i.e. unused) +* Setter/Getter for added a parameter map for internal PHP class methods + (``Reflection`` cannot detect these automatically) + +By default, the first behaviour is enabled. Of course, there are +situations where this can lead to unintended consequences. The mocking of +non-existent methods may allow mocks based on real classes/objects to fall out +of sync with the actual implementations, especially when some degree of +integration testing (testing of object wiring) is not being performed. + +You may allow or disallow this behaviour (whether for whole test suites or +just select tests) by using the following call: + +.. code-block:: php + + \Mockery::getConfiguration()->allowMockingNonExistentMethods(bool); + +Passing a true allows the behaviour, false disallows it. It takes effect +immediately until switched back. If the behaviour is detected when not allowed, +it will result in an Exception being thrown at that point. Note that disallowing +this behaviour should be carefully considered since it necessarily removes at +least some of Mockery's flexibility. + +The other two methods are: + +.. code-block:: php + + \Mockery::getConfiguration()->setInternalClassMethodParamMap($class, $method, array $paramMap) + \Mockery::getConfiguration()->getInternalClassMethodParamMap($class, $method) + +These are used to define parameters (i.e. the signature string of each) for the +methods of internal PHP classes (e.g. SPL, or PECL extension classes like +ext/mongo's MongoCollection. Reflection cannot analyse the parameters of internal +classes. Most of the time, you never need to do this. It's mainly needed where an +internal class method uses pass-by-reference for a parameter - you MUST in such +cases ensure the parameter signature includes the ``&`` symbol correctly as Mockery +won't correctly add it automatically for internal classes. + +Disabling reflection caching +---------------------------- + +Mockery heavily uses `"reflection" `_ +to do it's job. To speed up things, Mockery caches internally the information it +gathers via reflection. In some cases, this caching can cause problems. + +The **only** known situation when this occurs is when PHPUnit's ``--static-backup`` option +is used. If you use ``--static-backup`` and you get an error that looks like the +following: + +.. code-block:: php + + Error: Internal error: Failed to retrieve the reflection object + +We suggest turning off the reflection cache as so: + +.. code-block:: php + + \Mockery::getConfiguration()->disableReflectionCache(); + +Turning it back on can be done like so: + +.. code-block:: php + + \Mockery::getConfiguration()->enableReflectionCache(); + +In no other situation should you be required turn this reflection cache off. diff --git a/vendor/mockery/mockery/docs/mockery/exceptions.rst b/vendor/mockery/mockery/docs/mockery/exceptions.rst new file mode 100644 index 000000000..623b158e2 --- /dev/null +++ b/vendor/mockery/mockery/docs/mockery/exceptions.rst @@ -0,0 +1,65 @@ +.. index:: + single: Mockery; Exceptions + +Mockery Exceptions +================== + +Mockery throws three types of exceptions when it cannot verify a mock object. + +#. ``\Mockery\Exception\InvalidCountException`` +#. ``\Mockery\Exception\InvalidOrderException`` +#. ``\Mockery\Exception\NoMatchingExpectationException`` + +You can capture any of these exceptions in a try...catch block to query them +for specific information which is also passed along in the exception message +but is provided separately from getters should they be useful when logging or +reformatting output. + +\Mockery\Exception\InvalidCountException +---------------------------------------- + +The exception class is used when a method is called too many (or too few) +times and offers the following methods: + +* ``getMock()`` - return actual mock object +* ``getMockName()`` - return the name of the mock object +* ``getMethodName()`` - return the name of the method the failing expectation + is attached to +* ``getExpectedCount()`` - return expected calls +* ``getExpectedCountComparative()`` - returns a string, e.g. ``<=`` used to + compare to actual count +* ``getActualCount()`` - return actual calls made with given argument + constraints + +\Mockery\Exception\InvalidOrderException +---------------------------------------- + +The exception class is used when a method is called outside the expected order +set using the ``ordered()`` and ``globally()`` expectation modifiers. It +offers the following methods: + +* ``getMock()`` - return actual mock object +* ``getMockName()`` - return the name of the mock object +* ``getMethodName()`` - return the name of the method the failing expectation + is attached to +* ``getExpectedOrder()`` - returns an integer represented the expected index + for which this call was expected +* ``getActualOrder()`` - return the actual index at which this method call + occurred. + +\Mockery\Exception\NoMatchingExpectationException +------------------------------------------------- + +The exception class is used when a method call does not match any known +expectation. All expectations are uniquely identified in a mock object by the +method name and the list of expected arguments. You can disable this exception +and opt for returning NULL from all unexpected method calls by using the +earlier mentioned shouldIgnoreMissing() behaviour modifier. This exception +class offers the following methods: + +* ``getMock()`` - return actual mock object +* ``getMockName()`` - return the name of the mock object +* ``getMethodName()`` - return the name of the method the failing expectation + is attached to +* ``getActualArguments()`` - return actual arguments used to search for a + matching expectation diff --git a/vendor/mockery/mockery/docs/mockery/gotchas.rst b/vendor/mockery/mockery/docs/mockery/gotchas.rst new file mode 100644 index 000000000..ebd690fb5 --- /dev/null +++ b/vendor/mockery/mockery/docs/mockery/gotchas.rst @@ -0,0 +1,48 @@ +.. index:: + single: Mockery; Gotchas + +Gotchas! +======== + +Mocking objects in PHP has its limitations and gotchas. Some functionality +can't be mocked or can't be mocked YET! If you locate such a circumstance, +please please (pretty please with sugar on top) create a new issue on GitHub +so it can be documented and resolved where possible. Here is a list to note: + +1. Classes containing public ``__wakeup()`` methods can be mocked but the + mocked ``__wakeup()`` method will perform no actions and cannot have + expectations set for it. This is necessary since Mockery must serialize and + unserialize objects to avoid some ``__construct()`` insanity and attempting + to mock a ``__wakeup()`` method as normal leads to a + ``BadMethodCallException`` being thrown. + +2. Classes using non-real methods, i.e. where a method call triggers a + ``__call()`` method, will throw an exception that the non-real method does + not exist unless you first define at least one expectation (a simple + ``shouldReceive()`` call would suffice). This is necessary since there is + no other way for Mockery to be aware of the method name. + +3. Mockery has two scenarios where real classes are replaced: Instance mocks + and alias mocks. Both will generate PHP fatal errors if the real class is + loaded, usually via a require or include statement. Only use these two mock + types where autoloading is in place and where classes are not explicitly + loaded on a per-file basis using ``require()``, ``require_once()``, etc. + +4. Internal PHP classes are not entirely capable of being fully analysed using + ``Reflection``. For example, ``Reflection`` cannot reveal details of + expected parameters to the methods of such internal classes. As a result, + there will be problems where a method parameter is defined to accept a + value by reference (Mockery cannot detect this condition and will assume a + pass by value on scalars and arrays). If references as internal class + method parameters are needed, you should use the + ``\Mockery\Configuration::setInternalClassMethodParamMap()`` method. + +5. Creating a mock implementing a certain interface with incorrect case in the + interface name, and then creating a second mock implementing the same + interface, but this time with the correct case, will have undefined behavior + due to PHP's ``class_exists`` and related functions being case insensitive. + Using the ``::class`` keyword in PHP can help you avoid these mistakes. + +The gotchas noted above are largely down to PHP's architecture and are assumed +to be unavoidable. But - if you figure out a solution (or a better one than +what may exist), let us know! diff --git a/vendor/mockery/mockery/docs/mockery/index.rst b/vendor/mockery/mockery/docs/mockery/index.rst new file mode 100644 index 000000000..b698d6cb3 --- /dev/null +++ b/vendor/mockery/mockery/docs/mockery/index.rst @@ -0,0 +1,12 @@ +Mockery +======= + +.. toctree:: + :hidden: + + configuration + exceptions + reserved_method_names + gotchas + +.. include:: map.rst.inc diff --git a/vendor/mockery/mockery/docs/mockery/map.rst.inc b/vendor/mockery/mockery/docs/mockery/map.rst.inc new file mode 100644 index 000000000..46ffa9759 --- /dev/null +++ b/vendor/mockery/mockery/docs/mockery/map.rst.inc @@ -0,0 +1,4 @@ +* :doc:`/mockery/configuration` +* :doc:`/mockery/exceptions` +* :doc:`/mockery/reserved_method_names` +* :doc:`/mockery/gotchas` diff --git a/vendor/mockery/mockery/docs/mockery/reserved_method_names.rst b/vendor/mockery/mockery/docs/mockery/reserved_method_names.rst new file mode 100644 index 000000000..112d6f0a5 --- /dev/null +++ b/vendor/mockery/mockery/docs/mockery/reserved_method_names.rst @@ -0,0 +1,20 @@ +.. index:: + single: Reserved Method Names + +Reserved Method Names +===================== + +As you may have noticed, Mockery uses a number of methods called directly on +all mock objects, for example ``shouldReceive()``. Such methods are necessary +in order to setup expectations on the given mock, and so they cannot be +implemented on the classes or objects being mocked without creating a method +name collision (reported as a PHP fatal error). The methods reserved by +Mockery are: + +* ``shouldReceive()`` +* ``shouldBeStrict()`` + +In addition, all mocks utilise a set of added methods and protected properties +which cannot exist on the class or object being mocked. These are far less +likely to cause collisions. All properties are prefixed with ``_mockery`` and +all method names with ``mockery_``. diff --git a/vendor/mockery/mockery/docs/reference/alternative_should_receive_syntax.rst b/vendor/mockery/mockery/docs/reference/alternative_should_receive_syntax.rst new file mode 100644 index 000000000..78c1e83cb --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/alternative_should_receive_syntax.rst @@ -0,0 +1,91 @@ +.. index:: + single: Alternative shouldReceive Syntax + +Alternative shouldReceive Syntax +================================ + +As of Mockery 1.0.0, we support calling methods as we would call any PHP method, +and not as string arguments to Mockery ``should*`` methods. + +The two Mockery methods that enable this are ``allows()`` and ``expects()``. + +Allows +------ + +We use ``allows()`` when we create stubs for methods that return a predefined +return value, but for these method stubs we don't care how many times, or if at +all, were they called. + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->allows([ + 'name_of_method_1' => 'return value', + 'name_of_method_2' => 'return value', + ]); + +This is equivalent with the following ``shouldReceive`` syntax: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive([ + 'name_of_method_1' => 'return value', + 'name_of_method_2' => 'return value', + ]); + +Note that with this format, we also tell Mockery that we don't care about the +arguments to the stubbed methods. + +If we do care about the arguments, we would do it like so: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->allows() + ->name_of_method_1($arg1) + ->andReturn('return value'); + +This is equivalent with the following ``shouldReceive`` syntax: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method_1') + ->with($arg1) + ->andReturn('return value'); + +Expects +------- + +We use ``expects()`` when we want to verify that a particular method was called: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->expects() + ->name_of_method_1($arg1) + ->andReturn('return value'); + +This is equivalent with the following ``shouldReceive`` syntax: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method_1') + ->once() + ->with($arg1) + ->andReturn('return value'); + +By default ``expects()`` sets up an expectation that the method should be called +once and once only. If we expect more than one call to the method, we can change +that expectation: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->expects() + ->name_of_method_1($arg1) + ->twice() + ->andReturn('return value'); + diff --git a/vendor/mockery/mockery/docs/reference/argument_validation.rst b/vendor/mockery/mockery/docs/reference/argument_validation.rst new file mode 100644 index 000000000..735407c0c --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/argument_validation.rst @@ -0,0 +1,317 @@ +.. index:: + single: Argument Validation + +Argument Validation +=================== + +The arguments passed to the ``with()`` declaration when setting up an +expectation determine the criteria for matching method calls to expectations. +Thus, we can setup up many expectations for a single method, each +differentiated by the expected arguments. Such argument matching is done on a +"best fit" basis. This ensures explicit matches take precedence over +generalised matches. + +An explicit match is merely where the expected argument and the actual +argument are easily equated (i.e. using ``===`` or ``==``). More generalised +matches are possible using regular expressions, class hinting and the +available generic matchers. The purpose of generalised matchers is to allow +arguments be defined in non-explicit terms, e.g. ``Mockery::any()`` passed to +``with()`` will match **any** argument in that position. + +Mockery's generic matchers do not cover all possibilities but offers optional +support for the Hamcrest library of matchers. Hamcrest is a PHP port of the +similarly named Java library (which has been ported also to Python, Erlang, +etc). By using Hamcrest, Mockery does not need to duplicate Hamcrest's already +impressive utility which itself promotes a natural English DSL. + +The examples below show Mockery matchers and their Hamcrest equivalent, if there +is one. Hamcrest uses functions (no namespacing). + +.. note:: + + If you don't wish to use the global Hamcrest functions, they are all exposed + through the ``\Hamcrest\Matchers`` class as well, as static methods. Thus, + ``identicalTo($arg)`` is the same as ``\Hamcrest\Matchers::identicalTo($arg)`` + +The most common matcher is the ``with()`` matcher: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(1): + +It tells mockery that it should receive a call to the ``foo`` method with the +integer ``1`` as an argument. In cases like this, Mockery first tries to match +the arguments using ``===`` (identical) comparison operator. If the argument is +a primitive, and if it fails the identical comparison, Mockery does a fallback +to the ``==`` (equals) comparison operator. + +When matching objects as arguments, Mockery only does the strict ``===`` +comparison, which means only the same ``$object`` will match: + +.. code-block:: php + + $object = new stdClass(); + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive("foo") + ->with($object); + + // Hamcrest equivalent + $mock->shouldReceive("foo") + ->with(identicalTo($object)); + +A different instance of ``stdClass`` will **not** match. + +.. note:: + + The ``Mockery\Matcher\MustBe`` matcher has been deprecated. + +If we need a loose comparison of objects, we can do that using Hamcrest's +``equalTo`` matcher: + +.. code-block:: php + + $mock->shouldReceive("foo") + ->with(equalTo(new stdClass)); + +In cases when we don't care about the type, or the value of an argument, just +that any argument is present, we use ``any()``: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive("foo") + ->with(\Mockery::any()); + + // Hamcrest equivalent + $mock->shouldReceive("foo") + ->with(anything()) + +Anything and everything passed in this argument slot is passed unconstrained. + +Validating Types and Resources +------------------------------ + +The ``type()`` matcher accepts any string which can be attached to ``is_`` to +form a valid type check. + +To match any PHP resource, we could do the following: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive("foo") + ->with(\Mockery::type('resource')); + + // Hamcrest equivalents + $mock->shouldReceive("foo") + ->with(resourceValue()); + $mock->shouldReceive("foo") + ->with(typeOf('resource')); + +It will return a ``true`` from an ``is_resource()`` call, if the provided +argument to the method is a PHP resource. For example, ``\Mockery::type('float')`` +or Hamcrest's ``floatValue()`` and ``typeOf('float')`` checks use ``is_float()``, +and ``\Mockery::type('callable')`` or Hamcrest's ``callable()`` uses +``is_callable()``. + +The ``type()`` matcher also accepts a class or interface name to be used in an +``instanceof`` evaluation of the actual argument. Hamcrest uses ``anInstanceOf()``. + +A full list of the type checkers is available at +`php.net `_ or browse Hamcrest's function +list in +`the Hamcrest code `_. + +.. _argument-validation-complex-argument-validation: + +Complex Argument Validation +--------------------------- + +If we want to perform a complex argument validation, the ``on()`` matcher is +invaluable. It accepts a closure (anonymous function) to which the actual +argument will be passed. + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive("foo") + ->with(\Mockery::on(closure)); + +If the closure evaluates to (i.e. returns) boolean ``true`` then the argument is +assumed to have matched the expectation. + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + + $mock->shouldReceive('foo') + ->with(\Mockery::on(function ($argument) { + if ($argument % 2 == 0) { + return true; + } + return false; + })); + + $mock->foo(4); // matches the expectation + $mock->foo(3); // throws a NoMatchingExpectationException + +.. note:: + + There is no Hamcrest version of the ``on()`` matcher. + +We can also perform argument validation by passing a closure to ``withArgs()`` +method. The closure will receive all arguments passed in the call to the expected +method and if it evaluates (i.e. returns) to boolean ``true``, then the list of +arguments is assumed to have matched the expectation: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive("foo") + ->withArgs(closure); + +The closure can also handle optional parameters, so if an optional parameter is +missing in the call to the expected method, it doesn't necessary means that the +list of arguments doesn't match the expectation. + +.. code-block:: php + + $closure = function ($odd, $even, $sum = null) { + $result = ($odd % 2 != 0) && ($even % 2 == 0); + if (!is_null($sum)) { + return $result && ($odd + $even == $sum); + } + return $result; + }; + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo')->withArgs($closure); + + $mock->foo(1, 2); // It matches the expectation: the optional argument is not needed + $mock->foo(1, 2, 3); // It also matches the expectation: the optional argument pass the validation + $mock->foo(1, 2, 4); // It doesn't match the expectation: the optional doesn't pass the validation + +.. note:: + + In previous versions, Mockery's ``with()`` would attempt to do a pattern + matching against the arguments, attempting to use the argument as a + regular expression. Over time this proved to be not such a great idea, so + we removed this functionality, and have introduced ``Mockery::pattern()`` + instead. + +If we would like to match an argument against a regular expression, we can use +the ``\Mockery::pattern()``: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::pattern('/^foo/')); + + // Hamcrest equivalent + $mock->shouldReceive('foo') + with(matchesPattern('/^foo/')); + +The ``ducktype()`` matcher is an alternative to matching by class type: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::ducktype('foo', 'bar')); + +It matches any argument which is an object containing the provided list of +methods to call. + +.. note:: + + There is no Hamcrest version of the ``ducktype()`` matcher. + +Additional Argument Matchers +---------------------------- + +The ``not()`` matcher matches any argument which is not equal or identical to +the matcher's parameter: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::not(2)); + + // Hamcrest equivalent + $mock->shouldReceive('foo') + ->with(not(2)); + +``anyOf()`` matches any argument which equals any one of the given parameters: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::anyOf(1, 2)); + + // Hamcrest equivalent + $mock->shouldReceive('foo') + ->with(anyOf(1,2)); + +``notAnyOf()`` matches any argument which is not equal or identical to any of +the given parameters: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::notAnyOf(1, 2)); + +.. note:: + + There is no Hamcrest version of the ``notAnyOf()`` matcher. + +``subset()`` matches any argument which is any array containing the given array +subset: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::subset(array(0 => 'foo'))); + +This enforces both key naming and values, i.e. both the key and value of each +actual element is compared. + +.. note:: + + There is no Hamcrest version of this functionality, though Hamcrest can check + a single entry using ``hasEntry()`` or ``hasKeyValuePair()``. + +``contains()`` matches any argument which is an array containing the listed +values: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::contains(value1, value2)); + +The naming of keys is ignored. + +``hasKey()`` matches any argument which is an array containing the given key +name: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::hasKey(key)); + +``hasValue()`` matches any argument which is an array containing the given +value: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('foo') + ->with(\Mockery::hasValue(value)); diff --git a/vendor/mockery/mockery/docs/reference/creating_test_doubles.rst b/vendor/mockery/mockery/docs/reference/creating_test_doubles.rst new file mode 100644 index 000000000..377812d88 --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/creating_test_doubles.rst @@ -0,0 +1,419 @@ +.. index:: + single: Reference; Creating Test Doubles + +Creating Test Doubles +===================== + +Mockery's main goal is to help us create test doubles. It can create stubs, +mocks, and spies. + +Stubs and mocks are created the same. The difference between the two is that a +stub only returns a preset result when called, while a mock needs to have +expectations set on the method calls it expects to receive. + +Spies are a type of test doubles that keep track of the calls they received, and +allow us to inspect these calls after the fact. + +When creating a test double object, we can pass in an identifier as a name for +our test double. If we pass it no identifier, the test double name will be +unknown. Furthermore, the identifier must not be a class name. It is a +good practice, and our recommendation, to always name the test doubles with the +same name as the underlying class we are creating test doubles for. + +If the identifier we use for our test double is a name of an existing class, +the test double will inherit the type of the class (via inheritance), i.e. the +mock object will pass type hints or ``instanceof`` evaluations for the existing +class. This is useful when a test double must be of a specific type, to satisfy +the expectations our code has. + +Stubs and mocks +--------------- + +Stubs and mocks are created by calling the ``\Mockery::mock()`` method. The +following example shows how to create a stub, or a mock, object named "foo": + +.. code-block:: php + + $mock = \Mockery::mock('foo'); + +The mock object created like this is the loosest form of mocks possible, and is +an instance of ``\Mockery\MockInterface``. + +.. note:: + + All test doubles created with Mockery are an instance of + ``\Mockery\MockInterface``, regardless are they a stub, mock or a spy. + +To create a stub or a mock object with no name, we can call the ``mock()`` +method with no parameters: + +.. code-block:: php + + $mock = \Mockery::mock(); + +As we stated earlier, we don't recommend creating stub or mock objects without +a name. + +Classes, abstracts, interfaces +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The recommended way to create a stub or a mock object is by using a name of +an existing class we want to create a test double of: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + +This stub or mock object will have the type of ``MyClass``, through inheritance. + +Stub or mock objects can be based on any concrete class, abstract class or even +an interface. The primary purpose is to ensure the mock object inherits a +specific type for type hinting. + +.. code-block:: php + + $mock = \Mockery::mock('MyInterface'); + +This stub or mock object will implement the ``MyInterface`` interface. + +.. note:: + + Classes marked final, or classes that have methods marked final cannot be + mocked fully. Mockery supports creating partial mocks for these cases. + Partial mocks will be explained later in the documentation. + +Mockery also supports creating stub or mock objects based on a single existing +class, which must implement one or more interfaces. We can do this by providing +a comma-separated list of the class and interfaces as the first argument to the +``\Mockery::mock()`` method: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass, MyInterface, OtherInterface'); + +This stub or mock object will now be of type ``MyClass`` and implement the +``MyInterface`` and ``OtherInterface`` interfaces. + +.. note:: + + The class name doesn't need to be the first member of the list but it's a + friendly convention to use for readability. + +We can tell a mock to implement the desired interfaces by passing the list of +interfaces as the second argument: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass', 'MyInterface, OtherInterface'); + +For all intents and purposes, this is the same as the previous example. + +Spies +----- + +The third type of test doubles Mockery supports are spies. The main difference +between spies and mock objects is that with spies we verify the calls made +against our test double after the calls were made. We would use a spy when we +don't necessarily care about all of the calls that are going to be made to an +object. + +A spy will return ``null`` for all method calls it receives. It is not possible +to tell a spy what will be the return value of a method call. If we do that, then +we would deal with a mock object, and not with a spy. + +We create a spy by calling the ``\Mockery::spy()`` method: + +.. code-block:: php + + $spy = \Mockery::spy('MyClass'); + +Just as with stubs or mocks, we can tell Mockery to base a spy on any concrete +or abstract class, or to implement any number of interfaces: + +.. code-block:: php + + $spy = \Mockery::spy('MyClass, MyInterface, OtherInterface'); + +This spy will now be of type ``MyClass`` and implement the ``MyInterface`` and +``OtherInterface`` interfaces. + +.. note:: + + The ``\Mockery::spy()`` method call is actually a shorthand for calling + ``\Mockery::mock()->shouldIgnoreMissing()``. The ``shouldIgnoreMissing`` + method is a "behaviour modifier". We'll discuss them a bit later. + +Mocks vs. Spies +--------------- + +Let's try and illustrate the difference between mocks and spies with the +following example: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $spy = \Mockery::spy('MyClass'); + + $mock->shouldReceive('foo')->andReturn(42); + + $mockResult = $mock->foo(); + $spyResult = $spy->foo(); + + $spy->shouldHaveReceived()->foo(); + + var_dump($mockResult); // int(42) + var_dump($spyResult); // null + +As we can see from this example, with a mock object we set the call expectations +before the call itself, and we get the return result we expect it to return. +With a spy object on the other hand, we verify the call has happened after the +fact. The return result of a method call against a spy is always ``null``. + +We also have a dedicated chapter to :doc:`spies` only. + +.. _creating-test-doubles-partial-test-doubles: + +Partial Test Doubles +-------------------- + +Partial doubles are useful when we want to stub out, set expectations for, or +spy on *some* methods of a class, but run the actual code for other methods. + +We differentiate between three types of partial test doubles: + + * runtime partial test doubles, + * generated partial test doubles, and + * proxied partial test doubles. + +Runtime partial test doubles +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +What we call a runtime partial, involves creating a test double and then telling +it to make itself partial. Any method calls that the double hasn't been told to +allow or expect, will act as they would on a normal instance of the object. + +.. code-block:: php + + class Foo { + function foo() { return 123; } + function bar() { return $this->foo(); } + } + + $foo = mock(Foo::class)->makePartial(); + $foo->foo(); // int(123); + +We can then tell the test double to allow or expect calls as with any other +Mockery double. + +.. code-block:: php + + $foo->shouldReceive('foo')->andReturn(456); + $foo->bar(); // int(456) + +See the cookbook entry on :doc:`../cookbook/big_parent_class` for an example +usage of runtime partial test doubles. + +Generated partial test doubles +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +The second type of partial double we can create is what we call a generated +partial. With generated partials, we specifically tell Mockery which methods +we want to be able to allow or expect calls to. All other methods will run the +actual code *directly*, so stubs and expectations on these methods will not +work. + +.. code-block:: php + + class Foo { + function foo() { return 123; } + function bar() { return $this->foo(); } + } + + $foo = mock("Foo[foo]"); + + $foo->foo(); // error, no expectation set + + $foo->shouldReceive('foo')->andReturn(456); + $foo->foo(); // int(456) + + // setting an expectation for this has no effect + $foo->shouldReceive('bar')->andReturn(999); + $foo->bar(); // int(456) + +.. note:: + + Even though we support generated partial test doubles, we do not recommend + using them. + + One of the reasons why is because a generated partial will call the original + constructor of the mocked class. This can have unwanted side-effects during + testing application code. + + See :doc:`../cookbook/not_calling_the_constructor` for more details. + +Proxied partial test doubles +^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A proxied partial mock is a partial of last resort. We may encounter a class +which is simply not capable of being mocked because it has been marked as +final. Similarly, we may find a class with methods marked as final. In such a +scenario, we cannot simply extend the class and override methods to mock - we +need to get creative. + +.. code-block:: php + + $mock = \Mockery::mock(new MyClass); + +Yes, the new mock is a Proxy. It intercepts calls and reroutes them to the +proxied object (which we construct and pass in) for methods which are not +subject to any expectations. Indirectly, this allows us to mock methods +marked final since the Proxy is not subject to those limitations. The tradeoff +should be obvious - a proxied partial will fail any typehint checks for the +class being mocked since it cannot extend that class. + +.. _creating-test-doubles-aliasing: + +Aliasing +-------- + +Prefixing the valid name of a class (which is NOT currently loaded) with +"alias:" will generate an "alias mock". Alias mocks create a class alias with +the given classname to stdClass and are generally used to enable the mocking +of public static methods. Expectations set on the new mock object which refer +to static methods will be used by all static calls to this class. + +.. code-block:: php + + $mock = \Mockery::mock('alias:MyClass'); + + +.. note:: + + Even though aliasing classes is supported, we do not recommend it. + +Overloading +----------- + +Prefixing the valid name of a class (which is NOT currently loaded) with +"overload:" will generate an alias mock (as with "alias:") except that created +new instances of that class will import any expectations set on the origin +mock (``$mock``). The origin mock is never verified since it's used an +expectation store for new instances. For this purpose we use the term "instance +mock" to differentiate it from the simpler "alias mock". + +In other words, an instance mock will "intercept" when a new instance of the +mocked class is created, then the mock will be used instead. This is useful +especially when mocking hard dependencies which will be discussed later. + +.. code-block:: php + + $mock = \Mockery::mock('overload:MyClass'); + +.. note:: + + Using alias/instance mocks across more than one test will generate a fatal + error since we can't have two classes of the same name. To avoid this, + run each test of this kind in a separate PHP process (which is supported + out of the box by both PHPUnit and PHPT). + + +.. _creating-test-doubles-named-mocks: + +Named Mocks +----------- + +The ``namedMock()`` method will generate a class called by the first argument, +so in this example ``MyClassName``. The rest of the arguments are treated in the +same way as the ``mock`` method: + +.. code-block:: php + + $mock = \Mockery::namedMock('MyClassName', 'DateTime'); + +This example would create a class called ``MyClassName`` that extends +``DateTime``. + +Named mocks are quite an edge case, but they can be useful when code depends +on the ``__CLASS__`` magic constant, or when we need two derivatives of an +abstract type, that are actually different classes. + +See the cookbook entry on :doc:`../cookbook/class_constants` for an example +usage of named mocks. + +.. note:: + + We can only create a named mock once, any subsequent calls to + ``namedMock``, with different arguments are likely to cause exceptions. + +.. _creating-test-doubles-constructor-arguments: + +Constructor Arguments +--------------------- + +Sometimes the mocked class has required constructor arguments. We can pass these +to Mockery as an indexed array, as the 2nd argument: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass', [$constructorArg1, $constructorArg2]); + +or if we need the ``MyClass`` to implement an interface as well, as the 3rd +argument: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass', 'MyInterface', [$constructorArg1, $constructorArg2]); + +Mockery now knows to pass in ``$constructorArg1`` and ``$constructorArg2`` as +arguments to the constructor. + +.. _creating-test-doubles-behavior-modifiers: + +Behavior Modifiers +------------------ + +When creating a mock object, we may wish to use some commonly preferred +behaviours that are not the default in Mockery. + +The use of the ``shouldIgnoreMissing()`` behaviour modifier will label this +mock object as a Passive Mock: + +.. code-block:: php + + \Mockery::mock('MyClass')->shouldIgnoreMissing(); + +In such a mock object, calls to methods which are not covered by expectations +will return ``null`` instead of the usual error about there being no expectation +matching the call. + +On PHP >= 7.0.0, methods with missing expectations that have a return type +will return either a mock of the object (if return type is a class) or a +"falsy" primitive value, e.g. empty string, empty array, zero for ints and +floats, false for bools, or empty closures. + +On PHP >= 7.1.0, methods with missing expectations and nullable return type +will return null. + +We can optionally prefer to return an object of type ``\Mockery\Undefined`` +(i.e. a ``null`` object) (which was the 0.7.2 behaviour) by using an +additional modifier: + +.. code-block:: php + + \Mockery::mock('MyClass')->shouldIgnoreMissing()->asUndefined(); + +The returned object is nothing more than a placeholder so if, by some act of +fate, it's erroneously used somewhere it shouldn't it will likely not pass a +logic check. + +We have encountered the ``makePartial()`` method before, as it is the method we +use to create runtime partial test doubles: + +.. code-block:: php + + \Mockery::mock('MyClass')->makePartial(); + +This form of mock object will defer all methods not subject to an expectation to +the parent class of the mock, i.e. ``MyClass``. Whereas the previous +``shouldIgnoreMissing()`` returned ``null``, this behaviour simply calls the +parent's matching method. diff --git a/vendor/mockery/mockery/docs/reference/demeter_chains.rst b/vendor/mockery/mockery/docs/reference/demeter_chains.rst new file mode 100644 index 000000000..1dad5effe --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/demeter_chains.rst @@ -0,0 +1,38 @@ +.. index:: + single: Mocking; Demeter Chains + +Mocking Demeter Chains And Fluent Interfaces +============================================ + +Both of these terms refer to the growing practice of invoking statements +similar to: + +.. code-block:: php + + $object->foo()->bar()->zebra()->alpha()->selfDestruct(); + +The long chain of method calls isn't necessarily a bad thing, assuming they +each link back to a local object the calling class knows. As a fun example, +Mockery's long chains (after the first ``shouldReceive()`` method) all call to +the same instance of ``\Mockery\Expectation``. However, sometimes this is not +the case and the chain is constantly crossing object boundaries. + +In either case, mocking such a chain can be a horrible task. To make it easier +Mockery supports demeter chain mocking. Essentially, we shortcut through the +chain and return a defined value from the final call. For example, let's +assume ``selfDestruct()`` returns the string "Ten!" to $object (an instance of +``CaptainsConsole``). Here's how we could mock it. + +.. code-block:: php + + $mock = \Mockery::mock('CaptainsConsole'); + $mock->shouldReceive('foo->bar->zebra->alpha->selfDestruct')->andReturn('Ten!'); + +The above expectation can follow any previously seen format or expectation, +except that the method name is simply the string of all expected chain calls +separated by ``->``. Mockery will automatically setup the chain of expected +calls with its final return values, regardless of whatever intermediary object +might be used in the real implementation. + +Arguments to all members of the chain (except the final call) are ignored in +this process. diff --git a/vendor/mockery/mockery/docs/reference/expectations.rst b/vendor/mockery/mockery/docs/reference/expectations.rst new file mode 100644 index 000000000..fb1d736d4 --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/expectations.rst @@ -0,0 +1,465 @@ +.. index:: + single: Expectations + +Expectation Declarations +======================== + +.. note:: + + In order for our expectations to work we MUST call ``Mockery::close()``, + preferably in a callback method such as ``tearDown`` or ``_before`` + (depending on whether or not we're integrating Mockery with another + framework). This static call cleans up the Mockery container used by the + current test, and run any verification tasks needed for our expectations. + +Once we have created a mock object, we'll often want to start defining how +exactly it should behave (and how it should be called). This is where the +Mockery expectation declarations take over. + +Declaring Method Call Expectations +---------------------------------- + +To tell our test double to expect a call for a method with a given name, we use +the ``shouldReceive`` method: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method'); + +This is the starting expectation upon which all other expectations and +constraints are appended. + +We can declare more than one method call to be expected: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method_1', 'name_of_method_2'); + +All of these will adopt any chained expectations or constraints. + +It is possible to declare the expectations for the method calls, along with +their return values: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive([ + 'name_of_method_1' => 'return value 1', + 'name_of_method_2' => 'return value 2', + ]); + +There's also a shorthand way of setting up method call expectations and their +return values: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass', ['name_of_method_1' => 'return value 1', 'name_of_method_2' => 'return value 2']); + +All of these will adopt any additional chained expectations or constraints. + +We can declare that a test double should not expect a call to the given method +name: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldNotReceive('name_of_method'); + +This method is a convenience method for calling ``shouldReceive()->never()``. + +Declaring Method Argument Expectations +-------------------------------------- + +For every method we declare expectation for, we can add constraints that the +defined expectations apply only to the method calls that match the expected +argument list: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->with($arg1, $arg2, ...); + // or + $mock->shouldReceive('name_of_method') + ->withArgs([$arg1, $arg2, ...]); + +We can add a lot more flexibility to argument matching using the built in +matcher classes (see later). For example, ``\Mockery::any()`` matches any +argument passed to that position in the ``with()`` parameter list. Mockery also +allows Hamcrest library matchers - for example, the Hamcrest function +``anything()`` is equivalent to ``\Mockery::any()``. + +It's important to note that this means all expectations attached only apply to +the given method when it is called with these exact arguments: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + + $mock->shouldReceive('foo')->with('Hello'); + + $mock->foo('Goodbye'); // throws a NoMatchingExpectationException + +This allows for setting up differing expectations based on the arguments +provided to expected calls. + +Argument matching with closures +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Instead of providing a built-in matcher for each argument, we can provide a +closure that matches all passed arguments at once: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->withArgs(closure); + +The given closure receives all the arguments passed in the call to the expected +method. In this way, this expectation only applies to method calls where passed +arguments make the closure evaluate to true: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + + $mock->shouldReceive('foo')->withArgs(function ($arg) { + if ($arg % 2 == 0) { + return true; + } + return false; + }); + + $mock->foo(4); // matches the expectation + $mock->foo(3); // throws a NoMatchingExpectationException + +Any, or no arguments +^^^^^^^^^^^^^^^^^^^^ + +We can declare that the expectation matches a method call regardless of what +arguments are passed: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->withAnyArgs(); + +This is set by default unless otherwise specified. + +We can declare that the expectation matches method calls with zero arguments: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->withNoArgs(); + +Declaring Return Value Expectations +----------------------------------- + +For mock objects, we can tell Mockery what return values to return from the +expected method calls. + +For that we can use the ``andReturn()`` method: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andReturn($value); + +This sets a value to be returned from the expected method call. + +It is possible to set up expectation for multiple return values. By providing +a sequence of return values, we tell Mockery what value to return on every +subsequent call to the method: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andReturn($value1, $value2, ...) + +The first call will return ``$value1`` and the second call will return ``$value2``. + +If we call the method more times than the number of return values we declared, +Mockery will return the final value for any subsequent method call: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + + $mock->shouldReceive('foo')->andReturn(1, 2, 3); + + $mock->foo(); // int(1) + $mock->foo(); // int(2) + $mock->foo(); // int(3) + $mock->foo(); // int(3) + +The same can be achieved using the alternative syntax: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andReturnValues([$value1, $value2, ...]) + +It accepts a simple array instead of a list of parameters. The order of return +is determined by the numerical index of the given array with the last array +member being returned on all calls once previous return values are exhausted. + +The following two options are primarily for communication with test readers: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andReturnNull(); + // or + $mock->shouldReceive('name_of_method') + ->andReturn([null]); + +They mark the mock object method call as returning ``null`` or nothing. + +Sometimes we want to calculate the return results of the method calls, based on +the arguments passed to the method. We can do that with the ``andReturnUsing()`` +method which accepts one or more closure: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andReturnUsing(closure, ...); + +Closures can be queued by passing them as extra parameters as for ``andReturn()``. + +.. note:: + + We cannot currently mix ``andReturnUsing()`` with ``andReturn()``. + +If we are mocking fluid interfaces, the following method will be helpful: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andReturnSelf(); + +It sets the return value to the mocked class name. + +Throwing Exceptions +------------------- + +We can tell the method of mock objects to throw exceptions: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andThrow(Exception); + +It will throw the given ``Exception`` object when called. + +Rather than an object, we can pass in the ``Exception`` class and message to +use when throwing an ``Exception`` from the mocked method: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andThrow(exception_name, message); + +.. _expectations-setting-public-properties: + +Setting Public Properties +------------------------- + +Used with an expectation so that when a matching method is called, we can cause +a mock object's public property to be set to a specified value, by using +``andSet()`` or ``set()``: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->andSet($property, $value); + // or + $mock->shouldReceive('name_of_method') + ->set($property, $value); + +In cases where we want to call the real method of the class that was mocked and +return its result, the ``passthru()`` method tells the expectation to bypass +a return queue: + +.. code-block:: php + + passthru() + +It allows expectation matching and call count validation to be applied against +real methods while still calling the real class method with the expected +arguments. + +Declaring Call Count Expectations +--------------------------------- + +Besides setting expectations on the arguments of the method calls, and the +return values of those same calls, we can set expectations on how many times +should any method be called. + +When a call count expectation is not met, a +``\Mockery\Expectation\InvalidCountException`` will be thrown. + +.. note:: + + It is absolutely required to call ``\Mockery::close()`` at the end of our + tests, for example in the ``tearDown()`` method of PHPUnit. Otherwise + Mockery will not verify the calls made against our mock objects. + +We can declare that the expected method may be called zero or more times: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->zeroOrMoreTimes(); + +This is the default for all methods unless otherwise set. + +To tell Mockery to expect an exact number of calls to a method, we can use the +following: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->times($n); + +where ``$n`` is the number of times the method should be called. + +A couple of most common cases got their shorthand methods. + +To declare that the expected method must be called one time only: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->once(); + +To declare that the expected method must be called two times: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->twice(); + +To declare that the expected method must never be called: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->never(); + +Call count modifiers +^^^^^^^^^^^^^^^^^^^^ + +The call count expectations can have modifiers set. + +If we want to tell Mockery the minimum number of times a method should be called, +we use ``atLeast()``: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->atLeast() + ->times(3); + +``atLeast()->times(3)`` means the call must be called at least three times +(given matching method args) but never less than three times. + +Similarly, we can tell Mockery the maximum number of times a method should be +called, using ``atMost()``: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->atMost() + ->times(3); + +``atMost()->times(3)`` means the call must be called no more than three times. +If the method gets no calls at all, the expectation will still be met. + +We can also set a range of call counts, using ``between()``: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass'); + $mock->shouldReceive('name_of_method') + ->between($min, $max); + +This is actually identical to using ``atLeast()->times($min)->atMost()->times($max)`` +but is provided as a shorthand. It may be followed by a ``times()`` call with no +parameter to preserve the APIs natural language readability. + +Expectation Declaration Utilities +--------------------------------- + +Declares that this method is expected to be called in a specific order in +relation to similarly marked methods. + +.. code-block:: php + + ordered() + +The order is dictated by the order in which this modifier is actually used when +setting up mocks. + +Declares the method as belonging to an order group (which can be named or +numbered). Methods within a group can be called in any order, but the ordered +calls from outside the group are ordered in relation to the group: + +.. code-block:: php + + ordered(group) + +We can set up so that method1 is called before group1 which is in turn called +before method2. + +When called prior to ``ordered()`` or ``ordered(group)``, it declares this +ordering to apply across all mock objects (not just the current mock): + +.. code-block:: php + + globally() + +This allows for dictating order expectations across multiple mocks. + +The ``byDefault()`` marks an expectation as a default. Default expectations are +applied unless a non-default expectation is created: + +.. code-block:: php + + byDefault() + +These later expectations immediately replace the previously defined default. +This is useful so we can setup default mocks in our unit test ``setup()`` and +later tweak them in specific tests as needed. + +Returns the current mock object from an expectation chain: + +.. code-block:: php + + getMock() + +Useful where we prefer to keep mock setups as a single statement, e.g.: + +.. code-block:: php + + $mock = \Mockery::mock('foo')->shouldReceive('foo')->andReturn(1)->getMock(); diff --git a/vendor/mockery/mockery/docs/reference/final_methods_classes.rst b/vendor/mockery/mockery/docs/reference/final_methods_classes.rst new file mode 100644 index 000000000..3b2c443f7 --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/final_methods_classes.rst @@ -0,0 +1,28 @@ +.. index:: + single: Mocking; Final Classes/Methods + +Dealing with Final Classes/Methods +================================== + +One of the primary restrictions of mock objects in PHP, is that mocking +classes or methods marked final is hard. The final keyword prevents methods so +marked from being replaced in subclasses (subclassing is how mock objects can +inherit the type of the class or object being mocked). + +The simplest solution is to not mark classes or methods as final! + +However, in a compromise between mocking functionality and type safety, +Mockery does allow creating "proxy mocks" from classes marked final, or from +classes with methods marked final. This offers all the usual mock object +goodness but the resulting mock will not inherit the class type of the object +being mocked, i.e. it will not pass any instanceof comparison. Methods marked +as final will be proxied to the original method, i.e., final methods can't be +mocked. + +We can create a proxy mock by passing the instantiated object we wish to +mock into ``\Mockery::mock()``, i.e. Mockery will then generate a Proxy to the +real object and selectively intercept method calls for the purposes of setting +and meeting expectations. + +See the :ref:`creating-test-doubles-partial-test-doubles` chapter, the subsection +about proxied partial test doubles. diff --git a/vendor/mockery/mockery/docs/reference/index.rst b/vendor/mockery/mockery/docs/reference/index.rst new file mode 100644 index 000000000..1e5bf0481 --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/index.rst @@ -0,0 +1,22 @@ +Reference +========= + +.. toctree:: + :hidden: + + creating_test_doubles + expectations + argument_validation + alternative_should_receive_syntax + spies + partial_mocks + protected_methods + public_properties + public_static_properties + pass_by_reference_behaviours + demeter_chains + final_methods_classes + magic_methods + phpunit_integration + +.. include:: map.rst.inc diff --git a/vendor/mockery/mockery/docs/reference/instance_mocking.rst b/vendor/mockery/mockery/docs/reference/instance_mocking.rst new file mode 100644 index 000000000..9d1aa283e --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/instance_mocking.rst @@ -0,0 +1,22 @@ +.. index:: + single: Mocking; Instance + +Instance Mocking +================ + +Instance mocking means that a statement like: + +.. code-block:: php + + $obj = new \MyNamespace\Foo; + +...will actually generate a mock object. This is done by replacing the real +class with an instance mock (similar to an alias mock), as with mocking public +methods. The alias will import its expectations from the original mock of +that type (note that the original is never verified and should be ignored +after its expectations are setup). This lets you intercept instantiation where +you can't simply inject a replacement object. + +As before, this does not prevent a require statement from including the real +class and triggering a fatal PHP error. It's intended for use where +autoloading is the primary class loading mechanism. diff --git a/vendor/mockery/mockery/docs/reference/magic_methods.rst b/vendor/mockery/mockery/docs/reference/magic_methods.rst new file mode 100644 index 000000000..39591cff4 --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/magic_methods.rst @@ -0,0 +1,16 @@ +.. index:: + single: Mocking; Magic Methods + +PHP Magic Methods +================= + +PHP magic methods which are prefixed with a double underscore, e.g. +``__set()``, pose a particular problem in mocking and unit testing in general. +It is strongly recommended that unit tests and mock objects do not directly +refer to magic methods. Instead, refer only to the virtual methods and +properties these magic methods simulate. + +Following this piece of advice will ensure we are testing the real API of +classes and also ensures there is no conflict should Mockery override these +magic methods, which it will inevitably do in order to support its role in +intercepting method calls and properties. diff --git a/vendor/mockery/mockery/docs/reference/map.rst.inc b/vendor/mockery/mockery/docs/reference/map.rst.inc new file mode 100644 index 000000000..883bc3caf --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/map.rst.inc @@ -0,0 +1,14 @@ +* :doc:`/reference/creating_test_doubles` +* :doc:`/reference/expectations` +* :doc:`/reference/argument_validation` +* :doc:`/reference/alternative_should_receive_syntax` +* :doc:`/reference/spies` +* :doc:`/reference/partial_mocks` +* :doc:`/reference/protected_methods` +* :doc:`/reference/public_properties` +* :doc:`/reference/public_static_properties` +* :doc:`/reference/pass_by_reference_behaviours` +* :doc:`/reference/demeter_chains` +* :doc:`/reference/final_methods_classes` +* :doc:`/reference/magic_methods` +* :doc:`/reference/phpunit_integration` diff --git a/vendor/mockery/mockery/docs/reference/partial_mocks.rst b/vendor/mockery/mockery/docs/reference/partial_mocks.rst new file mode 100644 index 000000000..457eb8deb --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/partial_mocks.rst @@ -0,0 +1,108 @@ +.. index:: + single: Mocking; Partial Mocks + +Creating Partial Mocks +====================== + +Partial mocks are useful when we only need to mock several methods of an +object leaving the remainder free to respond to calls normally (i.e. as +implemented). Mockery implements three distinct strategies for creating +partials. Each has specific advantages and disadvantages so which strategy we +use will depend on our own preferences and the source code in need of +mocking. + +We have previously talked a bit about :ref:`creating-test-doubles-partial-test-doubles`, +but we'd like to expand on the subject a bit here. + +#. Runtime partial test doubles +#. Generated partial test doubles +#. Proxied Partial Mock + +Runtime partial test doubles +---------------------------- + +A runtime partial test double, also known as a passive partial mock, is a kind +of a default state of being for a mocked object. + +.. code-block:: php + + $mock = \Mockery::mock('MyClass')->makePartial(); + +With a runtime partial, we assume that all methods will simply defer to the +parent class (``MyClass``) original methods unless a method call matches a +known expectation. If we have no matching expectation for a specific method +call, that call is deferred to the class being mocked. Since the division +between mocked and unmocked calls depends entirely on the expectations we +define, there is no need to define which methods to mock in advance. + +See the cookbook entry on :doc:`../cookbook/big_parent_class` for an example +usage of runtime partial test doubles. + +Generated Partial Test Doubles +------------------------------ + +A generated partial test double, also known as a traditional partial mock, +defines ahead of time which methods of a class are to be mocked and which are +to be left unmocked (i.e. callable as normal). The syntax for creating +traditional mocks is: + +.. code-block:: php + + $mock = \Mockery::mock('MyClass[foo,bar]'); + +In the above example, the ``foo()`` and ``bar()`` methods of MyClass will be +mocked but no other MyClass methods are touched. We will need to define +expectations for the ``foo()`` and ``bar()`` methods to dictate their mocked +behaviour. + +Don't forget that we can pass in constructor arguments since unmocked methods +may rely on those! + +.. code-block:: php + + $mock = \Mockery::mock('MyNamespace\MyClass[foo]', array($arg1, $arg2)); + +See the :ref:`creating-test-doubles-constructor-arguments` section to read up +on them. + +.. note:: + + Even though we support generated partial test doubles, we do not recommend + using them. + +Proxied Partial Mock +-------------------- + +A proxied partial mock is a partial of last resort. We may encounter a class +which is simply not capable of being mocked because it has been marked as +final. Similarly, we may find a class with methods marked as final. In such a +scenario, we cannot simply extend the class and override methods to mock - we +need to get creative. + +.. code-block:: php + + $mock = \Mockery::mock(new MyClass); + +Yes, the new mock is a Proxy. It intercepts calls and reroutes them to the +proxied object (which we construct and pass in) for methods which are not +subject to any expectations. Indirectly, this allows us to mock methods +marked final since the Proxy is not subject to those limitations. The tradeoff +should be obvious - a proxied partial will fail any typehint checks for the +class being mocked since it cannot extend that class. + +Special Internal Cases +---------------------- + +All mock objects, with the exception of Proxied Partials, allows us to make +any expectation call to the underlying real class method using the ``passthru()`` +expectation call. This will return values from the real call and bypass any +mocked return queue (which can simply be omitted obviously). + +There is a fourth kind of partial mock reserved for internal use. This is +automatically generated when we attempt to mock a class containing methods +marked final. Since we cannot override such methods, they are simply left +unmocked. Typically, we don't need to worry about this but if we really +really must mock a final method, the only possible means is through a Proxied +Partial Mock. SplFileInfo, for example, is a common class subject to this form +of automatic internal partial since it contains public final methods used +internally. diff --git a/vendor/mockery/mockery/docs/reference/pass_by_reference_behaviours.rst b/vendor/mockery/mockery/docs/reference/pass_by_reference_behaviours.rst new file mode 100644 index 000000000..5e2e457f6 --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/pass_by_reference_behaviours.rst @@ -0,0 +1,130 @@ +.. index:: + single: Pass-By-Reference Method Parameter Behaviour + +Preserving Pass-By-Reference Method Parameter Behaviour +======================================================= + +PHP Class method may accept parameters by reference. In this case, changes +made to the parameter (a reference to the original variable passed to the +method) are reflected in the original variable. An example: + +.. code-block:: php + + class Foo + { + + public function bar(&$a) + { + $a++; + } + + } + + $baz = 1; + $foo = new Foo; + $foo->bar($baz); + + echo $baz; // will echo the integer 2 + +In the example above, the variable ``$baz`` is passed by reference to +``Foo::bar()`` (notice the ``&`` symbol in front of the parameter?). Any +change ``bar()`` makes to the parameter reference is reflected in the original +variable, ``$baz``. + +Mockery handles references correctly for all methods where it can analyse +the parameter (using ``Reflection``) to see if it is passed by reference. To +mock how a reference is manipulated by the class method, we can use a closure +argument matcher to manipulate it, i.e. ``\Mockery::on()`` - see the +:ref:`argument-validation-complex-argument-validation` chapter. + +There is an exception for internal PHP classes where Mockery cannot analyse +method parameters using ``Reflection`` (a limitation in PHP). To work around +this, we can explicitly declare method parameters for an internal class using +``\Mockery\Configuration::setInternalClassMethodParamMap()``. + +Here's an example using ``MongoCollection::insert()``. ``MongoCollection`` is +an internal class offered by the mongo extension from PECL. Its ``insert()`` +method accepts an array of data as the first parameter, and an optional +options array as the second parameter. The original data array is updated +(i.e. when a ``insert()`` pass-by-reference parameter) to include a new +``_id`` field. We can mock this behaviour using a configured parameter map (to +tell Mockery to expect a pass by reference parameter) and a ``Closure`` +attached to the expected method parameter to be updated. + +Here's a PHPUnit unit test verifying that this pass-by-reference behaviour is +preserved: + +.. code-block:: php + + public function testCanOverrideExpectedParametersOfInternalPHPClassesToPreserveRefs() + { + \Mockery::getConfiguration()->setInternalClassMethodParamMap( + 'MongoCollection', + 'insert', + array('&$data', '$options = array()') + ); + $m = \Mockery::mock('MongoCollection'); + $m->shouldReceive('insert')->with( + \Mockery::on(function(&$data) { + if (!is_array($data)) return false; + $data['_id'] = 123; + return true; + }), + \Mockery::any() + ); + + $data = array('a'=>1,'b'=>2); + $m->insert($data); + + $this->assertTrue(isset($data['_id'])); + $this->assertEquals(123, $data['_id']); + + \Mockery::resetContainer(); + } + +Protected Methods +----------------- + +When dealing with protected methods, and trying to preserve pass by reference +behavior for them, a different approach is required. + +.. code-block:: php + + class Model + { + public function test(&$data) + { + return $this->doTest($data); + } + + protected function doTest(&$data) + { + $data['something'] = 'wrong'; + return $this; + } + } + + class Test extends \PHPUnit\Framework\TestCase + { + public function testModel() + { + $mock = \Mockery::mock('Model[test]')->shouldAllowMockingProtectedMethods(); + + $mock->shouldReceive('test') + ->with(\Mockery::on(function(&$data) { + $data['something'] = 'wrong'; + return true; + })); + + $data = array('foo' => 'bar'); + + $mock->test($data); + $this->assertTrue(isset($data['something'])); + $this->assertEquals('wrong', $data['something']); + } + } + +This is quite an edge case, so we need to change the original code a little bit, +by creating a public method that will call our protected method, and then mock +that, instead of the protected method. This new public method will act as a +proxy to our protected method. diff --git a/vendor/mockery/mockery/docs/reference/phpunit_integration.rst b/vendor/mockery/mockery/docs/reference/phpunit_integration.rst new file mode 100644 index 000000000..7528b5aae --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/phpunit_integration.rst @@ -0,0 +1,151 @@ +.. index:: + single: PHPUnit Integration + +PHPUnit Integration +=================== + +Mockery was designed as a simple-to-use *standalone* mock object framework, so +its need for integration with any testing framework is entirely optional. To +integrate Mockery, we need to define a ``tearDown()`` method for our tests +containing the following (we may use a shorter ``\Mockery`` namespace +alias): + +.. code-block:: php + + public function tearDown() { + \Mockery::close(); + } + +This static call cleans up the Mockery container used by the current test, and +run any verification tasks needed for our expectations. + +For some added brevity when it comes to using Mockery, we can also explicitly +use the Mockery namespace with a shorter alias. For example: + +.. code-block:: php + + use \Mockery as m; + + class SimpleTest extends \PHPUnit\Framework\TestCase + { + public function testSimpleMock() { + $mock = m::mock('simplemock'); + $mock->shouldReceive('foo')->with(5, m::any())->once()->andReturn(10); + + $this->assertEquals(10, $mock->foo(5)); + } + + public function tearDown() { + m::close(); + } + } + +Mockery ships with an autoloader so we don't need to litter our tests with +``require_once()`` calls. To use it, ensure Mockery is on our +``include_path`` and add the following to our test suite's ``Bootstrap.php`` +or ``TestHelper.php`` file: + +.. code-block:: php + + require_once 'Mockery/Loader.php'; + require_once 'Hamcrest/Hamcrest.php'; + + $loader = new \Mockery\Loader; + $loader->register(); + +If we are using Composer, we can simplify this to including the Composer +generated autoloader file: + +.. code-block:: php + + require __DIR__ . '/../vendor/autoload.php'; // assuming vendor is one directory up + +.. caution:: + + Prior to Hamcrest 1.0.0, the ``Hamcrest.php`` file name had a small "h" + (i.e. ``hamcrest.php``). If upgrading Hamcrest to 1.0.0 remember to check + the file name is updated for all your projects.) + +To integrate Mockery into PHPUnit and avoid having to call the close method +and have Mockery remove itself from code coverage reports, have your test case +extends the ``\Mockery\Adapter\Phpunit\MockeryTestCase``: + +.. code-block:: php + + class MyTest extends \Mockery\Adapter\Phpunit\MockeryTestCase + { + + } + +An alternative is to use the supplied trait: + +.. code-block:: php + + class MyTest extends \PHPUnit\Framework\TestCase + { + use \Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration; + } + +Extending ``MockeryTestCase`` or using the ``MockeryPHPUnitIntegration`` +trait is **the recommended way** of integrating Mockery with PHPUnit, +since Mockery 1.0.0. + +PHPUnit listener +---------------- + +Before the 1.0.0 release, Mockery provided a PHPUnit listener that would +call ``Mockery::close()`` for us at the end of a test. This has changed +significantly since the 1.0.0 version. + +Now, Mockery provides a PHPUnit listener that makes tests fail if +``Mockery::close()`` has not been called. It can help identify tests where +we've forgotten to include the trait or extend the ``MockeryTestCase``. + +If we are using PHPUnit's XML configuration approach, we can include the +following to load the ``TestListener``: + +.. code-block:: xml + + + + + +Make sure Composer's or Mockery's autoloader is present in the bootstrap file +or we will need to also define a "file" attribute pointing to the file of the +``TestListener`` class. + +.. caution:: + + The ``TestListener`` will only work for PHPUnit 6+ versions. + + For PHPUnit versions 5 and lower, the test listener does not work. + +If we are creating the test suite programmatically we may add the listener +like this: + +.. code-block:: php + + // Create the suite. + $suite = new PHPUnit\Framework\TestSuite(); + + // Create the listener and add it to the suite. + $result = new PHPUnit\Framework\TestResult(); + $result->addListener(new \Mockery\Adapter\Phpunit\TestListener()); + + // Run the tests. + $suite->run($result); + +.. caution:: + + PHPUnit provides a functionality that allows + `tests to run in a separated process `_, + to ensure better isolation. Mockery verifies the mocks expectations using the + ``Mockery::close()`` method, and provides a PHPUnit listener, that automatically + calls this method for us after every test. + + However, this listener is not called in the right process when using + PHPUnit's process isolation, resulting in expectations that might not be + respected, but without raising any ``Mockery\Exception``. To avoid this, + we cannot rely on the supplied Mockery PHPUnit ``TestListener``, and we need + to explicitly call ``Mockery::close``. The easiest solution to include this + call in the ``tearDown()`` method, as explained previously. diff --git a/vendor/mockery/mockery/docs/reference/protected_methods.rst b/vendor/mockery/mockery/docs/reference/protected_methods.rst new file mode 100644 index 000000000..ec4a5bad8 --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/protected_methods.rst @@ -0,0 +1,26 @@ +.. index:: + single: Mocking; Protected Methods + +Mocking Protected Methods +========================= + +By default, Mockery does not allow mocking protected methods. We do not recommend +mocking protected methods, but there are cases when there is no other solution. + +For those cases we have the ``shouldAllowMockingProtectedMethods()`` method. It +instructs Mockery to specifically allow mocking of protected methods, for that +one class only: + +.. code-block:: php + + class MyClass + { + protected function foo() + { + } + } + + $mock = \Mockery::mock('MyClass') + ->shouldAllowMockingProtectedMethods(); + $mock->shouldReceive('foo'); + diff --git a/vendor/mockery/mockery/docs/reference/public_properties.rst b/vendor/mockery/mockery/docs/reference/public_properties.rst new file mode 100644 index 000000000..316566831 --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/public_properties.rst @@ -0,0 +1,20 @@ +.. index:: + single: Mocking; Public Properties + +Mocking Public Properties +========================= + +Mockery allows us to mock properties in several ways. One way is that we can set +a public property and its value on any mock object. The second is that we can +use the expectation methods ``set()`` and ``andSet()`` to set property values if +that expectation is ever met. + +You can read more about :ref:`expectations-setting-public-properties`. + +.. note:: + + In general, Mockery does not support mocking any magic methods since these + are generally not considered a public API (and besides it is a bit difficult + to differentiate them when you badly need them for mocking!). So please mock + virtual properties (those relying on ``__get()`` and ``__set()``) as if they + were actually declared on the class. diff --git a/vendor/mockery/mockery/docs/reference/public_static_properties.rst b/vendor/mockery/mockery/docs/reference/public_static_properties.rst new file mode 100644 index 000000000..2396efc7c --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/public_static_properties.rst @@ -0,0 +1,15 @@ +.. index:: + single: Mocking; Public Static Methods + +Mocking Public Static Methods +============================= + +Static methods are not called on real objects, so normal mock objects can't +mock them. Mockery supports class aliased mocks, mocks representing a class +name which would normally be loaded (via autoloading or a require statement) +in the system under test. These aliases block that loading (unless via a +require statement - so please use autoloading!) and allow Mockery to intercept +static method calls and add expectations for them. + +See the :ref:`creating-test-doubles-aliasing` section for more information on +creating aliased mocks, for the purpose of mocking public static methods. diff --git a/vendor/mockery/mockery/docs/reference/spies.rst b/vendor/mockery/mockery/docs/reference/spies.rst new file mode 100644 index 000000000..77f37f3db --- /dev/null +++ b/vendor/mockery/mockery/docs/reference/spies.rst @@ -0,0 +1,154 @@ +.. index:: + single: Reference; Spies + +Spies +===== + +Spies are a type of test doubles, but they differ from stubs or mocks in that, +that the spies record any interaction between the spy and the System Under Test +(SUT), and allow us to make assertions against those interactions after the fact. + +Creating a spy means we don't have to set up expectations for every method call +the double might receive during the test, some of which may not be relevant to +the current test. A spy allows us to make assertions about the calls we care +about for this test only, reducing the chances of over-specification and making +our tests more clear. + +Spies also allow us to follow the more familiar Arrange-Act-Assert or +Given-When-Then style within our tests. With mocks, we have to follow a less +familiar style, something along the lines of Arrange-Expect-Act-Assert, where +we have to tell our mocks what to expect before we act on the sut, then assert +that those expectations where met: + +.. code-block:: php + + // arrange + $mock = \Mockery::mock('MyDependency'); + $sut = new MyClass($mock); + + // expect + $mock->shouldReceive('foo') + ->once() + ->with('bar'); + + // act + $sut->callFoo(); + + // assert + \Mockery::close(); + +Spies allow us to skip the expect part and move the assertion to after we have +acted on the SUT, usually making our tests more readable: + +.. code-block:: php + + // arrange + $spy = \Mockery::spy('MyDependency'); + $sut = new MyClass($spy); + + // act + $sut->callFoo(); + + // assert + $spy->shouldHaveReceived() + ->foo() + ->with('bar'); + +On the other hand, spies are far less restrictive than mocks, meaning tests are +usually less precise, as they let us get away with more. This is usually a +good thing, they should only be as precise as they need to be, but while spies +make our tests more intent-revealing, they do tend to reveal less about the +design of the SUT. If we're having to setup lots of expectations for a mock, +in lots of different tests, our tests are trying to tell us something - the SUT +is doing too much and probably should be refactored. We don't get this with +spies, they simply ignore the calls that aren't relevant to them. + +Another downside to using spies is debugging. When a mock receives a call that +it wasn't expecting, it immediately throws an exception (failing fast), giving +us a nice stack trace or possibly even invoking our debugger. With spies, we're +simply asserting calls were made after the fact, so if the wrong calls were made, +we don't have quite the same just in time context we have with the mocks. + +Finally, if we need to define a return value for our test double, we can't do +that with a spy, only with a mock object. + +.. note:: + + This documentation page is an adaption of the blog post titled + `"Mockery Spies" `_, + published by Dave Marshall on his blog. Dave is the original author of spies + in Mockery. + +Spies Reference +--------------- + +To verify that a method was called on a spy, we use the ``shouldHaveReceived()`` +method: + +.. code-block:: php + + $spy->shouldHaveReceived('foo'); + +To verify that a method was **not** called on a spy, we use the +``shouldNotHaveReceived()`` method: + +.. code-block:: php + + $spy->shouldNotHaveReceived('foo'); + +We can also do argument matching with spies: + +.. code-block:: php + + $spy->shouldHaveReceived('foo') + ->with('bar'); + +Argument matching is also possible by passing in an array of arguments to +match: + +.. code-block:: php + + $spy->shouldHaveReceived('foo', ['bar']); + +Although when verifying a method was not called, the argument matching can only +be done by supplying the array of arguments as the 2nd argument to the +``shouldNotHaveReceived()`` method: + +.. code-block:: php + + $spy->shouldNotHaveReceived('foo', ['bar']); + +This is due to Mockery's internals. + +Finally, when expecting calls that should have been received, we can also verify +the number of calls: + +.. code-block:: php + + $spy->shouldHaveReceived('foo') + ->with('bar') + ->twice(); + +Alternative shouldReceive syntax +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +As of Mockery 1.0.0, we support calling methods as we would call any PHP method, +and not as string arguments to Mockery ``should*`` methods. + +In cases of spies, this only applies to the ``shouldHaveReceived()`` method: + +.. code-block:: php + + $spy->shouldHaveReceived() + ->foo('bar'); + +We can set expectation on number of calls as well: + +.. code-block:: php + + $spy->shouldHaveReceived() + ->foo('bar') + ->twice(); + +Unfortunately, due to limitations we can't support the same syntax for the +``shouldNotHaveReceived()`` method. diff --git a/vendor/mockery/mockery/library/Mockery.php b/vendor/mockery/mockery/library/Mockery.php new file mode 100644 index 000000000..8725f9199 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery.php @@ -0,0 +1,950 @@ += 0) { + $builtInTypes[] = 'object'; + } + + return $builtInTypes; + } + + /** + * @param string $type + * @return bool + */ + public static function isBuiltInType($type) + { + return in_array($type, \Mockery::builtInTypes()); + } + + /** + * Static shortcut to \Mockery\Container::mock(). + * + * @param array ...$args + * + * @return \Mockery\MockInterface + */ + public static function mock(...$args) + { + return call_user_func_array(array(self::getContainer(), 'mock'), $args); + } + + /** + * Static and semantic shortcut for getting a mock from the container + * and applying the spy's expected behavior into it. + * + * @param array ...$args + * + * @return \Mockery\MockInterface + */ + public static function spy(...$args) + { + if (count($args) && $args[0] instanceof \Closure) { + $args[0] = new ClosureWrapper($args[0]); + } + + return call_user_func_array(array(self::getContainer(), 'mock'), $args)->shouldIgnoreMissing(); + } + + /** + * Static and Semantic shortcut to \Mockery\Container::mock(). + * + * @param array ...$args + * + * @return \Mockery\MockInterface + */ + public static function instanceMock(...$args) + { + return call_user_func_array(array(self::getContainer(), 'mock'), $args); + } + + /** + * Static shortcut to \Mockery\Container::mock(), first argument names the mock. + * + * @param array ...$args + * + * @return \Mockery\MockInterface + */ + public static function namedMock(...$args) + { + $name = array_shift($args); + + $builder = new MockConfigurationBuilder(); + $builder->setName($name); + + array_unshift($args, $builder); + + return call_user_func_array(array(self::getContainer(), 'mock'), $args); + } + + /** + * Static shortcut to \Mockery\Container::self(). + * + * @throws LogicException + * + * @return \Mockery\MockInterface + */ + public static function self() + { + if (is_null(self::$_container)) { + throw new \LogicException('You have not declared any mocks yet'); + } + + return self::$_container->self(); + } + + /** + * Static shortcut to closing up and verifying all mocks in the global + * container, and resetting the container static variable to null. + * + * @return void + */ + public static function close() + { + foreach (self::$_filesToCleanUp as $fileName) { + @unlink($fileName); + } + self::$_filesToCleanUp = []; + + if (is_null(self::$_container)) { + return; + } + + $container = self::$_container; + self::$_container = null; + + $container->mockery_teardown(); + $container->mockery_close(); + } + + /** + * Static fetching of a mock associated with a name or explicit class poser. + * + * @param string $name + * + * @return \Mockery\Mock + */ + public static function fetchMock($name) + { + return self::$_container->fetchMock($name); + } + + /** + * Lazy loader and getter for + * the container property. + * + * @return Mockery\Container + */ + public static function getContainer() + { + if (is_null(self::$_container)) { + self::$_container = new Mockery\Container(self::getGenerator(), self::getLoader()); + } + + return self::$_container; + } + + /** + * Setter for the $_generator static propery. + * + * @param \Mockery\Generator\Generator $generator + */ + public static function setGenerator(Generator $generator) + { + self::$_generator = $generator; + } + + /** + * Lazy loader method and getter for + * the generator property. + * + * @return Generator + */ + public static function getGenerator() + { + if (is_null(self::$_generator)) { + self::$_generator = self::getDefaultGenerator(); + } + + return self::$_generator; + } + + /** + * Creates and returns a default generator + * used inside this class. + * + * @return CachingGenerator + */ + public static function getDefaultGenerator() + { + return new CachingGenerator(StringManipulationGenerator::withDefaultPasses()); + } + + /** + * Setter for the $_loader static property. + * + * @param Loader $loader + */ + public static function setLoader(Loader $loader) + { + self::$_loader = $loader; + } + + /** + * Lazy loader method and getter for + * the $_loader property. + * + * @return Loader + */ + public static function getLoader() + { + if (is_null(self::$_loader)) { + self::$_loader = self::getDefaultLoader(); + } + + return self::$_loader; + } + + /** + * Gets an EvalLoader to be used as default. + * + * @return EvalLoader + */ + public static function getDefaultLoader() + { + return new EvalLoader(); + } + + /** + * Set the container. + * + * @param \Mockery\Container $container + * + * @return \Mockery\Container + */ + public static function setContainer(Mockery\Container $container) + { + return self::$_container = $container; + } + + /** + * Reset the container to null. + * + * @return void + */ + public static function resetContainer() + { + self::$_container = null; + } + + /** + * Return instance of ANY matcher. + * + * @return \Mockery\Matcher\Any + */ + public static function any() + { + return new \Mockery\Matcher\Any(); + } + + /** + * Return instance of AndAnyOtherArgs matcher. + * + * An alternative name to `andAnyOtherArgs` so + * the API stays closer to `any` as well. + * + * @return \Mockery\Matcher\AndAnyOtherArgs + */ + public static function andAnyOthers() + { + return new \Mockery\Matcher\AndAnyOtherArgs(); + } + + /** + * Return instance of AndAnyOtherArgs matcher. + * + * @return \Mockery\Matcher\AndAnyOtherArgs + */ + public static function andAnyOtherArgs() + { + return new \Mockery\Matcher\AndAnyOtherArgs(); + } + + /** + * Return instance of TYPE matcher. + * + * @param mixed $expected + * + * @return \Mockery\Matcher\Type + */ + public static function type($expected) + { + return new \Mockery\Matcher\Type($expected); + } + + /** + * Return instance of DUCKTYPE matcher. + * + * @param array ...$args + * + * @return \Mockery\Matcher\Ducktype + */ + public static function ducktype(...$args) + { + return new \Mockery\Matcher\Ducktype($args); + } + + /** + * Return instance of SUBSET matcher. + * + * @param array $part + * @param bool $strict - (Optional) True for strict comparison, false for loose + * + * @return \Mockery\Matcher\Subset + */ + public static function subset(array $part, $strict = true) + { + return new \Mockery\Matcher\Subset($part, $strict); + } + + /** + * Return instance of CONTAINS matcher. + * + * @param array ...$args + * + * @return \Mockery\Matcher\Contains + */ + public static function contains(...$args) + { + return new \Mockery\Matcher\Contains($args); + } + + /** + * Return instance of HASKEY matcher. + * + * @param mixed $key + * + * @return \Mockery\Matcher\HasKey + */ + public static function hasKey($key) + { + return new \Mockery\Matcher\HasKey($key); + } + + /** + * Return instance of HASVALUE matcher. + * + * @param mixed $val + * + * @return \Mockery\Matcher\HasValue + */ + public static function hasValue($val) + { + return new \Mockery\Matcher\HasValue($val); + } + + /** + * Return instance of CLOSURE matcher. + * + * @param mixed $closure + * + * @return \Mockery\Matcher\Closure + */ + public static function on($closure) + { + return new \Mockery\Matcher\Closure($closure); + } + + /** + * Return instance of MUSTBE matcher. + * + * @param mixed $expected + * + * @return \Mockery\Matcher\MustBe + */ + public static function mustBe($expected) + { + return new \Mockery\Matcher\MustBe($expected); + } + + /** + * Return instance of NOT matcher. + * + * @param mixed $expected + * + * @return \Mockery\Matcher\Not + */ + public static function not($expected) + { + return new \Mockery\Matcher\Not($expected); + } + + /** + * Return instance of ANYOF matcher. + * + * @param array ...$args + * + * @return \Mockery\Matcher\AnyOf + */ + public static function anyOf(...$args) + { + return new \Mockery\Matcher\AnyOf($args); + } + + /** + * Return instance of NOTANYOF matcher. + * + * @param array ...$args + * + * @return \Mockery\Matcher\NotAnyOf + */ + public static function notAnyOf(...$args) + { + return new \Mockery\Matcher\NotAnyOf($args); + } + + /** + * Return instance of PATTERN matcher. + * + * @param mixed $expected + * + * @return \Mockery\Matcher\Pattern + */ + public static function pattern($expected) + { + return new \Mockery\Matcher\Pattern($expected); + } + + /** + * Lazy loader and Getter for the global + * configuration container. + * + * @return \Mockery\Configuration + */ + public static function getConfiguration() + { + if (is_null(self::$_config)) { + self::$_config = new \Mockery\Configuration(); + } + + return self::$_config; + } + + /** + * Utility method to format method name and arguments into a string. + * + * @param string $method + * @param array $arguments + * + * @return string + */ + public static function formatArgs($method, array $arguments = null) + { + if (is_null($arguments)) { + return $method . '()'; + } + + $formattedArguments = array(); + foreach ($arguments as $argument) { + $formattedArguments[] = self::formatArgument($argument); + } + + return $method . '(' . implode(', ', $formattedArguments) . ')'; + } + + /** + * Gets the string representation + * of any passed argument. + * + * @param mixed $argument + * @param int $depth + * + * @return mixed + */ + private static function formatArgument($argument, $depth = 0) + { + if ($argument instanceof MatcherAbstract) { + return (string) $argument; + } + + if (is_object($argument)) { + return 'object(' . get_class($argument) . ')'; + } + + if (is_int($argument) || is_float($argument)) { + return $argument; + } + + if (is_array($argument)) { + if ($depth === 1) { + $argument = '[...]'; + } else { + $sample = array(); + foreach ($argument as $key => $value) { + $key = is_int($key) ? $key : "'$key'"; + $value = self::formatArgument($value, $depth + 1); + $sample[] = "$key => $value"; + } + + $argument = "[".implode(", ", $sample)."]"; + } + + return ((strlen($argument) > 1000) ? substr($argument, 0, 1000).'...]' : $argument); + } + + if (is_bool($argument)) { + return $argument ? 'true' : 'false'; + } + + if (is_resource($argument)) { + return 'resource(...)'; + } + + if (is_null($argument)) { + return 'NULL'; + } + + return "'".(string) $argument."'"; + } + + /** + * Utility function to format objects to printable arrays. + * + * @param array $objects + * + * @return string + */ + public static function formatObjects(array $objects = null) + { + static $formatting; + + if ($formatting) { + return '[Recursion]'; + } + + if (is_null($objects)) { + return ''; + } + + $objects = array_filter($objects, 'is_object'); + if (empty($objects)) { + return ''; + } + + $formatting = true; + $parts = array(); + + foreach ($objects as $object) { + $parts[get_class($object)] = self::objectToArray($object); + } + + $formatting = false; + + return 'Objects: ( ' . var_export($parts, true) . ')'; + } + + /** + * Utility function to turn public properties and public get* and is* method values into an array. + * + * @param object $object + * @param int $nesting + * + * @return array + */ + private static function objectToArray($object, $nesting = 3) + { + if ($nesting == 0) { + return array('...'); + } + + return array( + 'class' => get_class($object), + 'properties' => self::extractInstancePublicProperties($object, $nesting) + ); + } + + /** + * Returns all public instance properties. + * + * @param mixed $object + * @param int $nesting + * + * @return array + */ + private static function extractInstancePublicProperties($object, $nesting) + { + $reflection = new \ReflectionClass(get_class($object)); + $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC); + $cleanedProperties = array(); + + foreach ($properties as $publicProperty) { + if (!$publicProperty->isStatic()) { + $name = $publicProperty->getName(); + $cleanedProperties[$name] = self::cleanupNesting($object->$name, $nesting); + } + } + + return $cleanedProperties; + } + + /** + * Utility method used for recursively generating + * an object or array representation. + * + * @param mixed $argument + * @param int $nesting + * + * @return mixed + */ + private static function cleanupNesting($argument, $nesting) + { + if (is_object($argument)) { + $object = self::objectToArray($argument, $nesting - 1); + $object['class'] = get_class($argument); + + return $object; + } + + if (is_array($argument)) { + return self::cleanupArray($argument, $nesting - 1); + } + + return $argument; + } + + /** + * Utility method for recursively + * gerating a representation + * of the given array. + * + * @param array $argument + * @param int $nesting + * + * @return mixed + */ + private static function cleanupArray($argument, $nesting = 3) + { + if ($nesting == 0) { + return '...'; + } + + foreach ($argument as $key => $value) { + if (is_array($value)) { + $argument[$key] = self::cleanupArray($value, $nesting - 1); + } elseif (is_object($value)) { + $argument[$key] = self::objectToArray($value, $nesting - 1); + } + } + + return $argument; + } + + /** + * Utility function to parse shouldReceive() arguments and generate + * expectations from such as needed. + * + * @param Mockery\MockInterface $mock + * @param array ...$args + * @param callable $add + * @return \Mockery\CompositeExpectation + */ + public static function parseShouldReturnArgs(\Mockery\MockInterface $mock, $args, $add) + { + $composite = new \Mockery\CompositeExpectation(); + + foreach ($args as $arg) { + if (is_array($arg)) { + foreach ($arg as $k => $v) { + $expectation = self::buildDemeterChain($mock, $k, $add)->andReturn($v); + $composite->add($expectation); + } + } elseif (is_string($arg)) { + $expectation = self::buildDemeterChain($mock, $arg, $add); + $composite->add($expectation); + } + } + + return $composite; + } + + /** + * Sets up expectations on the members of the CompositeExpectation and + * builds up any demeter chain that was passed to shouldReceive. + * + * @param \Mockery\MockInterface $mock + * @param string $arg + * @param callable $add + * @throws Mockery\Exception + * @return \Mockery\ExpectationInterface + */ + protected static function buildDemeterChain(\Mockery\MockInterface $mock, $arg, $add) + { + /** @var Mockery\Container $container */ + $container = $mock->mockery_getContainer(); + $methodNames = explode('->', $arg); + reset($methodNames); + + if (!\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() + && !$mock->mockery_isAnonymous() + && !in_array(current($methodNames), $mock->mockery_getMockableMethods()) + ) { + throw new \Mockery\Exception( + 'Mockery\'s configuration currently forbids mocking the method ' + . current($methodNames) . ' as it does not exist on the class or object ' + . 'being mocked' + ); + } + + /** @var ExpectationInterface|null $expectations */ + $expectations = null; + + /** @var Callable $nextExp */ + $nextExp = function ($method) use ($add) { + return $add($method); + }; + + $parent = get_class($mock); + + while (true) { + $method = array_shift($methodNames); + $expectations = $mock->mockery_getExpectationsFor($method); + + if (is_null($expectations) || self::noMoreElementsInChain($methodNames)) { + $expectations = $nextExp($method); + if (self::noMoreElementsInChain($methodNames)) { + break; + } + + $mock = self::getNewDemeterMock($container, $parent, $method, $expectations); + } else { + $demeterMockKey = $container->getKeyOfDemeterMockFor($method, $parent); + if ($demeterMockKey) { + $mock = self::getExistingDemeterMock($container, $demeterMockKey); + } + } + + $parent .= '->' . $method; + + $nextExp = function ($n) use ($mock) { + return $mock->shouldReceive($n); + }; + } + + return $expectations; + } + + /** + * Gets a new demeter configured + * mock from the container. + * + * @param \Mockery\Container $container + * @param string $parent + * @param string $method + * @param Mockery\ExpectationInterface $exp + * + * @return \Mockery\Mock + */ + private static function getNewDemeterMock( + Mockery\Container $container, + $parent, + $method, + Mockery\ExpectationInterface $exp + ) { + $newMockName = 'demeter_' . md5($parent) . '_' . $method; + + if (version_compare(PHP_VERSION, '7.0.0') >= 0) { + $parRef = null; + $parRefMethod = null; + $parRefMethodRetType = null; + + $parentMock = $exp->getMock(); + if ($parentMock !== null) { + $parRef = new ReflectionObject($parentMock); + } + + if ($parRef !== null && $parRef->hasMethod($method)) { + $parRefMethod = $parRef->getMethod($method); + $parRefMethodRetType = $parRefMethod->getReturnType(); + + if ($parRefMethodRetType !== null) { + $mock = self::namedMock($newMockName, (string) $parRefMethodRetType); + $exp->andReturn($mock); + + return $mock; + } + } + } + + $mock = $container->mock($newMockName); + $exp->andReturn($mock); + + return $mock; + } + + /** + * Gets an specific demeter mock from + * the ones kept by the container. + * + * @param \Mockery\Container $container + * @param string $demeterMockKey + * + * @return mixed + */ + private static function getExistingDemeterMock( + Mockery\Container $container, + $demeterMockKey + ) { + $mocks = $container->getMocks(); + $mock = $mocks[$demeterMockKey]; + + return $mock; + } + + /** + * Checks if the passed array representing a demeter + * chain with the method names is empty. + * + * @param array $methodNames + * + * @return bool + */ + private static function noMoreElementsInChain(array $methodNames) + { + return empty($methodNames); + } + + public static function declareClass($fqn) + { + return static::declareType($fqn, "class"); + } + + public static function declareInterface($fqn) + { + return static::declareType($fqn, "interface"); + } + + private static function declareType($fqn, $type) + { + $targetCode = "trait = new TestListenerTrait(); + } + + /** + * {@inheritdoc} + */ + public function endTest(\PHPUnit_Framework_Test $test, $time) + { + $this->trait->endTest($test, $time); + } + + /** + * {@inheritdoc} + */ + public function startTestSuite(\PHPUnit_Framework_TestSuite $suite) + { + $this->trait->startTestSuite(); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerForV6.php b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerForV6.php new file mode 100644 index 000000000..815b13c1a --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerForV6.php @@ -0,0 +1,51 @@ +trait = new TestListenerTrait(); + } + + /** + * {@inheritdoc} + */ + public function endTest(Test $test, $time) + { + $this->trait->endTest($test, $time); + } + + /** + * {@inheritdoc} + */ + public function startTestSuite(TestSuite $suite) + { + $this->trait->startTestSuite(); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerForV7.php b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerForV7.php new file mode 100644 index 000000000..d590825ab --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerForV7.php @@ -0,0 +1,55 @@ +trait = new TestListenerTrait(); + } + + + /** + * {@inheritdoc} + */ + public function endTest(Test $test, float $time): void + { + $this->trait->endTest($test, $time); + } + + /** + * {@inheritdoc} + */ + public function startTestSuite(TestSuite $suite): void + { + $this->trait->startTestSuite(); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerTrait.php b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerTrait.php new file mode 100644 index 000000000..08848b88a --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/Legacy/TestListenerTrait.php @@ -0,0 +1,90 @@ +getStatus() !== BaseTestRunner::STATUS_PASSED) { + // If the test didn't pass there is no guarantee that + // verifyMockObjects and assertPostConditions have been called. + // And even if it did, the point here is to prevent false + // negatives, not to make failing tests fail for more reasons. + return; + } + + try { + // The self() call is used as a sentinel. Anything that throws if + // the container is closed already will do. + \Mockery::self(); + } catch (\LogicException $_) { + return; + } + + $e = new ExpectationFailedException( + \sprintf( + "Mockery's expectations have not been verified. Make sure that \Mockery::close() is called at the end of the test. Consider using %s\MockeryPHPUnitIntegration or extending %s\MockeryTestCase.", + __NAMESPACE__, + __NAMESPACE__ + ) + ); + + /** @var \PHPUnit\Framework\TestResult $result */ + $result = $test->getTestResultObject(); + + if ($result !== null) { + $result->addFailure($test, $e, $time); + } + } + + public function startTestSuite() + { + Blacklist::$blacklistedClassNames[\Mockery::class] = 1; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegration.php b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegration.php new file mode 100644 index 000000000..9d3429355 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/MockeryPHPUnitIntegration.php @@ -0,0 +1,88 @@ +addMockeryExpectationsToAssertionCount(); + $this->checkMockeryExceptions(); + $this->closeMockery(); + + parent::assertPostConditions(); + } + + protected function addMockeryExpectationsToAssertionCount() + { + $this->addToAssertionCount(Mockery::getContainer()->mockery_getExpectationCount()); + } + + protected function checkMockeryExceptions() + { + if (!method_exists($this, "markAsRisky")) { + return; + } + + foreach (Mockery::getContainer()->mockery_thrownExceptions() as $e) { + if (!$e->dismissed()) { + $this->markAsRisky(); + } + } + } + + protected function closeMockery() + { + Mockery::close(); + $this->mockeryOpen = false; + } + + /** + * @before + */ + protected function startMockery() + { + $this->mockeryOpen = true; + } + + /** + * @after + */ + protected function purgeMockeryContainer() + { + if ($this->mockeryOpen) { + // post conditions wasn't called, so test probably failed + Mockery::close(); + } + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/MockeryTestCase.php b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/MockeryTestCase.php new file mode 100644 index 000000000..f4e9a86a6 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Adapter/Phpunit/MockeryTestCase.php @@ -0,0 +1,26 @@ +closure = $closure; + } + + public function __invoke() + { + return call_user_func_array($this->closure, func_get_args()); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/CompositeExpectation.php b/vendor/mockery/mockery/library/Mockery/CompositeExpectation.php new file mode 100644 index 000000000..86e390454 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/CompositeExpectation.php @@ -0,0 +1,154 @@ +_expectations[] = $expectation; + } + + /** + * @param mixed ...$args + */ + public function andReturn(...$args) + { + return $this->__call(__FUNCTION__, $args); + } + + /** + * Set a return value, or sequential queue of return values + * + * @param mixed ...$args + * @return self + */ + public function andReturns(...$args) + { + return call_user_func_array([$this, 'andReturn'], $args); + } + + /** + * Intercept any expectation calls and direct against all expectations + * + * @param string $method + * @param array $args + * @return self + */ + public function __call($method, array $args) + { + foreach ($this->_expectations as $expectation) { + call_user_func_array(array($expectation, $method), $args); + } + return $this; + } + + /** + * Return order number of the first expectation + * + * @return int + */ + public function getOrderNumber() + { + reset($this->_expectations); + $first = current($this->_expectations); + return $first->getOrderNumber(); + } + + /** + * Return the parent mock of the first expectation + * + * @return \Mockery\MockInterface + */ + public function getMock() + { + reset($this->_expectations); + $first = current($this->_expectations); + return $first->getMock(); + } + + /** + * Mockery API alias to getMock + * + * @return \Mockery\MockInterface + */ + public function mock() + { + return $this->getMock(); + } + + /** + * Starts a new expectation addition on the first mock which is the primary + * target outside of a demeter chain + * + * @param mixed ...$args + * @return \Mockery\Expectation + */ + public function shouldReceive(...$args) + { + reset($this->_expectations); + $first = current($this->_expectations); + return call_user_func_array(array($first->getMock(), 'shouldReceive'), $args); + } + + /** + * Starts a new expectation addition on the first mock which is the primary + * target outside of a demeter chain + * + * @param mixed ...$args + * @return \Mockery\Expectation + */ + public function shouldNotReceive(...$args) + { + reset($this->_expectations); + $first = current($this->_expectations); + return call_user_func_array(array($first->getMock(), 'shouldNotReceive'), $args); + } + + /** + * Return the string summary of this composite expectation + * + * @return string + */ + public function __toString() + { + $return = '['; + $parts = array(); + foreach ($this->_expectations as $exp) { + $parts[] = (string) $exp; + } + $return .= implode(', ', $parts) . ']'; + return $return; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Configuration.php b/vendor/mockery/mockery/library/Mockery/Configuration.php new file mode 100644 index 000000000..eaf7ffe41 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Configuration.php @@ -0,0 +1,190 @@ +_allowMockingNonExistentMethod = (bool) $flag; + } + + /** + * Return flag indicating whether mocking non-existent methods allowed + * + * @return bool + */ + public function mockingNonExistentMethodsAllowed() + { + return $this->_allowMockingNonExistentMethod; + } + + /** + * @deprecated + * + * Set boolean to allow/prevent unnecessary mocking of methods + * + * @param bool $flag + */ + public function allowMockingMethodsUnnecessarily($flag = true) + { + trigger_error(sprintf("The %s method is deprecated and will be removed in a future version of Mockery", __METHOD__), E_USER_DEPRECATED); + + $this->_allowMockingMethodsUnnecessarily = (bool) $flag; + } + + /** + * Return flag indicating whether mocking non-existent methods allowed + * + * @return bool + */ + public function mockingMethodsUnnecessarilyAllowed() + { + trigger_error(sprintf("The %s method is deprecated and will be removed in a future version of Mockery", __METHOD__), E_USER_DEPRECATED); + + return $this->_allowMockingMethodsUnnecessarily; + } + + /** + * Set a parameter map (array of param signature strings) for the method + * of an internal PHP class. + * + * @param string $class + * @param string $method + * @param array $map + */ + public function setInternalClassMethodParamMap($class, $method, array $map) + { + if (!isset($this->_internalClassParamMap[strtolower($class)])) { + $this->_internalClassParamMap[strtolower($class)] = array(); + } + $this->_internalClassParamMap[strtolower($class)][strtolower($method)] = $map; + } + + /** + * Remove all overriden parameter maps from internal PHP classes. + */ + public function resetInternalClassMethodParamMaps() + { + $this->_internalClassParamMap = array(); + } + + /** + * Get the parameter map of an internal PHP class method + * + * @return array + */ + public function getInternalClassMethodParamMap($class, $method) + { + if (isset($this->_internalClassParamMap[strtolower($class)][strtolower($method)])) { + return $this->_internalClassParamMap[strtolower($class)][strtolower($method)]; + } + } + + public function getInternalClassMethodParamMaps() + { + return $this->_internalClassParamMap; + } + + public function setConstantsMap(array $map) + { + $this->_constantsMap = $map; + } + + public function getConstantsMap() + { + return $this->_constantsMap; + } + + /** + * Disable reflection caching + * + * It should be always enabled, except when using + * PHPUnit's --static-backup option. + * + * @see https://github.com/mockery/mockery/issues/268 + */ + public function disableReflectionCache() + { + $this->_reflectionCacheEnabled = false; + } + + /** + * Enable reflection caching + * + * It should be always enabled, except when using + * PHPUnit's --static-backup option. + * + * @see https://github.com/mockery/mockery/issues/268 + */ + public function enableReflectionCache() + { + $this->_reflectionCacheEnabled = true; + } + + /** + * Is reflection cache enabled? + */ + public function reflectionCacheEnabled() + { + return $this->_reflectionCacheEnabled; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Container.php b/vendor/mockery/mockery/library/Mockery/Container.php new file mode 100644 index 000000000..5287ac4fb --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Container.php @@ -0,0 +1,539 @@ +_generator = $generator ?: \Mockery::getDefaultGenerator(); + $this->_loader = $loader ?: \Mockery::getDefaultLoader(); + } + + /** + * Generates a new mock object for this container + * + * I apologies in advance for this. A God Method just fits the API which + * doesn't require differentiating between classes, interfaces, abstracts, + * names or partials - just so long as it's something that can be mocked. + * I'll refactor it one day so it's easier to follow. + * + * @param array ...$args + * + * @return Mock + * @throws Exception\RuntimeException + */ + public function mock(...$args) + { + $expectationClosure = null; + $quickdefs = array(); + $constructorArgs = null; + $blocks = array(); + $class = null; + + if (count($args) > 1) { + $finalArg = end($args); + reset($args); + if (is_callable($finalArg) && is_object($finalArg)) { + $expectationClosure = array_pop($args); + } + } + + $builder = new MockConfigurationBuilder(); + + foreach ($args as $k => $arg) { + if ($arg instanceof MockConfigurationBuilder) { + $builder = $arg; + unset($args[$k]); + } + } + reset($args); + + $builder->setParameterOverrides(\Mockery::getConfiguration()->getInternalClassMethodParamMaps()); + $builder->setConstantsMap(\Mockery::getConfiguration()->getConstantsMap()); + + while (count($args) > 0) { + $arg = current($args); + // check for multiple interfaces + if (is_string($arg) && strpos($arg, ',') && !strpos($arg, ']')) { + $interfaces = explode(',', str_replace(' ', '', $arg)); + $builder->addTargets($interfaces); + array_shift($args); + + continue; + } elseif (is_string($arg) && substr($arg, 0, 6) == 'alias:') { + $name = array_shift($args); + $name = str_replace('alias:', '', $name); + $builder->addTarget('stdClass'); + $builder->setName($name); + continue; + } elseif (is_string($arg) && substr($arg, 0, 9) == 'overload:') { + $name = array_shift($args); + $name = str_replace('overload:', '', $name); + $builder->setInstanceMock(true); + $builder->addTarget('stdClass'); + $builder->setName($name); + continue; + } elseif (is_string($arg) && substr($arg, strlen($arg)-1, 1) == ']') { + $parts = explode('[', $arg); + if (!class_exists($parts[0], true) && !interface_exists($parts[0], true)) { + throw new \Mockery\Exception('Can only create a partial mock from' + . ' an existing class or interface'); + } + $class = $parts[0]; + $parts[1] = str_replace(' ', '', $parts[1]); + $partialMethods = explode(',', strtolower(rtrim($parts[1], ']'))); + $builder->addTarget($class); + $builder->setWhiteListedMethods($partialMethods); + array_shift($args); + continue; + } elseif (is_string($arg) && (class_exists($arg, true) || interface_exists($arg, true) || trait_exists($arg, true))) { + $class = array_shift($args); + $builder->addTarget($class); + continue; + } elseif (is_string($arg) && !\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() && (!class_exists($arg, true) && !interface_exists($arg, true))) { + throw new \Mockery\Exception("Mockery can't find '$arg' so can't mock it"); + } elseif (is_string($arg)) { + if (!$this->isValidClassName($arg)) { + throw new \Mockery\Exception('Class name contains invalid characters'); + } + $class = array_shift($args); + $builder->addTarget($class); + continue; + } elseif (is_object($arg)) { + $partial = array_shift($args); + $builder->addTarget($partial); + continue; + } elseif (is_array($arg) && !empty($arg) && array_keys($arg) !== range(0, count($arg) - 1)) { + // if associative array + if (array_key_exists(self::BLOCKS, $arg)) { + $blocks = $arg[self::BLOCKS]; + } + unset($arg[self::BLOCKS]); + $quickdefs = array_shift($args); + continue; + } elseif (is_array($arg)) { + $constructorArgs = array_shift($args); + continue; + } + + throw new \Mockery\Exception( + 'Unable to parse arguments sent to ' + . get_class($this) . '::mock()' + ); + } + + $builder->addBlackListedMethods($blocks); + + if (defined('HHVM_VERSION') + && ($class === 'Exception' || is_subclass_of($class, 'Exception'))) { + $builder->addBlackListedMethod("setTraceOptions"); + $builder->addBlackListedMethod("getTraceOptions"); + } + + if (!is_null($constructorArgs)) { + $builder->addBlackListedMethod("__construct"); // we need to pass through + } else { + $builder->setMockOriginalDestructor(true); + } + + if (!empty($partialMethods) && $constructorArgs === null) { + $constructorArgs = array(); + } + + $config = $builder->getMockConfiguration(); + + $this->checkForNamedMockClashes($config); + + $def = $this->getGenerator()->generate($config); + + if (class_exists($def->getClassName(), $attemptAutoload = false)) { + $rfc = new \ReflectionClass($def->getClassName()); + if (!$rfc->implementsInterface("Mockery\MockInterface")) { + throw new \Mockery\Exception\RuntimeException("Could not load mock {$def->getClassName()}, class already exists"); + } + } + + $this->getLoader()->load($def); + + $mock = $this->_getInstance($def->getClassName(), $constructorArgs); + $mock->mockery_init($this, $config->getTargetObject()); + + if (!empty($quickdefs)) { + $mock->shouldReceive($quickdefs)->byDefault(); + } + if (!empty($expectationClosure)) { + $expectationClosure($mock); + } + $this->rememberMock($mock); + return $mock; + } + + public function instanceMock() + { + } + + public function getLoader() + { + return $this->_loader; + } + + public function getGenerator() + { + return $this->_generator; + } + + /** + * @param string $method + * @param string $parent + * @return string|null + */ + public function getKeyOfDemeterMockFor($method, $parent) + { + $keys = array_keys($this->_mocks); + $match = preg_grep("/__demeter_" . md5($parent) . "_{$method}$/", $keys); + if (count($match) == 1) { + $res = array_values($match); + if (count($res) > 0) { + return $res[0]; + } + } + return null; + } + + /** + * @return array + */ + public function getMocks() + { + return $this->_mocks; + } + + /** + * Tear down tasks for this container + * + * @throws \Exception + * @return void + */ + public function mockery_teardown() + { + try { + $this->mockery_verify(); + } catch (\Exception $e) { + $this->mockery_close(); + throw $e; + } + } + + /** + * Verify the container mocks + * + * @return void + */ + public function mockery_verify() + { + foreach ($this->_mocks as $mock) { + $mock->mockery_verify(); + } + } + + /** + * Retrieves all exceptions thrown by mocks + * + * @return array + */ + public function mockery_thrownExceptions() + { + $e = []; + + foreach ($this->_mocks as $mock) { + $e = array_merge($e, $mock->mockery_thrownExceptions()); + } + + return $e; + } + + /** + * Reset the container to its original state + * + * @return void + */ + public function mockery_close() + { + foreach ($this->_mocks as $mock) { + $mock->mockery_teardown(); + } + $this->_mocks = array(); + } + + /** + * Fetch the next available allocation order number + * + * @return int + */ + public function mockery_allocateOrder() + { + $this->_allocatedOrder += 1; + return $this->_allocatedOrder; + } + + /** + * Set ordering for a group + * + * @param mixed $group + * @param int $order + */ + public function mockery_setGroup($group, $order) + { + $this->_groups[$group] = $order; + } + + /** + * Fetch array of ordered groups + * + * @return array + */ + public function mockery_getGroups() + { + return $this->_groups; + } + + /** + * Set current ordered number + * + * @param int $order + * @return int The current order number that was set + */ + public function mockery_setCurrentOrder($order) + { + $this->_currentOrder = $order; + return $this->_currentOrder; + } + + /** + * Get current ordered number + * + * @return int + */ + public function mockery_getCurrentOrder() + { + return $this->_currentOrder; + } + + /** + * Validate the current mock's ordering + * + * @param string $method + * @param int $order + * @throws \Mockery\Exception + * @return void + */ + public function mockery_validateOrder($method, $order, \Mockery\MockInterface $mock) + { + if ($order < $this->_currentOrder) { + $exception = new \Mockery\Exception\InvalidOrderException( + 'Method ' . $method . ' called out of order: expected order ' + . $order . ', was ' . $this->_currentOrder + ); + $exception->setMock($mock) + ->setMethodName($method) + ->setExpectedOrder($order) + ->setActualOrder($this->_currentOrder); + throw $exception; + } + $this->mockery_setCurrentOrder($order); + } + + /** + * Gets the count of expectations on the mocks + * + * @return int + */ + public function mockery_getExpectationCount() + { + $count = 0; + foreach ($this->_mocks as $mock) { + $count += $mock->mockery_getExpectationCount(); + } + return $count; + } + + /** + * Store a mock and set its container reference + * + * @param \Mockery\Mock $mock + * @return \Mockery\MockInterface + */ + public function rememberMock(\Mockery\MockInterface $mock) + { + if (!isset($this->_mocks[get_class($mock)])) { + $this->_mocks[get_class($mock)] = $mock; + } else { + /** + * This condition triggers for an instance mock where origin mock + * is already remembered + */ + $this->_mocks[] = $mock; + } + return $mock; + } + + /** + * Retrieve the last remembered mock object, which is the same as saying + * retrieve the current mock being programmed where you have yet to call + * mock() to change it - thus why the method name is "self" since it will be + * be used during the programming of the same mock. + * + * @return \Mockery\Mock + */ + public function self() + { + $mocks = array_values($this->_mocks); + $index = count($mocks) - 1; + return $mocks[$index]; + } + + /** + * Return a specific remembered mock according to the array index it + * was stored to in this container instance + * + * @return \Mockery\Mock + */ + public function fetchMock($reference) + { + if (isset($this->_mocks[$reference])) { + return $this->_mocks[$reference]; + } + } + + protected function _getInstance($mockName, $constructorArgs = null) + { + if ($constructorArgs !== null) { + $r = new \ReflectionClass($mockName); + return $r->newInstanceArgs($constructorArgs); + } + + try { + $instantiator = new Instantiator; + $instance = $instantiator->instantiate($mockName); + } catch (\Exception $ex) { + $internalMockName = $mockName . '_Internal'; + + if (!class_exists($internalMockName)) { + eval("class $internalMockName extends $mockName {" . + 'public function __construct() {}' . + '}'); + } + + $instance = new $internalMockName(); + } + + return $instance; + } + + protected function checkForNamedMockClashes($config) + { + $name = $config->getName(); + + if (!$name) { + return; + } + + $hash = $config->getHash(); + + if (isset($this->_namedMocks[$name])) { + if ($hash !== $this->_namedMocks[$name]) { + throw new \Mockery\Exception( + "The mock named '$name' has been already defined with a different mock configuration" + ); + } + } + + $this->_namedMocks[$name] = $hash; + } + + /** + * see http://php.net/manual/en/language.oop5.basic.php + * @param string $className + * @return bool + */ + public function isValidClassName($className) + { + $pos = strpos($className, '\\'); + if ($pos === 0) { + $className = substr($className, 1); // remove the first backslash + } + // all the namespaces and class name should match the regex + $invalidNames = array_filter(explode('\\', $className), function ($name) { + return !preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $name); + }); + return empty($invalidNames); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/CountValidator/AtLeast.php b/vendor/mockery/mockery/library/Mockery/CountValidator/AtLeast.php new file mode 100644 index 000000000..f6ac130e6 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/CountValidator/AtLeast.php @@ -0,0 +1,62 @@ +_limit > $n) { + $exception = new Mockery\Exception\InvalidCountException( + 'Method ' . (string) $this->_expectation + . ' from ' . $this->_expectation->getMock()->mockery_getName() + . ' should be called' . PHP_EOL + . ' at least ' . $this->_limit . ' times but called ' . $n + . ' times.' + ); + $exception->setMock($this->_expectation->getMock()) + ->setMethodName((string) $this->_expectation) + ->setExpectedCountComparative('>=') + ->setExpectedCount($this->_limit) + ->setActualCount($n); + throw $exception; + } + } +} diff --git a/vendor/mockery/mockery/library/Mockery/CountValidator/AtMost.php b/vendor/mockery/mockery/library/Mockery/CountValidator/AtMost.php new file mode 100644 index 000000000..4d23e28d2 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/CountValidator/AtMost.php @@ -0,0 +1,51 @@ +_limit < $n) { + $exception = new Mockery\Exception\InvalidCountException( + 'Method ' . (string) $this->_expectation + . ' from ' . $this->_expectation->getMock()->mockery_getName() + . ' should be called' . PHP_EOL + . ' at most ' . $this->_limit . ' times but called ' . $n + . ' times.' + ); + $exception->setMock($this->_expectation->getMock()) + ->setMethodName((string) $this->_expectation) + ->setExpectedCountComparative('<=') + ->setExpectedCount($this->_limit) + ->setActualCount($n); + throw $exception; + } + } +} diff --git a/vendor/mockery/mockery/library/Mockery/CountValidator/CountValidatorAbstract.php b/vendor/mockery/mockery/library/Mockery/CountValidator/CountValidatorAbstract.php new file mode 100644 index 000000000..ae3b0bfef --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/CountValidator/CountValidatorAbstract.php @@ -0,0 +1,69 @@ +_expectation = $expectation; + $this->_limit = $limit; + } + + /** + * Checks if the validator can accept an additional nth call + * + * @param int $n + * @return bool + */ + public function isEligible($n) + { + return ($n < $this->_limit); + } + + /** + * Validate the call count against this validator + * + * @param int $n + * @return bool + */ + abstract public function validate($n); +} diff --git a/vendor/mockery/mockery/library/Mockery/CountValidator/Exact.php b/vendor/mockery/mockery/library/Mockery/CountValidator/Exact.php new file mode 100644 index 000000000..504f080d4 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/CountValidator/Exact.php @@ -0,0 +1,54 @@ +_limit !== $n) { + $because = $this->_expectation->getExceptionMessage(); + + $exception = new Mockery\Exception\InvalidCountException( + 'Method ' . (string) $this->_expectation + . ' from ' . $this->_expectation->getMock()->mockery_getName() + . ' should be called' . PHP_EOL + . ' exactly ' . $this->_limit . ' times but called ' . $n + . ' times.' + . ($because ? ' Because ' . $this->_expectation->getExceptionMessage() : '') + ); + $exception->setMock($this->_expectation->getMock()) + ->setMethodName((string) $this->_expectation) + ->setExpectedCountComparative('=') + ->setExpectedCount($this->_limit) + ->setActualCount($n); + throw $exception; + } + } +} diff --git a/vendor/mockery/mockery/library/Mockery/CountValidator/Exception.php b/vendor/mockery/mockery/library/Mockery/CountValidator/Exception.php new file mode 100644 index 000000000..b43aad3ec --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/CountValidator/Exception.php @@ -0,0 +1,25 @@ +dismissed = true; + + // we sometimes stack them + if ($this->getPrevious() && $this->getPrevious() instanceof BadMethodCallException) { + $this->getPrevious()->dismiss(); + } + } + + public function dismissed() + { + return $this->dismissed; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Exception/InvalidArgumentException.php b/vendor/mockery/mockery/library/Mockery/Exception/InvalidArgumentException.php new file mode 100644 index 000000000..ccf5c76f9 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Exception/InvalidArgumentException.php @@ -0,0 +1,25 @@ +mockObject = $mock; + return $this; + } + + public function setMethodName($name) + { + $this->method = $name; + return $this; + } + + public function setActualCount($count) + { + $this->actual = $count; + return $this; + } + + public function setExpectedCount($count) + { + $this->expected = $count; + return $this; + } + + public function setExpectedCountComparative($comp) + { + if (!in_array($comp, array('=', '>', '<', '>=', '<='))) { + throw new RuntimeException( + 'Illegal comparative for expected call counts set: ' . $comp + ); + } + $this->expectedComparative = $comp; + return $this; + } + + public function getMock() + { + return $this->mockObject; + } + + public function getMethodName() + { + return $this->method; + } + + public function getActualCount() + { + return $this->actual; + } + + public function getExpectedCount() + { + return $this->expected; + } + + public function getMockName() + { + return $this->getMock()->mockery_getName(); + } + + public function getExpectedCountComparative() + { + return $this->expectedComparative; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Exception/InvalidOrderException.php b/vendor/mockery/mockery/library/Mockery/Exception/InvalidOrderException.php new file mode 100644 index 000000000..2134e093e --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Exception/InvalidOrderException.php @@ -0,0 +1,83 @@ +mockObject = $mock; + return $this; + } + + public function setMethodName($name) + { + $this->method = $name; + return $this; + } + + public function setActualOrder($count) + { + $this->actual = $count; + return $this; + } + + public function setExpectedOrder($count) + { + $this->expected = $count; + return $this; + } + + public function getMock() + { + return $this->mockObject; + } + + public function getMethodName() + { + return $this->method; + } + + public function getActualOrder() + { + return $this->actual; + } + + public function getExpectedOrder() + { + return $this->expected; + } + + public function getMockName() + { + return $this->getMock()->mockery_getName(); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Exception/NoMatchingExpectationException.php b/vendor/mockery/mockery/library/Mockery/Exception/NoMatchingExpectationException.php new file mode 100644 index 000000000..16574036c --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Exception/NoMatchingExpectationException.php @@ -0,0 +1,70 @@ +mockObject = $mock; + return $this; + } + + public function setMethodName($name) + { + $this->method = $name; + return $this; + } + + public function setActualArguments($count) + { + $this->actual = $count; + return $this; + } + + public function getMock() + { + return $this->mockObject; + } + + public function getMethodName() + { + return $this->method; + } + + public function getActualArguments() + { + return $this->actual; + } + + public function getMockName() + { + return $this->getMock()->mockery_getName(); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Exception/RuntimeException.php b/vendor/mockery/mockery/library/Mockery/Exception/RuntimeException.php new file mode 100644 index 000000000..4b2f53c22 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Exception/RuntimeException.php @@ -0,0 +1,25 @@ +_mock = $mock; + $this->_name = $name; + $this->withAnyArgs(); + } + + /** + * Return a string with the method name and arguments formatted + * + * @param string $name Name of the expected method + * @param array $args List of arguments to the method + * @return string + */ + public function __toString() + { + return \Mockery::formatArgs($this->_name, $this->_expectedArgs); + } + + /** + * Verify the current call, i.e. that the given arguments match those + * of this expectation + * + * @param array $args + * @return mixed + */ + public function verifyCall(array $args) + { + $this->validateOrder(); + $this->_actualCount++; + if (true === $this->_passthru) { + return $this->_mock->mockery_callSubjectMethod($this->_name, $args); + } + + $return = $this->_getReturnValue($args); + $this->throwAsNecessary($return); + $this->_setValues(); + + return $return; + } + + /** + * Throws an exception if the expectation has been configured to do so + * + * @throws \Exception|\Throwable + * @return void + */ + private function throwAsNecessary($return) + { + if (!$this->_throw) { + return; + } + + $type = version_compare(PHP_VERSION, '7.0.0') >= 0 + ? "\Throwable" + : "\Exception"; + + if ($return instanceof $type) { + throw $return; + } + + return; + } + + /** + * Sets public properties with queued values to the mock object + * + * @param array $args + * @return mixed + */ + protected function _setValues() + { + $mockClass = get_class($this->_mock); + $container = $this->_mock->mockery_getContainer(); + $mocks = $container->getMocks(); + foreach ($this->_setQueue as $name => &$values) { + if (count($values) > 0) { + $value = array_shift($values); + foreach ($mocks as $mock) { + if (is_a($mock, $mockClass)) { + $mock->{$name} = $value; + } + } + } + } + } + + /** + * Fetch the return value for the matching args + * + * @param array $args + * @return mixed + */ + protected function _getReturnValue(array $args) + { + if (count($this->_closureQueue) > 1) { + return call_user_func_array(array_shift($this->_closureQueue), $args); + } elseif (count($this->_closureQueue) > 0) { + return call_user_func_array(current($this->_closureQueue), $args); + } elseif (count($this->_returnQueue) > 1) { + return array_shift($this->_returnQueue); + } elseif (count($this->_returnQueue) > 0) { + return current($this->_returnQueue); + } + + return $this->_mock->mockery_returnValueForMethod($this->_name); + } + + /** + * Checks if this expectation is eligible for additional calls + * + * @return bool + */ + public function isEligible() + { + foreach ($this->_countValidators as $validator) { + if (!$validator->isEligible($this->_actualCount)) { + return false; + } + } + return true; + } + + /** + * Check if there is a constraint on call count + * + * @return bool + */ + public function isCallCountConstrained() + { + return (count($this->_countValidators) > 0); + } + + /** + * Verify call order + * + * @return void + */ + public function validateOrder() + { + if ($this->_orderNumber) { + $this->_mock->mockery_validateOrder((string) $this, $this->_orderNumber, $this->_mock); + } + if ($this->_globalOrderNumber) { + $this->_mock->mockery_getContainer() + ->mockery_validateOrder((string) $this, $this->_globalOrderNumber, $this->_mock); + } + } + + /** + * Verify this expectation + * + * @return void + */ + public function verify() + { + foreach ($this->_countValidators as $validator) { + $validator->validate($this->_actualCount); + } + } + + /** + * Check if the registered expectation is an ArgumentListMatcher + * @return bool + */ + private function isArgumentListMatcher() + { + return (count($this->_expectedArgs) === 1 && ($this->_expectedArgs[0] instanceof ArgumentListMatcher)); + } + + private function isAndAnyOtherArgumentsMatcher($expectedArg) + { + return $expectedArg instanceof AndAnyOtherArgs; + } + + /** + * Check if passed arguments match an argument expectation + * + * @param array $args + * @return bool + */ + public function matchArgs(array $args) + { + if ($this->isArgumentListMatcher()) { + return $this->_matchArg($this->_expectedArgs[0], $args); + } + $argCount = count($args); + if ($argCount !== count((array) $this->_expectedArgs)) { + $lastExpectedArgument = end($this->_expectedArgs); + reset($this->_expectedArgs); + + if ($this->isAndAnyOtherArgumentsMatcher($lastExpectedArgument)) { + $argCountToSkipMatching = $argCount - count($this->_expectedArgs); + $args = array_slice($args, 0, $argCountToSkipMatching); + return $this->_matchArgs($args); + } + + return false; + } + + return $this->_matchArgs($args); + } + + /** + * Check if the passed arguments match the expectations, one by one. + * + * @param array $args + * @return bool + */ + protected function _matchArgs($args) + { + $argCount = count($args); + for ($i=0; $i<$argCount; $i++) { + $param =& $args[$i]; + if (!$this->_matchArg($this->_expectedArgs[$i], $param)) { + return false; + } + } + return true; + } + + /** + * Check if passed argument matches an argument expectation + * + * @param mixed $expected + * @param mixed $actual + * @return bool + */ + protected function _matchArg($expected, &$actual) + { + if ($expected === $actual) { + return true; + } + if (!is_object($expected) && !is_object($actual) && $expected == $actual) { + return true; + } + if (is_string($expected) && is_object($actual)) { + $result = $actual instanceof $expected; + if ($result) { + return true; + } + } + if ($expected instanceof \Mockery\Matcher\MatcherAbstract) { + return $expected->match($actual); + } + if ($expected instanceof \Hamcrest\Matcher || $expected instanceof \Hamcrest_Matcher) { + return $expected->matches($actual); + } + return false; + } + + /** + * Expected argument setter for the expectation + * + * @param mixed[] ...$args + * @return self + */ + public function with(...$args) + { + return $this->withArgs($args); + } + + /** + * Expected arguments for the expectation passed as an array + * + * @param array $arguments + * @return self + */ + private function withArgsInArray(array $arguments) + { + if (empty($arguments)) { + return $this->withNoArgs(); + } + $this->_expectedArgs = $arguments; + return $this; + } + + /** + * Expected arguments have to be matched by the given closure. + * + * @param Closure $closure + * @return self + */ + private function withArgsMatchedByClosure(Closure $closure) + { + $this->_expectedArgs = [new MultiArgumentClosure($closure)]; + return $this; + } + + /** + * Expected arguments for the expectation passed as an array or a closure that matches each passed argument on + * each function call. + * + * @param array|Closure $argsOrClosure + * @return self + */ + public function withArgs($argsOrClosure) + { + if (is_array($argsOrClosure)) { + $this->withArgsInArray($argsOrClosure); + } elseif ($argsOrClosure instanceof Closure) { + $this->withArgsMatchedByClosure($argsOrClosure); + } else { + throw new \InvalidArgumentException(sprintf('Call to %s with an invalid argument (%s), only array and '. + 'closure are allowed', __METHOD__, $argsOrClosure)); + } + return $this; + } + + /** + * Set with() as no arguments expected + * + * @return self + */ + public function withNoArgs() + { + $this->_expectedArgs = [new NoArgs()]; + return $this; + } + + /** + * Set expectation that any arguments are acceptable + * + * @return self + */ + public function withAnyArgs() + { + $this->_expectedArgs = [new AnyArgs()]; + return $this; + } + + /** + * Set a return value, or sequential queue of return values + * + * @param mixed[] ...$args + * @return self + */ + public function andReturn(...$args) + { + $this->_returnQueue = $args; + return $this; + } + + /** + * Set a return value, or sequential queue of return values + * + * @param mixed[] ...$args + * @return self + */ + public function andReturns(...$args) + { + return call_user_func_array([$this, 'andReturn'], $args); + } + + /** + * Return this mock, like a fluent interface + * + * @return self + */ + public function andReturnSelf() + { + return $this->andReturn($this->_mock); + } + + /** + * Set a sequential queue of return values with an array + * + * @param array $values + * @return self + */ + public function andReturnValues(array $values) + { + call_user_func_array(array($this, 'andReturn'), $values); + return $this; + } + + /** + * Set a closure or sequence of closures with which to generate return + * values. The arguments passed to the expected method are passed to the + * closures as parameters. + * + * @param callable[] ...$args + * @return self + */ + public function andReturnUsing(...$args) + { + $this->_closureQueue = $args; + return $this; + } + + /** + * Return a self-returning black hole object. + * + * @return self + */ + public function andReturnUndefined() + { + $this->andReturn(new \Mockery\Undefined); + return $this; + } + + /** + * Return null. This is merely a language construct for Mock describing. + * + * @return self + */ + public function andReturnNull() + { + return $this->andReturn(null); + } + + public function andReturnFalse() + { + return $this->andReturn(false); + } + + public function andReturnTrue() + { + return $this->andReturn(true); + } + + /** + * Set Exception class and arguments to that class to be thrown + * + * @param string|\Exception $exception + * @param string $message + * @param int $code + * @param \Exception $previous + * @return self + */ + public function andThrow($exception, $message = '', $code = 0, \Exception $previous = null) + { + $this->_throw = true; + if (is_object($exception)) { + $this->andReturn($exception); + } else { + $this->andReturn(new $exception($message, $code, $previous)); + } + return $this; + } + + public function andThrows($exception, $message = '', $code = 0, \Exception $previous = null) + { + return $this->andThrow($exception, $message, $code, $previous); + } + + /** + * Set Exception classes to be thrown + * + * @param array $exceptions + * @return self + */ + public function andThrowExceptions(array $exceptions) + { + $this->_throw = true; + foreach ($exceptions as $exception) { + if (!is_object($exception)) { + throw new Exception('You must pass an array of exception objects to andThrowExceptions'); + } + } + return $this->andReturnValues($exceptions); + } + + /** + * Register values to be set to a public property each time this expectation occurs + * + * @param string $name + * @param array ...$values + * @return self + */ + public function andSet($name, ...$values) + { + $this->_setQueue[$name] = $values; + return $this; + } + + /** + * Alias to andSet(). Allows the natural English construct + * - set('foo', 'bar')->andReturn('bar') + * + * @param string $name + * @param mixed $value + * @return self + */ + public function set($name, $value) + { + return call_user_func_array(array($this, 'andSet'), func_get_args()); + } + + /** + * Indicates this expectation should occur zero or more times + * + * @return self + */ + public function zeroOrMoreTimes() + { + $this->atLeast()->never(); + } + + /** + * Indicates the number of times this expectation should occur + * + * @param int $limit + * @throws \InvalidArgumentException + * @return self + */ + public function times($limit = null) + { + if (is_null($limit)) { + return $this; + } + if (!is_int($limit)) { + throw new \InvalidArgumentException('The passed Times limit should be an integer value'); + } + $this->_countValidators[$this->_countValidatorClass] = new $this->_countValidatorClass($this, $limit); + $this->_countValidatorClass = 'Mockery\CountValidator\Exact'; + return $this; + } + + /** + * Indicates that this expectation is never expected to be called + * + * @return self + */ + public function never() + { + return $this->times(0); + } + + /** + * Indicates that this expectation is expected exactly once + * + * @return self + */ + public function once() + { + return $this->times(1); + } + + /** + * Indicates that this expectation is expected exactly twice + * + * @return self + */ + public function twice() + { + return $this->times(2); + } + + /** + * Sets next count validator to the AtLeast instance + * + * @return self + */ + public function atLeast() + { + $this->_countValidatorClass = 'Mockery\CountValidator\AtLeast'; + return $this; + } + + /** + * Sets next count validator to the AtMost instance + * + * @return self + */ + public function atMost() + { + $this->_countValidatorClass = 'Mockery\CountValidator\AtMost'; + return $this; + } + + /** + * Shorthand for setting minimum and maximum constraints on call counts + * + * @param int $minimum + * @param int $maximum + */ + public function between($minimum, $maximum) + { + return $this->atLeast()->times($minimum)->atMost()->times($maximum); + } + + + /** + * Set the exception message + * + * @param string $message + * @return $this + */ + public function because($message) + { + $this->_because = $message; + return $this; + } + + /** + * Indicates that this expectation must be called in a specific given order + * + * @param string $group Name of the ordered group + * @return self + */ + public function ordered($group = null) + { + if ($this->_globally) { + $this->_globalOrderNumber = $this->_defineOrdered($group, $this->_mock->mockery_getContainer()); + } else { + $this->_orderNumber = $this->_defineOrdered($group, $this->_mock); + } + $this->_globally = false; + return $this; + } + + /** + * Indicates call order should apply globally + * + * @return self + */ + public function globally() + { + $this->_globally = true; + return $this; + } + + /** + * Setup the ordering tracking on the mock or mock container + * + * @param string $group + * @param object $ordering + * @return int + */ + protected function _defineOrdered($group, $ordering) + { + $groups = $ordering->mockery_getGroups(); + if (is_null($group)) { + $result = $ordering->mockery_allocateOrder(); + } elseif (isset($groups[$group])) { + $result = $groups[$group]; + } else { + $result = $ordering->mockery_allocateOrder(); + $ordering->mockery_setGroup($group, $result); + } + return $result; + } + + /** + * Return order number + * + * @return int + */ + public function getOrderNumber() + { + return $this->_orderNumber; + } + + /** + * Mark this expectation as being a default + * + * @return self + */ + public function byDefault() + { + $director = $this->_mock->mockery_getExpectationsFor($this->_name); + if (!empty($director)) { + $director->makeExpectationDefault($this); + } + return $this; + } + + /** + * Return the parent mock of the expectation + * + * @return \Mockery\MockInterface + */ + public function getMock() + { + return $this->_mock; + } + + /** + * Flag this expectation as calling the original class method with the + * any provided arguments instead of using a return value queue. + * + * @return self + */ + public function passthru() + { + if ($this->_mock instanceof Mock) { + throw new Exception( + 'Mock Objects not created from a loaded/existing class are ' + . 'incapable of passing method calls through to a parent class' + ); + } + $this->_passthru = true; + return $this; + } + + /** + * Cloning logic + * + */ + public function __clone() + { + $newValidators = array(); + $countValidators = $this->_countValidators; + foreach ($countValidators as $validator) { + $newValidators[] = clone $validator; + } + $this->_countValidators = $newValidators; + } + + public function getName() + { + return $this->_name; + } + + public function getExceptionMessage() + { + return $this->_because; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/ExpectationDirector.php b/vendor/mockery/mockery/library/Mockery/ExpectationDirector.php new file mode 100644 index 000000000..d9bb6fbaa --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/ExpectationDirector.php @@ -0,0 +1,218 @@ +_name = $name; + $this->_mock = $mock; + } + + /** + * Add a new expectation to the director + * + * @param \Mockery\Expectation $expectation + */ + public function addExpectation(\Mockery\Expectation $expectation) + { + $this->_expectations[] = $expectation; + } + + /** + * Handle a method call being directed by this instance + * + * @param array $args + * @return mixed + */ + public function call(array $args) + { + $expectation = $this->findExpectation($args); + if (is_null($expectation)) { + $exception = new \Mockery\Exception\NoMatchingExpectationException( + 'No matching handler found for ' + . $this->_mock->mockery_getName() . '::' + . \Mockery::formatArgs($this->_name, $args) + . '. Either the method was unexpected or its arguments matched' + . ' no expected argument list for this method' + . PHP_EOL . PHP_EOL + . \Mockery::formatObjects($args) + ); + $exception->setMock($this->_mock) + ->setMethodName($this->_name) + ->setActualArguments($args); + throw $exception; + } + return $expectation->verifyCall($args); + } + + /** + * Verify all expectations of the director + * + * @throws \Mockery\CountValidator\Exception + * @return void + */ + public function verify() + { + if (!empty($this->_expectations)) { + foreach ($this->_expectations as $exp) { + $exp->verify(); + } + } else { + foreach ($this->_defaults as $exp) { + $exp->verify(); + } + } + } + + /** + * Attempt to locate an expectation matching the provided args + * + * @param array $args + * @return mixed + */ + public function findExpectation(array $args) + { + $expectation = null; + + if (!empty($this->_expectations)) { + $expectation = $this->_findExpectationIn($this->_expectations, $args); + } + + if ($expectation === null && !empty($this->_defaults)) { + $expectation = $this->_findExpectationIn($this->_defaults, $args); + } + + return $expectation; + } + + /** + * Make the given expectation a default for all others assuming it was + * correctly created last + * + * @param \Mockery\Expectation $expectation + */ + public function makeExpectationDefault(\Mockery\Expectation $expectation) + { + $last = end($this->_expectations); + if ($last === $expectation) { + array_pop($this->_expectations); + array_unshift($this->_defaults, $expectation); + } else { + throw new \Mockery\Exception( + 'Cannot turn a previously defined expectation into a default' + ); + } + } + + /** + * Search current array of expectations for a match + * + * @param array $expectations + * @param array $args + * @return mixed + */ + protected function _findExpectationIn(array $expectations, array $args) + { + foreach ($expectations as $exp) { + if ($exp->isEligible() && $exp->matchArgs($args)) { + return $exp; + } + } + foreach ($expectations as $exp) { + if ($exp->matchArgs($args)) { + return $exp; + } + } + } + + /** + * Return all expectations assigned to this director + * + * @return array + */ + public function getExpectations() + { + return $this->_expectations; + } + + /** + * Return all expectations assigned to this director + * + * @return array + */ + public function getDefaultExpectations() + { + return $this->_defaults; + } + + /** + * Return the number of expectations assigned to this director. + * + * @return int + */ + public function getExpectationCount() + { + return count($this->getExpectations()) ?: count($this->getDefaultExpectations()); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/ExpectationInterface.php b/vendor/mockery/mockery/library/Mockery/ExpectationInterface.php new file mode 100644 index 000000000..7d0b53686 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/ExpectationInterface.php @@ -0,0 +1,46 @@ +once(); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/CachingGenerator.php b/vendor/mockery/mockery/library/Mockery/Generator/CachingGenerator.php new file mode 100644 index 000000000..6497e8853 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/CachingGenerator.php @@ -0,0 +1,45 @@ +generator = $generator; + } + + public function generate(MockConfiguration $config) + { + $hash = $config->getHash(); + if (isset($this->cache[$hash])) { + return $this->cache[$hash]; + } + + $definition = $this->generator->generate($config); + $this->cache[$hash] = $definition; + + return $definition; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/DefinedTargetClass.php b/vendor/mockery/mockery/library/Mockery/Generator/DefinedTargetClass.php new file mode 100644 index 000000000..663b22547 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/DefinedTargetClass.php @@ -0,0 +1,108 @@ +rfc = $rfc; + } + + public static function factory($name) + { + return new self(new \ReflectionClass($name)); + } + + public function getName() + { + return $this->rfc->getName(); + } + + public function isAbstract() + { + return $this->rfc->isAbstract(); + } + + public function isFinal() + { + return $this->rfc->isFinal(); + } + + public function getMethods() + { + return array_map(function ($method) { + return new Method($method); + }, $this->rfc->getMethods()); + } + + public function getInterfaces() + { + $class = __CLASS__; + return array_map(function ($interface) use ($class) { + return new $class($interface); + }, $this->rfc->getInterfaces()); + } + + public function __toString() + { + return $this->getName(); + } + + public function getNamespaceName() + { + return $this->rfc->getNamespaceName(); + } + + public function inNamespace() + { + return $this->rfc->inNamespace(); + } + + public function getShortName() + { + return $this->rfc->getShortName(); + } + + public function implementsInterface($interface) + { + return $this->rfc->implementsInterface($interface); + } + + public function hasInternalAncestor() + { + if ($this->rfc->isInternal()) { + return true; + } + + $child = $this->rfc; + while ($parent = $child->getParentClass()) { + if ($parent->isInternal()) { + return true; + } + $child = $parent; + } + + return false; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/Generator.php b/vendor/mockery/mockery/library/Mockery/Generator/Generator.php new file mode 100644 index 000000000..459a93ccc --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/Generator.php @@ -0,0 +1,27 @@ +method = $method; + } + + public function __call($method, $args) + { + return call_user_func_array(array($this->method, $method), $args); + } + + public function getParameters() + { + return array_map(function ($parameter) { + return new Parameter($parameter); + }, $this->method->getParameters()); + } + + public function getReturnType() + { + if (defined('HHVM_VERSION') && method_exists($this->method, 'getReturnTypeText') && $this->method->hasReturnType()) { + // Available in HHVM + $returnType = $this->method->getReturnTypeText(); + + // Remove tuple, ImmVector<>, ImmSet<>, ImmMap<>, array<>, anything with <>, void, mixed which cause eval() errors + if (preg_match('/(\w+<.*>)|(\(.+\))|(HH\\\\(void|mixed|this))/', $returnType)) { + return ''; + } + + // return directly without going through php logic. + return $returnType; + } + + if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0 && $this->method->hasReturnType()) { + $returnType = (string) $this->method->getReturnType(); + + if ('self' === $returnType) { + $returnType = "\\".$this->method->getDeclaringClass()->getName(); + } elseif (!\Mockery::isBuiltInType($returnType)) { + $returnType = '\\'.$returnType; + } + + if (version_compare(PHP_VERSION, '7.1.0-dev') >= 0 && $this->method->getReturnType()->allowsNull()) { + $returnType = '?'.$returnType; + } + + return $returnType; + } + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/MockConfiguration.php b/vendor/mockery/mockery/library/Mockery/Generator/MockConfiguration.php new file mode 100644 index 000000000..529311893 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/MockConfiguration.php @@ -0,0 +1,579 @@ +addTargets($targets); + $this->blackListedMethods = $blackListedMethods; + $this->whiteListedMethods = $whiteListedMethods; + $this->name = $name; + $this->instanceMock = $instanceMock; + $this->parameterOverrides = $parameterOverrides; + $this->mockOriginalDestructor = $mockOriginalDestructor; + $this->constantsMap = $constantsMap; + } + + /** + * Attempt to create a hash of the configuration, in order to allow caching + * + * @TODO workout if this will work + * + * @return string + */ + public function getHash() + { + $vars = array( + 'targetClassName' => $this->targetClassName, + 'targetInterfaceNames' => $this->targetInterfaceNames, + 'targetTraitNames' => $this->targetTraitNames, + 'name' => $this->name, + 'blackListedMethods' => $this->blackListedMethods, + 'whiteListedMethod' => $this->whiteListedMethods, + 'instanceMock' => $this->instanceMock, + 'parameterOverrides' => $this->parameterOverrides, + 'mockOriginalDestructor' => $this->mockOriginalDestructor + ); + + return md5(serialize($vars)); + } + + /** + * Gets a list of methods from the classes, interfaces and objects and + * filters them appropriately. Lot's of filtering going on, perhaps we could + * have filter classes to iterate through + */ + public function getMethodsToMock() + { + $methods = $this->getAllMethods(); + + foreach ($methods as $key => $method) { + if ($method->isFinal()) { + unset($methods[$key]); + } + } + + /** + * Whitelist trumps everything else + */ + if (count($this->getWhiteListedMethods())) { + $whitelist = array_map('strtolower', $this->getWhiteListedMethods()); + $methods = array_filter($methods, function ($method) use ($whitelist) { + return $method->isAbstract() || in_array(strtolower($method->getName()), $whitelist); + }); + + return $methods; + } + + /** + * Remove blacklisted methods + */ + if (count($this->getBlackListedMethods())) { + $blacklist = array_map('strtolower', $this->getBlackListedMethods()); + $methods = array_filter($methods, function ($method) use ($blacklist) { + return !in_array(strtolower($method->getName()), $blacklist); + }); + } + + /** + * Internal objects can not be instantiated with newInstanceArgs and if + * they implement Serializable, unserialize will have to be called. As + * such, we can't mock it and will need a pass to add a dummy + * implementation + */ + if ($this->getTargetClass() + && $this->getTargetClass()->implementsInterface("Serializable") + && $this->getTargetClass()->hasInternalAncestor()) { + $methods = array_filter($methods, function ($method) { + return $method->getName() !== "unserialize"; + }); + } + + return array_values($methods); + } + + /** + * We declare the __call method to handle undefined stuff, if the class + * we're mocking has also defined it, we need to comply with their interface + */ + public function requiresCallTypeHintRemoval() + { + foreach ($this->getAllMethods() as $method) { + if ("__call" === $method->getName()) { + $params = $method->getParameters(); + return !$params[1]->isArray(); + } + } + + return false; + } + + /** + * We declare the __callStatic method to handle undefined stuff, if the class + * we're mocking has also defined it, we need to comply with their interface + */ + public function requiresCallStaticTypeHintRemoval() + { + foreach ($this->getAllMethods() as $method) { + if ("__callStatic" === $method->getName()) { + $params = $method->getParameters(); + return !$params[1]->isArray(); + } + } + + return false; + } + + public function rename($className) + { + $targets = array(); + + if ($this->targetClassName) { + $targets[] = $this->targetClassName; + } + + if ($this->targetInterfaceNames) { + $targets = array_merge($targets, $this->targetInterfaceNames); + } + + if ($this->targetTraitNames) { + $targets = array_merge($targets, $this->targetTraitNames); + } + + if ($this->targetObject) { + $targets[] = $this->targetObject; + } + + return new self( + $targets, + $this->blackListedMethods, + $this->whiteListedMethods, + $className, + $this->instanceMock, + $this->parameterOverrides, + $this->mockOriginalDestructor, + $this->constantsMap + ); + } + + protected function addTarget($target) + { + if (is_object($target)) { + $this->setTargetObject($target); + $this->setTargetClassName(get_class($target)); + return $this; + } + + if ($target[0] !== "\\") { + $target = "\\" . $target; + } + + if (class_exists($target)) { + $this->setTargetClassName($target); + return $this; + } + + if (interface_exists($target)) { + $this->addTargetInterfaceName($target); + return $this; + } + + if (trait_exists($target)) { + $this->addTargetTraitName($target); + return $this; + } + + /** + * Default is to set as class, or interface if class already set + * + * Don't like this condition, can't remember what the default + * targetClass is for + */ + if ($this->getTargetClassName()) { + $this->addTargetInterfaceName($target); + return $this; + } + + $this->setTargetClassName($target); + } + + protected function addTargets($interfaces) + { + foreach ($interfaces as $interface) { + $this->addTarget($interface); + } + } + + public function getTargetClassName() + { + return $this->targetClassName; + } + + public function getTargetClass() + { + if ($this->targetClass) { + return $this->targetClass; + } + + if (!$this->targetClassName) { + return null; + } + + if (class_exists($this->targetClassName)) { + $dtc = DefinedTargetClass::factory($this->targetClassName); + + if ($this->getTargetObject() == false && $dtc->isFinal()) { + throw new \Mockery\Exception( + 'The class ' . $this->targetClassName . ' is marked final and its methods' + . ' cannot be replaced. Classes marked final can be passed in' + . ' to \Mockery::mock() as instantiated objects to create a' + . ' partial mock, but only if the mock is not subject to type' + . ' hinting checks.' + ); + } + + $this->targetClass = $dtc; + } else { + $this->targetClass = UndefinedTargetClass::factory($this->targetClassName); + } + + return $this->targetClass; + } + + public function getTargetTraits() + { + if (!empty($this->targetTraits)) { + return $this->targetTraits; + } + + foreach ($this->targetTraitNames as $targetTrait) { + $this->targetTraits[] = DefinedTargetClass::factory($targetTrait); + } + + $this->targetTraits = array_unique($this->targetTraits); // just in case + return $this->targetTraits; + } + + public function getTargetInterfaces() + { + if (!empty($this->targetInterfaces)) { + return $this->targetInterfaces; + } + + foreach ($this->targetInterfaceNames as $targetInterface) { + if (!interface_exists($targetInterface)) { + $this->targetInterfaces[] = UndefinedTargetClass::factory($targetInterface); + return; + } + + $dtc = DefinedTargetClass::factory($targetInterface); + $extendedInterfaces = array_keys($dtc->getInterfaces()); + $extendedInterfaces[] = $targetInterface; + + $traversableFound = false; + $iteratorShiftedToFront = false; + foreach ($extendedInterfaces as $interface) { + if (!$traversableFound && preg_match("/^\\?Iterator(|Aggregate)$/i", $interface)) { + break; + } + + if (preg_match("/^\\\\?IteratorAggregate$/i", $interface)) { + $this->targetInterfaces[] = DefinedTargetClass::factory("\\IteratorAggregate"); + $iteratorShiftedToFront = true; + } elseif (preg_match("/^\\\\?Iterator$/i", $interface)) { + $this->targetInterfaces[] = DefinedTargetClass::factory("\\Iterator"); + $iteratorShiftedToFront = true; + } elseif (preg_match("/^\\\\?Traversable$/i", $interface)) { + $traversableFound = true; + } + } + + if ($traversableFound && !$iteratorShiftedToFront) { + $this->targetInterfaces[] = DefinedTargetClass::factory("\\IteratorAggregate"); + } + + /** + * We never straight up implement Traversable + */ + if (!preg_match("/^\\\\?Traversable$/i", $targetInterface)) { + $this->targetInterfaces[] = $dtc; + } + } + $this->targetInterfaces = array_unique($this->targetInterfaces); // just in case + return $this->targetInterfaces; + } + + public function getTargetObject() + { + return $this->targetObject; + } + + public function getName() + { + return $this->name; + } + + /** + * Generate a suitable name based on the config + */ + public function generateName() + { + $name = 'Mockery_' . static::$mockCounter++; + + if ($this->getTargetObject()) { + $name .= "_" . str_replace("\\", "_", get_class($this->getTargetObject())); + } + + if ($this->getTargetClass()) { + $name .= "_" . str_replace("\\", "_", $this->getTargetClass()->getName()); + } + + if ($this->getTargetInterfaces()) { + $name .= array_reduce($this->getTargetInterfaces(), function ($tmpname, $i) { + $tmpname .= '_' . str_replace("\\", "_", $i->getName()); + return $tmpname; + }, ''); + } + + return $name; + } + + public function getShortName() + { + $parts = explode("\\", $this->getName()); + return array_pop($parts); + } + + public function getNamespaceName() + { + $parts = explode("\\", $this->getName()); + array_pop($parts); + + if (count($parts)) { + return implode("\\", $parts); + } + + return ""; + } + + public function getBlackListedMethods() + { + return $this->blackListedMethods; + } + + public function getWhiteListedMethods() + { + return $this->whiteListedMethods; + } + + public function isInstanceMock() + { + return $this->instanceMock; + } + + public function getParameterOverrides() + { + return $this->parameterOverrides; + } + + public function isMockOriginalDestructor() + { + return $this->mockOriginalDestructor; + } + + protected function setTargetClassName($targetClassName) + { + $this->targetClassName = $targetClassName; + } + + protected function getAllMethods() + { + if ($this->allMethods) { + return $this->allMethods; + } + + $classes = $this->getTargetInterfaces(); + + if ($this->getTargetClass()) { + $classes[] = $this->getTargetClass(); + } + + $methods = array(); + foreach ($classes as $class) { + $methods = array_merge($methods, $class->getMethods()); + } + + foreach ($this->getTargetTraits() as $trait) { + foreach ($trait->getMethods() as $method) { + if ($method->isAbstract()) { + $methods[] = $method; + } + } + } + + $names = array(); + $methods = array_filter($methods, function ($method) use (&$names) { + if (in_array($method->getName(), $names)) { + return false; + } + + $names[] = $method->getName(); + return true; + }); + + // In HHVM, class methods can be annotated with the built-in + // <<__Memoize>> attribute (similar to a Python decorator), + // which builds an LRU cache of method arguments and their + // return values. + // https://docs.hhvm.com/hack/attributes/special#__memoize + // + // HHVM implements this behavior by inserting a private helper + // method into the class at runtime which is named as the + // method to be memoized, suffixed by `$memoize_impl`. + // https://github.com/facebook/hhvm/blob/6aa46f1e8c2351b97d65e67b73e26f274a7c3f2e/hphp/runtime/vm/func.cpp#L364 + // + // Ordinarily, PHP does not all allow the `$` token in method + // names, but since the memoization helper is inserted at + // runtime (and not in userland), HHVM allows it. + // + // We use code generation and eval() for some types of mocks, + // so to avoid syntax errors from these memoization helpers, + // we must filter them from our list of class methods. + // + // This effectively disables the memoization behavior in HHVM, + // but that's preferable to failing catastrophically when + // attempting to mock a class using the attribute. + if (defined('HHVM_VERSION')) { + $methods = array_filter($methods, function ($method) { + return strpos($method->getName(), '$memoize_impl') === false; + }); + } + + return $this->allMethods = $methods; + } + + /** + * If we attempt to implement Traversable, we must ensure we are also + * implementing either Iterator or IteratorAggregate, and that whichever one + * it is comes before Traversable in the list of implements. + */ + protected function addTargetInterfaceName($targetInterface) + { + $this->targetInterfaceNames[] = $targetInterface; + } + + protected function addTargetTraitName($targetTraitName) + { + $this->targetTraitNames[] = $targetTraitName; + } + + protected function setTargetObject($object) + { + $this->targetObject = $object; + } + + public function getConstantsMap() + { + return $this->constantsMap; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/MockConfigurationBuilder.php b/vendor/mockery/mockery/library/Mockery/Generator/MockConfigurationBuilder.php new file mode 100644 index 000000000..817049296 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/MockConfigurationBuilder.php @@ -0,0 +1,176 @@ += 0) { + $this->blackListedMethods = array_diff($this->blackListedMethods, $this->php7SemiReservedKeywords); + } + } + + public function addTarget($target) + { + $this->targets[] = $target; + + return $this; + } + + public function addTargets($targets) + { + foreach ($targets as $target) { + $this->addTarget($target); + } + + return $this; + } + + public function setName($name) + { + $this->name = $name; + return $this; + } + + public function addBlackListedMethod($blackListedMethod) + { + $this->blackListedMethods[] = $blackListedMethod; + return $this; + } + + public function addBlackListedMethods(array $blackListedMethods) + { + foreach ($blackListedMethods as $method) { + $this->addBlackListedMethod($method); + } + return $this; + } + + public function setBlackListedMethods(array $blackListedMethods) + { + $this->blackListedMethods = $blackListedMethods; + return $this; + } + + public function addWhiteListedMethod($whiteListedMethod) + { + $this->whiteListedMethods[] = $whiteListedMethod; + return $this; + } + + public function addWhiteListedMethods(array $whiteListedMethods) + { + foreach ($whiteListedMethods as $method) { + $this->addWhiteListedMethod($method); + } + return $this; + } + + public function setWhiteListedMethods(array $whiteListedMethods) + { + $this->whiteListedMethods = $whiteListedMethods; + return $this; + } + + public function setInstanceMock($instanceMock) + { + $this->instanceMock = (bool) $instanceMock; + } + + public function setParameterOverrides(array $overrides) + { + $this->parameterOverrides = $overrides; + } + + public function setMockOriginalDestructor($mockDestructor) + { + $this->mockOriginalDestructor = $mockDestructor; + return $this; + } + + public function setConstantsMap(array $map) + { + $this->constantsMap = $map; + } + + public function getMockConfiguration() + { + return new MockConfiguration( + $this->targets, + $this->blackListedMethods, + $this->whiteListedMethods, + $this->name, + $this->instanceMock, + $this->parameterOverrides, + $this->mockOriginalDestructor, + $this->constantsMap + ); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/MockDefinition.php b/vendor/mockery/mockery/library/Mockery/Generator/MockDefinition.php new file mode 100644 index 000000000..fd6a9fa2a --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/MockDefinition.php @@ -0,0 +1,51 @@ +getName()) { + throw new \InvalidArgumentException("MockConfiguration must contain a name"); + } + $this->config = $config; + $this->code = $code; + } + + public function getConfig() + { + return $this->config; + } + + public function getClassName() + { + return $this->config->getName(); + } + + public function getCode() + { + return $this->code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/Parameter.php b/vendor/mockery/mockery/library/Mockery/Generator/Parameter.php new file mode 100644 index 000000000..a5338c0c6 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/Parameter.php @@ -0,0 +1,110 @@ +rfp = $rfp; + } + + public function __call($method, array $args) + { + return call_user_func_array(array($this->rfp, $method), $args); + } + + public function getClass() + { + return new DefinedTargetClass($this->rfp->getClass()); + } + + public function getTypeHintAsString() + { + if (method_exists($this->rfp, 'getTypehintText')) { + // Available in HHVM + $typehint = $this->rfp->getTypehintText(); + + // not exhaustive, but will do for now + if (in_array($typehint, array('int', 'integer', 'float', 'string', 'bool', 'boolean'))) { + return ''; + } + + return $typehint; + } + + if ($this->rfp->isArray()) { + return 'array'; + } + + /* + * PHP < 5.4.1 has some strange behaviour with a typehint of self and + * subclass signatures, so we risk the regexp instead + */ + if ((version_compare(PHP_VERSION, '5.4.1') >= 0)) { + try { + if ($this->rfp->getClass()) { + return $this->rfp->getClass()->getName(); + } + } catch (\ReflectionException $re) { + // noop + } + } + + if (version_compare(PHP_VERSION, '7.0.0-dev') >= 0 && $this->rfp->hasType()) { + return (string) $this->rfp->getType(); + } + + if (preg_match('/^Parameter #[0-9]+ \[ \<(required|optional)\> (?\S+ )?.*\$' . $this->rfp->getName() . ' .*\]$/', $this->rfp->__toString(), $typehintMatch)) { + if (!empty($typehintMatch['typehint'])) { + return $typehintMatch['typehint']; + } + } + + return ''; + } + + /** + * Some internal classes have funny looking definitions... + */ + public function getName() + { + $name = $this->rfp->getName(); + if (!$name || $name == '...') { + $name = 'arg' . static::$parameterCounter++; + } + + return $name; + } + + + /** + * Variadics only introduced in 5.6 + */ + public function isVariadic() + { + return $this->rfp->isVariadic(); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/CallTypeHintPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/CallTypeHintPass.php new file mode 100644 index 000000000..fd00264ca --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/CallTypeHintPass.php @@ -0,0 +1,47 @@ +requiresCallTypeHintRemoval()) { + $code = str_replace( + 'public function __call($method, array $args)', + 'public function __call($method, $args)', + $code + ); + } + + if ($config->requiresCallStaticTypeHintRemoval()) { + $code = str_replace( + 'public static function __callStatic($method, array $args)', + 'public static function __callStatic($method, $args)', + $code + ); + } + + return $code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ClassNamePass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ClassNamePass.php new file mode 100644 index 000000000..b5a31098e --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ClassNamePass.php @@ -0,0 +1,49 @@ +getNamespaceName(); + + $namespace = ltrim($namespace, "\\"); + + $className = $config->getShortName(); + + $code = str_replace( + 'namespace Mockery;', + $namespace ? 'namespace ' . $namespace . ';' : '', + $code + ); + + $code = str_replace( + 'class Mock', + 'class ' . $className, + $code + ); + + return $code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ClassPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ClassPass.php new file mode 100644 index 000000000..91ccfabfa --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ClassPass.php @@ -0,0 +1,52 @@ +getTargetClass(); + + if (!$target) { + return $code; + } + + if ($target->isFinal()) { + return $code; + } + + $className = ltrim($target->getName(), "\\"); + if (!class_exists($className)) { + \Mockery::declareClass($className); + } + + $code = str_replace( + "implements MockInterface", + "extends \\" . $className . " implements MockInterface", + $code + ); + + return $code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ConstantsPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ConstantsPass.php new file mode 100644 index 000000000..28f5cdff3 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/ConstantsPass.php @@ -0,0 +1,33 @@ +getConstantsMap(); + if (empty($cm)) { + return $code; + } + + if (!isset($cm[$config->getName()])) { + return $code; + } + + $cm = $cm[$config->getName()]; + + $constantsCode = ''; + foreach ($cm as $constant => $value) { + $constantsCode .= sprintf("\n const %s = '%s';\n", $constant, $value); + } + + $i = strrpos($code, '}'); + $code = substr_replace($code, $constantsCode, $i); + $code .= "}\n"; + + return $code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/InstanceMockPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/InstanceMockPass.php new file mode 100644 index 000000000..627914757 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/InstanceMockPass.php @@ -0,0 +1,83 @@ +_mockery_ignoreVerification = false; + \$associatedRealObject = \Mockery::fetchMock(__CLASS__); + + foreach (get_object_vars(\$this) as \$attr => \$val) { + if (\$attr !== "_mockery_ignoreVerification" && \$attr !== "_mockery_expectations") { + \$this->\$attr = \$associatedRealObject->\$attr; + } + } + + \$directors = \$associatedRealObject->mockery_getExpectations(); + foreach (\$directors as \$method=>\$director) { + // get the director method needed + \$existingDirector = \$this->mockery_getExpectationsFor(\$method); + if (!\$existingDirector) { + \$existingDirector = new \Mockery\ExpectationDirector(\$method, \$this); + \$this->mockery_setExpectationsFor(\$method, \$existingDirector); + } + \$expectations = \$director->getExpectations(); + foreach (\$expectations as \$expectation) { + \$clonedExpectation = clone \$expectation; + \$existingDirector->addExpectation(\$clonedExpectation); + } + \$defaultExpectations = \$director->getDefaultExpectations(); + foreach (array_reverse(\$defaultExpectations) as \$expectation) { + \$clonedExpectation = clone \$expectation; + \$existingDirector->addExpectation(\$clonedExpectation); + \$existingDirector->makeExpectationDefault(\$clonedExpectation); + } + } + \Mockery::getContainer()->rememberMock(\$this); + + \$this->_mockery_constructorCalled(func_get_args()); + } +MOCK; + + public function apply($code, MockConfiguration $config) + { + if ($config->isInstanceMock()) { + $code = $this->appendToClass($code, static::INSTANCE_MOCK_CODE); + } + + return $code; + } + + protected function appendToClass($class, $code) + { + $lastBrace = strrpos($class, "}"); + $class = substr($class, 0, $lastBrace) . $code . "\n }\n"; + return $class; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/InterfacePass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/InterfacePass.php new file mode 100644 index 000000000..982956e5c --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/InterfacePass.php @@ -0,0 +1,48 @@ +getTargetInterfaces() as $i) { + $name = ltrim($i->getName(), "\\"); + if (!interface_exists($name)) { + \Mockery::declareInterface($name); + } + } + + $interfaces = array_reduce((array) $config->getTargetInterfaces(), function ($code, $i) { + return $code . ", \\" . ltrim($i->getName(), "\\"); + }, ""); + + $code = str_replace( + "implements MockInterface", + "implements MockInterface" . $interfaces, + $code + ); + + return $code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/MagicMethodTypeHintsPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/MagicMethodTypeHintsPass.php new file mode 100644 index 000000000..4a457b348 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/MagicMethodTypeHintsPass.php @@ -0,0 +1,208 @@ +getMagicMethods($config->getTargetClass()); + foreach ($config->getTargetInterfaces() as $interface) { + $magicMethods = array_merge($magicMethods, $this->getMagicMethods($interface)); + } + + foreach ($magicMethods as $method) { + $code = $this->applyMagicTypeHints($code, $method); + } + + return $code; + } + + /** + * Returns the magic methods within the + * passed DefinedTargetClass. + * + * @param TargetClassInterface $class + * @return array + */ + public function getMagicMethods( + TargetClassInterface $class = null + ) { + if (is_null($class)) { + return array(); + } + return array_filter($class->getMethods(), function (Method $method) { + return in_array($method->getName(), $this->mockMagicMethods); + }); + } + + /** + * Applies type hints of magic methods from + * class to the passed code. + * + * @param int $code + * @param Method $method + * @return string + */ + private function applyMagicTypeHints($code, Method $method) + { + if ($this->isMethodWithinCode($code, $method)) { + $namedParameters = $this->getOriginalParameters( + $code, + $method + ); + $code = preg_replace( + $this->getDeclarationRegex($method->getName()), + $this->getMethodDeclaration($method, $namedParameters), + $code + ); + } + return $code; + } + + /** + * Checks if the method is declared withing code. + * + * @param int $code + * @param Method $method + * @return boolean + */ + private function isMethodWithinCode($code, Method $method) + { + return preg_match( + $this->getDeclarationRegex($method->getName()), + $code + ) == 1; + } + + /** + * Returns the method original parameters, as they're + * described in the $code string. + * + * @param int $code + * @param Method $method + * @return array + */ + private function getOriginalParameters($code, Method $method) + { + $matches = []; + $parameterMatches = []; + + preg_match( + $this->getDeclarationRegex($method->getName()), + $code, + $matches + ); + + if (count($matches) > 0) { + preg_match_all( + '/(?<=\$)(\w+)+/i', + $matches[0], + $parameterMatches + ); + } + + $groupMatches = end($parameterMatches); + $parameterNames = is_array($groupMatches) ? + $groupMatches : + array($groupMatches); + + return $parameterNames; + } + + /** + * Gets the declaration code, as a string, for the passed method. + * + * @param Method $method + * @param array $namedParameters + * @return string + */ + private function getMethodDeclaration( + Method $method, + array $namedParameters + ) { + $declaration = 'public'; + $declaration .= $method->isStatic() ? ' static' : ''; + $declaration .= ' function '.$method->getName().'('; + + foreach ($method->getParameters() as $index => $parameter) { + $declaration .= $parameter->getTypeHintAsString().' '; + $name = isset($namedParameters[$index]) ? + $namedParameters[$index] : + $parameter->getName(); + $declaration .= '$'.$name; + $declaration .= ','; + } + $declaration = rtrim($declaration, ','); + $declaration .= ') '; + + $returnType = $method->getReturnType(); + if (!empty($returnType)) { + $declaration .= ': '.$returnType; + } + + return $declaration; + } + + /** + * Returns a regex string used to match the + * declaration of some method. + * + * @param string $methodName + * @return string + */ + private function getDeclarationRegex($methodName) + { + return "/public\s+(?:static\s+)?function\s+$methodName\s*\(.*\)\s*(?=\{)/i"; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/MethodDefinitionPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/MethodDefinitionPass.php new file mode 100644 index 000000000..c83ecf8cd --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/MethodDefinitionPass.php @@ -0,0 +1,175 @@ +getMethodsToMock() as $method) { + if ($method->isPublic()) { + $methodDef = 'public'; + } elseif ($method->isProtected()) { + $methodDef = 'protected'; + } else { + $methodDef = 'private'; + } + + if ($method->isStatic()) { + $methodDef .= ' static'; + } + + $methodDef .= ' function '; + $methodDef .= $method->returnsReference() ? ' & ' : ''; + $methodDef .= $method->getName(); + $methodDef .= $this->renderParams($method, $config); + $methodDef .= $this->renderReturnType($method); + $methodDef .= $this->renderMethodBody($method, $config); + + $code = $this->appendToClass($code, $methodDef); + } + + return $code; + } + + protected function renderParams(Method $method, $config) + { + $class = $method->getDeclaringClass(); + if ($class->isInternal()) { + $overrides = $config->getParameterOverrides(); + + if (isset($overrides[strtolower($class->getName())][$method->getName()])) { + return '(' . implode(',', $overrides[strtolower($class->getName())][$method->getName()]) . ')'; + } + } + + $methodParams = array(); + $params = $method->getParameters(); + foreach ($params as $param) { + $paramDef = $this->renderTypeHint($param); + $paramDef .= $param->isPassedByReference() ? '&' : ''; + $paramDef .= $param->isVariadic() ? '...' : ''; + $paramDef .= '$' . $param->getName(); + + if (!$param->isVariadic()) { + if (false !== $param->isDefaultValueAvailable()) { + $paramDef .= ' = ' . var_export($param->getDefaultValue(), true); + } elseif ($param->isOptional()) { + $paramDef .= ' = null'; + } + } + + $methodParams[] = $paramDef; + } + return '(' . implode(', ', $methodParams) . ')'; + } + + protected function renderReturnType(Method $method) + { + $type = $method->getReturnType(); + return $type ? sprintf(': %s', $type) : ''; + } + + protected function appendToClass($class, $code) + { + $lastBrace = strrpos($class, "}"); + $class = substr($class, 0, $lastBrace) . $code . "\n }\n"; + return $class; + } + + protected function renderTypeHint(Parameter $param) + { + $typeHint = trim($param->getTypeHintAsString()); + + if (!empty($typeHint)) { + if (!\Mockery::isBuiltInType($typeHint)) { + $typeHint = '\\'.$typeHint; + } + + if (version_compare(PHP_VERSION, '7.1.0-dev') >= 0 && $param->allowsNull()) { + $typeHint = "?".$typeHint; + } + } + + return $typeHint .= ' '; + } + + private function renderMethodBody($method, $config) + { + $invoke = $method->isStatic() ? 'static::_mockery_handleStaticMethodCall' : '$this->_mockery_handleMethodCall'; + $body = <<getDeclaringClass(); + $class_name = strtolower($class->getName()); + $overrides = $config->getParameterOverrides(); + if (isset($overrides[$class_name][$method->getName()])) { + $params = array_values($overrides[$class_name][$method->getName()]); + $paramCount = count($params); + for ($i = 0; $i < $paramCount; ++$i) { + $param = $params[$i]; + if (strpos($param, '&') !== false) { + $body .= << $i) { + \$argv[$i] = {$param}; +} + +BODY; + } + } + } else { + $params = array_values($method->getParameters()); + $paramCount = count($params); + for ($i = 0; $i < $paramCount; ++$i) { + $param = $params[$i]; + if (!$param->isPassedByReference()) { + continue; + } + $body .= << $i) { + \$argv[$i] =& \${$param->getName()}; +} + +BODY; + } + } + + $body .= "\$ret = {$invoke}(__FUNCTION__, \$argv);\n"; + + if ($method->getReturnType() !== "void") { + $body .= "return \$ret;\n"; + } + + $body .= "}\n"; + return $body; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/Pass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/Pass.php new file mode 100644 index 000000000..f7b72c9fa --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/Pass.php @@ -0,0 +1,28 @@ + '/public function __wakeup\(\)\s+\{.*?\}/sm', + ); + + public function apply($code, MockConfiguration $config) + { + $target = $config->getTargetClass(); + + if (!$target) { + return $code; + } + + foreach ($target->getMethods() as $method) { + if ($method->isFinal() && isset($this->methods[$method->getName()])) { + $code = preg_replace($this->methods[$method->getName()], '', $code); + } + } + + return $code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/RemoveDestructorPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/RemoveDestructorPass.php new file mode 100644 index 000000000..ed5a4206b --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/RemoveDestructorPass.php @@ -0,0 +1,45 @@ + + */ + +namespace Mockery\Generator\StringManipulation\Pass; + +use Mockery\Generator\MockConfiguration; + +/** + * Remove mock's empty destructor if we tend to use original class destructor + */ +class RemoveDestructorPass +{ + public function apply($code, MockConfiguration $config) + { + $target = $config->getTargetClass(); + + if (!$target) { + return $code; + } + + if (!$config->isMockOriginalDestructor()) { + $code = preg_replace('/public function __destruct\(\)\s+\{.*?\}/sm', '', $code); + } + + return $code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/RemoveUnserializeForInternalSerializableClassesPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/RemoveUnserializeForInternalSerializableClassesPass.php new file mode 100644 index 000000000..840fe9986 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/RemoveUnserializeForInternalSerializableClassesPass.php @@ -0,0 +1,58 @@ +getTargetClass(); + + if (!$target) { + return $code; + } + + if (!$target->hasInternalAncestor() || !$target->implementsInterface("Serializable")) { + return $code; + } + + $code = $this->appendToClass($code, self::DUMMY_METHOD_DEFINITION); + + return $code; + } + + protected function appendToClass($class, $code) + { + $lastBrace = strrpos($class, "}"); + $class = substr($class, 0, $lastBrace) . $code . "\n }\n"; + return $class; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/TraitPass.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/TraitPass.php new file mode 100644 index 000000000..13343c334 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulation/Pass/TraitPass.php @@ -0,0 +1,47 @@ +getTargetTraits(); + + if (empty($traits)) { + return $code; + } + + $useStatements = array_map(function ($trait) { + return "use \\\\".ltrim($trait->getName(), "\\").";"; + }, $traits); + + $code = preg_replace( + '/^{$/m', + "{\n ".implode("\n ", $useStatements)."\n", + $code + ); + + return $code; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/StringManipulationGenerator.php b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulationGenerator.php new file mode 100644 index 000000000..544bb88ff --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/StringManipulationGenerator.php @@ -0,0 +1,87 @@ +passes = $passes; + } + + public function generate(MockConfiguration $config) + { + $code = file_get_contents(__DIR__ . '/../Mock.php'); + $className = $config->getName() ?: $config->generateName(); + + $namedConfig = $config->rename($className); + + foreach ($this->passes as $pass) { + $code = $pass->apply($code, $namedConfig); + } + + return new MockDefinition($namedConfig, $code); + } + + public function addPass(Pass $pass) + { + $this->passes[] = $pass; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Generator/TargetClassInterface.php b/vendor/mockery/mockery/library/Mockery/Generator/TargetClassInterface.php new file mode 100644 index 000000000..772441242 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Generator/TargetClassInterface.php @@ -0,0 +1,107 @@ +name = $name; + } + + public static function factory($name) + { + return new self($name); + } + + public function getName() + { + return $this->name; + } + + public function isAbstract() + { + return false; + } + + public function isFinal() + { + return false; + } + + public function getMethods() + { + return array(); + } + + public function getInterfaces() + { + return array(); + } + + public function getNamespaceName() + { + $parts = explode("\\", ltrim($this->getName(), "\\")); + array_pop($parts); + return implode("\\", $parts); + } + + public function inNamespace() + { + return $this->getNamespaceName() !== ''; + } + + public function getShortName() + { + $parts = explode("\\", $this->getName()); + return array_pop($parts); + } + + public function implementsInterface($interface) + { + return false; + } + + public function hasInternalAncestor() + { + return false; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/HigherOrderMessage.php b/vendor/mockery/mockery/library/Mockery/HigherOrderMessage.php new file mode 100644 index 000000000..1c13c8985 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/HigherOrderMessage.php @@ -0,0 +1,49 @@ +mock = $mock; + $this->method = $method; + } + + /** + * @return \Mockery\Expectation + */ + public function __call($method, $args) + { + if ($this->method === 'shouldNotHaveReceived') { + return $this->mock->{$this->method}($method, $args); + } + + $expectation = $this->mock->{$this->method}($method); + return $expectation->withArgs($args); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Instantiator.php b/vendor/mockery/mockery/library/Mockery/Instantiator.php new file mode 100644 index 000000000..0e2c46476 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Instantiator.php @@ -0,0 +1,209 @@ +. + */ + +namespace Mockery; + +use Closure; +use ReflectionClass; +use UnexpectedValueException; +use InvalidArgumentException; + +/** + * This is a trimmed down version of https://github.com/doctrine/instantiator, + * basically without the caching + * + * @author Marco Pivetta + */ +final class Instantiator +{ + /** + * Markers used internally by PHP to define whether {@see \unserialize} should invoke + * the method {@see \Serializable::unserialize()} when dealing with classes implementing + * the {@see \Serializable} interface. + */ + const SERIALIZATION_FORMAT_USE_UNSERIALIZER = 'C'; + const SERIALIZATION_FORMAT_AVOID_UNSERIALIZER = 'O'; + + /** + * {@inheritDoc} + */ + public function instantiate($className) + { + $factory = $this->buildFactory($className); + $instance = $factory(); + + return $instance; + } + + /** + * @internal + * @private + * + * Builds a {@see \Closure} capable of instantiating the given $className without + * invoking its constructor. + * This method is only exposed as public because of PHP 5.3 compatibility. Do not + * use this method in your own code + * + * @param string $className + * + * @return Closure + */ + public function buildFactory($className) + { + $reflectionClass = $this->getReflectionClass($className); + + if ($this->isInstantiableViaReflection($reflectionClass)) { + return function () use ($reflectionClass) { + return $reflectionClass->newInstanceWithoutConstructor(); + }; + } + + $serializedString = sprintf( + '%s:%d:"%s":0:{}', + $this->getSerializationFormat($reflectionClass), + strlen($className), + $className + ); + + $this->attemptInstantiationViaUnSerialization($reflectionClass, $serializedString); + + return function () use ($serializedString) { + return unserialize($serializedString); + }; + } + + /** + * @param string $className + * + * @return ReflectionClass + * + * @throws InvalidArgumentException + */ + private function getReflectionClass($className) + { + if (! class_exists($className)) { + throw new InvalidArgumentException("Class:$className does not exist"); + } + + $reflection = new ReflectionClass($className); + + if ($reflection->isAbstract()) { + throw new InvalidArgumentException("Class:$className is an abstract class"); + } + + return $reflection; + } + + /** + * @param ReflectionClass $reflectionClass + * @param string $serializedString + * + * @throws UnexpectedValueException + * + * @return void + */ + private function attemptInstantiationViaUnSerialization(ReflectionClass $reflectionClass, $serializedString) + { + set_error_handler(function ($code, $message, $file, $line) use ($reflectionClass, & $error) { + $msg = sprintf( + 'Could not produce an instance of "%s" via un-serialization, since an error was triggered in file "%s" at line "%d"', + $reflectionClass->getName(), + $file, + $line + ); + + $error = new UnexpectedValueException($msg, 0, new \Exception($message, $code)); + }); + + try { + unserialize($serializedString); + } catch (\Exception $exception) { + restore_error_handler(); + + throw new UnexpectedValueException("An exception was raised while trying to instantiate an instance of \"{$reflectionClass->getName()}\" via un-serialization", 0, $exception); + } + + restore_error_handler(); + + if ($error) { + throw $error; + } + } + + /** + * @param ReflectionClass $reflectionClass + * + * @return bool + */ + private function isInstantiableViaReflection(ReflectionClass $reflectionClass) + { + return ! ($reflectionClass->isInternal() && $reflectionClass->isFinal()); + } + + /** + * Verifies whether the given class is to be considered internal + * + * @param ReflectionClass $reflectionClass + * + * @return bool + */ + private function hasInternalAncestors(ReflectionClass $reflectionClass) + { + do { + if ($reflectionClass->isInternal()) { + return true; + } + } while ($reflectionClass = $reflectionClass->getParentClass()); + + return false; + } + + /** + * Verifies if the given PHP version implements the `Serializable` interface serialization + * with an incompatible serialization format. If that's the case, use serialization marker + * "C" instead of "O". + * + * @link http://news.php.net/php.internals/74654 + * + * @param ReflectionClass $reflectionClass + * + * @return string the serialization format marker, either self::SERIALIZATION_FORMAT_USE_UNSERIALIZER + * or self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER + */ + private function getSerializationFormat(ReflectionClass $reflectionClass) + { + if ($this->isPhpVersionWithBrokenSerializationFormat() + && $reflectionClass->implementsInterface('Serializable') + ) { + return self::SERIALIZATION_FORMAT_USE_UNSERIALIZER; + } + + return self::SERIALIZATION_FORMAT_AVOID_UNSERIALIZER; + } + + /** + * Checks whether the current PHP runtime uses an incompatible serialization format + * + * @return bool + */ + private function isPhpVersionWithBrokenSerializationFormat() + { + return PHP_VERSION_ID === 50429 || PHP_VERSION_ID === 50513; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php b/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php new file mode 100644 index 000000000..e5f78a200 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Loader/EvalLoader.php @@ -0,0 +1,36 @@ +getClassName(), false)) { + return; + } + + eval("?>" . $definition->getCode()); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Loader/Loader.php b/vendor/mockery/mockery/library/Mockery/Loader/Loader.php new file mode 100644 index 000000000..170ffb6e9 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Loader/Loader.php @@ -0,0 +1,28 @@ +path = realpath($path) ?: sys_get_temp_dir(); + } + + public function load(MockDefinition $definition) + { + if (class_exists($definition->getClassName(), false)) { + return; + } + + $tmpfname = $this->path.DIRECTORY_SEPARATOR."Mockery_".uniqid().".php"; + file_put_contents($tmpfname, $definition->getCode()); + + require $tmpfname; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/AndAnyOtherArgs.php b/vendor/mockery/mockery/library/Mockery/Matcher/AndAnyOtherArgs.php new file mode 100644 index 000000000..e3c3b9439 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/AndAnyOtherArgs.php @@ -0,0 +1,45 @@ +'; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/Any.php b/vendor/mockery/mockery/library/Mockery/Matcher/Any.php new file mode 100644 index 000000000..1ff440b1b --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/Any.php @@ -0,0 +1,45 @@ +'; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/AnyArgs.php b/vendor/mockery/mockery/library/Mockery/Matcher/AnyArgs.php new file mode 100644 index 000000000..9663a76d4 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/AnyArgs.php @@ -0,0 +1,40 @@ +'; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/AnyOf.php b/vendor/mockery/mockery/library/Mockery/Matcher/AnyOf.php new file mode 100644 index 000000000..bcce4b745 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/AnyOf.php @@ -0,0 +1,46 @@ +_expected, true); + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/ArgumentListMatcher.php b/vendor/mockery/mockery/library/Mockery/Matcher/ArgumentListMatcher.php new file mode 100644 index 000000000..04408f569 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/ArgumentListMatcher.php @@ -0,0 +1,25 @@ +_expected; + $result = $closure($actual); + return $result === true; + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/Contains.php b/vendor/mockery/mockery/library/Mockery/Matcher/Contains.php new file mode 100644 index 000000000..79afb73a7 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/Contains.php @@ -0,0 +1,64 @@ +_expected as $exp) { + $match = false; + foreach ($values as $val) { + if ($exp === $val || $exp == $val) { + $match = true; + break; + } + } + if ($match === false) { + return false; + } + } + return true; + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + $return = '_expected as $v) { + $elements[] = (string) $v; + } + $return .= implode(', ', $elements) . ']>'; + return $return; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/Ducktype.php b/vendor/mockery/mockery/library/Mockery/Matcher/Ducktype.php new file mode 100644 index 000000000..291f42208 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/Ducktype.php @@ -0,0 +1,53 @@ +_expected as $method) { + if (!method_exists($actual, $method)) { + return false; + } + } + return true; + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return '_expected) . ']>'; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/HasKey.php b/vendor/mockery/mockery/library/Mockery/Matcher/HasKey.php new file mode 100644 index 000000000..fa983eaf7 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/HasKey.php @@ -0,0 +1,45 @@ +_expected, $actual); + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return "_expected]>"; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/HasValue.php b/vendor/mockery/mockery/library/Mockery/Matcher/HasValue.php new file mode 100644 index 000000000..8ca6afd13 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/HasValue.php @@ -0,0 +1,46 @@ +_expected, $actual); + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + $return = '_expected . ']>'; + return $return; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/MatcherAbstract.php b/vendor/mockery/mockery/library/Mockery/Matcher/MatcherAbstract.php new file mode 100644 index 000000000..3233079ec --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/MatcherAbstract.php @@ -0,0 +1,58 @@ +_expected = $expected; + } + + /** + * Check if the actual value matches the expected. + * Actual passed by reference to preserve reference trail (where applicable) + * back to the original method parameter. + * + * @param mixed $actual + * @return bool + */ + abstract public function match(&$actual); + + /** + * Return a string representation of this Matcher + * + * @return string + */ + abstract public function __toString(); +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/MultiArgumentClosure.php b/vendor/mockery/mockery/library/Mockery/Matcher/MultiArgumentClosure.php new file mode 100644 index 000000000..8f00a8933 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/MultiArgumentClosure.php @@ -0,0 +1,49 @@ +_expected; + return true === call_user_func_array($closure, $actual); + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/MustBe.php b/vendor/mockery/mockery/library/Mockery/Matcher/MustBe.php new file mode 100644 index 000000000..27b5ec562 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/MustBe.php @@ -0,0 +1,52 @@ +_expected === $actual; + } + + return $this->_expected == $actual; + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/NoArgs.php b/vendor/mockery/mockery/library/Mockery/Matcher/NoArgs.php new file mode 100644 index 000000000..5e9e4189e --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/NoArgs.php @@ -0,0 +1,40 @@ +'; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/Not.php b/vendor/mockery/mockery/library/Mockery/Matcher/Not.php new file mode 100644 index 000000000..756ccaa5b --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/Not.php @@ -0,0 +1,46 @@ +_expected; + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/NotAnyOf.php b/vendor/mockery/mockery/library/Mockery/Matcher/NotAnyOf.php new file mode 100644 index 000000000..cd8270157 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/NotAnyOf.php @@ -0,0 +1,51 @@ +_expected as $exp) { + if ($actual === $exp || $actual == $exp) { + return false; + } + } + return true; + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/PHPUnitConstraint.php b/vendor/mockery/mockery/library/Mockery/Matcher/PHPUnitConstraint.php new file mode 100644 index 000000000..a9aaf4c47 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/PHPUnitConstraint.php @@ -0,0 +1,76 @@ +constraint = $constraint; + $this->rethrow = $rethrow; + } + + /** + * @param mixed $actual + * @return bool + */ + public function match(&$actual) + { + try { + $this->constraint->evaluate($actual); + return true; + } catch (\PHPUnit_Framework_AssertionFailedError $e) { + if ($this->rethrow) { + throw $e; + } + return false; + } catch (\PHPUnit\Framework\AssertionFailedError $e) { + if ($this->rethrow) { + throw $e; + } + return false; + } + } + + /** + * + */ + public function __toString() + { + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/Pattern.php b/vendor/mockery/mockery/library/Mockery/Matcher/Pattern.php new file mode 100644 index 000000000..362c366fd --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/Pattern.php @@ -0,0 +1,45 @@ +_expected, (string) $actual) >= 1; + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return ''; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/Subset.php b/vendor/mockery/mockery/library/Mockery/Matcher/Subset.php new file mode 100644 index 000000000..5e706c81f --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/Subset.php @@ -0,0 +1,92 @@ +expected = $expected; + $this->strict = $strict; + } + + /** + * @param array $expected Expected subset of data + * + * @return Subset + */ + public static function strict(array $expected) + { + return new static($expected, true); + } + + /** + * @param array $expected Expected subset of data + * + * @return Subset + */ + public static function loose(array $expected) + { + return new static($expected, false); + } + + /** + * Check if the actual value matches the expected. + * + * @param mixed $actual + * @return bool + */ + public function match(&$actual) + { + if (!is_array($actual)) { + return false; + } + + if ($this->strict) { + return $actual === array_replace_recursive($actual, $this->expected); + } + + return $actual == array_replace_recursive($actual, $this->expected); + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + $return = 'expected as $k=>$v) { + $elements[] = $k . '=' . (string) $v; + } + $return .= implode(', ', $elements) . ']>'; + return $return; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Matcher/Type.php b/vendor/mockery/mockery/library/Mockery/Matcher/Type.php new file mode 100644 index 000000000..dc189ab0a --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Matcher/Type.php @@ -0,0 +1,52 @@ +_expected); + if (function_exists($function)) { + return $function($actual); + } elseif (is_string($this->_expected) + && (class_exists($this->_expected) || interface_exists($this->_expected))) { + return $actual instanceof $this->_expected; + } + return false; + } + + /** + * Return a string representation of this Matcher + * + * @return string + */ + public function __toString() + { + return '<' . ucfirst($this->_expected) . '>'; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/MethodCall.php b/vendor/mockery/mockery/library/Mockery/MethodCall.php new file mode 100644 index 000000000..db68fd81f --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/MethodCall.php @@ -0,0 +1,43 @@ +method = $method; + $this->args = $args; + } + + public function getMethod() + { + return $this->method; + } + + public function getArgs() + { + return $this->args; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Mock.php b/vendor/mockery/mockery/library/Mockery/Mock.php new file mode 100644 index 000000000..cf0aa13d7 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Mock.php @@ -0,0 +1,935 @@ +_mockery_container = $container; + if (!is_null($partialObject)) { + $this->_mockery_partial = $partialObject; + } + + if (!\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed()) { + foreach ($this->mockery_getMethods() as $method) { + if ($method->isPublic() && !$method->isStatic()) { + $this->_mockery_mockableMethods[] = $method->getName(); + } + } + } + } + + /** + * Set expected method calls + * + * @param array ...$methodNames one or many methods that are expected to be called in this mock + * + * @return \Mockery\ExpectationInterface|\Mockery\Expectation|\Mockery\HigherOrderMessage + */ + public function shouldReceive(...$methodNames) + { + if (count($methodNames) === 0) { + return new HigherOrderMessage($this, "shouldReceive"); + } + + foreach ($methodNames as $method) { + if ("" == $method) { + throw new \InvalidArgumentException("Received empty method name"); + } + } + + $self = $this; + $allowMockingProtectedMethods = $this->_mockery_allowMockingProtectedMethods; + + $lastExpectation = \Mockery::parseShouldReturnArgs( + $this, $methodNames, function ($method) use ($self, $allowMockingProtectedMethods) { + $rm = $self->mockery_getMethod($method); + if ($rm) { + if ($rm->isPrivate()) { + throw new \InvalidArgumentException("$method() cannot be mocked as it is a private method"); + } + if (!$allowMockingProtectedMethods && $rm->isProtected()) { + throw new \InvalidArgumentException("$method() cannot be mocked as it is a protected method and mocking protected methods is not enabled for the currently used mock object. Use shouldAllowMockingProtectedMethods() to enable mocking of protected methods."); + } + } + + $director = $self->mockery_getExpectationsFor($method); + if (!$director) { + $director = new \Mockery\ExpectationDirector($method, $self); + $self->mockery_setExpectationsFor($method, $director); + } + $expectation = new \Mockery\Expectation($self, $method); + $director->addExpectation($expectation); + return $expectation; + } + ); + return $lastExpectation; + } + + /** + * @param mixed $something String method name or map of method => return + * @return self|\Mockery\ExpectationInterface|\Mockery\Expectation|\Mockery\HigherOrderMessage + */ + public function allows($something = []) + { + if (is_string($something)) { + return $this->shouldReceive($something); + } + + if (empty($something)) { + return $this->shouldReceive(); + } + + foreach ($something as $method => $returnValue) { + $this->shouldReceive($method)->andReturn($returnValue); + } + + return $this; + } + + /** + * @param mixed $something String method name (optional) + * @return \Mockery\ExpectationInterface|\Mockery\Expectation|ExpectsHigherOrderMessage + */ + public function expects($something = null) + { + if (is_string($something)) { + return $this->shouldReceive($something)->once(); + } + + return new ExpectsHigherOrderMessage($this); + } + + /** + * Shortcut method for setting an expectation that a method should not be called. + * + * @param array ...$methodNames one or many methods that are expected not to be called in this mock + * @return \Mockery\ExpectationInterface|\Mockery\Expectation|\Mockery\HigherOrderMessage + */ + public function shouldNotReceive(...$methodNames) + { + if (count($methodNames) === 0) { + return new HigherOrderMessage($this, "shouldNotReceive"); + } + + $expectation = call_user_func_array(array($this, 'shouldReceive'), $methodNames); + $expectation->never(); + return $expectation; + } + + /** + * Allows additional methods to be mocked that do not explicitly exist on mocked class + * @param String $method name of the method to be mocked + * @return Mock + */ + public function shouldAllowMockingMethod($method) + { + $this->_mockery_mockableMethods[] = $method; + return $this; + } + + /** + * Set mock to ignore unexpected methods and return Undefined class + * @param mixed $returnValue the default return value for calls to missing functions on this mock + * @return Mock + */ + public function shouldIgnoreMissing($returnValue = null) + { + $this->_mockery_ignoreMissing = true; + $this->_mockery_defaultReturnValue = $returnValue; + return $this; + } + + public function asUndefined() + { + $this->_mockery_ignoreMissing = true; + $this->_mockery_defaultReturnValue = new \Mockery\Undefined; + return $this; + } + + /** + * @return Mock + */ + public function shouldAllowMockingProtectedMethods() + { + $this->_mockery_allowMockingProtectedMethods = true; + return $this; + } + + + /** + * Set mock to defer unexpected methods to it's parent + * + * This is particularly useless for this class, as it doesn't have a parent, + * but included for completeness + * + * @deprecated 2.0.0 Please use makePartial() instead + * + * @return Mock + */ + public function shouldDeferMissing() + { + return $this->makePartial(); + } + + /** + * Set mock to defer unexpected methods to it's parent + * + * It was an alias for shouldDeferMissing(), which will be removed + * in 2.0.0. + * + * @return Mock + */ + public function makePartial() + { + $this->_mockery_deferMissing = true; + return $this; + } + + /** + * In the event shouldReceive() accepting one or more methods/returns, + * this method will switch them from normal expectations to default + * expectations + * + * @return self + */ + public function byDefault() + { + foreach ($this->_mockery_expectations as $director) { + $exps = $director->getExpectations(); + foreach ($exps as $exp) { + $exp->byDefault(); + } + } + return $this; + } + + /** + * Capture calls to this mock + */ + public function __call($method, array $args) + { + return $this->_mockery_handleMethodCall($method, $args); + } + + public static function __callStatic($method, array $args) + { + return self::_mockery_handleStaticMethodCall($method, $args); + } + + /** + * Forward calls to this magic method to the __call method + */ + public function __toString() + { + return $this->__call('__toString', array()); + } + + /** + * Iterate across all expectation directors and validate each + * + * @throws \Mockery\CountValidator\Exception + * @return void + */ + public function mockery_verify() + { + if ($this->_mockery_verified) { + return; + } + if (isset($this->_mockery_ignoreVerification) + && $this->_mockery_ignoreVerification == true) { + return; + } + $this->_mockery_verified = true; + foreach ($this->_mockery_expectations as $director) { + $director->verify(); + } + } + + /** + * Gets a list of exceptions thrown by this mock + * + * @return array + */ + public function mockery_thrownExceptions() + { + return $this->_mockery_thrownExceptions; + } + + /** + * Tear down tasks for this mock + * + * @return void + */ + public function mockery_teardown() + { + } + + /** + * Fetch the next available allocation order number + * + * @return int + */ + public function mockery_allocateOrder() + { + $this->_mockery_allocatedOrder += 1; + return $this->_mockery_allocatedOrder; + } + + /** + * Set ordering for a group + * + * @param mixed $group + * @param int $order + */ + public function mockery_setGroup($group, $order) + { + $this->_mockery_groups[$group] = $order; + } + + /** + * Fetch array of ordered groups + * + * @return array + */ + public function mockery_getGroups() + { + return $this->_mockery_groups; + } + + /** + * Set current ordered number + * + * @param int $order + */ + public function mockery_setCurrentOrder($order) + { + $this->_mockery_currentOrder = $order; + return $this->_mockery_currentOrder; + } + + /** + * Get current ordered number + * + * @return int + */ + public function mockery_getCurrentOrder() + { + return $this->_mockery_currentOrder; + } + + /** + * Validate the current mock's ordering + * + * @param string $method + * @param int $order + * @throws \Mockery\Exception + * @return void + */ + public function mockery_validateOrder($method, $order) + { + if ($order < $this->_mockery_currentOrder) { + $exception = new \Mockery\Exception\InvalidOrderException( + 'Method ' . __CLASS__ . '::' . $method . '()' + . ' called out of order: expected order ' + . $order . ', was ' . $this->_mockery_currentOrder + ); + $exception->setMock($this) + ->setMethodName($method) + ->setExpectedOrder($order) + ->setActualOrder($this->_mockery_currentOrder); + throw $exception; + } + $this->mockery_setCurrentOrder($order); + } + + /** + * Gets the count of expectations for this mock + * + * @return int + */ + public function mockery_getExpectationCount() + { + $count = $this->_mockery_expectations_count; + foreach ($this->_mockery_expectations as $director) { + $count += $director->getExpectationCount(); + } + return $count; + } + + /** + * Return the expectations director for the given method + * + * @var string $method + * @return \Mockery\ExpectationDirector|null + */ + public function mockery_setExpectationsFor($method, \Mockery\ExpectationDirector $director) + { + $this->_mockery_expectations[$method] = $director; + } + + /** + * Return the expectations director for the given method + * + * @var string $method + * @return \Mockery\ExpectationDirector|null + */ + public function mockery_getExpectationsFor($method) + { + if (isset($this->_mockery_expectations[$method])) { + return $this->_mockery_expectations[$method]; + } + } + + /** + * Find an expectation matching the given method and arguments + * + * @var string $method + * @var array $args + * @return \Mockery\Expectation|null + */ + public function mockery_findExpectation($method, array $args) + { + if (!isset($this->_mockery_expectations[$method])) { + return null; + } + $director = $this->_mockery_expectations[$method]; + + return $director->findExpectation($args); + } + + /** + * Return the container for this mock + * + * @return \Mockery\Container + */ + public function mockery_getContainer() + { + return $this->_mockery_container; + } + + /** + * Return the name for this mock + * + * @return string + */ + public function mockery_getName() + { + return __CLASS__; + } + + /** + * @return array + */ + public function mockery_getMockableProperties() + { + return $this->_mockery_mockableProperties; + } + + public function __isset($name) + { + if (false === stripos($name, '_mockery_') && method_exists(get_parent_class($this), '__isset')) { + return parent::__isset($name); + } + + return false; + } + + public function mockery_getExpectations() + { + return $this->_mockery_expectations; + } + + /** + * Calls a parent class method and returns the result. Used in a passthru + * expectation where a real return value is required while still taking + * advantage of expectation matching and call count verification. + * + * @param string $name + * @param array $args + * @return mixed + */ + public function mockery_callSubjectMethod($name, array $args) + { + return call_user_func_array('parent::' . $name, $args); + } + + /** + * @return string[] + */ + public function mockery_getMockableMethods() + { + return $this->_mockery_mockableMethods; + } + + /** + * @return bool + */ + public function mockery_isAnonymous() + { + $rfc = new \ReflectionClass($this); + + // HHVM has a Stringish interface + $interfaces = array_filter($rfc->getInterfaces(), function ($i) { + return $i->getName() !== "Stringish"; + }); + $onlyImplementsMock = 1 == count($interfaces); + + return (false === $rfc->getParentClass()) && $onlyImplementsMock; + } + + public function __wakeup() + { + /** + * This does not add __wakeup method support. It's a blind method and any + * expected __wakeup work will NOT be performed. It merely cuts off + * annoying errors where a __wakeup exists but is not essential when + * mocking + */ + } + + public function __destruct() + { + /** + * Overrides real class destructor in case if class was created without original constructor + */ + } + + public function mockery_getMethod($name) + { + foreach ($this->mockery_getMethods() as $method) { + if ($method->getName() == $name) { + return $method; + } + } + + return null; + } + + /** + * @param string $name Method name. + * + * @return mixed Generated return value based on the declared return value of the named method. + */ + public function mockery_returnValueForMethod($name) + { + if (version_compare(PHP_VERSION, '7.0.0-dev') < 0) { + return; + } + + $rm = $this->mockery_getMethod($name); + if (!$rm || !$rm->hasReturnType()) { + return; + } + + $returnType = $rm->getReturnType(); + + // Default return value for methods with nullable type is null + if ($returnType->allowsNull()) { + return null; + } + + $type = (string) $returnType; + switch ($type) { + case '': return; + case 'string': return ''; + case 'int': return 0; + case 'float': return 0.0; + case 'bool': return false; + case 'array': return []; + + case 'callable': + case 'Closure': + return function () { + }; + + case 'Traversable': + case 'Generator': + // Remove eval() when minimum version >=5.5 + $generator = eval('return function () { yield; };'); + return $generator(); + + case 'self': + return \Mockery::mock($rm->getDeclaringClass()->getName()); + + case 'void': + return null; + + case 'object': + if (version_compare(PHP_VERSION, '7.2.0-dev') >= 0) { + return \Mockery::mock(); + } + + default: + return \Mockery::mock($type); + } + } + + public function shouldHaveReceived($method = null, $args = null) + { + if ($method === null) { + return new HigherOrderMessage($this, "shouldHaveReceived"); + } + + $expectation = new \Mockery\VerificationExpectation($this, $method); + if (null !== $args) { + $expectation->withArgs($args); + } + $expectation->atLeast()->once(); + $director = new \Mockery\VerificationDirector($this->_mockery_getReceivedMethodCalls(), $expectation); + $this->_mockery_expectations_count++; + $director->verify(); + return $director; + } + + public function shouldHaveBeenCalled() + { + return $this->shouldHaveReceived("__invoke"); + } + + public function shouldNotHaveReceived($method = null, $args = null) + { + if ($method === null) { + return new HigherOrderMessage($this, "shouldNotHaveReceived"); + } + + $expectation = new \Mockery\VerificationExpectation($this, $method); + if (null !== $args) { + $expectation->withArgs($args); + } + $expectation->never(); + $director = new \Mockery\VerificationDirector($this->_mockery_getReceivedMethodCalls(), $expectation); + $this->_mockery_expectations_count++; + $director->verify(); + return null; + } + + public function shouldNotHaveBeenCalled(array $args = null) + { + return $this->shouldNotHaveReceived("__invoke", $args); + } + + protected static function _mockery_handleStaticMethodCall($method, array $args) + { + $associatedRealObject = \Mockery::fetchMock(__CLASS__); + try { + return $associatedRealObject->__call($method, $args); + } catch (BadMethodCallException $e) { + throw new BadMethodCallException( + 'Static method ' . $associatedRealObject->mockery_getName() . '::' . $method + . '() does not exist on this mock object', + null, + $e + ); + } + } + + protected function _mockery_getReceivedMethodCalls() + { + return $this->_mockery_receivedMethodCalls ?: $this->_mockery_receivedMethodCalls = new \Mockery\ReceivedMethodCalls(); + } + + /** + * Called when an instance Mock was created and its constructor is getting called + * + * @see \Mockery\Generator\StringManipulation\Pass\InstanceMockPass + * @param array $args + */ + protected function _mockery_constructorCalled(array $args) + { + if (!isset($this->_mockery_expectations['__construct']) /* _mockery_handleMethodCall runs the other checks */) { + return; + } + $this->_mockery_handleMethodCall('__construct', $args); + } + + protected function _mockery_findExpectedMethodHandler($method) + { + if (isset($this->_mockery_expectations[$method])) { + return $this->_mockery_expectations[$method]; + } + + $lowerCasedMockeryExpectations = array_change_key_case($this->_mockery_expectations, CASE_LOWER); + $lowerCasedMethod = strtolower($method); + + if (isset($lowerCasedMockeryExpectations[$lowerCasedMethod])) { + return $lowerCasedMockeryExpectations[$lowerCasedMethod]; + } + + return null; + } + + protected function _mockery_handleMethodCall($method, array $args) + { + $this->_mockery_getReceivedMethodCalls()->push(new \Mockery\MethodCall($method, $args)); + + $rm = $this->mockery_getMethod($method); + if ($rm && $rm->isProtected() && !$this->_mockery_allowMockingProtectedMethods) { + if ($rm->isAbstract()) { + return; + } + + try { + $prototype = $rm->getPrototype(); + if ($prototype->isAbstract()) { + return; + } + } catch (\ReflectionException $re) { + // noop - there is no hasPrototype method + } + + return call_user_func_array("parent::$method", $args); + } + + $handler = $this->_mockery_findExpectedMethodHandler($method); + + if ($handler !== null && !$this->_mockery_disableExpectationMatching) { + try { + return $handler->call($args); + } catch (\Mockery\Exception\NoMatchingExpectationException $e) { + if (!$this->_mockery_ignoreMissing && !$this->_mockery_deferMissing) { + throw $e; + } + } + } + + if (!is_null($this->_mockery_partial) && method_exists($this->_mockery_partial, $method)) { + return call_user_func_array(array($this->_mockery_partial, $method), $args); + } elseif ($this->_mockery_deferMissing && is_callable("parent::$method") + && (!$this->hasMethodOverloadingInParentClass() || method_exists(get_parent_class($this), $method))) { + return call_user_func_array("parent::$method", $args); + } elseif ($method == '__toString') { + // __toString is special because we force its addition to the class API regardless of the + // original implementation. Thus, we should always return a string rather than honor + // _mockery_ignoreMissing and break the API with an error. + return sprintf("%s#%s", __CLASS__, spl_object_hash($this)); + } elseif ($this->_mockery_ignoreMissing) { + if (\Mockery::getConfiguration()->mockingNonExistentMethodsAllowed() || (method_exists($this->_mockery_partial, $method) || is_callable("parent::$method"))) { + if ($this->_mockery_defaultReturnValue instanceof \Mockery\Undefined) { + return call_user_func_array(array($this->_mockery_defaultReturnValue, $method), $args); + } elseif (null === $this->_mockery_defaultReturnValue) { + return $this->mockery_returnValueForMethod($method); + } + + return $this->_mockery_defaultReturnValue; + } + } + + $message = 'Method ' . __CLASS__ . '::' . $method . + '() does not exist on this mock object'; + + if (!is_null($rm)) { + $message = 'Received ' . __CLASS__ . + '::' . $method . '(), but no expectations were specified'; + } + + $bmce = new BadMethodCallException($message); + $this->_mockery_thrownExceptions[] = $bmce; + throw $bmce; + } + + /** + * Uses reflection to get the list of all + * methods within the current mock object + * + * @return array + */ + protected function mockery_getMethods() + { + if (static::$_mockery_methods && \Mockery::getConfiguration()->reflectionCacheEnabled()) { + return static::$_mockery_methods; + } + + if (isset($this->_mockery_partial)) { + $reflected = new \ReflectionObject($this->_mockery_partial); + } else { + $reflected = new \ReflectionClass($this); + } + + return static::$_mockery_methods = $reflected->getMethods(); + } + + private function hasMethodOverloadingInParentClass() + { + // if there's __call any name would be callable + return is_callable('parent::aFunctionNameThatNoOneWouldEverUseInRealLife12345'); + } + + /** + * @return array + */ + private function getNonPublicMethods() + { + return array_map( + function ($method) { + return $method->getName(); + }, + array_filter($this->mockery_getMethods(), function ($method) { + return !$method->isPublic(); + }) + ); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/MockInterface.php b/vendor/mockery/mockery/library/Mockery/MockInterface.php new file mode 100644 index 000000000..e7a2685eb --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/MockInterface.php @@ -0,0 +1,252 @@ + return + * @return self|\Mockery\ExpectationInterface|\Mockery\Expectation|\Mockery\HigherOrderMessage + */ + public function allows($something = []); + + /** + * @param mixed $something String method name (optional) + * @return \Mockery\ExpectationInterface|\Mockery\Expectation|\Mockery\ExpectsHigherOrderMessage + */ + public function expects($something = null); + + /** + * Alternative setup method to constructor + * + * @param \Mockery\Container $container + * @param object $partialObject + * @return void + */ + public function mockery_init(\Mockery\Container $container = null, $partialObject = null); + + /** + * Set expected method calls + * + * @param array ...$methodNames one or many methods that are expected to be called in this mock + * + * @return \Mockery\ExpectationInterface|\Mockery\Expectation|\Mockery\HigherOrderMessage + */ + public function shouldReceive(...$methodNames); + + /** + * Shortcut method for setting an expectation that a method should not be called. + * + * @param array ...$methodNames one or many methods that are expected not to be called in this mock + * @return \Mockery\ExpectationInterface|\Mockery\Expectation|\Mockery\HigherOrderMessage + */ + public function shouldNotReceive(...$methodNames); + + /** + * Allows additional methods to be mocked that do not explicitly exist on mocked class + * @param String $method name of the method to be mocked + */ + public function shouldAllowMockingMethod($method); + + /** + * Set mock to ignore unexpected methods and return Undefined class + * @param mixed $returnValue the default return value for calls to missing functions on this mock + * @return Mock + */ + public function shouldIgnoreMissing($returnValue = null); + + /** + * @return Mock + */ + public function shouldAllowMockingProtectedMethods(); + + /** + * Set mock to defer unexpected methods to its parent if possible + * + * @deprecated 2.0.0 Please use makePartial() instead + * + * @return Mock + */ + public function shouldDeferMissing(); + + /** + * Set mock to defer unexpected methods to its parent if possible + * + * @return Mock + */ + public function makePartial(); + + /** + * @param null|string $method + * @param null $args + * @return mixed + */ + public function shouldHaveReceived($method, $args = null); + + /** + * @return mixed + */ + public function shouldHaveBeenCalled(); + + /** + * @param null|string $method + * @param null $args + * @return mixed + */ + public function shouldNotHaveReceived($method, $args = null); + + /** + * @param array $args (optional) + * @return mixed + */ + public function shouldNotHaveBeenCalled(array $args = null); + + /** + * In the event shouldReceive() accepting an array of methods/returns + * this method will switch them from normal expectations to default + * expectations + * + * @return self + */ + public function byDefault(); + + /** + * Iterate across all expectation directors and validate each + * + * @throws \Mockery\CountValidator\Exception + * @return void + */ + public function mockery_verify(); + + /** + * Tear down tasks for this mock + * + * @return void + */ + public function mockery_teardown(); + + /** + * Fetch the next available allocation order number + * + * @return int + */ + public function mockery_allocateOrder(); + + /** + * Set ordering for a group + * + * @param mixed $group + * @param int $order + */ + public function mockery_setGroup($group, $order); + + /** + * Fetch array of ordered groups + * + * @return array + */ + public function mockery_getGroups(); + + /** + * Set current ordered number + * + * @param int $order + */ + public function mockery_setCurrentOrder($order); + + /** + * Get current ordered number + * + * @return int + */ + public function mockery_getCurrentOrder(); + + /** + * Validate the current mock's ordering + * + * @param string $method + * @param int $order + * @throws \Mockery\Exception + * @return void + */ + public function mockery_validateOrder($method, $order); + + /** + * Gets the count of expectations for this mock + * + * @return int + */ + public function mockery_getExpectationCount(); + + /** + * Return the expectations director for the given method + * + * @var string $method + * @return \Mockery\ExpectationDirector|null + */ + public function mockery_setExpectationsFor($method, \Mockery\ExpectationDirector $director); + + /** + * Return the expectations director for the given method + * + * @var string $method + * @return \Mockery\ExpectationDirector|null + */ + public function mockery_getExpectationsFor($method); + + /** + * Find an expectation matching the given method and arguments + * + * @var string $method + * @var array $args + * @return \Mockery\Expectation|null + */ + public function mockery_findExpectation($method, array $args); + + /** + * Return the container for this mock + * + * @return \Mockery\Container + */ + public function mockery_getContainer(); + + /** + * Return the name for this mock + * + * @return string + */ + public function mockery_getName(); + + /** + * @return array + */ + public function mockery_getMockableProperties(); + + /** + * @return string[] + */ + public function mockery_getMockableMethods(); + + /** + * @return bool + */ + public function mockery_isAnonymous(); +} diff --git a/vendor/mockery/mockery/library/Mockery/ReceivedMethodCalls.php b/vendor/mockery/mockery/library/Mockery/ReceivedMethodCalls.php new file mode 100644 index 000000000..da771c05a --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/ReceivedMethodCalls.php @@ -0,0 +1,48 @@ +methodCalls[] = $methodCall; + } + + public function verify(Expectation $expectation) + { + foreach ($this->methodCalls as $methodCall) { + if ($methodCall->getMethod() !== $expectation->getName()) { + continue; + } + + if (!$expectation->matchArgs($methodCall->getArgs())) { + continue; + } + + $expectation->verifyCall($methodCall->getArgs()); + } + + $expectation->verify(); + } +} diff --git a/vendor/mockery/mockery/library/Mockery/Undefined.php b/vendor/mockery/mockery/library/Mockery/Undefined.php new file mode 100644 index 000000000..53b05e9c5 --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/Undefined.php @@ -0,0 +1,46 @@ +receivedMethodCalls = $receivedMethodCalls; + $this->expectation = $expectation; + } + + public function verify() + { + return $this->receivedMethodCalls->verify($this->expectation); + } + + public function with(...$args) + { + return $this->cloneApplyAndVerify("with", $args); + } + + public function withArgs($args) + { + return $this->cloneApplyAndVerify("withArgs", array($args)); + } + + public function withNoArgs() + { + return $this->cloneApplyAndVerify("withNoArgs", array()); + } + + public function withAnyArgs() + { + return $this->cloneApplyAndVerify("withAnyArgs", array()); + } + + public function times($limit = null) + { + return $this->cloneWithoutCountValidatorsApplyAndVerify("times", array($limit)); + } + + public function once() + { + return $this->cloneWithoutCountValidatorsApplyAndVerify("once", array()); + } + + public function twice() + { + return $this->cloneWithoutCountValidatorsApplyAndVerify("twice", array()); + } + + public function atLeast() + { + return $this->cloneWithoutCountValidatorsApplyAndVerify("atLeast", array()); + } + + public function atMost() + { + return $this->cloneWithoutCountValidatorsApplyAndVerify("atMost", array()); + } + + public function between($minimum, $maximum) + { + return $this->cloneWithoutCountValidatorsApplyAndVerify("between", array($minimum, $maximum)); + } + + protected function cloneWithoutCountValidatorsApplyAndVerify($method, $args) + { + $expectation = clone $this->expectation; + $expectation->clearCountValidators(); + call_user_func_array(array($expectation, $method), $args); + $director = new VerificationDirector($this->receivedMethodCalls, $expectation); + $director->verify(); + return $director; + } + + protected function cloneApplyAndVerify($method, $args) + { + $expectation = clone $this->expectation; + call_user_func_array(array($expectation, $method), $args); + $director = new VerificationDirector($this->receivedMethodCalls, $expectation); + $director->verify(); + return $director; + } +} diff --git a/vendor/mockery/mockery/library/Mockery/VerificationExpectation.php b/vendor/mockery/mockery/library/Mockery/VerificationExpectation.php new file mode 100644 index 000000000..3844a090a --- /dev/null +++ b/vendor/mockery/mockery/library/Mockery/VerificationExpectation.php @@ -0,0 +1,35 @@ +_countValidators = array(); + } + + public function __clone() + { + parent::__clone(); + $this->_actualCount = 0; + } +} diff --git a/vendor/mockery/mockery/library/helpers.php b/vendor/mockery/mockery/library/helpers.php new file mode 100644 index 000000000..72b7240ed --- /dev/null +++ b/vendor/mockery/mockery/library/helpers.php @@ -0,0 +1,66 @@ + + + + + ./tests + ./tests/PHP70 + ./tests/PHP72 + + ./tests/PHP56 + ./tests/Mockery/MockingVariadicArgumentsTest.php + + + + ./tests + ./tests/PHP56 + + ./tests/PHP70 + ./tests/PHP72 + ./tests/Mockery/MockingVariadicArgumentsTest.php + + + + + + ./library/ + + ./library/Mockery/Adapter/Phpunit/Legacy + ./library/Mockery/Adapter/Phpunit/TestListener.php + + + + + diff --git a/vendor/mockery/mockery/tests/Bootstrap.php b/vendor/mockery/mockery/tests/Bootstrap.php new file mode 100644 index 000000000..5da2f6724 --- /dev/null +++ b/vendor/mockery/mockery/tests/Bootstrap.php @@ -0,0 +1,66 @@ +checkMockeryExceptions(); + } + + public function markAsRisky() + { + } +}; + +class MockeryPHPUnitIntegrationTest extends MockeryTestCase +{ + /** + * @test + * @requires PHPUnit 5.7.6 + */ + public function it_marks_a_passing_test_as_risky_if_we_threw_exceptions() + { + $mock = mock(); + try { + $mock->foobar(); + } catch (\Exception $e) { + // exception swallowed... + } + + $test = spy(BaseClassStub::class)->makePartial(); + $test->finish(); + + $test->shouldHaveReceived()->markAsRisky(); + } + + /** + * @test + * @requires PHPUnit 5.7.6 + */ + public function the_user_can_manually_dismiss_an_exception_to_avoid_the_risky_test() + { + $mock = mock(); + try { + $mock->foobar(); + } catch (BadMethodCallException $e) { + $e->dismiss(); + } + + $test = spy(BaseClassStub::class)->makePartial(); + $test->finish(); + + $test->shouldNotHaveReceived()->markAsRisky(); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Adapter/Phpunit/TestListenerTest.php b/vendor/mockery/mockery/tests/Mockery/Adapter/Phpunit/TestListenerTest.php new file mode 100644 index 000000000..9a73c81df --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Adapter/Phpunit/TestListenerTest.php @@ -0,0 +1,103 @@ +markTestSkipped('The TestListener is only supported with PHPUnit 6+.'); + return; + } + // We intentionally test the static container here. That is what the + // listener will check. + $this->container = \Mockery::getContainer(); + $this->listener = new TestListener(); + $this->testResult = new TestResult(); + $this->test = new EmptyTestCase(); + + $this->test->setTestResultObject($this->testResult); + $this->testResult->addListener($this->listener); + + $this->assertTrue($this->testResult->wasSuccessful(), 'sanity check: empty test results should be considered successful'); + } + + public function testSuccessOnClose() + { + $mock = $this->container->mock(); + $mock->shouldReceive('bar')->once(); + $mock->bar(); + + // This is what MockeryPHPUnitIntegration and MockeryTestCase trait + // will do. We intentionally call the static close method. + $this->test->addToAssertionCount($this->container->mockery_getExpectationCount()); + \Mockery::close(); + + $this->listener->endTest($this->test, 0); + $this->assertTrue($this->testResult->wasSuccessful(), 'expected test result to indicate success'); + } + + public function testFailureOnMissingClose() + { + $mock = $this->container->mock(); + $mock->shouldReceive('bar')->once(); + + $this->listener->endTest($this->test, 0); + $this->assertFalse($this->testResult->wasSuccessful(), 'expected test result to indicate failure'); + + // Satisfy the expectation and close the global container now so we + // don't taint the environment. + $mock->bar(); + \Mockery::close(); + } + + public function testMockeryIsAddedToBlacklist() + { + $suite = \Mockery::mock(\PHPUnit\Framework\TestSuite::class); + + $this->assertArrayNotHasKey(\Mockery::class, \PHPUnit\Util\Blacklist::$blacklistedClassNames); + $this->listener->startTestSuite($suite); + $this->assertSame(1, \PHPUnit\Util\Blacklist::$blacklistedClassNames[\Mockery::class]); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/AdhocTest.php b/vendor/mockery/mockery/tests/Mockery/AdhocTest.php new file mode 100644 index 000000000..b930c0a46 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/AdhocTest.php @@ -0,0 +1,119 @@ +container = new \Mockery\Container(\Mockery::getDefaultGenerator(), \Mockery::getDefaultLoader()); + } + + public function teardown() + { + $this->container->mockery_close(); + } + + public function testSimplestMockCreation() + { + $m = $this->container->mock('MockeryTest_NameOfExistingClass'); + $this->assertInstanceOf(MockeryTest_NameOfExistingClass::class, $m); + } + + public function testMockeryInterfaceForClass() + { + $m = $this->container->mock('SplFileInfo'); + $this->assertInstanceOf(\Mockery\MockInterface::class, $m); + } + + public function testMockeryInterfaceForNonExistingClass() + { + $m = $this->container->mock('ABC_IDontExist'); + $this->assertInstanceOf(\Mockery\MockInterface::class, $m); + } + + public function testMockeryInterfaceForInterface() + { + $m = $this->container->mock('MockeryTest_NameOfInterface'); + $this->assertInstanceOf(\Mockery\MockInterface::class, $m); + } + + public function testMockeryInterfaceForAbstract() + { + $m = $this->container->mock('MockeryTest_NameOfAbstract'); + $this->assertInstanceOf(\Mockery\MockInterface::class, $m); + } + + public function testInvalidCountExceptionThrowsRuntimeExceptionOnIllegalComparativeSymbol() + { + $this->expectException('Mockery\Exception\RuntimeException'); + $e = new \Mockery\Exception\InvalidCountException; + $e->setExpectedCountComparative('X'); + } + + public function testMockeryConstructAndDestructIsNotCalled() + { + MockeryTest_NameOfExistingClassWithDestructor::$isDestructorWasCalled = false; + // We pass no arguments in constructor, so it's not being called. Then destructor shouldn't be called too. + $this->container->mock('MockeryTest_NameOfExistingClassWithDestructor'); + // Clear references to trigger destructor + $this->container->mockery_close(); + $this->assertFalse(MockeryTest_NameOfExistingClassWithDestructor::$isDestructorWasCalled); + } + + public function testMockeryConstructAndDestructIsCalled() + { + MockeryTest_NameOfExistingClassWithDestructor::$isDestructorWasCalled = false; + + $this->container->mock('MockeryTest_NameOfExistingClassWithDestructor', array()); + // Clear references to trigger destructor + $this->container->mockery_close(); + $this->assertTrue(MockeryTest_NameOfExistingClassWithDestructor::$isDestructorWasCalled); + } +} + +class MockeryTest_NameOfExistingClass +{ +} + +interface MockeryTest_NameOfInterface +{ + public function foo(); +} + +abstract class MockeryTest_NameOfAbstract +{ + abstract public function foo(); +} + +class MockeryTest_NameOfExistingClassWithDestructor +{ + public static $isDestructorWasCalled = false; + + public function __destruct() + { + self::$isDestructorWasCalled = true; + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/AllowsExpectsSyntaxTest.php b/vendor/mockery/mockery/tests/Mockery/AllowsExpectsSyntaxTest.php new file mode 100644 index 000000000..d7492f378 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/AllowsExpectsSyntaxTest.php @@ -0,0 +1,111 @@ +allows()->foo(123)->andReturns(456); + + $this->assertEquals(456, $stub->foo(123)); + } + + /** @test */ + public function allowsCanTakeAnArrayOfCalls() + { + $stub = m::mock(); + $stub->allows([ + "foo" => "bar", + "bar" => "baz", + ]); + + $this->assertEquals("bar", $stub->foo()); + $this->assertEquals("baz", $stub->bar()); + } + + /** @test */ + public function allowsCanTakeAString() + { + $stub = m::mock(); + $stub->allows("foo")->andReturns("bar"); + $this->assertEquals("bar", $stub->foo()); + } + + /** @test */ + public function expects_can_optionally_match_on_any_arguments() + { + $mock = m::mock(); + $mock->allows()->foo()->withAnyArgs()->andReturns(123); + + $this->assertEquals(123, $mock->foo(456, 789)); + } + + /** @test */ + public function expects_can_take_a_string() + { + $mock = m::mock(); + $mock->expects("foo")->andReturns(123); + + $this->assertEquals(123, $mock->foo(456, 789)); + } + + /** @test */ + public function expectsSetsUpExpectationOfOneCall() + { + $mock = m::mock(); + $mock->expects()->foo(123); + + $this->expectException("Mockery\Exception\InvalidCountException"); + m::close(); + } + + /** @test */ + public function callVerificationCountCanBeOverridenAfterExpectsThrowsExceptionWhenIncorrectNumberOfCalls() + { + $mock = m::mock(); + $mock->expects()->foo(123)->twice(); + + $mock->foo(123); + $this->expectException("Mockery\Exception\InvalidCountException"); + m::close(); + } + + /** @test */ + public function callVerificationCountCanBeOverridenAfterExpects() + { + $mock = m::mock(); + $mock->expects()->foo(123)->twice(); + + $mock->foo(123); + $mock->foo(123); + + m::close(); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/CallableSpyTest.php b/vendor/mockery/mockery/tests/Mockery/CallableSpyTest.php new file mode 100644 index 000000000..013e5b11b --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/CallableSpyTest.php @@ -0,0 +1,199 @@ +shouldHaveBeenCalled(); + } + + /** @test */ + public function it_throws_if_the_callable_was_not_called_at_all() + { + $spy = spy(function() {}); + + $this->expectException(InvalidCountException::class); + $spy->shouldHaveBeenCalled(); + } + + /** @test */ + public function it_throws_if_there_were_no_arguments_but_we_expected_some() + { + $spy = spy(function() {}); + + $spy(); + + $this->expectException(InvalidCountException::class); + $spy->shouldHaveBeenCalled()->with(123, 546); + } + + /** @test */ + public function it_throws_if_the_arguments_do_not_match() + { + $spy = spy(function() {}); + + $spy(123); + + $this->expectException(InvalidCountException::class); + $spy->shouldHaveBeenCalled()->with(123, 546); + } + + /** @test */ + public function it_verifies_the_closure_was_not_called() + { + $spy = spy(function () {}); + + $spy->shouldNotHaveBeenCalled(); + } + + /** @test */ + public function it_throws_if_it_was_called_when_we_expected_it_to_not_have_been_called() + { + $spy = spy(function () {}); + + $spy(); + + $this->expectException(InvalidCountException::class); + $spy->shouldNotHaveBeenCalled(); + } + + /** @test */ + public function it_verifies_it_was_not_called_with_some_particular_arguments_when_called_with_no_args() + { + $spy = spy(function () {}); + + $spy(); + + $spy->shouldNotHaveBeenCalled([123]); + } + + /** @test */ + public function it_verifies_it_was_not_called_with_some_particular_arguments_when_called_with_different_args() + { + $spy = spy(function () {}); + + $spy(456); + + $spy->shouldNotHaveBeenCalled([123]); + } + + /** @test */ + public function it_throws_if_it_was_called_with_the_args_we_were_not_expecting() + { + $spy = spy(function () {}); + + $spy(123); + + $this->expectException(InvalidCountException::class); + $spy->shouldNotHaveBeenCalled([123]); + } + + /** @test */ + public function it_can_verify_it_was_called_a_number_of_times() + { + $spy = spy(function () {}); + + $spy(); + $spy(); + + $spy->shouldHaveBeenCalled()->twice(); + } + + /** @test */ + public function it_can_verify_it_was_called_a_number_of_times_with_particular_arguments() + { + $spy = spy(function () {}); + + $spy(123); + $spy(123); + + $spy->shouldHaveBeenCalled()->with(123)->twice(); + } + + /** @test */ + public function it_throws_if_it_was_called_less_than_the_number_of_times_we_expected() + { + $spy = spy(function () {}); + + $spy(); + + $this->expectException(InvalidCountException::class); + $spy->shouldHaveBeenCalled()->twice(); + } + + /** @test */ + public function it_throws_if_it_was_called_less_than_the_number_of_times_we_expected_with_particular_arguments() + { + $spy = spy(function () {}); + + $spy(); + $spy(123); + + $this->expectException(InvalidCountException::class); + $spy->shouldHaveBeenCalled()->with(123)->twice(); + } + + /** @test */ + public function it_throws_if_it_was_called_more_than_the_number_of_times_we_expected() + { + $spy = spy(function () {}); + + $spy(); + $spy(); + $spy(); + + $this->expectException(InvalidCountException::class); + $spy->shouldHaveBeenCalled()->twice(); + } + + /** @test */ + public function it_throws_if_it_was_called_more_than_the_number_of_times_we_expected_with_particular_arguments() + { + $spy = spy(function () {}); + + $spy(123); + $spy(123); + $spy(123); + + $this->expectException(InvalidCountException::class); + $spy->shouldHaveBeenCalled()->with(123)->twice(); + } + + /** @test */ + public function it_acts_as_partial() + { + $spy = spy(function ($number) { return $number + 1;}); + + $this->assertEquals(124, $spy(123)); + $spy->shouldHaveBeenCalled(); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/ContainerTest.php b/vendor/mockery/mockery/tests/Mockery/ContainerTest.php new file mode 100644 index 000000000..446d9e3f2 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/ContainerTest.php @@ -0,0 +1,1825 @@ +shouldReceive('foo')->andReturn('bar'); + $this->assertEquals('bar', $m->foo()); + } + + public function testGetKeyOfDemeterMockShouldReturnKeyWhenMatchingMock() + { + $m = mock(); + $m->shouldReceive('foo->bar'); + $this->assertRegExp( + '/Mockery_(\d+)__demeter_([0-9a-f]+)_foo/', + Mockery::getContainer()->getKeyOfDemeterMockFor('foo', get_class($m)) + ); + } + public function testGetKeyOfDemeterMockShouldReturnNullWhenNoMatchingMock() + { + $method = 'unknownMethod'; + $this->assertNull(Mockery::getContainer()->getKeyOfDemeterMockFor($method, 'any')); + + $m = mock(); + $m->shouldReceive('method'); + $this->assertNull(Mockery::getContainer()->getKeyOfDemeterMockFor($method, get_class($m))); + + $m->shouldReceive('foo->bar'); + $this->assertNull(Mockery::getContainer()->getKeyOfDemeterMockFor($method, get_class($m))); + } + + + public function testNamedMocksAddNameToExceptions() + { + $m = mock('Foo'); + $m->shouldReceive('foo')->with(1)->andReturn('bar'); + try { + $m->foo(); + } catch (\Mockery\Exception $e) { + $this->assertTrue((bool) preg_match("/Foo/", $e->getMessage())); + } + } + + public function testSimpleMockWithArrayDefs() + { + $m = mock(array('foo'=>1, 'bar'=>2)); + $this->assertEquals(1, $m->foo()); + $this->assertEquals(2, $m->bar()); + } + + public function testSimpleMockWithArrayDefsCanBeOverridden() + { + // eg. In shared test setup + $m = mock(array('foo' => 1, 'bar' => 2)); + + // and then overridden in one test + $m->shouldReceive('foo')->with('baz')->once()->andReturn(2); + $m->shouldReceive('bar')->with('baz')->once()->andReturn(42); + + $this->assertEquals(2, $m->foo('baz')); + $this->assertEquals(42, $m->bar('baz')); + } + + public function testNamedMockWithArrayDefs() + { + $m = mock('Foo', array('foo'=>1, 'bar'=>2)); + $this->assertEquals(1, $m->foo()); + $this->assertEquals(2, $m->bar()); + try { + $m->f(); + } catch (BadMethodCallException $e) { + $this->assertTrue((bool) preg_match("/Foo/", $e->getMessage())); + } + } + + public function testNamedMockWithArrayDefsCanBeOverridden() + { + // eg. In shared test setup + $m = mock('Foo', array('foo' => 1)); + + // and then overridden in one test + $m->shouldReceive('foo')->with('bar')->once()->andReturn(2); + + $this->assertEquals(2, $m->foo('bar')); + + try { + $m->f(); + } catch (BadMethodCallException $e) { + $this->assertTrue((bool) preg_match("/Foo/", $e->getMessage())); + } + } + + public function testNamedMockMultipleInterfaces() + { + $m = mock('stdClass, ArrayAccess, Countable', array('foo'=>1, 'bar'=>2)); + $this->assertEquals(1, $m->foo()); + $this->assertEquals(2, $m->bar()); + try { + $m->f(); + } catch (BadMethodCallException $e) { + $this->assertTrue((bool) preg_match("/stdClass/", $e->getMessage())); + $this->assertTrue((bool) preg_match("/ArrayAccess/", $e->getMessage())); + $this->assertTrue((bool) preg_match("/Countable/", $e->getMessage())); + } + } + + public function testNamedMockWithConstructorArgs() + { + $m = mock("MockeryTest_ClassConstructor2[foo]", array($param1 = new stdClass())); + $m->shouldReceive("foo")->andReturn(123); + $this->assertEquals(123, $m->foo()); + $this->assertEquals($param1, $m->getParam1()); + } + + public function testNamedMockWithConstructorArgsAndArrayDefs() + { + $m = mock( + "MockeryTest_ClassConstructor2[foo]", + array($param1 = new stdClass()), + array("foo" => 123) + ); + $this->assertEquals(123, $m->foo()); + $this->assertEquals($param1, $m->getParam1()); + } + + public function testNamedMockWithConstructorArgsWithInternalCallToMockedMethod() + { + $m = mock("MockeryTest_ClassConstructor2[foo]", array($param1 = new stdClass())); + $m->shouldReceive("foo")->andReturn(123); + $this->assertEquals(123, $m->bar()); + } + + public function testNamedMockWithConstructorArgsButNoQuickDefsShouldLeaveConstructorIntact() + { + $m = mock("MockeryTest_ClassConstructor2", array($param1 = new stdClass())); + $m->makePartial(); + $this->assertEquals($param1, $m->getParam1()); + } + + public function testNamedMockWithMakePartial() + { + $m = mock("MockeryTest_ClassConstructor2", array($param1 = new stdClass())); + $m->makePartial(); + $this->assertEquals('foo', $m->bar()); + $m->shouldReceive("bar")->andReturn(123); + $this->assertEquals(123, $m->bar()); + } + + /** + * @expectedException BadMethodCallException + */ + public function testNamedMockWithMakePartialThrowsIfNotAvailable() + { + $m = mock("MockeryTest_ClassConstructor2", array($param1 = new stdClass())); + $m->makePartial(); + $m->foorbar123(); + $m->mockery_verify(); + } + + public function testMockingAKnownConcreteClassSoMockInheritsClassType() + { + $m = mock('stdClass'); + $m->shouldReceive('foo')->andReturn('bar'); + $this->assertEquals('bar', $m->foo()); + $this->assertInstanceOf(stdClass::class, $m); + } + + public function testMockingAKnownUserClassSoMockInheritsClassType() + { + $m = mock('MockeryTest_TestInheritedType'); + $this->assertInstanceOf(MockeryTest_TestInheritedType::class, $m); + } + + public function testMockingAConcreteObjectCreatesAPartialWithoutError() + { + $m = mock(new stdClass); + $m->shouldReceive('foo')->andReturn('bar'); + $this->assertEquals('bar', $m->foo()); + $this->assertInstanceOf(stdClass::class, $m); + } + + public function testCreatingAPartialAllowsDynamicExpectationsAndPassesThroughUnexpectedMethods() + { + $m = mock(new MockeryTestFoo); + $m->shouldReceive('bar')->andReturn('bar'); + $this->assertEquals('bar', $m->bar()); + $this->assertEquals('foo', $m->foo()); + $this->assertInstanceOf(MockeryTestFoo::class, $m); + } + + public function testCreatingAPartialAllowsExpectationsToInterceptCallsToImplementedMethods() + { + $m = mock(new MockeryTestFoo2); + $m->shouldReceive('bar')->andReturn('baz'); + $this->assertEquals('baz', $m->bar()); + $this->assertEquals('foo', $m->foo()); + $this->assertInstanceOf(MockeryTestFoo2::class, $m); + } + + public function testBlockForwardingToPartialObject() + { + $m = mock(new MockeryTestBar1, array('foo'=>1, Mockery\Container::BLOCKS => array('method1'))); + $this->assertSame($m, $m->method1()); + } + + public function testPartialWithArrayDefs() + { + $m = mock(new MockeryTestBar1, array('foo'=>1, Mockery\Container::BLOCKS => array('method1'))); + $this->assertEquals(1, $m->foo()); + } + + public function testPassingClosureAsFinalParameterUsedToDefineExpectations() + { + $m = mock('foo', function ($m) { + $m->shouldReceive('foo')->once()->andReturn('bar'); + }); + $this->assertEquals('bar', $m->foo()); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testMockingAKnownConcreteFinalClassThrowsErrors_OnlyPartialMocksCanMockFinalElements() + { + $m = mock('MockeryFoo3'); + } + + public function testMockingAKnownConcreteClassWithFinalMethodsThrowsNoException() + { + $this->assertInstanceOf(MockInterface::class, mock('MockeryFoo4')); + } + + /** + * @group finalclass + */ + public function testFinalClassesCanBePartialMocks() + { + $m = mock(new MockeryFoo3); + $m->shouldReceive('foo')->andReturn('baz'); + $this->assertEquals('baz', $m->foo()); + $this->assertNotInstanceOf(MockeryFoo3::class, $m); + } + + public function testSplClassWithFinalMethodsCanBeMocked() + { + $m = mock('SplFileInfo'); + $m->shouldReceive('foo')->andReturn('baz'); + $this->assertEquals('baz', $m->foo()); + $this->assertInstanceOf(SplFileInfo::class, $m); + } + + public function testSplClassWithFinalMethodsCanBeMockedMultipleTimes() + { + mock('SplFileInfo'); + $m = mock('SplFileInfo'); + $m->shouldReceive('foo')->andReturn('baz'); + $this->assertEquals('baz', $m->foo()); + $this->assertInstanceOf(SplFileInfo::class, $m); + } + + public function testClassesWithFinalMethodsCanBeProxyPartialMocks() + { + $m = mock(new MockeryFoo4); + $m->shouldReceive('foo')->andReturn('baz'); + $this->assertEquals('baz', $m->foo()); + $this->assertEquals('bar', $m->bar()); + $this->assertInstanceOf(MockeryFoo4::class, $m); + } + + public function testClassesWithFinalMethodsCanBeProperPartialMocks() + { + $m = mock('MockeryFoo4[bar]'); + $m->shouldReceive('bar')->andReturn('baz'); + $this->assertEquals('baz', $m->foo()); + $this->assertEquals('baz', $m->bar()); + $this->assertInstanceOf(MockeryFoo4::class, $m); + } + + public function testClassesWithFinalMethodsCanBeProperPartialMocksButFinalMethodsNotPartialed() + { + $m = mock('MockeryFoo4[foo]'); + $m->shouldReceive('foo')->andReturn('foo'); + $this->assertEquals('baz', $m->foo()); // partial expectation ignored - will fail callcount assertion + $this->assertInstanceOf(MockeryFoo4::class, $m); + } + + public function testSplfileinfoClassMockPassesUserExpectations() + { + $file = mock('SplFileInfo[getFilename,getPathname,getExtension,getMTime]', array(__FILE__)); + $file->shouldReceive('getFilename')->once()->andReturn('foo'); + $file->shouldReceive('getPathname')->once()->andReturn('path/to/foo'); + $file->shouldReceive('getExtension')->once()->andReturn('css'); + $file->shouldReceive('getMTime')->once()->andReturn(time()); + + // not sure what this test is for, maybe something special about + // SplFileInfo + $this->assertEquals('foo', $file->getFilename()); + $this->assertEquals('path/to/foo', $file->getPathname()); + $this->assertEquals('css', $file->getExtension()); + $this->assertInternalType('int', $file->getMTime()); + } + + public function testCanMockInterface() + { + $m = mock('MockeryTest_Interface'); + $this->assertInstanceOf(MockeryTest_Interface::class, $m); + } + + public function testCanMockSpl() + { + $m = mock('\\SplFixedArray'); + $this->assertInstanceOf(SplFixedArray::class, $m); + } + + public function testCanMockInterfaceWithAbstractMethod() + { + $m = mock('MockeryTest_InterfaceWithAbstractMethod'); + $this->assertInstanceOf(MockeryTest_InterfaceWithAbstractMethod::class, $m); + $m->shouldReceive('foo')->andReturn(1); + $this->assertEquals(1, $m->foo()); + } + + public function testCanMockAbstractWithAbstractProtectedMethod() + { + $m = mock('MockeryTest_AbstractWithAbstractMethod'); + $this->assertInstanceOf(MockeryTest_AbstractWithAbstractMethod::class, $m); + } + + public function testCanMockInterfaceWithPublicStaticMethod() + { + $m = mock('MockeryTest_InterfaceWithPublicStaticMethod'); + $this->assertInstanceOf(MockeryTest_InterfaceWithPublicStaticMethod::class, $m); + } + + public function testCanMockClassWithConstructor() + { + $m = mock('MockeryTest_ClassConstructor'); + $this->assertInstanceOf(MockeryTest_ClassConstructor::class, $m); + } + + public function testCanMockClassWithConstructorNeedingClassArgs() + { + $m = mock('MockeryTest_ClassConstructor2'); + $this->assertInstanceOf(MockeryTest_ClassConstructor2::class, $m); + } + + /** + * @group partial + */ + public function testCanPartiallyMockANormalClass() + { + $m = mock('MockeryTest_PartialNormalClass[foo]'); + $this->assertInstanceOf(MockeryTest_PartialNormalClass::class, $m); + $m->shouldReceive('foo')->andReturn('cba'); + $this->assertEquals('abc', $m->bar()); + $this->assertEquals('cba', $m->foo()); + } + + /** + * @group partial + */ + public function testCanPartiallyMockAnAbstractClass() + { + $m = mock('MockeryTest_PartialAbstractClass[foo]'); + $this->assertInstanceOf(MockeryTest_PartialAbstractClass::class, $m); + $m->shouldReceive('foo')->andReturn('cba'); + $this->assertEquals('abc', $m->bar()); + $this->assertEquals('cba', $m->foo()); + } + + /** + * @group partial + */ + public function testCanPartiallyMockANormalClassWith2Methods() + { + $m = mock('MockeryTest_PartialNormalClass2[foo, baz]'); + $this->assertInstanceOf(MockeryTest_PartialNormalClass2::class, $m); + $m->shouldReceive('foo')->andReturn('cba'); + $m->shouldReceive('baz')->andReturn('cba'); + $this->assertEquals('abc', $m->bar()); + $this->assertEquals('cba', $m->foo()); + $this->assertEquals('cba', $m->baz()); + } + + /** + * @group partial + */ + public function testCanPartiallyMockAnAbstractClassWith2Methods() + { + $m = mock('MockeryTest_PartialAbstractClass2[foo,baz]'); + $this->assertInstanceOf(MockeryTest_PartialAbstractClass2::class, $m); + $m->shouldReceive('foo')->andReturn('cba'); + $m->shouldReceive('baz')->andReturn('cba'); + $this->assertEquals('abc', $m->bar()); + $this->assertEquals('cba', $m->foo()); + $this->assertEquals('cba', $m->baz()); + } + + /** + * @expectedException \Mockery\Exception + * @group partial + */ + public function testThrowsExceptionIfSettingExpectationForNonMockedMethodOfPartialMock() + { + $this->markTestSkipped('For now...'); + $m = mock('MockeryTest_PartialNormalClass[foo]'); + $this->assertInstanceOf(MockeryTest_PartialNormalClass::class, $m); + $m->shouldReceive('bar')->andReturn('cba'); + } + + /** + * @expectedException \Mockery\Exception + * @group partial + */ + public function testThrowsExceptionIfClassOrInterfaceForPartialMockDoesNotExist() + { + $m = mock('MockeryTest_PartialNormalClassXYZ[foo]'); + } + + /** + * @group issue/4 + */ + public function testCanMockClassContainingMagicCallMethod() + { + $m = mock('MockeryTest_Call1'); + $this->assertInstanceOf(MockeryTest_Call1::class, $m); + } + + /** + * @group issue/4 + */ + public function testCanMockClassContainingMagicCallMethodWithoutTypeHinting() + { + $m = mock('MockeryTest_Call2'); + $this->assertInstanceOf(MockeryTest_Call2::class, $m); + } + + /** + * @group issue/14 + */ + public function testCanMockClassContainingAPublicWakeupMethod() + { + $m = mock('MockeryTest_Wakeup1'); + $this->assertInstanceOf(MockeryTest_Wakeup1::class, $m); + } + + /** + * @group issue/18 + */ + public function testCanMockClassUsingMagicCallMethodsInPlaceOfNormalMethods() + { + $m = Mockery::mock('Gateway'); + $m->shouldReceive('iDoSomethingReallyCoolHere'); + $m->iDoSomethingReallyCoolHere(); + } + + /** + * @group issue/18 + */ + public function testCanPartialMockObjectUsingMagicCallMethodsInPlaceOfNormalMethods() + { + $m = Mockery::mock(new Gateway); + $m->shouldReceive('iDoSomethingReallyCoolHere'); + $m->iDoSomethingReallyCoolHere(); + } + + /** + * @group issue/13 + */ + public function testCanMockClassWhereMethodHasReferencedParameter() + { + $this->assertInstanceOf(MockInterface::class, Mockery::mock(new MockeryTest_MethodParamRef)); + } + + /** + * @group issue/13 + */ + public function testCanPartiallyMockObjectWhereMethodHasReferencedParameter() + { + $this->assertInstanceOf(MockInterface::class, Mockery::mock(new MockeryTest_MethodParamRef2)); + } + + /** + * @group issue/11 + */ + public function testMockingAKnownConcreteClassCanBeGrantedAnArbitraryClassType() + { + $m = mock('alias:MyNamespace\MyClass'); + $m->shouldReceive('foo')->andReturn('bar'); + $this->assertEquals('bar', $m->foo()); + $this->assertInstanceOf(MyNamespace\MyClass::class, $m); + } + + /** + * @group issue/15 + */ + public function testCanMockMultipleInterfaces() + { + $m = mock('MockeryTest_Interface1, MockeryTest_Interface2'); + $this->assertInstanceOf(MockeryTest_Interface1::class, $m); + $this->assertInstanceOf(MockeryTest_Interface2::class, $m); + } + + /** + */ + public function testCanMockMultipleInterfacesThatMayNotExist() + { + $m = mock('NonExistingClass, MockeryTest_Interface1, MockeryTest_Interface2, \Some\Thing\That\Doesnt\Exist'); + $this->assertInstanceOf(MockeryTest_Interface1::class, $m); + $this->assertInstanceOf(MockeryTest_Interface2::class, $m); + $this->assertInstanceOf(\Some\Thing\That\Doesnt\Exist::class, $m); + } + + /** + * @group issue/15 + */ + public function testCanMockClassAndApplyMultipleInterfaces() + { + $m = mock('MockeryTestFoo, MockeryTest_Interface1, MockeryTest_Interface2'); + $this->assertInstanceOf(MockeryTestFoo::class, $m); + $this->assertInstanceOf(MockeryTest_Interface1::class, $m); + $this->assertInstanceOf(MockeryTest_Interface2::class, $m); + } + + /** + * @group issue/7 + * + * Noted: We could complicate internally, but a blind class is better built + * with a real class noted up front (stdClass is a perfect choice it is + * behaviourless). Fine, it's a muddle - but we need to draw a line somewhere. + */ + public function testCanMockStaticMethods() + { + $m = mock('alias:MyNamespace\MyClass2'); + $m->shouldReceive('staticFoo')->andReturn('bar'); + $this->assertEquals('bar', \MyNameSpace\MyClass2::staticFoo()); + } + + /** + * @group issue/7 + * @expectedException \Mockery\CountValidator\Exception + */ + public function testMockedStaticMethodsObeyMethodCounting() + { + $m = mock('alias:MyNamespace\MyClass3'); + $m->shouldReceive('staticFoo')->once()->andReturn('bar'); + Mockery::close(); + } + + /** + */ + public function testMockedStaticThrowsExceptionWhenMethodDoesNotExist() + { + $m = mock('alias:MyNamespace\StaticNoMethod'); + try { + MyNameSpace\StaticNoMethod::staticFoo(); + } catch (BadMethodCallException $e) { + // Mockery + PHPUnit has a fail safe for tests swallowing our + // exceptions + $e->dismiss(); + return; + } + + $this->fail('Exception was not thrown'); + } + + /** + * @group issue/17 + */ + public function testMockingAllowsPublicPropertyStubbingOnRealClass() + { + $m = mock('MockeryTestFoo'); + $m->foo = 'bar'; + $this->assertEquals('bar', $m->foo); + //$this->assertArrayHasKey('foo', $m->mockery_getMockableProperties()); + } + + /** + * @group issue/17 + */ + public function testMockingAllowsPublicPropertyStubbingOnNamedMock() + { + $m = mock('Foo'); + $m->foo = 'bar'; + $this->assertEquals('bar', $m->foo); + //$this->assertArrayHasKey('foo', $m->mockery_getMockableProperties()); + } + + /** + * @group issue/17 + */ + public function testMockingAllowsPublicPropertyStubbingOnPartials() + { + $m = mock(new stdClass); + $m->foo = 'bar'; + $this->assertEquals('bar', $m->foo); + //$this->assertArrayHasKey('foo', $m->mockery_getMockableProperties()); + } + + /** + * @group issue/17 + */ + public function testMockingDoesNotStubNonStubbedPropertiesOnPartials() + { + $m = mock(new MockeryTest_ExistingProperty); + $this->assertEquals('bar', $m->foo); + $this->assertArrayNotHasKey('foo', $m->mockery_getMockableProperties()); + } + + public function testCreationOfInstanceMock() + { + $m = mock('overload:MyNamespace\MyClass4'); + $this->assertInstanceOf(MyNamespace\MyClass4::class, $m); + } + + public function testInstantiationOfInstanceMock() + { + $m = mock('overload:MyNamespace\MyClass5'); + $instance = new MyNamespace\MyClass5; + $this->assertInstanceOf(MyNamespace\MyClass5::class, $instance); + } + + public function testInstantiationOfInstanceMockImportsExpectations() + { + $m = mock('overload:MyNamespace\MyClass6'); + $m->shouldReceive('foo')->andReturn('bar'); + $instance = new MyNamespace\MyClass6; + $this->assertEquals('bar', $instance->foo()); + } + + public function testInstantiationOfInstanceMockImportsDefaultExpectations() + { + $m = mock('overload:MyNamespace\MyClass6'); + $m->shouldReceive('foo')->andReturn('bar')->byDefault(); + $instance = new MyNamespace\MyClass6; + + $this->assertEquals('bar', $instance->foo()); + } + + public function testInstantiationOfInstanceMockImportsDefaultExpectationsInTheCorrectOrder() + { + $m = mock('overload:MyNamespace\MyClass6'); + $m->shouldReceive('foo')->andReturn(1)->byDefault(); + $m->shouldReceive('foo')->andReturn(2)->byDefault(); + $m->shouldReceive('foo')->andReturn(3)->byDefault(); + $instance = new MyNamespace\MyClass6; + + $this->assertEquals(3, $instance->foo()); + } + + public function testInstantiationOfInstanceMocksIgnoresVerificationOfOriginMock() + { + $m = mock('overload:MyNamespace\MyClass7'); + $m->shouldReceive('foo')->once()->andReturn('bar'); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testInstantiationOfInstanceMocksAddsThemToContainerForVerification() + { + $m = mock('overload:MyNamespace\MyClass8'); + $m->shouldReceive('foo')->once(); + $instance = new MyNamespace\MyClass8; + Mockery::close(); + } + + public function testInstantiationOfInstanceMocksDoesNotHaveCountValidatorCrossover() + { + $m = mock('overload:MyNamespace\MyClass9'); + $m->shouldReceive('foo')->once(); + $instance1 = new MyNamespace\MyClass9; + $instance2 = new MyNamespace\MyClass9; + $instance1->foo(); + $instance2->foo(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testInstantiationOfInstanceMocksDoesNotHaveCountValidatorCrossover2() + { + $m = mock('overload:MyNamespace\MyClass10'); + $m->shouldReceive('foo')->once(); + $instance1 = new MyNamespace\MyClass10; + $instance2 = new MyNamespace\MyClass10; + $instance1->foo(); + Mockery::close(); + } + + public function testCreationOfInstanceMockWithFullyQualifiedName() + { + $m = mock('overload:\MyNamespace\MyClass11'); + $this->assertInstanceOf(MyNamespace\MyClass11::class, $m); + } + + public function testInstanceMocksShouldIgnoreMissing() + { + $m = mock('overload:MyNamespace\MyClass12'); + $m->shouldIgnoreMissing(); + + $instance = new MyNamespace\MyClass12(); + $this->assertNull($instance->foo()); + } + + /** + * @group issue/451 + */ + public function testSettingPropertyOnInstanceMockWillSetItOnActualInstance() + { + $m = mock('overload:MyNamespace\MyClass13'); + $m->shouldReceive('foo')->andSet('bar', 'baz'); + $instance = new MyNamespace\MyClass13; + $instance->foo(); + $this->assertEquals('baz', $m->bar); + $this->assertEquals('baz', $instance->bar); + } + + public function testInstantiationOfInstanceMockWithConstructorParameterValidation() + { + $m = mock('overload:MyNamespace\MyClass14'); + $params = [ + 'value1' => uniqid('test_') + ]; + $m->shouldReceive('__construct')->with($params); + + new MyNamespace\MyClass14($params); + } + + /** + * @expectedException \Mockery\Exception\NoMatchingExpectationException + */ + public function testInstantiationOfInstanceMockWithConstructorParameterValidationNegative() + { + $m = mock('overload:MyNamespace\MyClass15'); + $params = [ + 'value1' => uniqid('test_') + ]; + $m->shouldReceive('__construct')->with($params); + + new MyNamespace\MyClass15([]); + } + + /** + * @expectedException \Exception + * @expectedExceptionMessageRegExp /^instanceMock \d{3}$/ + */ + public function testInstantiationOfInstanceMockWithConstructorParameterValidationException() + { + $m = mock('overload:MyNamespace\MyClass16'); + $m->shouldReceive('__construct') + ->andThrow(new \Exception('instanceMock '.rand(100, 999))); + + new MyNamespace\MyClass16(); + } + + public function testMethodParamsPassedByReferenceHaveReferencePreserved() + { + $m = mock('MockeryTestRef1'); + $m->shouldReceive('foo')->with( + Mockery::on(function (&$a) { + $a += 1; + return true; + }), + Mockery::any() + ); + $a = 1; + $b = 1; + $m->foo($a, $b); + $this->assertEquals(2, $a); + $this->assertEquals(1, $b); + } + + public function testMethodParamsPassedByReferenceThroughWithArgsHaveReferencePreserved() + { + $m = mock('MockeryTestRef1'); + $m->shouldReceive('foo')->withArgs(function (&$a, $b) { + $a += 1; + $b += 1; + return true; + }); + $a = 1; + $b = 1; + $m->foo($a, $b); + $this->assertEquals(2, $a); + $this->assertEquals(1, $b); + } + + /** + * Meant to test the same logic as + * testCanOverrideExpectedParametersOfExtensionPHPClassesToPreserveRefs, + * but: + * - doesn't require an extension + * - isn't actually known to be used + */ + public function testCanOverrideExpectedParametersOfInternalPHPClassesToPreserveRefs() + { + Mockery::getConfiguration()->setInternalClassMethodParamMap( + 'DateTime', 'modify', array('&$string') + ); + // @ used to avoid E_STRICT for incompatible signature + @$m = mock('DateTime'); + $this->assertInstanceOf("Mockery\MockInterface", $m, "Mocking failed, remove @ error suppresion to debug"); + $m->shouldReceive('modify')->with( + Mockery::on(function (&$string) { + $string = 'foo'; + return true; + }) + ); + $data ='bar'; + $m->modify($data); + $this->assertEquals('foo', $data); + Mockery::getConfiguration()->resetInternalClassMethodParamMaps(); + } + + /** + * Real world version of + * testCanOverrideExpectedParametersOfInternalPHPClassesToPreserveRefs + */ + public function testCanOverrideExpectedParametersOfExtensionPHPClassesToPreserveRefs() + { + if (!class_exists('MongoCollection', false)) { + $this->markTestSkipped('ext/mongo not installed'); + } + Mockery::getConfiguration()->setInternalClassMethodParamMap( + 'MongoCollection', 'insert', array('&$data', '$options') + ); + // @ used to avoid E_STRICT for incompatible signature + @$m = mock('MongoCollection'); + $this->assertInstanceOf("Mockery\MockInterface", $m, "Mocking failed, remove @ error suppresion to debug"); + $m->shouldReceive('insert')->with( + Mockery::on(function (&$data) { + $data['_id'] = 123; + return true; + }), + Mockery::type('array') + ); + $data = array('a'=>1,'b'=>2); + $m->insert($data, array()); + $this->assertArrayHasKey('_id', $data); + $this->assertEquals(123, $data['_id']); + Mockery::getConfiguration()->resetInternalClassMethodParamMaps(); + } + + public function testCanCreateNonOverridenInstanceOfPreviouslyOverridenInternalClasses() + { + Mockery::getConfiguration()->setInternalClassMethodParamMap( + 'DateTime', 'modify', array('&$string') + ); + // @ used to avoid E_STRICT for incompatible signature + @$m = mock('DateTime'); + $this->assertInstanceOf("Mockery\MockInterface", $m, "Mocking failed, remove @ error suppresion to debug"); + $rc = new ReflectionClass($m); + $rm = $rc->getMethod('modify'); + $params = $rm->getParameters(); + $this->assertTrue($params[0]->isPassedByReference()); + + Mockery::getConfiguration()->resetInternalClassMethodParamMaps(); + + $m = mock('DateTime'); + $this->assertInstanceOf("Mockery\MockInterface", $m, "Mocking failed"); + $rc = new ReflectionClass($m); + $rm = $rc->getMethod('modify'); + $params = $rm->getParameters(); + $this->assertFalse($params[0]->isPassedByReference()); + + Mockery::getConfiguration()->resetInternalClassMethodParamMaps(); + } + + /** + * @group abstract + */ + public function testCanMockAbstractClassWithAbstractPublicMethod() + { + $m = mock('MockeryTest_AbstractWithAbstractPublicMethod'); + $this->assertInstanceOf(MockeryTest_AbstractWithAbstractPublicMethod::class, $m); + } + + /** + * @issue issue/21 + */ + public function testClassDeclaringIssetDoesNotThrowException() + { + $this->assertInstanceOf(MockInterface::class, mock('MockeryTest_IssetMethod')); + } + + /** + * @issue issue/21 + */ + public function testClassDeclaringUnsetDoesNotThrowException() + { + $this->assertInstanceOf(MockInterface::class, mock('MockeryTest_UnsetMethod')); + } + + /** + * @issue issue/35 + */ + public function testCallingSelfOnlyReturnsLastMockCreatedOrCurrentMockBeingProgrammedSinceTheyAreOneAndTheSame() + { + $m = mock('MockeryTestFoo'); + $this->assertNotInstanceOf(MockeryTestFoo2::class, Mockery::self()); + //$m = mock('MockeryTestFoo2'); + //$this->assertInstanceOf(MockeryTestFoo2::class, self()); + //$m = mock('MockeryTestFoo'); + //$this->assertNotInstanceOf(MockeryTestFoo2::class, Mockery::self()); + //$this->assertInstanceOf(MockeryTestFoo::class, Mockery::self()); + } + + /** + * @issue issue/89 + */ + public function testCreatingMockOfClassWithExistingToStringMethodDoesntCreateClassWithTwoToStringMethods() + { + $m = mock('MockeryTest_WithToString'); // this would fatal + $m->shouldReceive("__toString")->andReturn('dave'); + $this->assertEquals("dave", "$m"); + } + + public function testGetExpectationCount_freshContainer() + { + $this->assertEquals(0, Mockery::getContainer()->mockery_getExpectationCount()); + } + + public function testGetExpectationCount_simplestMock() + { + $m = mock(); + $m->shouldReceive('foo')->andReturn('bar'); + $this->assertEquals(1, Mockery::getContainer()->mockery_getExpectationCount()); + } + + public function testMethodsReturningParamsByReferenceDoesNotErrorOut() + { + mock('MockeryTest_ReturnByRef'); + $mock = mock('MockeryTest_ReturnByRef'); + $mock->shouldReceive("get")->andReturn($var = 123); + $this->assertSame($var, $mock->get()); + } + + + public function testMockCallableTypeHint() + { + $this->assertInstanceOf(MockInterface::class, mock('MockeryTest_MockCallableTypeHint')); + } + + public function testCanMockClassWithReservedWordMethod() + { + if (!extension_loaded("redis")) { + $this->markTestSkipped("phpredis not installed"); + } + + mock("Redis"); + } + + public function testUndeclaredClassIsDeclared() + { + $this->assertFalse(class_exists("BlahBlah")); + $mock = mock("BlahBlah"); + $this->assertInstanceOf("BlahBlah", $mock); + } + + public function testUndeclaredClassWithNamespaceIsDeclared() + { + $this->assertFalse(class_exists("MyClasses\Blah\BlahBlah")); + $mock = mock("MyClasses\Blah\BlahBlah"); + $this->assertInstanceOf("MyClasses\Blah\BlahBlah", $mock); + } + + public function testUndeclaredClassWithNamespaceIncludingLeadingOperatorIsDeclared() + { + $this->assertFalse(class_exists("\MyClasses\DaveBlah\BlahBlah")); + $mock = mock("\MyClasses\DaveBlah\BlahBlah"); + $this->assertInstanceOf("\MyClasses\DaveBlah\BlahBlah", $mock); + } + + public function testMockingPhpredisExtensionClassWorks() + { + if (!class_exists('Redis')) { + $this->markTestSkipped('PHPRedis extension required for this test'); + } + $m = mock('Redis'); + } + + public function testIssetMappingUsingProxiedPartials_CheckNoExceptionThrown() + { + $var = mock(new MockeryTestIsset_Bar()); + $mock = mock(new MockeryTestIsset_Foo($var)); + $mock->shouldReceive('bar')->once(); + $mock->bar(); + Mockery::close(); + + $this->assertTrue(true); + } + + /** + * @group traversable1 + */ + public function testCanMockInterfacesExtendingTraversable() + { + $mock = mock('MockeryTest_InterfaceWithTraversable'); + $this->assertInstanceOf('MockeryTest_InterfaceWithTraversable', $mock); + $this->assertInstanceOf('ArrayAccess', $mock); + $this->assertInstanceOf('Countable', $mock); + $this->assertInstanceOf('Traversable', $mock); + } + + /** + * @group traversable2 + */ + public function testCanMockInterfacesAlongsideTraversable() + { + $mock = mock('stdClass, ArrayAccess, Countable, Traversable'); + $this->assertInstanceOf('stdClass', $mock); + $this->assertInstanceOf('ArrayAccess', $mock); + $this->assertInstanceOf('Countable', $mock); + $this->assertInstanceOf('Traversable', $mock); + } + + public function testInterfacesCanHaveAssertions() + { + $m = mock('stdClass, ArrayAccess, Countable, Traversable'); + $m->shouldReceive('foo')->once(); + $m->foo(); + } + + public function testMockingIteratorAggregateDoesNotImplementIterator() + { + $mock = mock('MockeryTest_ImplementsIteratorAggregate'); + $this->assertInstanceOf('IteratorAggregate', $mock); + $this->assertInstanceOf('Traversable', $mock); + $this->assertNotInstanceOf('Iterator', $mock); + } + + public function testMockingInterfaceThatExtendsIteratorDoesNotImplementIterator() + { + $mock = mock('MockeryTest_InterfaceThatExtendsIterator'); + $this->assertInstanceOf('Iterator', $mock); + $this->assertInstanceOf('Traversable', $mock); + } + + public function testMockingInterfaceThatExtendsIteratorAggregateDoesNotImplementIterator() + { + $mock = mock('MockeryTest_InterfaceThatExtendsIteratorAggregate'); + $this->assertInstanceOf('IteratorAggregate', $mock); + $this->assertInstanceOf('Traversable', $mock); + $this->assertNotInstanceOf('Iterator', $mock); + } + + public function testMockingIteratorAggregateDoesNotImplementIteratorAlongside() + { + $mock = mock('IteratorAggregate'); + $this->assertInstanceOf('IteratorAggregate', $mock); + $this->assertInstanceOf('Traversable', $mock); + $this->assertNotInstanceOf('Iterator', $mock); + } + + public function testMockingIteratorDoesNotImplementIteratorAlongside() + { + $mock = mock('Iterator'); + $this->assertInstanceOf('Iterator', $mock); + $this->assertInstanceOf('Traversable', $mock); + } + + public function testMockingIteratorDoesNotImplementIterator() + { + $mock = mock('MockeryTest_ImplementsIterator'); + $this->assertInstanceOf('Iterator', $mock); + $this->assertInstanceOf('Traversable', $mock); + } + + public function testMockeryCloseForIllegalIssetFileInclude() + { + $m = Mockery::mock('StdClass') + ->shouldReceive('get') + ->andReturn(false) + ->getMock(); + $m->get(); + Mockery::close(); + + // no idea what this test does, adding this as an assertion... + $this->assertTrue(true); + } + + public function testMockeryShouldDistinguishBetweenConstructorParamsAndClosures() + { + $obj = new MockeryTestFoo(); + $this->assertInstanceOf(MockInterface::class, mock('MockeryTest_ClassMultipleConstructorParams[dave]', [ + &$obj, 'foo' + ])); + } + + /** @group nette */ + public function testMockeryShouldNotMockCallstaticMagicMethod() + { + $this->assertInstanceOf(MockInterface::class, mock('MockeryTest_CallStatic')); + } + + /** @group issue/144 */ + public function testMockeryShouldInterpretEmptyArrayAsConstructorArgs() + { + $mock = mock("EmptyConstructorTest", array()); + $this->assertSame(0, $mock->numberOfConstructorArgs); + } + + /** @group issue/144 */ + public function testMockeryShouldCallConstructorByDefaultWhenRequestingPartials() + { + $mock = mock("EmptyConstructorTest[foo]"); + $this->assertSame(0, $mock->numberOfConstructorArgs); + } + + /** @group issue/158 */ + public function testMockeryShouldRespectInterfaceWithMethodParamSelf() + { + $this->assertInstanceOf(MockInterface::class, mock('MockeryTest_InterfaceWithMethodParamSelf')); + } + + /** @group issue/162 */ + public function testMockeryDoesntTryAndMockLowercaseToString() + { + $this->assertInstanceOf(MockInterface::class, mock('MockeryTest_Lowercase_ToString')); + } + + /** @group issue/175 */ + public function testExistingStaticMethodMocking() + { + $mock = mock('MockeryTest_PartialStatic[mockMe]'); + + $mock->shouldReceive('mockMe')->with(5)->andReturn(10); + + $this->assertEquals(10, $mock::mockMe(5)); + $this->assertEquals(3, $mock::keepMe(3)); + } + + /** + * @group issue/154 + * @expectedException InvalidArgumentException + * @expectedExceptionMessage protectedMethod() cannot be mocked as it is a protected method and mocking protected methods is not enabled for the currently used mock object. + */ + public function testShouldThrowIfAttemptingToStubProtectedMethod() + { + $mock = mock('MockeryTest_WithProtectedAndPrivate'); + $mock->shouldReceive("protectedMethod"); + } + + /** + * @group issue/154 + * @expectedException InvalidArgumentException + * @expectedExceptionMessage privateMethod() cannot be mocked as it is a private method + */ + public function testShouldThrowIfAttemptingToStubPrivateMethod() + { + $mock = mock('MockeryTest_WithProtectedAndPrivate'); + $mock->shouldReceive("privateMethod"); + } + + public function testWakeupMagicIsNotMockedToAllowSerialisationInstanceHack() + { + $this->assertInstanceOf(\DateTime::class, mock('DateTime')); + } + + /** + * @group issue/154 + */ + public function testCanMockMethodsWithRequiredParamsThatHaveDefaultValues() + { + $mock = mock('MockeryTest_MethodWithRequiredParamWithDefaultValue'); + $mock->shouldIgnoreMissing(); + $this->assertNull($mock->foo(null, 123)); + } + + /** + * @test + * @group issue/294 + * @expectedException Mockery\Exception\RuntimeException + * @expectedExceptionMessage Could not load mock DateTime, class already exists + */ + public function testThrowsWhenNamedMockClassExistsAndIsNotMockery() + { + $builder = new MockConfigurationBuilder(); + $builder->setName("DateTime"); + $mock = mock($builder); + } + + /** + * @expectedException Mockery\Exception\NoMatchingExpectationException + * @expectedExceptionMessage MyTestClass::foo(resource(...)) + */ + public function testHandlesMethodWithArgumentExpectationWhenCalledWithResource() + { + $mock = mock('MyTestClass'); + $mock->shouldReceive('foo')->with(array('yourself' => 21)); + + $mock->foo(fopen('php://memory', 'r')); + } + + /** + * @expectedException Mockery\Exception\NoMatchingExpectationException + * @expectedExceptionMessage MyTestClass::foo(['myself' => [...]]) + */ + public function testHandlesMethodWithArgumentExpectationWhenCalledWithCircularArray() + { + $testArray = array(); + $testArray['myself'] =& $testArray; + + $mock = mock('MyTestClass'); + $mock->shouldReceive('foo')->with(array('yourself' => 21)); + + $mock->foo($testArray); + } + + /** + * @expectedException Mockery\Exception\NoMatchingExpectationException + * @expectedExceptionMessage MyTestClass::foo(['a_scalar' => 2, 'an_array' => [...]]) + */ + public function testHandlesMethodWithArgumentExpectationWhenCalledWithNestedArray() + { + $testArray = array(); + $testArray['a_scalar'] = 2; + $testArray['an_array'] = array(1, 2, 3); + + $mock = mock('MyTestClass'); + $mock->shouldReceive('foo')->with(array('yourself' => 21)); + + $mock->foo($testArray); + } + + /** + * @expectedException Mockery\Exception\NoMatchingExpectationException + * @expectedExceptionMessage MyTestClass::foo(['a_scalar' => 2, 'an_object' => object(stdClass)]) + */ + public function testHandlesMethodWithArgumentExpectationWhenCalledWithNestedObject() + { + $testArray = array(); + $testArray['a_scalar'] = 2; + $testArray['an_object'] = new stdClass(); + + $mock = mock('MyTestClass'); + $mock->shouldReceive('foo')->with(array('yourself' => 21)); + + $mock->foo($testArray); + } + + /** + * @expectedException Mockery\Exception\NoMatchingExpectationException + * @expectedExceptionMessage MyTestClass::foo(['a_scalar' => 2, 'a_closure' => object(Closure + */ + public function testHandlesMethodWithArgumentExpectationWhenCalledWithNestedClosure() + { + $testArray = array(); + $testArray['a_scalar'] = 2; + $testArray['a_closure'] = function () { + }; + + $mock = mock('MyTestClass'); + $mock->shouldReceive('foo')->with(array('yourself' => 21)); + + $mock->foo($testArray); + } + + /** + * @expectedException Mockery\Exception\NoMatchingExpectationException + * @expectedExceptionMessage MyTestClass::foo(['a_scalar' => 2, 'a_resource' => resource(...)]) + */ + public function testHandlesMethodWithArgumentExpectationWhenCalledWithNestedResource() + { + $testArray = array(); + $testArray['a_scalar'] = 2; + $testArray['a_resource'] = fopen('php://memory', 'r'); + + $mock = mock('MyTestClass'); + $mock->shouldReceive('foo')->with(array('yourself' => 21)); + + $mock->foo($testArray); + } + + public function testExceptionOutputMakesBooleansLookLikeBooleans() + { + $mock = mock('MyTestClass'); + $mock->shouldReceive("foo")->with(123); + + $this->expectException( + "Mockery\Exception\NoMatchingExpectationException", + "MyTestClass::foo(true, false, [0 => true, 1 => false])" + ); + + $mock->foo(true, false, [true, false]); + } + + /** + * @test + * @group issue/339 + */ + public function canMockClassesThatDescendFromInternalClasses() + { + $mock = mock("MockeryTest_ClassThatDescendsFromInternalClass"); + $this->assertInstanceOf("DateTime", $mock); + } + + /** + * @test + * @group issue/339 + */ + public function canMockClassesThatImplementSerializable() + { + $mock = mock("MockeryTest_ClassThatImplementsSerializable"); + $this->assertInstanceOf("Serializable", $mock); + } + + /** + * @test + * @group issue/346 + */ + public function canMockInternalClassesThatImplementSerializable() + { + $mock = mock("ArrayObject"); + $this->assertInstanceOf("Serializable", $mock); + } + + /** + * @dataProvider classNameProvider + */ + public function testIsValidClassName($expected, $className) + { + $container = new \Mockery\Container; + $this->assertSame($expected, $container->isValidClassName($className)); + } + + public function classNameProvider() + { + return array( + array(false, ' '), // just a space + array(false, 'ClassName.WithDot'), + array(false, '\\\\TooManyBackSlashes'), + array(true, 'Foo'), + array(true, '\\Foo\\Bar'), + ); + } +} + +class MockeryTest_CallStatic +{ + public static function __callStatic($method, $args) + { + } +} + +class MockeryTest_ClassMultipleConstructorParams +{ + public function __construct($a, $b) + { + } + + public function dave() + { + } +} + +interface MockeryTest_InterfaceWithTraversable extends ArrayAccess, Traversable, Countable +{ + public function self(); +} + +class MockeryTestIsset_Bar +{ + public function doSomething() + { + } +} + +class MockeryTestIsset_Foo +{ + private $var; + + public function __construct($var) + { + $this->var = $var; + } + + public function __get($name) + { + $this->var->doSomething(); + } + + public function __isset($name) + { + return (bool) strlen($this->__get($name)); + } +} + +class MockeryTest_IssetMethod +{ + protected $_properties = array(); + + public function __construct() + { + } + + public function __isset($property) + { + return isset($this->_properties[$property]); + } +} + +class MockeryTest_UnsetMethod +{ + protected $_properties = array(); + + public function __construct() + { + } + + public function __unset($property) + { + unset($this->_properties[$property]); + } +} + +class MockeryTestFoo +{ + public function foo() + { + return 'foo'; + } +} + +class MockeryTestFoo2 +{ + public function foo() + { + return 'foo'; + } + + public function bar() + { + return 'bar'; + } +} + +final class MockeryFoo3 +{ + public function foo() + { + return 'baz'; + } +} + +class MockeryFoo4 +{ + final public function foo() + { + return 'baz'; + } + + public function bar() + { + return 'bar'; + } +} + +interface MockeryTest_Interface +{ +} +interface MockeryTest_Interface1 +{ +} +interface MockeryTest_Interface2 +{ +} + +interface MockeryTest_InterfaceWithAbstractMethod +{ + public function set(); +} + +interface MockeryTest_InterfaceWithPublicStaticMethod +{ + public static function self(); +} + +abstract class MockeryTest_AbstractWithAbstractMethod +{ + abstract protected function set(); +} + +class MockeryTest_WithProtectedAndPrivate +{ + protected function protectedMethod() + { + } + + private function privateMethod() + { + } +} + +class MockeryTest_ClassConstructor +{ + public function __construct($param1) + { + } +} + +class MockeryTest_ClassConstructor2 +{ + protected $param1; + + public function __construct(stdClass $param1) + { + $this->param1 = $param1; + } + + public function getParam1() + { + return $this->param1; + } + + public function foo() + { + return 'foo'; + } + + public function bar() + { + return $this->foo(); + } +} + +class MockeryTest_Call1 +{ + public function __call($method, array $params) + { + } +} + +class MockeryTest_Call2 +{ + public function __call($method, $params) + { + } +} + +class MockeryTest_Wakeup1 +{ + public function __construct() + { + } + + public function __wakeup() + { + } +} + +class MockeryTest_ExistingProperty +{ + public $foo = 'bar'; +} + +abstract class MockeryTest_AbstractWithAbstractPublicMethod +{ + abstract public function foo($a, $b); +} + +// issue/18 +class SoCool +{ + public function iDoSomethingReallyCoolHere() + { + return 3; + } +} + +class Gateway +{ + public function __call($method, $args) + { + $m = new SoCool(); + return call_user_func_array(array($m, $method), $args); + } +} + +class MockeryTestBar1 +{ + public function method1() + { + return $this; + } +} + +class MockeryTest_ReturnByRef +{ + public $i = 0; + + public function &get() + { + return $this->$i; + } +} + +class MockeryTest_MethodParamRef +{ + public function method1(&$foo) + { + return true; + } +} +class MockeryTest_MethodParamRef2 +{ + public function method1(&$foo) + { + return true; + } +} +class MockeryTestRef1 +{ + public function foo(&$a, $b) + { + } +} + +class MockeryTest_PartialNormalClass +{ + public function foo() + { + return 'abc'; + } + + public function bar() + { + return 'abc'; + } +} + +abstract class MockeryTest_PartialAbstractClass +{ + abstract public function foo(); + + public function bar() + { + return 'abc'; + } +} + +class MockeryTest_PartialNormalClass2 +{ + public function foo() + { + return 'abc'; + } + + public function bar() + { + return 'abc'; + } + + public function baz() + { + return 'abc'; + } +} + +abstract class MockeryTest_PartialAbstractClass2 +{ + abstract public function foo(); + + public function bar() + { + return 'abc'; + } + + abstract public function baz(); +} + +class MockeryTest_TestInheritedType +{ +} + +if (PHP_VERSION_ID >= 50400) { + class MockeryTest_MockCallableTypeHint + { + public function foo(callable $baz) + { + $baz(); + } + + public function bar(callable $callback = null) + { + $callback(); + } + } +} + +class MockeryTest_WithToString +{ + public function __toString() + { + } +} + +class MockeryTest_ImplementsIteratorAggregate implements IteratorAggregate +{ + public function getIterator() + { + return new ArrayIterator(array()); + } +} + +class MockeryTest_ImplementsIterator implements Iterator +{ + public function rewind() + { + } + + public function current() + { + } + + public function key() + { + } + + public function next() + { + } + + public function valid() + { + } +} + +class EmptyConstructorTest +{ + public $numberOfConstructorArgs; + + public function __construct(...$args) + { + $this->numberOfConstructorArgs = count($args); + } + + public function foo() + { + } +} + +interface MockeryTest_InterfaceWithMethodParamSelf +{ + public function foo(self $bar); +} + +class MockeryTest_Lowercase_ToString +{ + public function __tostring() + { + } +} + +class MockeryTest_PartialStatic +{ + public static function mockMe($a) + { + return $a; + } + + public static function keepMe($b) + { + return $b; + } +} + +class MockeryTest_MethodWithRequiredParamWithDefaultValue +{ + public function foo(DateTime $bar = null, $baz) + { + } +} + +interface MockeryTest_InterfaceThatExtendsIterator extends Iterator +{ + public function foo(); +} + +interface MockeryTest_InterfaceThatExtendsIteratorAggregate extends IteratorAggregate +{ + public function foo(); +} + +class MockeryTest_ClassThatDescendsFromInternalClass extends DateTime +{ +} + +class MockeryTest_ClassThatImplementsSerializable implements Serializable +{ + public function serialize() + { + } + + public function unserialize($serialized) + { + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/DemeterChainTest.php b/vendor/mockery/mockery/tests/Mockery/DemeterChainTest.php new file mode 100644 index 000000000..9528d1612 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/DemeterChainTest.php @@ -0,0 +1,204 @@ += 0) { + require_once __DIR__.'/DummyClasses/DemeterChain.php'; +} + +use Mockery\Adapter\Phpunit\MockeryTestCase; + +class DemeterChainTest extends MockeryTestCase +{ + /** @var Mockery\Mock $this->mock */ + private $mock; + + public function setUp() + { + $this->mock = $this->mock = Mockery::mock()->shouldIgnoreMissing(); + } + + public function tearDown() + { + $this->mock->mockery_getContainer()->mockery_close(); + } + + public function testTwoChains() + { + $this->mock->shouldReceive('getElement->getFirst') + ->once() + ->andReturn('something'); + + $this->mock->shouldReceive('getElement->getSecond') + ->once() + ->andReturn('somethingElse'); + + $this->assertEquals( + 'something', + $this->mock->getElement()->getFirst() + ); + $this->assertEquals( + 'somethingElse', + $this->mock->getElement()->getSecond() + ); + $this->mock->mockery_getContainer()->mockery_close(); + } + + public function testTwoChainsWithExpectedParameters() + { + $this->mock->shouldReceive('getElement->getFirst') + ->once() + ->with('parameter') + ->andReturn('something'); + + $this->mock->shouldReceive('getElement->getSecond') + ->once() + ->with('secondParameter') + ->andReturn('somethingElse'); + + $this->assertEquals( + 'something', + $this->mock->getElement()->getFirst('parameter') + ); + $this->assertEquals( + 'somethingElse', + $this->mock->getElement()->getSecond('secondParameter') + ); + $this->mock->mockery_getContainer()->mockery_close(); + } + + public function testThreeChains() + { + $this->mock->shouldReceive('getElement->getFirst') + ->once() + ->andReturn('something'); + + $this->mock->shouldReceive('getElement->getSecond') + ->once() + ->andReturn('somethingElse'); + + $this->assertEquals( + 'something', + $this->mock->getElement()->getFirst() + ); + $this->assertEquals( + 'somethingElse', + $this->mock->getElement()->getSecond() + ); + $this->mock->shouldReceive('getElement->getFirst') + ->once() + ->andReturn('somethingNew'); + $this->assertEquals( + 'somethingNew', + $this->mock->getElement()->getFirst() + ); + } + + public function testManyChains() + { + $this->mock->shouldReceive('getElements->getFirst') + ->once() + ->andReturn('something'); + + $this->mock->shouldReceive('getElements->getSecond') + ->once() + ->andReturn('somethingElse'); + + $this->mock->getElements()->getFirst(); + $this->mock->getElements()->getSecond(); + } + + public function testTwoNotRelatedChains() + { + $this->mock->shouldReceive('getElement->getFirst') + ->once() + ->andReturn('something'); + + $this->mock->shouldReceive('getOtherElement->getSecond') + ->once() + ->andReturn('somethingElse'); + + $this->assertEquals( + 'somethingElse', + $this->mock->getOtherElement()->getSecond() + ); + $this->assertEquals( + 'something', + $this->mock->getElement()->getFirst() + ); + } + + public function testDemeterChain() + { + $this->mock->shouldReceive('getElement->getFirst') + ->once() + ->andReturn('somethingElse'); + + $this->assertEquals('somethingElse', $this->mock->getElement()->getFirst()); + } + + public function testMultiLevelDemeterChain() + { + $this->mock->shouldReceive('levelOne->levelTwo->getFirst') + ->andReturn('first'); + + $this->mock->shouldReceive('levelOne->levelTwo->getSecond') + ->andReturn('second'); + + $this->assertEquals( + 'second', + $this->mock->levelOne()->levelTwo()->getSecond() + ); + $this->assertEquals( + 'first', + $this->mock->levelOne()->levelTwo()->getFirst() + ); + } + + public function testSimilarDemeterChainsOnDifferentClasses() + { + $mock1 = Mockery::mock('overload:mock1'); + $mock1->shouldReceive('select->some->data')->andReturn(1); + $mock1->shouldReceive('select->some->other->data')->andReturn(2); + + $mock2 = Mockery::mock('overload:mock2'); + $mock2->shouldReceive('select->some->data')->andReturn(3); + $mock2->shouldReceive('select->some->other->data')->andReturn(4); + + $this->assertEquals(1, mock1::select()->some()->data()); + $this->assertEquals(2, mock1::select()->some()->other()->data()); + $this->assertEquals(3, mock2::select()->some()->data()); + $this->assertEquals(4, mock2::select()->some()->other()->data()); + } + + /** + * @requires PHP 7.0.0 + */ + public function testDemeterChainsWithClassReturnTypeHints() + { + $a = \Mockery::mock(\DemeterChain\A::class); + $a->shouldReceive('foo->bar->baz')->andReturn(new stdClass); + + $m = new \DemeterChain\Main(); + $result = $m->callDemeter($a); + + $this->assertInstanceOf(stdClass::class, $result); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/DummyClasses/DemeterChain.php b/vendor/mockery/mockery/tests/Mockery/DummyClasses/DemeterChain.php new file mode 100644 index 000000000..b778cd4eb --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/DummyClasses/DemeterChain.php @@ -0,0 +1,54 @@ +foo()->bar()->baz(); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/DummyClasses/Namespaced.php b/vendor/mockery/mockery/tests/Mockery/DummyClasses/Namespaced.php new file mode 100644 index 000000000..615eb718a --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/DummyClasses/Namespaced.php @@ -0,0 +1,35 @@ +mock = mock(); + } + + public function teardown() + { + parent::tearDown(); + \Mockery::getConfiguration()->allowMockingNonExistentMethods(true); + } + + public function testReturnsNullWhenNoArgs() + { + $this->mock->shouldReceive('foo'); + $this->assertNull($this->mock->foo()); + } + + public function testReturnsNullWhenSingleArg() + { + $this->mock->shouldReceive('foo'); + $this->assertNull($this->mock->foo(1)); + } + + public function testReturnsNullWhenManyArgs() + { + $this->mock->shouldReceive('foo'); + $this->assertNull($this->mock->foo('foo', array(), new stdClass)); + } + + public function testReturnsNullIfNullIsReturnValue() + { + $this->mock->shouldReceive('foo')->andReturn(null); + $this->assertNull($this->mock->foo()); + } + + public function testReturnsNullForMockedExistingClassIfAndreturnnullCalled() + { + $mock = mock('MockeryTest_Foo'); + $mock->shouldReceive('foo')->andReturn(null); + $this->assertNull($mock->foo()); + } + + public function testReturnsNullForMockedExistingClassIfNullIsReturnValue() + { + $mock = mock('MockeryTest_Foo'); + $mock->shouldReceive('foo')->andReturnNull(); + $this->assertNull($mock->foo()); + } + + public function testReturnsSameValueForAllIfNoArgsExpectationAndNoneGiven() + { + $this->mock->shouldReceive('foo')->andReturn(1); + $this->assertEquals(1, $this->mock->foo()); + } + + public function testSetsPublicPropertyWhenRequested() + { + $this->mock->bar = null; + $this->mock->shouldReceive('foo')->andSet('bar', 'baz'); + $this->assertNull($this->mock->bar); + $this->mock->foo(); + $this->assertEquals('baz', $this->mock->bar); + } + + public function testSetsPublicPropertyWhenRequestedUsingAlias() + { + $this->mock->bar = null; + $this->mock->shouldReceive('foo')->set('bar', 'baz'); + $this->assertNull($this->mock->bar); + $this->mock->foo(); + $this->assertEquals('baz', $this->mock->bar); + } + + public function testSetsPublicPropertiesWhenRequested() + { + $this->mock->bar = null; + $this->mock->shouldReceive('foo')->andSet('bar', 'baz', 'bazz', 'bazzz'); + $this->assertNull($this->mock->bar); + $this->mock->foo(); + $this->assertEquals('baz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazzz', $this->mock->bar); + } + + public function testSetsPublicPropertiesWhenRequestedUsingAlias() + { + $this->mock->bar = null; + $this->mock->shouldReceive('foo')->set('bar', 'baz', 'bazz', 'bazzz'); + $this->assertAttributeEmpty('bar', $this->mock); + $this->mock->foo(); + $this->assertEquals('baz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazzz', $this->mock->bar); + } + + public function testSetsPublicPropertiesWhenRequestedMoreTimesThanSetValues() + { + $this->mock->bar = null; + $this->mock->shouldReceive('foo')->andSet('bar', 'baz', 'bazz'); + $this->assertNull($this->mock->bar); + $this->mock->foo(); + $this->assertEquals('baz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazz', $this->mock->bar); + } + + public function testSetsPublicPropertiesWhenRequestedMoreTimesThanSetValuesUsingAlias() + { + $this->mock->bar = null; + $this->mock->shouldReceive('foo')->andSet('bar', 'baz', 'bazz'); + $this->assertNull($this->mock->bar); + $this->mock->foo(); + $this->assertEquals('baz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazz', $this->mock->bar); + } + + public function testSetsPublicPropertiesWhenRequestedMoreTimesThanSetValuesWithDirectSet() + { + $this->mock->bar = null; + $this->mock->shouldReceive('foo')->andSet('bar', 'baz', 'bazz'); + $this->assertNull($this->mock->bar); + $this->mock->foo(); + $this->assertEquals('baz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazz', $this->mock->bar); + $this->mock->bar = null; + $this->mock->foo(); + $this->assertNull($this->mock->bar); + } + + public function testSetsPublicPropertiesWhenRequestedMoreTimesThanSetValuesWithDirectSetUsingAlias() + { + $this->mock->bar = null; + $this->mock->shouldReceive('foo')->set('bar', 'baz', 'bazz'); + $this->assertNull($this->mock->bar); + $this->mock->foo(); + $this->assertEquals('baz', $this->mock->bar); + $this->mock->foo(); + $this->assertEquals('bazz', $this->mock->bar); + $this->mock->bar = null; + $this->mock->foo(); + $this->assertNull($this->mock->bar); + } + + public function testReturnsSameValueForAllIfNoArgsExpectationAndSomeGiven() + { + $this->mock->shouldReceive('foo')->andReturn(1); + $this->assertEquals(1, $this->mock->foo('foo')); + } + + public function testReturnsValueFromSequenceSequentially() + { + $this->mock->shouldReceive('foo')->andReturn(1, 2, 3); + $this->mock->foo('foo'); + $this->assertEquals(2, $this->mock->foo('foo')); + } + + public function testReturnsValueFromSequenceSequentiallyAndRepeatedlyReturnsFinalValueOnExtraCalls() + { + $this->mock->shouldReceive('foo')->andReturn(1, 2, 3); + $this->mock->foo('foo'); + $this->mock->foo('foo'); + $this->assertEquals(3, $this->mock->foo('foo')); + $this->assertEquals(3, $this->mock->foo('foo')); + } + + public function testReturnsValueFromSequenceSequentiallyAndRepeatedlyReturnsFinalValueOnExtraCallsWithManyAndReturnCalls() + { + $this->mock->shouldReceive('foo')->andReturn(1)->andReturn(2, 3); + $this->mock->foo('foo'); + $this->mock->foo('foo'); + $this->assertEquals(3, $this->mock->foo('foo')); + $this->assertEquals(3, $this->mock->foo('foo')); + } + + public function testReturnsValueOfClosure() + { + $this->mock->shouldReceive('foo')->with(5)->andReturnUsing(function ($v) { + return $v+1; + }); + $this->assertEquals(6, $this->mock->foo(5)); + } + + public function testReturnsUndefined() + { + $this->mock->shouldReceive('foo')->andReturnUndefined(); + $this->assertInstanceOf(\Mockery\Undefined::class, $this->mock->foo()); + } + + public function testReturnsValuesSetAsArray() + { + $this->mock->shouldReceive('foo')->andReturnValues(array(1, 2, 3)); + $this->assertEquals(1, $this->mock->foo()); + $this->assertEquals(2, $this->mock->foo()); + $this->assertEquals(3, $this->mock->foo()); + } + + /** + * @expectedException OutOfBoundsException + */ + public function testThrowsException() + { + $this->mock->shouldReceive('foo')->andThrow(new OutOfBoundsException); + $this->mock->foo(); + Mockery::close(); + } + + /** @test */ + public function and_throws_is_an_alias_to_and_throw() + { + $this->mock->shouldReceive('foo')->andThrows(new OutOfBoundsException); + + $this->expectException(OutOfBoundsException::class); + $this->mock->foo(); + } + + /** + * @test + * @requires PHP 7.0.0 + */ + public function it_can_throw_a_throwable() + { + $this->expectException(\Error::class); + $this->mock->shouldReceive('foo')->andThrow(new \Error()); + $this->mock->foo(); + } + + /** + * @expectedException OutOfBoundsException + */ + public function testThrowsExceptionBasedOnArgs() + { + $this->mock->shouldReceive('foo')->andThrow('OutOfBoundsException'); + $this->mock->foo(); + Mockery::close(); + } + + public function testThrowsExceptionBasedOnArgsWithMessage() + { + $this->mock->shouldReceive('foo')->andThrow('OutOfBoundsException', 'foo'); + try { + $this->mock->foo(); + } catch (OutOfBoundsException $e) { + $this->assertEquals('foo', $e->getMessage()); + } + } + + /** + * @expectedException OutOfBoundsException + */ + public function testThrowsExceptionSequentially() + { + $this->mock->shouldReceive('foo')->andThrow(new Exception)->andThrow(new OutOfBoundsException); + try { + $this->mock->foo(); + } catch (Exception $e) { + } + $this->mock->foo(); + Mockery::close(); + } + + public function testAndThrowExceptions() + { + $this->mock->shouldReceive('foo')->andThrowExceptions(array( + new OutOfBoundsException, + new InvalidArgumentException, + )); + + try { + $this->mock->foo(); + throw new Exception("Expected OutOfBoundsException, non thrown"); + } catch (\Exception $e) { + $this->assertInstanceOf("OutOfBoundsException", $e, "Wrong or no exception thrown: {$e->getMessage()}"); + } + + try { + $this->mock->foo(); + throw new Exception("Expected InvalidArgumentException, non thrown"); + } catch (\Exception $e) { + $this->assertInstanceOf("InvalidArgumentException", $e, "Wrong or no exception thrown: {$e->getMessage()}"); + } + } + + /** + * @expectedException Mockery\Exception + * @expectedExceptionMessage You must pass an array of exception objects to andThrowExceptions + */ + public function testAndThrowExceptionsCatchNonExceptionArgument() + { + $this->mock + ->shouldReceive('foo') + ->andThrowExceptions(array('NotAnException')); + Mockery::close(); + } + + public function testMultipleExpectationsWithReturns() + { + $this->mock->shouldReceive('foo')->with(1)->andReturn(10); + $this->mock->shouldReceive('bar')->with(2)->andReturn(20); + $this->assertEquals(10, $this->mock->foo(1)); + $this->assertEquals(20, $this->mock->bar(2)); + } + + public function testExpectsNoArguments() + { + $this->mock->shouldReceive('foo')->withNoArgs(); + $this->mock->foo(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testExpectsNoArgumentsThrowsExceptionIfAnyPassed() + { + $this->mock->shouldReceive('foo')->withNoArgs(); + $this->mock->foo(1); + Mockery::close(); + } + + public function testExpectsArgumentsArray() + { + $this->mock->shouldReceive('foo')->withArgs(array(1, 2)); + $this->mock->foo(1, 2); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testExpectsArgumentsArrayThrowsExceptionIfPassedEmptyArray() + { + $this->mock->shouldReceive('foo')->withArgs(array()); + $this->mock->foo(1, 2); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testExpectsArgumentsArrayThrowsExceptionIfNoArgumentsPassed() + { + $this->mock->shouldReceive('foo')->with(); + $this->mock->foo(1); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testExpectsArgumentsArrayThrowsExceptionIfPassedWrongArguments() + { + $this->mock->shouldReceive('foo')->withArgs(array(1, 2)); + $this->mock->foo(3, 4); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception + * @expectedExceptionMessageRegExp /foo\(NULL\)/ + */ + public function testExpectsStringArgumentExceptionMessageDifferentiatesBetweenNullAndEmptyString() + { + $this->mock->shouldReceive('foo')->withArgs(array('a string')); + $this->mock->foo(null); + Mockery::close(); + } + + /** + * @expectedException \InvalidArgumentException + * @expectedExceptionMessageRegExp /invalid argument (.+), only array and closure are allowed/ + */ + public function testExpectsArgumentsArrayThrowsExceptionIfPassedWrongArgumentType() + { + $this->mock->shouldReceive('foo')->withArgs(5); + Mockery::close(); + } + + public function testExpectsArgumentsArrayAcceptAClosureThatValidatesPassedArguments() + { + $closure = function ($odd, $even) { + return ($odd % 2 != 0) && ($even % 2 == 0); + }; + $this->mock->shouldReceive('foo')->withArgs($closure); + $this->mock->foo(1, 2); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testExpectsArgumentsArrayThrowsExceptionWhenClosureEvaluatesToFalse() + { + $closure = function ($odd, $even) { + return ($odd % 2 != 0) && ($even % 2 == 0); + }; + $this->mock->shouldReceive('foo')->withArgs($closure); + $this->mock->foo(4, 2); + Mockery::close(); + } + + public function testExpectsArgumentsArrayClosureDoesNotThrowExceptionIfOptionalArgumentsAreMissing() + { + $closure = function ($odd, $even, $sum = null) { + $result = ($odd % 2 != 0) && ($even % 2 == 0); + if (!is_null($sum)) { + return $result && ($odd + $even == $sum); + } + return $result; + }; + $this->mock->shouldReceive('foo')->withArgs($closure); + $this->mock->foo(1, 4); + } + + public function testExpectsArgumentsArrayClosureDoesNotThrowExceptionIfOptionalArgumentsMathTheExpectation() + { + $closure = function ($odd, $even, $sum = null) { + $result = ($odd % 2 != 0) && ($even % 2 == 0); + if (!is_null($sum)) { + return $result && ($odd + $even == $sum); + } + return $result; + }; + $this->mock->shouldReceive('foo')->withArgs($closure); + $this->mock->foo(1, 4, 5); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testExpectsArgumentsArrayClosureThrowsExceptionIfOptionalArgumentsDontMatchTheExpectation() + { + $closure = function ($odd, $even, $sum = null) { + $result = ($odd % 2 != 0) && ($even % 2 == 0); + if (!is_null($sum)) { + return $result && ($odd + $even == $sum); + } + return $result; + }; + $this->mock->shouldReceive('foo')->withArgs($closure); + $this->mock->foo(1, 4, 2); + Mockery::close(); + } + + public function testExpectsAnyArguments() + { + $this->mock->shouldReceive('foo')->withAnyArgs(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 'k', new stdClass); + } + + public function testExpectsArgumentMatchingObjectType() + { + $this->mock->shouldReceive('foo')->with('\stdClass'); + $this->mock->foo(new stdClass); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testThrowsExceptionOnNoArgumentMatch() + { + $this->mock->shouldReceive('foo')->with(1); + $this->mock->foo(2); + Mockery::close(); + } + + public function testNeverCalled() + { + $this->mock->shouldReceive('foo')->never(); + } + + public function testShouldNotReceive() + { + $this->mock->shouldNotReceive('foo'); + } + + /** + * @expectedException \Mockery\Exception\InvalidCountException + */ + public function testShouldNotReceiveThrowsExceptionIfMethodCalled() + { + $this->mock->shouldNotReceive('foo'); + $this->mock->foo(); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception\InvalidCountException + */ + public function testShouldNotReceiveWithArgumentThrowsExceptionIfMethodCalled() + { + $this->mock->shouldNotReceive('foo')->with(2); + $this->mock->foo(2); + Mockery::close(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testNeverCalledThrowsExceptionOnCall() + { + $this->mock->shouldReceive('foo')->never(); + $this->mock->foo(); + Mockery::close(); + } + + public function testCalledOnce() + { + $this->mock->shouldReceive('foo')->once(); + $this->mock->foo(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testCalledOnceThrowsExceptionIfNotCalled() + { + $this->mock->shouldReceive('foo')->once(); + Mockery::close(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testCalledOnceThrowsExceptionIfCalledTwice() + { + $this->mock->shouldReceive('foo')->once(); + $this->mock->foo(); + $this->mock->foo(); + Mockery::close(); + } + + public function testCalledTwice() + { + $this->mock->shouldReceive('foo')->twice(); + $this->mock->foo(); + $this->mock->foo(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testCalledTwiceThrowsExceptionIfNotCalled() + { + $this->mock->shouldReceive('foo')->twice(); + Mockery::close(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testCalledOnceThrowsExceptionIfCalledThreeTimes() + { + $this->mock->shouldReceive('foo')->twice(); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + Mockery::close(); + } + + public function testCalledZeroOrMoreTimesAtZeroCalls() + { + $this->mock->shouldReceive('foo')->zeroOrMoreTimes(); + } + + public function testCalledZeroOrMoreTimesAtThreeCalls() + { + $this->mock->shouldReceive('foo')->zeroOrMoreTimes(); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + } + + public function testTimesCountCalls() + { + $this->mock->shouldReceive('foo')->times(4); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testTimesCountCallThrowsExceptionOnTooFewCalls() + { + $this->mock->shouldReceive('foo')->times(2); + $this->mock->foo(); + Mockery::close(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testTimesCountCallThrowsExceptionOnTooManyCalls() + { + $this->mock->shouldReceive('foo')->times(2); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + Mockery::close(); + } + + public function testCalledAtLeastOnceAtExactlyOneCall() + { + $this->mock->shouldReceive('foo')->atLeast()->once(); + $this->mock->foo(); + } + + public function testCalledAtLeastOnceAtExactlyThreeCalls() + { + $this->mock->shouldReceive('foo')->atLeast()->times(3); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testCalledAtLeastThrowsExceptionOnTooFewCalls() + { + $this->mock->shouldReceive('foo')->atLeast()->twice(); + $this->mock->foo(); + Mockery::close(); + } + + public function testCalledAtMostOnceAtExactlyOneCall() + { + $this->mock->shouldReceive('foo')->atMost()->once(); + $this->mock->foo(); + } + + public function testCalledAtMostAtExactlyThreeCalls() + { + $this->mock->shouldReceive('foo')->atMost()->times(3); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testCalledAtLeastThrowsExceptionOnTooManyCalls() + { + $this->mock->shouldReceive('foo')->atMost()->twice(); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + Mockery::close(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testExactCountersOverrideAnyPriorSetNonExactCounters() + { + $this->mock->shouldReceive('foo')->atLeast()->once()->once(); + $this->mock->foo(); + $this->mock->foo(); + Mockery::close(); + } + + public function testComboOfLeastAndMostCallsWithOneCall() + { + $this->mock->shouldReceive('foo')->atleast()->once()->atMost()->twice(); + $this->mock->foo(); + } + + public function testComboOfLeastAndMostCallsWithTwoCalls() + { + $this->mock->shouldReceive('foo')->atleast()->once()->atMost()->twice(); + $this->mock->foo(); + $this->mock->foo(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testComboOfLeastAndMostCallsThrowsExceptionAtTooFewCalls() + { + $this->mock->shouldReceive('foo')->atleast()->once()->atMost()->twice(); + Mockery::close(); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testComboOfLeastAndMostCallsThrowsExceptionAtTooManyCalls() + { + $this->mock->shouldReceive('foo')->atleast()->once()->atMost()->twice(); + $this->mock->foo(); + $this->mock->foo(); + $this->mock->foo(); + Mockery::close(); + } + + public function testCallCountingOnlyAppliesToMatchedExpectations() + { + $this->mock->shouldReceive('foo')->with(1)->once(); + $this->mock->shouldReceive('foo')->with(2)->twice(); + $this->mock->shouldReceive('foo')->with(3); + $this->mock->foo(1); + $this->mock->foo(2); + $this->mock->foo(2); + $this->mock->foo(3); + } + + /** + * @expectedException \Mockery\CountValidator\Exception + */ + public function testCallCountingThrowsExceptionOnAnyMismatch() + { + $this->mock->shouldReceive('foo')->with(1)->once(); + $this->mock->shouldReceive('foo')->with(2)->twice(); + $this->mock->shouldReceive('foo')->with(3); + $this->mock->shouldReceive('bar'); + $this->mock->foo(1); + $this->mock->foo(2); + $this->mock->foo(3); + $this->mock->bar(); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception\InvalidCountException + */ + public function testCallCountingThrowsExceptionFirst() + { + $number_of_calls = 0; + $this->mock->shouldReceive('foo') + ->times(2) + ->with(\Mockery::on(function ($argument) use (&$number_of_calls) { + $number_of_calls++; + return $number_of_calls <= 3; + })); + + $this->mock->foo(1); + $this->mock->foo(1); + $this->mock->foo(1); + Mockery::close(); + } + + public function testOrderedCallsWithoutError() + { + $this->mock->shouldReceive('foo')->ordered(); + $this->mock->shouldReceive('bar')->ordered(); + $this->mock->foo(); + $this->mock->bar(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testOrderedCallsWithOutOfOrderError() + { + $this->mock->shouldReceive('foo')->ordered(); + $this->mock->shouldReceive('bar')->ordered(); + $this->mock->bar(); + $this->mock->foo(); + Mockery::close(); + } + + public function testDifferentArgumentsAndOrderingsPassWithoutException() + { + $this->mock->shouldReceive('foo')->with(1)->ordered(); + $this->mock->shouldReceive('foo')->with(2)->ordered(); + $this->mock->foo(1); + $this->mock->foo(2); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testDifferentArgumentsAndOrderingsThrowExceptionWhenInWrongOrder() + { + $this->mock->shouldReceive('foo')->with(1)->ordered(); + $this->mock->shouldReceive('foo')->with(2)->ordered(); + $this->mock->foo(2); + $this->mock->foo(1); + Mockery::close(); + } + + public function testUnorderedCallsIgnoredForOrdering() + { + $this->mock->shouldReceive('foo')->with(1)->ordered(); + $this->mock->shouldReceive('foo')->with(2); + $this->mock->shouldReceive('foo')->with(3)->ordered(); + $this->mock->foo(2); + $this->mock->foo(1); + $this->mock->foo(2); + $this->mock->foo(3); + $this->mock->foo(2); + } + + public function testOrderingOfDefaultGrouping() + { + $this->mock->shouldReceive('foo')->ordered(); + $this->mock->shouldReceive('bar')->ordered(); + $this->mock->foo(); + $this->mock->bar(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testOrderingOfDefaultGroupingThrowsExceptionOnWrongOrder() + { + $this->mock->shouldReceive('foo')->ordered(); + $this->mock->shouldReceive('bar')->ordered(); + $this->mock->bar(); + $this->mock->foo(); + Mockery::close(); + } + + public function testOrderingUsingNumberedGroups() + { + $this->mock->shouldReceive('start')->ordered(1); + $this->mock->shouldReceive('foo')->ordered(2); + $this->mock->shouldReceive('bar')->ordered(2); + $this->mock->shouldReceive('final')->ordered(); + $this->mock->start(); + $this->mock->bar(); + $this->mock->foo(); + $this->mock->bar(); + $this->mock->final(); + } + + public function testOrderingUsingNamedGroups() + { + $this->mock->shouldReceive('start')->ordered('start'); + $this->mock->shouldReceive('foo')->ordered('foobar'); + $this->mock->shouldReceive('bar')->ordered('foobar'); + $this->mock->shouldReceive('final')->ordered(); + $this->mock->start(); + $this->mock->bar(); + $this->mock->foo(); + $this->mock->bar(); + $this->mock->final(); + } + + /** + * @group 2A + */ + public function testGroupedUngroupedOrderingDoNotOverlap() + { + $s = $this->mock->shouldReceive('start')->ordered(); + $m = $this->mock->shouldReceive('mid')->ordered('foobar'); + $e = $this->mock->shouldReceive('end')->ordered(); + $this->assertLessThan($m->getOrderNumber(), $s->getOrderNumber()); + $this->assertLessThan($e->getOrderNumber(), $m->getOrderNumber()); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testGroupedOrderingThrowsExceptionWhenCallsDisordered() + { + $this->mock->shouldReceive('foo')->ordered('first'); + $this->mock->shouldReceive('bar')->ordered('second'); + $this->mock->bar(); + $this->mock->foo(); + Mockery::close(); + } + + public function testExpectationMatchingWithNoArgsOrderings() + { + $this->mock->shouldReceive('foo')->withNoArgs()->once()->ordered(); + $this->mock->shouldReceive('bar')->withNoArgs()->once()->ordered(); + $this->mock->shouldReceive('foo')->withNoArgs()->once()->ordered(); + $this->mock->foo(); + $this->mock->bar(); + $this->mock->foo(); + } + + public function testExpectationMatchingWithAnyArgsOrderings() + { + $this->mock->shouldReceive('foo')->withAnyArgs()->once()->ordered(); + $this->mock->shouldReceive('bar')->withAnyArgs()->once()->ordered(); + $this->mock->shouldReceive('foo')->withAnyArgs()->once()->ordered(); + $this->mock->foo(); + $this->mock->bar(); + $this->mock->foo(); + } + + public function testEnsuresOrderingIsNotCrossMockByDefault() + { + $this->mock->shouldReceive('foo')->ordered(); + $mock2 = mock('bar'); + $mock2->shouldReceive('bar')->ordered(); + $mock2->bar(); + $this->mock->foo(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testEnsuresOrderingIsCrossMockWhenGloballyFlagSet() + { + $this->mock->shouldReceive('foo')->globally()->ordered(); + $mock2 = mock('bar'); + $mock2->shouldReceive('bar')->globally()->ordered(); + $mock2->bar(); + $this->mock->foo(); + Mockery::close(); + } + + public function testExpectationCastToStringFormatting() + { + $exp = $this->mock->shouldReceive('foo')->with(1, 'bar', new stdClass, array('Spam' => 'Ham', 'Bar' => 'Baz')); + $this->assertEquals("[foo(1, 'bar', object(stdClass), ['Spam' => 'Ham', 'Bar' => 'Baz'])]", (string) $exp); + } + + public function testLongExpectationCastToStringFormatting() + { + $exp = $this->mock->shouldReceive('foo')->with(array('Spam' => 'Ham', 'Bar' => 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'Bar', 'Baz', 'End')); + $this->assertEquals("[foo(['Spam' => 'Ham', 'Bar' => 'Baz', 0 => 'Bar', 1 => 'Baz', 2 => 'Bar', 3 => 'Baz', 4 => 'Bar', 5 => 'Baz', 6 => 'Bar', 7 => 'Baz', 8 => 'Bar', 9 => 'Baz', 10 => 'Bar', 11 => 'Baz', 12 => 'Bar', 13 => 'Baz', 14 => 'Bar', 15 => 'Baz', 16 => 'Bar', 17 => 'Baz', 18 => 'Bar', 19 => 'Baz', 20 => 'Bar', 21 => 'Baz', 22 => 'Bar', 23 => 'Baz', 24 => 'Bar', 25 => 'Baz', 26 => 'Bar', 27 => 'Baz', 28 => 'Bar', 29 => 'Baz', 30 => 'Bar', 31 => 'Baz', 32 => 'Bar', 33 => 'Baz', 34 => 'Bar', 35 => 'Baz', 36 => 'Bar', 37 => 'Baz', 38 => 'Bar', 39 => 'Baz', 40 => 'Bar', 41 => 'Baz', 42 => 'Bar', 43 => 'Baz', 44 => 'Bar', 45 => 'Baz', 46 => 'Baz', 47 => 'Bar', 48 => 'Baz', 49 => 'Bar', 50 => 'Baz', 51 => 'Bar', 52 => 'Baz', 53 => 'Bar', 54 => 'Baz', 55 => 'Bar', 56 => 'Baz', 57 => 'Baz', 58 => 'Bar', 59 => 'Baz', 60 => 'Bar', 61 => 'Baz', 62 => 'Bar', 63 => 'Baz', 64 => 'Bar', 65 => 'Baz', 66 => 'Bar', 67 => 'Baz', 68 => 'Baz', 69 => 'Bar', 70 => 'Baz', 71 => 'Bar', 72 => 'Baz', 73 => 'Bar', 74 => 'Baz', 7...])]", (string) $exp); + } + + public function testMultipleExpectationCastToStringFormatting() + { + $exp = $this->mock->shouldReceive('foo', 'bar')->with(1); + $this->assertEquals('[foo(1), bar(1)]', (string) $exp); + } + + public function testGroupedOrderingWithLimitsAllowsMultipleReturnValues() + { + $this->mock->shouldReceive('foo')->with(2)->once()->andReturn('first'); + $this->mock->shouldReceive('foo')->with(2)->twice()->andReturn('second/third'); + $this->mock->shouldReceive('foo')->with(2)->andReturn('infinity'); + $this->assertEquals('first', $this->mock->foo(2)); + $this->assertEquals('second/third', $this->mock->foo(2)); + $this->assertEquals('second/third', $this->mock->foo(2)); + $this->assertEquals('infinity', $this->mock->foo(2)); + $this->assertEquals('infinity', $this->mock->foo(2)); + $this->assertEquals('infinity', $this->mock->foo(2)); + } + + public function testExpectationsCanBeMarkedAsDefaults() + { + $this->mock->shouldReceive('foo')->andReturn('bar')->byDefault(); + $this->assertEquals('bar', $this->mock->foo()); + } + + public function testDefaultExpectationsValidatedInCorrectOrder() + { + $this->mock->shouldReceive('foo')->with(1)->once()->andReturn('first')->byDefault(); + $this->mock->shouldReceive('foo')->with(2)->once()->andReturn('second')->byDefault(); + $this->assertEquals('first', $this->mock->foo(1)); + $this->assertEquals('second', $this->mock->foo(2)); + } + + public function testDefaultExpectationsAreReplacedByLaterConcreteExpectations() + { + $this->mock->shouldReceive('foo')->andReturn('bar')->once()->byDefault(); + $this->mock->shouldReceive('foo')->andReturn('baz')->twice(); + $this->assertEquals('baz', $this->mock->foo()); + $this->assertEquals('baz', $this->mock->foo()); + } + + public function testExpectationFallsBackToDefaultExpectationWhenConcreteExpectationsAreUsedUp() + { + $this->mock->shouldReceive('foo')->with(1)->andReturn('bar')->once()->byDefault(); + $this->mock->shouldReceive('foo')->with(2)->andReturn('baz')->once(); + $this->assertEquals('baz', $this->mock->foo(2)); + $this->assertEquals('bar', $this->mock->foo(1)); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testDefaultExpectationsCanBeOrdered() + { + $this->mock->shouldReceive('foo')->ordered()->byDefault(); + $this->mock->shouldReceive('bar')->ordered()->byDefault(); + $this->mock->bar(); + $this->mock->foo(); + Mockery::close(); + } + + public function testDefaultExpectationsCanBeOrderedAndReplaced() + { + $this->mock->shouldReceive('foo')->ordered()->byDefault(); + $this->mock->shouldReceive('bar')->ordered()->byDefault(); + $this->mock->shouldReceive('bar')->ordered(); + $this->mock->shouldReceive('foo')->ordered(); + $this->mock->bar(); + $this->mock->foo(); + } + + public function testByDefaultOperatesFromMockConstruction() + { + $container = new \Mockery\Container(\Mockery::getDefaultGenerator(), \Mockery::getDefaultLoader()); + $mock = $container->mock('f', array('foo'=>'rfoo', 'bar'=>'rbar', 'baz'=>'rbaz'))->byDefault(); + $mock->shouldReceive('foo')->andReturn('foobar'); + $this->assertEquals('foobar', $mock->foo()); + $this->assertEquals('rbar', $mock->bar()); + $this->assertEquals('rbaz', $mock->baz()); + } + + public function testByDefaultOnAMockDoesSquatWithoutExpectations() + { + $this->assertInstanceOf(MockInterface::class, mock('f')->byDefault()); + } + + public function testDefaultExpectationsCanBeOverridden() + { + $this->mock->shouldReceive('foo')->with('test')->andReturn('bar')->byDefault(); + $this->mock->shouldReceive('foo')->with('test')->andReturn('newbar')->byDefault(); + $this->mock->foo('test'); + $this->assertEquals('newbar', $this->mock->foo('test')); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testByDefaultPreventedFromSettingDefaultWhenDefaultingExpectationWasReplaced() + { + $exp = $this->mock->shouldReceive('foo')->andReturn(1); + $this->mock->shouldReceive('foo')->andReturn(2); + $exp->byDefault(); + Mockery::close(); + } + + /** + * Argument Constraint Tests + */ + + public function testAnyConstraintMatchesAnyArg() + { + $this->mock->shouldReceive('foo')->with(1, Mockery::any())->twice(); + $this->mock->foo(1, 2); + $this->mock->foo(1, 'str'); + } + + public function testAnyConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::any())->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + public function testAndAnyOtherConstraintMatchesTheRestOfTheArguments() + { + $this->mock->shouldReceive('foo')->with(1, 2, Mockery::andAnyOthers())->twice(); + $this->mock->foo(1, 2, 3, 4, 5); + $this->mock->foo(1, 'str', 3, 4); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testAndAnyOtherConstraintDoesNotPreventMatchingOfRegularArguments() + { + $this->mock->shouldReceive('foo')->with(1, 2, Mockery::andAnyOthers()); + $this->mock->foo(10, 2, 3, 4, 5); + Mockery::close(); + } + + public function testArrayConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('array'))->once(); + $this->mock->foo(array()); + } + + public function testArrayConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('array'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testArrayConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('array')); + $this->mock->foo(1); + Mockery::close(); + } + + public function testBoolConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('bool'))->once(); + $this->mock->foo(true); + } + + public function testBoolConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('bool'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testBoolConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('bool')); + $this->mock->foo(1); + Mockery::close(); + } + + public function testCallableConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('callable'))->once(); + $this->mock->foo(function () { + return 'f'; + }); + } + + public function testCallableConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('callable'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testCallableConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('callable')); + $this->mock->foo(1); + Mockery::close(); + } + + public function testDoubleConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('double'))->once(); + $this->mock->foo(2.25); + } + + public function testDoubleConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('double'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testDoubleConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('double')); + $this->mock->foo(1); + Mockery::close(); + } + + public function testFloatConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('float'))->once(); + $this->mock->foo(2.25); + } + + public function testFloatConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('float'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testFloatConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('float')); + $this->mock->foo(1); + Mockery::close(); + } + + public function testIntConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('int'))->once(); + $this->mock->foo(2); + } + + public function testIntConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('int'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testIntConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('int')); + $this->mock->foo('f'); + Mockery::close(); + } + + public function testLongConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('long'))->once(); + $this->mock->foo(2); + } + + public function testLongConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('long'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testLongConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('long')); + $this->mock->foo('f'); + Mockery::close(); + } + + public function testNullConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('null'))->once(); + $this->mock->foo(null); + } + + public function testNullConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('null'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testNullConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('null')); + $this->mock->foo('f'); + Mockery::close(); + } + + public function testNumericConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('numeric'))->once(); + $this->mock->foo('2'); + } + + public function testNumericConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('numeric'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testNumericConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('numeric')); + $this->mock->foo('f'); + Mockery::close(); + } + + public function testObjectConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('object'))->once(); + $this->mock->foo(new stdClass); + } + + public function testObjectConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('object`'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testObjectConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('object')); + $this->mock->foo('f'); + Mockery::close(); + } + + public function testRealConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('real'))->once(); + $this->mock->foo(2.25); + } + + public function testRealConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('real'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testRealConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('real')); + $this->mock->foo('f'); + Mockery::close(); + } + + public function testResourceConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('resource'))->once(); + $r = fopen(dirname(__FILE__) . '/_files/file.txt', 'r'); + $this->mock->foo($r); + } + + public function testResourceConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('resource'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testResourceConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('resource')); + $this->mock->foo('f'); + Mockery::close(); + } + + public function testScalarConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('scalar'))->once(); + $this->mock->foo(2); + } + + public function testScalarConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('scalar'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testScalarConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('scalar')); + $this->mock->foo(array()); + Mockery::close(); + } + + public function testStringConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('string'))->once(); + $this->mock->foo('2'); + } + + public function testStringConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('string'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testStringConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('string')); + $this->mock->foo(1); + Mockery::close(); + } + + public function testClassConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('stdClass'))->once(); + $this->mock->foo(new stdClass); + } + + public function testClassConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::type('stdClass'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testClassConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::type('stdClass')); + $this->mock->foo(new Exception); + Mockery::close(); + } + + public function testDucktypeConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::ducktype('quack', 'swim'))->once(); + $this->mock->foo(new Mockery_Duck); + } + + public function testDucktypeConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::ducktype('quack', 'swim'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testDucktypeConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::ducktype('quack', 'swim')); + $this->mock->foo(new Mockery_Duck_Nonswimmer); + Mockery::close(); + } + + public function testArrayContentConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::subset(array('a'=>1, 'b'=>2)))->once(); + $this->mock->foo(array('a'=>1, 'b'=>2, 'c'=>3)); + } + + public function testArrayContentConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::subset(array('a'=>1, 'b'=>2)))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testArrayContentConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::subset(array('a'=>1, 'b'=>2))); + $this->mock->foo(array('a'=>1, 'c'=>3)); + Mockery::close(); + } + + public function testContainsConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::contains(1, 2))->once(); + $this->mock->foo(array('a'=>1, 'b'=>2, 'c'=>3)); + } + + public function testContainsConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::contains(1, 2))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testContainsConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::contains(1, 2)); + $this->mock->foo(array('a'=>1, 'c'=>3)); + Mockery::close(); + } + + public function testHasKeyConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::hasKey('c'))->once(); + $this->mock->foo(array('a'=>1, 'b'=>2, 'c'=>3)); + } + + public function testHasKeyConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::hasKey('a'))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, array('a'=>1), 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testHasKeyConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::hasKey('c')); + $this->mock->foo(array('a'=>1, 'b'=>3)); + Mockery::close(); + } + + public function testHasValueConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::hasValue(1))->once(); + $this->mock->foo(array('a'=>1, 'b'=>2, 'c'=>3)); + } + + public function testHasValueConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::hasValue(1))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, array('a'=>1), 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testHasValueConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::hasValue(2)); + $this->mock->foo(array('a'=>1, 'b'=>3)); + Mockery::close(); + } + + public function testOnConstraintMatchesArgument_ClosureEvaluatesToTrue() + { + $function = function ($arg) { + return $arg % 2 == 0; + }; + $this->mock->shouldReceive('foo')->with(Mockery::on($function))->once(); + $this->mock->foo(4); + } + + public function testOnConstraintMatchesArgumentOfTypeArray_ClosureEvaluatesToTrue() + { + $function = function ($arg) { + return is_array($arg); + }; + $this->mock->shouldReceive('foo')->with(Mockery::on($function))->once(); + $this->mock->foo([4, 5]); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testOnConstraintThrowsExceptionWhenConstraintUnmatched_ClosureEvaluatesToFalse() + { + $function = function ($arg) { + return $arg % 2 == 0; + }; + $this->mock->shouldReceive('foo')->with(Mockery::on($function)); + $this->mock->foo(5); + Mockery::close(); + } + + public function testMustBeConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::mustBe(2))->once(); + $this->mock->foo(2); + } + + public function testMustBeConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::mustBe(2))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testMustBeConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::mustBe(2)); + $this->mock->foo('2'); + Mockery::close(); + } + + public function testMustBeConstraintMatchesObjectArgumentWithEqualsComparisonNotIdentical() + { + $a = new stdClass; + $a->foo = 1; + $b = new stdClass; + $b->foo = 1; + $this->mock->shouldReceive('foo')->with(Mockery::mustBe($a))->once(); + $this->mock->foo($b); + } + + public function testMustBeConstraintNonMatchingCaseWithObject() + { + $a = new stdClass; + $a->foo = 1; + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::mustBe($a))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, $a, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testMustBeConstraintThrowsExceptionWhenConstraintUnmatchedWithObject() + { + $a = new stdClass; + $a->foo = 1; + $b = new stdClass; + $b->foo = 2; + $this->mock->shouldReceive('foo')->with(Mockery::mustBe($a)); + $this->mock->foo($b); + Mockery::close(); + } + + public function testMatchPrecedenceBasedOnExpectedCallsFavouringExplicitMatch() + { + $this->mock->shouldReceive('foo')->with(1)->once(); + $this->mock->shouldReceive('foo')->with(Mockery::any())->never(); + $this->mock->foo(1); + } + + public function testMatchPrecedenceBasedOnExpectedCallsFavouringAnyMatch() + { + $this->mock->shouldReceive('foo')->with(Mockery::any())->once(); + $this->mock->shouldReceive('foo')->with(1)->never(); + $this->mock->foo(1); + } + + public function testReturnNullIfIgnoreMissingMethodsSet() + { + $this->mock->shouldIgnoreMissing(); + $this->assertNull($this->mock->g(1, 2)); + } + + public function testReturnUndefinedIfIgnoreMissingMethodsSet() + { + $this->mock->shouldIgnoreMissing()->asUndefined(); + $this->assertInstanceOf(\Mockery\Undefined::class, $this->mock->g(1, 2)); + } + + public function testReturnAsUndefinedAllowsForInfiniteSelfReturningChain() + { + $this->mock->shouldIgnoreMissing()->asUndefined(); + $this->assertInstanceOf(\Mockery\Undefined::class, $this->mock->g(1, 2)->a()->b()->c()); + } + + public function testShouldIgnoreMissingFluentInterface() + { + $this->assertInstanceOf(\Mockery\MockInterface::class, $this->mock->shouldIgnoreMissing()); + } + + public function testShouldIgnoreMissingAsUndefinedFluentInterface() + { + $this->assertInstanceOf(\Mockery\MockInterface::class, $this->mock->shouldIgnoreMissing()->asUndefined()); + } + + public function testShouldIgnoreMissingAsDefinedProxiesToUndefinedAllowingToString() + { + $this->mock->shouldIgnoreMissing()->asUndefined(); + $this->assertInternalType('string', "{$this->mock->g()}"); + $this->assertInternalType('string', "{$this->mock}"); + } + + public function testShouldIgnoreMissingDefaultReturnValue() + { + $this->mock->shouldIgnoreMissing(1); + $this->assertEquals(1, $this->mock->a()); + } + + /** @issue #253 */ + public function testShouldIgnoreMissingDefaultSelfAndReturnsSelf() + { + $this->mock->shouldIgnoreMissing(\Mockery::self()); + $this->assertSame($this->mock, $this->mock->a()->b()); + } + + public function testToStringMagicMethodCanBeMocked() + { + $this->mock->shouldReceive("__toString")->andReturn('dave'); + $this->assertEquals("{$this->mock}", "dave"); + } + + public function testOptionalMockRetrieval() + { + $m = mock('f')->shouldReceive('foo')->with(1)->andReturn(3)->mock(); + $this->assertInstanceOf(\Mockery\MockInterface::class, $m); + } + + public function testNotConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::not(1))->once(); + $this->mock->foo(2); + } + + public function testNotConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::not(2))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testNotConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::not(2)); + $this->mock->foo(2); + Mockery::close(); + } + + public function testAnyOfConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::anyOf(1, 2))->twice(); + $this->mock->foo(2); + $this->mock->foo(1); + } + + public function testAnyOfConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::anyOf(1, 2))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 2, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testAnyOfConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::anyOf(1, 2)); + $this->mock->foo(3); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testAnyOfConstraintThrowsExceptionWhenTrueIsNotAnExpectedArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::anyOf(1, 2)); + $this->mock->foo(true); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testAnyOfConstraintThrowsExceptionWhenFalseIsNotAnExpectedArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::anyOf(0, 1, 2)); + $this->mock->foo(false); + } + + public function testNotAnyOfConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::notAnyOf(1, 2))->once(); + $this->mock->foo(3); + } + + public function testNotAnyOfConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->times(3); + $this->mock->shouldReceive('foo')->with(1, Mockery::notAnyOf(1, 2))->never(); + $this->mock->foo(); + $this->mock->foo(1); + $this->mock->foo(1, 4, 3); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testNotAnyOfConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::notAnyOf(1, 2)); + $this->mock->foo(2); + Mockery::close(); + } + + public function testPatternConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(Mockery::pattern('/foo.*/'))->once(); + $this->mock->foo('foobar'); + } + + public function testPatternConstraintNonMatchingCase() + { + $this->mock->shouldReceive('foo')->once(); + $this->mock->shouldReceive('foo')->with(Mockery::pattern('/foo.*/'))->never(); + $this->mock->foo('bar'); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testPatternConstraintThrowsExceptionWhenConstraintUnmatched() + { + $this->mock->shouldReceive('foo')->with(Mockery::pattern('/foo.*/')); + $this->mock->foo('bar'); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testGlobalConfigMayForbidMockingNonExistentMethodsOnClasses() + { + \Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + $mock = mock('stdClass'); + $mock->shouldReceive('foo'); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception + * @expectedExceptionMessage Mockery can't find 'SomeMadeUpClass' so can't mock it + */ + public function testGlobalConfigMayForbidMockingNonExistentMethodsOnAutoDeclaredClasses() + { + \Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + $mock = mock('SomeMadeUpClass'); + $mock->shouldReceive('foo'); + Mockery::close(); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testGlobalConfigMayForbidMockingNonExistentMethodsOnObjects() + { + \Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + $mock = mock(new stdClass); + $mock->shouldReceive('foo'); + Mockery::close(); + } + + public function testAnExampleWithSomeExpectationAmends() + { + $service = mock('MyService'); + $service->shouldReceive('login')->with('user', 'pass')->once()->andReturn(true); + $service->shouldReceive('hasBookmarksTagged')->with('php')->once()->andReturn(false); + $service->shouldReceive('addBookmark')->with(Mockery::pattern('/^http:/'), \Mockery::type('string'))->times(3)->andReturn(true); + $service->shouldReceive('hasBookmarksTagged')->with('php')->once()->andReturn(true); + + $this->assertTrue($service->login('user', 'pass')); + $this->assertFalse($service->hasBookmarksTagged('php')); + $this->assertTrue($service->addBookmark('http://example.com/1', 'some_tag1')); + $this->assertTrue($service->addBookmark('http://example.com/2', 'some_tag2')); + $this->assertTrue($service->addBookmark('http://example.com/3', 'some_tag3')); + $this->assertTrue($service->hasBookmarksTagged('php')); + } + + public function testAnExampleWithSomeExpectationAmendsOnCallCounts() + { + $service = mock('MyService'); + $service->shouldReceive('login')->with('user', 'pass')->once()->andReturn(true); + $service->shouldReceive('hasBookmarksTagged')->with('php')->once()->andReturn(false); + $service->shouldReceive('addBookmark')->with(Mockery::pattern('/^http:/'), \Mockery::type('string'))->times(3)->andReturn(true); + $service->shouldReceive('hasBookmarksTagged')->with('php')->twice()->andReturn(true); + + $this->assertTrue($service->login('user', 'pass')); + $this->assertFalse($service->hasBookmarksTagged('php')); + $this->assertTrue($service->addBookmark('http://example.com/1', 'some_tag1')); + $this->assertTrue($service->addBookmark('http://example.com/2', 'some_tag2')); + $this->assertTrue($service->addBookmark('http://example.com/3', 'some_tag3')); + $this->assertTrue($service->hasBookmarksTagged('php')); + $this->assertTrue($service->hasBookmarksTagged('php')); + } + + public function testAnExampleWithSomeExpectationAmendsOnCallCounts_PHPUnitTest() + { + $service = $this->createMock('MyService2'); + $service->expects($this->once())->method('login')->with('user', 'pass')->will($this->returnValue(true)); + $service->expects($this->exactly(3))->method('hasBookmarksTagged')->with('php') + ->will($this->onConsecutiveCalls(false, true, true)); + $service->expects($this->exactly(3))->method('addBookmark') + ->with($this->matchesRegularExpression('/^http:/'), $this->isType('string')) + ->will($this->returnValue(true)); + + $this->assertTrue($service->login('user', 'pass')); + $this->assertFalse($service->hasBookmarksTagged('php')); + $this->assertTrue($service->addBookmark('http://example.com/1', 'some_tag1')); + $this->assertTrue($service->addBookmark('http://example.com/2', 'some_tag2')); + $this->assertTrue($service->addBookmark('http://example.com/3', 'some_tag3')); + $this->assertTrue($service->hasBookmarksTagged('php')); + $this->assertTrue($service->hasBookmarksTagged('php')); + } + + public function testMockedMethodsCallableFromWithinOriginalClass() + { + $mock = mock('MockeryTest_InterMethod1[doThird]'); + $mock->shouldReceive('doThird')->andReturn(true); + $this->assertTrue($mock->doFirst()); + } + + /** + * @group issue #20 + */ + public function testMockingDemeterChainsPassesMockeryExpectationToCompositeExpectation() + { + $mock = mock('Mockery_Demeterowski'); + $mock->shouldReceive('foo->bar->baz')->andReturn('Spam!'); + $demeter = new Mockery_UseDemeter($mock); + $this->assertSame('Spam!', $demeter->doit()); + } + + /** + * @group issue #20 - with args in demeter chain + */ + public function testMockingDemeterChainsPassesMockeryExpectationToCompositeExpectationWithArgs() + { + $mock = mock('Mockery_Demeterowski'); + $mock->shouldReceive('foo->bar->baz')->andReturn('Spam!'); + $demeter = new Mockery_UseDemeter($mock); + $this->assertSame('Spam!', $demeter->doitWithArgs()); + } + + public function testShouldNotReceiveCanBeAddedToCompositeExpectation() + { + $mock = mock('Foo'); + $mock->shouldReceive('a')->once()->andReturn('Spam!') + ->shouldNotReceive('b'); + $mock->a(); + } + + public function testPassthruEnsuresRealMethodCalledForReturnValues() + { + $mock = mock('MockeryTest_SubjectCall1'); + $mock->shouldReceive('foo')->once()->passthru(); + $this->assertEquals('bar', $mock->foo()); + } + + public function testShouldIgnoreMissingExpectationBasedOnArgs() + { + $mock = mock("MyService2")->shouldIgnoreMissing(); + $mock->shouldReceive("hasBookmarksTagged")->with("dave")->once(); + $mock->hasBookmarksTagged("dave"); + $mock->hasBookmarksTagged("padraic"); + } + + public function testMakePartialExpectationBasedOnArgs() + { + $mock = mock("MockeryTest_SubjectCall1")->makePartial(); + + $this->assertEquals('bar', $mock->foo()); + $this->assertEquals('bar', $mock->foo("baz")); + $this->assertEquals('bar', $mock->foo("qux")); + + $mock->shouldReceive("foo")->with("baz")->twice()->andReturn('123'); + $this->assertEquals('bar', $mock->foo()); + $this->assertEquals('123', $mock->foo("baz")); + $this->assertEquals('bar', $mock->foo("qux")); + + $mock->shouldReceive("foo")->withNoArgs()->once()->andReturn('456'); + $this->assertEquals('456', $mock->foo()); + $this->assertEquals('123', $mock->foo("baz")); + $this->assertEquals('bar', $mock->foo("qux")); + } + + public function testCanReturnSelf() + { + $this->mock->shouldReceive("foo")->andReturnSelf(); + $this->assertSame($this->mock, $this->mock->foo()); + } + + public function testReturnsTrueIfTrueIsReturnValue() + { + $this->mock->shouldReceive("foo")->andReturnTrue(); + $this->assertTrue($this->mock->foo()); + } + + public function testReturnsFalseIfFalseIsReturnValue() + { + $this->mock->shouldReceive("foo")->andReturnFalse(); + $this->assertFalse($this->mock->foo()); + } + + public function testExpectationCanBeOverridden() + { + $this->mock->shouldReceive('foo')->once()->andReturn('green'); + $this->mock->shouldReceive('foo')->andReturn('blue'); + $this->assertEquals($this->mock->foo(), 'green'); + $this->assertEquals($this->mock->foo(), 'blue'); + } + + /** + * @expectedException \InvalidArgumentException + */ + public function testTimesExpectationForbidsFloatNumbers() + { + $this->mock->shouldReceive('foo')->times(1.3); + Mockery::close(); + } + + public function testIfExceptionIndicatesAbsenceOfMethodAndExpectationsOnMock() + { + $mock = mock('Mockery_Duck'); + + $this->expectException( + '\BadMethodCallException', + 'Method ' . get_class($mock) . + '::nonExistent() does not exist on this mock object' + ); + + $mock->nonExistent(); + Mockery::close(); + } + + public function testIfCallingMethodWithNoExpectationsHasSpecificExceptionMessage() + { + $mock = mock('Mockery_Duck'); + + $this->expectException( + '\BadMethodCallException', + 'Received ' . get_class($mock) . + '::quack(), ' . 'but no expectations were specified' + ); + + $mock->quack(); + Mockery::close(); + } + + public function testMockShouldNotBeAnonymousWhenImplementingSpecificInterface() + { + $waterMock = mock('IWater'); + $this->assertFalse($waterMock->mockery_isAnonymous()); + } + + /** + * @expectedException \Mockery\Exception + */ + public function testWetherMockWithInterfaceOnlyCanNotImplementNonExistingMethods() + { + \Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + $waterMock = \Mockery::mock('IWater'); + $waterMock + ->shouldReceive('nonExistentMethod') + ->once() + ->andReturnNull(); + \Mockery::close(); + } + + public function testCountWithBecauseExceptionMessage() + { + $this->expectException(InvalidCountException::class); + $this->expectExceptionMessageRegexp( + '/Method foo\(\) from Mockery_[\d]+ should be called' . PHP_EOL . ' ' . + 'exactly 1 times but called 0 times. Because We like foo/' + ); + + $this->mock->shouldReceive('foo')->once()->because('We like foo'); + Mockery::close(); + } + + /** @test */ + public function it_uses_a_matchers_to_string_method_in_the_exception_output() + { + $mock = Mockery::mock(); + + $mock->expects()->foo(Mockery::hasKey('foo')); + + $this->expectException( + InvalidCountException::class, + "Method foo()" + ); + + Mockery::close(); + } +} + +interface IWater +{ + public function dry(); +} + +class MockeryTest_SubjectCall1 +{ + public function foo() + { + return 'bar'; + } +} + +class MockeryTest_InterMethod1 +{ + public function doFirst() + { + return $this->doSecond(); + } + + private function doSecond() + { + return $this->doThird(); + } + + public function doThird() + { + return false; + } +} + +class MyService2 +{ + public function login($user, $pass) + { + } + public function hasBookmarksTagged($tag) + { + } + public function addBookmark($uri, $tag) + { + } +} + +class Mockery_Duck +{ + public function quack() + { + } + public function swim() + { + } +} + +class Mockery_Duck_Nonswimmer +{ + public function quack() + { + } +} + +class Mockery_Demeterowski +{ + public function foo() + { + return $this; + } + public function bar() + { + return $this; + } + public function baz() + { + return 'Ham!'; + } +} + +class Mockery_UseDemeter +{ + public function __construct($demeter) + { + $this->demeter = $demeter; + } + public function doit() + { + return $this->demeter->foo()->bar()->baz(); + } + public function doitWithArgs() + { + return $this->demeter->foo("foo")->bar("bar")->baz("baz"); + } +} + +class MockeryTest_Foo +{ + public function foo() + { + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Fixtures/ClassWithAllLowerCaseMethod.php b/vendor/mockery/mockery/tests/Mockery/Fixtures/ClassWithAllLowerCaseMethod.php new file mode 100644 index 000000000..2cf2b770e --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Fixtures/ClassWithAllLowerCaseMethod.php @@ -0,0 +1,30 @@ + + { + return array('key' => true); + } + + public function HHVMVoid() : ?void + { + return null; + } + + public function HHVMMixed() : mixed + { + return null; + } + + public function HHVMThis() : this + { + return $this; + } + + public function HHVMString() : string + { + return 'a string'; + } + + public function HHVMImmVector() : ImmVector + { + return new ImmVector([1, 2, 3]); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Fixtures/MethodWithIterableTypeHints.php b/vendor/mockery/mockery/tests/Mockery/Fixtures/MethodWithIterableTypeHints.php new file mode 100644 index 000000000..49739c604 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Fixtures/MethodWithIterableTypeHints.php @@ -0,0 +1,29 @@ +assertTrue($target->hasInternalAncestor()); + + $target = new DefinedTargetClass(new \ReflectionClass("Mockery\MockeryTest_ClassThatExtendsArrayObject")); + $this->assertTrue($target->hasInternalAncestor()); + + $target = new DefinedTargetClass(new \ReflectionClass("Mockery\DefinedTargetClassTest")); + $this->assertFalse($target->hasInternalAncestor()); + } +} + +class MockeryTest_ClassThatExtendsArrayObject extends \ArrayObject +{ +} diff --git a/vendor/mockery/mockery/tests/Mockery/Generator/MockConfigurationBuilderTest.php b/vendor/mockery/mockery/tests/Mockery/Generator/MockConfigurationBuilderTest.php new file mode 100644 index 000000000..ac48ac149 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Generator/MockConfigurationBuilderTest.php @@ -0,0 +1,85 @@ +assertContains('__halt_compiler', $builder->getMockConfiguration()->getBlackListedMethods()); + + // need a builtin for this + $this->markTestSkipped("Need a builtin class with a method that is a reserved word"); + } + + /** + * @test + */ + public function magicMethodsAreBlackListedByDefault() + { + $builder = new MockConfigurationBuilder; + $builder->addTarget(ClassWithMagicCall::class); + $methods = $builder->getMockConfiguration()->getMethodsToMock(); + $this->assertCount(1, $methods); + $this->assertEquals("foo", $methods[0]->getName()); + } + + /** @test */ + public function xdebugs_debug_info_is_black_listed_by_default() + { + $builder = new MockConfigurationBuilder; + $builder->addTarget(ClassWithDebugInfo::class); + $methods = $builder->getMockConfiguration()->getMethodsToMock(); + $this->assertCount(1, $methods); + $this->assertEquals("foo", $methods[0]->getName()); + } +} + +class ClassWithMagicCall +{ + public function foo() + { + } + + public function __call($method, $args) + { + } +} + +class ClassWithDebugInfo +{ + public function foo() + { + } + + public function __debugInfo() + { + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Generator/MockConfigurationTest.php b/vendor/mockery/mockery/tests/Mockery/Generator/MockConfigurationTest.php new file mode 100644 index 000000000..d32ac581e --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Generator/MockConfigurationTest.php @@ -0,0 +1,218 @@ +getMethodsToMock(); + $this->assertCount(1, $methods); + $this->assertEquals("bar", $methods[0]->getName()); + } + + /** + * @test + */ + public function blackListsAreCaseInsensitive() + { + $config = new MockConfiguration(array("Mockery\Generator\\TestSubject"), array("FOO")); + + $methods = $config->getMethodsToMock(); + $this->assertCount(1, $methods); + $this->assertEquals("bar", $methods[0]->getName()); + } + + + /** + * @test + */ + public function onlyWhiteListedMethodsShouldBeInListToBeMocked() + { + $config = new MockConfiguration(array("Mockery\Generator\\TestSubject"), array(), array('foo')); + + $methods = $config->getMethodsToMock(); + $this->assertCount(1, $methods); + $this->assertEquals("foo", $methods[0]->getName()); + } + + /** + * @test + */ + public function whitelistOverRulesBlackList() + { + $config = new MockConfiguration(array("Mockery\Generator\\TestSubject"), array("foo"), array("foo")); + + $methods = $config->getMethodsToMock(); + $this->assertCount(1, $methods); + $this->assertEquals("foo", $methods[0]->getName()); + } + + /** + * @test + */ + public function whiteListsAreCaseInsensitive() + { + $config = new MockConfiguration(array("Mockery\Generator\\TestSubject"), array(), array("FOO")); + + $methods = $config->getMethodsToMock(); + $this->assertCount(1, $methods); + $this->assertEquals("foo", $methods[0]->getName()); + } + + /** + * @test + */ + public function finalMethodsAreExcluded() + { + $config = new MockConfiguration(array("Mockery\Generator\\ClassWithFinalMethod")); + + $methods = $config->getMethodsToMock(); + $this->assertCount(1, $methods); + $this->assertEquals("bar", $methods[0]->getName()); + } + + /** + * @test + */ + public function shouldIncludeMethodsFromAllTargets() + { + $config = new MockConfiguration(array("Mockery\\Generator\\TestInterface", "Mockery\\Generator\\TestInterface2")); + $methods = $config->getMethodsToMock(); + $this->assertCount(2, $methods); + } + + /** + * @test + * @expectedException Mockery\Exception + */ + public function shouldThrowIfTargetClassIsFinal() + { + $config = new MockConfiguration(array("Mockery\\Generator\\TestFinal")); + $config->getTargetClass(); + } + + /** + * @test + */ + public function shouldTargetIteratorAggregateIfTryingToMockTraversable() + { + $config = new MockConfiguration(array("\\Traversable")); + + $interfaces = $config->getTargetInterfaces(); + $this->assertCount(1, $interfaces); + $first = array_shift($interfaces); + $this->assertEquals("IteratorAggregate", $first->getName()); + } + + /** + * @test + */ + public function shouldTargetIteratorAggregateIfTraversableInTargetsTree() + { + $config = new MockConfiguration(array("Mockery\Generator\TestTraversableInterface")); + + $interfaces = $config->getTargetInterfaces(); + $this->assertCount(2, $interfaces); + $this->assertEquals("IteratorAggregate", $interfaces[0]->getName()); + $this->assertEquals("Mockery\Generator\TestTraversableInterface", $interfaces[1]->getName()); + } + + /** + * @test + */ + public function shouldBringIteratorToHeadOfTargetListIfTraversablePresent() + { + $config = new MockConfiguration(array("Mockery\Generator\TestTraversableInterface2")); + + $interfaces = $config->getTargetInterfaces(); + $this->assertCount(2, $interfaces); + $this->assertEquals("Iterator", $interfaces[0]->getName()); + $this->assertEquals("Mockery\Generator\TestTraversableInterface2", $interfaces[1]->getName()); + } + + /** + * @test + */ + public function shouldBringIteratorAggregateToHeadOfTargetListIfTraversablePresent() + { + $config = new MockConfiguration(array("Mockery\Generator\TestTraversableInterface3")); + + $interfaces = $config->getTargetInterfaces(); + $this->assertCount(2, $interfaces); + $this->assertEquals("IteratorAggregate", $interfaces[0]->getName()); + $this->assertEquals("Mockery\Generator\TestTraversableInterface3", $interfaces[1]->getName()); + } +} + +interface TestTraversableInterface extends \Traversable +{ +} +interface TestTraversableInterface2 extends \Traversable, \Iterator +{ +} +interface TestTraversableInterface3 extends \Traversable, \IteratorAggregate +{ +} + +final class TestFinal +{ +} + +interface TestInterface +{ + public function foo(); +} + +interface TestInterface2 +{ + public function bar(); +} + +class TestSubject +{ + public function foo() + { + } + + public function bar() + { + } +} + +class ClassWithFinalMethod +{ + final public function foo() + { + } + + public function bar() + { + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/CallTypeHintPassTest.php b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/CallTypeHintPassTest.php new file mode 100644 index 000000000..6ce54e961 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/CallTypeHintPassTest.php @@ -0,0 +1,59 @@ + true, + ))->makePartial(); + $code = $pass->apply(static::CODE, $config); + $this->assertContains('__call($method, $args)', $code); + } + + /** + * @test + */ + public function shouldRemoveCallStaticTypeHintIfRequired() + { + $pass = new CallTypeHintPass; + $config = m::mock("Mockery\Generator\MockConfiguration", array( + "requiresCallStaticTypeHintRemoval" => true, + ))->makePartial(); + $code = $pass->apply(static::CODE, $config); + $this->assertContains('__callStatic($method, $args)', $code); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/ClassNamePassTest.php b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/ClassNamePassTest.php new file mode 100644 index 000000000..d9209b865 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/ClassNamePassTest.php @@ -0,0 +1,78 @@ +pass = new ClassNamePass(); + } + + /** + * @test + */ + public function shouldRemoveNamespaceDefinition() + { + $config = new MockConfiguration(array(), array(), array(), "Dave\Dave"); + $code = $this->pass->apply(static::CODE, $config); + $this->assertNotContains('namespace Mockery;', $code); + } + + /** + * @test + */ + public function shouldReplaceNamespaceIfClassNameIsNamespaced() + { + $config = new MockConfiguration(array(), array(), array(), "Dave\Dave"); + $code = $this->pass->apply(static::CODE, $config); + $this->assertNotContains('namespace Mockery;', $code); + $this->assertContains('namespace Dave;', $code); + } + + /** + * @test + */ + public function shouldReplaceClassNameWithSpecifiedName() + { + $config = new MockConfiguration(array(), array(), array(), "Dave"); + $code = $this->pass->apply(static::CODE, $config); + $this->assertContains('class Dave', $code); + } + + /** + * @test + */ + public function shouldRemoveLeadingBackslashesFromNamespace() + { + $config = new MockConfiguration(array(), array(), array(), "\Dave\Dave"); + $code = $this->pass->apply(static::CODE, $config); + $this->assertContains('namespace Dave;', $code); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/ConstantsPassTest.php b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/ConstantsPassTest.php new file mode 100644 index 000000000..ae907bca8 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/ConstantsPassTest.php @@ -0,0 +1,52 @@ + ['FOO' => 'test']] + ); + $code = $pass->apply(static::CODE, $config); + $this->assertContains("const FOO = 'test'", $code); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/InstanceMockPassTest.php b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/InstanceMockPassTest.php new file mode 100644 index 000000000..94be52666 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/InstanceMockPassTest.php @@ -0,0 +1,45 @@ +setInstanceMock(true); + $config = $builder->getMockConfiguration(); + $pass = new InstanceMockPass; + $code = $pass->apply('class Dave { }', $config); + $this->assertContains('public function __construct', $code); + $this->assertContains('protected $_mockery_ignoreVerification', $code); + $this->assertContains('this->_mockery_constructorCalled(func_get_args());', $code); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/InterfacePassTest.php b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/InterfacePassTest.php new file mode 100644 index 000000000..99301652a --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Generator/StringManipulation/Pass/InterfacePassTest.php @@ -0,0 +1,66 @@ + array(), + )); + + $code = $pass->apply(static::CODE, $config); + $this->assertEquals(static::CODE, $code); + } + + /** + * @test + */ + public function shouldAddAnyInterfaceNamesToImplementsDefinition() + { + $pass = new InterfacePass; + + $config = m::mock("Mockery\Generator\MockConfiguration", array( + "getTargetInterfaces" => array( + m::mock(array("getName" => "Dave\Dave")), + m::mock(array("getName" => "Paddy\Paddy")), + ), + )); + + $code = $pass->apply(static::CODE, $config); + + $this->assertContains("implements MockInterface, \Dave\Dave, \Paddy\Paddy", $code); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/GlobalHelpersTest.php b/vendor/mockery/mockery/tests/Mockery/GlobalHelpersTest.php new file mode 100644 index 000000000..0f2b7c4a6 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/GlobalHelpersTest.php @@ -0,0 +1,63 @@ +assertInstanceOf(\Mockery\MockInterface::class, $double); + $this->expectException(\Exception::class); + $double->foo(); + } + + /** @test */ + public function spy_creates_a_spy() + { + $double = spy(); + + $this->assertInstanceOf(\Mockery\MockInterface::class, $double); + $double->foo(); + } + + /** @test */ + public function named_mock_creates_a_named_mock() + { + $className = "Class".uniqid(); + $double = namedMock($className); + + $this->assertInstanceOf(\Mockery\MockInterface::class, $double); + $this->assertInstanceOf($className, $double); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/HamcrestExpectationTest.php b/vendor/mockery/mockery/tests/Mockery/HamcrestExpectationTest.php new file mode 100644 index 000000000..659397c0f --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/HamcrestExpectationTest.php @@ -0,0 +1,62 @@ +mock = mock('foo'); + } + + + public function tearDown() + { + \Mockery::getConfiguration()->allowMockingNonExistentMethods(true); + parent::tearDown(); + } + + /** Just a quickie roundup of a few Hamcrest matchers to check nothing obvious out of place **/ + + public function testAnythingConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(anything())->once(); + $this->mock->foo(2); + } + + public function testGreaterThanConstraintMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(greaterThan(1))->once(); + $this->mock->foo(2); + } + + /** + * @expectedException Mockery\Exception + */ + public function testGreaterThanConstraintNotMatchesArgument() + { + $this->mock->shouldReceive('foo')->with(greaterThan(1)); + $this->mock->foo(1); + Mockery::close(); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Loader/EvalLoaderTest.php b/vendor/mockery/mockery/tests/Mockery/Loader/EvalLoaderTest.php new file mode 100644 index 000000000..025a1dab7 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Loader/EvalLoaderTest.php @@ -0,0 +1,35 @@ +getLoader()->load($definition); + + $this->assertTrue(class_exists($className)); + } + + abstract public function getLoader(); +} diff --git a/vendor/mockery/mockery/tests/Mockery/Loader/RequireLoaderTest.php b/vendor/mockery/mockery/tests/Mockery/Loader/RequireLoaderTest.php new file mode 100644 index 000000000..9f0664a34 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Loader/RequireLoaderTest.php @@ -0,0 +1,35 @@ +assertionFailedError = '\PHPUnit\Framework\AssertionFailedError'; + $this->frameworkConstraint = '\PHPUnit\Framework\Constraint'; + } else { + $this->assertionFailedError = '\PHPUnit_Framework_AssertionFailedError'; + $this->frameworkConstraint = '\PHPUnit_Framework_Constraint'; + } + + $this->constraint = \Mockery::mock($this->frameworkConstraint); + $this->matcher = new PHPUnitConstraint($this->constraint); + $this->rethrowingMatcher = new PHPUnitConstraint($this->constraint, true); + } + + public function testMatches() + { + $value1 = 'value1'; + $value2 = 'value1'; + $value3 = 'value1'; + $this->constraint + ->shouldReceive('evaluate') + ->once() + ->with($value1) + ->getMock() + ->shouldReceive('evaluate') + ->once() + ->with($value2) + ->andThrow($this->assertionFailedError) + ->getMock() + ->shouldReceive('evaluate') + ->once() + ->with($value3) + ->getMock() + ; + $this->assertTrue($this->matcher->match($value1)); + $this->assertFalse($this->matcher->match($value2)); + $this->assertTrue($this->rethrowingMatcher->match($value3)); + } + + public function testMatchesWhereNotMatchAndRethrowing() + { + $this->expectException($this->assertionFailedError); + $value = 'value'; + $this->constraint + ->shouldReceive('evaluate') + ->once() + ->with($value) + ->andThrow($this->assertionFailedError) + ; + $this->rethrowingMatcher->match($value); + } + + public function test__toString() + { + $this->assertEquals('', $this->matcher); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Matcher/SubsetTest.php b/vendor/mockery/mockery/tests/Mockery/Matcher/SubsetTest.php new file mode 100644 index 000000000..e45e17cf3 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Matcher/SubsetTest.php @@ -0,0 +1,97 @@ + 123]); + + $actual = [ + 'foo' => 'bar', + 'dave' => 123, + 'bar' => 'baz', + ]; + + $this->assertTrue($matcher->match($actual)); + } + + /** @test */ + public function it_recursively_matches() + { + $matcher = Subset::strict(['foo' => ['bar' => ['baz' => 123]]]); + + $actual = [ + 'foo' => [ + 'bar' => [ + 'baz' => 123, + ] + ], + 'dave' => 123, + 'bar' => 'baz', + ]; + + $this->assertTrue($matcher->match($actual)); + } + + /** @test */ + public function it_is_strict_by_default() + { + $matcher = new Subset(['dave' => 123]); + + $actual = [ + 'foo' => 'bar', + 'dave' => 123.0, + 'bar' => 'baz', + ]; + + $this->assertFalse($matcher->match($actual)); + } + + /** @test */ + public function it_can_run_a_loose_comparison() + { + $matcher = Subset::loose(['dave' => 123]); + + $actual = [ + 'foo' => 'bar', + 'dave' => 123.0, + 'bar' => 'baz', + ]; + + $this->assertTrue($matcher->match($actual)); + } + + /** @test */ + public function it_returns_false_if_actual_is_not_an_array() + { + $matcher = new Subset(['dave' => 123]); + + $actual = null; + + $this->assertFalse($matcher->match($actual)); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockClassWithFinalWakeupTest.php b/vendor/mockery/mockery/tests/Mockery/MockClassWithFinalWakeupTest.php new file mode 100644 index 000000000..f84b30d35 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockClassWithFinalWakeupTest.php @@ -0,0 +1,94 @@ + + * @license http://github.com/padraic/mockery/blob/master/LICENSE New BSD License + */ + +namespace test\Mockery; + +use Mockery\Adapter\Phpunit\MockeryTestCase; + +class MockClassWithFinalWakeupTest extends MockeryTestCase +{ + protected function setUp() + { + $this->container = new \Mockery\Container; + } + + protected function tearDown() + { + $this->container->mockery_close(); + } + + /** + * @test + * + * Test that we are able to create partial mocks of classes that have + * a __wakeup method marked as final. As long as __wakeup is not one of the + * mocked methods. + */ + public function testCreateMockForClassWithFinalWakeup() + { + $mock = $this->container->mock("test\Mockery\TestWithFinalWakeup"); + $this->assertInstanceOf("test\Mockery\TestWithFinalWakeup", $mock); + $this->assertEquals('test\Mockery\TestWithFinalWakeup::__wakeup', $mock->__wakeup()); + + $mock = $this->container->mock('test\Mockery\SubclassWithFinalWakeup'); + $this->assertInstanceOf('test\Mockery\SubclassWithFinalWakeup', $mock); + $this->assertEquals('test\Mockery\TestWithFinalWakeup::__wakeup', $mock->__wakeup()); + } + + public function testCreateMockForClassWithNonFinalWakeup() + { + $mock = $this->container->mock('test\Mockery\TestWithNonFinalWakeup'); + $this->assertInstanceOf('test\Mockery\TestWithNonFinalWakeup', $mock); + + // Make sure __wakeup is overridden and doesn't return anything. + $this->assertNull($mock->__wakeup()); + } +} + +class TestWithFinalWakeup +{ + public function foo() + { + return 'foo'; + } + + public function bar() + { + return 'bar'; + } + + final public function __wakeup() + { + return __METHOD__; + } +} + +class SubclassWithFinalWakeup extends TestWithFinalWakeup +{ +} + +class TestWithNonFinalWakeup +{ + public function __wakeup() + { + return __METHOD__; + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockClassWithMethodOverloadingTest.php b/vendor/mockery/mockery/tests/Mockery/MockClassWithMethodOverloadingTest.php new file mode 100644 index 000000000..b0284dc0c --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockClassWithMethodOverloadingTest.php @@ -0,0 +1,43 @@ +makePartial(); + $this->assertInstanceOf('test\Mockery\TestWithMethodOverloading', $mock); + + // TestWithMethodOverloading::__call wouldn't be used. See Gotchas!. + $mock->randomMethod(); + } + + public function testCreateMockForClassWithMethodOverloadingWithExistingMethod() + { + $mock = mock('test\Mockery\TestWithMethodOverloading') + ->makePartial(); + $this->assertInstanceOf('test\Mockery\TestWithMethodOverloading', $mock); + + $this->assertSame(1, $mock->thisIsRealMethod()); + } +} + +class TestWithMethodOverloading +{ + public function __call($name, $arguments) + { + return 1; + } + + public function thisIsRealMethod() + { + return 1; + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockClassWithUnknownTypeHintTest.php b/vendor/mockery/mockery/tests/Mockery/MockClassWithUnknownTypeHintTest.php new file mode 100644 index 000000000..8706f8d79 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockClassWithUnknownTypeHintTest.php @@ -0,0 +1,43 @@ +assertInstanceOf(MockInterface::class, $mock); + } +} + +class HasUnknownClassAsTypeHintOnMethod +{ + public function foo(\UnknownTestClass\Bar $bar) + { + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockTest.php b/vendor/mockery/mockery/tests/Mockery/MockTest.php new file mode 100644 index 000000000..15b4b7be3 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockTest.php @@ -0,0 +1,219 @@ +allowMockingNonExistentMethods(false); + $m = mock(); + $m->shouldReceive("test123")->andReturn(true); + assertThat($m->test123(), equalTo(true)); + \Mockery::getConfiguration()->allowMockingNonExistentMethods(true); + } + + public function testMockWithNotAllowingMockingOfNonExistentMethodsCanBeGivenAdditionalMethodsToMockEvenIfTheyDontExistOnClass() + { + \Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + $m = mock('ExampleClassForTestingNonExistentMethod'); + $m->shouldAllowMockingMethod('testSomeNonExistentMethod'); + $m->shouldReceive("testSomeNonExistentMethod")->andReturn(true); + assertThat($m->testSomeNonExistentMethod(), equalTo(true)); + \Mockery::getConfiguration()->allowMockingNonExistentMethods(true); + } + + public function testShouldAllowMockingMethodReturnsMockInstance() + { + $m = Mockery::mock('someClass'); + $this->assertInstanceOf('Mockery\MockInterface', $m->shouldAllowMockingMethod('testFunction')); + } + + public function testShouldAllowMockingProtectedMethodReturnsMockInstance() + { + $m = Mockery::mock('someClass'); + $this->assertInstanceOf('Mockery\MockInterface', $m->shouldAllowMockingProtectedMethods('testFunction')); + } + + public function testMockAddsToString() + { + $mock = mock('ClassWithNoToString'); + $this->assertTrue(method_exists($mock, '__toString')); + } + + public function testMockToStringMayBeDeferred() + { + $mock = mock('ClassWithToString')->makePartial(); + $this->assertEquals("foo", (string)$mock); + } + + public function testMockToStringShouldIgnoreMissingAlwaysReturnsString() + { + $mock = mock('ClassWithNoToString')->shouldIgnoreMissing(); + $this->assertNotEquals('', (string)$mock); + + $mock->asUndefined(); + $this->assertNotEquals('', (string)$mock); + } + + public function testShouldIgnoreMissing() + { + $mock = mock('ClassWithNoToString')->shouldIgnoreMissing(); + $this->assertNull($mock->nonExistingMethod()); + } + + /** + * @expectedException Mockery\Exception + */ + public function testShouldIgnoreMissingDisallowMockingNonExistentMethodsUsingGlobalConfiguration() + { + Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + $mock = mock('ClassWithMethods')->shouldIgnoreMissing(); + $mock->shouldReceive('nonExistentMethod'); + } + + /** + * @expectedException BadMethodCallException + */ + public function testShouldIgnoreMissingCallingNonExistentMethodsUsingGlobalConfiguration() + { + Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + $mock = mock('ClassWithMethods')->shouldIgnoreMissing(); + $mock->nonExistentMethod(); + } + + public function testShouldIgnoreMissingCallingExistentMethods() + { + Mockery::getConfiguration()->allowMockingNonExistentMethods(false); + $mock = mock('ClassWithMethods')->shouldIgnoreMissing(); + assertThat(nullValue($mock->foo())); + $mock->shouldReceive('bar')->passthru(); + assertThat($mock->bar(), equalTo('bar')); + } + + public function testShouldIgnoreMissingCallingNonExistentMethods() + { + Mockery::getConfiguration()->allowMockingNonExistentMethods(true); + $mock = mock('ClassWithMethods')->shouldIgnoreMissing(); + assertThat(nullValue($mock->foo())); + assertThat(nullValue($mock->bar())); + assertThat(nullValue($mock->nonExistentMethod())); + + $mock->shouldReceive(array('foo' => 'new_foo', 'nonExistentMethod' => 'result')); + $mock->shouldReceive('bar')->passthru(); + assertThat($mock->foo(), equalTo('new_foo')); + assertThat($mock->bar(), equalTo('bar')); + assertThat($mock->nonExistentMethod(), equalTo('result')); + } + + public function testCanMockException() + { + $exception = Mockery::mock('Exception'); + $this->assertInstanceOf('Exception', $exception); + } + + public function testCanMockSubclassOfException() + { + $errorException = Mockery::mock('ErrorException'); + $this->assertInstanceOf('ErrorException', $errorException); + $this->assertInstanceOf('Exception', $errorException); + } + + public function testCallingShouldReceiveWithoutAValidMethodName() + { + $mock = Mockery::mock(); + + $this->expectException("InvalidArgumentException", "Received empty method name"); + $mock->shouldReceive(""); + } + + /** + * @expectedException Mockery\Exception + */ + public function testShouldThrowExceptionWithInvalidClassName() + { + mock('ClassName.CannotContainDot'); + } + + + /** @test */ + public function expectation_count_will_count_expectations() + { + $mock = new Mock(); + $mock->shouldReceive("doThis")->once(); + $mock->shouldReceive("doThat")->once(); + + $this->assertEquals(2, $mock->mockery_getExpectationCount()); + } + + /** @test */ + public function expectation_count_will_ignore_defaults_if_overriden() + { + $mock = new Mock(); + $mock->shouldReceive("doThis")->once()->byDefault(); + $mock->shouldReceive("doThis")->twice(); + $mock->shouldReceive("andThis")->twice(); + + $this->assertEquals(2, $mock->mockery_getExpectationCount()); + } + + /** @test */ + public function expectation_count_will_count_defaults_if_not_overriden() + { + $mock = new Mock(); + $mock->shouldReceive("doThis")->once()->byDefault(); + $mock->shouldReceive("doThat")->once()->byDefault(); + + $this->assertEquals(2, $mock->mockery_getExpectationCount()); + } +} + + +class ExampleClassForTestingNonExistentMethod +{ +} + +class ClassWithToString +{ + public function __toString() + { + return 'foo'; + } +} + +class ClassWithNoToString +{ +} + +class ClassWithMethods +{ + public function foo() + { + return 'foo'; + } + + public function bar() + { + return 'bar'; + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockeryCanMockClassesWithSemiReservedWordsTest.php b/vendor/mockery/mockery/tests/Mockery/MockeryCanMockClassesWithSemiReservedWordsTest.php new file mode 100644 index 000000000..fe8ed916c --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockeryCanMockClassesWithSemiReservedWordsTest.php @@ -0,0 +1,28 @@ +shouldReceive("include")->andReturn("foo"); + + $this->assertTrue(method_exists($mock, "include")); + $this->assertEquals("foo", $mock->include()); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockeryCanMockMultipleInterfacesWhichOverlapTest.php b/vendor/mockery/mockery/tests/Mockery/MockeryCanMockMultipleInterfacesWhichOverlapTest.php new file mode 100644 index 000000000..6f494283c --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockeryCanMockMultipleInterfacesWhichOverlapTest.php @@ -0,0 +1,65 @@ +mock('Mockery\Tests\Evenement_EventEmitter', 'Mockery\Tests\Chatroulette_ConnectionInterface'); + } +} + +interface Evenement_EventEmitterInterface +{ + public function on($name, $callback); +} + +class Evenement_EventEmitter implements Evenement_EventEmitterInterface +{ + public function on($name, $callback) + { + } +} + +interface React_StreamInterface extends Evenement_EventEmitterInterface +{ + public function close(); +} + +interface React_ReadableStreamInterface extends React_StreamInterface +{ + public function pause(); +} + +interface React_WritableStreamInterface extends React_StreamInterface +{ + public function write($data); +} + +interface Chatroulette_ConnectionInterface extends React_ReadableStreamInterface, React_WritableStreamInterface +{ +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingAllLowerCasedMethodsTest.php b/vendor/mockery/mockery/tests/Mockery/MockingAllLowerCasedMethodsTest.php new file mode 100644 index 000000000..295ae6ca8 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingAllLowerCasedMethodsTest.php @@ -0,0 +1,43 @@ +shouldReceive('userExpectsCamelCaseMethod') + ->andReturn('mocked'); + + $result = $mock->userExpectsCamelCaseMethod(); + + $expected = 'mocked'; + + self::assertSame($expected, $result); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingClassConstantsTest.php b/vendor/mockery/mockery/tests/Mockery/MockingClassConstantsTest.php new file mode 100644 index 000000000..4cb7b839c --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingClassConstantsTest.php @@ -0,0 +1,43 @@ +setConstantsMap([ + 'ClassWithConstants' => [ + 'FOO' => 'baz', + 'X' => 2, + ] + ]); + + $mock = \Mockery::mock('overload:ClassWithConstants'); + + self::assertEquals('baz', $mock::FOO); + self::assertEquals(2, $mock::X); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingHHVMMethodsTest.php b/vendor/mockery/mockery/tests/Mockery/MockingHHVMMethodsTest.php new file mode 100644 index 000000000..7377f1608 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingHHVMMethodsTest.php @@ -0,0 +1,107 @@ +isHHVM()) { + $this->markTestSkipped('For HHVM test only'); + } + + parent::setUp(); + + require_once __DIR__."/Fixtures/MethodWithHHVMReturnType.php"; + } + + /** @test */ + public function it_strip_hhvm_array_return_types() + { + $mock = mock('test\Mockery\Fixtures\MethodWithHHVMReturnType'); + + $mock->shouldReceive('nullableHHVMArray')->andReturn(array('key' => true)); + $mock->nullableHHVMArray(); + } + + /** @test */ + public function it_strip_hhvm_void_return_types() + { + $mock = mock('test\Mockery\Fixtures\MethodWithHHVMReturnType'); + + $mock->shouldReceive('HHVMVoid')->andReturnNull(); + $mock->HHVMVoid(); + } + + /** @test */ + public function it_strip_hhvm_mixed_return_types() + { + $mock = mock('test\Mockery\Fixtures\MethodWithHHVMReturnType'); + + $mock->shouldReceive('HHVMMixed')->andReturnNull(); + $mock->HHVMMixed(); + } + + /** @test */ + public function it_strip_hhvm_this_return_types() + { + $mock = mock('test\Mockery\Fixtures\MethodWithHHVMReturnType'); + + $mock->shouldReceive('HHVMThis')->andReturn(new MethodWithHHVMReturnType()); + $mock->HHVMThis(); + } + + /** @test */ + public function it_allow_hhvm_string_return_types() + { + $mock = mock('test\Mockery\Fixtures\MethodWithHHVMReturnType'); + + $mock->shouldReceive('HHVMString')->andReturn('a string'); + $mock->HHVMString(); + } + + /** @test */ + public function it_allow_hhvm_imm_vector_return_types() + { + $mock = mock('test\Mockery\Fixtures\MethodWithHHVMReturnType'); + + $mock->shouldReceive('HHVMImmVector')->andReturn(new \HH\ImmVector([1, 2, 3])); + $mock->HHVMImmVector(); + } + + /** + * Returns true when it is HHVM. + */ + private function isHHVM() + { + return \defined('HHVM_VERSION'); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingMethodsWithIterableTypeHintsTest.php b/vendor/mockery/mockery/tests/Mockery/MockingMethodsWithIterableTypeHintsTest.php new file mode 100644 index 000000000..34ef54c00 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingMethodsWithIterableTypeHintsTest.php @@ -0,0 +1,39 @@ +assertInstanceOf(\test\Mockery\Fixtures\MethodWithIterableTypeHints::class, $mock); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingMethodsWithNullableParametersTest.php b/vendor/mockery/mockery/tests/Mockery/MockingMethodsWithNullableParametersTest.php new file mode 100644 index 000000000..e3aa76759 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingMethodsWithNullableParametersTest.php @@ -0,0 +1,52 @@ +assertInstanceOf(\test\Mockery\Fixtures\MethodWithNullableTypedParameter::class, $mock); + } + + /** + * @test + */ + public function it_can_handle_default_parameters() + { + require __DIR__."/Fixtures/MethodWithParametersWithDefaultValues.php"; + $mock = mock("test\Mockery\Fixtures\MethodWithParametersWithDefaultValues"); + + $this->assertInstanceOf(\test\Mockery\Fixtures\MethodWithParametersWithDefaultValues::class, $mock); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingNullableMethodsTest.php b/vendor/mockery/mockery/tests/Mockery/MockingNullableMethodsTest.php new file mode 100644 index 000000000..9b7bdc24a --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingNullableMethodsTest.php @@ -0,0 +1,217 @@ +shouldReceive('nonNullablePrimitive')->andReturn('a string'); + $mock->nonNullablePrimitive(); + } + + /** + * @test + * @expectedException \TypeError + */ + public function itShouldNotAllowNonNullToBeNull() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nonNullablePrimitive')->andReturn(null); + $mock->nonNullablePrimitive(); + } + + /** + * @test + */ + public function itShouldAllowPrimitiveNullableToBeNull() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nullablePrimitive')->andReturn(null); + $mock->nullablePrimitive(); + } + + /** + * @test + */ + public function itShouldAllowPrimitiveNullabeToBeSet() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nullablePrimitive')->andReturn('a string'); + $mock->nullablePrimitive(); + } + + /** + * @test + */ + public function itShouldAllowSelfToBeSet() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nonNullableSelf')->andReturn(new MethodWithNullableReturnType()); + $mock->nonNullableSelf(); + } + + /** + * @test + * @expectedException \TypeError + */ + public function itShouldNotAllowSelfToBeNull() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nonNullableSelf')->andReturn(null); + $mock->nonNullableSelf(); + } + + /** + * @test + */ + public function itShouldAllowNullableSelfToBeSet() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nullableSelf')->andReturn(new MethodWithNullableReturnType()); + $mock->nullableSelf(); + } + + /** + * @test + */ + public function itShouldAllowNullableSelfToBeNull() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nullableSelf')->andReturn(null); + $mock->nullableSelf(); + } + + /** + * @test + */ + public function itShouldAllowClassToBeSet() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nonNullableClass')->andReturn(new MethodWithNullableReturnType()); + $mock->nonNullableClass(); + } + + /** + * @test + * @expectedException \TypeError + */ + public function itShouldNotAllowClassToBeNull() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nonNullableClass')->andReturn(null); + $mock->nonNullableClass(); + } + + /** + * @test + */ + public function itShouldAllowNullalbeClassToBeSet() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nullableClass')->andReturn(new MethodWithNullableReturnType()); + $mock->nullableClass(); + } + + /** + * @test + */ + public function itShouldAllowNullableClassToBeNull() + { + $mock = mock("test\Mockery\Fixtures\MethodWithNullableReturnType"); + + $mock->shouldReceive('nullableClass')->andReturn(null); + $mock->nullableClass(); + } + + /** @test */ + public function it_allows_returning_null_for_nullable_object_return_types() + { + $double= \Mockery::mock(MethodWithNullableReturnType::class); + + $double->shouldReceive("nullableClass")->andReturnNull(); + + $this->assertNull($double->nullableClass()); + } + + /** @test */ + public function it_allows_returning_null_for_nullable_string_return_types() + { + $double= \Mockery::mock(MethodWithNullableReturnType::class); + + $double->shouldReceive("nullableString")->andReturnNull(); + + $this->assertNull($double->nullableString()); + } + + /** @test */ + public function it_allows_returning_null_for_nullable_int_return_types() + { + $double= \Mockery::mock(MethodWithNullableReturnType::class); + + $double->shouldReceive("nullableInt")->andReturnNull(); + + $this->assertNull($double->nullableInt()); + } + + /** @test */ + public function it_returns_null_on_calls_to_ignored_methods_of_spies_if_return_type_is_nullable() + { + $double = \Mockery::spy(MethodWithNullableReturnType::class); + + $this->assertNull($double->nullableClass()); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingProtectedMethodsTest.php b/vendor/mockery/mockery/tests/Mockery/MockingProtectedMethodsTest.php new file mode 100644 index 000000000..7810d1bf4 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingProtectedMethodsTest.php @@ -0,0 +1,133 @@ +assertEquals("bar", $mock->bar()); + } + + /** + * @test + * + * This is a regression test, basically we don't want the mock handling + * interfering with calling protected methods partials + */ + public function shouldAutomaticallyDeferCallsToProtectedMethodsForRuntimePartials() + { + $mock = mock("test\Mockery\TestWithProtectedMethods")->makePartial(); + $this->assertEquals("bar", $mock->bar()); + } + + /** @test */ + public function shouldAutomaticallyIgnoreAbstractProtectedMethods() + { + $mock = mock("test\Mockery\TestWithProtectedMethods")->makePartial(); + $this->assertNull($mock->foo()); + } + + /** @test */ + public function shouldAllowMockingProtectedMethods() + { + $mock = mock("test\Mockery\TestWithProtectedMethods") + ->makePartial() + ->shouldAllowMockingProtectedMethods(); + + $mock->shouldReceive("protectedBar")->andReturn("notbar"); + $this->assertEquals("notbar", $mock->bar()); + } + + /** @test */ + public function shouldAllowMockingProtectedMethodOnDefinitionTimePartial() + { + $mock = mock("test\Mockery\TestWithProtectedMethods[protectedBar]") + ->shouldAllowMockingProtectedMethods(); + + $mock->shouldReceive("protectedBar")->andReturn("notbar"); + $this->assertEquals("notbar", $mock->bar()); + } + + /** @test */ + public function shouldAllowMockingAbstractProtectedMethods() + { + $mock = mock("test\Mockery\TestWithProtectedMethods") + ->makePartial() + ->shouldAllowMockingProtectedMethods(); + + $mock->shouldReceive("abstractProtected")->andReturn("abstractProtected"); + $this->assertEquals("abstractProtected", $mock->foo()); + } + + /** @test */ + public function shouldAllowMockingIncreasedVisabilityMethods() + { + $mock = mock("test\Mockery\TestIncreasedVisibilityChild"); + $mock->shouldReceive('foobar')->andReturn("foobar"); + $this->assertEquals('foobar', $mock->foobar()); + } +} + + +abstract class TestWithProtectedMethods +{ + public function foo() + { + return $this->abstractProtected(); + } + + abstract protected function abstractProtected(); + + public function bar() + { + return $this->protectedBar(); + } + + protected function protectedBar() + { + return 'bar'; + } +} + +class TestIncreasedVisibilityParent +{ + protected function foobar() + { + } +} + +class TestIncreasedVisibilityChild extends TestIncreasedVisibilityParent +{ + public function foobar() + { + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingVariadicArgumentsTest.php b/vendor/mockery/mockery/tests/Mockery/MockingVariadicArgumentsTest.php new file mode 100644 index 000000000..a940f63ad --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingVariadicArgumentsTest.php @@ -0,0 +1,45 @@ +shouldReceive("foo")->andReturn("notbar"); + $this->assertEquals("notbar", $mock->foo()); + } +} + + +abstract class TestWithVariadicArguments +{ + public function foo(...$bar) + { + return $bar; + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/MockingVoidMethodsTest.php b/vendor/mockery/mockery/tests/Mockery/MockingVoidMethodsTest.php new file mode 100644 index 000000000..f1f167a13 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/MockingVoidMethodsTest.php @@ -0,0 +1,53 @@ +assertInstanceOf(\test\Mockery\Fixtures\MethodWithVoidReturnType::class, $mock); + } + + /** @test */ + public function it_can_stub_and_mock_void_methods() + { + $mock = mock("test\Mockery\Fixtures\MethodWithVoidReturnType"); + + $mock->shouldReceive("foo"); + $mock->foo(); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/NamedMockTest.php b/vendor/mockery/mockery/tests/Mockery/NamedMockTest.php new file mode 100644 index 000000000..b39355f20 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/NamedMockTest.php @@ -0,0 +1,86 @@ +assertInstanceOf("Mockery\Dave123", $mock); + } + + /** @test */ + public function itCreatesPassesFurtherArgumentsJustLikeMock() + { + $mock = Mockery::namedMock("Mockery\Dave456", "DateTime", array( + "getDave" => "dave" + )); + + $this->assertInstanceOf("DateTime", $mock); + $this->assertEquals("dave", $mock->getDave()); + } + + /** + * @test + * @expectedException Mockery\Exception + * @expectedExceptionMessage The mock named 'Mockery\Dave7' has been already defined with a different mock configuration + */ + public function itShouldThrowIfAttemptingToRedefineNamedMock() + { + $mock = Mockery::namedMock("Mockery\Dave7"); + $mock = Mockery::namedMock("Mockery\Dave7", "DateTime"); + } + + /** @test */ + public function itCreatesConcreteMethodImplementationWithReturnType() + { + $cactus = new \Nature\Plant(); + $gardener = Mockery::namedMock( + "NewNamespace\\ClassName", + "Gardener", + array('water' => true) + ); + $this->assertTrue($gardener->water($cactus)); + } + + /** + * @test + * @requires PHP 7.0.0 + */ + public function it_gracefully_handles_namespacing() + { + $animal = Mockery::namedMock( + uniqid(Animal::class, false), + Animal::class + ); + + $animal->shouldReceive("habitat")->andReturn(new Habitat()); + + $this->assertInstanceOf(Habitat::class, $animal->habitat()); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/SpyTest.php b/vendor/mockery/mockery/tests/Mockery/SpyTest.php new file mode 100644 index 000000000..73de84c0b --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/SpyTest.php @@ -0,0 +1,152 @@ +myMethod(); + $spy->shouldHaveReceived("myMethod"); + + $this->expectException("Mockery\Exception\InvalidCountException"); + $spy->shouldHaveReceived("someMethodThatWasNotCalled"); + } + + /** @test */ + public function itVerifiesAMethodWasNotCalled() + { + $spy = m::spy(); + $spy->shouldNotHaveReceived("myMethod"); + + $this->expectException("Mockery\Exception\InvalidCountException"); + $spy->myMethod(); + $spy->shouldNotHaveReceived("myMethod"); + } + + /** @test */ + public function itVerifiesAMethodWasNotCalledWithParticularArguments() + { + $spy = m::spy(); + $spy->myMethod(123, 456); + + $spy->shouldNotHaveReceived("myMethod", array(789, 10)); + + $this->expectException("Mockery\Exception\InvalidCountException"); + $spy->shouldNotHaveReceived("myMethod", array(123, 456)); + } + + /** @test */ + public function itVerifiesAMethodWasCalledASpecificNumberOfTimes() + { + $spy = m::spy(); + $spy->myMethod(); + $spy->myMethod(); + $spy->shouldHaveReceived("myMethod")->twice(); + + $this->expectException("Mockery\Exception\InvalidCountException"); + $spy->myMethod(); + $spy->shouldHaveReceived("myMethod")->twice(); + } + + /** @test */ + public function itVerifiesAMethodWasCalledWithSpecificArguments() + { + $spy = m::spy(); + $spy->myMethod(123, "a string"); + $spy->shouldHaveReceived("myMethod")->with(123, "a string"); + $spy->shouldHaveReceived("myMethod", array(123, "a string")); + + $this->expectException("Mockery\Exception\InvalidCountException"); + $spy->shouldHaveReceived("myMethod")->with(123); + } + + /** @test */ + public function itIncrementsExpectationCountWhenShouldHaveReceivedIsUsed() + { + $spy = m::spy(); + $spy->myMethod('param1', 'param2'); + $spy->shouldHaveReceived('myMethod')->with('param1', 'param2'); + $this->assertEquals(1, $spy->mockery_getExpectationCount()); + } + + /** @test */ + public function itIncrementsExpectationCountWhenShouldNotHaveReceivedIsUsed() + { + $spy = m::spy(); + $spy->shouldNotHaveReceived('method'); + $this->assertEquals(1, $spy->mockery_getExpectationCount()); + } + + /** @test */ + public function any_args_can_be_used_with_alternative_syntax() + { + $spy = m::spy(); + $spy->foo(123, 456); + + $spy->shouldHaveReceived()->foo(anyArgs()); + } + + /** @test */ + public function should_have_received_higher_order_message_call_a_method_with_correct_arguments() + { + $spy = m::spy(); + $spy->foo(123); + + $spy->shouldHaveReceived()->foo(123); + } + + /** @test */ + public function should_have_received_higher_order_message_call_a_method_with_incorrect_arguments_throws_exception() + { + $spy = m::spy(); + $spy->foo(123); + + $this->expectException("Mockery\Exception\InvalidCountException"); + $spy->shouldHaveReceived()->foo(456); + } + + /** @test */ + public function should_not_have_received_higher_order_message_call_a_method_with_incorrect_arguments() + { + $spy = m::spy(); + $spy->foo(123); + + $spy->shouldNotHaveReceived()->foo(456); + } + + /** @test */ + public function should_not_have_received_higher_order_message_call_a_method_with_correct_arguments_throws_an_exception() + { + $spy = m::spy(); + $spy->foo(123); + + $this->expectException("Mockery\Exception\InvalidCountException"); + $spy->shouldNotHaveReceived()->foo(123); + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/Stubs/Animal.php b/vendor/mockery/mockery/tests/Mockery/Stubs/Animal.php new file mode 100644 index 000000000..50de12939 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/Stubs/Animal.php @@ -0,0 +1,29 @@ +assertEquals('bar', $trait->foo()); + } + + /** @test */ + public function it_creates_abstract_methods_as_necessary() + { + $trait = mock(TraitWithAbstractMethod::class, ['doBaz' => 'baz']); + + $this->assertEquals('baz', $trait->baz()); + } + + /** @test */ + public function it_can_create_an_object_using_multiple_traits() + { + $trait = mock(SimpleTrait::class, TraitWithAbstractMethod::class, [ + 'doBaz' => 123, + ]); + + $this->assertEquals('bar', $trait->foo()); + $this->assertEquals(123, $trait->baz()); + } +} + +trait SimpleTrait +{ + public function foo() + { + return 'bar'; + } +} + +trait TraitWithAbstractMethod +{ + public function baz() + { + return $this->doBaz(); + } + + abstract public function doBaz(); +} diff --git a/vendor/mockery/mockery/tests/Mockery/WithFormatterExpectationTest.php b/vendor/mockery/mockery/tests/Mockery/WithFormatterExpectationTest.php new file mode 100644 index 000000000..2e3c4f922 --- /dev/null +++ b/vendor/mockery/mockery/tests/Mockery/WithFormatterExpectationTest.php @@ -0,0 +1,123 @@ +assertEquals( + $expected, + Mockery::formatObjects($args) + ); + } + + /** + * @expectedException Mockery\Exception\NoMatchingExpectationException + * + * Note that without the patch checked in with this test, rather than throwing + * an exception, the program will go into an infinite recursive loop + */ + public function testFormatObjectsWithMockCalledInGetterDoesNotLeadToRecursion() + { + $mock = Mockery::mock('stdClass'); + $mock->shouldReceive('doBar')->with('foo'); + $obj = new ClassWithGetter($mock); + $obj->getFoo(); + } + + public function formatObjectsDataProvider() + { + return array( + array( + array(null), + '' + ), + array( + array('a string', 98768, array('a', 'nother', 'array')), + '' + ), + ); + } + + /** @test */ + public function format_objects_should_not_call_getters_with_params() + { + $obj = new ClassWithGetterWithParam(); + $string = Mockery::formatObjects(array($obj)); + + $this->assertNotContains('Missing argument 1 for', $string); + } + + public function testFormatObjectsExcludesStaticProperties() + { + $obj = new ClassWithPublicStaticProperty(); + $string = Mockery::formatObjects(array($obj)); + + $this->assertNotContains('excludedProperty', $string); + } + + public function testFormatObjectsExcludesStaticGetters() + { + $obj = new ClassWithPublicStaticGetter(); + $string = Mockery::formatObjects(array($obj)); + + $this->assertNotContains('getExcluded', $string); + } +} + +class ClassWithGetter +{ + private $dep; + + public function __construct($dep) + { + $this->dep = $dep; + } + + public function getFoo() + { + return $this->dep->doBar('bar', $this); + } +} + +class ClassWithGetterWithParam +{ + public function getBar($bar) + { + } +} + +class ClassWithPublicStaticProperty +{ + public static $excludedProperty; +} + +class ClassWithPublicStaticGetter +{ + public static function getExcluded() + { + } +} diff --git a/vendor/mockery/mockery/tests/Mockery/_files/file.txt b/vendor/mockery/mockery/tests/Mockery/_files/file.txt new file mode 100644 index 000000000..e69de29bb diff --git a/vendor/mockery/mockery/tests/PHP56/MockingOldStyleConstructorTest.php b/vendor/mockery/mockery/tests/PHP56/MockingOldStyleConstructorTest.php new file mode 100644 index 000000000..89e66c07b --- /dev/null +++ b/vendor/mockery/mockery/tests/PHP56/MockingOldStyleConstructorTest.php @@ -0,0 +1,44 @@ +assertInstanceOf(MockInterface::class, mock('MockeryTest_OldStyleConstructor')); + } +} + +class MockeryTest_OldStyleConstructor +{ + public function MockeryTest_OldStyleConstructor($arg) + { + } +} diff --git a/vendor/mockery/mockery/tests/PHP70/Generator/StringManipulation/Pass/MagicMethodTypeHintsPassTest.php b/vendor/mockery/mockery/tests/PHP70/Generator/StringManipulation/Pass/MagicMethodTypeHintsPassTest.php new file mode 100644 index 000000000..a1957ff19 --- /dev/null +++ b/vendor/mockery/mockery/tests/PHP70/Generator/StringManipulation/Pass/MagicMethodTypeHintsPassTest.php @@ -0,0 +1,392 @@ +pass = new MagicMethodTypeHintsPass; + $this->mockedConfiguration = m::mock( + 'Mockery\Generator\MockConfiguration' + ); + } + + /** + * @test + */ + public function itShouldWork() + { + $this->assertTrue(true); + } + + /** + * @test + */ + public function itShouldGrabClassMagicMethods() + { + $targetClass = DefinedTargetClass::factory( + 'Mockery\Test\Generator\StringManipulation\Pass\MagicDummy' + ); + $magicMethods = $this->pass->getMagicMethods($targetClass); + + $this->assertCount(6, $magicMethods); + $this->assertEquals('__isset', $magicMethods[0]->getName()); + } + + /** + * @test + */ + public function itShouldGrabInterfaceMagicMethods() + { + $targetClass = DefinedTargetClass::factory( + 'Mockery\Test\Generator\StringManipulation\Pass\MagicInterfaceDummy' + ); + $magicMethods = $this->pass->getMagicMethods($targetClass); + + $this->assertCount(6, $magicMethods); + $this->assertEquals('__isset', $magicMethods[0]->getName()); + } + + /** + * @test + */ + public function itShouldAddStringTypeHintOnMagicMethod() + { + $this->configureForClass(); + $code = $this->pass->apply( + 'public function __isset($name) {}', + $this->mockedConfiguration + ); + $this->assertContains('string $name', $code); + + $this->configureForInterface(); + $code = $this->pass->apply( + 'public function __isset($name) {}', + $this->mockedConfiguration + ); + $this->assertContains('string $name', $code); + } + + /** + * @test + */ + public function itShouldAddStringTypeHintOnAllMagicMethods() + { + $this->configureForInterfaces([ + 'Mockery\Test\Generator\StringManipulation\Pass\MagicInterfaceDummy', + 'Mockery\Test\Generator\StringManipulation\Pass\MagicUnsetInterfaceDummy' + ]); + $code = $this->pass->apply( + 'public function __isset($name) {}', + $this->mockedConfiguration + ); + $this->assertContains('string $name', $code); + $code = $this->pass->apply( + 'public function __unset($name) {}', + $this->mockedConfiguration + ); + $this->assertContains('string $name', $code); + } + + /** + * @test + */ + public function itShouldAddBooleanReturnOnMagicMethod() + { + $this->configureForClass(); + $code = $this->pass->apply( + 'public function __isset($name) {}', + $this->mockedConfiguration + ); + $this->assertContains(' : bool', $code); + + $this->configureForInterface(); + $code = $this->pass->apply( + 'public function __isset($name) {}', + $this->mockedConfiguration + ); + $this->assertContains(' : bool', $code); + } + + /** + * @test + */ + public function itShouldAddTypeHintsOnToStringMethod() + { + $this->configureForClass(); + $code = $this->pass->apply( + 'public function __toString() {}', + $this->mockedConfiguration + ); + $this->assertContains(' : string', $code); + + $this->configureForInterface(); + $code = $this->pass->apply( + 'public function __toString() {}', + $this->mockedConfiguration + ); + $this->assertContains(' : string', $code); + } + + /** + * @test + */ + public function itShouldAddTypeHintsOnCallMethod() + { + $this->configureForClass(); + $code = $this->pass->apply( + 'public function __call($method, array $args) {}', + $this->mockedConfiguration + ); + $this->assertContains('string $method', $code); + + $this->configureForInterface(); + $code = $this->pass->apply( + 'public function __call($method, array $args) {}', + $this->mockedConfiguration + ); + $this->assertContains('string $method', $code); + } + + /** + * @test + */ + public function itShouldAddTypeHintsOnCallStaticMethod() + { + $this->configureForClass(); + $code = $this->pass->apply( + 'public static function __callStatic($method, array $args) {}', + $this->mockedConfiguration + ); + $this->assertContains('string $method', $code); + + $this->configureForInterface(); + $code = $this->pass->apply( + 'public static function __callStatic($method, array $args) {}', + $this->mockedConfiguration + ); + $this->assertContains('string $method', $code); + } + + /** + * @test + */ + public function itShouldNotAddReturnTypeHintIfOneIsNotFound() + { + $this->configureForClass('Mockery\Test\Generator\StringManipulation\Pass\MagicReturnDummy'); + $code = $this->pass->apply( + 'public static function __isset($parameter) {}', + $this->mockedConfiguration + ); + $this->assertContains(') {', $code); + + $this->configureForInterface('Mockery\Test\Generator\StringManipulation\Pass\MagicReturnInterfaceDummy'); + $code = $this->pass->apply( + 'public static function __isset($parameter) {}', + $this->mockedConfiguration + ); + $this->assertContains(') {', $code); + } + + /** + * @test + */ + public function itShouldReturnEmptyArrayIfClassDoesNotHaveMagicMethods() + { + $targetClass = DefinedTargetClass::factory( + '\StdClass' + ); + $magicMethods = $this->pass->getMagicMethods($targetClass); + $this->assertInternalType('array', $magicMethods); + $this->assertEmpty($magicMethods); + } + + /** + * @test + */ + public function itShouldReturnEmptyArrayIfClassTypeIsNotExpected() + { + $magicMethods = $this->pass->getMagicMethods(null); + $this->assertInternalType('array', $magicMethods); + $this->assertEmpty($magicMethods); + } + + /** + * Tests if the pass correclty replaces all the magic + * method parameters with those found in the + * Mock class. This is made to avoid variable + * conflicts withing Mock's magic methods + * implementations. + * + * @test + */ + public function itShouldGrabAndReplaceAllParametersWithTheCodeStringMatches() + { + $this->configureForClass(); + $code = $this->pass->apply( + 'public function __call($method, array $args) {}', + $this->mockedConfiguration + ); + $this->assertContains('$method', $code); + $this->assertContains('array $args', $code); + + $this->configureForInterface(); + $code = $this->pass->apply( + 'public function __call($method, array $args) {}', + $this->mockedConfiguration + ); + $this->assertContains('$method', $code); + $this->assertContains('array $args', $code); + } + + protected function configureForClass(string $className = 'Mockery\Test\Generator\StringManipulation\Pass\MagicDummy') + { + $targetClass = DefinedTargetClass::factory($className); + + $this->mockedConfiguration + ->shouldReceive('getTargetClass') + ->andReturn($targetClass) + ->byDefault(); + $this->mockedConfiguration + ->shouldReceive('getTargetInterfaces') + ->andReturn([]) + ->byDefault(); + } + + protected function configureForInterface(string $interfaceName = 'Mockery\Test\Generator\StringManipulation\Pass\MagicDummy') + { + $targetInterface = DefinedTargetClass::factory($interfaceName); + + $this->mockedConfiguration + ->shouldReceive('getTargetClass') + ->andReturn(null) + ->byDefault(); + $this->mockedConfiguration + ->shouldReceive('getTargetInterfaces') + ->andReturn([$targetInterface]) + ->byDefault(); + } + + protected function configureForInterfaces(array $interfaceNames) + { + $targetInterfaces = array_map([DefinedTargetClass::class, 'factory'], $interfaceNames); + + $this->mockedConfiguration + ->shouldReceive('getTargetClass') + ->andReturn(null) + ->byDefault(); + $this->mockedConfiguration + ->shouldReceive('getTargetInterfaces') + ->andReturn($targetInterfaces) + ->byDefault(); + } +} + +class MagicDummy +{ + public function __isset(string $name) : bool + { + return false; + } + + public function __toString() : string + { + return ''; + } + + public function __wakeup() + { + } + + public function __destruct() + { + } + + public function __call(string $name, array $arguments) : string + { + } + + public static function __callStatic(string $name, array $arguments) : int + { + } + + public function nonMagicMethod() + { + } +} + +class MagicReturnDummy +{ + public function __isset(string $name) + { + return false; + } +} + +interface MagicInterfaceDummy +{ + public function __isset(string $name) : bool; + + public function __toString() : string; + + public function __wakeup(); + + public function __destruct(); + + public function __call(string $name, array $arguments) : string; + + public static function __callStatic(string $name, array $arguments) : int; + + public function nonMagicMethod(); +} + +interface MagicReturnInterfaceDummy +{ + public function __isset(string $name); +} + +interface MagicUnsetInterfaceDummy +{ + public function __unset(string $name); +} diff --git a/vendor/mockery/mockery/tests/PHP70/MockingParameterAndReturnTypesTest.php b/vendor/mockery/mockery/tests/PHP70/MockingParameterAndReturnTypesTest.php new file mode 100644 index 000000000..690625f60 --- /dev/null +++ b/vendor/mockery/mockery/tests/PHP70/MockingParameterAndReturnTypesTest.php @@ -0,0 +1,177 @@ +shouldReceive("returnString"); + $this->assertSame("", $mock->returnString()); + } + + public function testMockingIntegerReturnType() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldReceive("returnInteger"); + $this->assertSame(0, $mock->returnInteger()); + } + + public function testMockingFloatReturnType() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldReceive("returnFloat"); + $this->assertSame(0.0, $mock->returnFloat()); + } + + public function testMockingBooleanReturnType() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldReceive("returnBoolean"); + $this->assertFalse($mock->returnBoolean()); + } + + public function testMockingArrayReturnType() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldReceive("returnArray"); + $this->assertSame([], $mock->returnArray()); + } + + public function testMockingGeneratorReturnTyps() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldReceive("returnGenerator"); + $this->assertInstanceOf("\Generator", $mock->returnGenerator()); + } + + public function testMockingCallableReturnType() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldReceive("returnCallable"); + $this->assertInternalType('callable', $mock->returnCallable()); + } + + public function testMockingClassReturnTypes() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldReceive("withClassReturnType"); + $this->assertInstanceOf("test\Mockery\TestWithParameterAndReturnType", $mock->withClassReturnType()); + } + + public function testMockingParameterTypes() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldReceive("withScalarParameters"); + $mock->withScalarParameters(1, 1.0, true, 'string'); + } + + public function testIgnoringMissingReturnsType() + { + $mock = mock("test\Mockery\TestWithParameterAndReturnType"); + + $mock->shouldIgnoreMissing(); + + $this->assertSame('', $mock->returnString()); + $this->assertSame(0, $mock->returnInteger()); + $this->assertSame(0.0, $mock->returnFloat()); + $this->assertFalse( $mock->returnBoolean()); + $this->assertSame([], $mock->returnArray()); + $this->assertInternalType('callable', $mock->returnCallable()); + $this->assertInstanceOf("\Generator", $mock->returnGenerator()); + $this->assertInstanceOf("test\Mockery\TestWithParameterAndReturnType", $mock->withClassReturnType()); + } + + public function testAutoStubbingSelf() + { + $spy = \Mockery::spy("test\Mockery\TestWithParameterAndReturnType"); + + $this->assertInstanceOf("test\Mockery\TestWithParameterAndReturnType", $spy->returnSelf()); + } + + public function testItShouldMockClassWithHintedParamsInMagicMethod() + { + $this->assertNotNull( + \Mockery::mock('test\Mockery\MagicParams') + ); + } + + public function testItShouldMockClassWithHintedReturnInMagicMethod() + { + $this->assertNotNull( + \Mockery::mock('test\Mockery\MagicReturns') + ); + } +} + +class MagicParams +{ + public function __isset(string $property) + { + return false; + } +} + +class MagicReturns +{ + public function __isset($property) : bool + { + return false; + } +} + +abstract class TestWithParameterAndReturnType +{ + public function returnString(): string {} + + public function returnInteger(): int {} + + public function returnFloat(): float {} + + public function returnBoolean(): bool {} + + public function returnArray(): array {} + + public function returnCallable(): callable {} + + public function returnGenerator(): \Generator {} + + public function withClassReturnType(): TestWithParameterAndReturnType {} + + public function withScalarParameters(int $integer, float $float, bool $boolean, string $string) {} + + public function returnSelf(): self {} +} diff --git a/vendor/mockery/mockery/tests/PHP72/Php72LanguageFeaturesTest.php b/vendor/mockery/mockery/tests/PHP72/Php72LanguageFeaturesTest.php new file mode 100644 index 000000000..f6fb957a4 --- /dev/null +++ b/vendor/mockery/mockery/tests/PHP72/Php72LanguageFeaturesTest.php @@ -0,0 +1,45 @@ +allows()->foo($object); + + $mock->foo($object); + } + + /** @test */ + public function it_can_mock_a_class_with_an_object_return_type_hint() + { + $mock = spy(ReturnTypeObjectTypeHint::class); + + $object = $mock->foo(); + + $this->assertTrue(is_object($object)); + } +} + +class ArgumentObjectTypeHint +{ + public function foo(object $foo) + { + } +} + +class ReturnTypeObjectTypeHint +{ + public function foo(): object + { + } +}